Browse Source

[2.0.x] Fix_Autotune_THERMAL_PROTECTION_BED_off (#10166)

- Fix Autotune Thermal Protection
- Make 2 constants in autotune configurable
AnHardt 7 years ago
parent
commit
837ac2fdbd
1 changed files with 29 additions and 14 deletions
  1. 29
    14
      Marlin/src/module/temperature.cpp

+ 29
- 14
Marlin/src/module/temperature.cpp View File

@@ -409,7 +409,9 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS],
409 409
       }
410 410
 
411 411
       // Did the temperature overshoot very far?
412
-      #define MAX_OVERSHOOT_PID_AUTOTUNE 20
412
+      #ifndef MAX_OVERSHOOT_PID_AUTOTUNE
413
+        #define MAX_OVERSHOOT_PID_AUTOTUNE 20
414
+      #endif
413 415
       if (current > target + MAX_OVERSHOOT_PID_AUTOTUNE) {
414 416
         SERIAL_PROTOCOLLNPGM(MSG_PID_TEMP_TOO_HIGH);
415 417
         break;
@@ -425,24 +427,37 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS],
425 427
 
426 428
         // Make sure heating is actually working
427 429
         #if WATCH_THE_BED || WATCH_HOTENDS
428
-          if (!heated) {                                          // If not yet reached target...
429
-            if (current > next_watch_temp) {                      // Over the watch temp?
430
-              next_watch_temp = current + watch_temp_increase;    // - set the next temp to watch for
431
-              temp_change_ms = ms + watch_temp_period * 1000UL;   // - move the expiration timer up
432
-              if (current > watch_temp_target) heated = true;     // - Flag if target temperature reached
430
+          if (
431
+            #if WATCH_THE_BED && WATCH_HOTENDS
432
+              true
433
+            #elif WATCH_THE_BED
434
+              hotend < 0
435
+            #else
436
+              hotend >= 0
437
+            #endif
438
+          ) {
439
+            if (!heated) {                                          // If not yet reached target...
440
+              if (current > next_watch_temp) {                      // Over the watch temp?
441
+                next_watch_temp = current + watch_temp_increase;    // - set the next temp to watch for
442
+                temp_change_ms = ms + watch_temp_period * 1000UL;   // - move the expiration timer up
443
+                if (current > watch_temp_target) heated = true;     // - Flag if target temperature reached
444
+              }
445
+              else if (ELAPSED(ms, temp_change_ms))                 // Watch timer expired
446
+                _temp_error(hotend, PSTR(MSG_T_HEATING_FAILED), PSTR(MSG_HEATING_FAILED_LCD));
433 447
             }
434
-            else if (ELAPSED(ms, temp_change_ms))                 // Watch timer expired
435
-              _temp_error(hotend, PSTR(MSG_T_HEATING_FAILED), PSTR(MSG_HEATING_FAILED_LCD));
448
+            else if (current < target - (MAX_OVERSHOOT_PID_AUTOTUNE)) // Heated, then temperature fell too far?
449
+              _temp_error(hotend, PSTR(MSG_T_THERMAL_RUNAWAY),
450
+                hotend >= 0 ? PSTR(MSG_THERMAL_RUNAWAY) : PSTR(MSG_THERMAL_RUNAWAY_BED)
451
+              );
436 452
           }
437
-          else if (current < target - (MAX_OVERSHOOT_PID_AUTOTUNE)) // Heated, then temperature fell too far?
438
-            _temp_error(hotend, PSTR(MSG_T_THERMAL_RUNAWAY),
439
-              hotend >= 0 ? PSTR(MSG_THERMAL_RUNAWAY) : PSTR(MSG_THERMAL_RUNAWAY_BED)
440
-            );
441 453
         #endif
442 454
       } // every 2 seconds
443 455
 
444
-      // Timeout after 20 minutes since the last undershoot/overshoot cycle
445
-      if (((ms - t1) + (ms - t2)) > (20L * 60L * 1000L)) {
456
+      // Timeout after MAX_CYCLE_TIME_PID_AUTOTUNE minutes since the last undershoot/overshoot cycle
457
+      #ifndef MAX_CYCLE_TIME_PID_AUTOTUNE
458
+        #define MAX_CYCLE_TIME_PID_AUTOTUNE 20L
459
+      #endif
460
+      if (((ms - t1) + (ms - t2)) > (MAX_CYCLE_TIME_PID_AUTOTUNE * 60L * 1000L)) {
446 461
         SERIAL_PROTOCOLLNPGM(MSG_PID_TIMEOUT);
447 462
         break;
448 463
       }

Loading…
Cancel
Save