[brewpi]
- log data - log raw temp git-svn-id: http://moon:8086/svn/projects/HendiControl@240 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
@@ -11,9 +11,21 @@ from matplotlib.pyplot import figure, clf, plot, xlabel, ylabel, xlim, ylim, tit
|
|||||||
|
|
||||||
def results_plot(self):
|
def results_plot(self):
|
||||||
|
|
||||||
|
fp = open("results.dat", 'w')
|
||||||
|
|
||||||
|
for n in range(0, len(self.time_v)):
|
||||||
|
d = self.time_v[n]
|
||||||
|
v1 = self.theta_raw_v[n]
|
||||||
|
v2 = self.theta_k_v[n]
|
||||||
|
v3 = self.power_v[n]
|
||||||
|
v4 = self.error_v[n]
|
||||||
|
v5 = self.heatrate_k_v[n]
|
||||||
|
fp.write("{:6.3f} {:6.3f} {:6.3f} {:6.3f} {:6.3f}\n".format(d, v1, v2, v3, v4, v5))
|
||||||
|
|
||||||
|
fp.close()
|
||||||
figure(1)
|
figure(1)
|
||||||
subplot(4, 1, 1)
|
subplot(4, 1, 1)
|
||||||
plot(self.time_v, self.theta_k_v, 'r-', linewidth=1)
|
plot(self.time_v, self.theta_raw_v, 'g-', self.time_v, self.theta_k_v, 'r-', linewidth=1)
|
||||||
title('Temperature')
|
title('Temperature')
|
||||||
grid(True)
|
grid(True)
|
||||||
ylabel('°C')
|
ylabel('°C')
|
||||||
@@ -56,7 +68,7 @@ if __name__ == '__main__':
|
|||||||
signal.signal(signal.SIGCONT, handler)
|
signal.signal(signal.SIGCONT, handler)
|
||||||
signal.signal(signal.SIGHUP, handler)
|
signal.signal(signal.SIGHUP, handler)
|
||||||
|
|
||||||
fp = open("brewpi.json")
|
fp = open("brewpi_sprung.json")
|
||||||
configJson = json.load(fp)
|
configJson = json.load(fp)
|
||||||
|
|
||||||
plant_class = globals()[configJson["Controller"]['plant_name']]
|
plant_class = globals()[configJson["Controller"]['plant_name']]
|
||||||
@@ -66,7 +78,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
ablauf = Controller(configJson["Controller"], plant, ruehrer)
|
ablauf = Controller(configJson["Controller"], plant, ruehrer)
|
||||||
|
|
||||||
fp = open("Rezept-001.json")
|
fp = open("Rezept-Sprung.json")
|
||||||
recipeJson = json.load(fp)
|
recipeJson = json.load(fp)
|
||||||
|
|
||||||
ablauf.start(recipeJson)
|
ablauf.start(recipeJson)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class Controller():
|
|||||||
self.timer_ist = 0
|
self.timer_ist = 0
|
||||||
self.theta = 0
|
self.theta = 0
|
||||||
self.heatrate = 0
|
self.heatrate = 0
|
||||||
|
self.theta_raw_v = np.empty(0)
|
||||||
self.theta_v = np.empty(0)
|
self.theta_v = np.empty(0)
|
||||||
self.theta_k_v = np.empty(0)
|
self.theta_k_v = np.empty(0)
|
||||||
self.heatrate_v = np.empty(0)
|
self.heatrate_v = np.empty(0)
|
||||||
@@ -160,10 +161,11 @@ class Controller():
|
|||||||
self.stirrer.process()
|
self.stirrer.process()
|
||||||
self.plant.process()
|
self.plant.process()
|
||||||
|
|
||||||
theta = self.plant.getTemperature()
|
theta_raw = self.plant.getTemperature()
|
||||||
|
self.theta_raw_v = np.append(self.theta_raw_v, theta_raw)
|
||||||
|
|
||||||
# Process Kalman
|
# Process Kalman
|
||||||
Z = self.kalman.process_measurement((theta, 0))
|
Z = self.kalman.process_measurement((theta_raw, 0))
|
||||||
xp = self.kalman.process(Z)
|
xp = self.kalman.process(Z)
|
||||||
theta_ist_k = xp[0, 0]
|
theta_ist_k = xp[0, 0]
|
||||||
dtheta_ist_k = xp[1, 0]
|
dtheta_ist_k = xp[1, 0]
|
||||||
@@ -171,7 +173,7 @@ class Controller():
|
|||||||
self.heatrate_k_v = np.append(self.heatrate_k_v, dtheta_ist_k * 60 / self.dt)
|
self.heatrate_k_v = np.append(self.heatrate_k_v, dtheta_ist_k * 60 / self.dt)
|
||||||
|
|
||||||
# Process conventional
|
# Process conventional
|
||||||
theta_ist = self.theta_sm.process(theta)
|
theta_ist = self.theta_sm.process(theta_raw)
|
||||||
dtheta_ist = self.heatrate_sm.process(theta_ist - self.theta)
|
dtheta_ist = self.heatrate_sm.process(theta_ist - self.theta)
|
||||||
self.theta_v = np.append(self.theta_v, theta_ist)
|
self.theta_v = np.append(self.theta_v, theta_ist)
|
||||||
self.heatrate_v = np.append(self.heatrate_v, dtheta_ist * 60/self.dt)
|
self.heatrate_v = np.append(self.heatrate_v, dtheta_ist * 60/self.dt)
|
||||||
|
|||||||
Reference in New Issue
Block a user