Custom version for NXP cup car
Diff: MotorControl.h
- Revision:
- 0:a1bb4583940a
- Child:
- 1:7ce4ffeb8ccb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MotorControl.h Thu Mar 24 20:12:32 2016 +0000 @@ -0,0 +1,40 @@ +#include "mbed.h" +#include "TFC.h" + +#ifndef _MOTORCONTROL_H +#define _MOTORCONTROL_H + +#define MOTSAMPLECOUNT 100 +#define BATSAMPLECOUNT 100 + +class Motors +{ + public: + + Motors(); + void start(); + void stop(); + void saveBatteryVoltageMeasure(uint16_t ADCresult); + void saveMotorCurrentMeasure(uint16_t MotA_ADCresult, uint16_t MotB_ADCresult); + void saveSteering(float angle); + float getWheelSpeed(char mot); + float getWheelRPS(char mot); + void processTasks(); + float getAverageMotCurrent(char mot); + float getAverageBatteryVoltage(); + void setFixedPWMValue(float pwm); + + private: + + uint16_t motorACurrent[MOTSAMPLECOUNT]; + uint16_t motorBCurrent[MOTSAMPLECOUNT]; + uint16_t batteryVoltage[BATSAMPLECOUNT]; + + uint8_t motorCurrentIndex; + uint8_t batVoltageIndex; + + float currentPWM; + float steeringAngle; +}; + +#endif \ No newline at end of file