Sei sulla pagina 1di 79

EE480.

3 Digital Control Systems


Part 9. Frequency Response Method
- using the bilinear transformation
Kunio Takaya
Electrical and Computer Engineering
University of Saskatchewan
March 26, 2008
** Go to full-screen mode now by hitting CTRL-L
1
Contents
1 CONTROL SYSTEM DESIGN III 3
2 Routh-Hurwitz stability criterion 10
3 Phase Lead or Lag Compensator 17
4 DIGITAL CONTROLLER DESIGN 3 22
5 PID Controller Design 56
2
1 CONTROL SYSTEM DESIGN III
Bilinear Transformation
Consider integration based on trapezoidal rule.
y(k)
x(k)
x(k-1)
T
y(k-1)
Let the integrated area to k be y(k). Then, using the area to k 1
given by y(k 1), the approximated area under the curve is
y(k) = y(k 1) +
T
2
[x(k) +x(k 1)]
3
y(k) = y(k 1) +
T
2
[x(k) +x(k 1)]
Taking the z-transform,
Y (z) = z
1
Y (z) +
T
2
[X(z) +z
1
X(z)]
(1 z
1
)Y (z) =
T
2
(1 +z
1
)X(z)
Y (z)
X(z)
=
T
2
1 +z
1
1 z
1
We let integration in the Laplace transform
1
s
equal to the
integration in the z-domain.
1
s
=
T
2
1 +z
1
1 z
1
4
Then, we dene the bilinear transformation,
s =
2
T
1 z
1
1 +z
1
=
2
T
z 1
z + 1
.
Since this is a new mapping function between s-domain and
z-domain, we use w instead of s. The bilinear transformation
denes w-domain as
w =
2
T
1 z
1
1 +z
1
=
2
T
z 1
z + 1
,
w =
2
T
z 1
z + 1
z =
1 +
T
2
w
1
T
2
w
whereas the Laplace s-domain relates to the z-domian by
z = e
sT
Both mapping functions make the stable system poles be jzj < 1.
5
MATLAB function for the bilinear transformation is bilinear and
corresponding impulse invariant transformation is impinvar. The
following program shows the transformation applied to
G(s) =
2
(s + 1)(s + 2)
% s-domain: s=2/(s+1)(s+2)
z=[];
p=[-1,-2];
T=0.1;
K=2;
csys=tf(K*poly(z),poly(p))
[numd,dend]=bilinear(K*poly(z),poly(p),1/T)
roots(numd)
pbl=roots(dend)
plot(pbl,[0,0],rx); axis([-1,1,-1,1]); axis square; hold on;
[numd,dend]=impinvar(K*poly(z),poly(p),1/T)
roots(numd)
piv=roots(dend)
plot(piv,[0,0],bx); axis([-1,1,-1,1]); axis square; hold on;
6
The impulse invariant transformation is
G(z) = 0.0172
z
(z 0.9048)(z 0.8187)
The bilinear transformation is
G(z) = 0.0043
(z 1)
2
(z 0.9048)(z 0.8182)
The poles are very close to each other, though the zeros are
dissimilar.
Exercise: Transform the following continuous time system to
its Bilinear Transform. Sampling frequency is 10 samples per
sec, or T = 0.1.
E(s) =
1
s(s + 1)
7
Nonlinear frequency relationship
2
T
1 z
1
1 +z
1

z=e
jT
=
2
T
1 e
jT
1 +e
jT
=
2
T
e
j
T
2
(e
j
T
2
e
j
T
2
)
e
j
T
2
(e
j
T
2
+e
j
T
2
)
= j
2
T
tan
T
2
= j
w
Thus,
w
has a nonlinear relation ship with given by

w
=
2
T
tan
T
2
.
8
In the relationship between s-domain and z-domain, z = e
sT
,
analog frequency is dened by s = j whereas digital (discrete
time) frequency
d
is dened by e
j
d
= e
jT
. Therefore, =

d
T
.
9
frequency range in ,
d
and
w
= 0

s
2
=
2f
s
2
=

T

d
= 0
d
= T

w
= 0
w
=
T
2
tan
T
2

T
2
tan

2
=
This means that one zone of periodic frequency axis produced by
sampling,

T
in s-domain, corresponds to 0
w
< in the
frequency axis of w-plane. The frequency axis is the imaginary axis
j. Therefore, the inside of the unit circle in z-plane is mapped
into the entire LHP in the w-plane. Thus, we can see that the
Routh-Hurwitz stability criteion becomes applicable if bilinear
transformation is applied to a discrete time transfer function in
z-transform and converted to w-domain.
10
2 Routh-Hurwitz stability criterion
z(z-1)
z+1
K
+
-
Test the stability of this closed loop system. Determine the range of
K that keeps the system stable. The open loop transfer function is
G(z) = K
z + 1
z(z 1)
.
w =
2
T
z 1
z + 1
z =
1 +
T
2
w
1
T
2
w
G(w) = K
z + 1
z(z 1)

