diff --git a/firmware/heater_control.cpp b/firmware/heater_control.cpp index a0b52441..b4bfc778 100644 --- a/firmware/heater_control.cpp +++ b/firmware/heater_control.cpp @@ -20,6 +20,7 @@ void HeaterControllerBase::Configure(float targetTempC, float targetEsr) m_preheatTimer.reset(); m_warmupTimer.reset(); m_batteryStableTimer.reset(); + m_closedLoopStableTimer.reset(); } bool HeaterControllerBase::IsRunningClosedLoop() const @@ -89,6 +90,7 @@ HeaterState HeaterControllerBase::GetNextState(HeaterState currentState, HeaterA case HeaterState::WarmupRamp: if (sensorTemp > closedLoopTemp) { + m_closedLoopStableTimer.reset(); return HeaterState::ClosedLoop; } else if (m_warmupTimer.hasElapsedSec(m_warmupTimeSec)) @@ -99,16 +101,22 @@ HeaterState HeaterControllerBase::GetNextState(HeaterState currentState, HeaterA break; case HeaterState::ClosedLoop: - // Check that the sensor's ESR is acceptable for normal operation - if (sensorTemp > overheatTemp) - { - SetFault(ch, Fault::SensorOverheat); - return HeaterState::Stopped; - } - else if (sensorTemp < underheatTemp) - { - SetFault(ch, Fault::SensorUnderheat); - return HeaterState::Stopped; + if (m_closedLoopStableTimer.hasElapsedSec(HEATER_CLOSED_LOOP_STAB_TIME)) { + // Check that the sensor's ESR is acceptable for normal operation + if (sensorTemp > overheatTemp) + { + SetFault(ch, Fault::SensorOverheat); + return HeaterState::Stopped; + } + else if (sensorTemp < underheatTemp) + { + SetFault(ch, Fault::SensorUnderheat); + return HeaterState::Stopped; + } + } else { + // give some time for stabilization... + // looks like heavy ramped Ipump affects sensorTemp measure + // and right after switch to closed loop sensorTemp drops below underhead threshold } break; diff --git a/firmware/heater_control.h b/firmware/heater_control.h index df0b2a2d..bb6aa7d7 100644 --- a/firmware/heater_control.h +++ b/firmware/heater_control.h @@ -73,6 +73,7 @@ class HeaterControllerBase : public IHeaterController Timer m_batteryStableTimer; Timer m_preheatTimer; Timer m_warmupTimer; + Timer m_closedLoopStableTimer; static const int batteryStabTimeCounter = HEATER_BATTERY_STAB_TIME / HEATER_CONTROL_PERIOD; }; diff --git a/firmware/wideband_config.h b/firmware/wideband_config.h index 6e1000da..53ccc30d 100644 --- a/firmware/wideband_config.h +++ b/firmware/wideband_config.h @@ -42,6 +42,7 @@ #define HEATER_PREHEAT_TIME 5 #define HEATER_WARMUP_TIMEOUT 60 +#define HEATER_CLOSED_LOOP_STAB_TIME 5 #define HEATER_BATTERY_STAB_TIME 0.5f // minimal battery voltage to start heating without CAN command