Skip to content

Commit

Permalink
Fix thermal error protection, reporting (#20655)
Browse files Browse the repository at this point in the history
  • Loading branch information
marciot authored and thinkyhead committed Apr 29, 2021
1 parent c6c5cc7 commit d3d8fd6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ namespace FTDI {

while (has_more_notes()) {
onIdle();
#ifdef EXTENSIBLE_UI
ExtUI::yield();
#endif
TERN_(TOUCH_UI_FTDI_EVE, ExtUI::yield());
}
}

Expand Down
28 changes: 18 additions & 10 deletions Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down Expand Up @@ -923,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;
Expand Down Expand Up @@ -1243,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)
Expand Down Expand Up @@ -1274,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;
Expand Down Expand Up @@ -1355,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
Expand Down Expand Up @@ -1387,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*/) {
Expand Down Expand Up @@ -2423,7 +2431,7 @@ void Temperature::readings_ready() {

#endif // HAS_HOTEND

#if HAS_HEATED_BED
#if ENABLED(THERMAL_PROTECTION_BED)
#if TEMPDIR(BED) < 0
#define BEDCMP(A,B) ((A)<(B))
#else
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/module/temperature.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -715,7 +715,7 @@ class Temperature {
;
start_watching_chamber();
}
#endif // HAS_HEATED_CHAMBER
#endif

/**
* The software PWM power for a heater
Expand Down

0 comments on commit d3d8fd6

Please sign in to comment.