
Click the blue text above to follow us

📋📋📋 The table of contents is as follows: 🎁🎁🎁
Contents
💥1 Overview
📚2 Results
🎉3 References
🌈4 Matlab Code Implementation



1 Overview
The PID controller is the most widely used controller in industrial systems. However, properly tuning a PID controller is not easy, even though it has at most three parameters. Most PID tuning rules are based on the assumption of first-order plus dead time, which does not ensure optimal control performance. With modern optimization techniques, the PID controller can be tuned based on the actual transfer function of the plant to optimize closed-loop performance. This submission includes a function for performing optimal PID design based on four different performance indices (e.g., ISE, IAE, ITSE, and ITAE). PID controllers are the most widely applied controllers in various engineering systems. However, properly tuning a PID controller is not an easy task, despite having at most three parameters. The difficulty arises partly from the high demands placed on control system performance and partly from the complex effect of PID parameters on control performance. A second tutorial on PID tuning using stability margin is also provided.



2 Results
Compare the closed-loop performance of PID controllers designed with different performance indices.
G=zpk([],[-3 -2 -1 0],1); % The plantC1=optimPID(G,3,1); % PID-Control, ISE indexC2=optimPID(G,3,2); % PID-Control, IAE indexC3=optimPID(G,3,3); % PID-Control, ITSE indexC4=optimPID(G,3,4); % PID-Control, ITAE indexK=znpidtuning(G,3); % Ziegler-Nichols stability margin tuningt=0:0.1:30;y1=step(feedback(C1*G,1),t); %Closed-loop step response of C1y2=step(feedback(C2*G,1),t); %Closed-loop step response of C2y3=step(feedback(C3*G,1),t); %Closed-loop step response of C3y4=step(feedback(C4*G,1),t); %Closed-loop step response of C4%Closed-loop step response of Ky=step(feedback(G*(K.kc*(1+tf(1,[K.ti 0])+tf([K.td 0],1))),1),t);plot(t,y1,t,y2,t,y3,t,y4,t,y,'--','Linewidth',2)legend('ISE','IAE','ITSE','ITAE','Z-N','Location','Best')grid% The comparison shows that the ITSE index leads to the best PID% controller.




G=tf(1,[1 4 6 4 1]); % The plantC1=optimPID(G,2,1); % PID-Control, ISE indexC2=optimPID(G,2,2); % PID-Control, IAE indexC3=optimPID(G,2,3); % PID-Control, ITSE indexC4=optimPID(G,2,4); % PID-Control, ITAE indexK=znpidtuning(G,2); % Ziegler-Nichols stability margin tuningt=0:0.1:40;y1=step(feedback(C1*G,1),t); %Closed-loop step response of C1y2=step(feedback(C2*G,1),t); %Closed-loop step response of C2y3=step(feedback(C3*G,1),t); %Closed-loop step response of C3y4=step(feedback(C4*G,1),t); %Closed-loop step response of C4%Closed-loop step response of Ky=step(feedback(G*(K.kc*(1+tf(1,[K.ti 0]))),1),t);plot(t,y1,t,y2,t,y3,t,y4,t,y,'--','Linewidth',2)legend('ISE','IAE','ITSE','ITAE','Z-N','Location','Best')grid% This time the ITAE index gives the best design.




% part of the code: first let us get stability margins[Gm,Pm,Wcg]=margin(g);% If we increase the gain by the Gm, the system is critically stable. Hence% the ultimate gain in dB equals to the gain margin, i.e.% 20 * log10(ku) = Gm, hence:% ku=10^(Gm/20);% In Control System Toolbox, the gain margin is shown in dB in the graph,% but returns in normal ratio.ku=Gm;% If we increase the gain by ku, the system will ocsillate at Wcg% frequency, hencepu=2*pi/Wcg;% Controller parameters based on Ziegler-Nichols' tuning ruleswitch ctype case 1 % P-controller k.kc=ku/2; case 2 % PI-controller k.kc=ku/2.2; k.ti=pu/1.2; case 3 % PID-controller k.kc=ku/1.7; k.ti=pu/2; k.td=pu/8;end

3 References


3 References
Some theories are sourced from the internet. If there is any infringement, please contact us for removal.

[1] Song Shangfei, Liu Xuanzhang, Chen Hongju, Kang Qi, Li Chenxuan, Deng Tao, Wu Haihao, Shi Bohui, Gong Jing. The Impact of PID Control Parameters on the Production Process of Gravity Three-Phase Separator [J]. Petroleum Science Bulletin, 2023, 8(02):179-192.
[2] Yi Cao (2023). Learning PID Tuning III: Performance Index Optimization.



4 Matlab Code Implementation
