- improved temp controllers
This commit is contained in:
@@ -169,7 +169,7 @@ if __name__ == '__main__':
|
||||
hold_counter -= 1
|
||||
ctrl.process()
|
||||
plant.process()
|
||||
temp_ist = plant.get_temperature() + 0.0 * np.random.randn()
|
||||
temp_ist = plant.get_temperature_delayed() + 0.0 * np.random.randn()
|
||||
ctrl.set_theta_ist(temp_ist)
|
||||
|
||||
y = 3500*ctrl.get_power()
|
||||
@@ -185,7 +185,7 @@ if __name__ == '__main__':
|
||||
_y = np.append(_y, y)
|
||||
_fb = np.append(_fb, fb)
|
||||
_t = np.append(_t, t)
|
||||
_heatrate_ist_kalman = np.append(_heatrate_ist_kalman, min(3, ctrl.heatrate_ist))
|
||||
_heatrate_ist_kalman = np.append(_heatrate_ist_kalman, max(-1, min(3, ctrl.heatrate_ist)))
|
||||
_temp_ist_kalman = np.append(_temp_ist, ctrl.theta_ist)
|
||||
t += 1
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@ import numpy as np
|
||||
from utils.value import AttributeChange
|
||||
from enum import Enum
|
||||
|
||||
PLANT_DELAY = 35
|
||||
|
||||
|
||||
class States(Enum):
|
||||
IDLE = 0,
|
||||
@@ -37,8 +35,8 @@ class TempController(AttributeChange):
|
||||
self.pid_hold.set_params(params['Hold'])
|
||||
self.pid_rate.set_params(params['Heat'])
|
||||
self.model = Pot(dt, model_params)
|
||||
self.theta_ist_delay_model = Delay(dt, PLANT_DELAY)
|
||||
self.dtheta_ist_delay_model = Delay(dt, PLANT_DELAY)
|
||||
self.theta_ist_delay_model = Delay(dt, model_params['Td'])
|
||||
self.dtheta_ist_delay_model = Delay(dt, model_params['Td'])
|
||||
|
||||
def set_theta_ist(self, value):
|
||||
self.theta_ist_set = value
|
||||
@@ -53,7 +51,7 @@ class TempController(AttributeChange):
|
||||
self.heatrate_soll_set = value
|
||||
|
||||
def process(self):
|
||||
# Process Kalman
|
||||
# Process Kalman of Model
|
||||
Z_model = self.kalman_model.process_measurement((self.model.get_temperature(), 0), 0.0)
|
||||
xp_model = self.kalman_model.process(Z_model)
|
||||
theta_ist_model = xp_model[0, 0]
|
||||
@@ -61,6 +59,7 @@ class TempController(AttributeChange):
|
||||
self.theta_ist_delay_model.put(theta_ist_model)
|
||||
self.dtheta_ist_delay_model.put(heatrate_ist_model)
|
||||
|
||||
# Process Kalman of Plant
|
||||
Z_plant = self.kalman_plant.process_measurement((self.theta_ist_set, 0), 0.0)
|
||||
xp_plant = self.kalman_plant.process(Z_plant)
|
||||
theta_ist_plant = xp_plant[0, 0]
|
||||
@@ -150,7 +149,7 @@ if __name__ == '__main__':
|
||||
"C" : 4190,
|
||||
"M" : 20,
|
||||
"L" : 0.05,
|
||||
"Td" : 0,
|
||||
"Td" : 30,
|
||||
"kn" : 0.2
|
||||
}
|
||||
|
||||
@@ -158,9 +157,9 @@ if __name__ == '__main__':
|
||||
"dt" : 1.0,
|
||||
"theta" : 20,
|
||||
"C" : 4190,
|
||||
"M" : 20,
|
||||
"L" : 0.05,
|
||||
"Td" : 0,
|
||||
"M" : 20 + 4,
|
||||
"L" : 0.07,
|
||||
"Td" : 30 + 5,
|
||||
"kn" : 0.2
|
||||
}
|
||||
|
||||
@@ -182,8 +181,6 @@ if __name__ == '__main__':
|
||||
|
||||
t = 0
|
||||
|
||||
delay_plant = Delay(1.0, PLANT_DELAY)
|
||||
|
||||
for temp in temps:
|
||||
temp_soll = temp['Temp']
|
||||
hold_counter = temp['Duration']
|
||||
@@ -198,8 +195,7 @@ if __name__ == '__main__':
|
||||
hold_counter -= 1
|
||||
ctrl.process()
|
||||
plant.process()
|
||||
delay_plant.put(plant.get_temperature())
|
||||
temp_ist = delay_plant.get()
|
||||
temp_ist = plant.get_temperature_delayed()
|
||||
ctrl.set_theta_ist(temp_ist)
|
||||
|
||||
y = 3500*ctrl.get_power()
|
||||
|
||||
Reference in New Issue
Block a user