You are on page 1of 10

ECTE942 Computer Controlled System : Assignment 1 Page 1

ASSIGNMENT 1
DESIGN OF LEAD COMPENSATOR


This report will be divided into two parts. The first part is to design a continuous time digital
lead compensator and the second part is re-design the digital lead compensator using
emulation. Figure 1 shows the digital controller using the compensator. In that controller, the
plant is 0(s) =
1
s(s+1)
.


Figure 1. Digital compensator

In addition, parameters which will be used in the design are:

(s) = K
(1s+1)
u1s+1
, < 1
Static velocity error constant Kv is 50 sec
-1
,
Phase margin is 50
gain margin not less than 8 dB

a. LEAD COMPENSATOR DESIGN
In order to find the zero and pole of (s) = K
(1s+1)
u1s+1
, < 1, the equation can be
changed by divided it by T, thus (s) = Kc
(
1
T
+s)
1
oT
+s
, K=K
c


1. Gain adjustment to meet the required Kv

u1(s) = Ku(s) =
K
s(s +1)


K: = lim
s0
s(s)0(s) =lim
s0
s
1 +Is
oIs +1
01(s) = lim
s0
sK
s(s +1)
= K
Thus K = Kv = 50

2. Plot the bode diagram
01(s) =
Su
s(s +1)




Using MATLAB, bode diagram of the G1 (s) can be plotted as follows:
MATLAB command:
num=[0 0 50];
den=[1 1 0];
ECTE942 Computer Controlled System : Assignment 1

sys=tf(num,den)
bode(sys)
margin(sys)
grid

Figure 2 shows the result of bode diagram. From the graph, it can be clearly seen
that the gain margin is
phase margin requirement, which is 50
needed to add 5
0

this case 7
0
is chosen to the system.




3. Determine the attenuation factor
Frequency of uncompensated system:
1
o
=
Thus, from the bode diagram,

4. Determine the corner frequency of the lead compensator
Zero at =
1
1

1
1
Pole at =
1
u1

u1
The lead compensator is determined:
ECTE942 Computer Controlled System : Assignment 1
sys=tf(num,den)
Figure 2 shows the result of bode diagram. From the graph, it can be clearly seen
that the gain margin is + dB and phase margin is 8.09
0
. In
phase margin requirement, which is 50
0
, the additional phase lead is 42
to 12
0
to compensate the shift in gain crossover frequency.
is chosen to the system. Thus m= 50 8.09 + 7
0
=
Figure 2. Bode diagram of G1(s)
Determine the attenuation factor
sin 0m =
1 - o
1 + o
sin48 =
1 - o
1 + o

u.74 + u.74o = 1 - o
o = u.149
Frequency of uncompensated system:

1
u.149
=
1
u.S86
= 2.S9 2u log 2.S9 = 8
, from the bode diagram, |01(])| = -8.26 JB related to
Determine the corner frequency of the lead compensator
1
1
= o
c
= u.149x11.4 = 4.4
1
u1
=
o
c
u
=
11.4
0.149
= 29.S
The lead compensator is determined:
Page 2
Figure 2 shows the result of bode diagram. From the graph, it can be clearly seen
. In order to meet the
, the additional phase lead is 42
0
. It is
to compensate the shift in gain crossover frequency. In
= 48.1
0
48
0
.


.26 JB
related to
c
= 11.4 rad/sec.
ECTE942 Computer Controlled System : Assignment 1 Page 3

(s) = Kc
(
1
T
+s)
1
oT
+s
, K = K
c
o K
c
=
K
u
=
50
0.149
= SSS.6
(s) =
Su
u.149
x
s +4.4
s +29.S


5. Plot the Bode diagram of compensated system using MATLAB:

MATLAB command:
s=tf('s');
sys=1/(s*(s+1));
comp=(50* (s+4.4))/(0.149*(s+29.5));
sysc=sys*comp;
bode(sysc)
margin(sysc)
grid on