z=
1+
T
2
w
1
T
2
w
11
= K
1 +
T
2
w
1
T
2
w
+ 1
1 +
T
2
w
1
T
2
w
(
1 +
T
2
w
1
T
2
w
1)
= K
1
T
2
w
(1 +
T
2
w)
T
2
w
The characteristic equation is
1 +G(w) = 1 +K
1
T
2
w
(1 +
T
2
w)
T
2
w
= 0
(
T
2
)
2
w
2
+
T
2
(1 K)w +K = 0
12
w
2
w
1
w
0

(
T
2
)
2
K
T
2
(1 K) 0
K 0
Therefore, 0 < K < 1 is necessary for the system to be stable.
Routh Hurwitz stability criterion
When the characteristic equation is given by
b
n
w
n
+b
n1
w
n1
+ +b
1
w +b
0
= 0
13
w
n
w
n1
w
n2
w
n3
.
.
.

b
n
b
n2
b
n4

b
n1
b
n3
b
n5

c
1
c
2
c
3
d
1
d
2
d
3
.
.
.
.
.
.
.
.
.
c
1
=
b
n1
b
n2
b
n
b
n3
b
n1
c
2
=
b
n1
b
n4
b
n
b
n5
b
n1
d
1
=
c
1
b
n3
c
2
b
n1
c
1
d
2
=
c
1
b
n5
c
3
b
n1
c
1
The number of sign changes in the rst column gives the number of
unstable poles.
14
Example
An open loop transfer function
G(z) = K
z + 1
(z 1)
2
yields
G(w) = K
2 Tw
(Tw)
2
The characteristic equation is
T
2
w
2
KTw + 2K = 0.
w
2
w
1
w
0

T
2
2K
KT 0
2K 0
15
Since the number of sign changes is 2, this system is always
unstable regardless of the value of K. This system is the same as
analog system,
1
s
2
. So, the unity gain feedback always results in
instability.
16
3 Phase Lead or Lag Compensator
A discrete time phase lead/lag compensator is designed by using
the bilinear transformation that maps the inside of the unit circle
in z-plane to the entire LHP of w-plane. The phase lead/lag
compensator is designed in w-domain utilizing the techniques
available for continuous time compensator design, then map it back
to the z-domain by the bilinear transformation.
The rst order w-domain compensator is given by analogy to
s-domain as
D(w) = a
0
1 +
w

w
0
1 +
w

w
p
17
A pole is at w =
w
p
and a zero is at w =
w
0
.
18
Phase lead compensator:
w
p
>
w
0
Phase lag compensator:
w
0
>
w
p
19
Substituting w =
2
T
z 1
z + 1
for w in the compensator transfer
function,
D(z) = a
0
1 +
2
T
z 1
z + 1

w
0
1 +
2
T
z 1
z + 1

w
p
= a
0

w
0

w
p
+
w
p
2
T
z 1
z + 1

w
0

w
p
+
w
0
2
T
z 1
z + 1
= a
0

w
0

w
p
T(z + 1) + 2
w
p
(z 1)

w
0

w
p
T(z + 1) + 2
w
0
(z 1)
20
= a
0

w
p
(
w
0
T + 2)

w
0
(
w
p
T + 2)

z +

w
0
T 2

w
0
T + 2
z +

w
p
T 2

w
p
T + 2
= K
d
z z
0
z z
p
Thus,
K
d
= a
0

w
p
(
w
0
T + 2)

w
0
(
w
p
T + 2)
= a
0

w
p
(
w
0
+
2
T
)

w
0
(
w
p
+
2
T
)
z
0
=

w
0
T 2

w
0
T + 2
=

w
0

2
T

w
0
+
2
T
z
p
=

w
p
T 2

w
p
T + 2
=

w
p

2
T

w
p
+
2
T
21
4 DIGITAL CONTROLLER DESIGN 3
Frequency Response Method
G(s)
ZOH K
z - z
z - z
p
0
T
+
-
d
Design a phase lead or phase lag compensator
D(z) = K
d
z z
0
z z
p
such that the (open loop) system satises a given phase margin of

m
100 so that the (closed loop) system has damping ratio of .
22
Since the frequency response method based on phase margin and
gain margin established in the Laplace domain (s-domain) is used
here, the frequency response of D(z) combined with a plant
transfer function G(z) with ZOH must be transformed into
w-domain by using the bilinear transformation. Because, the stable
region of the z-plane that is the inside of a unit circle, is mapped
into the entire LHP (Left Half Plane) of the w-plane.
The parameters K
d
, z
0
and z
p
of the rst order phase lead/lag
compensator are determined in terms of a
0
,
w
0
,
w
p
dened in the
w-domain.
23
Calculations of Frequency Response in
w-domain
In order to obtain frequency response (Bode plot) in w-domain, do
the following steps.
1. Find the transfer function in the z-transform,
G(z) = (1 z
1
)Z

