Custom version for NXP cup car
MotorControl.h@1:7ce4ffeb8ccb, 2016-03-25 (annotated)
- Committer:
- Clarkk
- Date:
- Fri Mar 25 13:03:59 2016 +0000
- Revision:
- 1:7ce4ffeb8ccb
- Parent:
- 0:a1bb4583940a
- Child:
- 2:0d5c994d8135
Few updates
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Clarkk | 0:a1bb4583940a | 1 | #include "mbed.h" |
Clarkk | 0:a1bb4583940a | 2 | #include "TFC.h" |
Clarkk | 0:a1bb4583940a | 3 | |
Clarkk | 0:a1bb4583940a | 4 | #ifndef _MOTORCONTROL_H |
Clarkk | 0:a1bb4583940a | 5 | #define _MOTORCONTROL_H |
Clarkk | 0:a1bb4583940a | 6 | |
Clarkk | 0:a1bb4583940a | 7 | #define MOTSAMPLECOUNT 100 |
Clarkk | 1:7ce4ffeb8ccb | 8 | #define BATSAMPLECOUNT 50 |
Clarkk | 0:a1bb4583940a | 9 | |
Clarkk | 0:a1bb4583940a | 10 | class Motors |
Clarkk | 0:a1bb4583940a | 11 | { |
Clarkk | 0:a1bb4583940a | 12 | public: |
Clarkk | 0:a1bb4583940a | 13 | |
Clarkk | 0:a1bb4583940a | 14 | Motors(); |
Clarkk | 0:a1bb4583940a | 15 | void start(); |
Clarkk | 0:a1bb4583940a | 16 | void stop(); |
Clarkk | 0:a1bb4583940a | 17 | void saveBatteryVoltageMeasure(uint16_t ADCresult); |
Clarkk | 0:a1bb4583940a | 18 | void saveMotorCurrentMeasure(uint16_t MotA_ADCresult, uint16_t MotB_ADCresult); |
Clarkk | 0:a1bb4583940a | 19 | void saveSteering(float angle); |
Clarkk | 0:a1bb4583940a | 20 | float getWheelSpeed(char mot); |
Clarkk | 0:a1bb4583940a | 21 | float getWheelRPS(char mot); |
Clarkk | 0:a1bb4583940a | 22 | void processTasks(); |
Clarkk | 0:a1bb4583940a | 23 | float getAverageMotCurrent(char mot); |
Clarkk | 0:a1bb4583940a | 24 | float getAverageBatteryVoltage(); |
Clarkk | 0:a1bb4583940a | 25 | void setFixedPWMValue(float pwm); |
Clarkk | 0:a1bb4583940a | 26 | |
Clarkk | 0:a1bb4583940a | 27 | private: |
Clarkk | 0:a1bb4583940a | 28 | |
Clarkk | 0:a1bb4583940a | 29 | uint16_t motorACurrent[MOTSAMPLECOUNT]; |
Clarkk | 0:a1bb4583940a | 30 | uint16_t motorBCurrent[MOTSAMPLECOUNT]; |
Clarkk | 0:a1bb4583940a | 31 | uint16_t batteryVoltage[BATSAMPLECOUNT]; |
Clarkk | 0:a1bb4583940a | 32 | |
Clarkk | 0:a1bb4583940a | 33 | uint8_t motorCurrentIndex; |
Clarkk | 0:a1bb4583940a | 34 | uint8_t batVoltageIndex; |
Clarkk | 0:a1bb4583940a | 35 | |
Clarkk | 0:a1bb4583940a | 36 | float currentPWM; |
Clarkk | 0:a1bb4583940a | 37 | float steeringAngle; |
Clarkk | 0:a1bb4583940a | 38 | }; |
Clarkk | 0:a1bb4583940a | 39 | |
Clarkk | 0:a1bb4583940a | 40 | #endif |