Figure 3 shows the resulted Bode diagram. It can be clearly seen that the phase
margin is 52.8
0
, which is met the requirement 50
0
.



Figure 3. Bode diagram of compensated system


b. EMULATION DESIGN
1. Step response system, system margin and bandwidth
Step response system

MATLAB code:
s=tf('s');
sys=1/(s*(s+1));
comp=(50* (s+4.4))/(0.149*(s+29.5));
sysc=sys*comp;
closedloop=feedback(sysc,1)
step(closedloop)
grid

ECTE942 Computer Controlled System : Assignment 1 Page 4



Figure 4. Step response of closed loop system

Close loop frequency response:
MATLAB code:
s=tf('s');
sys=1/(s*(s+1));
comp=(50* (s+4.4))/(0.149*(s+29.5));
sysc=sys*comp;
closedloop=feedback(sysc,1)
bode(closedloop)
margin(closedloop)
grid


Figure 5. Closed loop frequency response

System margin
From Figure 5, Gain margin and phase margin of the closed loop system
are + dB and 103
0
, respectively.

Bandwidth
It can be seen that from Figure 5, the bandwidth of the compensator
system is
b =
18.6 rad/sec.

ECTE942 Computer Controlled System : Assignment 1 Page 5

2. Sample frequency
Based on the bandwidth, the sample frequency is

c
= 2u x
b
= 2u x 18.6 = S72 roJscc
Then I =
2n
o
s
=
2n
372
= u.u169 s

3. Analysis the effects of ZOH and AAF to the system response
AAF
Since
c
= 372 rad/sec, the passband of the antialiasing filter is therefore

p
=

s
2
= 186 roJs
From this, the first-order filter can be determined as:
0
AAP
(s) =
1
1 +
s
186

The phase plot of G
AAF
(s) at certain frequency is given as:
atanI

186
] = atan|
11
186
1 = S.4
0


MATLAB code:
s=tf('s');
sys=1/(s*(s+1));
comp=(50* (s+4.4))/(0.149*(s+29.5));
gaaf=1/(1+(s/186));
sysc=sys*comp;
bode(sysc,'b')
hold
bode(gaaf,'r')
margin(sysc)
grid



Figure 6. Effect of AAF to the system

ZOH
For ZOH, the introduced time delay (T/2) must be considered, thus the
transfer function is
0
z0H
(s) c
-0.00845

ECTE942 Computer Controlled System : Assignment 1 Page 6


MATLAB code:
s=tf('s');
sys=1/(s*(s+1));
comp=(50* (s+4.4))/(0.149*(s+29.5));
gzoh=exp(-0.00845*s);
syszoh=sys*comp*gzoh;
bode(syszoh)
margin(syszoh)
grid



Figure 7. Effect of ZOH to the system

Figure 7 shows the effect of zero order hold filter on the system. It can be seen
that the gain margin change from infinity to 19.5 dB and the phase margin change
from 52.8
0
to 47.3
0
or in other word, the phase margin is decreased by 5.5
0
.

Therefore, total 5.5
0
+ 3.4
0
= 8.9
0
9
0
has been lost due to the antialiasing filter
and ZOH.
To regain the lost 9
0
, the open loop gain must be lowered and from open loop
frequency response, the gain crossover frequency needed for a phase margin of
52
0
+ 9
0
is about 0.76 rad/sec. Therefore, from Figure 8, the gain should be
reduced by 34 dB and this is corresponding to about 50, which is resulted the new
gain K/50 = 50/50 = 1.
Thus the new D(s) to maintain the phase margin of continuous time design is:
(s) =
1
u.149
x
s +4.4
s +29.S




ECTE942 Computer Controlled System : Assignment 1 Page 7



Figure 8. Regain of lost 9
0




Figure 9. Bode diagram of system using redesigned compensator

