|
|
@ -200,11 +200,16 @@ static float analog2temp(int raw, uint8_t e); |
|
|
|
static float analog2tempBed(int raw); |
|
|
|
static void updateTemperaturesFromRawValues(); |
|
|
|
|
|
|
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS) |
|
|
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0 |
|
|
|
int watch_target_temp[EXTRUDERS] = { 0 }; |
|
|
|
millis_t watch_heater_next_ms[EXTRUDERS] = { 0 }; |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0 |
|
|
|
int watch_target_bed_temp = 0; |
|
|
|
millis_t watch_bed_next_ms = 0; |
|
|
|
#endif |
|
|
|
|
|
|
|
#ifndef SOFT_PWM_SCALE |
|
|
|
#define SOFT_PWM_SCALE 0 |
|
|
|
#endif |
|
|
@ -717,7 +722,7 @@ void manage_heater() { |
|
|
|
if (ct < max(HEATER_0_MINTEMP, 0.01)) min_temp_error(0); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS) || DISABLED(PIDTEMPBED) || HAS_AUTO_FAN |
|
|
|
#if (ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0) || (ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0) || DISABLED(PIDTEMPBED) || HAS_AUTO_FAN |
|
|
|
millis_t ms = millis(); |
|
|
|
#endif |
|
|
|
|
|
|
@ -734,7 +739,7 @@ void manage_heater() { |
|
|
|
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
|
|
|
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS) |
|
|
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0 |
|
|
|
|
|
|
|
// Is it time to check this extruder's heater?
|
|
|
|
if (watch_heater_next_ms[e] && ELAPSED(ms, watch_heater_next_ms[e])) { |
|
|
@ -751,6 +756,24 @@ void manage_heater() { |
|
|
|
|
|
|
|
#endif // THERMAL_PROTECTION_HOTENDS
|
|
|
|
|
|
|
|
// Check if the temperature is failing to increase
|
|
|
|
#if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0 |
|
|
|
|
|
|
|
// Is it time to check the bed?
|
|
|
|
if (watch_bed_next_ms && ELAPSED(ms, watch_bed_next_ms)) { |
|
|
|
// Has it failed to increase enough?
|
|
|
|
if (degBed() < watch_target_bed_temp) { |
|
|
|
// Stop!
|
|
|
|
_temp_error(-1, PSTR(MSG_T_HEATING_FAILED), PSTR(MSG_HEATING_FAILED_LCD)); |
|
|
|
} |
|
|
|
else { |
|
|
|
// Start again if the target is still far off
|
|
|
|
start_watching_bed(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif // THERMAL_PROTECTION_HOTENDS
|
|
|
|
|
|
|
|
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) |
|
|
|
if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) { |
|
|
|
_temp_error(0, PSTR(MSG_REDUNDANCY), PSTR(MSG_ERR_REDUNDANT_TEMP)); |
|
|
@ -1160,7 +1183,7 @@ void tp_init() { |
|
|
|
#endif //BED_MAXTEMP
|
|
|
|
} |
|
|
|
|
|
|
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS) |
|
|
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0 |
|
|
|
/**
|
|
|
|
* Start Heating Sanity Check for hotends that are below |
|
|
|
* their target temperature by a configurable margin. |
|
|
@ -1176,6 +1199,22 @@ void tp_init() { |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0 |
|
|
|
/**
|
|
|
|
* Start Heating Sanity Check for hotends that are below |
|
|
|
* their target temperature by a configurable margin. |
|
|
|
* This is called when the temperature is set. (M140, M190) |
|
|
|
*/ |
|
|
|
void start_watching_bed() { |
|
|
|
if (degBed() < degTargetBed() - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1)) { |
|
|
|
watch_target_bed_temp = degBed() + WATCH_BED_TEMP_INCREASE; |
|
|
|
watch_bed_next_ms = millis() + (WATCH_BED_TEMP_PERIOD) * 1000UL; |
|
|
|
} |
|
|
|
else |
|
|
|
watch_bed_next_ms = 0; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS) || ENABLED(THERMAL_PROTECTION_BED) |
|
|
|
|
|
|
|
void thermal_runaway_protection(TRState* state, millis_t* timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc) { |
|
|
|