diff --git a/docs/G-Codes.md b/docs/G-Codes.md index fb9e4a7ad..755be6e27 100644 --- a/docs/G-Codes.md +++ b/docs/G-Codes.md @@ -863,6 +863,11 @@ WRITE_FILE parameter is enabled, then the file /tmp/heattest.txt will be created with a log of all temperature samples taken during the test. +#### SET_HEATER_PID +`SET_HEATER_PID HEATER= KP= KI= KD=`: Will +allow one to manually change PID parameters of heaters without a +reload of the firmware. + ### [pause_resume] The following commands are available when the diff --git a/klippy/extras/heaters.py b/klippy/extras/heaters.py index 80431899f..72d6eea25 100644 --- a/klippy/extras/heaters.py +++ b/klippy/extras/heaters.py @@ -74,6 +74,13 @@ def __init__(self, config, sensor): self.cmd_SET_HEATER_TEMPERATURE, desc=self.cmd_SET_HEATER_TEMPERATURE_help, ) + gcode.register_mux_command( + "SET_HEATER_PID", + "HEATER", + self.name, + self.cmd_SET_HEATER_PID, + desc=self.cmd_SET_HEATER_PID_help, + ) def set_pwm(self, read_time, value): if self.target_temp <= 0.0: @@ -180,6 +187,21 @@ def cmd_SET_HEATER_TEMPERATURE(self, gcmd): pheaters = self.printer.lookup_object("heaters") pheaters.set_temperature(self, temp) + cmd_SET_HEATER_PID_help = "Sets a heater PID parameter" + + def cmd_SET_HEATER_PID(self, gcmd): + if not isinstance(self.control, ControlPID): + raise gcmd.error("Not a PID controlled heater") + kp = gcmd.get_float("KP", None) + if kp is not None: + self.control.Kp = kp / PID_PARAM_BASE + ki = gcmd.get_float("KI", None) + if ki is not None: + self.control.Ki = ki / PID_PARAM_BASE + kd = gcmd.get_float("KD", None) + if kd is not None: + self.control.Kd = kd / PID_PARAM_BASE + ###################################################################### # Bang-bang control algo