diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2018-09-17 19:28:07 -0400 |
---|---|---|
committer | KevinOConnor <kevin@koconnor.net> | 2018-09-25 13:48:46 -0400 |
commit | 5a1b2d61aed628c13d636945327d71eaa9ff510f (patch) | |
tree | 39189a56ee7849584888ccf0d36d9c1c70a94a72 | |
parent | 531134f092555f737e7031c1b011fb85cb051f71 (diff) | |
download | kutter-5a1b2d61aed628c13d636945327d71eaa9ff510f.tar.gz kutter-5a1b2d61aed628c13d636945327d71eaa9ff510f.tar.xz kutter-5a1b2d61aed628c13d636945327d71eaa9ff510f.zip |
pid_calibrate: Support saving calibration data via SAVE_CONFIG
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r-- | docs/Config_checks.md | 4 | ||||
-rw-r--r-- | klippy/extras/pid_calibrate.py | 11 |
2 files changed, 11 insertions, 4 deletions
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 |