Академический Документы
Профессиональный Документы
Культура Документы
Session outline
Sampled-data control
Discretization of continuous-time controllers
Implementation of PID Controllers
u (t )
t
u (t )
Process
y (t )
Hold
Sampler
yk
uk
uk
D-A
Computer
A-D
yk
.
.
. ...
u(t)
y(t)
u(t)
y(t)
Process
t
DA
and
Hold
.
.
. ...
Sampler
and
AD
Communication network
uk
yk
uk
Computer
...
.
.
.
yk
Sampling
Computer
A/D
u
Algorithm
D/A
y
Process
Aliasing
1
0
1
0
s =
N =
2
h
s
2
5
Time
10
= sampling frequency
= Nyquist frequency
Anti-aliasing filter
Analog low-pass filter that eliminates all frequencies above the
Nyquist frequency
Analog filter
2-6th order Bessel or Butterworth filter
Difficulties with changing h (sampling interval)
Example Prefiltering
(a)
(b)
1
0
1
0
(c)
10
20
30
(d)
1
10
20
30
Time
10
20
30
10
20
30
Time
Design approaches
Digital controllers can be designed in two different ways:
Discrete-time design sampled control theory
Sample the continuous system
Design a digital controller for the sampled system
Z-transform domain
state-space domain
Continuous time design + discretization
Design a continuous controller for the continuous system
Approximate the continuous design
Use fast sampling
Clock
Algorithm
Output
10
5
Time (0t)
10
Input
0.5
0
0.5
Output
(a)
1
10
10
5
10
Time (0t)
15
0.5
Input
0.5
Input
0
0.5
0
0.5
5
10
Time (0t)
15
Better performance?
Dead-beat control h = 1.4/ 0
Position
Velocity
10
10
5
Time (0t)
10
0.5
Input
0.5
0
0.5
A-D
{y(t k )}
{u(t k )}
Algorithm
u(t)
D-A
y(t )
Process
Sampling of systems
Look at the system from the point of view of the computer
Clock
{u(t k )}
y(t)
u(t)
D-A
System
A-D
{ y (tk )}
A(ttk )
x(t k) +
= eA(ttk) x(tk) +
tk
t
A(ts )
tk
ttk
Periodic sampling
Assume periodic sampling, i.e. tk = kh. Then
x( kh + h) = x( kh) + u( kh)
y( kh) = Cx( kh) + Du( kh)
where
= eAh
h
=
eAs ds B
0
0 1
0
dx
x+
u
dt
1 0
1
y = 1 0x
We get
cosh h sinh h
Ah
=e =
sinh h cosh h
h
sinh s
cosh h 1
ds =
cosh s
sinh h
0
Several ways to calculate and . Matlab
= Ax(t) + Bu(t ),
where
= eAh
h
0 =
eAs ds B
0
1 = eA(h )
eAs ds B
Stability region
In continuous time the stability region is the complex left half
plane, i.e., the system is stable if all the poles are in the left
half plane.
In discrete time the stability region is the unit circle.
Frstrkning
10
10
10
10
10
10
50
Fas
100
150
200
250
1
10
10
Frekvens [rad/s]
h = 0.3,
c h = 0.78
h = 0.5,
c h = 1.12
10
10
10
10
10
10
20
5
Time
20
5
Time
20
Time
h = 0.3,
c h = 0.78
h = 0.5,
c h = 1.12
10
10
10
10
10
10
20
5
Time
20
5
Time
20
Time
Session outline
Sampled-data control
Discretization of continuous-time controllers
Implementation of PID Controllers
u(t)
A-D
{u ( kh )}
Algorithm
{ y ( kh )}
y (t)
D-A
Clock
Want to get:
A/D + Algorithm + D/A G (s)
Methods:
Approximate s, i.e., H ( z) = G (s )
Other discretization methods (Matlab)
Approximation methods
Forward Difference (Eulers method):
dx(t)
x(t k+1 ) x(t k)
dt
h
s =
z1
h
Backward Difference:
dx(t)
x(t k) x(t k1 )
dt
h
s =
Tustin:
dx(t)
dt
z1
zh
tk+1 )
+ dx(dt
x(t k+1 ) x(t k)
2
h
1
s = h2 zz
+1
Stability of approximations
Forward differences
Backward differences
Tustin
Discretization example
Controller designed in continuous-time:
b
E(s)
U (s) =
s+a
z1
):
h
b
e( k)
u( k) =
( z 1)/h + a
( z 1 + ha)u( k) = bhe( k)
u( k + 1) = (1 ha)u( k) + bhe( k)
u( k) = (1 ha)u( k 1) + bhe( k 1)
Controller stable if 1 < (1 ha) < 1, i.e., 0 < h < 2/a (does not 3
imply that the closed loop system is stable, though)
Controller Synthesis
Process Model
G(s)
x = Ax + Bu
y = Cx + Du
Difference Equation
Software algorithm
Session outline
Sampled-data control
Discretization of continuous-time controllers
Implementation of PID Controllers
PID Algorithm
Textbook Algorithm:
u(t)
K ( e(t)
U (s) = K ( E(s) +
1
TI
1
sTI
e( )d +
TD dedt(t) )
E(s)
+ TD sE(s))
Algorithm Modifications
Derivative weighting
Setpoint weighting
replaced by
u = K ( ysp y)
0 1
A better algorithm
1
TD s
Y (s))
U (s) = K ( yr y +
E(s)
sTI
1 + sTD / N
Modifications:
Setpoint weighting ( ) in the proportional term improves setpoint response
Limitation of the derivative gain (low-pass filter) to avoid derivation of measurement noise
Derivative action only on y to avoid bumps for step changes in
the reference signal
When the control signal saturates the integral part will continue to grow
integrator (reset) windup.
When the control signal saturates the integral part will integrate up to a
very large value. This may cause large overshoots.
2 Output y and yref
1.5
1
0.5
0
0
10
20
Control variable u
0.2
0
0.2
4
0
10
20
Anti-Reset Windup
Several solutions exist:
controllers on velocity form (not discussed here))
limit the setpoint variations (saturation never reached)
conditional integration (integration is switched off when the
control is far from the steady-state)
tracking (back-calculation)
Tracking
Tracking
y
KTds
Actuator
e = r y
K
Ti
1
s
es
1
Tt
y
KT d s
e = r y
Actuator
model
K
K
Ti
Actuator
1
s
1
Tt
+
es
Tracking
1
0.5
0
10
20
30
10
20
30
10
20
30
0.15
0.05
0.05
0
0.4
0.8
Discretization
P-part:
u P ( k) = K ( ysp( k) y( k))
Discretization
I-part:
K
I ( t) =
TI
t
0
K
dI
e( )d ,
=
e
dt
TI
Forward difference
I (t k+1 ) I (t k)
K
=
e(t k)
h
TI
Discretization
D-part (assume = 0):
sTD
D=K
( Y (s))
1 + sTD / N
TD dD
dy
+ D = K TD
N dt
dt
Discretization, cont.
D-part:
Backward difference
TD D (t k) D (t k1 )
+ D (t k)
N
h
y(t k) y(t k1 )
= K TD
h
TD
D (t k1 )
D (t k) =
TD + Nh
K TD N
( y(tk) y(tk1 ))
TD + Nh
Discretization
Tracking:
v := P + I + D;
u := sat(v,umax,umin);
I := I + (K*h/Ti)*e + (h/Tr)*(u - v);
PID code
PID-controller with anti-reset windup
y = yIn.get(); // A-D conversion
e = yref - y;
D = ad * D - bd * (y - yold);
v = K*(beta*yref - y) + I + D;
u = sat(v,umax,umin)}
uOut.put(u);
// D-A conversion
I = I + (K*h/Ti)*e + (h/Tr)*(u - v);
yold = y
Class SimplePID
public class SimplePID {
private double u,e,v,y;
private double K,Ti,Td,Beta,Tr,N,h;
private double ad,bd;
private double D,I,yOld;
public SimplePID(double nK, double nTi, double NTd,
double nBeta, double nTr, double nN, double nh) {
updateParameters(nK,nTi,nTd,nBeta,nTr,nN,nh);
}
public void updateParameters(double nK, double nTi, double NTd,
double nBeta, double nTr, double nN, double nh) {
K = nK; Ti = nTi; Td = nTd; Beta = nBeta;
Tr = nTr
N = nN;
h = nh;
ad = Td / (Td + N*h);
bd = K*ad*N;
}
Task Models
Further reading
B. Wittenmark, K. J. strm, K.-E. rzn: Computer Control:
An Overview. IFAC Professional Brief, 2002.
(Available at http://www.control.lth.se)
K. J. strm, B. Wittenmark: Computer-Controlled Systems,
Third Ed. Prentice Hall, 1997.
K. J. strm, Tore Hgglund: Advanced PID Control. The
Instrumentation, Systems, and Automation Society, 2005.