Custom version for NXP cup car

Dependents:   NXPCUPcar

Committer:
Clarkk
Date:
Thu Jun 01 13:16:50 2017 +0000
Revision:
2:0d5c994d8135
Parent:
1:7ce4ffeb8ccb
Child:
3:170c22171ec2
Few changes

Who changed what in which revision?

UserRevisionLine numberNew 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 float getWheelSpeed(char mot);
Clarkk 0:a1bb4583940a 20 float getWheelRPS(char mot);
Clarkk 2:0d5c994d8135 21 float getCarSpeed();
Clarkk 0:a1bb4583940a 22 void processTasks();
Clarkk 2:0d5c994d8135 23 float getMotCurrent(char mot);
Clarkk 2:0d5c994d8135 24 float getMotPWM(char mot);
Clarkk 0:a1bb4583940a 25 float getAverageMotCurrent(char mot);
Clarkk 0:a1bb4583940a 26 float getAverageBatteryVoltage();
Clarkk 0:a1bb4583940a 27 void setFixedPWMValue(float pwm);
Clarkk 2:0d5c994d8135 28 void setSpeedTargetValue(float speed);
Clarkk 2:0d5c994d8135 29
Clarkk 2:0d5c994d8135 30 float getSpeedError();
Clarkk 0:a1bb4583940a 31
Clarkk 0:a1bb4583940a 32 private:
Clarkk 0:a1bb4583940a 33
Clarkk 2:0d5c994d8135 34 int16_t motorAPWM[MOTSAMPLECOUNT];
Clarkk 2:0d5c994d8135 35 int16_t motorBPWM[MOTSAMPLECOUNT];
Clarkk 0:a1bb4583940a 36 uint16_t motorACurrent[MOTSAMPLECOUNT];
Clarkk 0:a1bb4583940a 37 uint16_t motorBCurrent[MOTSAMPLECOUNT];
Clarkk 0:a1bb4583940a 38 uint16_t batteryVoltage[BATSAMPLECOUNT];
Clarkk 0:a1bb4583940a 39
Clarkk 0:a1bb4583940a 40 uint8_t motorCurrentIndex;
Clarkk 0:a1bb4583940a 41 uint8_t batVoltageIndex;
Clarkk 0:a1bb4583940a 42
Clarkk 2:0d5c994d8135 43 int16_t nextPWM;
Clarkk 2:0d5c994d8135 44 // int16_t torqueDiffAvg;
Clarkk 2:0d5c994d8135 45 uint8_t motorDriveIndex;
Clarkk 2:0d5c994d8135 46 float currentMotAPWM;
Clarkk 2:0d5c994d8135 47 float currentMotBPWM;
Clarkk 2:0d5c994d8135 48
Clarkk 2:0d5c994d8135 49 int32_t speedTarget;
Clarkk 2:0d5c994d8135 50 int32_t speederror1000000;
Clarkk 0:a1bb4583940a 51 };
Clarkk 0:a1bb4583940a 52
Clarkk 0:a1bb4583940a 53 #endif