projekte:hardware_tricks:batterie_messungen:rc_glied_messung
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
| projekte:hardware_tricks:batterie_messungen:rc_glied_messung [2018-07-25 22:25] – [Formeln] gamecompiler | projekte:hardware_tricks:batterie_messungen:rc_glied_messung [2022-11-17 22:34] (aktuell) – Externe Bearbeitung 127.0.0.1 | ||
|---|---|---|---|
| Zeile 4: | Zeile 4: | ||
| ===== Formeln ===== | ===== Formeln ===== | ||
| - | Die 3.3V Spannungsquelle soll die " | ||
| - | Im Falle eines 5V Arduinos 5V. Diese Spannungsquelle ist die Betriebsspannung des CPUs. | ||
| {{: | {{: | ||
| ===== Schaltplan ===== | ===== Schaltplan ===== | ||
| + | |||
| + | Die 3.3V Spannungsquelle soll die " | ||
| + | Im Falle eines 5V Arduinos 5V. Diese Spannungsquelle ist die Betriebsspannung des CPUs. | ||
| {{: | {{: | ||
| Zeile 49: | Zeile 50: | ||
| Serial.println(meassureVoltage()); | Serial.println(meassureVoltage()); | ||
| } | } | ||
| + | </ | ||
| + | |||
| + | ===== Code - Java RaspberryPi ===== | ||
| + | <file java RC_meassure.java> | ||
| + | package rc_meassure; | ||
| + | |||
| + | import com.pi4j.io.gpio.GpioController; | ||
| + | import com.pi4j.io.gpio.GpioFactory; | ||
| + | import com.pi4j.io.gpio.GpioPinDigitalInput; | ||
| + | import com.pi4j.io.gpio.GpioPinDigitalOutput; | ||
| + | import com.pi4j.io.gpio.Pin; | ||
| + | import com.pi4j.io.gpio.PinState; | ||
| + | import com.pi4j.io.gpio.RaspiPin; | ||
| + | import static java.lang.Math.pow; | ||
| + | import java.util.concurrent.TimeUnit; | ||
| + | |||
| + | /** | ||
| + | * | ||
| + | * In einer echten Java Anwendung würde man das nicht so machen, das dient wirklich nur als Beispiel. | ||
| + | */ | ||
| + | public class RC_meassure { | ||
| + | |||
| + | /** | ||
| + | * @param args the command line arguments | ||
| + | */ | ||
| + | static Pin rcPin = RaspiPin.GPIO_00; | ||
| + | static final int r = 100000; | ||
| + | static final float c = (float) (100 * pow(10, -9)); | ||
| + | /** | ||
| + | * Vih = 0.625*Vdd | ||
| + | * http:// | ||
| + | */ | ||
| + | static final float vih = (float) 2.976473; | ||
| + | public static void main(String[] args) throws InterruptedException { | ||
| + | GpioController gpio = GpioFactory.getInstance(); | ||
| + | gpio.unexportAll(); | ||
| + | final GpioPinDigitalOutput outPin = gpio.provisionDigitalOutputPin(rcPin); | ||
| + | outPin.setShutdownOptions(true, | ||
| + | outPin.low(); | ||
| + | | ||
| + | TimeUnit.SECONDS.sleep(1); | ||
| + | // | ||
| + | gpio.unprovisionPin(outPin); | ||
| + | | ||
| + | long startTime = System.nanoTime(); | ||
| + | final GpioPinDigitalInput inPin = gpio.provisionDigitalInputPin(rcPin); | ||
| + | | ||
| + | while(inPin.isLow()){ //warte | ||
| + | | ||
| + | } | ||
| + | long estimatedTime = System.nanoTime() - startTime; | ||
| + | gpio.unprovisionPin(inPin); | ||
| + | System.out.println(estimatedTime); | ||
| + | System.out.println(" | ||
| + | } | ||
| + | static float meassureRCVoltage(long t, float r, float c, float vih_voltage){ | ||
| + | float vbat = (vih_voltage * c * r) /((float)(t * pow(10, -9))); | ||
| + | return vbat; | ||
| + | } | ||
| + | } | ||
| + | |||
| </ | </ | ||
projekte/hardware_tricks/batterie_messungen/rc_glied_messung.1532550306.txt.gz · Zuletzt geändert: (Externe Bearbeitung)
