kopia lustrzana https://github.com/jbruce12000/kiln-controller
simplified code changes for pid window. removed static flashing heat image with simple html progress bar
rodzic
dab1c45b7f
commit
8546d91035
28
lib/oven.py
28
lib/oven.py
|
|
@ -480,25 +480,8 @@ class PID():
|
|||
window_size = 100
|
||||
|
||||
error = float(setpoint - ispoint)
|
||||
|
||||
# this removes the need for config.stop_integral_windup
|
||||
# it turns the controller into a binary on/off switch
|
||||
# any time it's outside the window defined by
|
||||
# config.pid_control_window
|
||||
if error < (-1 * config.pid_control_window):
|
||||
log.info("kiln outside pid control window, max cooling")
|
||||
self.lastErr = error
|
||||
self.lastNow = now
|
||||
return 0
|
||||
if error > (1 * config.pid_control_window):
|
||||
log.info("kiln outside pid control window, max heating")
|
||||
self.lastErr = error
|
||||
self.lastNow = now
|
||||
return 1
|
||||
|
||||
icomp = (error * timeDelta * (1/self.ki))
|
||||
self.iterm += (error * timeDelta * (1/self.ki))
|
||||
|
||||
dErr = (error - self.lastErr) / timeDelta
|
||||
output = self.kp * error + self.iterm + self.kd * dErr
|
||||
out4logs = output
|
||||
|
|
@ -512,6 +495,17 @@ class PID():
|
|||
|
||||
output = float(output / window_size)
|
||||
|
||||
# this removes the need for config.stop_integral_windup
|
||||
# it turns the controller into a binary on/off switch
|
||||
# any time it's outside the window defined by
|
||||
# config.pid_control_window
|
||||
if error < (-1 * config.pid_control_window):
|
||||
log.info("kiln outside pid control window, max cooling")
|
||||
output = 0
|
||||
if error > (1 * config.pid_control_window):
|
||||
log.info("kiln outside pid control window, max heating")
|
||||
output = 1
|
||||
|
||||
self.pidstats = {
|
||||
'time': time.mktime(now.timetuple()),
|
||||
'timeDelta': timeDelta,
|
||||
|
|
|
|||
|
|
@ -124,6 +124,18 @@ body {
|
|||
display: inline-block;
|
||||
}
|
||||
|
||||
.bar {
|
||||
width:70%;
|
||||
//padding: 2px 2px 0px 2px;
|
||||
//display:block;
|
||||
display: inline-block;
|
||||
font-family:arial;
|
||||
font-size:12px;
|
||||
background-color:#ca3c38;
|
||||
color:#000;
|
||||
//position:absolute;
|
||||
//bottom:0;
|
||||
}
|
||||
|
||||
.ds-led-hazard-active {
|
||||
color: rgb(255, 204, 0);
|
||||
|
|
|
|||
|
|
@ -561,8 +561,7 @@ $(document).ready(function()
|
|||
$('#act_temp').html(parseInt(x.temperature));
|
||||
|
||||
if (x.heat > 0.0) {
|
||||
setTimeout(function() { $('#heat').addClass("ds-led-heat-active") }, 0 )
|
||||
setTimeout(function() { $('#heat').removeClass("ds-led-heat-active") }, (x.heat*1000.0)-5)
|
||||
$('#heat').html('<div class="bar" style="height:'+x.pidstats.out*70+'%;"></div>')
|
||||
}
|
||||
if (x.cool > 0.5) { $('#cool').addClass("ds-led-cool-active"); } else { $('#cool').removeClass("ds-led-cool-active"); }
|
||||
if (x.air > 0.5) { $('#air').addClass("ds-led-air-active"); } else { $('#air').removeClass("ds-led-air-active"); }
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue