From 5a1b2d61aed628c13d636945327d71eaa9ff510f Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 17 Sep 2018 19:28:07 -0400 Subject: pid_calibrate: Support saving calibration data via SAVE_CONFIG Signed-off-by: Kevin O'Connor --- klippy/extras/pid_calibrate.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'klippy/extras/pid_calibrate.py') 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 -- cgit v1.2.3-70-g09d2