Patched some weird behavior with motor temp on stormcore and added #define for filter constant

Was seeing a lot of coupled noise on stormcore with phase currents so I turned up the LPF on the motor temp sensor. I think it might be a good idea to turn up that LPF generally since motor temp is generally slow to change anyways.

Also found a problem in the #define for motor temp 2 in my header file. Fixed it.
This commit is contained in:
Jeffrey M. Friesen 2020-04-14 14:05:47 -07:00
parent 6e83fd3408
commit acfc93e693
8 changed files with 30 additions and 20 deletions

View File

@ -24,7 +24,7 @@
#define FW_VERSION_MAJOR 5
#define FW_VERSION_MINOR 00
// Set to 0 for building a release and iterate during beta test builds
#define FW_TEST_VERSION_NUMBER 3
#define FW_TEST_VERSION_NUMBER 4
#include "datatypes.h"

View File

@ -431,6 +431,9 @@
#ifndef ADC_IND_TEMP_MOTOR_2
#define ADC_IND_TEMP_MOTOR_2 ADC_IND_TEMP_MOTOR
#endif
#ifndef MOTOR_TEMP_LPF
#define MOTOR_TEMP_LPF 0.1
#endif
#ifndef HW_ADC_CHANNELS_EXTRA
#define HW_ADC_CHANNELS_EXTRA 0
#endif

View File

@ -314,35 +314,37 @@ static THD_FUNCTION(mux_thread, arg) {
for (;;) {
ENABLE_MOS_TEMP1();
chThdSleepMilliseconds(1);
chThdSleepMicroseconds(400);
ADC_Value[ADC_IND_TEMP_MOS] = ADC_Value[ADC_IND_ADC_MUX];
ENABLE_MOS_TEMP2();
chThdSleepMilliseconds(1);
chThdSleepMicroseconds(400);
ADC_Value[ADC_IND_TEMP_MOS_M2] = ADC_Value[ADC_IND_ADC_MUX];
ENABLE_MOT_TEMP1();
chThdSleepMilliseconds(1);
chThdSleepMicroseconds(400);
ADC_Value[ADC_IND_TEMP_MOTOR] = ADC_Value[ADC_IND_ADC_MUX];
ENABLE_MOT_TEMP2();
chThdSleepMilliseconds(1);
chThdSleepMicroseconds(400);
ADC_Value[ADC_IND_TEMP_MOTOR_2] = ADC_Value[ADC_IND_ADC_MUX];
ENABLE_ADC_EXT_1();
chThdSleepMilliseconds(1);
chThdSleepMicroseconds(400);
ADC_Value[ADC_IND_EXT] = ADC_Value[ADC_IND_ADC_MUX];
ENABLE_ADC_EXT_2();
chThdSleepMilliseconds(1);
chThdSleepMicroseconds(400);
ADC_Value[ADC_IND_EXT2] = ADC_Value[ADC_IND_ADC_MUX];
ENABLE_ADC_EXT_3();
chThdSleepMilliseconds(1);
chThdSleepMicroseconds(400);
ADC_Value[ADC_IND_EXT3] = ADC_Value[ADC_IND_ADC_MUX];
ENABLE_V_BATT_DIV();
chThdSleepMilliseconds(1);
chThdSleepMicroseconds(300);
ADC_Value[ADC_IND_V_BATT] = ADC_Value[ADC_IND_ADC_MUX];
}
}

View File

@ -247,7 +247,9 @@
#define NTC_RES_MOTOR(adc_val) (10000.0 / ((4095.0 / (float)adc_val) - 1.0)) // Motor temp sensor on low side
#define NTC_TEMP_MOTOR(beta) (1.0 / ((logf(NTC_RES_MOTOR(ADC_Value[ADC_IND_TEMP_MOTOR]) / 10000.0) / beta) + (1.0 / 298.15)) - 273.15)
#define NTC_TEMP_MOTOR2(beta) (1.0 / ((logf(NTC_RES_MOTOR(ADC_Value[ADC_IND_TEMP_MOTOR2]) / 10000.0) / beta) + (1.0 / 298.15)) - 273.15)
#define NTC_TEMP_MOTOR_2(beta) (1.0 / ((logf(NTC_RES_MOTOR(ADC_Value[ADC_IND_TEMP_MOTOR_2]) / 10000.0) / beta) + (1.0 / 298.15)) - 273.15)
#define MOTOR_TEMP_LPF 0.01
// Double samples in beginning and end for positive current measurement.
// Useful when the shunt sense traces have noise that causes offset.
#ifndef CURR1_DOUBLE_SAMPLE

View File

