|
Let us calculate a lag-lead compensator that satisfies the following requirements static velocity constant error , phase margin 50 and gain margin . The open-loop system is the following:
- First, let's calculate the value of K to obtain
- Let's calculate Bode plot
Gain table:
w |
|
1 |
|
4 |
|
|
(-20) |
0 |
(-20) |
|
(-20) |
|
(0) |
0 |
(-20) |
|
(-20) |
|
(0) |
0 |
(0) |
0 |
(-20) |
|
(-20) |
20 |
(-40) |
-4.06 |
(-60) |
Phase table:
w |
0.1 |
|
0.4 |
|
1 |
|
4 |
|
10 |
|
40 |
|
|
-90 |
(0) |
-90 |
(0) |
-90 |
(0) |
-90 |
(0) |
-90 |
(0) |
-90 |
(0) |
|
0 |
(-45) |
|
(-45) |
-45 |
(-45) |
|
(-45) |
-90 |
(0) |
-90 |
(0) |
|
0 |
(0) |
0 |
(-45) |
|
(-45) |
-45 |
(-45) |
|
(-45) |
-90 |
(0) |
|
-90 |
(-45) |
-117 |
(-90) |
-153 |
(-90) |
-207 |
(-90) |
-243 |
(-45) |
-270 |
(0) |
Calculations and Bode plot by Scilab
w1=[0.1 1 4 40 100];
w2=[0.1 0.4 1 4 10 40 100];
gdb1=20*log10(10)
gdb(1)=gdb1-20*log10(0.1)
gdb(2)=gdb1
gdb(3)=gdb1-40*log10(4)
gdb(4)=gdb(3)-60*log10(40/4)
gdb(5)=gdb(3)-60*log10(100/4)
a(1)=-90
a(2)=a(1)-45*log10(0.4/0.1)
a(3)=a(2)-90*log10(1/0.4)
a(4)=a(2)-90*log10(4/0.4)
a(5)=a(2)-90*log10(10/0.4)
a(6)=a(5)-45*log10(40/10)
a(7)=a(6)
s=%s/(%pi*2);
g=40/(s*(s+1)*(s+4));
gs=syslin('c',g);
w=logspace(-1,2,100);
gsf=tf2ss(gs);
[frq1,rep] =repfreq(gsf,w);
[db,phi]=dbphi(rep);
clf;
subplot(2,1,1);
plot2d(w,db,5,logflag="ln")
plot2d(w1,gdb,2,logflag="ln")
legends(['Exact','Calculated (approximated)'],[5,2],opt=1);
xgrid;
subplot(2,1,2);
plot2d(w,phi,5,logflag="ln")
plot2d(w2,a,2,logflag="ln")
xgrid;
- Let's calculate the frequency to which phase is -180. This is the new gain crossover frequency.
- The value
of lag compensator is a decade below the new gain crossover frequency
- The phase margin is , with this value we calculate
The lag compensator is:
We draw the lag compensator by Scilab
Scilab program:
s=%s/(2*%pi);
g=40/(s*(s+1)*(s+4));
gc1=(s+0.2)/(s+0.02);
gt1=g*gc1;
gs=syslin('c',g);
gc1s=syslin('c',gc1);
gt1s=syslin('c',gt1);
clf();
bode([gs;gt1s;gc1s],['compensator';'compensated';'no compensated']);
- Let's calculate the lead compensator. We calculate the gain in new gain crossover frequency.
We calculate the pole and zero of compensator, draw a line passing a line through point (2rad/seg,-7.95dB) of Bode plot and see where intersects with line -20dB(gain value of lag compensator in
) and line 0dB. The slope is 20dB/dec.
The lead compensator is:
Let's calculate the phase and gain margins, and Bode plot by Scilab
Scilab program:
s=%s/(2*%pi);
g=40/((s+0.00000000001)*(s+1)*(s+4));
gc1=(s+0.2)/(s+0.02);
gc2=(s+0.5)/(s+5);
gc3=(s+0.4)*(s+0.2)/((s+4)*(s+0.02));
gt1=g*gc1*gc2;
gt2=gc3*g;
gs=syslin('c',g);
gc1s=syslin('c',gc1*gc2);
gc2s=syslin('c',gc3);
gt1s=syslin('c',gt1);
[mg,fcp]=g_margin(gt1s)
[mp,fcg]=p_margin(gt1s)
gt2s=syslin('c',gt2);
clf();
bode([gs;gt1s;gc1s;gc2s;gt2s],['compensated (book)';'Compensator (book)';
'compensator';'compensated';'no compensated']);
Results:
-->[mg,fcp]=g_margin(gt1s)
fcp =
4.7720943
mg =
14.341752
-->[mp,fcg]=p_margin(gt1s)
fcg =
1.5842083
mp =
59.086358
As we see the gain margin is 14dB >10dB and phase margin is 59>50
Lets draw the unit-step response by Scilab
Scilab program:
s=%s;
g=40/(s*(s+1)*(s+4));
gc1=(s+0.2)/(s+0.02);
gc2=(s+0.5)/(s+5);
gc3=(s+0.4)*(s+0.2)/((s+4)*(s+0.02));
gt1=g*gc1*gc2;
gt2=gc3*g;
glc=g /. 1;
glc2=gt1 /. 1;
glc3=gt2 /. 1;
gs=syslin('c',glc);
gs2=syslin('c',glc2);
gs3=syslin('c',glc3);
t=0:0.1:40;
y=csim('step',t,gs);
y2=csim('step',t,gs2);
y3=csim('step',t,gs3);
clf();
subplot(2,1,1);
plot(t,y,1);
legends('no compensated',1,opt=1)
xgrid;
xtitle('Unit-step response','','y(t)')
subplot(2,1,2)
plot(t,y2,'b');
plot(t,y3,'g');
legends(['compensated';'compensated (Book)'],[2;3],opt=4);
xtitle('','t(seg)','y(t)')
xgrid;
Let's draw the ramp response by Scilab.
Scilab program:
s=%s;
g=40/(s*(s+1)*(s+4));
gc1=(s+0.2)/(s+0.02);
gc2=(s+0.5)/(s+5);
gc3=(s+0.4)*(s+0.2)/((s+4)*(s+0.02));
gt1=g*gc1*gc2;
gt2=gc3*g;
glc=g /. 1;
glc2=gt1 /. 1;
glc3=gt2 /. 1;
gs=syslin('c',glc);
gs2=syslin('c',glc2);
gs3=syslin('c',glc3);
t=0:0.1:20;
y=csim(t,t,gs);
y2=csim(t,t,gs2);
y3=csim(t,t,gs3);
clf();
subplot(2,1,1);
plot(t,y,1);
legends('no compensated',2,opt=1)
xgrid;
xtitle('Ramp response','','y(t)')
subplot(2,1,2)
plot(t,t,'r');
plot(t,y2,'b');
plot(t,y3,'g');
legends(['compensated';'compensated (Book)';'Ramp'],[2;3;5],opt=4);
xtitle('','t(seg)','y(t)')
xgrid;
|