diff --git a/firmware/fault.h b/firmware/fault.h index 7b4967a..b65813c 100644 --- a/firmware/fault.h +++ b/firmware/fault.h @@ -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); diff --git a/firmware/heater_control.cpp b/firmware/heater_control.cpp index 2cd564a..4a85652 100644 --- a/firmware/heater_control.cpp +++ b/firmware/heater_control.cpp @@ -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; diff --git a/firmware/wideband_config.h b/firmware/wideband_config.h index b0730af..e75a3f0 100644 --- a/firmware/wideband_config.h +++ b/firmware/wideband_config.h @@ -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