|
@ -646,7 +646,7 @@ void manage_heater() { |
|
|
#if TEMP_SENSOR_BED != 0 |
|
|
#if TEMP_SENSOR_BED != 0 |
|
|
|
|
|
|
|
|
#if HAS_BED_THERMAL_PROTECTION |
|
|
#if HAS_BED_THERMAL_PROTECTION |
|
|
thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, 9, THERMAL_RUNAWAY_PROTECTION_BED_PERIOD, THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS); |
|
|
thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, -1, THERMAL_RUNAWAY_PROTECTION_BED_PERIOD, THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#ifdef PIDTEMPBED |
|
|
#ifdef PIDTEMPBED |
|
@ -1007,21 +1007,21 @@ void setWatch() { |
|
|
|
|
|
|
|
|
void thermal_runaway_protection(TRState *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc) { |
|
|
void thermal_runaway_protection(TRState *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc) { |
|
|
|
|
|
|
|
|
static int tr_target_temperature = 0; |
|
|
static int tr_target_temperature[EXTRUDERS+1]; |
|
|
|
|
|
|
|
|
/*
|
|
|
/*
|
|
|
SERIAL_ECHO_START; |
|
|
SERIAL_ECHO_START; |
|
|
SERIAL_ECHO("Thermal Thermal Runaway Running. Heater ID:"); |
|
|
SERIAL_ECHOPGM("Thermal Thermal Runaway Running. Heater ID: "); |
|
|
SERIAL_ECHO(heater_id); |
|
|
if (heater_id < 0) SERIAL_ECHOPGM("bed"); else SERIAL_ECHOPGM(heater_id); |
|
|
SERIAL_ECHO(" ; State:"); |
|
|
SERIAL_ECHOPGM(" ; State:"); |
|
|
SERIAL_ECHO(*state); |
|
|
SERIAL_ECHOPGM(*state); |
|
|
SERIAL_ECHO(" ; Timer:"); |
|
|
SERIAL_ECHOPGM(" ; Timer:"); |
|
|
SERIAL_ECHO(*timer); |
|
|
SERIAL_ECHOPGM(*timer); |
|
|
SERIAL_ECHO(" ; Temperature:"); |
|
|
SERIAL_ECHOPGM(" ; Temperature:"); |
|
|
SERIAL_ECHO(temperature); |
|
|
SERIAL_ECHOPGM(temperature); |
|
|
SERIAL_ECHO(" ; Target Temp:"); |
|
|
SERIAL_ECHOPGM(" ; Target Temp:"); |
|
|
SERIAL_ECHO(target_temperature); |
|
|
SERIAL_ECHOPGM(target_temperature); |
|
|
SERIAL_ECHOLN(""); |
|
|
SERIAL_EOL; |
|
|
*/ |
|
|
*/ |
|
|
if (target_temperature == 0 || thermal_runaway) { |
|
|
if (target_temperature == 0 || thermal_runaway) { |
|
|
*state = TRInactive; |
|
|
*state = TRInactive; |
|
@ -1029,35 +1029,37 @@ void setWatch() { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int heater_index = heater_id >= 0 ? heater_id : EXTRUDERS; |
|
|
|
|
|
|
|
|
switch (*state) { |
|
|
switch (*state) { |
|
|
// Inactive state waits for a target temperature to be set
|
|
|
// Inactive state waits for a target temperature to be set
|
|
|
case TRInactive: |
|
|
case TRInactive: |
|
|
if (target_temperature > 0) { |
|
|
if (target_temperature > 0) { |
|
|
*state = TRFirstHeating; |
|
|
*state = TRFirstHeating; |
|
|
tr_target_temperature = target_temperature; |
|
|
tr_target_temperature[heater_index] = target_temperature; |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
// When first heating, wait for the temperature to be reached then go to Stable state
|
|
|
// When first heating, wait for the temperature to be reached then go to Stable state
|
|
|
case TRFirstHeating: |
|
|
case TRFirstHeating: |
|
|
if (temperature >= tr_target_temperature) *state = TRStable; |
|
|
if (temperature >= tr_target_temperature[heater_index]) *state = TRStable; |
|
|
break; |
|
|
break; |
|
|
// While the temperature is stable watch for a bad temperature
|
|
|
// While the temperature is stable watch for a bad temperature
|
|
|
case TRStable: |
|
|
case TRStable: |
|
|
{ |
|
|
{ |
|
|
// If the target temperature changes, restart
|
|
|
// If the target temperature changes, restart
|
|
|
if (tr_target_temperature != target_temperature) { |
|
|
if (tr_target_temperature[heater_index] != target_temperature) { |
|
|
*state = TRInactive; |
|
|
*state = TRInactive; |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// If the temperature is over the target (-hysteresis) restart the timer
|
|
|
// If the temperature is over the target (-hysteresis) restart the timer
|
|
|
if (temperature >= tr_target_temperature - hysteresis_degc) *timer = millis(); |
|
|
if (temperature >= tr_target_temperature[heater_index] - hysteresis_degc) *timer = millis(); |
|
|
|
|
|
|
|
|
// If the timer goes too long without a reset, trigger shutdown
|
|
|
// If the timer goes too long without a reset, trigger shutdown
|
|
|
else if (millis() > *timer + period_seconds * 1000UL) { |
|
|
else if (millis() > *timer + period_seconds * 1000UL) { |
|
|
SERIAL_ERROR_START; |
|
|
SERIAL_ERROR_START; |
|
|
SERIAL_ERRORLNPGM(MSG_THERMAL_RUNAWAY_STOP); |
|
|
SERIAL_ERRORLNPGM(MSG_THERMAL_RUNAWAY_STOP); |
|
|
SERIAL_ERRORLN((int)heater_id); |
|
|
if (heater_id < 0) SERIAL_ERRORLNPGM("bed"); else SERIAL_ERRORLN(heater_id); |
|
|
LCD_ALERTMESSAGEPGM(MSG_THERMAL_RUNAWAY); |
|
|
LCD_ALERTMESSAGEPGM(MSG_THERMAL_RUNAWAY); |
|
|
thermal_runaway = true; |
|
|
thermal_runaway = true; |
|
|
for (;;) { |
|
|
for (;;) { |
|
|