|
|
@ -222,7 +222,7 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS], |
|
|
|
int cycles = 0; |
|
|
|
bool heating = true; |
|
|
|
|
|
|
|
millis_t temp_ms = millis(), t1 = temp_ms, t2 = temp_ms; |
|
|
|
millis_t next_temp_ms = millis(), t1 = next_temp_ms, t2 = next_temp_ms; |
|
|
|
long t_high = 0, t_low = 0; |
|
|
|
|
|
|
|
long bias, d; |
|
|
@ -231,7 +231,7 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS], |
|
|
|
float max = 0, min = 10000; |
|
|
|
|
|
|
|
#if HAS_AUTO_FAN |
|
|
|
next_auto_fan_check_ms = temp_ms + 2500UL; |
|
|
|
next_auto_fan_check_ms = next_temp_ms + 2500UL; |
|
|
|
#endif |
|
|
|
|
|
|
|
if (hotend >= |
|
|
@ -271,7 +271,7 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS], |
|
|
|
// PID Tuning loop
|
|
|
|
while (wait_for_heatup) { |
|
|
|
|
|
|
|
millis_t ms = millis(); |
|
|
|
const millis_t ms = millis(); |
|
|
|
|
|
|
|
if (temp_meas_ready) { // temp sample ready
|
|
|
|
updateTemperaturesFromRawValues(); |
|
|
@ -386,21 +386,21 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS], |
|
|
|
#define MAX_OVERSHOOT_PID_AUTOTUNE 20 |
|
|
|
if (input > temp + MAX_OVERSHOOT_PID_AUTOTUNE) { |
|
|
|
SERIAL_PROTOCOLLNPGM(MSG_PID_TEMP_TOO_HIGH); |
|
|
|
return; |
|
|
|
break; |
|
|
|
} |
|
|
|
// Every 2 seconds...
|
|
|
|
if (ELAPSED(ms, temp_ms + 2000UL)) { |
|
|
|
if (ELAPSED(ms, next_temp_ms)) { |
|
|
|
#if HAS_TEMP_HOTEND || HAS_TEMP_BED |
|
|
|
print_heaterstates(); |
|
|
|
SERIAL_EOL(); |
|
|
|
#endif |
|
|
|
|
|
|
|
temp_ms = ms; |
|
|
|
next_temp_ms = ms + 2000UL; |
|
|
|
} // every 2 seconds
|
|
|
|
// Over 2 minutes?
|
|
|
|
if (((ms - t1) + (ms - t2)) > (10L * 60L * 1000L * 2L)) { |
|
|
|
// Timeout after 20 minutes since the last undershoot/overshoot cycle
|
|
|
|
if (((ms - t1) + (ms - t2)) > (20L * 60L * 1000L)) { |
|
|
|
SERIAL_PROTOCOLLNPGM(MSG_PID_TIMEOUT); |
|
|
|
return; |
|
|
|
break; |
|
|
|
} |
|
|
|
if (cycles > ncycles) { |
|
|
|
SERIAL_PROTOCOLLNPGM(MSG_PID_AUTOTUNE_FINISHED); |
|
|
@ -449,7 +449,7 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS], |
|
|
|
} |
|
|
|
lcd_update(); |
|
|
|
} |
|
|
|
if (!wait_for_heatup) disable_all_heaters(); |
|
|
|
disable_all_heaters(); |
|
|
|
} |
|
|
|
|
|
|
|
#endif // HAS_PID_HEATING
|
|
|
@ -2033,8 +2033,15 @@ void Temperature::isr() { |
|
|
|
|
|
|
|
for (uint8_t e = 0; e < COUNT(temp_dir); e++) { |
|
|
|
const int16_t tdir = temp_dir[e], rawtemp = current_temperature_raw[e] * tdir; |
|
|
|
if (rawtemp > maxttemp_raw[e] * tdir && target_temperature[e] > 0) max_temp_error(e); |
|
|
|
if (rawtemp < minttemp_raw[e] * tdir && !is_preheating(e) && target_temperature[e] > 0) { |
|
|
|
const bool heater_on = 0 < |
|
|
|
#if ENABLED(PIDTEMP) |
|
|
|
soft_pwm_amount[e] |
|
|
|
#else |
|
|
|
target_temperature[e] |
|
|
|
#endif |
|
|
|
; |
|
|
|
if (rawtemp > maxttemp_raw[e] * tdir && heater_on) max_temp_error(e); |
|
|
|
if (rawtemp < minttemp_raw[e] * tdir && !is_preheating(e) && heater_on) { |
|
|
|
#ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED |
|
|
|
if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED) |
|
|
|
#endif |
|
|
@ -2052,8 +2059,15 @@ void Temperature::isr() { |
|
|
|
#else |
|
|
|
#define GEBED >= |
|
|
|
#endif |
|
|
|
if (current_temperature_bed_raw GEBED bed_maxttemp_raw && target_temperature_bed > 0) max_temp_error(-1); |
|
|
|
if (bed_minttemp_raw GEBED current_temperature_bed_raw && target_temperature_bed > 0) min_temp_error(-1); |
|
|
|
const bool bed_on = 0 < |
|
|
|
#if ENABLED(PIDTEMPBED) |
|
|
|
soft_pwm_amount_bed |
|
|
|
#else |
|
|
|
target_temperature_bed |
|
|
|
#endif |
|
|
|
; |
|
|
|
if (current_temperature_bed_raw GEBED bed_maxttemp_raw && bed_on) max_temp_error(-1); |
|
|
|
if (bed_minttemp_raw GEBED current_temperature_bed_raw && bed_on) min_temp_error(-1); |
|
|
|
#endif |
|
|
|
|
|
|
|
} // temp_count >= OVERSAMPLENR
|
|
|
|