Lab Program
Lab Program
n=[0 10];
d=[1 1];
a= tf(n,d);
y=step(a);
plot(y)
xlabel('Time')
ylabel('Amplitude')
title('Step response of 1st order system without delay')
%t=0:0.5:50;
t=0:0.01:500;
n1=[0 2];
d1=[10 1];
Kp = 2.25;
[nc,dc]= cloop (Kp*n1,d1);
y=step(nc,dc,t);
%subplot(2,2,1);
%plot(t,y);
xlabel('Time');
ylabel('Amplitude');
title('P-Controller');
Kp1 = 2.25;
Kil = 2.025;
n2=[Kp1 Kil];
d2=[1 0];
[nc1,dc1] = cloop(conv(n1,n2),conv(d1,d2));
y1=step(nc1,dc1,t);
%subplot(2,2,2); %plot(t,y1);
xlabel('Time');
ylabel('Amplitude');
title('PI-Controller');
Kp2 = 2.25;
Ki2 = 2.825;
Kd2 = 2.655;
n3=[Kd2 Kp2 Ki2];
d3=[0 1 0];
[nc2,dc2] = cloop(conv(n1,n3),conv(d1,d3));
y2=step(nc2,dc2,t);
%subplot(2,2,3);
%plot(t,y2);
xlabel('Time');
ylabel('Amplitude');
title('PID-Controller');
%subplot(2,2,4);
plot(t,y,'r',t,y1,'b',t,y2,'g');
xlabel('Time');
ylabel('Amplitude');
title('P,PI,PID RESPONSE');