Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: Messdatenerfassung.cpp
- Revision:
- 12:bad33209d1bb
- Parent:
- 11:7dfdb8074992
- Child:
- 13:565aa2c6bd3d
--- a/Messdatenerfassung.cpp Tue Jun 09 11:17:32 2015 +0000 +++ b/Messdatenerfassung.cpp Tue Jun 23 10:49:55 2015 +0000 @@ -1,13 +1,13 @@ #include "mbed.h" -constant mosfet1_resistence; -AnalogIn voltage0(A0); // Edit Pin-Port for the accu-voltage measurement +const int mosfet1_resistence = 100; // Resistence in Ohm +AnalogIn voltage0(A0); // Edit Pin-Port for the battery-voltage measurement AnalogIn voltage1(A1); // Edit Pin-Port for the throttle-voltage measurement AnalogIn voltage2(A2); // Edit Pin-Port for the capacitor-voltage measurement DigitalIn breaksensor(PA_5); //Edit Pin-Port for the breaksensor measurement! AnalogIn voltage3(A3); // Pin-Port for voltage before Mosfet1 AnalogIn voltage4(A4); // Pin-Port for voltage after Mosfet2 -Timer timer; // Timer for Capacity-Measurement -float Accu_Voltage(){ +Timer timer2; // Timer for Capacity-Measurement +float accu_voltage(){ float meas0; meas0 = voltage0.read(); // read adc value @@ -30,29 +30,35 @@ return meas0; // return value } - +//-------------Code für Bremsenergierückgewinnung--------------- +/* float Capacitor_Voltage(){ float meas0; meas0 = voltage2.read(); //read adc value return meas0; // return value } - +*/ //----------------------------------------------------------- int break_value(){ int break_value; break_value = breaksensor.read(); // read breaksensor value(1/0) return break_value; // return value } -float accu_charge(){ - float accu_charge,current; - - voltage_before = voltage3.read()*12.0; - voltage_after = voltage4.read()*12.0; - current = (voltage_before - voltage_after)/(mosfet1_resistence); - accu_charge = capacity - current ; - timer.start() - while(timer.read() < - - - - } \ No newline at end of file +float battery_charge(){ + Timer timer2; + float battery_charge,current; + int time,voltage_before,voltage_after; + voltage_before = voltage3.read()*12.0; // voltage in V + voltage_after = voltage4.read()*12.0; // voltage in V + current = (voltage_before - voltage_after)/(mosfet1_resistence); // current in A + timer2.start(); // Timer start + time = timer2.read_ms(); + while(time < 10){ // loop to get 0.01s delay + ; + } + timer2.stop(); + timer2.reset(); + + battery_charge = battery_charge - current*0.01; + return battery_charge; + } \ No newline at end of file