Browse Source

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

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
David 4 years ago
parent
commit
cfdfd16779
No account linked to committer's email address
2 changed files with 15 additions and 13 deletions
  1. 13
    13
      Marlin/src/module/temperature.cpp
  2. 2
    0
      Marlin/src/module/temperature.h

+ 13
- 13
Marlin/src/module/temperature.cpp View File

@@ -543,7 +543,7 @@ volatile bool Temperature::raw_temps_ready = false;
543 543
       #define GTV(C,B,H) C_GTV(ischamber, C, B_GTV(isbed, B, H))
544 544
       const uint16_t watch_temp_period = GTV(WATCH_CHAMBER_TEMP_PERIOD, WATCH_BED_TEMP_PERIOD, WATCH_TEMP_PERIOD);
545 545
       const uint8_t watch_temp_increase = GTV(WATCH_CHAMBER_TEMP_INCREASE, WATCH_BED_TEMP_INCREASE, WATCH_TEMP_INCREASE);
546
-      const celsius_float_t watch_temp_target = celsius_float_t(target - watch_temp_increase + GTV(TEMP_CHAMBER_HYSTERESIS, TEMP_BED_HYSTERESIS, TEMP_HYSTERESIS) + 1);
546
+      const celsius_float_t watch_temp_target = celsius_float_t(target - (watch_temp_increase + GTV(TEMP_CHAMBER_HYSTERESIS, TEMP_BED_HYSTERESIS, TEMP_HYSTERESIS) + 1));
547 547
       millis_t temp_change_ms = next_temp_ms + SEC_TO_MS(watch_temp_period);
548 548
       celsius_float_t next_watch_temp = 0.0;
549 549
       bool heated = false;
@@ -1253,13 +1253,13 @@ void Temperature::manage_heater() {
1253 1253
 
1254 1254
       #if WATCH_HOTENDS
1255 1255
         // Make sure temperature is increasing
1256
-        if (watch_hotend[e].next_ms && ELAPSED(ms, watch_hotend[e].next_ms)) {  // Time to check this extruder?
1257
-          if (degHotend(e) < watch_hotend[e].target) {                          // Failed to increase enough?
1256
+        if (watch_hotend[e].elapsed(ms)) {          // Enabled and time to check?
1257
+          if (watch_hotend[e].check(degHotend(e)))  // Increased enough?
1258
+            start_watching_hotend(e);               // If temp reached, turn off elapsed check
1259
+          else {
1258 1260
             TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0));
1259 1261
             _temp_error((heater_id_t)e, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
1260 1262
           }
1261
-          else                                                                  // Start again if the target is still far off
1262
-            start_watching_hotend(e);
1263 1263
         }
1264 1264
       #endif
1265 1265
 
@@ -1296,13 +1296,13 @@ void Temperature::manage_heater() {
1296 1296
 
1297 1297
     #if WATCH_BED
1298 1298
       // Make sure temperature is increasing
1299
-      if (watch_bed.elapsed(ms)) {        // Time to check the bed?
1300
-        if (degBed() < watch_bed.target) {                              // Failed to increase enough?
1299
+      if (watch_bed.elapsed(ms)) {              // Time to check the bed?
1300
+        if (watch_bed.check(degBed()))          // Increased enough?
1301
+          start_watching_bed();                 // If temp reached, turn off elapsed check
1302
+        else {
1301 1303
           TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0));
1302 1304
           _temp_error(H_BED, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
1303 1305
         }
1304
-        else                                                            // Start again if the target is still far off
1305
-          start_watching_bed();
1306 1306
       }
1307 1307
     #endif // WATCH_BED
1308 1308
 
@@ -1377,11 +1377,11 @@ void Temperature::manage_heater() {
1377 1377
 
1378 1378
     #if WATCH_CHAMBER
1379 1379
       // Make sure temperature is increasing
1380
-      if (watch_chamber.elapsed(ms)) {              // Time to check the chamber?
1381
-        if (degChamber() < watch_chamber.target)    // Failed to increase enough?
1382
-          _temp_error(H_CHAMBER, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
1380
+      if (watch_chamber.elapsed(ms)) {          // Time to check the chamber?
1381
+        if (watch_chamber.check(degChamber()))  // Increased enough? Error below.
1382
+          start_watching_chamber();             // If temp reached, turn off elapsed check.
1383 1383
         else
1384
-          start_watching_chamber();                 // Start again if the target is still far off
1384
+          _temp_error(H_CHAMBER, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
1385 1385
       }
1386 1386
     #endif
1387 1387
 

+ 2
- 0
Marlin/src/module/temperature.h View File

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

Loading…
Cancel
Save