My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hotend_idle.cpp 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * Hotend Idle Timeout
  24. * Prevent filament in the nozzle from charring and causing a critical jam.
  25. */
  26. #include "../inc/MarlinConfig.h"
  27. #if ENABLED(HOTEND_IDLE_TIMEOUT)
  28. #include "hotend_idle.h"
  29. #include "../gcode/gcode.h"
  30. #include "../module/temperature.h"
  31. #include "../module/motion.h"
  32. #include "../lcd/marlinui.h"
  33. extern HotendIdleProtection hotend_idle;
  34. millis_t HotendIdleProtection::next_protect_ms = 0;
  35. void HotendIdleProtection::check_hotends(const millis_t &ms) {
  36. bool do_prot = false;
  37. HOTEND_LOOP() {
  38. if (thermalManager.degHotend(e) >= HOTEND_IDLE_MIN_TRIGGER) {
  39. do_prot = true; break;
  40. }
  41. }
  42. if (bool(next_protect_ms) != do_prot)
  43. next_protect_ms = do_prot ? ms + hp_interval : 0;
  44. }
  45. void HotendIdleProtection::check_e_motion(const millis_t &ms) {
  46. static float old_e_position = 0;
  47. if (old_e_position != current_position.e) {
  48. old_e_position = current_position.e; // Track filament motion
  49. if (next_protect_ms) // If some heater is on then...
  50. next_protect_ms = ms + hp_interval; // ...delay the timeout till later
  51. }
  52. }
  53. void HotendIdleProtection::check() {
  54. const millis_t ms = millis(); // Shared millis
  55. check_hotends(ms); // Any hotends need protection?
  56. check_e_motion(ms); // Motion will protect them
  57. // Hot and not moving for too long...
  58. if (next_protect_ms && ELAPSED(ms, next_protect_ms))
  59. timed_out();
  60. }
  61. // Lower (but don't raise) hotend / bed temperatures
  62. void HotendIdleProtection::timed_out() {
  63. next_protect_ms = 0;
  64. SERIAL_ECHOLNPGM("Hotend Idle Timeout");
  65. LCD_MESSAGEPGM(MSG_HOTEND_IDLE_TIMEOUT);
  66. HOTEND_LOOP() {
  67. if ((HOTEND_IDLE_NOZZLE_TARGET) < thermalManager.degTargetHotend(e))
  68. thermalManager.setTargetHotend(HOTEND_IDLE_NOZZLE_TARGET, e);
  69. }
  70. #if HAS_HEATED_BED
  71. if ((HOTEND_IDLE_BED_TARGET) < thermalManager.degTargetBed())
  72. thermalManager.setTargetBed(HOTEND_IDLE_BED_TARGET);
  73. #endif
  74. }
  75. #endif // HOTEND_IDLE_TIMEOUT