some hack to handle linear CLT sensors
This commit is contained in:
parent
5e9ed07904
commit
69d155daaf
|
@ -170,6 +170,8 @@ void ensureArrayIsAscending(const char *msg, const float array[], int size) {
|
||||||
/** @brief Binary search
|
/** @brief Binary search
|
||||||
* @returns the highest index within sorted array such that array[i] is greater than or equal to the parameter
|
* @returns the highest index within sorted array such that array[i] is greater than or equal to the parameter
|
||||||
* @note If the parameter is smaller than the first element of the array, -1 is returned.
|
* @note If the parameter is smaller than the first element of the array, -1 is returned.
|
||||||
|
*
|
||||||
|
* See also ensureArrayIsAscending
|
||||||
*/
|
*/
|
||||||
int findIndexMsg(const char *msg, const float array[], int size, float value) {
|
int findIndexMsg(const char *msg, const float array[], int size, float value) {
|
||||||
if (cisnan(value)) {
|
if (cisnan(value)) {
|
||||||
|
|
|
@ -77,10 +77,20 @@ float getResistance(ThermistorConf *config, float voltage) {
|
||||||
return resistance;
|
return resistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getTemperatureC(ThermistorConf *config, ThermistorMath *tm) {
|
float getTemperatureC(ThermistorConf *config, ThermistorMath *tm, bool useLinear) {
|
||||||
tm->setConfig(&config->config); // implementation checks if configuration has changed or not
|
tm->setConfig(&config->config); // implementation checks if configuration has changed or not
|
||||||
|
|
||||||
float voltage = getVoltageDivided("term", config->adcChannel);
|
float voltage = getVoltageDivided("term", config->adcChannel);
|
||||||
|
if (useLinear) {
|
||||||
|
// todo: fix this horrible code!
|
||||||
|
// should work as a short term fix.
|
||||||
|
// todo: move 'useLinearXXXSensor' into termistor configuration record
|
||||||
|
// yes, we use 'resistance' setting for 'voltage' here
|
||||||
|
return interpolate(config->config.resistance_1, config->config.tempC_1,
|
||||||
|
config->config.resistance_2, config->config.tempC_2,
|
||||||
|
voltage);
|
||||||
|
|
||||||
|
}
|
||||||
float resistance = getResistance(config, voltage);
|
float resistance = getResistance(config, voltage);
|
||||||
|
|
||||||
float kelvinTemperature = tm->getKelvinTemperatureByResistance(resistance);
|
float kelvinTemperature = tm->getKelvinTemperatureByResistance(resistance);
|
||||||
|
@ -109,7 +119,8 @@ float getCoolantTemperature(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
engine->isCltBroken = false;
|
engine->isCltBroken = false;
|
||||||
return NO_CLT_SENSOR_TEMPERATURE;
|
return NO_CLT_SENSOR_TEMPERATURE;
|
||||||
}
|
}
|
||||||
float temperature = getTemperatureC(&engineConfiguration->clt, &engine->engineState.cltCurve);
|
float temperature = getTemperatureC(&engineConfiguration->clt, &engine->engineState.cltCurve,
|
||||||
|
engineConfiguration->useLinearCltSensor);
|
||||||
if (!isValidCoolantTemperature(temperature)) {
|
if (!isValidCoolantTemperature(temperature)) {
|
||||||
efiAssert(engineConfiguration!=NULL, "NULL engineConfiguration", NAN);
|
efiAssert(engineConfiguration!=NULL, "NULL engineConfiguration", NAN);
|
||||||
warning(OBD_Engine_Coolant_Temperature_Circuit_Malfunction, "unrealistic CLT %f", temperature);
|
warning(OBD_Engine_Coolant_Temperature_Circuit_Malfunction, "unrealistic CLT %f", temperature);
|
||||||
|
@ -189,7 +200,8 @@ float getIntakeAirTemperature(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
if (!hasIatSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) {
|
if (!hasIatSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) {
|
||||||
return NO_IAT_SENSOR_TEMPERATURE;
|
return NO_IAT_SENSOR_TEMPERATURE;
|
||||||
}
|
}
|
||||||
float temperature = getTemperatureC(&engineConfiguration->iat, &engine->engineState.iatCurve);
|
float temperature = getTemperatureC(&engineConfiguration->iat, &engine->engineState.iatCurve,
|
||||||
|
engineConfiguration->useLinearIatSensor);
|
||||||
if (!isValidIntakeAirTemperature(temperature)) {
|
if (!isValidIntakeAirTemperature(temperature)) {
|
||||||
efiAssert(engineConfiguration!=NULL, "NULL engineConfiguration", NAN);
|
efiAssert(engineConfiguration!=NULL, "NULL engineConfiguration", NAN);
|
||||||
#if EFI_PROD_CODE || EFI_UNIT_TEST || defined(__DOXYGEN__)
|
#if EFI_PROD_CODE || EFI_UNIT_TEST || defined(__DOXYGEN__)
|
||||||
|
|
|
@ -32,7 +32,7 @@ float convertFtoCelcius(float tempF);
|
||||||
|
|
||||||
float getKelvinTemperature(float resistance, ThermistorMath *tm);
|
float getKelvinTemperature(float resistance, ThermistorMath *tm);
|
||||||
float getResistance(ThermistorConf *config, float voltage);
|
float getResistance(ThermistorConf *config, float voltage);
|
||||||
float getTemperatureC(ThermistorConf *config, ThermistorMath *tm);
|
float getTemperatureC(ThermistorConf *config, ThermistorMath *tm, bool useLinear);
|
||||||
float getCoolantTemperature(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
float getCoolantTemperature(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
bool isValidCoolantTemperature(float temperature);
|
bool isValidCoolantTemperature(float temperature);
|
||||||
float getIntakeAirTemperature(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
float getIntakeAirTemperature(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
|
@ -378,12 +378,12 @@ static void setOM(int value) {
|
||||||
|
|
||||||
static char pinNameBuffer[16];
|
static char pinNameBuffer[16];
|
||||||
|
|
||||||
static void printThermistor(const char *msg, ThermistorConf *config, ThermistorMath *tm) {
|
static void printThermistor(const char *msg, ThermistorConf *config, ThermistorMath *tm, bool useLinear) {
|
||||||
adc_channel_e adcChannel = config->adcChannel;
|
adc_channel_e adcChannel = config->adcChannel;
|
||||||
float voltage = getVoltageDivided("term", adcChannel);
|
float voltage = getVoltageDivided("term", adcChannel);
|
||||||
float r = getResistance(config, voltage);
|
float r = getResistance(config, voltage);
|
||||||
|
|
||||||
float t = getTemperatureC(config, tm);
|
float t = getTemperatureC(config, tm, useLinear);
|
||||||
|
|
||||||
thermistor_conf_s *tc = &config->config;
|
thermistor_conf_s *tc = &config->config;
|
||||||
|
|
||||||
|
@ -417,11 +417,13 @@ static void printTPSInfo(void) {
|
||||||
|
|
||||||
static void printTemperatureInfo(void) {
|
static void printTemperatureInfo(void) {
|
||||||
#if EFI_ANALOG_SENSORS || defined(__DOXYGEN__)
|
#if EFI_ANALOG_SENSORS || defined(__DOXYGEN__)
|
||||||
printThermistor("CLT", &engineConfiguration->clt, &engine->engineState.cltCurve);
|
printThermistor("CLT", &engineConfiguration->clt, &engine->engineState.cltCurve,
|
||||||
|
engineConfiguration->useLinearCltSensor);
|
||||||
if (!isValidCoolantTemperature(getCoolantTemperature(PASS_ENGINE_PARAMETER_SIGNATURE))) {
|
if (!isValidCoolantTemperature(getCoolantTemperature(PASS_ENGINE_PARAMETER_SIGNATURE))) {
|
||||||
scheduleMsg(&logger, "CLT sensing error");
|
scheduleMsg(&logger, "CLT sensing error");
|
||||||
}
|
}
|
||||||
printThermistor("IAT", &engineConfiguration->iat, &engine->engineState.iatCurve);
|
printThermistor("IAT", &engineConfiguration->iat, &engine->engineState.iatCurve,
|
||||||
|
engineConfiguration->useLinearIatSensor);
|
||||||
if (!isValidIntakeAirTemperature(getIntakeAirTemperature(PASS_ENGINE_PARAMETER_SIGNATURE))) {
|
if (!isValidIntakeAirTemperature(getIntakeAirTemperature(PASS_ENGINE_PARAMETER_SIGNATURE))) {
|
||||||
scheduleMsg(&logger, "IAT sensing error");
|
scheduleMsg(&logger, "IAT sensing error");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue