|
@@ -269,7 +269,7 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS],
|
269
|
269
|
// PID Tuning loop
|
270
|
270
|
while (wait_for_heatup) {
|
271
|
271
|
|
272
|
|
- millis_t ms = millis();
|
|
272
|
+ const millis_t ms = millis();
|
273
|
273
|
|
274
|
274
|
if (temp_meas_ready) { // temp sample ready
|
275
|
275
|
updateTemperaturesFromRawValues();
|
|
@@ -384,21 +384,21 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS],
|
384
|
384
|
#define MAX_OVERSHOOT_PID_AUTOTUNE 20
|
385
|
385
|
if (input > temp + MAX_OVERSHOOT_PID_AUTOTUNE) {
|
386
|
386
|
SERIAL_PROTOCOLLNPGM(MSG_PID_TEMP_TOO_HIGH);
|
387
|
|
- return;
|
|
387
|
+ break;
|
388
|
388
|
}
|
389
|
389
|
// Every 2 seconds...
|
390
|
|
- if (ELAPSED(ms, temp_ms + 2000UL)) {
|
|
390
|
+ if (ELAPSED(ms, temp_ms)) {
|
391
|
391
|
#if HAS_TEMP_HOTEND || HAS_TEMP_BED
|
392
|
392
|
print_heaterstates();
|
393
|
393
|
SERIAL_EOL();
|
394
|
394
|
#endif
|
395
|
395
|
|
396
|
|
- temp_ms = ms;
|
|
396
|
+ temp_ms = ms + 2000UL;
|
397
|
397
|
} // every 2 seconds
|
398
|
|
- // Over 2 minutes?
|
399
|
|
- if (((ms - t1) + (ms - t2)) > (10L * 60L * 1000L * 2L)) {
|
|
398
|
+ // Timeout after 20 minutes since the last undershoot/overshoot cycle
|
|
399
|
+ if (((ms - t1) + (ms - t2)) > (20L * 60L * 1000L)) {
|
400
|
400
|
SERIAL_PROTOCOLLNPGM(MSG_PID_TIMEOUT);
|
401
|
|
- return;
|
|
401
|
+ break;
|
402
|
402
|
}
|
403
|
403
|
if (cycles > ncycles) {
|
404
|
404
|
SERIAL_PROTOCOLLNPGM(MSG_PID_AUTOTUNE_FINISHED);
|
|
@@ -447,7 +447,7 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS],
|
447
|
447
|
}
|
448
|
448
|
lcd_update();
|
449
|
449
|
}
|
450
|
|
- if (!wait_for_heatup) disable_all_heaters();
|
|
450
|
+ disable_all_heaters();
|
451
|
451
|
}
|
452
|
452
|
|
453
|
453
|
#endif // HAS_PID_HEATING
|
|
@@ -2067,8 +2067,15 @@ void Temperature::isr() {
|
2067
|
2067
|
|
2068
|
2068
|
for (uint8_t e = 0; e < COUNT(temp_dir); e++) {
|
2069
|
2069
|
const int16_t tdir = temp_dir[e], rawtemp = current_temperature_raw[e] * tdir;
|
2070
|
|
- if (rawtemp > maxttemp_raw[e] * tdir && target_temperature[e] > 0) max_temp_error(e);
|
2071
|
|
- if (rawtemp < minttemp_raw[e] * tdir && !is_preheating(e) && target_temperature[e] > 0) {
|
|
2070
|
+ const bool heater_on = 0 <
|
|
2071
|
+ #if ENABLED(PIDTEMP)
|
|
2072
|
+ soft_pwm_amount[e]
|
|
2073
|
+ #else
|
|
2074
|
+ target_temperature[e]
|
|
2075
|
+ #endif
|
|
2076
|
+ ;
|
|
2077
|
+ if (rawtemp > maxttemp_raw[e] * tdir && heater_on) max_temp_error(e);
|
|
2078
|
+ if (rawtemp < minttemp_raw[e] * tdir && !is_preheating(e) && heater_on) {
|
2072
|
2079
|
#ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
|
2073
|
2080
|
if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED)
|
2074
|
2081
|
#endif
|
|
@@ -2086,8 +2093,15 @@ void Temperature::isr() {
|
2086
|
2093
|
#else
|
2087
|
2094
|
#define GEBED >=
|
2088
|
2095
|
#endif
|
2089
|
|
- if (current_temperature_bed_raw GEBED bed_maxttemp_raw && target_temperature_bed > 0) max_temp_error(-1);
|
2090
|
|
- if (bed_minttemp_raw GEBED current_temperature_bed_raw && target_temperature_bed > 0) min_temp_error(-1);
|
|
2096
|
+ const bool bed_on = 0 <
|
|
2097
|
+ #if ENABLED(PIDTEMPBED)
|
|
2098
|
+ soft_pwm_amount_bed
|
|
2099
|
+ #else
|
|
2100
|
+ target_temperature_bed
|
|
2101
|
+ #endif
|
|
2102
|
+ ;
|
|
2103
|
+ if (current_temperature_bed_raw GEBED bed_maxttemp_raw && bed_on) max_temp_error(-1);
|
|
2104
|
+ if (bed_minttemp_raw GEBED current_temperature_bed_raw && bed_on) min_temp_error(-1);
|
2091
|
2105
|
#endif
|
2092
|
2106
|
|
2093
|
2107
|
} // temp_count >= OVERSAMPLENR
|