Figure 9 shows the bode diagram of system using the redesigned compensator in
order to get the new parameters for fulfilling the phase requirement. The
MATLAB code is:
%redesigned compensator
s=tf('s');
sys=1/(s*(s+1));
K=50/50;
comp=(K*(s+4.4))/(0.149*(s+29.5));
sysc=sys*comp;
bode(sysc)
margin(sysc)
grid

In addition, the new parameters are:
Bandwidth=b=1.17 rad/sec,
Sample frequency s=20 x b = 20 x 1.17 = 23.4 rad/sec ,
ECTE942 Computer Controlled System : Assignment 1 Page 8

T=0.268 s and p=s/2=11.7 rad/sec
0
z0H
(s) c
-0.134
, AAF can be ignored because it will not affect the
system
Therefore using the new parameters, the open loop system after the inserting AAF and ZOH
can be plotted using the following MATLAB code and the result is shown in Figure 10. From
figure 10, it can be seen that the phase margin is 54.1
0
, which is met the requirement of 50
0
.

MATLAB code:
s=tf('s');
sys=1/(s*(s+1));
comp= (s+4.4)/(0.149*(s+29.5));
gzoh=exp(-0.134*s);
syszoh=sys*comp*gzoh;
bode(syszoh)
margin(syszoh)
grid



Figure 10. Open loop frequency response of the redesigned system

4. Approximate D(s) using bilinear method to find D(z)
It can be done using MATLAB command c2d
Ts=0.268;
Kc=50;
Kd=Kc/50;
Ds=(Kd*(s+4.4))/(0.149*(s+29.5))
%bilinear method
Dz=c2d(Ds,Ts,'tustin')

Result:
D(s) D(z)
Transfer function:
s + 4.4
---------------
0.149 s + 4.396

Transfer function:
2.154 z - 0.5561
----------------
z + 0.5962



ECTE942 Computer Controlled System : Assignment 1 Page 9


5. Comparison between discrete system performance and original one using
step response and bode diagram

MATLAB code:
%CONTINUOUS SYSTEM MODEL
s=tf('s');
Kc=50;
plant_c=1/(s*(s+1));
comp_c=(Kc*(s+4.4))/(0.149*(s+29.5));
sysc=plant_c*comp_c;
closedloop_c=feedback(sysc,1);

% DISCRETE SYSTEM MODEL
Ts=0.268;
Kd=Kc/50;
comp_c1=(Kd*(s+4.4))/(0.149*(s+29.5));
comp_d=c2d(comp_c1,Ts,'tustin');
plant_d=c2d(plant_c,Ts,'tustin');
sysd=comp_d*plant_d;
closedloop_d=feedback(sysd,1);

% STEP RESPONSE COMPARISON
Time=0:Ts:199*Ts;figure(1)
yc=step(closedloop_c,Time);
yd=step(closedloop_d,Time);
plot(Time,yc,Time,yd),title('STEP RESPONSE
COMPARISION'),legend('CONTINUOUS','SAMPLED-DATA')
grid

% FREQUENCY RESPONSE COMPARISON
[Gain_Margin_c,Phase_Margin_c]=margin(sysc)
[Gain_Margin_d,Phase_Margin_d]=margin(sysd)
Gain_Margin_c_dB=20*log10(Gain_Margin_c)
Gain_Margin_d_dB=20*log10(Gain_Margin_d)
figure(2),bode(closedloop_c,'b',closedloop_d,'r')
title('CLOSED-LOOP FREQUENCY RESPONSE
COMPARISION'),legend('CONTINUOUS','SAMPLED-DATA')
grid

The results is shown in Figure 11 and Table 1 shows the values of the gains.


Figure 11. Comparison between discrete and original performance
ECTE942 Computer Controlled System : Assignment 1 Page 10


Table 1. Gain values comparison between continuous and discrete system
Item Continuous Discrete
Gain margin Inf 1.2265e+017
Phase margin 52.8041
0
60.1950
0

Gain margin (dB) Inf 341.7736


6. Comparison the performance of different approximate methods for
discretizing continuous compensator.

You might also like