Added KTY84 temp sensor support

This commit is contained in:
Benjamin Vedder 2021-03-17 11:54:42 +01:00
parent 89c4d712e8
commit bdb7b0bf7b
6 changed files with 13 additions and 5 deletions

View File

@ -9,6 +9,7 @@
* Force oberver state magnitude above 50% of flux linkage. This prevents the motor from getting stuck and 'screaming'. * Force oberver state magnitude above 50% of flux linkage. This prevents the motor from getting stuck and 'screaming'.
* Observer global convergence update. Helps tracking the motor through 0 speed. * Observer global convergence update. Helps tracking the motor through 0 speed.
* Added HFI start sensor mode. * Added HFI start sensor mode.
* Added TEMP_SENSOR_KTY84_130.
=== FW 5.02 === === FW 5.02 ===
* IMU calibration improvement. * IMU calibration improvement.

View File

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

View File

@ -8,7 +8,7 @@
#include <stdbool.h> #include <stdbool.h>
// Constants // Constants
#define MCCONF_SIGNATURE 3829768460 #define MCCONF_SIGNATURE 4103704218
#define APPCONF_SIGNATURE 3264926020 #define APPCONF_SIGNATURE 3264926020
// Functions // Functions

View File

@ -78,6 +78,7 @@ typedef enum {
TEMP_SENSOR_PTC_1K_100C, TEMP_SENSOR_PTC_1K_100C,
TEMP_SENSOR_KTY83_122, TEMP_SENSOR_KTY83_122,
TEMP_SENSOR_NTC_100K_25C, TEMP_SENSOR_NTC_100K_25C,
TEMP_SENSOR_KTY84_130
} temp_sensor_type; } temp_sensor_type;
// General purpose drive output mode // General purpose drive output mode

View File

@ -126,7 +126,8 @@
#define NTC_RES(adc_val) ((4095.0 * 10000.0) / adc_val - 10000.0) #define NTC_RES(adc_val) ((4095.0 * 10000.0) / adc_val - 10000.0)
#define NTC_TEMP(adc_ind) (1.0 / ((logf(NTC_RES(ADC_Value[adc_ind]) / 10000.0) / 3380.0) + (1.0 / 298.15)) - 273.15) #define NTC_TEMP(adc_ind) (1.0 / ((logf(NTC_RES(ADC_Value[adc_ind]) / 10000.0) / 3380.0) + (1.0 / 298.15)) - 273.15)
#define NTC_RES_MOTOR(adc_val) (10000.0 / ((4095.0 / (float)adc_val) - 1.0)) // Motor temp sensor on low side // TODO: Update equation for next HW revision when voltage divider is fixed.
#define NTC_RES_MOTOR(adc_val) (10000.0 / (((4095.0 * (5.0 / 3.3)) / (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(beta) (1.0 / ((logf(NTC_RES_MOTOR(ADC_Value[ADC_IND_TEMP_MOTOR]) / 10000.0) / beta) + (1.0 / 298.15)) - 273.15)
// Voltage on ADC channel // Voltage on ADC channel

View File

@ -1902,8 +1902,13 @@ static void update_override_limits(volatile motor_if_state_t *motor, volatile mc
float pow2 = res * res; float pow2 = res * res;
temp_motor = 0.0000000102114874947423 * pow2 * res - 0.000069967997703501 * pow2 + temp_motor = 0.0000000102114874947423 * pow2 * res - 0.000069967997703501 * pow2 +
0.243402040973194 * res - 160.145048329356; 0.243402040973194 * res - 160.145048329356;
} } break;
break;
case TEMP_SENSOR_KTY84_130: {
float res = NTC_RES_MOTOR(ADC_Value[is_motor_1 ? ADC_IND_TEMP_MOTOR : ADC_IND_TEMP_MOTOR_2]);
temp_motor = -7.82531699e-12 * res * res * res * res + 6.34445902e-8 * res * res * res -
0.00020119157 * res * res + 0.407683016 * res - 161.357536;
} break;
} }
// If the reading is messed up (by e.g. reading 0 on the ADC and dividing by 0) we avoid putting an // If the reading is messed up (by e.g. reading 0 on the ADC and dividing by 0) we avoid putting an