aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-10-19 21:30:15 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-10-19 22:40:11 -0400
commit7efbc021a5107b3066b7f19c9672fd07b1d1c955 (patch)
tree62c0e3935ae25e42e92740e12e345deb8e1ae636 /klippy
parente30053f2a9fe5ac7027bd42286366813b239671b (diff)
downloadkutter-7efbc021a5107b3066b7f19c9672fd07b1d1c955.tar.gz
kutter-7efbc021a5107b3066b7f19c9672fd07b1d1c955.tar.xz
kutter-7efbc021a5107b3066b7f19c9672fd07b1d1c955.zip
pid_calibrate: Add some comments on the calibration methodology
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy')
-rw-r--r--klippy/extras/pid_calibrate.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/klippy/extras/pid_calibrate.py b/klippy/extras/pid_calibrate.py
index d2413e15..0eb7c382 100644
--- a/klippy/extras/pid_calibrate.py
+++ b/klippy/extras/pid_calibrate.py
@@ -75,6 +75,8 @@ class ControlAutoTune:
self.heater.set_pwm(read_time, value)
def temperature_update(self, read_time, temp, target_temp):
self.temp_samples.append((read_time, temp))
+ # Check if the temperature has crossed the target and
+ # enable/disable the heater if so.
if self.heating and temp >= target_temp:
self.heating = False
self.check_peaks()
@@ -83,6 +85,7 @@ class ControlAutoTune:
self.heating = True
self.check_peaks()
self.heater.alter_target(self.calibrate_temp)
+ # Check if this temperature is a peak and record it if so
if self.heating:
self.set_pwm(read_time, self.heater_max_power)
if temp < self.peak:
@@ -110,9 +113,11 @@ class ControlAutoTune:
def calc_pid(self, pos):
temp_diff = self.peaks[pos][0] - self.peaks[pos-1][0]
time_diff = self.peaks[pos][1] - self.peaks[pos-2][1]
- Ku = 4. * (2. * self.heater_max_power) / (abs(temp_diff) * math.pi)
+ # Use Astrom-Hagglund method to estimate Ku and Tu
+ amplitude = .5 * abs(temp_diff)
+ Ku = 4. * self.heater_max_power / (math.pi * amplitude)
Tu = time_diff
-
+ # Use Ziegler-Nichols method to generate PID parameters
Ti = 0.5 * Tu
Td = 0.125 * Tu
Kp = 0.6 * Ku * heater.PID_PARAM_BASE