You are on page 1of 10

clc

close all
clear all
% -----------------------------------------
% Lag-Lead Ball and bema
% -----------------------------------------
os=20;
%---------------------- Matriz Linealizada A -------------
A=[0, 1, 0, 0 ;...
0, 0, (-9.7504), 0 ;...
0, 0, 0, 1;...
(-917.1669), 0, 0, 0]

A =
1.0e+02 *

0 0.010000000000000 0 0
0 0 -0.097504000000000 0
0 0 0 0.010000000000000
-9.171669000000001 0 0 0

%---------------------- Matriz Linealizada B -------------


B=[0 ;...
0 ;...
0 ;...
(244.9960)]

B =
1.0e+02 *

0
0
0
2.449960000000000

%---------------------- Matriz Linealizada C -------------


C=[1 0 0 0]

C =
1 0 0 0

% Aoz=[0 1 0 0;...
% 0 0 1 0;...
% 0 0 0 1;...
% 9.7245789 -9.72458 (9.7245*i) (-9.7245*i)];
[num,dem]=ss2tf(A,B,C,0);
Tf=zpk(tf(num,dem))

Tf =

-2388.8
---------------------------------

1
(s+9.725) (s-9.725) (s^2 + 94.57)

Continuous-time zero/pole/gain model.

p1=9.725;
p2=-9.725;
p3=0;
p4=0;

% os=exp(-pi*zita/(sqrt(1-zita^2)))*100;
zita=-log(os/100)/sqrt(pi^2+log(os/100)^2)

zita =
0.455949810769126

theta=acos(zita)*180/pi

theta =
62.873936608351372

[wnx,kx]=CondMagAng([],[p1 p2 p3 p4],zita)

Warning: Unable to solve symbolically. Returning a numeric approximation instead.


wnx =
-4.233815823226547e+247
kx =
5.917336500256872e+03 + 1.438889177784784e+00i

G0=zpk([],[-p1 -p2 -p3 -p4],[-2388.8])

G0 =

-2388.8
-----------------------
s^2 (s+9.725) (s-9.725)

Continuous-time zero/pole/gain model.

figure
rlocus(G0)

2
% Raices en lazo cerrado
k0=kx;
s=sym('s');
PC0=(s+p1)*(s+p2)*(s+p3)*(s+p4)+k0;
U=double(solve(PC0==0,s))

U =
7.880129839579492 + 3.849739153399457i
7.881344644062088 - 3.849145767297011i
-7.880129839579492 - 3.849739153399457i
-7.881344644062088 + 3.849145767297011i

% Punto de diseno
sigma0=-wnx*zita

sigma0 =
1.930407523431476e+247

wd0=-wnx*sqrt(1-zita^2)

wd0 =
3.768119321157789e+247

ts0=4/sigma0;

3
tsN=ts0/2;
sigmaN=4/tsN

sigmaN =
3.860815046862952e+247

wdN=sigmaN*tan(theta*pi/180)

wdN =
7.536238642315580e+247

% Diseno compensador de adelanto (Lead)


zlead=9.725;
angGsN=GsdAngle([zlead],[p1 p2 p3 p4],sigmaN,wdN);

thetaLead=-180-angGsN

thetaLead =
1.713781901749459e+02

plead=(wdN+sigmaN*tan(-thetaLead*pi/180))/tan(-thetaLead*pi/180)

plead =
5.356390186817099e+248

[wnx,kx]=CondMagAng([zlead],[p1 p2 p3 p4 plead],zita)

Warning: Unable to find explicit solution. For options, see help.


wnx =

0×1 empty double column vector

kx =

0×1 empty double column vector

GLead=zpk([-zlead],[-p1 -p2 -p3 -p4 -plead],[-2388.8])

GLead =

-2388.8 (s+9.725)
-------------------------------------
s^2 (s+9.725) (s-9.725) (s+5.356e248)

Continuous-time zero/pole/gain model.

