Fix autotune Thermal Protection

When `THERMAL_PROTECTION_BED` is off but `THERMAL_PROTECTION_HOTENDS` is on, `watch_temp_period` and `watch_temp_increase` are initialized with the values for `THERMAL_PROTECTION_HOTENDS`. Later it is not tested if these values are for the bed or the nozzles.

- Add test.
- Name a constant.

Fix for #10150
This commit is contained in:
AnHardt 2018-03-20 11:11:52 +01:00 committed by Scott Lahteine
parent 80adb124f7
commit 3911c38d5e

View File

@ -424,6 +424,15 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS],
// Make sure heating is actually working // Make sure heating is actually working
#if WATCH_THE_BED || WATCH_HOTENDS #if WATCH_THE_BED || WATCH_HOTENDS
if (
#if WATCH_THE_BED && WATCH_HOTENDS
true
#elif WATCH_THE_BED
hotend < 0
#else
hotend >= 0
#endif
) {
if (!heated) { // If not yet reached target... if (!heated) { // If not yet reached target...
if (current > next_watch_temp) { // Over the watch temp? if (current > next_watch_temp) { // Over the watch temp?
next_watch_temp = current + watch_temp_increase; // - set the next temp to watch for next_watch_temp = current + watch_temp_increase; // - set the next temp to watch for
@ -437,11 +446,13 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS],
_temp_error(hotend, PSTR(MSG_T_THERMAL_RUNAWAY), _temp_error(hotend, PSTR(MSG_T_THERMAL_RUNAWAY),
hotend >= 0 ? PSTR(MSG_THERMAL_RUNAWAY) : PSTR(MSG_THERMAL_RUNAWAY_BED) hotend >= 0 ? PSTR(MSG_THERMAL_RUNAWAY) : PSTR(MSG_THERMAL_RUNAWAY_BED)
); );
}
#endif #endif
} // every 2 seconds } // every 2 seconds
// Timeout after 20 minutes since the last undershoot/overshoot cycle // Timeout after MAX_CYCLE_TIME_PID_AUTOTUNE minutes since the last undershoot/overshoot cycle
if (((ms - t1) + (ms - t2)) > (20L * 60L * 1000L)) { #define MAX_CYCLE_TIME_PID_AUTOTUNE 20L
if (((ms - t1) + (ms - t2)) > (MAX_CYCLE_TIME_PID_AUTOTUNE * 60L * 1000L)) {
SERIAL_PROTOCOLLNPGM(MSG_PID_TIMEOUT); SERIAL_PROTOCOLLNPGM(MSG_PID_TIMEOUT);
break; break;
} }