Tuning a PID controller to desired Overshoot, settling time and rise time
605 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Muhammad
il 24 Dic 2022
Commentato: Emmanouil Tzorakoleftherakis
il 17 Giu 2024
The uncompensated plant transfer function in this case is: as shown in the simulink model below:
I want to tune the PID so that the Rise time becomes 0.561 s, settling time becomes 2.6 s and overshoot narrows to 8.83%. However the PID tuner app is very inconvenient in this regard as it only varies the response time and transient behaviour, it is impossible to achieve the desired settling time and overshoot with such a PID tuner.
0 Commenti
Risposta accettata
Sam Chak
il 14 Gen 2024
Hi @Muhammad
I'm revisiting a control problem we encountered a year ago. Previously, we utilized the systune() method to establish PIDF gains, but the transient response exhibited significant oscillations, and the derivative term appeared unusual with an unexpectedly large time constant Tf. This time, I've discovered that a set of classical PID gains can fulfill the requirements: settling time (ts) less than 2.6, overshoot (os) of 8.83%, and a rise time (tr) of 0.561.
%% Original Plant
Gp = tf(20, [1 4.5 64]);
%% Target Reference
Gref= tf(64.9193300346851, [1, 7.93016824066555, 31.8718356679018, 64.9193300346851]);
%% Classical PID
kp = -0.733860787658412;
ki = 6.597481064703570;
kd = 0.100288660665148;
Gc = pid(kp, ki, kd);
%% Closed-loop system
Gcl = feedback(Gc*Gp, 1)
Scl = stepinfo(Gcl)
stepplot(Gref), hold on
stepplot(Gcl), grid on
stepplot(Gp), hold off
legend('Target System', 'PID Controller', 'Original Plant', 'location', 'east')
1 Commento
Emmanouil Tzorakoleftherakis
il 17 Giu 2024
For completeness, can you maybe share how you reached to those pid gains so that the accepted answer is complete?
Thanks
Più risposte (3)
Sulaymon Eshkabilov
il 24 Dic 2022
Simply double-click on PID block and its parameters window opens. Click on "Tune" button as shown in the attached screen shot - Step 1 - PID_tune_step1.jpg.
Then follow step 2 as shown in the attached file: PID_tune_step2.jpg
Alternative way is using pidtune() in MATLAB.
Good luck
0 Commenti
Paul
il 24 Dic 2022
The CST offers some tools to do this. Start from this doc page. Or from this doc page if you want to use Simulink.
Here is an example of the command line workflow. The result I got is not that good, so you'll have to make it work better to get the result you want
Define the plant model
G = tf(20,[1 4.5 64],'InputName','u','OutputName','y');
Define a tunable PID compensator
K = tunablePID('PID','PID');
K.InputName = 'e';
K.OutputName = 'u';
Create the closed loop system
S = sumblk('e = r - y');
CL0 = connect(G,K,S,'r','y');
Define a second order model response that meets the requirements for rise time, settling time, and overshoot.
Rtrack = TuningGoal.StepTracking('r','y',.30,8.8);
stepinfo(Rtrack.ReferenceModel)
CL = systune(CL0,Rtrack);
The PID controller is:
showTunable(CL)
Those negative gains look peculiar!
The closed-loop step response is
stepplot(CL)
stepinfo(CL)
7 Commenti
Sam Chak
il 15 Gen 2024
Hi @Hansi K
I'm not entirely certain about deriving the formula for when the rise time isn't measured from 0 to 100% of its final value. However, @Paul has found the inequality quite useful. If the Rise time < requirement is loosely defined, this formula provides for the exact measured from 0 to 100%:
.
In simpler terms, it ensures that will yield the Rise time < when measured from 10% to 90% or 5% to 95%. The Wendepunkt-based rise time seems to approximate the rise time measured from 10% to 90%.
The control problem presented by the OP is somewhat unique. In my opinion, the systune() tool proves to be more versatile than the pidtune() tool, especially when the Control Designer can effectively express the Reference system for a desired step response.
The pidtune() is better suited for cases, where the 0 dB gain crossover frequency () and target phase margin (pm) are precisely specified. Nonetheless, a challenge arises as not many users are familiar with the process of converting desired rise time () or settling time () into and target phase margin. Maybe there are, but I don't remember seeing related examples in the documentation.
Here is an example illustrating how the powerful systune() tool can design the PIDF controller to compensate for a slower plant, yielding an output that precisely mirrors the Reference system for a desired step response.
%% Original Plant (2nd-order system with ts ≈ 8 and os ≈ 16%)
Gp = tf(1, [1 1 1])
stepinfo(Gp)
%% Set tunable parameters in the Compensator Gc
Gc0 = tunablePID('Gc', 'PID');
%% Initial Closed-loop system (untuned)
CL0 = feedback(Gc0*Gp, 1);
CL0.InputName = 'r';
CL0.OutputName = 'y';
%% Reference system for target step response (ts < 1 & No Overshoot)
wn = 6; % this value gives Settling time under 1 sec
zeta = 1; % damping ratio 1 gives zero overshoot
Gref = tf(wn^2, [1, 2*zeta*wn, wn^2]) % I want the output to look like this!
%% Tuning goal
Req = TuningGoal.StepTracking('r', 'y', Gref);
stepinfo(Req.ReferenceModel)
%% Tune CL0 according to tuning goals specified in Req
CL = systune(CL0, Req);
CLsys = getIOTransfer(CL, 'r', 'y');
Gcl = tf(CLsys)
%% Display the values of all tunable Control parameters
showTunable(CL)
%% Show performances of tuned Closed-loop system
stepinfo(CL)
%% Plot result and comparison
subplot(211)
stepplot(Gref, 12), grid on
ylim([0 1.2])
legend('Target System', 'location', 'East')
subplot(212)
stepplot(CL), hold on, grid on
ylim([0 1.2])
stepplot(Gp), hold off
legend('PID Controller', 'Original Plant', 'location', 'East')
Paul
il 15 Gen 2024
IIRC, the approxiation tr ~ 1.8/wn applies for "intermediate" values of zeta. In this problem, the specified overshoot was 8%, which implies a zeta of around 0.62 (which sounds like it's intermediate), which happens to correspond very closes to wn = 1.8/tr.
Here's the plot (assuming wn = 5, the plot should be agnostic to the value of wn)
zeta = 0.1:.1:0.9; wn = 5;
for ii = 1:numel(zeta)
S = stepinfo(tf(wn^2,[1 2*zeta(ii)*wn wn^2]));
tr(ii) = S.RiseTime;
Mp(ii) = S.Peak - 1;
end
figure
plot(zeta,tr*wn,zeta,Mp)
xlabel('zeta')
yline([0.08 1.8])
xline(0.62)
legend('10-90 Rise Time*wn','%OverShoot/100','Location','NorthWest')
Sam Chak
il 24 Dic 2022
Modificato: Sam Chak
il 24 Dic 2022
Hi @Muhammad
This is the Root Locus compensator design approach, first attempt.
s = tf('s');
Gp = 20/(s^2 + 4.5*s + 64)
controlSystemDesigner('rlocus', Gp)
The app will show root locus of .
Fig. 1: Right-click the white area and add a new design requirement.
Fig. 2: Select Percent overshoot and insert the design value.
Fig. 3: An exclusion region is indicated by the yellow shaded area, separated from the white area by the thick black lines.
Fig. 4: Add a second design requirement, select Settling time and insert the design value.
Fig. 5: A second exclusion region overlaps with the first exclusion region. A new thick black line can also be seen.
Fig. 6: Right-click the white area, click on Edit compensator, and then add an Integrator, because the Plant is a Type-0 system.
Fig. 7: Right-click the white area, click on Edit compensator, and then add a Real Pole, placing it relatively far away from the Plant's poles
Fig. 8: Right-click the white area, click on Edit compensator, and then add the Complex Zeros to cancel out the Plant's stable Complex poles. Natural frequency , and Damping ratio .
Note: This doesn't work if the Plant is unstable.
Fig. 9: The "magenta dot markers" can be seen. The Plant's stable poles are cancelled out by the Compensator's zeros. Next, the design task is to drag one of the magenta markers (on the real axis) along the root locus until a response plot stays outside of the associated exclusion regions.
Fig. 10: The "magenta dot markers" are dragged to the breakaway point (My preference).
Fig. 11: This can also be directly adjusted through entering a design value to Compensator gain.
Fig. 12: Check the Step response if the performance is satisfactory.
Fig. 13: If satisfactory, then export the designed Compensator to Workspace. With the design values, they can be entered in the Transfer function block or zpk block in Simulink.
C = zpk(1.8*(s^2 + 4.5*s + 64)/(s*(s + 12)))
Gcl = tf(feedback(C*Gp, 1))
% Can check in MATLAB whether the design requirements are satisfied.
S = stepinfo(Gcl)
If satisfactory, find the equivalent PID gains via algebraic calculations.
% This step is unnecessary, because the Compensator works just as good!
kp = -0.125;
ki = 9.6;
kd = 77/480;
Tf = 1/12;
Cpid = pid(kp, ki, kd, Tf)
% Proof
zpk(Cpid)
5 Commenti
Paul
il 27 Dic 2022
Hi Sam,
I haven't been looking at this problem too closely, still wasn't able to get systune to give me what I wanted, but I was getting closer. Anyway, there are several ways to insert an Analysis Point into a model. See the link from the doc page you linked for some examples, maybe other doc pages as well. Here's one way, using connect
G = tf(20,[1 4.5 64],'InputName','u','OutputName','y');
K = tunablePID('PID','PID');
K.InputName = 'e';
K.OutputName = 'u';
% Create the closed loop system, include an analysis point at the error
% signal
S = sumblk('e = r - y');
CL0 = connect(G,K,S,'r','y','e')
Then, in systune, the "location" input would 'e'
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!