How do I code Ziegler-Nichols Tuning Method to find PID control constants?
35 views (last 30 days)
Show older comments
I need to use the Ziegler-Nichols Tuning rules to determine the PID control constants for the following system to meet a settling time ts ≤ 5 sec, an overshoot of Mp ≤ 50%, and zero steady state error to a unit step function input.
System: PID control = Kp((Ti*Td*s^2+Ti*s+1)/(Ti*s))
And plant open loop transfer function = 10/(2*s^3+12*s^2+22*s+12)
PID control and plant function are in series with negative feedback loop.
For PID control tuning rules are as follows, Kp=0.6*Kr, Ti=0.5*Pcr, Td=0.125*Pcr
I appreciate your help.
3 Comments
kerem
on 13 Mar 2024
transfer fonksiyonu verilen bir sistem için PID katsayıları nasıl belirleyebilirim?
Sam Chak
on 13 Mar 2024
Hi @kerem
I suggest posting a new question and providing the transfer function of the given Plant. However, it is important to note that not all types of transfer functions can be stabilized by a PID controller. PID controllers are typically most effective for linear systems of 2nd-order or lower.
Answers (1)
Sam Chak
on 7 Jul 2024
It is now time to provide a conclusion for this control problem. In the Ziegler-Nichols 2nd method, the critical gain can be determined from the Routh–Hurwitz criterion. Simulating the closed-loop system will cause the output to exhibit sustained oscillations. From the oscillations, the critical period can be found using the findpeaks() command.
While the Ziegler-Nichols-tuned PID gains do not strictly satisfy the settling time requirement, it is possible to employ a heuristic approach to quickly tune the PID gains. However, this heuristic approach may not always lead to the optimal solution.
Ziegler-Nichols Second method
%% Process Plant, Gp
s = tf('s');
Gp = 10/(2*s^3 + 12*s^2 + 22*s + 12)
%% Find Critical Gain, Kcr (determined by Routh-Hurwitz criterion)
Kcr = 12;
Gc = pid(Kcr);
Gcl = minreal(feedback(Gc*Gp, 1)); % closed-loop system
[y, t] = step(Gcl, 10);
figure(1)
plot(t, y), grid on, xlabel('t'), ylabel('y(t)'), title('Step Response')
%% Find Critical Period, Pcr
[pk, lo]= findpeaks(y, t);
Pcr = lo(2) - lo(1)
%% Apply Ziegler-Nichols Tuning Rules
Kp = 0.6*Kcr;
Ti = 0.5*Pcr;
Td = 0.125*Pcr;
%% PID controller in standard form
Gc = pidstd(Kp, Ti, Td)
%% Closed-loop system
Gcl = minreal(feedback(Gc*Gp, 1))
figure(2)
nfo = stepinfo(Gcl);
disp(nfo.SettlingTime)
disp(nfo.Overshoot)
step(Gp, 10), hold on
step(Gcl, 10), grid on, hold off
xline(nfo.SettlingTime, '--', sprintf('Settling Time: %.3f sec', nfo.SettlingTime), 'color', '#7F7F7F', 'LabelVerticalAlignment', 'bottom')
legend('Original System', 'Closed-loop System', '')
Rational number PID gains
%% PID Controller
kp = 9/10;
ki = 18/25;
kd = 1/8;
Tf = 5/12;
Gc = pid(kp, ki, kd, Tf) % PID controller
Gcl = minreal(feedback(Gc*Gp, 1)) % closed-loop system
figure(3)
step(Gp), hold on
step(Gcl), grid on
S = stepinfo(Gcl);
xline(S.SettlingTime, '--', sprintf('Settling Time: %.3f sec', S.SettlingTime), 'color', '#7F7F7F', 'LabelVerticalAlignment', 'bottom')
legend('Original System', 'Closed-loop System', '')
0 Comments
See Also
Categories
Find more on Gain Scheduling 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!