diff --git a/Control/brewpi/brewpi.py b/Control/brewpi/brewpi.py index 682054a..cd34c84 100755 --- a/Control/brewpi/brewpi.py +++ b/Control/brewpi/brewpi.py @@ -11,9 +11,21 @@ from matplotlib.pyplot import figure, clf, plot, xlabel, ylabel, xlim, ylim, tit 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) 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') grid(True) ylabel('°C') @@ -56,7 +68,7 @@ if __name__ == '__main__': signal.signal(signal.SIGCONT, handler) signal.signal(signal.SIGHUP, handler) - fp = open("brewpi.json") + fp = open("brewpi_sprung.json") configJson = json.load(fp) plant_class = globals()[configJson["Controller"]['plant_name']] @@ -66,7 +78,7 @@ if __name__ == '__main__': ablauf = Controller(configJson["Controller"], plant, ruehrer) - fp = open("Rezept-001.json") + fp = open("Rezept-Sprung.json") recipeJson = json.load(fp) ablauf.start(recipeJson) diff --git a/Control/brewpi/controller.py b/Control/brewpi/controller.py index b68a09c..809c2b6 100644 --- a/Control/brewpi/controller.py +++ b/Control/brewpi/controller.py @@ -25,6 +25,7 @@ class Controller(): self.timer_ist = 0 self.theta = 0 self.heatrate = 0 + self.theta_raw_v = np.empty(0) self.theta_v = np.empty(0) self.theta_k_v = np.empty(0) self.heatrate_v = np.empty(0) @@ -160,10 +161,11 @@ class Controller(): self.stirrer.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 - Z = self.kalman.process_measurement((theta, 0)) + Z = self.kalman.process_measurement((theta_raw, 0)) xp = self.kalman.process(Z) theta_ist_k = xp[0, 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) # 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) self.theta_v = np.append(self.theta_v, theta_ist) self.heatrate_v = np.append(self.heatrate_v, dtheta_ist * 60/self.dt)