using the bilinear transformation. Kunio Takaya. Electrical and Computer
Engineering. University of Saskatchewan. March 26, 2008. ** Go to full-screen
mode ...
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) y(k-1)
x(k) x(k-1) T
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 [x(k) + x(k − 1)] 2 3
T y(k) = y(k − 1) + [x(k) + x(k − 1)] 2 Taking the z-transform, Y (z) (1 − z
−1
z −1 Y (z) +
=
)Y (z)
=
Y (z) X(z)
=
T [X(z) + z −1 X(z)] 2
T (1 + z −1 )X(z) 2 T 1 + z −1 2 1 − z −1
We let integration in the Laplace transform integration in the z-domain. 1 T 1 + z −1 = s 2 1 − z −1
4
1 equal to the s
Then, we define the bilinear transformation, 2 z−1 2 1 − z −1 = s= . −1 T 1+z T z+1 Since this is a new mapping function between s-domain and z-domain, we use w instead of s. The bilinear transformation defines w-domain as 2 z−1 2 1 − z −1 = w= , −1 T 1+z T z+1 2 z−1 w= T z+1
⇔
1+ z= 1−
T 2w T 2w
whereas the Laplace s-domain relates to the z-domian by z = esT 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 2 G(s) = (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 z G(z) = 0.0172 (z − 0.9048)(z − 0.8187) The bilinear transformation is (z − 1)2 G(z) = 0.0043 (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. 1 E(s) = s(s + 1)
7
Nonlinear frequency relationship −1
2 1−z T 1 + z −1 z=ejωT
=
2 1 − e−jωT T 1 + e−jωT ωT
ωT
ωT
2 e−j 2 (ej 2 − e−j 2 ) = ωT ωT T e−j ωT 2 (ej 2 + e−j 2 ) 2 ωT = j 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 = esT , analog frequency is defined by s = jω whereas digital (discrete ωd jωd jωT time) frequency ωd is defined by e =e . Therefore, ω = . T
9
frequency range in ω, ωd and ωw ω ωd ωw
ωs 2πfs π = = 2 2 T =⇒ 0 ≤ ωd = ωT ≤ π T ωT T π =⇒ 0 ≤ ωw = tan ≤ tan = ∞ 2 2 2 2
=⇒
0≤ω≤
This means that one zone of periodic frequency axis produced by π sampling, ± in s-domain, corresponds to 0 ≤ ωw < ∞ in the T 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 K +
-
z+1 z(z-1)
Test the stability of this closed loop system. Determine the range of K that keeps the system stable. The open loop transfer function is z+1 G(z) = K . z(z − 1) 1 + T2 w ⇔ z= 1 − T2 w z + 1 K z(z − 1) 1+ T2 w
2 z−1 w= T z+1 G(w)
=
z=
11
1− T w 2
=
=
1 + T2 w +1 T 1− 2w K 1 + T2 w 1 + T2 w ( − 1) T T 1− 2w 1− 2w T 1− w 2 K T T (1 + w) w 2 2
The characteristic equation is T w 2 1 + G(w) = 1 + K =0 T T (1 + w) w 2 2 1−
T T ( )2 w2 + (1 − K)w + K = 0 2 2 12
w ( T2 )2 1 T w 2 (1 − K) 0 w K 2
K 0 0
Therefore, 0 < K < 1 is necessary for the system to be stable.
Routh Hurwitz stability criterion When the characteristic equation is given by bn wn + bn−1 wn−1 + · · · + b1 w + b0 = 0
13
wn wn−1 wn−2 wn−3 .. .
bn
bn−2
bn−4 · · ·
bn−1
bn−3
bn−5 · · ·
c1
c2
c3
d1 .. .
d2 .. .
d3 .. .
bn−1 bn−4 − bn bn−5 bn−1 c1 bn−5 − c3 bn−1 d2 = c1
bn−1 bn−2 − bn bn−3 bn−1 c1 bn−3 − c2 bn−1 d1 = c1
c2 =
c1 =
The number of sign changes in the first column gives the number of unstable poles.
14
Example An open loop transfer function z+1 G(z) = K (z − 1)2 yields G(w) = K
2 − Tw (T w)2
The characteristic equation is T 2 w2 − KT w + 2K = 0. 2K w2 T 2 1 w −KT 0 0 w 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 1 analog system, 2 . So, the unity gain feedback always results in s 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 first order w-domain compensator is given by analogy to s-domain as w 1+ ωw0 D(w) = a0 w 1+ ωwp
17
A pole is at w = −ωwp and a zero is at w = −ωw0 .
18
• Phase lead compensator: ωwp > ωw0 • Phase lag compensator: ωw0 > ωwp 19
Substituting w =
2 z−1 for w in the compensator transfer T z+1
function, z−1 1+ z+1 ωw0 a0 2 z−1 T z+1 1+ ωwp 2 T
D(z) =
=
=
2 z−1 ωw0 ωwp + ωwp T z+1 a0 2 z−1 ωw0 ωwp + ωw0 T z+1 ωw0 ωwp T (z + 1) + 2ωwp (z − 1) a0 ωw0 ωwp T (z + 1) + 2ωw0 (z − 1)
20
ωw0 T ωwp (ωw0 T + 2) ωw0 T = a0 × ωwp T ωw0 (ωwp T + 2) z+ ωwp T z − z0 = Kd z − zp z+
−2 +2 −2 +2
Thus, Kd
z0
zp
ωwp (ωw0 T + 2) ωwp (ωw0 + = a0 = a0 ωw0 (ωwp T + 2) ωw0 (ωwp + 2 ω − w0 ωw0 T − 2 T = − =− 2 ωw0 T + 2 ωw0 + T 2 ωwp − ωwp T − 2 T = − =− 2 ωwp T + 2 ωwp + T 21
2 T) 2 T)
4
DIGITAL CONTROLLER DESIGN 3
Frequency Response Method + Kd -
T
z - z0
ZOH
G(s)
z - zp
Design a phase lead or phase lag compensator D(z) = Kd
z − z0 z − zp
such that the (open loop) system satisfies 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 Kd , z0 and zp of the first order phase lead/lag compensator are determined in terms of a0 , ωw0 , ωwp defined 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(s) −1 G(z) = (1 − z )Z s 2. Calculate the frequency response G(ejωT ) 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(ejωT ). ωw =
2 ωT tan T 2
24
4. Make a frequency response table to help drawing the Bode diagram. ω
jG(ejωT )j
···
···
···
···
··· .. .
··· .. .
··· .. .
··· .. .
6
G(ejωT )
ωw
5. Draw the Bode Diagram, both for jG(ejωT )j and 6 G(ejωT ) 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 specified phase margin φm at a frequency ωw1 . 26
• Finding the new cross-over frequency ωw1 requires several conditions to be met, and also requires “try and error” until a satisfactory value is found. • We are designing (determining) w ωw0 D(w) = a0 w 1+ ωwp 1+
where, a pole is at w = −ωwp and a zero is at w = −ωw0 .
27
Characteristic Equation of the Closed Loop Systems The only mathematical condition required at ωw1 is D(jωw1 )G(jωw1 ) = 16 (−180◦ + φm ) = 16 (+180◦ + φm ) For magnitude, jD(jωw1 )j jG(jωw1 )j = 1 ⇒ jD(jωw1 )j =
1 jG(jωw1 )j
For phase, 6
D(jωw1 ) + 6 G(jωw1 ) = ∓180◦ + φm ⇒ θ = 6 D(jωw1 ) = ∓180◦ + φm − 6 G(jωw1 )
28
Mathematical Design Formula for Phase Lead/Lag Compesators The phase margin of the open loop trnasfer function D(w)G(w) satisfies a specified phase margin φm at a frequency ωw1 , if the parameters a1 and b1 of w a1 1 + 1+ w a1 w + a0 ωw0 a0 = a0 = a0 D(w) = w b1 w + 1 1 + b1 w 1+ ωwp where,
wω0 =
a0 a1
are set to satisfy
29
and
wωp =
1 b1
a1
=
b1
=
1 − a0 jG(jωw1 )j cos θ ωw1 jG(jωw1 )j sin θ cos θ − a0 jG(jωw1 )j ωw1 sin θ
where, θ = 6 D(jωw1 ) = ∓180◦ + φm − 6 G(jωw1 ). The DC gain a0 must be known from other criteria such as steady state error ess or DC gain.
30
Verification (check) 1 − a0 jG(jωw1 )j cos θ j ωw1 + a0 ja1 ωw1 + a0 ωw1 jG(jωw1 )j sin θ = cos θ − a0 jG(jωw1 )j jb1 ωw1 + 1 ωw1 + 1 j ωw1 sin θ 1 j(1 − a0 jGj cos θ) + a0 jGj sin θ × jG(jωw1 )j j(cos θ − a0 jGj) + sin θ
D(jωw1 ) =
= Thus, 2
D(jωw1 )
= = =
1 (1 − a0 jGj cos θ)2 + (a0 jGj sin θ)2 jGj2 (cos θ − a0 jGj)2 + sin2 θ 1 1 − 2a0 jGj cos θ + a20 jGj2 jGj2 1 − 2a0 jGj cos θ + a20 jGj2 1 jGj2 31
For phase angle,
6
D(jωw1 )
= =
tan 6 D(jωw1 )
=
=
a1 1 + j ωw1 a0 6 1 + jb1 jωw1 −1 a1 ωw1 − tan−1 b1 ωw1 tan a0 −1 a1 ωw1 − tan tan−1 b1 ωw1 tan tan a0 a1 1 + tan tan−1 ωw1 × tan tan−1 b1 ωw1 a0 a1 ωw − b1 ωw1 a0 1 a1 1 + ωw1 × b1 ωw1 a0
32
Substituting, a1 ωw1 =
1 − a0 jGj cos θ jGj sin θ
tan 6 D(jωw1 )
and
b1 ωw1 =
cos θ − a0 jGj sin θ
sin θ(1 − 2a0 jGj cos θ + a20 jGj2 ) = cos θ(1 − 2a0 jGj cos θ + a20 jGj2 ) = tan θ
Thus, the compensator D(jωw1 ) satisfies 1 jD(jωw1 )j = jG(jωw1 )j
33
and
6
D(jωw1 ) = θ
Range to choose ωw1 for Phase-Lead Case This formula based method is straightforward and works well as long as the choice of ωw1 is proper. The range of frequency ωw from which ωw1 should be chosen is specified by the following conditions for phase lead compensators. 1. θ = 6 D(jωw1 ) = ∓180◦ + φm − 6 G(jωw1 ) > 0 requires to choose ωw1 to satisfy a phase condition 6
G(jωw1 ) < ∓180◦ + φm .
2. Since jD(jωw )j > a0 , jD(jωw1 )j > a0 . Then, ωw1 should satisfy a gain condition, jG(jωw1 )j =
1 1 < jD(jωw1 )j a0
3. In the transfer function D(w), a0 , a1 and b1 must be all 34
positive as ωw0 compensators. Referring to a1 ωw1
a0 1 = and ωwp = . sin θ > 0 for phase lead a1 b1
1 − a0 jGj cos θ = jGj sin θ
and
b1 ωw1
cos θ − a0 jGj = . sin θ
the numerators must be positive as well. 1 − a0 jGj cos θ > 0
and
cos θ − a0 jGj > 0
1 > cos θ > a0 jG(jωw1 )j a0 jG(jωw1 )j This condition is written for jG(jωw1 )j as 1 cos θ < jG(jωw1 )j < a0 a0 cos θ
35
Thus, cos θ jG(jωw1 )j < , a0 which is more restrictive than the condition derived from the 1 gain, jG(jωw1 )j < . a0
36
Range to choose ωw1 for Phase-Lag Case The range of frequency ωw from which ωw1 should be chosen is specified by the following conditions for phase lag compensators. 1. θ = 6 D(jωw1 ) = ∓180◦ + φm − 6 G(jωw1 ) < 0 requires to choose ωw1 to satisfy a phase condition 6
G(jωw1 ) > ∓180◦ + φm .
2. Since jD(jωw )j < a0 , jD(jωw1 )j < a0 . Then, ωw1 should satisfy a gain condition, 1 1 jG(jωw1 )j = > jD(jωw1 )j a0 3. In the transfer function D(w), a0 , a1 and b1 must be all 1 a0 positive as ωw0 = and ωwp = . sin θ < 0 for phase lag a1 b1 37
compensators. Referring to a1 ωw1 =
1 − a0 jGj cos θ jGj sin θ
and
b1 ωw1 =
cos θ − a0 jGj . sin θ
the numerators must be negative as well. 1 − a0 jGj cos θ < 0
and
cos θ − a0 jGj < 0
1 < cos θ < a0 jG(jωw1 )j a0 jG(jωw1 )j This condition yields, jG(jωw1 )j >
1 cos θ > a0 cos θ a0
Thus, jG(jωw1 )j > 38
1 . a0 cos θ
1 This is more restrictive than jG(jωw1 )j > . a0
39
Design specific to Phase lag Compensator The first order phase lag compensator can be designed by the formula similarly as in the case of phase lead compensator. However, there is a basic difference 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 ωw1 is shifted to a lower frequency where the phase response of the Bode diagram is not affected by the compensator, selecting ωw1 can be done on the Bode 40
diagram of G(w) alone without being affected by the compensator. First, find a new crossover frequency ωw1 where the condition, 6
G(jωw1 ) = −180◦ + φm + 5◦
is satisfied. 5◦ accounts for a slight phase angle derease by the phase lag compensator. The rule of thumb to set ωw0 in the compensator’s transfer function, w 1+ a1 w + a0 ωw0 D(w) = a0 w = b1 w + 1 1+ ωwp is to pick one decade lower than the ωw1 , i.e. ωw0 = 0.1 × ωw1 .
41
For a phase lag compensator, ωwp < ωw0 . 1 + j ωw1 ωwp 1 ωw0 jD(ωw1 )j = a0 = ' a0 1 + j ωw1 ωw0 G(jωw1 ) ω wp
Thus, ωwp =
ωw0 0.1 ωw1 = a0 jG(jωw1 )j a0 jG(jωw1 )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 1 G(s) = s(s + 1)(0.5s + 1) The z-transform of this system combined with ZOH is −5
G(z) = 4.0140 × 10
(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
Magnitude Response
Magnitude in dB
20
0
−20
−40
−60 −1 10
0
10 frequency in rad/s
1
10
Phase Response −50
Phase in degrees
−100 −150 −200 −250 −300 −1 10
0
10 frequency in rad/s
44
1
10
Design a phase lag compensator that achieves a phase margin of φm = 55◦ for a0 = 1. 6
G(jωw1 ) = −180◦ + 55◦ + 5◦ = −120◦
By the Bode diagram, ωw1 ' 0.36. At this frequency jG(jωw1 )j = 2.57 = 8.2dB. Therefore, ωw0 = 0.1 ωw1 = 0.036 ωwp =
0.1 ωw1 = 0.0140 a0 jG(jωw1 )j
Using these values of a0 , ωw0 and ωwp , D(z) = 0.3891
z − 0.9982 . z − 0.9993
The frequency response after compensation is shown in the frequency axis of ωw . 45
Magnitude Response 20
Magnitude in dB
0 −20 −40 −60 −80 −1 10
0
10 frequency in rad/s
1
10
Phase Response −50
Phase in degrees
−100 −150 −200 −250 −300 −1 10
0
10 frequency in rad/s
46
1
10
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 1 G(s) = s(s + 1)(0.5s + 1) Try a phase lead compensator that satisfies the phase margin of φm = 55◦ . We keep a0 = 1 as the previous phase lag case. We need to select a ωw1 to use the formula that determine the compensator coefficients a1 and b1 . Refer to the three conditions. 6
G(jωw1 ) < ∓180◦ + φm .
1 1 jG(jωw1 )j = < D(jωw1 ) a0 47
cos θ , a0 where, θ = 6 D(jωw1 ) = ∓180◦ + φm − 6 G(jωw1 ) > 0. jG(jωw1 )j
0.45 according to the 1 1 Bode diagram (phase). 1 requres ωw1 > 0.75 from • The second condition jG(jωw1 )j < a0 the Bode diagram (gain). So, try ωw1 > 1.2 to see if the third condition is satisfied. θ = ∓180◦ + φm − 6 G(jωw1 ) > 0. 6 G(jωw ) = −172.8◦ . Therefore, 1 θ = −180◦ + 55 − (−172.8) = 47.8◦ . • cos θ = 0.6709 and a0 jG(jωw1 )j = 0.4576. Thus, the third condition is met. Therefore, the choice of ωw1 ≥ 1.2 is acceptable for the use of the 48
formula. i.e. ωw1 = 1.2 Using the formula, a1 =
1 − a0 jGj cos θ ωw1 jGj sin θ
and
b1 =
cos θ − a0 jGj ωw1 sin θ
We find, a1 = 1.7016
and
b1 = 0.2397
The parameters of the discrete time domain transfer function of the compensator z − z0 D(z) = Kd z − zp are Kd z0
=
ωwp (ωw0 T + 2) ωwp (ωw0 + a0 = a0 ωw0 (ωwp T + 2) ωw0 (ωwp +
=
ωw0 − ωw0 T − 2 − =− ωw0 T + 2 ωw0 + 49
2 T 2 T
2 T) 2 T)
= 0.9710
= 6.5230
zp
=
ωw T − 2 ωw − − p =− p ωwp T + 2 ωwp +
2 T 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
Magnitude Response 40
Magnitude in dB
20 0 −20 −40 −60 −1 10
0
10 frequency in rad/s
1
10
Phase Response −50
Phase in degrees
−100 −150 −200 −250 −300 −1 10
0
10 frequency in rad/s
51
1
10
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 Differential) controller is given by T z+1 1 D(z) = KP + KI + KD (1 − z −1 ), 2 z−1 T whereas an analog PID controller is 1 + KD w w KD w 2 + KP w + KI = w w w (1 + )(1 + ) wω1 wω2 = KI w From the last expression, we can obtain the frequency response (Bode diagram) of D(w). D(w)
=
KP + KI
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 2 ωT desired value. Since ωw = tan , due to the term KD w, T 2 jD(jωw )j → ∞
when, 57
ωT → π.
We do not use w =
2 z−1 for D-action. Instead we use T z+1 1 z−1 (1 − z −1 ) = . T Tz
z − 1 Tz
w w w = = = w w 1+ T w T 2 z= 1+ 1 + ωs 1+ w 1− T w 2 2 2 ( ) ( ) π T 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
ωs ωs an assumption that the actual frequency ω < . π 2 D(w) = KP + KI
1 + KD w. w
1 + jKD ωw D(jωw ) = KP − jKI ωw 1 = KP + j KD ωw − KI ωw = jD(jωw )j6 θ r 1 2 2 ) jD(jωw )j = KP + (KD ωw − KI ωw 1 K ω − K D w I ωw θ = tan−1 KP
59
PID controller design Determine KP , KI and KD such that the phase margin is φm at a cross-over frequency ωw1 . This requirement is D(jωw1 )G(jωw1 ) = 16 − 180◦ + φm For gain, 1 jD(jωw1 )j = jG(jωw1 )j For phase, 6 6
D(jωw1 ) + 6 G(jωw1 ) = ∓180◦ + φm D(jωw1 ) = ∓180◦ + φm − 6 G(jωw1 ).
Since 1 KP + j KD ωw1 − KI ωw1
=
60
jD(jωw1 )jejθ
= =
KD ωw1 − KI phase lag:
KP
=
1 ωw1
=
θ0
sin θ > 0
KD ωw1 > KI ωw1
1
Increasing KD increases bandwidth. Increasing KI decreases steady state error ess provided that the system retains an acceptable gain margin. If the above two conditions are staisfied, varying KI and KD will change the gain margin, while the phase 61
margin remains unchanged. From the relationship, 6
D(jωw1 ) = ∓180◦ + φm − 6 G(jωw1 ) = θ
the cross-over frequency ωw1 must be chosen depending on whether the PID controller should be of leading phase or lagging phase. • ωw1 should be chosen where 6 G(jωw1 ) < ∓180◦ + φm , if leading phase (more D-action than I-action). • ωw1 should be chosen where 6 G(jωw1 ) > ∓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, ess . 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 KI and KD . 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 KI or KD becomes uniquely determinable. In PID case, 1 1 KP + j KD ωw1 − KI = (cos θ + j sin θ) ωw1 jG(jωw1 )j
PI controller, θ < 0 1 1 KP − jKI = (cos θ + j sin θ) ωw1 jG(jωw1 )j 64
KP KI
1 = cos θ jG(jωw1 )j 1 sin θ = −ωw1 jG(jωw1 )j
65
PD controller, θ > 0 KP + jKD ωw1
KP
=
KD
=
1 = (cos θ + j sin θ) jG(jωw1 )j 1 cos θ jG(jωw1 )j 1 sin θ ωw1 jG(jωw1 )j
Exact Solutions The digital PID controller 1 T z+1 + KD (1 − z −1 ), D(z) = KP + KI 2 z−1 T is mapped to w-domain exactly as D(w) = KP + KI
1 + KD w
66
w T 1+ w 2
The solutions derived from 1 D(w) = KP + KI + KD w w ωs ωs provided for the actual frequency ω to be ω < are π 2 approximations. The frequency response is D(jωw ) = KP − jKI
1 + KD ωw
jωw T 1 + jωw 2
At the cross-over frequency ωw1 , D(jωw1 )
1 + KD ωw1
jωw1 T 1 + jωw1 2
=
KP − jKI
=
1 (cos θ + j sin θ) jG(jωw1 )j 67
The real part gives 2 ) cos θ T KP + = 2 jG(jωw1 )j 2 ( )2 + ωw 1 T The imaginary part gives 2 KD ωw ( 1
2 2 KD ωw ( ) 1 sin θ T − KI = 2 ωw1 jG(jωw1 )j 2 ( )2 + ωw 1 T For PI controller with KD = 0, the equations for KP and KI remain the same as the approximated solutions. However, PD controller gains KD and KP are given as follows. 2 2 2 ( ) + ω w 1 sin θ T KD = 2 jG(jωw1 )j ( )2 ωw1 T 68
KP =
2 KD ωw ( 1
2 ) T
cos θ − 2 jG(jωw1 )j 2 ( )2 + ωw 1 T
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 ωw1 = 0.4. Using the design program below, Kp = 0.4392 and Ki = 0.0040 were found.
70
Magnitude Response 20
Magnitude in dB
0 −20 −40 −60 −80 −1 10
0
10 frequency in rad/s
1
10
Phase Response −50
Phase in degrees
−100 −150 −200 −250 −300 −1 10
0
10 frequency in rad/s
71
1
10
% % 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 1 G(s) = , s(s + 1)(0.5s + 1) design a PID controller to have phase margin of 55◦ at ωw1 = 1.2. Specifying Ki = 0.004 in the PID design program, Kp = 1.4661 and Kd = 1.3530 were found.
77
Magnitude Response 40
Magnitude in dB
20 0 −20 −40 −60 −1 10
0
10 frequency in rad/s
1
10
Phase Response −50
Phase in degrees
−100 −150 −200 −250 −300 −1 10
0
10 frequency in rad/s
78
1
10
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