%PI controller example
%Example to illustrate wind-up
delay=30;
Kc=0.0065;
tauI=244.5;
c1=Kc;
c0=Kc/tauI;
num=1.8;
den1=conv([10 1],[10 1]);
den2=conv([1 0],den1);
den=conv(den1,den2);
umax=0.0015;
umin=-0.0008;
Tsim=3000;
deltat=1;
sim('PI_Awin');
y2=y;
u2=u;
umax=0.0015;
umin=-0.0008;
sim('PIController_AD5');
figure(1)
plot(t,y)
hold on
plot(t,y2,'LineWidth',2,'Color',[.6 0 0])
set(gca,'FontSize',20,'FontName','helvetica');
legend('1','2')
xlabel('Time (sec)')
ylabel('Output')
%axis([0 1600 0 1.5])
figure(2)
plot(t,u)
hold on 
plot(t,u2,'LineWidth',2,'Color',[.6 0 0])
legend('1','2')
plot(t,umin*ones(1,length(t)),'-.',t,umax*ones(1,length(t)),'-.' )
set(gca,'FontSize',20,'FontName','helvetica');
%legend('1','2','3')
xlabel('Time (sec)')
ylabel('Control')
axis([0 3000 -1.2e-3 3e-3])

