why is my PID doing this
조회 수: 1 (최근 30일)
이전 댓글 표시
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');
댓글 수: 0
채택된 답변
Mathieu NOE
2020년 10월 26일
hi
I found that you have too much loop gain and therefore your are unstable - maybe before closing the loop you should look at the opel loop gain first and check stability margins. I let you do this
For just the sake of the demo, I reduced the unity feedback gain to lower values so that it remains stable.
example : P regulator :
g2p1cl = feedback(g2p1,2/p1); instead of g2p1cl = feedback(g2p1,1);
same for PI and PID
I also tweaked a bit your PID coefficients. I do not pretend that this is optimal PID design but I just suggest a few ideas to test...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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,2/p1);
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,2/p2);
step(g2p2cl);
legend('close loop');
%PID
% p3= kcu/1.7;
% i2 = tu/2;
% d1 = tu/8;
p3= kcu/1.7;
i2 = tu;
d1 = tu/6;
con2 = p3*(1+(1/(i2*s))+(d1*s));
figure()
g3p3 = g2*con2;
g3p3cl = feedback(g3p3,2/p3);
step(g3p3cl);
legend('close loop');
%comparing the controllers
figure()
step(g3p3cl,g2p2cl,g2p1cl)
legend('PID','PI','P');
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 PID Controller Tuning에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!