G(s)
s

2. Calculate the frequency response G(e


jT
) for 0 T with
a proper step size. Record the actual frequncy scale of
0
s
=

T
3. Calculate corresponding frequency
w
to the frequencies used
to calculate G(e
jT
).

w
=
2
T
tan
T
2
24
4. Make a frequency response table to help drawing the Bode
diagram.
jG(e
jT
)j

G(e
jT
)
w


.
.
.
.
.
.
.
.
.
.
.
.
5. Draw the Bode Diagram, both for jG(e
jT
)j and

G(e
jT
)
using the frequency scale of
w
, not . This process is often
called as frequency pre-warping.
25
Design Approach
Digital controller design to determine D(z) by the frequency
response method uses phase margin
m
as a key parameter.
Design is to make the phase margin of the open loop trnasfer
function D(w)G(w) have a specied phase margin
m
at a
frequency
w
1
.
26
Finding the new cross-over frequency
w
1
requires several
conditions to be met, and also requires try and error until a
satisfactory value is found.
We are designing (determining)
D(w) = a
0
1 +
w

w
0
1 +
w

w
p
where, a pole is at w =
w
p
and a zero is at w =
w
0
.
27
Characteristic Equation of the Closed Loop
Systems
The only mathematical condition required at
w
1
is
D(j
w
1
)G(j
w
1
) = 1

(180

+
m
) = 1

(+180

+
m
)
For magnitude,
jD(j
w
1
)j jG(j
w
1
)j = 1 jD(j
w
1
)j =
1
jG(j
w
1
)j
For phase,

D(j
w
1
) +

G(j
w
1
) = 180

+
m
=

D(j
w
1
) = 180

+
m

G(j
w
1
)
28
Mathematical Design Formula for Phase
Lead/Lag Compesators
The phase margin of the open loop trnasfer function D(w)G(w)
satises a specied phase margin
m
at a frequency
w
1
, if the
parameters a
1
and b
1
of
D(w) =
a
1
w +a
0
b
1
w + 1
= a
0
1 +
a
1
a
0
w
1 +b
1
w
= a
0
1 +
w

w
0
1 +
w

w
p
where, w

0
=
a
0
a
1
and w

p
=
1
b
1
are set to satisfy
29
a
1
=
1 a
0
jG(j
w
1
)j cos

w
1
jG(j
w
1
)j sin
b
1
=
cos a
0
jG(j
w
1
)j

w
1
sin
where, =

D(j
w
1
) = 180

+
m

G(j
w
1
). The DC gain a
0
must be known from other criteria such as steady state error e
ss
or
DC gain.
30
Verication (check)
D(j
w
1
) =
ja
1

w
1
+a
0
jb
1

w
1
+ 1
=
j
1 a
0
jG(j
w
1
)j cos

w
1
jG(j
w
1
)j sin

w
1
+a
0
j
cos a
0
jG(j
w
1
)j

w
1
sin

w
1
+ 1
=
1
jG(j
w
1
)j

j(1 a
0
jGj cos ) +a
0
jGj sin
j(cos a
0
jGj) + sin
Thus,
D(j
w
1
)
2
=
1
jGj
2
(1 a
0
jGj cos )
2
+ (a
0
jGj sin)
2
(cos a
0
jGj)
2
+ sin
2

=
1
jGj
2
1 2a
0
jGj cos +a
2
0
jGj
2
1 2a
0
jGj cos +a
2
0
jGj
2
=
1
jGj
2
31
For phase angle,

D(j
w
1
) =

1 +j
a
1
a
0

w
1
1 +jb
1
j
w
1
= tan
1
a
1
a
0

w
1
tan
1
b
1

w
1
tan

D(j
w
1
) =
tantan
1
a
1
a
0

w
1
tantan
1
b
1

w
1
1 + tantan
1
a
1
a
0

w
1
tantan
1
b
1

w
1
=
a
1
a
0

w
1
b
1

w
1
1 +
a
1
a
0

w
1
b
1

w
1
32
Substituting,
a
1

w
1
=
1 a
0
jGj cos
jGj sin
and b
1

w
1
=
cos a
0
jGj
sin
tan

D(j
w
1
) =
sin(1 2a
0
jGj cos +a
2
0
jGj
2
)
cos (1 2a
0
jGj cos +a
2
0
jGj
2
)
= tan
Thus, the compensator D(j
w
1
) satises
jD(j
w
1
)j =
1
jG(j
w
1
)j
and

D(j
w
1
) =
33
Range to choose
w
1
for Phase-Lead Case
This formula based method is straightforward and works well as
long as the choice of
w
1
is proper. The range of frequency
w
from which
w
1
should be chosen is specied by the following
conditions for phase lead compensators.
1. =

D(j
w
1
) = 180

+
m

