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@7:ed9a83df000a, 2015-05-19 (annotated)
- Committer:
- thorb3n
- Date:
- Tue May 19 15:49:46 2015 +0000
- Revision:
- 7:ed9a83df000a
- Parent:
- 5:d213c03872fe
- Child:
- 8:fb6cb712eb52
update der messdatenerfassung und kommentierung
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thorb3n | 1:4d1b3fffabd5 | 1 | #include "mbed.h" |
thorb3n | 7:ed9a83df000a | 2 | |
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 | 7:ed9a83df000a | 6 | |
thorb3n | 7:ed9a83df000a | 7 | float Accu_Voltage(){ |
thorb3n | 7:ed9a83df000a | 8 | |
thorb3n | 7:ed9a83df000a | 9 | float meas0; |
thorb3n | 7:ed9a83df000a | 10 | meas0 = voltage0.read(); // read adc value |
thorb3n | 7:ed9a83df000a | 11 | return meas0; // return value |
scooter_project | 5:d213c03872fe | 12 | } |
scooter_project | 5:d213c03872fe | 13 | |
thorb3n | 7:ed9a83df000a | 14 | float hall_umrechnung(){ |
thorb3n | 7:ed9a83df000a | 15 | float meas0; |
thorb3n | 7:ed9a83df000a | 16 | meas0 = voltage1read() - 0.27; // read adc and rearange the voltage_value,because its 0.27 when the throttle is off |
thorb3n | 7:ed9a83df000a | 17 | |
thorb3n | 7:ed9a83df000a | 18 | if(meas0 < 0){ // meas0 isnt allowed to be <0 because its sets the pulsewidht of the pwm |
thorb3n | 7:ed9a83df000a | 19 | meas0 = 0; |
thorb3n | 7:ed9a83df000a | 20 | } |
scooter_project | 5:d213c03872fe | 21 | |
thorb3n | 7:ed9a83df000a | 22 | meas0 = meas0*2; // creates values between 0 and 1 |
thorb3n | 7:ed9a83df000a | 23 | |
thorb3n | 7:ed9a83df000a | 24 | if(meas0 > 1){ // meas0 isnt allowed to be >1 because its sets the pulsewidth of the pwm |
scooter_project | 5:d213c03872fe | 25 | meas0 = 1; |
thorb3n | 7:ed9a83df000a | 26 | } |
thorb3n | 7:ed9a83df000a | 27 | |
thorb3n | 7:ed9a83df000a | 28 | return meas0; // return value |
scooter_project | 5:d213c03872fe | 29 | } |
scooter_project | 5:d213c03872fe | 30 | |
thorb3n | 7:ed9a83df000a | 31 | float Capacitor_Voltage(){ |
thorb3n | 7:ed9a83df000a | 32 | |
thorb3n | 7:ed9a83df000a | 33 | float meas0; |
thorb3n | 7:ed9a83df000a | 34 | meas0 = avoltage2.read(); //read adc value |
thorb3n | 7:ed9a83df000a | 35 | return meas0; // return value |
thorb3n | 7:ed9a83df000a | 36 | } |