Added PT1000 temperature sensor support

This commit is contained in:
Benjamin Vedder 2022-09-23 11:26:31 +02:00
parent 22a3111d18
commit 114fc7aa53
4 changed files with 9 additions and 2 deletions

View File

@ -20,6 +20,7 @@
- mxlemming with flux linkage tracking
* AS5x47 encoder support: https://github.com/vedderb/bldc/pull/511
* Disable BMS limit options.
* Added PT1000 temperature sensor support.
=== FW 5.03 ===
* Fixed inductance measurement bug.

View File

@ -8,7 +8,7 @@
#include <stdbool.h>
// Constants
#define MCCONF_SIGNATURE 715312237
#define MCCONF_SIGNATURE 1990552441
#define APPCONF_SIGNATURE 3494444161
// Functions

View File

@ -92,7 +92,8 @@ typedef enum {
TEMP_SENSOR_NTC_100K_25C,
TEMP_SENSOR_KTY84_130,
TEMP_SENSOR_NTCX,
TEMP_SENSOR_PTCX
TEMP_SENSOR_PTCX,
TEMP_SENSOR_PT1000
} temp_sensor_type;
// General purpose drive output mode

View File

@ -2126,6 +2126,11 @@ static void update_override_limits(volatile motor_if_state_t *motor, volatile mc
temp_motor = is_motor_1 ? PTC_TEMP_MOTOR(conf->m_ntcx_ptcx_res, conf->m_ptc_motor_coeff, conf->m_ntcx_ptcx_temp_base) :
PTC_TEMP_MOTOR_2(conf->m_ntcx_ptcx_res, conf->m_ptc_motor_coeff, conf->m_ntcx_ptcx_temp_base);
break;
case TEMP_SENSOR_PT1000: {
float res = NTC_RES_MOTOR(ADC_Value[is_motor_1 ? ADC_IND_TEMP_MOTOR : ADC_IND_TEMP_MOTOR_2]);
temp_motor = -(sqrtf(-0.00232 * res + 17.59246) - 3.908) / 0.00116;
} break;
}
// If the reading is messed up (by e.g. reading 0 on the ADC and dividing by 0) we avoid putting an