|
|
@ -196,6 +196,7 @@ |
|
|
|
Temperature thermalManager; |
|
|
|
|
|
|
|
PGMSTR(str_t_thermal_runaway, STR_T_THERMAL_RUNAWAY); |
|
|
|
PGMSTR(str_t_temp_malfunction, STR_T_MALFUNCTION); |
|
|
|
PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); |
|
|
|
|
|
|
|
/**
|
|
|
@ -2570,14 +2571,30 @@ void Temperature::init() { |
|
|
|
); |
|
|
|
*/ |
|
|
|
|
|
|
|
#if ENABLED(THERMAL_PROTECTION_VARIANCE_MONITOR) |
|
|
|
if (state == TRMalfunction) { // temperature invariance may continue, regardless of heater state
|
|
|
|
variance += ABS(current - last_temp); // no need for detection window now, a single change in variance is enough
|
|
|
|
last_temp = current; |
|
|
|
if (!NEAR_ZERO(variance)) { |
|
|
|
variance_timer = millis() + SEC_TO_MS(period_seconds); |
|
|
|
variance = 0.0; |
|
|
|
state = TRStable; // resume from where we detected the problem
|
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
if (TERN1(THERMAL_PROTECTION_VARIANCE_MONITOR, state != TRMalfunction)) { |
|
|
|
// If the heater idle timeout expires, restart
|
|
|
|
if (TERN0(HEATER_IDLE_HANDLER, heater_idle[idle_index].timed_out)) { |
|
|
|
state = TRInactive; |
|
|
|
running_temp = 0; |
|
|
|
TERN_(THERMAL_PROTECTION_VARIANCE_MONITOR, variance_timer = 0); |
|
|
|
} |
|
|
|
else if (running_temp != target) { // If the target temperature changes, restart
|
|
|
|
running_temp = target; |
|
|
|
state = target > 0 ? TRFirstHeating : TRInactive; |
|
|
|
TERN_(THERMAL_PROTECTION_VARIANCE_MONITOR, variance_timer = 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
switch (state) { |
|
|
@ -2610,6 +2627,22 @@ void Temperature::init() { |
|
|
|
|
|
|
|
const millis_t now = millis(); |
|
|
|
|
|
|
|
#if ENABLED(THERMAL_PROTECTION_VARIANCE_MONITOR) |
|
|
|
if (PENDING(now, variance_timer)) { |
|
|
|
variance += ABS(current - last_temp); |
|
|
|
last_temp = current; |
|
|
|
} |
|
|
|
else { |
|
|
|
if (NEAR_ZERO(variance) && variance_timer) { // valid variance monitoring window
|
|
|
|
state = TRMalfunction; |
|
|
|
break; |
|
|
|
} |
|
|
|
variance_timer = now + SEC_TO_MS(period_seconds); |
|
|
|
variance = 0.0; |
|
|
|
last_temp = current; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
if (current >= running_temp - hysteresis_degc) { |
|
|
|
timer = now + SEC_TO_MS(period_seconds); |
|
|
|
break; |
|
|
@ -2622,6 +2655,12 @@ void Temperature::init() { |
|
|
|
case TRRunaway: |
|
|
|
TERN_(HAS_DWIN_E3V2_BASIC, DWIN_Popup_Temperature(0)); |
|
|
|
_temp_error(heater_id, FPSTR(str_t_thermal_runaway), GET_TEXT_F(MSG_THERMAL_RUNAWAY)); |
|
|
|
|
|
|
|
#if ENABLED(THERMAL_PROTECTION_VARIANCE_MONITOR) |
|
|
|
case TRMalfunction: |
|
|
|
TERN_(HAS_DWIN_E3V2_BASIC, DWIN_Popup_Temperature(0)); |
|
|
|
_temp_error(heater_id, FPSTR(str_t_temp_malfunction), GET_TEXT_F(MSG_TEMP_MALFUNCTION)); |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|