- improved temp controller test
This commit is contained in:
@@ -45,9 +45,9 @@ if __name__ == '__main__':
|
|||||||
"dt": 1.0,
|
"dt": 1.0,
|
||||||
"Hold": {
|
"Hold": {
|
||||||
"Pid": {
|
"Pid": {
|
||||||
"kp": 0.4,
|
"kp": 0.5,
|
||||||
"ki": 0.00004,
|
"ki": 0.0,
|
||||||
"kd": 0.0,
|
"kd": 0.5,
|
||||||
"rho": 1.0
|
"rho": 1.0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -64,21 +64,42 @@ if __name__ == '__main__':
|
|||||||
temp_ist = 0
|
temp_ist = 0
|
||||||
temp_soll = 20
|
temp_soll = 20
|
||||||
ctrl = TempController(params)
|
ctrl = TempController(params)
|
||||||
ctrl.set_theta_ist(temp_ist)
|
|
||||||
ctrl.set_theta_soll(temp_soll)
|
|
||||||
t = range(0, 100)
|
|
||||||
_temp_ist = np.empty(0)
|
_temp_ist = np.empty(0)
|
||||||
_temp_soll = np.empty(0)
|
_temp_soll = np.empty(0)
|
||||||
for i in t:
|
_t = np.empty(0)
|
||||||
_temp_ist = np.append(_temp_ist, temp_ist)
|
a = 0.5
|
||||||
_temp_soll = np.append(_temp_soll, temp_soll)
|
fb = 0
|
||||||
ctrl.process()
|
rho = 0.001
|
||||||
y = ctrl.get_power_hold()
|
temps = [{'Temp': 20, 'Duration': 100}, {'Temp': 40, 'Duration': 100}, {'Temp': 30, 'Duration': 100}]
|
||||||
temp_ist += round(y, 2)
|
|
||||||
ctrl.set_theta_ist(temp_ist)
|
t = 0
|
||||||
|
for temp in temps:
|
||||||
|
temp_soll = temp['Temp']
|
||||||
|
hold_counter = temp['Duration']
|
||||||
|
hold = False
|
||||||
|
ctrl.set_theta_soll(temp_soll)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
if hold:
|
||||||
|
if hold_counter == 0:
|
||||||
|
break
|
||||||
|
hold_counter -= 1
|
||||||
|
ctrl.process()
|
||||||
|
y = ctrl.get_power_hold()
|
||||||
|
fb = (1-a)*fb + a*round(y, 2)
|
||||||
|
temp_ist += fb
|
||||||
|
ctrl.set_theta_ist(temp_ist)
|
||||||
|
if abs(temp_ist - temp_soll) < 0.1:
|
||||||
|
hold = True
|
||||||
|
|
||||||
|
temp_ist -= rho
|
||||||
|
_temp_ist = np.append(_temp_ist, temp_ist)
|
||||||
|
_temp_soll = np.append(_temp_soll, temp_soll)
|
||||||
|
_t = np.append(_t, t)
|
||||||
|
t += 1
|
||||||
|
|
||||||
figure(1)
|
figure(1)
|
||||||
plot(t, _temp_ist - _temp_soll, 'bx', linewidth=1)
|
plot(_t, _temp_ist, _t, _temp_soll, 'r-', linewidth=1)
|
||||||
grid(True)
|
grid(True)
|
||||||
show()
|
show()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user