- refactored
- increased Hold.Pid.kp - decrease state change HEAT TO HOLD windows to 1°C
This commit is contained in:
@@ -4,6 +4,7 @@ from components.pid import Pid, Kalman
|
||||
from components import APid
|
||||
import numpy as np
|
||||
from enum import Enum
|
||||
from components.pid.tc_constants import *
|
||||
|
||||
|
||||
class States(Enum):
|
||||
@@ -90,13 +91,6 @@ class TempController(APid):
|
||||
self.process_pid(theta_err, heatrate_err)
|
||||
|
||||
def process_fsm(self, diff):
|
||||
THRESH_HOLD_IDLE = 0.1
|
||||
THRESH_HOLD_HEAT = 2.0
|
||||
THRESH_IDLE_HEAT = 1.0
|
||||
THRESH_IDLE_HOLD = 0.1
|
||||
THRESH_HEAT_HOLD = 2.0
|
||||
THRESH_HEAT_IDLE = 2.0
|
||||
|
||||
# Process state
|
||||
state_next = self.state
|
||||
if self.state == States.IDLE:
|
||||
@@ -139,40 +133,10 @@ class TempController(APid):
|
||||
if __name__ == '__main__':
|
||||
dt = 1.0
|
||||
|
||||
tc_params = {
|
||||
"Kalman": {
|
||||
"var_P" : 1.0,
|
||||
"var_Q" : 0.0001,
|
||||
"var_R" : 1.0
|
||||
},
|
||||
"Hold": {
|
||||
"kp": 0.2,
|
||||
"ki": 0.0,
|
||||
"kd": 0.0,
|
||||
"kt": 0.0
|
||||
},
|
||||
"Heat": {
|
||||
"kp": 0.1,
|
||||
"ki": 0.01,
|
||||
"kd": 0.0,
|
||||
"kt": 1.5
|
||||
}
|
||||
}
|
||||
|
||||
pot_params = {
|
||||
"theta" : 20,
|
||||
"C" : 4190,
|
||||
"M" : 20,
|
||||
"L" : 0.05,
|
||||
"Td" : 80,
|
||||
"kn" : 0.2,
|
||||
"gain" : 0.8
|
||||
}
|
||||
|
||||
temp_ist = 0
|
||||
temp_soll = 20
|
||||
ctrl = TempController(dt, tc_params)
|
||||
plant = Pot(dt, pot_params)
|
||||
ctrl = TempController(dt, Test.tc_ctrl_params)
|
||||
plant = Pot(dt, Test.tc_pot_params)
|
||||
_temp_ist = np.empty(0)
|
||||
_temp_soll = np.empty(0)
|
||||
_y = np.empty(0)
|
||||
@@ -198,10 +162,10 @@ if __name__ == '__main__':
|
||||
if hold_counter == 0:
|
||||
break
|
||||
hold_counter -= 1
|
||||
ctrl.process()
|
||||
plant.process()
|
||||
temp_ist = plant.get_temperature() + 0.0 * np.random.randn()
|
||||
ctrl.set_theta_ist(temp_ist)
|
||||
ctrl.process()
|
||||
|
||||
y = 3500*ctrl.get_power()
|
||||
power = max(0, y)
|
||||
|
||||
Reference in New Issue
Block a user