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 Jul 15, 2023
1 parent 6627ba6 commit 05b8add
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
24 changes: 15 additions & 9 deletions firmware/heater_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,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;

class HeaterController : public IHeaterController
Expand Down Expand Up @@ -190,6 +191,7 @@ HeaterState HeaterController::GetNextState(HeaterAllow heaterAllowState, float b
case HeaterState::WarmupRamp:
if (sensorTemp > closedLoopTemp)
{
s.timeCounter = closedLoopStabTimeCounter;
return HeaterState::ClosedLoop;
}
else if (timeCounter == 0)
Expand All @@ -202,16 +204,20 @@ HeaterState HeaterController::GetNextState(HeaterAllow heaterAllowState, float b

break;
case HeaterState::ClosedLoop:
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 (sensorTemp > overheatTemp)
{
SetFault(ch, Fault::SensorOverheat);
return HeaterState::Stopped;
}
else if (sensorTemp < underheatTemp)
{
SetFault(ch, Fault::SensorUnderheat);
return HeaterState::Stopped;
if (sensorTemp > overheatTemp) {
SetFault(ch, Fault::SensorOverheat);
return HeaterState::Stopped;
} else if (sensorTemp < underheatTemp) {
SetFault(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 05b8add

Please sign in to comment.