You are on page 1of 10

clc,clear all;

num=input('Ingrese el Numerador: ');


den=input('Ingrese el Denominador: ');
%KVc=0; %KVc=input('Ingrese el Coef. de Error Estatico: ');
disp('Escriba: 1 , si va ingresar el Polo')
disp('Escriba: 2 , si va ingresar Z y Wn')
dat=input('Escriba: 3 , si va ingresar Mp (%) y tss: ');
if dat==1
sd=input('Ingrese el Polo Deseado: ');
o=real(sd);
Wd=imag(sd);
Z=sqrt(o^2/(Wd^2+o^2));
Wn=-o/Z;
end
COMPENSADORES=[];
PlantaLA=tf(num,den)
PlantaLA1=PlantaLA;
Realim=1;
PlantaLC=feedback(PlantaLA,Realim)
PlantaLC1=PlantaLC;
disp('Parametros Actuales: Sin Compensar
')
[Wn1,Z1,P1]=damp(PlantaLC); %POLOS DOMINANTES ACTUALES
clear x
syms x
numsim=poly2sym(num);

densim=poly2sym(den);
GsNoComp=x*numsim/densim;
KVnc=limit(GsNoComp,x,0);
KVnc=double(KVnc);
disp('
Polos
Wn
Z')
disp([P1,Wn1,Z1])
figure (1), rlocus(PlantaLA),grid ,title('Lugar de Raices: SIN
COMPENSAR')
figure (2), step(PlantaLC),grid, title('Respuesta ante Entrada
Escalon: SIN COMPENSAR')
figure (3)
a1=[1];
a2=[1 0]
cer=tf(a1,a2);
hold off
a=0:1:100; plot(a,a,'r'),grid,hold on,
step(series(PlantaLC,cer)),grid, hold off , axis([0 100 0 100]),
legend('Entrada','Salida')
disp('Parametros Deseados: Compensado
')
disp('
Polos
Wn
Z')
disp([sd,Wn,Z;conj(sd),Wn,Z])
figure (1), hold on, plot(sd,'or')
axis auto
hold off
disp('PASO 3: Deficiencia Angular:
')
[z,p,k]=tf2zp(num,den);
disp('ANGULOS CON LOS CEROS
')
SumAngCeros=0; % Suma de los angulos con los ceros (inicializacion)
for g=1:length(z)
th=angle(sd-z(g))*180/pi;
disp([' theta=', num2str(th)]);
SumAngCeros=SumAngCeros+th;
end
disp(['phiC=', num2str(SumAngCeros)]);
disp('ANGULOS CON LOS POLOS
')
SumAngPolos=0; % Suma de los angulos con los polos (inicializacion)
for h=1:length(p)
Th=angle(sd-p(h))*180/pi;
disp(['
theta=', num2str(Th)]);
SumAngPolos=SumAngPolos+Th;
end
disp('
-----------------')
disp(['
phiP =', num2str(SumAngPolos)]);
disp('DEFICIENCIA ANGULAR: ')
phi=-180-(SumAngCeros-SumAngPolos)
MPS=Inf;
if and(-270<=SumAngCeros-SumAngPolos,SumAngCeros-SumAngPolos<-180)
dsz=imag(sd)/tand(phi); SZERO=real(sd)-abs(dsz);
numc=[1 -SZERO]; denc=[1];
Kcz=deconv(conv(denc,den),conv(numc,num)); Kcz=abs(polyval(Kcz,sd));
numco=conv(numc,num); denco=conv(denc,den);
PlantaCZLA=Kcz*tf(numco,denco); PlantaCZLC=feedback(PlantaCZLA,1);
escalsz=stepinfo(PlantaCZLC); % informacion de la entrada escalon
Mpsz=escalsz.Overshoot; MPS=Mpsz;
tsssz=escalsz.SettlingTime;
figure (8)
rlocus(PlantaLA,PlantaCZLA), legend('SIN
COMPENSAR','COMPENSADO'),sgrid(Z,Wn)
title('GRAFICAS COMPENSANDO SOLO CON UN CERO')

figure (9)
step(PlantaLC,PlantaCZLC), legend('SIN
COMPENSAR','COMPENSADO'),grid
title('Entrada Escalon')
figure (10)
step(series(PlantaLC,cer),series(PlantaCZLC,cer)),hold
on,a=0:0.1:10;plot(a,a,'r'),grid,axis([0 40 0 40]),hold off,
legend('SIN COMPENSAR','COMPENSADO', 'ENTRADA RAMPA')
title('Entrada Rampa')
end
if abs(SumAngCeros-SumAngPolos)==180
disp('El Polo Deseado YA PASA POR El LUGAR DE RAICES')
end
if sign(phi)==1
disp('ESTA FUNCION DE TRANSFERENCIA SE COMPENSARA POR ADELANTO')
a=[]; % Matriz de Overshoots, para escojer el menor
b=[]; % Matriz de Settlingtimes, para escojer el menor
z=[]; % Zeros
p=[]; % Polos
for c=0.1:0.1:10 % VALOR PARA "EL" O LOS CEROS desde 0.1 hasta 10
zero=-c;
thz=180-angle(sd-zero)*180/pi; % ANGULO DENTRO DEL TRIANGULO
thp=180-(phi+thz);
dz=abs(sd-zero);
dpz=sind(phi)*dz/(sind(thp));
if abs(dpz)+c<abs(real(sd))
polo=real(sd)-c;
zero=polo+dpz;
else
zero=-c;
polo=zero-dpz;
end
numc=[1 -zero]; denc=[1 -polo];
Kc=deconv(conv(denc,den),conv(numc,num));

Kc=abs(polyval(Kc,sd));

compn=tf(Kc*[1 -zero],[1 -polo]);


sysc=series(PlantaLA,compn);
sysclc=feedback(sysc,1);
esca=stepinfo(sysclc); % informacion de la entrada escalon
transitorio=esca.Overshoot;
if transitorio==0
transitorio=1000;
end
tss=esca.SettlingTime;
b=[b,tss]; % Tiempos de establecimiento
a=[a,transitorio]; % Sobrepasos
z=[z,zero];
p=[p,polo];
end

Ingrese el Numerador: [2 0.1]

Ingrese el Denominador: [1 0.1 4 0]


Escriba: 1 , si va ingresar el Polo
Escriba: 2 , si va ingresar Z y Wn
Escriba: 3 , si va ingresar Mp (%) y tss: 1
Ingrese el Polo Deseado: -2+i*2*sqrt(3)

Transfer function:
2 s + 0.1
------------------s^3 + 0.1 s^2 + 4 s

Transfer function:
2 s + 0.1
------------------------s^3 + 0.1 s^2 + 6 s + 0.1

Parametros Actuales: Sin Compensar


Polos
-0.0167

Wn

0.0167

1.0000

-0.0417 + 2.4489i 2.4492

0.0170

-0.0417 - 2.4489i 2.4492

0.0170

a2 =

Parametros Deseados: Compensado


Polos

Wn

-2.0000 + 3.4641i 4.0000


-2.0000 - 3.4641i 4.0000

Z
0.5000
0.5000

PASO 3: Deficiencia Angular:


ANGULOS CON LOS CEROS
theta=119.3759
phiC=119.3759
ANGULOS CON LOS POLOS
theta=120
theta=143.0883
theta=109.6423
----------------phiP =372.7305
DEFICIENCIA ANGULAR:

phi =

73.3546

ESTA FUNCION DE TRANSFERENCIA SE COMPENSARA POR ADELANTO

You might also like