Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

heater: 5 sec stabilization time after switching to closed loop #222

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -101,6 +102,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 @@ -111,16 +113,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
Loading