diff --git a/docs/Config_checks.md b/docs/Config_checks.md index 32f2329f..4d612cd3 100644 --- a/docs/Config_checks.md +++ b/docs/Config_checks.md @@ -139,8 +139,8 @@ To calibrate the extruder, navigate to the OctoPrint terminal tab and run the PID_CALIBRATE command. For example: `PID_CALIBRATE HEATER=extruder TARGET=170` -At the completion of the tuning test, update the printer.cfg file with -the recommended pid_Kp, pid_Ki, and pid_Kd values. +At the completion of the tuning test run `SAVE_CONFIG` to update the +printer.cfg file the new PID settings. If the printer has a heated bed and it supports being driven by PWM (Pulse Width Modulation) then it is recommended to use PID control for diff --git a/klippy/extras/pid_calibrate.py b/klippy/extras/pid_calibrate.py index b087f2b3..d2413e15 100644 --- a/klippy/extras/pid_calibrate.py +++ b/klippy/extras/pid_calibrate.py @@ -35,12 +35,19 @@ class PIDCalibrate: heater.set_control(old_control) if write_file: calibrate.write_file('/tmp/heattest.txt') + # Log and report results Kp, Ki, Kd = calibrate.calc_final_pid() logging.info("Autotune: final: Kp=%f Ki=%f Kd=%f", Kp, Ki, Kd) self.gcode.respond_info( "PID parameters: pid_Kp=%.3f pid_Ki=%.3f pid_Kd=%.3f\n" - "To use these parameters, update the printer config file with\n" - "the above and then issue a RESTART command" % (Kp, Ki, Kd)) + "The SAVE_CONFIG command will update the printer config file\n" + "with these parameters and restart the printer." % (Kp, Ki, Kd)) + # Store results for SAVE_CONFIG + configfile = self.printer.lookup_object('configfile') + configfile.set(heater_name, 'control', 'pid') + configfile.set(heater_name, 'pid_Kp', "%.3f" % (Kp,)) + configfile.set(heater_name, 'pid_Ki', "%.3f" % (Ki,)) + configfile.set(heater_name, 'pid_Kd', "%.3f" % (Kd,)) TUNE_PID_DELTA = 5.0