v

Committer:
thorb3n
Date:
Mon Feb 22 09:20:32 2016 +0000
Revision:
1:377ad5dc13e3
Parent:
0:13fa5527033b
v

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thorb3n 0:13fa5527033b 1 #include "pins.h"
thorb3n 0:13fa5527033b 2 #include "mbed.h"
thorb3n 1:377ad5dc13e3 3 #include "messen.h"
thorb3n 0:13fa5527033b 4 AnalogIn throttle(SPEED_PIN);
thorb3n 0:13fa5527033b 5 DigitalIn breake(BREAKE_PIN);
thorb3n 0:13fa5527033b 6 AnalogIn voltage(VOLTAGE_PIN);
thorb3n 0:13fa5527033b 7 AnalogIn current(CURRENT_PIN);
thorb3n 0:13fa5527033b 8
thorb3n 0:13fa5527033b 9 float getSpeed(){
thorb3n 0:13fa5527033b 10 float speed = throttle.read() -0.27;
thorb3n 0:13fa5527033b 11 if(speed < 0){ // meas0 isnt allowed to be <0 because its sets the pulsewidht of the pwm
thorb3n 0:13fa5527033b 12 speed = 0;
thorb3n 0:13fa5527033b 13 }
thorb3n 0:13fa5527033b 14 speed *= 2; // creates values between 0 and 1
thorb3n 0:13fa5527033b 15 if(speed > 1){ // meas0 isnt allowed to be >1 because its sets the pulsewidth of the pwm
thorb3n 0:13fa5527033b 16 speed = 1;
thorb3n 0:13fa5527033b 17 }
thorb3n 0:13fa5527033b 18 return speed;
thorb3n 0:13fa5527033b 19 }
thorb3n 0:13fa5527033b 20
thorb3n 0:13fa5527033b 21 int getBreake(){
thorb3n 0:13fa5527033b 22 int breake_value = breake.read();
thorb3n 0:13fa5527033b 23 return breake_value;
thorb3n 0:13fa5527033b 24 }
thorb3n 0:13fa5527033b 25
thorb3n 0:13fa5527033b 26 float getVoltage(){
thorb3n 0:13fa5527033b 27 float voltage_value = voltage.read();
thorb3n 0:13fa5527033b 28 return voltage_value;
thorb3n 0:13fa5527033b 29 }
thorb3n 0:13fa5527033b 30
thorb3n 0:13fa5527033b 31 float getCurrent(){
thorb3n 0:13fa5527033b 32 float current_value = current.read();
thorb3n 0:13fa5527033b 33 return current_value;
thorb3n 0:13fa5527033b 34 }