G(j
w
1
) > 0 requires to
choose
w
1
to satisfy a phase condition

G(j
w
1
) < 180

+
m
.
2. Since jD(j
w
)j > a
0
, jD(j
w
1
)j > a
0
. Then,
w
1
should satisfy
a gain condition,
jG(j
w
1
)j =
1
jD(j
w
1
)j
<
1
a
0
3. In the transfer function D(w), a
0
, a
1
and b
1
must be all
34
positive as
w
0
=
a
0
a
1
and
w
p
=
1
b
1
. sin > 0 for phase lead
compensators.
Referring to
a
1

w
1
=
1 a
0
jGj cos
jGj sin
and b
1

w
1
=
cos a
0
jGj
sin
.
the numerators must be positive as well.
1 a
0
jGj cos > 0 and cos a
0
jGj > 0
1
a
0
jG(j
w
1
)j
> cos > a
0
jG(j
w
1
)j
This condition is written for jG(j
w
1
)j as
jG(j
w
1
)j <
cos
a
0
<
1
a
0
cos
35
Thus,
jG(j
w
1
)j <
cos
a
0
,
which is more restrictive than the condition derived from the
gain, jG(j
w
1
)j <
1
a
0
.
36
Range to choose
w
1
for Phase-Lag Case
The range of frequency
w
from which
w
1
should be chosen is
specied by the following conditions for phase lag compensators.
1. =

D(j
w
1
) = 180

+
m

G(j
w
1
) < 0 requires to
choose
w
1
to satisfy a phase condition

G(j
w
1
) > 180

+
m
.
2. Since jD(j
w
)j < a
0
, jD(j
w
1
)j < a
0
. Then,
w
1
should satisfy
a gain condition,
jG(j
w
1
)j =
1
jD(j
w
1
)j
>
1
a
0
3. In the transfer function D(w), a
0
, a
1
and b
1
must be all
positive as
w
0
=
a
0
a
1
and
w
p
=
1
b
1
. sin < 0 for phase lag
37
compensators.
Referring to
a
1

w
1
=
1 a
0
jGj cos
jGj sin
and b
1

w
1
=
cos a
0
jGj
sin
.
the numerators must be negative as well.
1 a
0
jGj cos < 0 and cos a
0
jGj < 0
1
a
0
jG(j
w
1
)j
< cos < a
0
jG(j
w
1
)j
This condition yields,
jG(j
w
1
)j >
1
a
0
cos
>
cos
a
0
Thus,
jG(j
w
1
)j >
1
a
0
cos
.
38
This is more restrictive than jG(j
w
1
)j >
1
a
0
.
39
Design specic to Phase lag Compensator
The rst order phase lag compensator can be designed by the
formula similarly as in the case of phase lead compensator.
However, there is a basic dierence in the principle of
compensating for a required phase margin.
Phase lead compensators add a positive phase to increase the
phase margin without drastically changing the 0 dB crossover
frequency.
A phase lag compensators is used to lower the overall gain to
shift the 0 dB crossover frequency to a much smaller value so
that a larger phase margin is obtained.
Since the 0 dB crossover frequency
w
1
is shifted to a lower
frequency where the phase response of the Bode diagram is not
aected by the compensator, selecting
w
1
can be done on the Bode
40
diagram of G(w) alone without being aected by the compensator.
First, nd a new crossover frequency
w
1
where the condition,

G(j
w
1
) = 180

+
m
+ 5

is satised. 5

accounts for a slight phase angle derease by the


phase lag compensator. The rule of thumb to set
w
0
in the
compensators transfer function,
D(w) = a
0
1 +
w

w
0
1 +
w

w
p
=
a
1
w +a
0
b
1
w + 1
is to pick one decade lower than the
w
1
, i.e.

w
0
= 0.1
w
1
.
41
For a phase lag compensator,
w
p
<
w
0
.
jD(
w
1
)j = a
0

1 +j

w
1

w
0
1 +j

w
1

w
p

a
0

w
p

w
0
=
1
G(j
w
1
)
Thus,

w
p
=

w
0
a
0
jG(j
w
1
)j
=
0.1
w
1
a
0
jG(j
w
1
)j
42
Example 8.1 page 294
The servo motor is to control the horizontal (azimuth) angle for
pointing a radar antenna. The transfer function is given by
G(s) =
1
s(s + 1)(0.5s + 1)
The z-transform of this system combined with ZOH is
G(z) = 4.0140 10
5
(z + 3.5954)(z + 0.2580)
(z 1)(z 0.9512)(z 0.9048)
.
The Bode diagram drawn for w-domain with respect to the
frequency axis of
w
is shown.
43
10
1
10
0
10
1
60
40
20
0
20
Magnitude Response
frequency in rad/s
M
a
g
n
i
t
u
d
e

i
n

d
B
10
1
10
0
10
1
300
250
200
150
100
50
Phase Response
frequency in rad/s
P
h
a
s
e

