why is my PID doing this
Show older comments
clc
clear all
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% original plant
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
s = tf('s');
% Delay = 0.5; % 1 sec pure time delay in the process
% Gp = exp(-Delay*s)/((s+1)^2); % second order system
Delay = 21.9; % 1 sec pure time delay in the process
g2 = 0.33*exp(-Delay*s)/(17.28*s + 1); % second order system
% determine settlingTime and use that to generate sufficient number of
kcu = 35;
tu = 21;
figure()
g2cl = feedback(g2,1);
step(g2,g2cl);
legend('open loop','close loop');
grid on;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% tuning
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%P Only
p1 = kcu/2;
figure()
g2p1 = g2*p1;
g2p1cl = feedback(g2p1,1);
step(g2p1,g2p1cl);
legend('open loop','close loop');
%pi
p2 = kcu/2.2;% proportional gain
i1 = tu/1.2;% integral time
con1 = p2*(1+(1/(i1*s)));
figure()
g2p2 = g2*con1;
g2p2cl = feedback(g2p2,1);
step(g2p2cl);
legend('close loop');
%PID
p3= kcu/1.7;
i2 = tu/2;
d1 = tu/8;
con2 = p3*(1+(1/(i2*s))+(d1*s));
figure()
g3p3 = g2*con2;
g3p3cl = feedback(g3p3,1);
step(g3p3cl);
legend('close loop');
%comparing the controllers
figure()
step(g3p3cl,g2p2cl,g2p1cl)
legend('PID','PI','P');

Accepted Answer
More Answers (0)
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!