implement thermistors

This commit is contained in:
Matthew Kennedy 2023-09-18 04:37:46 -04:00 committed by rusefillc
parent bcc5647e27
commit b44e2b4d1c
2 changed files with 41 additions and 3 deletions

View File

@ -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);
}

View File

@ -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