- temperature from plant simulation is rounded
and now causes problems estimating heat rate - create smoother at contruction time git-svn-id: http://moon:8086/svn/projects/HendiControl@201 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
@@ -39,6 +39,10 @@ class Controller():
|
||||
self.is_pause = False
|
||||
self.is_restart = False
|
||||
self.receipe = None
|
||||
self.theta_sm = Smoother(1.0)
|
||||
self.heatrate_sm = Smoother(0.5)
|
||||
self.theta_err_sm = Smoother(1.0)
|
||||
self.heatrate_err_sm = Smoother(1.0)
|
||||
|
||||
def log(self, s):
|
||||
now = time.time()
|
||||
@@ -132,8 +136,6 @@ class Controller():
|
||||
# The loop
|
||||
# ------------------------------
|
||||
doLoop = True
|
||||
theta_err_sm = Smoother(0.5)
|
||||
heatrate_err_sm = Smoother(0.5)
|
||||
while(doLoop):
|
||||
|
||||
time_start = time.time()
|
||||
@@ -144,15 +146,18 @@ class Controller():
|
||||
# -----------------------------------------
|
||||
self.stirrer.process()
|
||||
self.plant.process()
|
||||
theta_ist = self.plant.getTemperature()
|
||||
|
||||
heatrate_ist = 60/self.dt * (theta_ist - self.theta_ist)
|
||||
theta = self.plant.getTemperature()
|
||||
theta_ist = self.theta_sm.process(theta)
|
||||
|
||||
heatrate = 60/self.dt * (theta_ist - self.theta_ist)
|
||||
heatrate_ist = self.heatrate_sm.process(heatrate)
|
||||
|
||||
theta_err = theta_soll - theta_ist
|
||||
heatrate_err = heatrate_soll - heatrate_ist
|
||||
|
||||
theta_err_sm.process(theta_err)
|
||||
heatrate_err_sm.process(heatrate_err)
|
||||
self.theta_err_sm.process(theta_err)
|
||||
self.heatrate_err_sm.process(heatrate_err)
|
||||
|
||||
if self.ovenState == ovenStates.NOP:
|
||||
if theta_ist < theta_soll:
|
||||
@@ -160,7 +165,7 @@ class Controller():
|
||||
|
||||
pid_err = 0
|
||||
if self.ovenState == ovenStates.HEAT:
|
||||
pid_err = heatrate_err_sm.get_y()
|
||||
pid_err = self.heatrate_err_sm.get_y()
|
||||
pid_params_acqu = self.params['Heat']['Acqu']['Pid']
|
||||
pid_params_track = self.params['Heat']['Track']['Pid']
|
||||
pid_thresh_acqu = 0.2
|
||||
@@ -171,7 +176,7 @@ class Controller():
|
||||
self.timer_ist = timer_soll
|
||||
|
||||
if self.ovenState == ovenStates.HOLD:
|
||||
pid_err = theta_err_sm.get_y()
|
||||
pid_err = self.theta_err_sm.get_y()
|
||||
pid_params_acqu = self.params['Hold']['Acqu']['Pid']
|
||||
pid_params_track = self.params['Hold']['Track']['Pid']
|
||||
pid_thresh_acqu = 0.2
|
||||
|
||||
@@ -39,4 +39,4 @@ class Mass(APlant):
|
||||
return self.P
|
||||
|
||||
def getTemperature(self):
|
||||
return self.theta + self.theta_amb + self.kn*np.random.normal(0,1)/sqrt(12.0)
|
||||
return round(self.theta + self.theta_amb + self.kn*np.random.normal(0,1)/sqrt(12.0), 1)
|
||||
|
||||
Reference in New Issue
Block a user