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 Nov 19, 2023
1 parent 4bdd8f5 commit c3b432f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
28 changes: 18 additions & 10 deletions firmware/heater_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void HeaterControllerBase::Configure(float targetTempC, float targetEsr)
m_preheatTimer.reset();
m_warmupTimer.reset();
m_batteryStableTimer.reset();
m_closedLoopStableTimer.reset();
}

bool HeaterControllerBase::IsRunningClosedLoop() const
Expand Down Expand Up @@ -89,6 +90,7 @@ HeaterState HeaterControllerBase::GetNextState(HeaterState currentState, HeaterA
case HeaterState::WarmupRamp:
if (sensorTemp > closedLoopTemp)
{
m_closedLoopStableTimer.reset();
return HeaterState::ClosedLoop;
}
else if (m_warmupTimer.hasElapsedSec(m_warmupTimeSec))
Expand All @@ -99,16 +101,22 @@ HeaterState HeaterControllerBase::GetNextState(HeaterState currentState, HeaterA

break;
case HeaterState::ClosedLoop:
// 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 (m_closedLoopStableTimer.hasElapsedSec(HEATER_CLOSED_LOOP_STAB_TIME)) {
// 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;
}
} else {
// give some time for stabilization...
// looks like heavy ramped Ipump affects sensorTemp measure
// and right after switch to closed loop sensorTemp drops below underhead threshold
}

break;
Expand Down
1 change: 1 addition & 0 deletions firmware/heater_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class HeaterControllerBase : public IHeaterController
Timer m_batteryStableTimer;
Timer m_preheatTimer;
Timer m_warmupTimer;
Timer m_closedLoopStableTimer;

static const int batteryStabTimeCounter = HEATER_BATTERY_STAB_TIME / HEATER_CONTROL_PERIOD;
};
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 5
#define HEATER_WARMUP_TIMEOUT 60
#define HEATER_CLOSED_LOOP_STAB_TIME 5

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

0 comments on commit c3b432f

Please sign in to comment.