From b44e2b4d1c63567f980c1724240f675c77447e94 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Mon, 18 Sep 2023 04:37:46 -0400 Subject: [PATCH] implement thermistors --- firmware/init/sensor/init_thermistors.cpp | 37 +++++++++++++++++++++-- firmware/integration/rusefi_config.txt | 7 ++++- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/firmware/init/sensor/init_thermistors.cpp b/firmware/init/sensor/init_thermistors.cpp index 2c56c2f6df..c5980beb0a 100644 --- a/firmware/init/sensor/init_thermistors.cpp +++ b/firmware/init/sensor/init_thermistors.cpp @@ -19,9 +19,14 @@ struct FuncPair { static CCM_OPTIONAL FunctionalSensor clt(SensorType::Clt, MS2NT(10)); static CCM_OPTIONAL FunctionalSensor iat(SensorType::Iat, MS2NT(10)); static CCM_OPTIONAL FunctionalSensor aux1(SensorType::AuxTemp1, MS2NT(10)); -static FunctionalSensor aux2(SensorType::AuxTemp2, MS2NT(10)); +static CCM_OPTIONAL FunctionalSensor aux2(SensorType::AuxTemp2, MS2NT(10)); -static FuncPair fclt, fiat, faux1, faux2; +static CCM_OPTIONAL FunctionalSensor oilTempSensor(SensorType::OilTemperature, MS2NT(10)); +static CCM_OPTIONAL FunctionalSensor fuelTempSensor(SensorType::FuelTemperature, MS2NT(10)); +static CCM_OPTIONAL FunctionalSensor ambientTempSensor(SensorType::AmbientTemperature, MS2NT(10)); +static CCM_OPTIONAL FunctionalSensor compressorDischargeTemp(SensorType::CompressorDischargeTemperature, MS2NT(10)); + +static FuncPair fclt, fiat, faux1, faux2, foil, ffuel, fambient, fcdt; static void validateThermistorConfig(const char *msg, thermistor_conf_s& cfg) { if (cfg.tempC_1 >= cfg.tempC_2 || @@ -102,6 +107,30 @@ void initThermistors() { engineConfiguration->iatSensorPulldown); } + configureTempSensor("oil temp", + oilTempSensor, + faux2, + engineConfiguration->oilTempSensor, + false); + + configureTempSensor("fuel temp", + fuelTempSensor, + ffuel, + engineConfiguration->fuelTempSensor, + false); + + configureTempSensor("ambient temp", + ambientTempSensor, + fambient, + engineConfiguration->ambientTempSensor, + false); + + configureTempSensor("compressor discharge temp", + compressorDischargeTemp, + fcdt, + engineConfiguration->compressorDischargeTemperature, + false); + configureTempSensor("aux1", aux1, faux1, @@ -118,6 +147,10 @@ void initThermistors() { void deinitThermistors() { AdcSubscription::UnsubscribeSensor(clt, engineConfiguration->clt.adcChannel); AdcSubscription::UnsubscribeSensor(iat, engineConfiguration->iat.adcChannel); + AdcSubscription::UnsubscribeSensor(oilTempSensor, engineConfiguration->oilTempSensor.adcChannel); + AdcSubscription::UnsubscribeSensor(fuelTempSensor, engineConfiguration->fuelTempSensor.adcChannel); + AdcSubscription::UnsubscribeSensor(ambientTempSensor, engineConfiguration->ambientTempSensor.adcChannel); + AdcSubscription::UnsubscribeSensor(compressorDischargeTemp, engineConfiguration->compressorDischargeTemperature.adcChannel); AdcSubscription::UnsubscribeSensor(aux1, engineConfiguration->auxTempSensor1.adcChannel); AdcSubscription::UnsubscribeSensor(aux2, engineConfiguration->auxTempSensor2.adcChannel); } diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index e64ed64c00..cb86adfab8 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -1550,10 +1550,15 @@ pin_input_mode_e[LUA_DIGITAL_INPUT_COUNT iterate] luaDigitalInputPinModes; uint16_t autoscale canVssScaling;Scale the reported vehicle speed value from CAN. Example: Parameter set to 1.1, CAN VSS reports 50kph, ECU will report 55kph instead.;"ratio", 0.0001, 0, 0.5, 1.5, 4 + ThermistorConf oilTempSensor + ThermistorConf fuelTempSensor + ThermistorConf ambientTempSensor + ThermistorConf compressorDischargeTemperature + ! ! Just a shortcut to facilitate compatible configuration changes, i.e. a change which does not touch FLASH_DATA_VERSION and thus does not require manual tune migration ! -uint8_t[186] mainUnusedEnd;;"units", 1, 0, 0, 1, 0 +uint8_t[256] mainUnusedEnd;;"units", 1, 0, 0, 1, 0 ! end of engine_configuration_s end_struct