Use a 0.5s timeout for over/underheat to reject transients

This commit is contained in:
Matthew Kennedy 2024-09-24 18:35:44 -07:00
parent b16b3239bb
commit a34e0bbdf2
2 changed files with 18 additions and 2 deletions

View File

@ -117,12 +117,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)
if (sensorTemp <= overheatTemp)
{
m_overheatTimer.reset();
}
if (sensorTemp >= underheatTemp)
{
m_underheatTimer.reset();
}
if (m_overheatTimer.hasElapsedSec(0.5f))
{
SetFault(ch, Fault::SensorOverheat);
return HeaterState::Stopped;
}
else if (sensorTemp < underheatTemp)
else if (m_underheatTimer.hasElapsedSec(0.5f))
{
SetFault(ch, Fault::SensorUnderheat);
return HeaterState::Stopped;

View File

@ -76,6 +76,12 @@ private:
Timer m_preheatTimer;
Timer m_warmupTimer;
// Stores the time since a non-over/underheat condition
// If the timer reaches a threshold, an over/underheat has
// occured
Timer m_underheatTimer;
Timer m_overheatTimer;
static const int batteryStabTimeCounter = HEATER_BATTERY_STAB_TIME / HEATER_CONTROL_PERIOD;
};