Program in Scilab:
s=%s;
g=4/(s*(s+0.5));
s1=-2.5+5*sqrt(1-0.5^2)*%i;
gs=syslin('c',g);
//angle's system in dominant pole s1
gs1=horner(gs,s1);
angulo=180-360*atan(abs(imag(gs1))/abs(real(gs1)))/(2*%pi)
angulocorregir=180-angulo
//lead-pole
l=imag(s1)*tan(2*%pi*angulocorregir/360);
p1=-2.5-l;
z1=-2.5;
gc=(s-z1)/(s-p1)
//the gain of compensator
gma=p1/z1;
gt=gc*g;
aux1=(abs(horner(gt,s1)));
kc=1/aux1
//lag compensator
gct=kc*gc;
gt2=kc*gt;
aux3=s*gt2;
aux4=horner(aux3,0);
b=80/aux4
gc2=(s+(1/5))/(s+(1/(5*b)))
//Check results
aux5=horner(gc2,s1);
aux6=abs(aux5)
angulo2=-360*atan(abs(imag(aux5))/abs(real(aux5)))/(2*%pi)
//Draw responses
gt3=gc2*gt2;
gct2=6.26*((s+0.5)/(s+5.02))*((s+0.2)/(s+0.01247));
gt4=g*gct2;
gct3=10*((s+2.38)/(s+8.34))*((s+0.1)/(s+0.0285));
gt5=g*gct3;
t=0:0.01:5;
glc=g /. 1;
glc1=gt3 /. 1;
glc2=gt4 /. 1;
glc3=gt5 /. 1;
y=csim('step',t,glc);
y1=csim('step',t,glc1);
y2=csim('step',t,glc2);
y3=csim('step',t,glc3);
clf;
plot(t,y,'k');
plot(t,y1,'g');
plot(t,y2,'b');
plot(t,y3,'c');
legend(['no compensate';'compensate';'compensate book 7.3'
;'compensate book 7.4']);
xtitle('response to unit-step input',
't','output');
xgrid;
Let us draw the response to unit-ramp.
let us add more code lines:
y=csim(t,t,glc);
y1=csim(t,t,glc1);
y2=csim(t,t,glc2);
y3=csim(t,t,glc3);
clf;
plot(t,t,'r');
plot(t,y,'k');
plot(t,y1,'g');
plot(t,y2,'b');
plot(t,y3,'c');
legend(['unit-ramp';'no compensated';'compensated'
;'compensated book 7.3';'compensated book 7.4'],style=4);
xtitle('Response to unit-ramp input'
,'t','salida');
xgrid;
|
|