Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pid_calibrate: allowing TUNE_PID_DELTA to pass through gcode #6346

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions klippy/extras/pid_calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ def __init__(self, config):
def cmd_PID_CALIBRATE(self, gcmd):
heater_name = gcmd.get('HEATER')
target = gcmd.get_float('TARGET')
tune_pid_delta = gcmd.get_float('TUNE_PID_DELTA', 5.0)
write_file = gcmd.get_int('WRITE_FILE', 0)
pheaters = self.printer.lookup_object('heaters')
try:
heater = pheaters.lookup_heater(heater_name)
except self.printer.config_error as e:
raise gcmd.error(str(e))
self.printer.lookup_object('toolhead').get_last_move_time()
calibrate = ControlAutoTune(heater, target)
calibrate = ControlAutoTune(heater, target, tune_pid_delta)
old_control = heater.set_control(calibrate)
try:
pheaters.set_temperature(heater, target, True)
Expand All @@ -49,13 +50,13 @@ def cmd_PID_CALIBRATE(self, gcmd):
configfile.set(heater_name, 'pid_Ki', "%.3f" % (Ki,))
configfile.set(heater_name, 'pid_Kd', "%.3f" % (Kd,))

TUNE_PID_DELTA = 5.0

class ControlAutoTune:
def __init__(self, heater, target):
def __init__(self, heater, target, tune_pid_delta):
self.heater = heater
self.heater_max_power = heater.get_max_power()
self.calibrate_temp = target
self.tune_pid_delta = tune_pid_delta
# Heating control
self.heating = False
self.peak = 0.
Expand All @@ -80,7 +81,7 @@ def temperature_update(self, read_time, temp, target_temp):
if self.heating and temp >= target_temp:
self.heating = False
self.check_peaks()
self.heater.alter_target(self.calibrate_temp - TUNE_PID_DELTA)
self.heater.alter_target(self.calibrate_temp - self.tune_pid_delta)
elif not self.heating and temp <= target_temp:
self.heating = True
self.check_peaks()
Expand Down