i
n

d
e
g
r
e
e
s
44
Design a phase lag compensator that achieves a phase margin of

m
= 55

for a
0
= 1.

G(j
w
1
) = 180

+ 55

+ 5

= 120

By the Bode diagram,


w
1
0.36. At this frequency
jG(j
w
1
)j = 2.57 = 8.2dB. Therefore,

w
0
= 0.1
w
1
= 0.036

w
p
=
0.1
w
1
a
0
jG(j
w
1
)j
= 0.0140
Using these values of a
0
,
w
0
and
w
p
,
D(z) = 0.3891
z 0.9982
z 0.9993
.
The frequency response after compensation is shown in the
frequency axis of
w
.
45
10
1
10
0
10
1
80
60
40
20
0
20
Magnitude Response
frequency in rad/s
M
a
g
n
i
t
u
d
e

i
n

d
B
10
1
10
0
10
1
300
250
200
150
100
50
Phase Response
frequency in rad/s
P
h
a
s
e

i
n

d
e
g
r
e
e
s
46
Example 8.2 page 302 Phase lead compensator
design
The servo motor is to control the horizontal (azimuth) angle for
pointing a radar antenna. (same system as Example 8.1) The
transfer function is given by
G(s) =
1
s(s + 1)(0.5s + 1)
Try a phase lead compensator that satises the phase margin of

m
= 55

. We keep a
0
= 1 as the previous phase lag case. We need
to select a
w
1
to use the formula that determine the compensator
coecients a
1
and b
1
. Refer to the three conditions.

G(j
w
1
) < 180

+
m
.
jG(j
w
1
)j =
1
D(j
w
1
)
<
1
a
0
47
jG(j
w
1
)j <
cos
a
0
,
where, =

D(j
w
1
) = 180

+
m

G(j
w
1
) > 0.
The range that the rst condition

G(j
w
1
) < 180

+
m
= 125

,
w
1
> 0.45 according to the
Bode diagram (phase).
The second condition jG(j
w
1
)j <
1
a
0
requres
w
1
> 0.75 from
the Bode diagram (gain). So, try
w
1
> 1.2 to see if the third
condition is satised. = 180

+
m

G(j
w
1
) > 0.

G(j
w
1
) = 172.8

. Therefore,
= 180

+ 55 (172.8) = 47.8

.
cos = 0.6709 and a
0
jG(j
w
1
)j = 0.4576. Thus, the third
condition is met.
Therefore, the choice of
w
1
1.2 is acceptable for the use of the
48
formula. i.e.
w
1
= 1.2 Using the formula,
a
1
=
1 a
0
jGj cos

w
1
jGj sin
and b
1
=
cos a
0
jGj

w
1
sin
We nd,
a
1
= 1.7016 and b
1
= 0.2397
The parameters of the discrete time domain transfer function of the
compensator
D(z) = K
d
z z
0
z z
p
are
K
d
= a
0

w
p
(
w
0
T + 2)

w
0
(
w
p
T + 2)
= a
0

w
p
(
w
0
+
2
T
)

w
0
(
w
p
+
2
T
)
= 6.5230
z
0
=

w
0
T 2

w
0
T + 2
=

w
0

2
T

w
0
+
2
T
= 0.9710
49
z
p
=

w
p
T 2

w
p
T + 2
=

w
p

2
T

w
p
+
2
T
= 0.8111
The frequency response of D(j
w
)G(j
w
) in the w-domain is
shown below. This shows that the phase margin was increased.
The graph shows increased gain in a high frequency range caused
by the phase lead compensator.
50
10
1
10
0
10
1
60
40
20
0
20
40
Magnitude Response
frequency in rad/s
M
a
g
n
i
t
u
d
e

i
n

d
B
10
1
10
0
10
1
300
250
200
150
100
50
Phase Response
frequency in rad/s
P
h
a
s
e

i
n

