- PID: use pot for testing
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from components.pid.pid import Pid
|
||||
from components.plant.pot import Pot
|
||||
from matplotlib.pyplot import plot, figure, subplot, title, xlabel, ylabel, grid, show
|
||||
import numpy as np
|
||||
from utils.value import AttributeChange
|
||||
@@ -53,9 +54,9 @@ if __name__ == '__main__':
|
||||
"dt": 1.0,
|
||||
"Hold": {
|
||||
"Pid": {
|
||||
"kp": 0.5,
|
||||
"ki": 0.0,
|
||||
"kd": 0.5,
|
||||
"kp": 0.8,
|
||||
"ki": 0.008,
|
||||
"kd": 0.0,
|
||||
"rho": 1.0
|
||||
}
|
||||
},
|
||||
@@ -69,9 +70,20 @@ if __name__ == '__main__':
|
||||
}
|
||||
}
|
||||
|
||||
pot_params = {
|
||||
"dt" : 1.0,
|
||||
"theta" : 20,
|
||||
"C" : 4190,
|
||||
"M" : 20,
|
||||
"L" : 0.05,
|
||||
"Td" : 12,
|
||||
"kn" : 0.2
|
||||
}
|
||||
|
||||
temp_ist = 0
|
||||
temp_soll = 20
|
||||
ctrl = TempController(params)
|
||||
plant = Pot(pot_params)
|
||||
_temp_ist = np.empty(0)
|
||||
_temp_soll = np.empty(0)
|
||||
_y = np.empty(0)
|
||||
@@ -80,7 +92,7 @@ if __name__ == '__main__':
|
||||
a = 0.5
|
||||
fb = 0
|
||||
rho = 0.02
|
||||
temps = [{'Temp': 20, 'Duration': 100}, {'Temp': 40, 'Duration': 100}, {'Temp': 35, 'Duration': 100}]
|
||||
temps = [{'Temp': 20, 'Duration': 1000}, {'Temp': 40, 'Duration': 1000}, {'Temp': 50, 'Duration': 1000}, {'Temp': 60, 'Duration': 1000}, {'Temp': 70, 'Duration': 1000}, {'Temp': 80, 'Duration': 1000}]
|
||||
|
||||
t = 0
|
||||
for temp in temps:
|
||||
@@ -95,9 +107,11 @@ if __name__ == '__main__':
|
||||
break
|
||||
hold_counter -= 1
|
||||
ctrl.process()
|
||||
y = max(0, ctrl.get_power_hold())
|
||||
fb = (1-a)*fb + a*round(y, 2)
|
||||
temp_ist += fb
|
||||
plant.process()
|
||||
y = max(0, 3500*ctrl.get_power_hold())
|
||||
plant.setPower(y)
|
||||
temp_ist = round(plant.getTemperature(), 1)
|
||||
fb = plant.getPower()
|
||||
ctrl.set_theta_ist(temp_ist)
|
||||
if abs(temp_ist - temp_soll) < 0.1:
|
||||
hold = True
|
||||
|
||||
Reference in New Issue
Block a user