progress towards #961

This commit is contained in:
rusefi 2019-11-04 22:44:52 -05:00
parent 79fd7fc8ce
commit bab1744d1d
3 changed files with 11 additions and 8 deletions

View File

@ -293,7 +293,7 @@ static percent_t automaticIdleController(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
int idlePidLowerRpm = targetRpm + CONFIG(idlePidRpmDeadZone);
if (CONFIG(idlePidRpmUpperLimit) > 0) {
engine->engineState.idle.idleState = PID_UPPER;
if (CONFIGB(useIacTableForCoasting) && !cisnan(engine->sensors.clt)) {
if (CONFIGB(useIacTableForCoasting) && hasCltSensor()) {
percent_t iacPosForCoasting = interpolate2d("iacCoasting", getCoolantTemperature(), CONFIG(iacCoastingBins), CONFIG(iacCoasting));
newValue = interpolateClamped(idlePidLowerRpm, newValue, idlePidLowerRpm + CONFIG(idlePidRpmUpperLimit), iacPosForCoasting, rpm);
} else {
@ -371,7 +371,7 @@ static percent_t automaticIdleController(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#endif /* EFI_SHAFT_POSITION_INPUT */
// cltCorrection is used only for cranking or running in manual mode
float cltCorrection;
if (cisnan(clt))
if (!hasCltSensor())
cltCorrection = 1.0f;
// Use separate CLT correction table for cranking
else if (engineConfiguration->overrideCrankingIacSetting && !isRunning) {

View File

@ -548,7 +548,7 @@ void setTargetRpmCurve(int rpm DECLARE_CONFIG_PARAMETER_SUFFIX) {
int getTargetRpmForIdleCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
float clt = getCoolantTemperature();
int targetRpm;
if (cisnan(clt)) {
if (!hasCltSensor()) {
// error is already reported, let's take first value from the table should be good enough error handing solution
targetRpm = CONFIG(cltIdleRpm)[0];
} else {

View File

@ -129,15 +129,14 @@ bool hasCltSensorM(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (!haveSensorChannel) {
return false;
}
// return !cisnan(engine->sensors.clt); todo why would unit tests fail?!
return true;
return !cisnan(engine->sensors.clt);
}
/**
* @return coolant temperature, in Celsius
*/
temperature_t getCoolantTemperatureM(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (!hasCltSensor()) {
if (engineConfiguration->clt.adcChannel == EFI_ADC_NONE) {
engine->isCltBroken = false;
return NO_CLT_SENSOR_TEMPERATURE;
}
@ -212,14 +211,18 @@ void ThermistorMath::prepareThermistorCurve(thermistor_conf_s *tc) {
}
bool hasIatSensorM(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
return engineConfiguration->iat.adcChannel != EFI_ADC_NONE;
bool haveSensorChannel = engineConfiguration->iat.adcChannel != EFI_ADC_NONE;
if (!haveSensorChannel) {
return false;
}
return !cisnan(engine->sensors.iat);
}
/**
* @return Celsius value
*/
temperature_t getIntakeAirTemperatureM(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (!hasIatSensor()) {
if (engineConfiguration->iat.adcChannel == EFI_ADC_NONE) {
return NO_IAT_SENSOR_TEMPERATURE;
}
float temperature = getTemperatureC(&engineConfiguration->iat, &engine->engineState.iatCurve,