moving logging to one place. make logging output more verbose. remove code to zero out iterm if out of pid window.
This commit is contained in:
parent
3d0ced062c
commit
165a8b16dd
@ -65,7 +65,7 @@ sensor_time_wait = 2
|
|||||||
# your specific kiln. Note that the integral pid_ki is
|
# your specific kiln. Note that the integral pid_ki is
|
||||||
# inverted so that a smaller number means more integral action.
|
# inverted so that a smaller number means more integral action.
|
||||||
pid_kp = 25 # Proportional 25,200,200
|
pid_kp = 25 # Proportional 25,200,200
|
||||||
pid_ki = 1 # Integral
|
pid_ki = 20 # Integral
|
||||||
pid_kd = 200 # Derivative
|
pid_kd = 200 # Derivative
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
67
lib/oven.py
67
lib/oven.py
@ -219,12 +219,10 @@ class Oven(threading.Thread):
|
|||||||
if self.target - temp > config.pid_control_window:
|
if self.target - temp > config.pid_control_window:
|
||||||
log.info("kiln must catch up, too cold, shifting schedule")
|
log.info("kiln must catch up, too cold, shifting schedule")
|
||||||
self.start_time = datetime.datetime.now() - datetime.timedelta(milliseconds = self.runtime * 1000)
|
self.start_time = datetime.datetime.now() - datetime.timedelta(milliseconds = self.runtime * 1000)
|
||||||
self.pid.iterm = 0
|
|
||||||
# kiln too hot, wait for it to cool down
|
# kiln too hot, wait for it to cool down
|
||||||
if temp - self.target > config.pid_control_window:
|
if temp - self.target > config.pid_control_window:
|
||||||
log.info("kiln must catch up, too hot, shifting schedule")
|
log.info("kiln must catch up, too hot, shifting schedule")
|
||||||
self.start_time = datetime.datetime.now() - datetime.timedelta(milliseconds = self.runtime * 1000)
|
self.start_time = datetime.datetime.now() - datetime.timedelta(milliseconds = self.runtime * 1000)
|
||||||
self.pid.iterm = 0
|
|
||||||
|
|
||||||
def update_runtime(self):
|
def update_runtime(self):
|
||||||
|
|
||||||
@ -363,15 +361,20 @@ class SimulatedOven(Oven):
|
|||||||
int(self.p_env)))
|
int(self.p_env)))
|
||||||
|
|
||||||
time_left = self.totaltime - self.runtime
|
time_left = self.totaltime - self.runtime
|
||||||
log.info("temp=%.2f, target=%.2f, pid=%.3f, heat_on=%.2f, heat_off=%.2f, run_time=%d, total_time=%d, time_left=%d" %
|
|
||||||
(self.board.temp_sensor.temperature + config.thermocouple_offset,
|
log.info("temp=%.2f, target=%.2f, error=%.2f, pid=%.2f, p=%.2f, i=%.2f, d=%.2f, heat_on=%.2f, heat_off=%.2f, run_time=%d, total_time=%d, time_left=%d" %
|
||||||
self.target,
|
(self.pid.pidstats['ispoint'],
|
||||||
pid,
|
self.pid.pidstats['setpoint'],
|
||||||
heat_on,
|
self.pid.pidstats['err'],
|
||||||
heat_off,
|
self.pid.pidstats['pid'],
|
||||||
self.runtime,
|
self.pid.pidstats['p'],
|
||||||
self.totaltime,
|
self.pid.pidstats['i'],
|
||||||
time_left))
|
self.pid.pidstats['d'],
|
||||||
|
heat_on,
|
||||||
|
heat_off,
|
||||||
|
self.runtime,
|
||||||
|
self.totaltime,
|
||||||
|
time_left))
|
||||||
|
|
||||||
# we don't actually spend time heating & cooling during
|
# we don't actually spend time heating & cooling during
|
||||||
# a simulation, so sleep.
|
# a simulation, so sleep.
|
||||||
@ -412,15 +415,20 @@ class RealOven(Oven):
|
|||||||
if heat_off:
|
if heat_off:
|
||||||
self.output.cool(heat_off)
|
self.output.cool(heat_off)
|
||||||
time_left = self.totaltime - self.runtime
|
time_left = self.totaltime - self.runtime
|
||||||
log.info("temp=%.2f, target=%.2f, pid=%.3f, heat_on=%.2f, heat_off=%.2f, run_time=%d, total_time=%d, time_left=%d" %
|
|
||||||
(self.board.temp_sensor.temperature + config.thermocouple_offset,
|
log.info("temp=%.2f, target=%.2f, error=%.2f, pid=%.2f, p=%.2f, i=%.2f, d=%.2f, heat_on=%.2f, heat_off=%.2f, run_time=%d, total_time=%d, time_left=%d" %
|
||||||
self.target,
|
(self.pid.pidstats['ispoint'],
|
||||||
pid,
|
self.pid.pidstats['setpoint'],
|
||||||
heat_on,
|
self.pid.pidstats['err'],
|
||||||
heat_off,
|
self.pid.pidstats['pid'],
|
||||||
self.runtime,
|
self.pid.pidstats['p'],
|
||||||
self.totaltime,
|
self.pid.pidstats['i'],
|
||||||
time_left))
|
self.pid.pidstats['d'],
|
||||||
|
heat_on,
|
||||||
|
heat_off,
|
||||||
|
self.runtime,
|
||||||
|
self.totaltime,
|
||||||
|
time_left))
|
||||||
|
|
||||||
class Profile():
|
class Profile():
|
||||||
def __init__(self, json_data):
|
def __init__(self, json_data):
|
||||||
@ -489,10 +497,11 @@ class PID():
|
|||||||
output = 0
|
output = 0
|
||||||
out4logs = 0
|
out4logs = 0
|
||||||
dErr = 0
|
dErr = 0
|
||||||
|
|
||||||
if error < (-1 * config.pid_control_window):
|
if error < (-1 * config.pid_control_window):
|
||||||
log.info("kiln outside pid control window, max cooling")
|
log.info("kiln outside pid control window, max cooling")
|
||||||
output = 0
|
output = 0
|
||||||
|
# it is possible to set self.iterm=0 here and also below
|
||||||
|
# but I dont think its needed
|
||||||
elif error > (1 * config.pid_control_window):
|
elif error > (1 * config.pid_control_window):
|
||||||
log.info("kiln outside pid control window, max heating")
|
log.info("kiln outside pid control window, max heating")
|
||||||
output = 1
|
output = 1
|
||||||
@ -508,6 +517,10 @@ class PID():
|
|||||||
self.lastErr = error
|
self.lastErr = error
|
||||||
self.lastNow = now
|
self.lastNow = now
|
||||||
|
|
||||||
|
# no active cooling
|
||||||
|
if output < 0:
|
||||||
|
output = 0
|
||||||
|
|
||||||
self.pidstats = {
|
self.pidstats = {
|
||||||
'time': time.mktime(now.timetuple()),
|
'time': time.mktime(now.timetuple()),
|
||||||
'timeDelta': timeDelta,
|
'timeDelta': timeDelta,
|
||||||
@ -525,16 +538,4 @@ class PID():
|
|||||||
'out': output,
|
'out': output,
|
||||||
}
|
}
|
||||||
|
|
||||||
# if out4logs > 0:
|
|
||||||
# log.info("pid percents pid=%0.2f p=%0.2f i=%0.2f d=%0.2f" % (out4logs,
|
|
||||||
# ((self.kp * error)/out4logs)*100,
|
|
||||||
# (self.iterm/out4logs)*100,
|
|
||||||
# ((self.kd * dErr)/out4logs)*100))
|
|
||||||
log.info("pid actuals pid=%0.2f p=%0.2f i=%0.2f d=%0.2f icomp=%0.2f error=%0.2f" % (out4logs,
|
|
||||||
self.kp * error,
|
|
||||||
self.iterm,
|
|
||||||
self.kd * dErr,
|
|
||||||
icomp,
|
|
||||||
error))
|
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user