Skip to content

Commit

Permalink
heater: 5 sec stabilization time after switching to closed loop
Browse files Browse the repository at this point in the history
LSU4.2 falls to Underheated state right after switch to closed loop
due to rise of sensorEsr (due to applied pump current?)
  • Loading branch information
dron0gus authored and rusefillc committed Mar 22, 2023
1 parent e9343db commit ea16833
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
29 changes: 19 additions & 10 deletions firmware/heater_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ static const PWMConfig heaterPwmConfig = {

static constexpr int preheatTimeCounter = HEATER_PREHEAT_TIME / HEATER_CONTROL_PERIOD;
static constexpr int batteryStabTimeCounter = HEATER_BATTERY_STAB_TIME / HEATER_CONTROL_PERIOD;
static constexpr int closedLoopStabTimeCounter = HEATER_CLOSED_LOOP_STAB_TIME / HEATER_CONTROL_PERIOD;
static const struct sensorHeaterParams *heater;

struct heater_state {
Expand Down Expand Up @@ -169,6 +170,7 @@ static HeaterState GetNextState(struct heater_state &s, HeaterAllow heaterAllowS
case HeaterState::WarmupRamp:
if (sensorEsr < heater->closedLoopThresholdESR)
{
s.timeCounter = closedLoopStabTimeCounter;
return HeaterState::ClosedLoop;
}
else if (s.timeCounter == 0)
Expand All @@ -181,16 +183,23 @@ static HeaterState GetNextState(struct heater_state &s, HeaterAllow heaterAllowS

break;
case HeaterState::ClosedLoop:
// Check that the sensor's ESR is acceptable for normal operation
if (sensorEsr < heater->overheatESR)
{
SetFault(s.ch, Fault::SensorOverheat);
return HeaterState::Stopped;
}
else if (sensorEsr > heater->underheatESR)
{
SetFault(s.ch, Fault::SensorUnderheat);
return HeaterState::Stopped;
if (s.timeCounter > 0) {
// give some time for stabilization...
// looks like heavy ramped Ipump affects sensorEsr measure
// and right after switch to closed loop sensorEsr rises above underhead threshold
s.timeCounter--;
} else {
// Check that the sensor's ESR is acceptable for normal operation
if (sensorEsr < heater->overheatESR)
{
SetFault(s.ch, Fault::SensorOverheat);
return HeaterState::Stopped;
}
else if (sensorEsr > heater->underheatESR)
{
SetFault(s.ch, Fault::SensorUnderheat);
return HeaterState::Stopped;
}
}

break;
Expand Down
1 change: 1 addition & 0 deletions firmware/wideband_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

#define HEATER_PREHEAT_TIME 5000
#define HEATER_WARMUP_TIMEOUT 60000
#define HEATER_CLOSED_LOOP_STAB_TIME 5000

#define HEATER_BATTERY_STAB_TIME 3000
// minimal battery voltage to start heating without CAN command
Expand Down

0 comments on commit ea16833

Please sign in to comment.