d
e
g
r
e
e
s
51
Matlab program to assist phase lead compensator design.
%
% Example 8.1 page 294
% G(s)=1/s(s+1)(0.5s+1)=2/s(s+1)(s+2)
%
%
num=2;
den=poly([0,-1,-2]);
sys=tf(num,den);
w=logspace(-1,1,100);
jw=j*w;
H=polyval(num,jw)./polyval(den,jw);
mag=20*log10(abs(H));
radians=angle(H);
phase=unwrap(radians)*180/pi;
subplot(211),semilogx(w,mag,b),grid
title(Magnitude Response Analog);
xlabel(frequency in rad/s),ylabel(Magnitude in dB);
subplot(212),semilogx(w,phase,b),grid
title(Phase Response Analog);
xlabel(frequency in rad/s),ylabel(Phase in degrees);
figure(2);
T=0.05;
52
zeroG=[];
poleG=[0, -1, -2];
gainG=2;
[zdG, pdG, kdG]=c2dzp(zeroG, poleG, gainG, T);
numdG=poly(zdG)*kdG;
dendG=poly(pdG);
[numW, denW]=z2w(numdG,dendG,T);
w=logspace(-1,1,100);
jw=j*w;
H=polyval(numW,jw)./polyval(denW,jw);
mag=20*log10(abs(H));
radians=angle(H);
phase=unwrap(radians)*180/pi;
subplot(211),semilogx(w,mag,b),grid
title(Magnitude Response);
xlabel(frequency in rad/s),ylabel(Magnitude in dB);
subplot(212),semilogx(w,phase,b),grid
title(Phase Response);
xlabel(frequency in rad/s),ylabel(Phase in degrees);
%bode(kdG*numW, denW, W);
print -dps exmpL8_1.ps
% Phase lead compensator design a1*w +a0 / b1 w + 1 = a0 (w/(a0/a1) + 1)/(w/(1/b1)+1)
Ww=input(Select Omega_w_1=);
53
Phmar=input(Specify Phase margin(+ in degrees)=);
a0=input(compensator DC gain a0=)
[G,GdB,Ph]=Gpha(numW,denW,Ww)
theta=-180+Phmar-Ph
theta=theta*pi/180;
a1=(1-a0*G*cos(theta))/(Ww*G*sin(theta))
b1=(cos(theta)-a0*G)/(Ww*sin(theta))
% check
disp(angle G(j omega_w_1) < -180 + Phmar);
Ph
-180+Phmar
disp(gain G(j omega_w_1) < 1/a0);
G
1/a0
disp(cos theta > a0 * gain G(j omega_w_1));
cos(theta)
a0*G
pause;
figure(3);
sysW=tf(numW,denW);
w0=a0/a1;
wp=1/b1;
cmsW=tf(a1*[1, w0], b1*[1, wp]);
54
%cmsW=tf(0.014*[1,0.036],0.036*[1,0.014])
ttlW=sysW*cmsW;
ttWmin=minreal(ttlW);
[numW,denW]=tfdata(ttWmin,v);
[G,GdB,Ph]=Gpha(numW,denW,Ww);
w=logspace(-1,1,100);
jw=j*w;
H=polyval(numW,jw)./polyval(denW,jw);
mag2=20*log10(abs(H));
radians=angle(H);
phase2=unwrap(radians)*180/pi;
subplot(211),semilogx(w,mag,k--,w,mag2,b),grid
title(Magnitude Response);
xlabel(frequency in rad/s),ylabel(Magnitude in dB);
subplot(212),semilogx(w,phase,k--,w,phase2,b),grid
title(Phase Response);
xlabel(frequency in rad/s),ylabel(Phase in degrees);
print -dps exmpL8_1c.ps
disp(discrete time, z-domain compensator Kd(z-z0)/(z-zp));
Kd=a0*(wp*(w0+2/T))/(w0*(wp+2/T))
z0=(2/T-w0)/(2/T+w0)
zp=(2/T-wp)/(2/T+wp)
55
5 PID Controller Design
A digital PID (Proportional, Integral and Dierential) controller is
given by
D(z) = K
P
+K
I
T
2
z + 1
z 1
+K
D
1
T
(1 z
1
),
whereas an analog PID controller is
D(w) = K
P
+K
I
1
w
+K
D
w
=
K
D
w
2
+K
P
w +K
I
w
= K
I
(1 +
w
w

1
)(1 +
w
w

2
)
w
From the last expression, we can obtain the frequency response
(Bode diagram) of D(w).
56
PID contoller is widely used as a compensator to stabilize
closed-loop systems by adjusting the phase margin and gain
margin. Here, we try to primarily adjust the phase margin to a
desired value. Since
w
=
2
T
tan
T
2
, due to the term K
D
w,
jD(j
w
)j when, T .
57
We do not use w =
2
T
z 1
z + 1
for D-action. Instead we use
1
T
(1 z
1
) =
z 1
Tz
.
z 1
Tz

z=
1+
T
2
w
1
T
2
w
=
w
1 +
T
2
w
=
w
1 +
w
(
2
T
)
=
w
1 +
w
(

)
Therefore, the corner frequency at

w
=

s

<

s
2
prevents the gain of D-action from going to . In another word,
the pole at z = 1 is unstable but not the pole at z = 0. We use
the following D(w) for the purpose of PID controller design with
58
an assumption that the actual frequency

s

<

s
2
.
D(w) = K
P
+K
I
1
w
+K
D
w.
D(j
w
) = K
P
jK
I
1

w
+jK
D

w
= K
P
+j

K
D

w
K
I
1

= jD(j
w
)j

jD(j
w
)j =

K
2
P
+ (K
D

w
K
I
1

w
)
2
= tan
1
K
D

w
K
I
1

