scooter / Mbed 2 deprecated Scooter-uC-Programm

Dependencies:   mbed

Committer:
thorb3n
Date:
Tue May 26 12:14:44 2015 +0000
Revision:
8:fb6cb712eb52
Parent:
7:ed9a83df000a
Child:
9:b1bf6699d610
beleuchtung

Who changed what in which revision?

UserRevisionLine numberNew 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 8:fb6cb712eb52 6 DigitalIn breaksensor(PA_5); //Edit Pin-Port for the breaksensor measurement!
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 8:fb6cb712eb52 16 meas0 = voltage1.read() - 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 8:fb6cb712eb52 34 meas0 = voltage2.read(); //read adc value
thorb3n 7:ed9a83df000a 35 return meas0; // return value
thorb3n 7:ed9a83df000a 36 }
thorb3n 8:fb6cb712eb52 37 int break_value(){
thorb3n 8:fb6cb712eb52 38 int break_value;
thorb3n 8:fb6cb712eb52 39 break_value = breaksensor.read(); // read breaksensor value(1/0)
thorb3n 8:fb6cb712eb52 40 return break_value; // return value
thorb3n 8:fb6cb712eb52 41
thorb3n 8:fb6cb712eb52 42 }