diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index faa6f56843..91a3b342b6 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -899,7 +899,7 @@ #if ANY(PIDTEMP, PIDTEMPBED, PIDTEMPCHAMBER) //#define PID_OPENLOOP // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX //#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay - #define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature + #define PID_FUNCTIONAL_RANGE 20 // If the temperature difference between the target temperature and the actual temperature // is more than PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max. //#define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of flash) diff --git a/Marlin/src/lcd/sovol_rts/sovol_rts.cpp b/Marlin/src/lcd/sovol_rts/sovol_rts.cpp index c92850494b..dcd5d9b384 100644 --- a/Marlin/src/lcd/sovol_rts/sovol_rts.cpp +++ b/Marlin/src/lcd/sovol_rts/sovol_rts.cpp @@ -1312,9 +1312,9 @@ void RTS::handleData() { #endif #if ENABLED(PIDTEMPBED) - case Hot_Bed_P: thermalManager.temp_bed.pid.Kp = float(recdat.data[0]) / 100.0f; break; - case Hot_Bed_I: thermalManager.temp_bed.pid.Ki = float(recdat.data[0]) * 8.0f / 10000.0f; break; - case Hot_Bed_D: thermalManager.temp_bed.pid.Kd = float(recdat.data[0]) / 0.8f; break; + case Hot_Bed_P: thermalManager.temp_bed.pid.set_Kp(float(recdat.data[0]) / 100.0f); break; + case Hot_Bed_I: thermalManager.temp_bed.pid.set_Ki(float(recdat.data[0]) * 8.0f / 10000.0f); break; + case Hot_Bed_D: thermalManager.temp_bed.pid.set_Kd(float(recdat.data[0]) / 0.8f); break; #endif #if HAS_X_AXIS diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 934b1b1246..77c16bba0a 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -173,7 +173,7 @@ typedef struct { float p, i, d, c, f; } raw_pidcf_t; struct PID_t { protected: bool pid_reset = true; - float temp_iState = 0.0f, temp_dState = 0.0f; + float temp_dState = 0; float work_p = 0, work_i = 0, work_d = 0; public: @@ -217,17 +217,14 @@ typedef struct { float p, i, d, c, f; } raw_pidcf_t; } else { if (pid_reset) { + work_i = 0; + work_d = 0; pid_reset = false; - temp_iState = 0.0; - work_d = 0.0; } - const float max_power_over_i_gain = float(MAX_POW) / Ki - float(MIN_POW); - temp_iState = constrain(temp_iState + pid_error, 0, max_power_over_i_gain); - work_p = Kp * pid_error; - work_i = Ki * temp_iState; - work_d = work_d + PID_K2 * (Kd * (temp_dState - current) - work_d); + work_i = constrain(work_i + Ki * pid_error, 0, float(MAX_POW - MIN_POW)); + work_d += (Kd * (temp_dState - current) - work_d) * PID_K2; output_pow = constrain(work_p + work_i + work_d + float(MIN_POW), 0, MAX_POW); }