w
K
P
59
PID controller design
Determine K
P
, K
I
and K
D
such that the phase margin is
m
at a
cross-over frequency
w
1
. This requirement is
D(j
w
1
)G(j
w
1
) = 1

180

+
m
For gain,
jD(j
w
1
)j =
1
jG(j
w
1
)j
For phase,

D(j
w
1
) +

G(j
w
1
) = 180

+
m

D(j
w
1
) = 180

+
m

G(j
w
1
).
Since
K
P
+j

K
D

w
1
K
I
1

w
1

= jD(j
w
1
)je
j
60
= jD(j
w
1
)j (cos +j sin)
=
1
jG(j
w
1
)j
(cos +j sin)
K
P
=
1
jG(j
w
1
)j
cos
K
D

w
1
K
I
1

w
1
=
1
jG(j
w
1
)j
sin
phase lag: < 0 sin < 0 K
D

w
1
< K
I
1

w
1
phase lead: > 0 sin > 0 K
D

w
1
> K
I
1

w
1
Increasing K
D
increases bandwidth. Increasing K
I
decreases
steady state error e
ss
provided that the system retains an
acceptable gain margin. If the above two conditions are staised,
varying K
I
and K
D
will change the gain margin, while the phase
61
margin remains unchanged. From the relationship,

D(j
w
1
) = 180

+
m

G(j
w
1
) =
the cross-over frequency
w
1
must be chosen depending on whether
the PID controller should be of leading phase or lagging phase.

w
1
should be chosen where

G(j
w
1
) < 180

+
m
, if
leading phase (more D-action than I-action).

w
1
should be chosen where

G(j
w
1
) > 180

+
m
, if
lagging phase (more I-action than D-action).
62
PI and PD Controller
Referring to the Bode diagram of PID controller, PID controller
increases its gain both at low frequecy and at high frequency. A
large gain at low frequency decreases steady state error, e
ss
. A
large gain at high frequency may shift the cross-over frequency to a
higher frequency causing the decrease of phase margin, but it adds
63
a leading phase up to 90

. A larger gain at high frequency makes


the bandwidth wider.
The previously described design method for PID controller does
not give a unique solution for K
I
and K
D
. The PI or PD controller
drops D-action or I-action, respectively. In the case where both
D-action and I action need not to be present, one can use PI or PD
controller for which the solution for K
I
or K
D
becomes uniquely
determinable. In PID case,
K
P
+j

K
D

w
1
K
I
1

w
1

=
1
jG(j
w
1
)j
(cos +j sin)
PI controller, < 0
K
P
jK
I
1

w
1
=
1
jG(j
w
1
)j
(cos +j sin)
64
K
P
=
1
jG(j
w
1
)j
cos
K
I
=
w
1
1
jG(j
w
1
)j
sin
65
PD controller, > 0
K
P
+jK
D

w
1
=
1
jG(j
w
1
)j
(cos +j sin)
K
P
=
1
jG(j
w
1
)j
cos
K
D
=
1

w
1
jG(j
w
1
)j
sin
Exact Solutions
The digital PID controller
D(z) = K
P
+K
I
T
2
z + 1
z 1
+K
D
1
T
(1 z
1
),
is mapped to w-domain exactly as
D(w) = K
P
+K
I
1
w
+K
D
w
1 +
T
2
w
66
The solutions derived from
D(w) = K
P
+K
I
1
w
+K
D
w
provided for the actual frequency to be

s

<

s
2
are
approximations. The frequency response is
D(j
w
) = K
P
jK
I
1

w
+K
D
j
w
1 +
T
2
j
w
At the cross-over frequency
w
1
,
D(j
w
1
) = K
P
jK
I
1

w
1
+K
D
j
w
1
1 +
T
2
j
w
1
=
1
jG(j
w
1
)j
(cos +j sin)
67
The real part gives
K
P
+
K
D

2
w
1
(
2
T
)
(
2
T
)
2
+
2
w
1
=
cos
jG(j
w
1
)j
The imaginary part gives
K
D

2
w
1
(
2
T
)
(
2
T
)
2
+
2
w
1

K
I

w
1
=
sin
jG(j
w
1
)j
For PI controller with K
D
= 0, the equations for K
P
and K
I
remain the same as the approximated solutions. However, PD
controller gains K
D
and K
P
are given as follows.
K
D
=
sin
jG(j
w
1
)j

(
2
T
)
2
+
2
w
1
(
2
T
)
2

w
1

68
K
P
=
cos
jG(j
w
1
)j

K
D

2
w
1
(
2
T
)
(
2
T
)
2
+
2
w
1
69
PI controller for the servo-motor for a radar
antenna
For the same system of
G(s) =
1
s(s + 1)(0.5s + 1)
,
design a PI controller to have phase margin of 55

at
w
1
= 0.4.
Using the design program below, K
p
= 0.4392 and K
i
= 0.0040
were found.
70
10
1
10
0
10
1
80
60
40
20
0
20
Magnitude Response
frequency in rad/s
M
a
g
n
i
t
u
d
e

