detect underheat fault

This commit is contained in:
Matthew Kennedy 2020-12-11 15:46:03 -08:00
parent b32d6bf80f
commit 5c9acd4c66
3 changed files with 9 additions and 3 deletions

View File

@ -7,6 +7,7 @@ enum class Fault
// First fault code at 3 so it's easier to see
SensorDidntHeat = 3,
SensorOverheat = 4,
SensorUnderheat = 5,
};
void setFault(Fault fault);

View File

@ -59,12 +59,16 @@ static HeaterState GetNextState(HeaterState state, float sensorEsr)
break;
case HeaterState::ClosedLoop:
// TODO: handle departure from closed loop
if (sensorEsr < HEATER_FAULT_ESR)
if (sensorEsr < HEATER_OVERHEAT_ESR)
{
setFault(Fault::SensorOverheat);
return HeaterState::Stopped;
}
else if (sensorEsr > HEATER_UNDERHEAT_ESR)
{
setFault(Fault::SensorUnderheat);
return HeaterState::Stopped;
}
break;
case HeaterState::Stopped: break;

View File

@ -38,4 +38,5 @@
#define HEATER_CLOSED_LOOP_THRESHOLD_ESR 2000
#define HEATER_TARGET_ESR 300
#define HEATER_FAULT_ESR 200
#define HEATER_OVERHEAT_ESR 200
#define HEATER_UNDERHEAT_ESR 3000