From 62be001ca29555283d50a4a231ce531d5e80253f Mon Sep 17 00:00:00 2001 From: Paul Guenette Date: Wed, 22 Nov 2017 19:17:31 -0500 Subject: [PATCH] Revert "Handle current scaling factor for HW versions <= 3.3" This reverts commit fefa091de22bc8ad00292ff476a0b87a0f1c709d. --- Firmware/MotorControl/low_level.c | 16 ++-------------- Firmware/MotorControl/utils.h | 1 - 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/Firmware/MotorControl/low_level.c b/Firmware/MotorControl/low_level.c index 97ee3a9b..961d4f7b 100644 --- a/Firmware/MotorControl/low_level.c +++ b/Firmware/MotorControl/low_level.c @@ -39,8 +39,6 @@ float vbus_voltage = 12.0f; #define POLE_PAIRS 7 static float elec_rad_per_enc = POLE_PAIRS * 2 * M_PI * (1.0f / (float)ENCODER_CPR); -#define CURRENT_SCALING_FACTOR (1.31578947f) - // TODO: Migrate to C++, clearly we are actually doing object oriented code here... // TODO: For nice encapsulation, consider not having the motor objects public Motor_t motors[] = { @@ -621,12 +619,7 @@ void pwm_trig_adc_cb(ADC_HandleTypeDef* hadc, bool injected) { } else { ADCValue = HAL_ADC_GetValue(hadc); } - if(HW_VERSION_MAJOR == 3 && HW_VERSION_MINOR <= 3){ - float current = phase_current_from_adcval(motor, ADCValue)*CURRENT_SCALING_FACTOR; - } else { - float current = phase_current_from_adcval(motor, ADCValue); - } - + float current = phase_current_from_adcval(motor, ADCValue); if (current_meas_not_DC_CAL) { // ADC2 and ADC3 record the phB and phC currents concurrently, @@ -1300,12 +1293,7 @@ static void control_motor_loop(Motor_t* motor) { } // Current limiting - if(HW_VERSION_MAJOR == 3 && HW_VERSION_MINOR <= 3){ - float Ilim = motor->current_control.current_lim*CURRENT_SCALING_FACTOR; - } else{ - float Ilim = motor->current_control.current_lim; - } - + float Ilim = motor->current_control.current_lim; bool limited = false; if (Iq > Ilim) { limited = true; diff --git a/Firmware/MotorControl/utils.h b/Firmware/MotorControl/utils.h index 1acfc657..542b7dd7 100644 --- a/Firmware/MotorControl/utils.h +++ b/Firmware/MotorControl/utils.h @@ -70,7 +70,6 @@ #define MACRO_MAX(x, y) (((x) > (y)) ? (x) : (y)) #define MACRO_MIN(x, y) (((x) < (y)) ? (x) : (y)) -#define MACRO_CONSTRAIN(amt,low,high) (((amt)<(low)) ? (low) : ((amt > high) ? (high) : (amt))) // Compute rising edge timings (0.0 - 1.0) as a function of alpha-beta // as per the magnitude invariant clarke transform