fix data type
This commit is contained in:
parent
2bab3aa1a4
commit
898898a63c
23
Src/main.c
23
Src/main.c
|
@ -82,8 +82,8 @@ extern uint8_t enable; // global variable for motor enable
|
||||||
|
|
||||||
extern int16_t batVoltage; // global variable for battery voltage
|
extern int16_t batVoltage; // global variable for battery voltage
|
||||||
|
|
||||||
//extern int16_t curL_DC; // global variable for left motor current. to get current in Ampere divide by A2BIT_CONV
|
extern int16_t curL_DC; // global variable for left motor current. to get current in Ampere divide by A2BIT_CONV
|
||||||
//extern int16_t curR_DC; // global variable for right motor current
|
extern int16_t curR_DC; // global variable for right motor current
|
||||||
extern int16_t curL_phaA;
|
extern int16_t curL_phaA;
|
||||||
extern int16_t curL_phaB;
|
extern int16_t curL_phaB;
|
||||||
extern int16_t curR_phaA;
|
extern int16_t curR_phaA;
|
||||||
|
@ -157,8 +157,8 @@ static int16_t speed; // local variable for speed. -1000 to 10
|
||||||
static int16_t speedRightRateFixdt; // local fixed-point variable for speed rate limiter
|
static int16_t speedRightRateFixdt; // local fixed-point variable for speed rate limiter
|
||||||
//static int32_t steerFixdt; // local fixed-point variable for steering low-pass filter
|
//static int32_t steerFixdt; // local fixed-point variable for steering low-pass filter
|
||||||
//static int32_t speedFixdt; // local fixed-point variable for speed low-pass filter
|
//static int32_t speedFixdt; // local fixed-point variable for speed low-pass filter
|
||||||
static int16_t speedLeftFixdt; // local fixed-point variable for speedLeft low-pass filter
|
static int32_t speedLeftFixdt; // local fixed-point variable for speedLeft low-pass filter
|
||||||
static int16_t speedRightFixdt; // local fixed-point variable for speedRight low-pass filter
|
static int32_t speedRightFixdt; // local fixed-point variable for speedRight low-pass filter
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint32_t inactivity_timeout_counter;
|
static uint32_t inactivity_timeout_counter;
|
||||||
|
@ -297,7 +297,7 @@ int main(void) {
|
||||||
filtLowPass32(speedLeftRateFixdt >> 4, FILTER, &speedLeftFixdt);
|
filtLowPass32(speedLeftRateFixdt >> 4, FILTER, &speedLeftFixdt);
|
||||||
filtLowPass32(speedRightRateFixdt >> 4, FILTER, &speedRightFixdt);
|
filtLowPass32(speedRightRateFixdt >> 4, FILTER, &speedRightFixdt);
|
||||||
speedL = (int16_t)(speedLeftFixdt >> 16); // convert fixed-point to integer
|
speedL = (int16_t)(speedLeftFixdt >> 16); // convert fixed-point to integer
|
||||||
speedR = (int16_t)(speedRightRateFixdt >> 16); // convert fixed-point to integer
|
speedR = (int16_t)(speedRightFixdt >> 16); // convert fixed-point to integer
|
||||||
|
|
||||||
// ####### VARIANT_HOVERCAR #######
|
// ####### VARIANT_HOVERCAR #######
|
||||||
#ifdef VARIANT_HOVERCAR
|
#ifdef VARIANT_HOVERCAR
|
||||||
|
@ -315,8 +315,9 @@ int main(void) {
|
||||||
// cmdR = CLAMP((int)(speed * SPEED_COEFFICIENT - steer * STEER_COEFFICIENT), INPUT_MIN, INPUT_MAX);
|
// cmdR = CLAMP((int)(speed * SPEED_COEFFICIENT - steer * STEER_COEFFICIENT), INPUT_MIN, INPUT_MAX);
|
||||||
// cmdL = CLAMP((int)(speed * SPEED_COEFFICIENT + steer * STEER_COEFFICIENT), INPUT_MIN, INPUT_MAX);
|
// cmdL = CLAMP((int)(speed * SPEED_COEFFICIENT + steer * STEER_COEFFICIENT), INPUT_MIN, INPUT_MAX);
|
||||||
//mixerFcn(speed << 4, steer << 4, &cmdR, &cmdL); // This function implements the equations above
|
//mixerFcn(speed << 4, steer << 4, &cmdR, &cmdL); // This function implements the equations above
|
||||||
cmdL = speedL; //straight copy, no mixing needed
|
int16_t _temp;
|
||||||
cmdR = speedR; //straight copy
|
mixerFcn(speedL << 4, ((int16_t)0) << 4, &cmdL, &_temp); // This function implements the equations above
|
||||||
|
mixerFcn(speedR << 4, ((int16_t)0) << 4, &cmdR, &_temp); // This function implements the equations above
|
||||||
|
|
||||||
// ####### SET OUTPUTS (if the target change is less than +/- 100) #######
|
// ####### SET OUTPUTS (if the target change is less than +/- 100) #######
|
||||||
if ((cmdL > cmdL_prev-100 && cmdL < cmdL_prev+100) && (cmdR > cmdR_prev-100 && cmdR < cmdR_prev+100)) {
|
if ((cmdL > cmdL_prev-100 && cmdL < cmdL_prev+100) && (cmdR > cmdR_prev-100 && cmdR < cmdR_prev+100)) {
|
||||||
|
@ -476,10 +477,10 @@ int main(void) {
|
||||||
Feedback.speedL_meas = (int16_t)rtY_Left.n_mot;
|
Feedback.speedL_meas = (int16_t)rtY_Left.n_mot;
|
||||||
Feedback.batVoltage = (int16_t)(batVoltage * BAT_CALIB_REAL_VOLTAGE / BAT_CALIB_ADC);
|
Feedback.batVoltage = (int16_t)(batVoltage * BAT_CALIB_REAL_VOLTAGE / BAT_CALIB_ADC);
|
||||||
Feedback.boardTemp = (int16_t)board_temp_deg_c;
|
Feedback.boardTemp = (int16_t)board_temp_deg_c;
|
||||||
//Feedback.curL_DC = (int16_t)curL_DC; //divide by A2BIT_CONV to get current in amperes
|
Feedback.curL_DC = (int16_t)curL_DC; //divide by A2BIT_CONV to get current in amperes
|
||||||
//Feedback.curR_DC = (int16_t)curR_DC;
|
Feedback.curR_DC = (int16_t)curR_DC;
|
||||||
Feedback.curL_DC = (int16_t)curL_phaA;
|
//Feedback.curL_DC = (int16_t)curL_phaA;
|
||||||
Feedback.curR_DC = (int16_t)curL_phaB;
|
//Feedback.curR_DC = (int16_t)curL_phaB;
|
||||||
|
|
||||||
#if defined(FEEDBACK_SERIAL_USART2)
|
#if defined(FEEDBACK_SERIAL_USART2)
|
||||||
if(__HAL_DMA_GET_COUNTER(huart2.hdmatx) == 0) {
|
if(__HAL_DMA_GET_COUNTER(huart2.hdmatx) == 0) {
|
||||||
|
|
Loading…
Reference in New Issue