228
6 Hierarchical Component Models
Then, the equations will take the following differential forms:
dI (t)
dt
= e(t)
u h (t) = K p ·
e(t) +
1
K p T I
· I (t) +
K d
K p
de(t)
dt
We introduce the following convenient notation:
1
K p T I
· I (t) = x(t), K p T I = T, K p = K ,
K d
K p
= T d
Finally, the equations are rewritten as:
dx(t)
dt
=
1
T
e(t)
u h (t) = K ·
e(t) + x(t) + T d
de(t)
dt
Here, x(t) is the state variable of the PID controller, T is the time constant of the
integral gain, K is the integral gain of the PID controller, and T d is the time constant
of the differential gain.
Using these equations and the parent class BaseController, we can create an
inherited class PIDController
model PIDController ”Elementary PID controller”
extends BaseController;
parameter Real K(unit = ”m2/s”) = 0.1 ”Gain”;
parameter Real T(unit = ”s”) = 10 ”Integrator time
constant”;
parameter Real Td(unit = ”s”) = 5 ”Derivative gain”;
Real x(unit = ”m”) ”Integrator state”;
equation
der(x) = e / T;
u = K * (e + x + Td * der(e));
end PIDController;
Check the model for balance and create, as usual, an icon, Fig. 6.33.
You can begin compiling a system model by dragging and dropping components
onto a diagram. However, it is easier to obtain a tank with a PID controller by
replacing the PI controller with the PID controller in the previous diagram, Fig. 6.34.
You can go to the text view. We will see the program code of the TankPID model
in Modelica:
model TankPID ”A tank controlled by a PID controller”
Components.Tank tank;
Components.PIDController pidControl(ref = 0.25);
Components.LiquidSource source;
equation
6 Hierarchical Component Models
Then, the equations will take the following differential forms:
dI (t)
dt
= e(t)
u h (t) = K p ·
e(t) +
1
K p T I
· I (t) +
K d
K p
de(t)
dt
We introduce the following convenient notation:
1
K p T I
· I (t) = x(t), K p T I = T, K p = K ,
K d
K p
= T d
Finally, the equations are rewritten as:
dx(t)
dt
=
1
T
e(t)
u h (t) = K ·
e(t) + x(t) + T d
de(t)
dt
Here, x(t) is the state variable of the PID controller, T is the time constant of the
integral gain, K is the integral gain of the PID controller, and T d is the time constant
of the differential gain.
Using these equations and the parent class BaseController, we can create an
inherited class PIDController
model PIDController ”Elementary PID controller”
extends BaseController;
parameter Real K(unit = ”m2/s”) = 0.1 ”Gain”;
parameter Real T(unit = ”s”) = 10 ”Integrator time
constant”;
parameter Real Td(unit = ”s”) = 5 ”Derivative gain”;
Real x(unit = ”m”) ”Integrator state”;
equation
der(x) = e / T;
u = K * (e + x + Td * der(e));
end PIDController;
Check the model for balance and create, as usual, an icon, Fig. 6.33.
You can begin compiling a system model by dragging and dropping components
onto a diagram. However, it is easier to obtain a tank with a PID controller by
replacing the PI controller with the PID controller in the previous diagram, Fig. 6.34.
You can go to the text view. We will see the program code of the TankPID model
in Modelica:
model TankPID ”A tank controlled by a PID controller”
Components.Tank tank;
Components.PIDController pidControl(ref = 0.25);
Components.LiquidSource source;
equation