i
n

d
B
10
1
10
0
10
1
300
250
200
150
100
50
Phase Response
frequency in rad/s
P
h
a
s
e

i
n

d
e
g
r
e
e
s
71
%
% Example 8.4 and 8.5 page 317 and 318
% G(s)=1/s(s+1)(0.5s+1)=2/s(s+1)(s+2)
%
num=2;
den=poly([0,-1,-2]);
sys=tf(num,den);
%------------------
dSys=c2d(sys,0.05,zoh);
[dSyszeros,dSyspoles,Ksys,ts]=zpkdata(dSys,v);
zeros=[dSyszeros];
poles=[dSyspoles];
num=poly(zeros);
den=poly(poles);
%------------------
w=logspace(-1,1,100);
jw=j*w;
H=polyval(num,jw)./polyval(den,jw);
mag=20*log10(abs(H));
radians=angle(H);
phase=unwrap(radians)*180/pi;
subplot(211),semilogx(w,mag,b),grid
title(Magnitude Response);
xlabel(frequency in rad/s),ylabel(Magnitude in dB);
72
subplot(212),semilogx(w,phase,b),grid
title(Phase Response);
xlabel(frequency in rad/s),ylabel(Phase in degrees);
figure(2);
T=0.05;
zeroG=[];
poleG=[0, -1, -2];
gainG=2;
[zdG, pdG, kdG]=c2dzp(zeroG, poleG, gainG, T);
numdG=poly(zdG)*kdG;
dendG=poly(pdG);
[numW, denW]=z2w(numdG,dendG,T);
w=logspace(-1,1,100);
jw=j*w;
H=polyval(numW,jw)./polyval(denW,jw);
mag=20*log10(abs(H));
radians=angle(H);
phase=unwrap(radians)*180/pi;
subplot(211),semilogx(w,mag,b),grid
title(Magnitude Response);
xlabel(frequency in rad/s),ylabel(Magnitude in dB);
subplot(212),semilogx(w,phase,b),grid
title(Phase Response);
73
xlabel(frequency in rad/s),ylabel(Phase in degrees);
print -dps exmpL8_5.ps
% PID controller design D(w)=Kp + Ki/w + Kd*w
Ww=input(Select Omega_w_1=);
Phmar=input(Specify Phase margin(+ in degrees)=);
[G,GdB,Ph]=Gpha(numW,denW,Ww)
theta=-180+Phmar-Ph
theta=theta*pi/180;
if theta>0
disp(D action > I action);
else
disp(I action > D action);
end
Kp=cos(theta)/G
type=input(Which do you specify, Ki or Kd? ,s);
notOK=1;
while(notOK)
if (type==Ki | type==ki)
Ki=input(Enter value of Ki =);
notOK=0;
Kd=(sin(theta)/G+Ki/Ww)/Ww
else if (type==Kd | type==kd)
Kd=input(Enter value of Kd =);
74
notOK=0;
Ki=(Kd*Ww-sin(theta)/G)*Ww
end
end
end
figure(3);
sysW=tf(numW,denW);
pidW=tf([Kd,Kp,Ki],[0,1,0])
ttlW=sysW*pidW;
ttWmin=minreal(ttlW);
[numW,denW]=tfdata(ttWmin,v);
w=logspace(-1,1,100);
jw=j*w;
H=polyval(numW,jw)./polyval(denW,jw);
mag2=20*log10(abs(H));
radians=angle(H);
phase2=unwrap(radians)*180/pi;
subplot(211),semilogx(w,mag,k--,w,mag2,b),grid
title(Magnitude Response);
xlabel(frequency in rad/s),ylabel(Magnitude in dB);
subplot(212),semilogx(w,phase,k--,w,phase2,b),grid
title(Phase Response);
75
xlabel(frequency in rad/s),ylabel(Phase in degrees);
print -dps exmpL8_5c.ps
76
PID controller for the servo-motor for a radar
antenna
For the same system of
G(s) =
1
s(s + 1)(0.5s + 1)
,
design a PID controller to have phase margin of 55

at
w
1
= 1.2.
Specifying K
i
= 0.004 in the PID design program, K
p
= 1.4661 and
K
d
= 1.3530 were found.
77
10
1
10
0
10
1
60
40
20
0
20
40
Magnitude Response
frequency in rad/s
M
a
g
n
i
t
u
d
e

i
n

d
B
10
1
10
0
10
1
300
250
200
150
100
50
Phase Response
frequency in rad/s
P
h
a
s
e

i
n

d
e
g
r
e
e
s
78
Assignment No. 6
Work on a series of questions related to the same system in Figure
P8-2 (page 329).
1. 8-2 textbook page 328
2. 8-3 textbook page 329
3. 8-10 textbook page 330
4. 8-11 textbook page 330
79

Potrebbero piacerti anche