kopia lustrzana https://github.com/jamesgao/kiln_controller
implement rudimentary duty-cycle support
rodzic
b6ae241f08
commit
67e53d1981
|
@ -127,6 +127,7 @@ class Profile(threading.Thread):
|
|||
self.pid = PID.PID(Kp, Ki, Kd)
|
||||
self.callback = callback
|
||||
self.running = True
|
||||
self.duty_cycle = False
|
||||
self.start()
|
||||
|
||||
@property
|
||||
|
@ -157,11 +158,19 @@ class Profile(threading.Thread):
|
|||
temp = self.therm.temperature.temp
|
||||
if temp == -1:
|
||||
continue #skip invalid temperature readings
|
||||
elif temp - setpoint > 50:
|
||||
self.regulator.off()
|
||||
self.duty_cycle = True
|
||||
|
||||
pid_out = self.pid.update(temp)
|
||||
if pid_out < 0: pid_out = 0
|
||||
if pid_out > 1: pid_out = 1
|
||||
self.regulator.set(pid_out)
|
||||
else:
|
||||
if self.duty_cycle:
|
||||
self.regulator.ignite()
|
||||
self.duty_cycle = False
|
||||
|
||||
pid_out = self.pid.update(temp)
|
||||
if pid_out < 0: pid_out = 0
|
||||
if pid_out > 1: pid_out = 1
|
||||
self.regulator.set(pid_out)
|
||||
|
||||
if self.callback is not None:
|
||||
self.callback(temp, setpoint, pid_out)
|
||||
|
|
Ładowanie…
Reference in New Issue