figure
rlocus(GLead)

Warning: Accuracy may be poor in parts of the frequency range. Use the "prescale" command to maximize
accuracy in the range of interest.

4
% Punto de diseno
sigmaN_lead=-wnx*zita

sigmaN_lead =

0×1 empty double column vector

wdN_lead=-wnx*sqrt(1-zita^2)

wdN_lead =

0×1 empty double column vector

% Raices en lazo cerrado


klead=kx

klead =

0×1 empty double column vector

PCLead=(s+p1)*(s+p2)*(s+p3)*(s+p4)*(s+plead)+klead*(s+zlead);
% U=double(solve(PCLead==0,s))
% Respuesta del sistema
figure
impulse(feedback(series(double(k0),G0),1))

Warning: The data cannot be plotted because it is not real valued.

5
% hold on
% impulse(feedback(series(double(klead),GLead),1))

% Diseno compensador de atraso (Lag)


% dado que la funcion no compensada G0 es:
% -2388.9
% -----------------------
% s^2 (s+9.725) (s-9.725)
kv0=k0/prod([p2 p1])

kv0 =
-62.567247113163383 - 0.015214165148629i

% dado que la funcion lead compensada GLead es:


% (s+9.725) klead
% ------------------------
% s^2 (s+9.725) (s-9.725) (s+5.325e+248)
kvlead=klead*prod([zlead])/prod([p2 p1 plead])

kvlead =

0×1 empty double column vector

% el errorss ha mejorado en
factorss_0lead=kvlead/kv0

6
factorss_0lead =

0×1 empty double column vector

factorss_0leadlag=10;
factorss_leadlag=factorss_0leadlag/factorss_0lead

factorss_leadlag =

1×0 empty double row vector

plag=0.01;
zlag=plag*factorss_leadlag;

[wnx,kx]=CondMagAng([zlead zlag],[p1 p2 p3 p4 plead plag],zita)

Warning: Unable to find explicit solution. For options, see help.


wnx =

0×1 empty double column vector

kx =

0×1 empty double column vector

GLeadLag=zpk([-zlead -zlag],[-p1 -p2 -p3 -p4 -plead -plag],[-2388.8])

GLeadLag =

-2388.8 (s+9.725)
----------------------------------------------
s^2 (s+9.725) (s-9.725) (s+0.01) (s+5.356e248)

Continuous-time zero/pole/gain model.

figure
rlocus(GLeadLag)

Warning: Accuracy may be poor in parts of the frequency range. Use the "prescale" command to maximize
accuracy in the range of interest.

7
% Punto de diseno
sigmaN_leadlag=-wnx*zita

sigmaN_leadlag =

0×1 empty double column vector

wdN_leadlag=-wnx*sqrt(1-zita^2)

wdN_leadlag =

0×1 empty double column vector

% Raices en lazo cerrado


kleadlag=kx;
PCLeadLag=(s+p1)*(s+p2)*(s+p3)*(s+p4)*(s+plead)*(s+plag)+kleadlag*(s+zlead)*(s+zlag);
% double(solve(PCLeadLag==0,s))

kvleadlag=kleadlag*prod([zlead zlag])/prod([p2 p1 plead plag])

kvleadlag =

0×1 empty double column vector

% Respuesta del sistema

8
figure
step(feedback(series(double(k0),G0),1),100)

Warning: The data cannot be plotted because it is not real valued.

% hold on
% step(feedback(series(double(kleadlag),GLeadLag),1),100)
% step(feedback(series(double(klead),GLead),1),100)

GI=zpk([],[0],[1]);
figure
step(series(GI,feedback(series(double(k0),G0),1)),100)

Warning: The data cannot be plotted because it is not real valued.

9
% hold on
% step(series(GI,feedback(series(double(kleadlag),GLeadLag),1)),100)
% step(series(GI,feedback(series(double(klead),GLead),1)),100)

10

You might also like