Browse Source

Add HAL-based thermal protection grace period for all heaters (#13778)

pull/1/head
Kajetan Rzepecki 6 years ago
committed by Scott Lahteine
parent
commit
875e673a8c
  1. 3
      Marlin/src/HAL/HAL_LPC1768/HAL.h
  2. 32
      Marlin/src/module/temperature.cpp

3
Marlin/src/HAL/HAL_LPC1768/HAL.h

@ -147,6 +147,9 @@ using FilteredADC = LPC176x::ADC<ADC_LOWPASS_K_VALUE, ADC_MEDIAN_FILTER_SIZE>;
#define HAL_READ_ADC() FilteredADC::get_result()
#define HAL_ADC_READY() FilteredADC::finished_conversion()
// A grace period for the ADC readings to stabilize before they start causing thermal protection errors.
#define THERMAL_PROTECTION_GRACE_PERIOD 500
// Parse a G-code word into a pin index
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval);
// P0.6 thru P0.9 are for the onboard SD card

32
Marlin/src/module/temperature.cpp

@ -944,13 +944,29 @@ void Temperature::manage_heater() {
if (temp_hotend[1].current < MAX(HEATER_1_MINTEMP, HEATER_1_MAX6675_TMIN + .01)) min_temp_error(1);
#endif
#if WATCH_HOTENDS || WATCH_BED || DISABLED(PIDTEMPBED) || HAS_AUTO_FAN || HEATER_IDLE_HANDLER || WATCH_CHAMBER
#define HAS_THERMAL_PROTECTION (ENABLED(THERMAL_PROTECTION_HOTENDS) || HAS_THERMALLY_PROTECTED_BED || ENABLED(THERMAL_PROTECTION_CHAMBER))
#if HAS_THERMAL_PROTECTION || DISABLED(PIDTEMPBED) || HAS_AUTO_FAN || HEATER_IDLE_HANDLER
millis_t ms = millis();
#endif
#if HAS_THERMAL_PROTECTION
#ifndef THERMAL_PROTECTION_GRACE_PERIOD
#define THERMAL_PROTECTION_GRACE_PERIOD 0 // No grace period needed on well-behaved boards
#endif
#if THERMAL_PROTECTION_GRACE_PERIOD > 0
static millis_t grace_period = ms + THERMAL_PROTECTION_GRACE_PERIOD;
if (ELAPSED(ms, grace_period)) grace_period = 0UL;
#else
static constexpr millis_t grace_period = 0UL;
#endif
#endif
HOTEND_LOOP() {
if (degHotend(e) > temp_range[e].maxtemp)
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
if (!grace_period && degHotend(e) > temp_range[e].maxtemp)
_temp_error(e, PSTR(MSG_T_THERMAL_RUNAWAY), TEMP_ERR_PSTR(MSG_THERMAL_RUNAWAY, e));
#endif
#if HEATER_IDLE_HANDLER
hotend_idle[e].update(ms);
@ -1003,8 +1019,10 @@ void Temperature::manage_heater() {
#if HAS_HEATED_BED
if (degBed() > BED_MAXTEMP)
#if ENABLED(THERMAL_PROTECTION_BED)
if (!grace_period && degBed() > BED_MAXTEMP)
_temp_error(-1, PSTR(MSG_T_THERMAL_RUNAWAY), TEMP_ERR_PSTR(MSG_THERMAL_RUNAWAY, -1));
#endif
#if WATCH_BED
// Make sure temperature is increasing
@ -1076,8 +1094,10 @@ void Temperature::manage_heater() {
#if HAS_HEATED_CHAMBER
if (degChamber() > CHAMBER_MAXTEMP)
#if ENABLED(THERMAL_PROTECTION_CHAMBER)
if (!grace_period && degChamber() > CHAMBER_MAXTEMP)
_temp_error(-2, PSTR(MSG_T_THERMAL_RUNAWAY), TEMP_ERR_PSTR(MSG_THERMAL_RUNAWAY, -2));
#endif
#if WATCH_CHAMBER
// Make sure temperature is increasing
@ -1610,7 +1630,7 @@ void Temperature::init() {
}
#endif
#if ENABLED(THERMAL_PROTECTION_HOTENDS) || HAS_THERMALLY_PROTECTED_BED || ENABLED(THERMAL_PROTECTION_CHAMBER)
#if HAS_THERMAL_PROTECTION
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
Temperature::tr_state_machine_t Temperature::tr_state_machine[HOTENDS]; // = { { TRInactive, 0 } };
@ -1637,7 +1657,7 @@ void Temperature::init() {
else
SERIAL_ECHOPAIR(" ; Idle Timeout:", bed_idle.timed_out);
SERIAL_EOL();
*/
//*/
const int heater_index = heater_id >= 0 ? heater_id : HOTENDS;

Loading…
Cancel
Save