@ -314,35 +314,35 @@ static THD_FUNCTION(mux_thread, arg) {
for (;;) {
ENABLE_MOS_TEMP1();
chThdSleepMilliseconds(1);
chThdSleepMicroseconds(400);
ADC_Value[ADC_IND_TEMP_MOS] = ADC_Value[ADC_IND_ADC_MUX];
ENABLE_MOS_TEMP2();
chThdSleepMilliseconds(1);
chThdSleepMicroseconds(400);
ADC_Value[ADC_IND_TEMP_MOS_M2] = ADC_Value[ADC_IND_ADC_MUX];
ENABLE_MOT_TEMP1();
chThdSleepMilliseconds(1);
chThdSleepMicroseconds(400);
ADC_Value[ADC_IND_TEMP_MOTOR] = ADC_Value[ADC_IND_ADC_MUX];
ENABLE_MOT_TEMP2();
chThdSleepMilliseconds(1);
chThdSleepMicroseconds(400);
ADC_Value[ADC_IND_TEMP_MOTOR_2] = ADC_Value[ADC_IND_ADC_MUX];
ENABLE_ADC_EXT_1();
chThdSleepMilliseconds(1);
chThdSleepMicroseconds(400);
ADC_Value[ADC_IND_EXT] = ADC_Value[ADC_IND_ADC_MUX];
ENABLE_ADC_EXT_2();
chThdSleepMilliseconds(1);
chThdSleepMicroseconds(400);
ADC_Value[ADC_IND_EXT2] = ADC_Value[ADC_IND_ADC_MUX];
ENABLE_ADC_EXT_3();
chThdSleepMilliseconds(1);
chThdSleepMicroseconds(400);
ADC_Value[ADC_IND_EXT3] = ADC_Value[ADC_IND_ADC_MUX];
ENABLE_V_BATT_DIV();
chThdSleepMilliseconds(1);
chThdSleepMicroseconds(400);
ADC_Value[ADC_IND_V_BATT] = ADC_Value[ADC_IND_ADC_MUX];
}
}

View File

@ -238,7 +238,9 @@
#define NTC_RES_MOTOR(adc_val) (10000.0 / ((4095.0 / (float)adc_val) - 1.0)) // Motor temp sensor on low side
#define NTC_TEMP_MOTOR(beta) (1.0 / ((logf(NTC_RES_MOTOR(ADC_Value[ADC_IND_TEMP_MOTOR]) / 10000.0) / beta) + (1.0 / 298.15)) - 273.15)
#define NTC_TEMP_MOTOR2(beta) (1.0 / ((logf(NTC_RES_MOTOR(ADC_Value[ADC_IND_TEMP_MOTOR2]) / 10000.0) / beta) + (1.0 / 298.15)) - 273.15)
#define NTC_TEMP_MOTOR_2(beta) (1.0 / ((logf(NTC_RES_MOTOR(ADC_Value[ADC_IND_TEMP_MOTOR_2]) / 10000.0) / beta) + (1.0 / 298.15)) - 273.15)
#define MOTOR_TEMP_LPF 0.01
// Double samples in beginning and end for positive current measurement.
// Useful when the shunt sense traces have noise that causes offset.
#ifndef CURR1_DOUBLE_SAMPLE

View File

@ -179,6 +179,7 @@
#define NTC_RES_MOTOR(adc_val) (10000.0 / ((4095.0 / (float)adc_val) - 1.0)) // Motor temp sensor on low side
#define NTC_TEMP_MOTOR(beta) (1.0 / ((logf(NTC_RES_MOTOR(ADC_Value[ADC_IND_TEMP_MOTOR]) / 10000.0) / beta) + (1.0 / 298.15)) - 273.15)
#define NTC_TEMP_MOTOR_2(beta) (1.0 / ((logf(NTC_RES_MOTOR(ADC_Value[ADC_IND_TEMP_MOTOR_2]) / 10000.0) / beta) + (1.0 / 298.15)) - 273.15)
#define MOTOR_TEMP_LPF 0.01
// UART Peripheral
#define HW_UART_DEV SD3

View File

@ -1878,7 +1878,7 @@ static void update_override_limits(volatile motor_if_state_t *motor, volatile mc
temp_motor = -100.0;
}
UTILS_LP_FAST(motor->m_temp_motor, temp_motor, 0.1);
UTILS_LP_FAST(motor->m_temp_motor, temp_motor, MOTOR_TEMP_LPF);
#ifdef HW_HAS_GATE_DRIVER_SUPPLY_MONITOR
UTILS_LP_FAST(motor->m_gate_driver_voltage, GET_GATE_DRIVER_SUPPLY_VOLTAGE(), 0.01);