diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index b79035ab69..dafb271b5f 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -17,8 +17,8 @@ //// Heating sanity check: // This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature // If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE +// It can be reset with another M104/M109. This check is also only triggered if the target temperature and +// the current temperature differ by at least 2x WATCH_TEMP_INCREASE //#define WATCH_TEMP_PERIOD 40000 //40 seconds //#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds diff --git a/Marlin/configurator/config/Configuration_adv.h b/Marlin/configurator/config/Configuration_adv.h index b79035ab69..dafb271b5f 100644 --- a/Marlin/configurator/config/Configuration_adv.h +++ b/Marlin/configurator/config/Configuration_adv.h @@ -17,8 +17,8 @@ //// Heating sanity check: // This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature // If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE +// It can be reset with another M104/M109. This check is also only triggered if the target temperature and +// the current temperature differ by at least 2x WATCH_TEMP_INCREASE //#define WATCH_TEMP_PERIOD 40000 //40 seconds //#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds diff --git a/Marlin/example_configurations/Felix/Configuration_adv.h b/Marlin/example_configurations/Felix/Configuration_adv.h index 672b3ff028..52cb51bfe7 100644 --- a/Marlin/example_configurations/Felix/Configuration_adv.h +++ b/Marlin/example_configurations/Felix/Configuration_adv.h @@ -17,8 +17,8 @@ //// Heating sanity check: // This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature // If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE +// It can be reset with another M104/M109. This check is also only triggered if the target temperature and +// the current temperature differ by at least 2x WATCH_TEMP_INCREASE //#define WATCH_TEMP_PERIOD 40000 //40 seconds //#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds diff --git a/Marlin/example_configurations/Hephestos/Configuration_adv.h b/Marlin/example_configurations/Hephestos/Configuration_adv.h index 5713373d16..cb736f2cba 100644 --- a/Marlin/example_configurations/Hephestos/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos/Configuration_adv.h @@ -17,8 +17,8 @@ //// Heating sanity check: // This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature // If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE +// It can be reset with another M104/M109. This check is also only triggered if the target temperature and +// the current temperature differ by at least 2x WATCH_TEMP_INCREASE //#define WATCH_TEMP_PERIOD 40000 //40 seconds //#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds diff --git a/Marlin/example_configurations/K8200/Configuration_adv.h b/Marlin/example_configurations/K8200/Configuration_adv.h index 672b3ff028..52cb51bfe7 100644 --- a/Marlin/example_configurations/K8200/Configuration_adv.h +++ b/Marlin/example_configurations/K8200/Configuration_adv.h @@ -17,8 +17,8 @@ //// Heating sanity check: // This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature // If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE +// It can be reset with another M104/M109. This check is also only triggered if the target temperature and +// the current temperature differ by at least 2x WATCH_TEMP_INCREASE //#define WATCH_TEMP_PERIOD 40000 //40 seconds //#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds diff --git a/Marlin/example_configurations/SCARA/Configuration_adv.h b/Marlin/example_configurations/SCARA/Configuration_adv.h index a706696aad..4e90b004b7 100644 --- a/Marlin/example_configurations/SCARA/Configuration_adv.h +++ b/Marlin/example_configurations/SCARA/Configuration_adv.h @@ -17,8 +17,8 @@ //// Heating sanity check: // This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature // If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE +// It can be reset with another M104/M109. This check is also only triggered if the target temperature and +// the current temperature differ by at least 2x WATCH_TEMP_INCREASE //#define WATCH_TEMP_PERIOD 40000 //40 seconds //#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds diff --git a/Marlin/example_configurations/WITBOX/Configuration_adv.h b/Marlin/example_configurations/WITBOX/Configuration_adv.h index 25abd17c2c..f3778a715c 100644 --- a/Marlin/example_configurations/WITBOX/Configuration_adv.h +++ b/Marlin/example_configurations/WITBOX/Configuration_adv.h @@ -17,8 +17,8 @@ //// Heating sanity check: // This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature // If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE +// It can be reset with another M104/M109. This check is also only triggered if the target temperature and +// the current temperature differ by at least 2x WATCH_TEMP_INCREASE //#define WATCH_TEMP_PERIOD 40000 //40 seconds //#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds diff --git a/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h b/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h index d035073b8d..7fb10e3c45 100644 --- a/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h +++ b/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h @@ -17,8 +17,8 @@ //// Heating sanity check: // This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature // If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE +// It can be reset with another M104/M109. This check is also only triggered if the target temperature and +// the current temperature differ by at least 2x WATCH_TEMP_INCREASE #define WATCH_TEMP_PERIOD 40000 //40 seconds #define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds diff --git a/Marlin/example_configurations/delta/generic/Configuration_adv.h b/Marlin/example_configurations/delta/generic/Configuration_adv.h index cdfa7c8f93..d90b0d5c05 100644 --- a/Marlin/example_configurations/delta/generic/Configuration_adv.h +++ b/Marlin/example_configurations/delta/generic/Configuration_adv.h @@ -17,8 +17,8 @@ //// Heating sanity check: // This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature // If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE +// It can be reset with another M104/M109. This check is also only triggered if the target temperature and +// the current temperature differ by at least 2x WATCH_TEMP_INCREASE //#define WATCH_TEMP_PERIOD 40000 //40 seconds //#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h index 943022c819..e3b87902f6 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h @@ -17,8 +17,8 @@ //// Heating sanity check: // This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature // If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE +// It can be reset with another M104/M109. This check is also only triggered if the target temperature and +// the current temperature differ by at least 2x WATCH_TEMP_INCREASE //#define WATCH_TEMP_PERIOD 40000 //40 seconds //#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds diff --git a/Marlin/example_configurations/makibox/Configuration_adv.h b/Marlin/example_configurations/makibox/Configuration_adv.h index 8d451fd282..e762a09e7b 100644 --- a/Marlin/example_configurations/makibox/Configuration_adv.h +++ b/Marlin/example_configurations/makibox/Configuration_adv.h @@ -17,8 +17,8 @@ //// Heating sanity check: // This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature // If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE +// It can be reset with another M104/M109. This check is also only triggered if the target temperature and +// the current temperature differ by at least 2x WATCH_TEMP_INCREASE //#define WATCH_TEMP_PERIOD 40000 //40 seconds //#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h index 3187150ba9..e13987b836 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h @@ -17,8 +17,8 @@ //// Heating sanity check: // This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature // If the temperature has not increased at the end of that period, the target temperature is set to zero. -// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature -// differ by at least 2x WATCH_TEMP_INCREASE +// It can be reset with another M104/M109. This check is also only triggered if the target temperature and +// the current temperature differ by at least 2x WATCH_TEMP_INCREASE //#define WATCH_TEMP_PERIOD 40000 //40 seconds //#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 7bf0b6e53c..587b29b0c2 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -172,8 +172,8 @@ static void updateTemperaturesFromRawValues(); #ifdef WATCH_TEMP_PERIOD int watch_start_temp[EXTRUDERS] = { 0 }; - millis_t watchmillis[EXTRUDERS] = { 0 }; -#endif //WATCH_TEMP_PERIOD + millis_t watch_heater_next_ms[EXTRUDERS] = { 0 }; +#endif #ifndef SOFT_PWM_SCALE #define SOFT_PWM_SCALE 0 @@ -447,14 +447,14 @@ void checkExtruderAutoFans() // // Temperature Error Handlers // -inline void _temp_error(int e, const char *msg1, const char *msg2) { +inline void _temp_error(int e, const char *serial_msg, const char *lcd_msg) { if (IsRunning()) { SERIAL_ERROR_START; if (e >= 0) SERIAL_ERRORLN((int)e); - serialprintPGM(msg1); + serialprintPGM(serial_msg); MYSERIAL.write('\n'); #ifdef ULTRA_LCD - lcd_setalertstatuspgm(msg2); + lcd_setalertstatuspgm(lcd_msg); #endif } #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE @@ -602,7 +602,7 @@ void manage_heater() { float ct = current_temperature[0]; if (ct > min(HEATER_0_MAXTEMP, 1023)) max_temp_error(0); if (ct < max(HEATER_0_MINTEMP, 0.01)) min_temp_error(0); - #endif //HEATER_0_USES_MAX6675 + #endif #if defined(WATCH_TEMP_PERIOD) || !defined(PIDTEMPBED) || HAS_AUTO_FAN millis_t ms = millis(); @@ -620,26 +620,27 @@ void manage_heater() { // Check if temperature is within the correct range soft_pwm[e] = current_temperature[e] > minttemp[e] && current_temperature[e] < maxttemp[e] ? (int)pid_output >> 1 : 0; + // Check if the temperature is failing to increase #ifdef WATCH_TEMP_PERIOD - if (watchmillis[e] && ms > watchmillis[e] + WATCH_TEMP_PERIOD) { + // Is it time to check this extruder's heater? + if (watch_heater_next_ms[e] && ms > watch_heater_next_ms[e]) { + // Has it failed to increase enough? if (degHotend(e) < watch_start_temp[e] + WATCH_TEMP_INCREASE) { - setTargetHotend(0, e); - LCD_MESSAGEPGM(MSG_HEATING_FAILED_LCD); // translatable - SERIAL_ECHO_START; - SERIAL_ECHOLNPGM(MSG_HEATING_FAILED); + // Stop! + _temp_error(e, MSG_HEATING_FAILED, MSG_HEATING_FAILED_LCD); } else { - watchmillis[e] = 0; + watch_heater_next_ms[e] = 0; } } - #endif //WATCH_TEMP_PERIOD + #endif // WATCH_TEMP_PERIOD #ifdef TEMP_SENSOR_1_AS_REDUNDANT if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) { disable_all_heaters(); _temp_error(0, PSTR(MSG_EXTRUDER_SWITCHED_OFF), PSTR(MSG_ERR_REDUNDANT_TEMP)); } - #endif // TEMP_SENSOR_1_AS_REDUNDANT + #endif } // Extruders Loop @@ -996,16 +997,23 @@ void tp_init() { #endif //BED_MAXTEMP } +/** + * Start Heating Sanity Check for hotends that are below + * their target temperature by a configurable margin. + * This is called when the temperature is set. (M104, M109) + */ void setWatch() { #ifdef WATCH_TEMP_PERIOD - millis_t ms = millis(); + millis_t ms = millis() + WATCH_TEMP_PERIOD; for (int e = 0; e < EXTRUDERS; e++) { if (degHotend(e) < degTargetHotend(e) - (WATCH_TEMP_INCREASE * 2)) { watch_start_temp[e] = degHotend(e); - watchmillis[e] = ms; - } + watch_heater_next_ms[e] = ms; + } + else + watch_heater_next_ms[e] = 0; } - #endif + #endif } #if HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION