From 745e3d23a88720f1ef56d2fe32798fad9d72b7db Mon Sep 17 00:00:00 2001 From: Marcio T Date: Sun, 3 Jan 2021 09:24:13 -0700 Subject: [PATCH 1/6] Fixes to thermal error protection and reporting. - Do not trigger min and max temp errors when thermal protection is disabled. - Add watchdog timer resets to prevent board reboot: - While toggling BEEPER_PIN. - While playing error sound in FTDI UI. - Ensures message stays on the LCD so the user can read it. --- .../ftdi_eve_lib/extended/sound_player.cpp | 2 +- Marlin/src/module/temperature.cpp | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.cpp index f9869320ba54..75b20d84f286 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.cpp @@ -75,7 +75,7 @@ namespace FTDI { while (has_more_notes()) { onIdle(); - #ifdef EXTENSIBLE_UI + #if ENABLED(TOUCH_UI_FTDI_EVE) ExtUI::yield(); #endif } diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 6f02f3b90018..b068eabe3fa6 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -793,9 +793,16 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { inline void loud_kill(PGM_P const lcd_msg, const heater_id_t heater_id) { marlin_state = MF_KILLED; #if USE_BEEPER + thermalManager.disable_all_heaters(); for (uint8_t i = 20; i--;) { - WRITE(BEEPER_PIN, HIGH); delay(25); - WRITE(BEEPER_PIN, LOW); delay(80); + WRITE(BEEPER_PIN, HIGH); + delay(25); + watchdog_refresh(); + WRITE(BEEPER_PIN, LOW); + delay(40); + watchdog_refresh(); + delay(40); + watchdog_refresh(); } WRITE(BEEPER_PIN, HIGH); #endif @@ -820,6 +827,7 @@ void Temperature::_temp_error(const heater_id_t heater_id, PGM_P const serial_ms } disable_all_heaters(); // always disable (even for bogus temp) + watchdog_refresh(); #if BOGUS_TEMPERATURE_GRACE_PERIOD const millis_t ms = millis(); @@ -2423,7 +2431,7 @@ void Temperature::readings_ready() { #endif // HAS_HOTEND - #if HAS_HEATED_BED + #if BOTH(HAS_HEATED_BED, THERMAL_PROTECTION_BED) #if TEMPDIR(BED) < 0 #define BEDCMP(A,B) ((A)<(B)) #else @@ -2434,7 +2442,7 @@ void Temperature::readings_ready() { if (bed_on && BEDCMP(mintemp_raw_BED, temp_bed.raw)) min_temp_error(H_BED); #endif - #if HAS_HEATED_CHAMBER + #if BOTH(HAS_HEATED_CHAMBER, THERMAL_PROTECTION_CHAMBER) #if TEMPDIR(CHAMBER) < 0 #define CHAMBERCMP(A,B) ((A)<(B)) #else From 433c1762691488299d70d59541ccbd44fce0d00b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 3 Jan 2021 18:44:32 -0600 Subject: [PATCH 2/6] Update sound_player.cpp --- .../ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.cpp index 75b20d84f286..07d1ff56246d 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.cpp @@ -75,9 +75,7 @@ namespace FTDI { while (has_more_notes()) { onIdle(); - #if ENABLED(TOUCH_UI_FTDI_EVE) - ExtUI::yield(); - #endif + TERN_(TOUCH_UI_FTDI_EVE, ExtUI::yield()); } } From b0fb01a29483ee94e5db776fe932497d75d7ac7e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 3 Jan 2021 18:45:23 -0600 Subject: [PATCH 3/6] Update temperature.cpp --- Marlin/src/module/temperature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index b068eabe3fa6..cf06fda38b4a 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -793,7 +793,7 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { inline void loud_kill(PGM_P const lcd_msg, const heater_id_t heater_id) { marlin_state = MF_KILLED; #if USE_BEEPER - thermalManager.disable_all_heaters(); + disable_all_heaters(); for (uint8_t i = 20; i--;) { WRITE(BEEPER_PIN, HIGH); delay(25); From a457cd18397cf791ce5f44ea495c4830ffabfdb2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 3 Jan 2021 18:47:07 -0600 Subject: [PATCH 4/6] Update temperature.cpp --- Marlin/src/module/temperature.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index cf06fda38b4a..1fc70835a181 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2431,7 +2431,7 @@ void Temperature::readings_ready() { #endif // HAS_HOTEND - #if BOTH(HAS_HEATED_BED, THERMAL_PROTECTION_BED) + #if ENABLED(THERMAL_PROTECTION_BED) #if TEMPDIR(BED) < 0 #define BEDCMP(A,B) ((A)<(B)) #else @@ -2442,7 +2442,7 @@ void Temperature::readings_ready() { if (bed_on && BEDCMP(mintemp_raw_BED, temp_bed.raw)) min_temp_error(H_BED); #endif - #if BOTH(HAS_HEATED_CHAMBER, THERMAL_PROTECTION_CHAMBER) + #if ENABLED(THERMAL_PROTECTION_CHAMBER) #if TEMPDIR(CHAMBER) < 0 #define CHAMBERCMP(A,B) ((A)<(B)) #else From bd52c46c10e21a0abc75de8d7721eaf0578413c0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 3 Jan 2021 18:51:11 -0600 Subject: [PATCH 5/6] Update temperature.cpp --- Marlin/src/module/temperature.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 1fc70835a181..f355759acf8e 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -793,7 +793,7 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { inline void loud_kill(PGM_P const lcd_msg, const heater_id_t heater_id) { marlin_state = MF_KILLED; #if USE_BEEPER - disable_all_heaters(); + thermalManager.disable_all_heaters(); for (uint8_t i = 20; i--;) { WRITE(BEEPER_PIN, HIGH); delay(25); @@ -931,8 +931,8 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { } #endif // PID_EXTRUSION_SCALING #if ENABLED(PID_FAN_SCALING) - if (thermalManager.fan_speed[active_extruder] > PID_FAN_SCALING_MIN_SPEED) { - work_pid[ee].Kf = PID_PARAM(Kf, ee) + (PID_FAN_SCALING_LIN_FACTOR) * thermalManager.fan_speed[active_extruder]; + if (fan_speed[active_extruder] > PID_FAN_SCALING_MIN_SPEED) { + work_pid[ee].Kf = PID_PARAM(Kf, ee) + (PID_FAN_SCALING_LIN_FACTOR) * fan_speed[active_extruder]; pid_output += work_pid[ee].Kf; } //pid_output -= work_pid[ee].Ki; @@ -1251,7 +1251,7 @@ void Temperature::manage_heater() { fan_chamber_pwm += (CHAMBER_FAN_FACTOR) * 2; #endif NOMORE(fan_chamber_pwm, 225); - thermalManager.set_fan_speed(2, fan_chamber_pwm); // TODO: instead of fan 2, set to chamber fan + set_fan_speed(2, fan_chamber_pwm); // TODO: instead of fan 2, set to chamber fan #endif #if ENABLED(CHAMBER_VENT) @@ -1282,7 +1282,7 @@ void Temperature::manage_heater() { else if (!flag_chamber_off) { #if ENABLED(CHAMBER_FAN) flag_chamber_off = true; - thermalManager.set_fan_speed(2, 0); + set_fan_speed(2, 0); #endif #if ENABLED(CHAMBER_VENT) flag_chamber_excess_heat = false; @@ -1363,7 +1363,7 @@ void Temperature::manage_heater() { user_thermistor_t Temperature::user_thermistor[USER_THERMISTORS]; // Initialized by settings.load() void Temperature::reset_user_thermistors() { - user_thermistor_t user_thermistor[USER_THERMISTORS] = { + user_thermistor_t default_user_thermistor[USER_THERMISTORS] = { #if HEATER_0_USER_THERMISTOR { true, 0, 0, HOTEND0_PULLUP_RESISTOR_OHMS, HOTEND0_RESISTANCE_25C_OHMS, 0, 0, HOTEND0_BETA, 0 }, #endif @@ -1395,7 +1395,7 @@ void Temperature::manage_heater() { { true, 0, 0, CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS, 0, 0, CHAMBER_BETA, 0 } #endif }; - COPY(thermalManager.user_thermistor, user_thermistor); + COPY(user_thermistor, default_user_thermistor); } void Temperature::log_user_thermistor(const uint8_t t_index, const bool eprom/*=false*/) { From 1972aea9684480a6480a140ea9fb5d005f9f4e8d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 3 Jan 2021 19:50:16 -0600 Subject: [PATCH 6/6] heater req'd --- Marlin/src/module/temperature.cpp | 2 +- Marlin/src/module/temperature.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index f355759acf8e..327f43dc03ae 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2442,7 +2442,7 @@ void Temperature::readings_ready() { if (bed_on && BEDCMP(mintemp_raw_BED, temp_bed.raw)) min_temp_error(H_BED); #endif - #if ENABLED(THERMAL_PROTECTION_CHAMBER) + #if BOTH(HAS_HEATED_CHAMBER, THERMAL_PROTECTION_CHAMBER) #if TEMPDIR(CHAMBER) < 0 #define CHAMBERCMP(A,B) ((A)<(B)) #else diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 33f38c303608..aa4f2e7634dc 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -696,7 +696,7 @@ class Temperature { static bool wait_for_chamber(const bool no_wait_for_cooling=true); #endif - #endif // HAS_TEMP_CHAMBER + #endif #if WATCH_CHAMBER static void start_watching_chamber(); @@ -715,7 +715,7 @@ class Temperature { ; start_watching_chamber(); } - #endif // HAS_HEATED_CHAMBER + #endif /** * The software PWM power for a heater