Vous êtes sur la page 1sur 4

Teoría de control 2

disp(' Dinamica de um tanque de Nível')


clc
clear all
close all
%Variables del tanque
k1=0.05;k2=0.015;g=10;
A=0.5;
a1=0.0:0.1:1; %Avertura da valvula de entrada
a2=0:0.1:1; %Avertura da valvula de Saida
k=1;

A1o=0.6; %Avertura da Valvula en el Punto de equlibrio


A2o=0.5; %Avertura da valvula de salida
Ho=(k1^2*A1o^2)/(k2^2*A2o^2*2*g);

for i=1:11
hA1(i)=(k1^2*a1(i)^2)/(k2^2*A2o^2*2*g);
hA2(i)=(k1^2*A1o^2)/(k2^2*a2(i)^2*2*g);
k=k+1;
end
figure
t=0:0.1:1;
subplot(2,1,1);
plot(t,hA1),grid
axis([0 1 0 1]);
title('Variacion en la valvula de entrada a1');
ylabel('Altura (h)');
xlabel('Abertura da Valvula a1');
subplot(2,1,2);
plot(t,hA2),grid
axis([0 1 0 1]);
title('Variacion de la valvula de entrada a2');
ylabel('Altura (h)');
xlabel('Abertura da Valvula a2');

%% Processo de Simulação
tsim=400; %tempo de simulaion
tA1=100; %tiempo en que varia a1
tA2=250; %tiempo en que varia a2

dA1=0.5; %variacion de a1
dA2=0.05; %variacion de a2
simulando
sim('tanque1');
%resultados prsentados en graficas
figure
subplot(3,1,1);
plot(t,rY(:,1),t,rY(:,3)),grid
title('Nível do Tanque');
ylabel('Altura (h)');
xlabel('Tempo (s)');
legend('Não Linear','Linear');

subplot(3,1,2);
plot(t,rY(:,2)),grid
title('Abertura em a1');
ylabel('% a1');
xlabel('Tempo (s)');
subplot(3,1,3);
plot(t,rY(:,4)),grid
title('Abertura em a2');
ylabel('% a2');
xlabel('Tempo (s)');
clc

%Controle Proporcional
tsim=120; %tempo de simulacion

ref= [1 0.6 0.2 0.9 0.9]'; %Referencias

per=[0.5 0.85]'; %Perturbaciones


tper=90;

Kc=100;
%Simulacion
sim('tanque_Kc');
%Grafica dos resultados
figure
subplot(2,1,1);
plot(t,rY(:,1),t,rY(:,2)),grid
title('Controle Kc=100');
ylabel('Altura (h)');
xlabel('Tempo (s)');
subplot(2,1,2);
plot(t,rY(:,3)),grid
ylabel('Abertura A2');
xlabel('Tempo (s)');

%Controle PI
Tau=A/((k2*A2o*sqrt(2*g))/(2*sqrt(Ho)));
Kp=k1/((k2*A2o*sqrt(2*g))/(2*sqrt(Ho)));

Tr=Tau/5;

Ti=Tau;
Kc=Ti/(Kp*Tr);

tsim=500; %tempo de simulacion

ref= [0.8 0.6 0.7 0.65 0.65]'; %Referencias

per=[0.5 0.80]'; %Perturbacion


tper=350;

%simulacion
sim('tanque_PI_Can');
%Grafica dos resultados
figure
subplot(3,1,1);
plot(t,rY(:,1),t,rY(:,2)),grid
title('Controle PI Cancelamento');
ylabel('Altura (h)');
xlabel('Tempo (s)');
subplot(3,1,2);
plot(t,rY(:,4)),grid
ylabel('Controle');
xlabel('Tempo (s)')
subplot(3,1,3);
plot(t,rY(:,3)),grid
ylabel('Abertura A2');
xlabel('Tempo (s)')

C=tf(Kc*[Ti 1],[Ti 0]);


P=tf(0.1,[1 0.0375]);
Q=tf(-0.12,[1 0.0375]);

YR=minreal((C*P)/(1+C*P));
YQ=minreal((Q)/(1+C*P));
figure
subplot(2,2,1)
pzmap(YR);
title('DPZ_R');
subplot(2,2,2)
rlocus(YR);
subplot(2,2,3)
pzmap(YQ);
title('DPZ_Q');
subplot(2,2,4)
rlocus(YQ);

%Controle por localizacion de polos


% Calculo do controlador

TsMA=(Tau*3)/5; %Tempo de acomodação MA (Sistema de Primera


Ordem)
ep=1; %Coeficente de amortiguamiento
Wn=3/(ep*TsMA); %Frequência Natural
Sd=[-ep*Wn+1i*Wn*sqrt(1-ep^2), -ep*Wn-1i*Wn*sqrt(1-ep^2)];
Pds=poly(Sd);

Kc=(Pds(2)*Tau-1)/Kp; %Calculo de Kc
Ti=(Kp*Kc)/(Pds(3)*Tau); %Calculo de ti

%simulacion
sim('tanque_PI_Can');
%Grafica dos resultados
figure
subplot(3,1,1);
plot(t,rY(:,1),t,rY(:,2)),grid
title('Control PI Polos Raicess Igualess');
ylabel('Altura (h)');
xlabel('Tempo (s)');
subplot(3,1,2);
plot(t,rY(:,4)),grid
ylabel('Control');
xlabel('Tiempo (s)')
subplot(3,1,3);
plot(t,rY(:,3)),grid
ylabel('Abertura A2');
xlabel('Tiempo (s)')

C=tf(Kc*[Ti 1],[Ti 0]);


P=tf(0.1,[1 0.0375]);
Q=tf(-0.12,[1 0.0375]);

YR=minreal((C*P)/(1+C*P));
YQ=minreal((Q)/(1+C*P));
figure
subplot(2,2,1)
pzmap(YR);
title('DPZ_R');
subplot(2,2,2)
rlocus(YR);
subplot(2,2,3)
pzmap(YQ);
title('DPZ_Q');
subplot(2,2,4)
rlocus(YQ);

Vous aimerez peut-être aussi