Bladeren bron

Hotend Idle Timeout (#16362)

Italo Soares 4 jaren geleden
bovenliggende
commit
213d4b890e
No account linked to committer's email address

+ 13
- 1
Marlin/Configuration_adv.h Bestand weergeven

@@ -330,6 +330,18 @@
330 330
   #define EXTRUDER_RUNOUT_EXTRUDE 5   // (mm)
331 331
 #endif
332 332
 
333
+/**
334
+ * Hotend Idle Timeout
335
+ * Prevent filament in the nozzle from charring and causing a critical jam.
336
+ */
337
+//#define HOTEND_IDLE_TIMEOUT
338
+#if ENABLED(HOTEND_IDLE_TIMEOUT)
339
+  #define HOTEND_IDLE_DURATION_SEC    5     // (minutes) Time without extruder movement to trigger protection
340
+  #define HOTEND_IDLE_MIN_TRIGGER   180     // (°C) Minimum temperature to enable hotend protection
341
+  #define HOTEND_IDLE_NOZZLE_TARGET   0     // (°C) Safe temperature for the nozzle after timeout
342
+  #define HOTEND_IDLE_BED_TARGET      0     // (°C) Safe temperature for the bed after timeout
343
+#endif
344
+
333 345
 // @section temperature
334 346
 
335 347
 // Calibration for AD595 / AD8495 sensor to adjust temperature measurements.
@@ -3308,7 +3320,7 @@
3308 3320
    */
3309 3321
 
3310 3322
   //#define MMU_EXTRUDER_SENSOR
3311
-  #if ENABLED(MMU_EXTRUDER_SENSOR) 
3323
+  #if ENABLED(MMU_EXTRUDER_SENSOR)
3312 3324
     #define MMU_LOADING_ATTEMPTS_NR 5 //max. number of attempts to load filament if first load fail
3313 3325
   #endif
3314 3326
 

+ 6
- 0
Marlin/src/MarlinCore.cpp Bestand weergeven

@@ -159,6 +159,10 @@
159 159
   #include "feature/runout.h"
160 160
 #endif
161 161
 
162
+#if ENABLED(HOTEND_IDLE_TIMEOUT)
163
+  #include "feature/hotend_idle.h"
164
+#endif
165
+
162 166
 #if ENABLED(TEMP_STAT_LEDS)
163 167
   #include "feature/leds/tempstat.h"
164 168
 #endif
@@ -527,6 +531,8 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
527 531
 
528 532
   TERN_(AUTO_POWER_CONTROL, powerManager.check());
529 533
 
534
+  TERN_(HOTEND_IDLE_TIMEOUT, hotend_idle.check());
535
+
530 536
   #if ENABLED(EXTRUDER_RUNOUT_PREVENT)
531 537
     if (thermalManager.degHotend(active_extruder) > EXTRUDER_RUNOUT_MINTEMP
532 538
       && ELAPSED(ms, gcode.previous_move_ms + SEC_TO_MS(EXTRUDER_RUNOUT_SECONDS))

+ 89
- 0
Marlin/src/feature/hotend_idle.cpp Bestand weergeven

@@ -0,0 +1,89 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * Hotend Idle Timeout
25
+ * Prevent filament in the nozzle from charring and causing a critical jam.
26
+ */
27
+
28
+#include "../inc/MarlinConfig.h"
29
+
30
+#if ENABLED(HOTEND_IDLE_TIMEOUT)
31
+
32
+#include "hotend_idle.h"
33
+#include "../gcode/gcode.h"
34
+
35
+#include "../module/temperature.h"
36
+#include "../module/motion.h"
37
+#include "../lcd/ultralcd.h"
38
+
39
+extern HotendIdleProtection hotend_idle;
40
+
41
+millis_t HotendIdleProtection::next_protect_ms = 0;
42
+
43
+void HotendIdleProtection::check_hotends(const millis_t &ms) {
44
+  bool do_prot = false;
45
+  HOTEND_LOOP() {
46
+    if (thermalManager.degHotendNear(e, HOTEND_IDLE_MIN_TRIGGER)) {
47
+      do_prot = true; break;
48
+    }
49
+  }
50
+  if (bool(next_protect_ms) != do_prot)
51
+    next_protect_ms = do_prot ? ms + hp_interval : 0;
52
+}
53
+
54
+void HotendIdleProtection::check_e_motion(const millis_t &ms) {
55
+  static float old_e_position = 0;
56
+  if (old_e_position != current_position.e) {
57
+    old_e_position = current_position.e;          // Track filament motion
58
+    if (next_protect_ms)                          // If some heater is on then...
59
+      next_protect_ms = ms + hp_interval;         // ...delay the timeout till later
60
+  }
61
+}
62
+
63
+void HotendIdleProtection::check() {
64
+  const millis_t ms = millis();                   // Shared millis
65
+
66
+  check_hotends(ms);                              // Any hotends need protection?
67
+  check_e_motion(ms);                             // Motion will protect them
68
+
69
+  // Hot and not moving for too long...
70
+  if (next_protect_ms && ELAPSED(ms, next_protect_ms))
71
+    timed_out();
72
+}
73
+
74
+// Lower (but don't raise) hotend / bed temperatures
75
+void HotendIdleProtection::timed_out() {
76
+  next_protect_ms = 0;
77
+  SERIAL_ECHOLNPGM("Hotend Idle Timeout");
78
+  LCD_MESSAGEPGM(MSG_HOTEND_IDLE_TIMEOUT);
79
+  HOTEND_LOOP() {
80
+    if ((HOTEND_IDLE_NOZZLE_TARGET) < thermalManager.degTargetHotend(e))
81
+      thermalManager.setTargetHotend(HOTEND_IDLE_NOZZLE_TARGET, e);
82
+  }
83
+  #if HAS_HEATED_BED
84
+    if ((HOTEND_IDLE_BED_TARGET) < thermalManager.degTargetBed())
85
+      thermalManager.setTargetBed(HOTEND_IDLE_BED_TARGET);
86
+  #endif
87
+}
88
+
89
+#endif // HOTEND_IDLE_TIMEOUT

+ 37
- 0
Marlin/src/feature/hotend_idle.h Bestand weergeven

@@ -0,0 +1,37 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include "../core/millis_t.h"
25
+
26
+class HotendIdleProtection {
27
+public:
28
+  static void check();
29
+private:
30
+  static constexpr millis_t hp_interval = SEC_TO_MS(HOTEND_IDLE_DURATION_SEC);
31
+  static millis_t next_protect_ms;
32
+  static void check_hotends(const millis_t &ms);
33
+  static void check_e_motion(const millis_t &ms);
34
+  static void timed_out();
35
+};
36
+
37
+extern HotendIdleProtection hotend_idle;

+ 1
- 0
Marlin/src/inc/Conditionals_LCD.h Bestand weergeven

@@ -414,6 +414,7 @@
414 414
   #undef MIXING_EXTRUDER
415 415
   #undef MK2_MULTIPLEXER
416 416
   #undef PRUSA_MMU2
417
+  #undef HOTEND_IDLE_TIMEOUT
417 418
 #endif
418 419
 
419 420
 #if ENABLED(SWITCHING_EXTRUDER)   // One stepper for every two EXTRUDERS

+ 1
- 0
Marlin/src/lcd/language/language_en.h Bestand weergeven

@@ -488,6 +488,7 @@ namespace Language_en {
488 488
   PROGMEM Language_Str MSG_INFO_PROTOCOL                   = _UxGT("Protocol");
489 489
   PROGMEM Language_Str MSG_INFO_RUNAWAY_OFF                = _UxGT("Runaway Watch: OFF");
490 490
   PROGMEM Language_Str MSG_INFO_RUNAWAY_ON                 = _UxGT("Runaway Watch: ON");
491
+  PROGMEM Language_Str MSG_HOTEND_IDLE_TIMEOUT             = _UxGT("Hotend Idle Timeout");
491 492
 
492 493
   PROGMEM Language_Str MSG_CASE_LIGHT                      = _UxGT("Case Light");
493 494
   PROGMEM Language_Str MSG_CASE_LIGHT_BRIGHTNESS           = _UxGT("Light Brightness");

+ 8
- 0
Marlin/src/module/temperature.h Bestand weergeven

@@ -612,6 +612,10 @@ class Temperature {
612 612
         return degTargetHotend(e) > TEMP_HYSTERESIS && ABS(degHotend(e) - degTargetHotend(e)) > TEMP_HYSTERESIS;
613 613
       }
614 614
 
615
+      FORCE_INLINE static bool degHotendNear(const uint8_t e, const float &temp) {
616
+        return ABS(degHotend(e) - temp) < (TEMP_HYSTERESIS);
617
+      }
618
+
615 619
     #endif // HOTENDS
616 620
 
617 621
     #if HAS_HEATED_BED
@@ -650,6 +654,10 @@ class Temperature {
650 654
 
651 655
       static void wait_for_bed_heating();
652 656
 
657
+      FORCE_INLINE static bool degBedNear(const float &temp) {
658
+        return ABS(degBed() - temp) < (TEMP_BED_HYSTERESIS);
659
+      }
660
+
653 661
     #endif // HAS_HEATED_BED
654 662
 
655 663
     #if HAS_TEMP_PROBE

+ 2
- 1
buildroot/share/tests/esp32-tests Bestand weergeven

@@ -31,7 +31,8 @@ opt_set X_HARDWARE_SERIAL Serial1
31 31
 opt_set Y_HARDWARE_SERIAL Serial1
32 32
 opt_set Z_HARDWARE_SERIAL Serial1
33 33
 opt_set E0_HARDWARE_SERIAL Serial1
34
-exec_test $1 $2 "ESP32 with TMC Hardware Serial"
34
+opt_enable HOTEND_IDLE_TIMEOUT
35
+exec_test $1 $2 "ESP32, TMC HW Serial, Hotend Idle"
35 36
 
36 37
 # cleanup
37 38
 restore_configs

Laden…
Annuleren
Opslaan