Biomedical Engineering Reference
In-Depth Information
Actuator model
Plant
86
a
2
.
s
2
+
a
1
.
s
+ 4
1
1
u
y
Figure 11.14
The plant is a second-order linear system
Controller
+
PID
u
y
-
Step
Plant and actuator
Scope
1
*Tunable Variables are PID gains,
Kp
,
Ki
and
Kd
.
Out
1
Figure 11.15
The closed-loop system
The error is defined as the difference between step input and output. The cost function
to be minimized (
J
) is the total square error from 0 to 100 seconds (see Equation 11.21).
100
y (t)
u(t)
2
d
t
J
=
−
(11.21)
0
The variables are the parameters of the PID controller,
J
(
K
)=
J
(
K
p
,
K
I
,K
D
). In discrete
cases, Equation 11.21 is written as:
N
J
K
P
,K
I
,K
D
=
y(k)
u(k)
2
−
;
k
=
1
, ... ,N
(11.22)
k
=
1
where:
100
T
s
N
=
(11.23)
In which
N
is the total number of samples in 100 seconds and
T
s
is the sampling period.
Having the number of samples (
N
) and sampling period (
T
s
), the objective of the
optimization problem is to find PID controller parameters for which
J
(
K
) is minimized.
The Matlab routine '
lsqnonlin
' was used to perform least-squares fit on the tracking of
the output. The tracking was performed via an M-file function '
tracklsq
,' which returns
the error signal, the output was computed by calling '
sim
,' minus the input signal 1(unit
step). The code for '
tracklsq
' is shown in Appendix 11.A.