clear close all clc s=tf('s'); t=0:0.0001:2; r=t; % Planta Gp=5/(s+0.8); figure; step(Gp); legend('Planta LA') Gplc=feedback(Gp,1); figure; step(Gplc); legend('Planta LC') zpk(Gplc) % Especificaciones xita=0.8; wn=9; Glcd=wn^2/(s^2 + 2*xita*wn*s + wn^2); % figure; step(Glcd) polos=pole(Glcd); sigma=abs(real(polos(1))); wd=imag(polos(1)); Mp1=100*exp(-pi*xita/(sqrt(1 - xita^2))); Mp2=100*exp(-pi*sigma/wd); Kp=(2*xita*wn - 0.8)/5; Ki=wn^2/5; Gc=Kp*(s + Ki/Kp)/s; zpk(Gc) zPI=Ki/Kp; Ti=1/zPI; Gla=Gc*Gp; Glc=feedback(Gla,1); zpk(Glc) [Wlc,Zlc]=damp(Glc) figure; step(Glc,Gplc,t) legend('Planta LC compensada','Planta LC no compensada') figure; step(Glc,Glcd,t) legend('Planta LC compensada','Planta LC deseada') figure; pzmap(Gplc,Glc) legend('polos y ceros LC sin PI','polos y ceros LC con PI') %% Acción de control [y,t]=step(Glc,t); ref=ones(length(t),1); error=ref - y; figure; lsim(Gc,error,t) %% Reajuste compensador % 3.1713 (s+1.24) % C = --------------- % s Kp=3.1713; cero_PI=1.24; Ki=Kp*cero_PI; Ti=Kp/Ki; Gcr=Kp*(s + cero_PI)/s; Glar=Gcr*Gp; Glcr=feedback(Glar,1); zpk(Glcr) [Wlc,Zlc]=damp(Glcr) figure; step(Glcr,Gplc,t) legend('Planta LC compensada','Planta LC no compensada') figure; step(Glcr,Glcd,t) legend('Planta LC compensada','Planta LC deseada') figure; pzmap(Gplc,Glcr) legend('polos y ceros LC sin PI','polos y ceros LC con PI') figure; pzmap(Glc,Glcr) legend('polos y ceros LC con 1er PI','polos y ceros LC con 2do PI') %% Acción de control [y,t]=step(Glcr,t); error=ref - y; figure; lsim(Gcr,error,t) close all %% Al PI reajustado se modifica la ganancia Kp para un mejor ajuste del tiempo de subida Kp=1.58; cero_PI=1.24; Ki=Kp*cero_PI; Ti=Kp/Ki; Gcr=Kp*(s + cero_PI)/s; Glar=Gcr*Gp; Glcr=feedback(Glar,1); zpk(Glcr) [Wlc,Zlc]=damp(Glcr) figure; step(Glcr,Gplc,t) legend('Planta LC compensada','Planta LC no compensada') figure; step(Glcr,Glcd,t) legend('Planta LC compensada','Planta LC deseada') figure; pzmap(Gplc,Glcr) legend('polos y ceros LC sin PI','polos y ceros LC con PI')