Professional Documents
Culture Documents
Myee480 p9 freqrespPID PDF
Myee480 p9 freqrespPID PDF
Kunio Takaya
Electrical and Computer Engineering
University of Saskatchewan
1
Contents
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
3
T
y(k) = y(k − 1) + [x(k) + x(k − 1)]
2
Taking the z-transform,
T
Y (z) = z −1 Y (z) + [X(z) + z −1 X(z)]
2
−1 T
(1 − z )Y (z) = (1 + z −1 )X(z)
2
Y (z) T 1 + z −1
=
X(z) 2 1 − z −1
1
We let integration in the Laplace transform equal to the
s
integration in the z-domain.
1 T 1 + z −1
=
s 2 1 − z −1
4
Then, we define the bilinear transformation,
2 1 − z −1 2 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 1 − z −1 2 z−1
w= −1
= ,
T 1+z T z+1
T
2 z−1 1+ 2w
w= ⇔ z= T
T z+1 1− 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.
7
Nonlinear frequency relationship
−1
2 1 − e−jωT
2 1−z
=
T 1 + z −1 z=ejωT T 1 + e−jωT
ωT ωT ωT
2 e−j 2 (ej 2 − e−j 2 )
=
T e−j ωT ωT ωT
2 (ej 2 + e−j 2 )
2 ωT
= j tan
T 2
= jωw
8
In the relationship between s-domain and z-domain, z = esT ,
analog frequency is defined by s = jω whereas digital (discrete
jωd jωT ωd
time) frequency ωd is defined by e =e . Therefore, ω = .
T
9
frequency range in ω, ωd and ωw
ωs 2πfs π
ω =⇒ 0≤ω≤ = =
2 2 T
ωd =⇒ 0 ≤ ωd = ωT ≤ π
T ωT T π
ωw =⇒ 0 ≤ ωw = tan ≤ tan = ∞
2 2 2 2
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
z+1
K
+ - 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)
2 z−1 1 + T2 w
w= ⇔ z=
T z+1 1 − T2 w
z + 1
G(w) = K
z(z − 1) 1+ T2 w
z=
1− T w
2
11
1 + T2 w
T
+1
1− 2w
= K
1 + T2 w 1 + T2 w
T
( T
− 1)
1− 2w 1− 2w
T
1− w
= K 2
T T
(1 + w) w
2 2
The characteristic equation is
T
1−w
1 + G(w) = 1 + K 2 =0
T T
(1 + w) w
2 2
T T
( )2 w2 + (1 − K)w + K = 0
2 2
12
w ( T2 )2
2
K
1 T
w 2 (1 − K) 0
0
w K 0
Therefore, 0 < K < 1 is necessary for the system to be stable.
bn wn + bn−1 wn−1 + · · · + b1 w + b0 = 0
13
wn
bn bn−2 bn−4 · · ·
wn−1
bn−1 bn−3 bn−5 · · ·
wn−2
c1 c2 c3
wn−3
d1 d2 d3
.. .. .. ..
. . . .
14
Example
An open loop transfer function
z+1
G(z) = K
(z − 1)2
yields
2 − Tw
G(w) = K
(T w)2
The characteristic equation is
T 2 w2 − KT w + 2K = 0.
w2 T 2 2K
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
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
2 z−1
Substituting w = for w in the compensator transfer
T z+1
function,
2z−1
T
1+ z+1
ωw0
D(z) = a0
2 z−1
T z+1
1+
ωwp
2 z−1
ωw0 ωwp + ωwp
= a0 T z+1
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 −2
z+
ωwp (ωw0 T + 2) ωw0 T +2
= a0 ×
ωw0 (ωwp T + 2) ωwp T −2
z+
ωwp T +2
z − z0
= Kd
z − zp
Thus,
2
ωwp (ωw0 T + 2) ωwp (ωw0 + T)
Kd = a0 = a0 2
ωw0 (ωwp T + 2) ωw0 (ωwp + T)
2
ωw0 T − 2 ω w0 −
z0 = − =− T
ωw0 T + 2 2
ωw0 +
T
2
ωwp T − 2 ωwp −
zp = − =− T
ωwp T + 2 2
ωwp +
T
21
4 DIGITAL CONTROLLER DESIGN 3
+ z - z0
Kd ZOH G(s)
- T z - zp
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.
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,
?
−1 G(s)
G(z) = (1 − z )Z
s
24
4. Make a frequency response table to help drawing the Bode
diagram.
ω jG(ejωT )j 6 G(ejωT ) ωw
··· ··· ··· ···
··· ··· ··· ···
.. .. .. ..
. . . .
25
Design Approach
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.
27
Characteristic Equation of the Closed Loop
Systems
The only mathematical condition required at ωw1 is
For magnitude,
1
jD(jωw1 )j jG(jωw1 )j = 1 ⇒ jD(jωw1 )j =
jG(jωw1 )j
For phase,
28
Mathematical Design Formula for Phase
Lead/Lag Compesators
a0 1
where, wω0 = and wωp =
a1 b1
are set to satisfy
29
1 − a0 jG(jωw1 )j cos θ
a1 =
ωw1 jG(jωw1 )j sin θ
cos θ − a0 jG(jωw1 )j
b1 =
ωw1 sin θ
30
Verification (check)
1 − a0 jG(jωw1 )j cos θ
j ωw1 + a0
ja1 ωw1 + a0 ωw1 jG(jωw1 )j sin θ
D(jωw1 ) = =
jb1 ωw1 + 1 cos θ − a0 jG(jωw1 )j
j ωw1 + 1
ωw1 sin θ
1 j(1 − a0 jGj cos θ) + a0 jGj sin θ
= ×
jG(jωw1 )j j(cos θ − a0 jGj) + sin θ
Thus,
31
For phase angle,
a1
1 + j ωw1
6 6
a0
D(jωw1 ) =
1 + jb1 jωw1
−1 a1
= tan ωw1 − tan−1 b1 ωw1
a0
−1 a1
tan tan ωw1 − tan tan−1 b1 ωw1
a0
tan 6 D(jωw1 ) = 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,
1 − a0 jGj cos θ cos θ − a0 jGj
a1 ωw1 = and b1 ωw1 =
jGj sin θ sin θ
33
Range to choose ωw1 for Phase-Lead Case
34
a0 1
positive as ωw0 = and ωwp = . sin θ > 0 for phase lead
a1 b1
compensators.
Referring to
1 − a0 jGj cos θ cos θ − a0 jGj
a1 ωw1 = and b1 ωw1 = .
jGj sin θ sin θ
the numerators must be positive as well.
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
37
compensators.
Referring to
1 − a0 jGj cos θ cos θ − a0 jGj
a1 ωw1 = and b1 ωw1 = .
jGj sin θ sin θ
the numerators must be negative as well.
38
1
This is more restrictive than jG(jωw1 )j > .
a0
39
Design specific to Phase lag Compensator
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◦
41
For a phase lag compensator, ωwp < ωw0 .
1 + j ωw1
ωw0
ωwp 1
jD(ωw1 )j = a0 ' a0 =
1 + j ωw1 ωw0 G(jωw1 )
ωwp
Thus,
ωw0 0.1 ωw1
ωwp = =
a0 jG(jωw1 )j a0 jG(jωw1 )j
42
Example 8.1 page 294
−5 (z + 3.5954)(z + 0.2580)
G(z) = 4.0140 × 10 .
(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
20
0
Magnitude in dB
−20
−40
−60
−1 0 1
10 10 10
frequency in rad/s
Phase Response
−50
−100
Phase in degrees
−150
−200
−250
−300
−1 0 1
10 10 10
frequency in rad/s
44
Design a phase lag compensator that achieves a phase margin of
φm = 55◦ for a0 = 1.
45
Magnitude Response
20
Magnitude in dB 0
−20
−40
−60
−80
−1 0 1
10 10 10
frequency in rad/s
Phase Response
−50
−100
Phase in degrees
−150
−200
−250
−300
−1 0 1
10 10 10
frequency in rad/s
46
Example 8.2 page 302 Phase lead compensator
design
47
cos θ
jG(jωw1 )j < ,
a0
where, θ = 6 D(jωw1 ) = ∓180◦ + φm − 6 G(jωw1 ) > 0.
• The range that the first condition
6 G(jωw ) < ∓180◦ + φm = −125◦ , ωw > 0.45 according to the
1 1
48
formula. i.e. ωw1 = 1.2 Using the formula,
1 − a0 jGj cos θ cos θ − a0 jGj
a1 = and b1 =
ωw1 jGj sin θ ω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
2
ωwp (ωw0 T + 2) ωwp (ωw0 + T)
Kd = a0 = a0 2 = 6.5230
ωw0 (ωwp T + 2) ωw0 (ωwp + T)
2
ωw0 T − 2 ωw0 − T
z0 = − =− 2 = 0.9710
ωw0 T + 2 ωw0 + T
49
2
ωw T − 2 ωw − T
zp = − p =− p 2 = 0.8111
ωwp T + 2 ωwp + T
50
Magnitude Response
40
Magnitude in dB 20
−20
−40
−60
−1 0 1
10 10 10
frequency in rad/s
Phase Response
−50
−100
Phase in degrees
−150
−200
−250
−300
−1 0 1
10 10 10
frequency in rad/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
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
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
D(w) = KP + KI + 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).
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, ωT → π.
57
2 z−1
We do not use w = for D-action. Instead we use
T z+1
1 z−1
(1 − z −1 ) = .
T Tz
z − 1 w w w
= = w = w
Tz z=
1+ T w
2 T 1+ 1 + ωs
1− T w 1+ w 2
2
2 ( ) ( )
T π
Therefore, the corner frequency at
ωs ωs
ωw = <
π 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
1
D(w) = KP + KI + KD w.
w
1
D(jωw ) = KP − jKI + jKD ωw
ωw
1
= KP + j KD ωw − KI
ωw
= jD(jωw )j6 θ
r
2 1 2
jD(jωw )j = KP + (KD ωw − KI )
ωw
1
K D ωw − K I ωw
θ = tan−1
KP
59
PID controller design
For gain,
1
jD(jωw1 )j =
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 ).
Since
1
KP + j KD ωw1 − KI = jD(jωw1 )jejθ
ωw1
60
= jD(jωw1 )j (cos θ + j sin θ)
1
= (cos θ + j sin θ)
jG(jωw1 )j
1
KP = cos θ
jG(jωw1 )j
1 1
KD ωw1 − KI = sin θ
ωw1 jG(jωw1 )j
61
margin remains unchanged. From the relationship,
62
PI and PD Controller
63
a leading phase up to 90◦ . A larger gain at high frequency makes
the bandwidth wider.
PI controller, θ < 0
1 1
KP − jKI = (cos θ + j sin θ)
ωw1 jG(jωw1 )j
64
1
KP = cos θ
jG(jωw1 )j
1
KI = −ωw1 sin θ
jG(jωw1 )j
65
PD controller, θ > 0
1
KP + jKD ωw1 = (cos θ + j sin θ)
jG(jωw1 )j
1
KP = cos θ
jG(jωw1 )j
1
KD = sin θ
ωw1 jG(jωw1 )j
Exact Solutions
The digital PID controller
T z+1 1
D(z) = KP + KI + KD (1 − z −1 ),
2 z−1 T
is mapped to w-domain exactly as
1 w
D(w) = KP + KI + KD
w T
1+ w
2
66
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
1 jωw
D(jωw ) = KP − jKI + KD
ωw T
1 + jωw
2
At the cross-over frequency ωw1 ,
1 jωw1
D(jωw1 ) = KP − jKI + KD
ωw1 T
1 + jωw1
2
1
= (cos θ + j sin θ)
jG(jωw1 )j
67
The real part gives
2 2
KD ωw ( ) cos θ
KP +
1
T =
2 jG(jωw1 )j
( )2 + ωw2
T 1
68
2 2
cos θ KD ωw ( )
KP = −
1
T
jG(jωw1 )j 2
( )2 + ωw
2
T 1
69
PI controller for the servo-motor for a radar
antenna
70
Magnitude Response
20
Magnitude in dB 0
−20
−40
−60
−80
−1 0 1
10 10 10
frequency in rad/s
Phase Response
−50
−100
Phase in degrees
−150
−200
−250
−300
−1 0 1
10 10 10
frequency in rad/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
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
77
Magnitude Response
40
Magnitude in dB 20
−20
−40
−60
−1 0 1
10 10 10
frequency in rad/s
Phase Response
−50
−100
Phase in degrees
−150
−200
−250
−300
−1 0 1
10 10 10
frequency in rad/s
78
Assignment No. 6
79