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
Messdatenerfassung.cpp@11:7dfdb8074992, 2015-06-09 (annotated)
- Committer:
- thorb3n
- Date:
- Tue Jun 09 11:17:32 2015 +0000
- Revision:
- 11:7dfdb8074992
- Parent:
- 9:b1bf6699d610
- Child:
- 12:bad33209d1bb
messdaten bearbeitet;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thorb3n | 1:4d1b3fffabd5 | 1 | #include "mbed.h" |
thorb3n | 11:7dfdb8074992 | 2 | constant mosfet1_resistence; |
thorb3n | 7:ed9a83df000a | 3 | AnalogIn voltage0(A0); // Edit Pin-Port for the accu-voltage measurement |
thorb3n | 7:ed9a83df000a | 4 | AnalogIn voltage1(A1); // Edit Pin-Port for the throttle-voltage measurement |
thorb3n | 7:ed9a83df000a | 5 | AnalogIn voltage2(A2); // Edit Pin-Port for the capacitor-voltage measurement |
thorb3n | 8:fb6cb712eb52 | 6 | DigitalIn breaksensor(PA_5); //Edit Pin-Port for the breaksensor measurement! |
thorb3n | 11:7dfdb8074992 | 7 | AnalogIn voltage3(A3); // Pin-Port for voltage before Mosfet1 |
thorb3n | 11:7dfdb8074992 | 8 | AnalogIn voltage4(A4); // Pin-Port for voltage after Mosfet2 |
thorb3n | 11:7dfdb8074992 | 9 | Timer timer; // Timer for Capacity-Measurement |
thorb3n | 7:ed9a83df000a | 10 | float Accu_Voltage(){ |
thorb3n | 7:ed9a83df000a | 11 | |
thorb3n | 7:ed9a83df000a | 12 | float meas0; |
thorb3n | 7:ed9a83df000a | 13 | meas0 = voltage0.read(); // read adc value |
thorb3n | 7:ed9a83df000a | 14 | return meas0; // return value |
scooter_project | 5:d213c03872fe | 15 | } |
scooter_project | 5:d213c03872fe | 16 | |
thorb3n | 7:ed9a83df000a | 17 | float hall_umrechnung(){ |
thorb3n | 7:ed9a83df000a | 18 | float meas0; |
thorb3n | 8:fb6cb712eb52 | 19 | meas0 = voltage1.read() - 0.27; // read adc and rearange the voltage_value,because its 0.27 when the throttle is off |
thorb3n | 7:ed9a83df000a | 20 | |
thorb3n | 7:ed9a83df000a | 21 | if(meas0 < 0){ // meas0 isnt allowed to be <0 because its sets the pulsewidht of the pwm |
thorb3n | 7:ed9a83df000a | 22 | meas0 = 0; |
thorb3n | 7:ed9a83df000a | 23 | } |
scooter_project | 5:d213c03872fe | 24 | |
thorb3n | 7:ed9a83df000a | 25 | meas0 = meas0*2; // creates values between 0 and 1 |
thorb3n | 7:ed9a83df000a | 26 | |
thorb3n | 7:ed9a83df000a | 27 | if(meas0 > 1){ // meas0 isnt allowed to be >1 because its sets the pulsewidth of the pwm |
scooter_project | 5:d213c03872fe | 28 | meas0 = 1; |
thorb3n | 7:ed9a83df000a | 29 | } |
thorb3n | 7:ed9a83df000a | 30 | |
thorb3n | 7:ed9a83df000a | 31 | return meas0; // return value |
scooter_project | 5:d213c03872fe | 32 | } |
scooter_project | 5:d213c03872fe | 33 | |
thorb3n | 7:ed9a83df000a | 34 | float Capacitor_Voltage(){ |
thorb3n | 7:ed9a83df000a | 35 | |
thorb3n | 7:ed9a83df000a | 36 | float meas0; |
thorb3n | 8:fb6cb712eb52 | 37 | meas0 = voltage2.read(); //read adc value |
thorb3n | 7:ed9a83df000a | 38 | return meas0; // return value |
thorb3n | 7:ed9a83df000a | 39 | } |
scooter_project | 9:b1bf6699d610 | 40 | |
thorb3n | 8:fb6cb712eb52 | 41 | int break_value(){ |
thorb3n | 8:fb6cb712eb52 | 42 | int break_value; |
thorb3n | 8:fb6cb712eb52 | 43 | break_value = breaksensor.read(); // read breaksensor value(1/0) |
thorb3n | 8:fb6cb712eb52 | 44 | return break_value; // return value |
thorb3n | 11:7dfdb8074992 | 45 | } |
thorb3n | 11:7dfdb8074992 | 46 | float accu_charge(){ |
thorb3n | 11:7dfdb8074992 | 47 | float accu_charge,current; |
thorb3n | 8:fb6cb712eb52 | 48 | |
thorb3n | 11:7dfdb8074992 | 49 | voltage_before = voltage3.read()*12.0; |
thorb3n | 11:7dfdb8074992 | 50 | voltage_after = voltage4.read()*12.0; |
thorb3n | 11:7dfdb8074992 | 51 | current = (voltage_before - voltage_after)/(mosfet1_resistence); |
thorb3n | 11:7dfdb8074992 | 52 | accu_charge = capacity - current ; |
thorb3n | 11:7dfdb8074992 | 53 | timer.start() |
thorb3n | 11:7dfdb8074992 | 54 | while(timer.read() < |
thorb3n | 11:7dfdb8074992 | 55 | |
thorb3n | 11:7dfdb8074992 | 56 | |
thorb3n | 11:7dfdb8074992 | 57 | |
thorb3n | 11:7dfdb8074992 | 58 | } |