Fix Thermal Runaway false-alarm in M303, add HeaterWatch::check (#21743)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
David 2021-04-30 08:51:26 +02:00 committed by Scott Lahteine
parent 731a018905
commit a1154b226d
2 changed files with 15 additions and 13 deletions

View File

@ -543,7 +543,7 @@ volatile bool Temperature::raw_temps_ready = false;
#define GTV(C,B,H) C_GTV(ischamber, C, B_GTV(isbed, B, H)) #define GTV(C,B,H) C_GTV(ischamber, C, B_GTV(isbed, B, H))
const uint16_t watch_temp_period = GTV(WATCH_CHAMBER_TEMP_PERIOD, WATCH_BED_TEMP_PERIOD, WATCH_TEMP_PERIOD); const uint16_t watch_temp_period = GTV(WATCH_CHAMBER_TEMP_PERIOD, WATCH_BED_TEMP_PERIOD, WATCH_TEMP_PERIOD);
const uint8_t watch_temp_increase = GTV(WATCH_CHAMBER_TEMP_INCREASE, WATCH_BED_TEMP_INCREASE, WATCH_TEMP_INCREASE); const uint8_t watch_temp_increase = GTV(WATCH_CHAMBER_TEMP_INCREASE, WATCH_BED_TEMP_INCREASE, WATCH_TEMP_INCREASE);
const celsius_float_t watch_temp_target = celsius_float_t(target - watch_temp_increase + GTV(TEMP_CHAMBER_HYSTERESIS, TEMP_BED_HYSTERESIS, TEMP_HYSTERESIS) + 1); const celsius_float_t watch_temp_target = celsius_float_t(target - (watch_temp_increase + GTV(TEMP_CHAMBER_HYSTERESIS, TEMP_BED_HYSTERESIS, TEMP_HYSTERESIS) + 1));
millis_t temp_change_ms = next_temp_ms + SEC_TO_MS(watch_temp_period); millis_t temp_change_ms = next_temp_ms + SEC_TO_MS(watch_temp_period);
celsius_float_t next_watch_temp = 0.0; celsius_float_t next_watch_temp = 0.0;
bool heated = false; bool heated = false;
@ -1253,13 +1253,13 @@ void Temperature::manage_heater() {
#if WATCH_HOTENDS #if WATCH_HOTENDS
// Make sure temperature is increasing // Make sure temperature is increasing
if (watch_hotend[e].next_ms && ELAPSED(ms, watch_hotend[e].next_ms)) { // Time to check this extruder? if (watch_hotend[e].elapsed(ms)) { // Enabled and time to check?
if (degHotend(e) < watch_hotend[e].target) { // Failed to increase enough? if (watch_hotend[e].check(degHotend(e))) // Increased enough?
start_watching_hotend(e); // If temp reached, turn off elapsed check
else {
TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0)); TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0));
_temp_error((heater_id_t)e, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD)); _temp_error((heater_id_t)e, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
} }
else // Start again if the target is still far off
start_watching_hotend(e);
} }
#endif #endif
@ -1297,12 +1297,12 @@ void Temperature::manage_heater() {
#if WATCH_BED #if WATCH_BED
// Make sure temperature is increasing // Make sure temperature is increasing
if (watch_bed.elapsed(ms)) { // Time to check the bed? if (watch_bed.elapsed(ms)) { // Time to check the bed?
if (degBed() < watch_bed.target) { // Failed to increase enough? if (watch_bed.check(degBed())) // Increased enough?
start_watching_bed(); // If temp reached, turn off elapsed check
else {
TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0)); TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0));
_temp_error(H_BED, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD)); _temp_error(H_BED, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
} }
else // Start again if the target is still far off
start_watching_bed();
} }
#endif // WATCH_BED #endif // WATCH_BED
@ -1378,10 +1378,10 @@ void Temperature::manage_heater() {
#if WATCH_CHAMBER #if WATCH_CHAMBER
// Make sure temperature is increasing // Make sure temperature is increasing
if (watch_chamber.elapsed(ms)) { // Time to check the chamber? if (watch_chamber.elapsed(ms)) { // Time to check the chamber?
if (degChamber() < watch_chamber.target) // Failed to increase enough? if (watch_chamber.check(degChamber())) // Increased enough? Error below.
_temp_error(H_CHAMBER, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD)); start_watching_chamber(); // If temp reached, turn off elapsed check.
else else
start_watching_chamber(); // Start again if the target is still far off _temp_error(H_CHAMBER, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
} }
#endif #endif

View File

@ -233,6 +233,8 @@ struct HeaterWatch {
inline bool elapsed(const millis_t &ms) { return next_ms && ELAPSED(ms, next_ms); } inline bool elapsed(const millis_t &ms) { return next_ms && ELAPSED(ms, next_ms); }
inline bool elapsed() { return elapsed(millis()); } inline bool elapsed() { return elapsed(millis()); }
inline bool check(const celsius_t curr) { return curr >= target; }
inline void restart(const celsius_t curr, const celsius_t tgt) { inline void restart(const celsius_t curr, const celsius_t tgt) {
if (tgt) { if (tgt) {
const celsius_t newtarget = curr + INCREASE; const celsius_t newtarget = curr + INCREASE;