detect sensor overheat

This commit is contained in:
Matthew Kennedy 2020-12-10 22:08:00 -08:00
parent 1110cc81ff
commit c711252791
3 changed files with 15 additions and 3 deletions

View File

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

View File

@ -20,7 +20,7 @@ enum class HeaterState
Stopped,
};
int timeCounter = 5000 / 50;
int timeCounter = HEATER_PREHEAT_TIME / HEATER_CONTROL_PERIOD;
float rampDuty = 0.5f;
static HeaterState GetNextState(HeaterState state, float sensorEsr)
@ -37,7 +37,7 @@ static HeaterState GetNextState(HeaterState state, float sensorEsr)
rampDuty = 0.5f;
// Next phase times out at 15 seconds
timeCounter = 15000 / 50;
timeCounter = HEATER_WARMUP_TIMEOUT / HEATER_CONTROL_PERIOD;
return HeaterState::WarmupRamp;
}
@ -45,7 +45,7 @@ static HeaterState GetNextState(HeaterState state, float sensorEsr)
// Stay in preheat - wait for time to elapse
break;
case HeaterState::WarmupRamp:
if (sensorEsr < 1000)
if (sensorEsr < HEATER_CLOSED_LOOP_THRESHOLD_ESR)
{
return HeaterState::ClosedLoop;
}
@ -60,6 +60,11 @@ static HeaterState GetNextState(HeaterState state, float sensorEsr)
break;
case HeaterState::ClosedLoop:
// TODO: handle departure from closed loop
if (sensorEsr < HEATER_FAULT_ESR)
{
setFault(Fault::SensorOverheat);
}
break;
case HeaterState::Stopped: break;
}

View File

@ -32,4 +32,10 @@
// Heater controller config
// *******************************
#define HEATER_CONTROL_PERIOD 50
#define HEATER_PREHEAT_TIME 5000
#define HEATER_WARMUP_TIMEOUT 15000
#define HEATER_CLOSED_LOOP_THRESHOLD_ESR 1000
#define HEATER_TARGET_ESR 300
#define HEATER_FAULT_ESR 200