Filter löschen
Filter löschen

Which Algorithm "pidtune()" function used for finding PID gains?

27 Ansichten (letzte 30 Tage)
Hafiz Hamza
Hafiz Hamza am 1 Aug. 2024 um 15:55
Kommentiert: Sam Chak am 1 Aug. 2024 um 21:23
I am working on tunning the PID gains for a flyback converter. I am curious about what methods out of the popular lmethods ( Ziegler–Nichols, Aström's AMIGO, Skogestad's Internal Model Control, and Chien-Hrones-Reswick) the "pidtune()" function used to give the PID gains.
I also go throw the pidtune.m file using the "edit pidtune" command in the MATLAB script to have a look what is going on inside the pidtune function. After going through several iteration line by line I am still unable to figure out the answer. To me its look like a kind of heuristic algorithm.
I am seeking assistance from all the community.
Regards

Antworten (1)

Sam Chak
Sam Chak am 1 Aug. 2024 um 16:30
The pidtune() command utilizes a proprietary algorithm for tuning the PID gains to achieve a balance between performance and robustness. If you do not specify the desired properties, namely the target phase margin and the closed-loop performance objective, for tuning a PID controller using the pidtuneOptions() command, then the algorithm will determine a crossover frequency based on the given plant dynamics, and then design for a target phase margin of 60 degrees.
  3 Kommentare
Hafiz Hamza
Hafiz Hamza am 1 Aug. 2024 um 20:14
@Sam Chak Thank you for your response. But I am confused here "proprietary algorithm".
What are these algorithms?. Yes I have my system model derived. Could you please elaborate why one should not use Ziegler–Nichols, Aström's AMIGO, Skogestad's Internal Model Control, or Chien-Hrones-Reswick methods when he/she has derived the system matehmatical model.
I shall be gratefull if you share your approach ( intellectual formulas) to determine the PID gains.
Regarding genetic algorithims how would you come up with a objective function if let suppose my system is continuously subjected to varying loads?
I am looking forwrad to your response.
Regards
Sam Chak
Sam Chak am 1 Aug. 2024 um 21:23
The "proprietary algorithm" could be utilizing the in-house 'fmincon()' algorithm or a similar optimizer to tune the PID gains until the optimization objectives are met (e.g., the target phase margin and the closed-loop performance).
You may have misinterpreted my previous comment. However, you can definitely use any of the Ziegler–Nichols, Åström's AMIGO, Skogestad's Internal Model Control, or Chien-Hrones-Reswick methods to tune the PID gains, even when the Plant's transfer function is known. These autotuning methods are model-free, reactive approaches. In other words, you inject an input signal and measure the output response. From the data analysis, you can obtain the response characteristics such as time constant, dead-time, etc.
For example, if you select the Chien-Hrones-Reswick method, these characteristics serve as the parameters to estimate the PID gains using the specified formulas that guarantee 0% (conservative) and 20% (aggressive) overshoot. No complex control design and stability proof is required!!!
Unfortunately, I am unfamiliar with the flyback converter, so I cannot comment on how to construct the objective function. However, I can share my unpublished PID formulas for 0% overshoot, if that would be helpful.
Gp = tf(20, [1 4.5 64]) % Plant's transfer function (stable)
Gp = 20 ---------------- s^2 + 4.5 s + 64 Continuous-time transfer function.
Ts = 0.561; % Desired Settling Time of the Closed-loop System
[Gc, Gh] = zeropid(Gp, Ts) % Scroll down to the end of the script
Gc = 1 Kp + Ki * --- + Kd * s s with Kp = 4.86, Ki = 17, Kd = 0.349 Continuous-time PID controller in parallel form. Gh = 0.821 s^2 + 4.094 s + 16.95 ---------------------------- 0.3487 s^2 + 4.863 s + 16.95 Continuous-time transfer function.
Gcl = feedback(Gc*Gp, Gh) % Closed-loop System
Gcl = 2.431 s^4 + 67.82 s^3 + 709.4 s^2 + 3298 s + 5749 ------------------------------------------------------------- 0.3487 s^5 + 12.16 s^4 + 169.5 s^3 + 1182 s^2 + 4122 s + 5749 Continuous-time transfer function.
S = stepinfo(Gcl) % Performances
S = struct with fields:
RiseTime: 0.3150 TransientTime: 0.5610 SettlingTime: 0.5610 SettlingMin: 0.9066 SettlingMax: 0.9999 Overshoot: 0 Undershoot: 0 Peak: 0.9999 PeakTime: 1.2900
step(Gcl, round(4*Ts, 0)), hold on
step(Gp), grid on, ylim([-0.2, 1.2])
xline(S.SettlingTime, '--', sprintf('Settling Time: %.3f sec', S.SettlingTime), 'color', '#7F7F7F', 'LabelVerticalAlignment', 'bottom')
legend('Closed-loop', 'Open-loop Plant', 'location', 'east')
%% The 0% overshoot method
function [C, H] = zeropid(P, Ts)
% Gp is a stable 2nd-order Plant
% Ts is the desired settling time
[numP, denP] = tfdata(minreal(P), 'v');
a1 = denP(2);
a2 = denP(3);
b = numP(3);
Tc = -log(0.02)/Ts; % Desired time constant
% Formulas
k1 = (3*(b^2)*((Tc/b)^2) - a2)/b;
k2 = (b^2)*((Tc/b)^3);
k3 = (3*b*(Tc/b) - a1)/b;
k4 = 2*b*((Tc/b)^2); % P-gain of PID controller
k5 = k2; % I-gain of PID controller
k6 = Tc/b; % D-gain of PID controller
% PID controller and the Compensator
C = pid(k4, k5, k6); % PID control in the forward path
H = tf([k3 k1 k2], [k6 k4 k5]); % Compensator in the feedback path
end

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by