Tuning a PID controller to desired Overshoot, settling time and rise time
277 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Sam Chak
2024 年 1 月 14 日
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')
2 件のコメント
Emmanouil Tzorakoleftherakis
2024 年 6 月 17 日
For completeness, can you maybe share how you reached to those pid gains so that the accepted answer is complete?
Thanks
Sam Chak
2025 年 6 月 19 日 12:15
Thank you for accepting my answer on behalf of the OP. The PID gains were obtained by solving the optimization problem using fmincon(). After revisiting this problem a year later, I adjusted the weights of the cost function and found a solution that yields slightly improved step performance.
For linear 2nd-order systems, achieving the desired settling time does not satisfy the rise time requirement. Thus, the rise time requirement takes precedence over the settling time. In other words, satisfying the rise time will satisfy the settling time.
For some unknown reason, systune() yields a less satisfactory solution, characterized by an oscillatory transient response, despite the TuningGoal.StepTracking being properly specified using the tau method, as demonstrated by @Paul. It is believed that systune() may be tuning the PID gains to meet internal objectives that are not known to users, aiming to achieve a balance between performance and robustness, similar to the behavior of pidtune().
%% Target Reference
zeta= 0.611315066227871; % desired damping ratio that yields target 8.83% overshoot
wn1 = 2.29352925249462; % natural frequency that yields target 2.6 s settling time
Gt1 = tf(wn1^2, [1, 2*zeta*wn1, wn1^2])
wn2 = 3.35700150674195; % natural frequency that yields target 0.561 s rise time
Gt2 = tf(wn2^2, [1, 2*zeta*wn2, wn2^2]);
%% Find optimal PID gains using fmincon
[K, fval] = fmincon(@costfcn, [-0.7 6.6 0.1], [], [])
%% Original Plant
Gp = tf(20, [1 4.5 64])
%% Classical PID
Kp = K(1);
Ki = K(2);
Kd = K(3);
Gc = pid(Kp, Ki, Kd)
%% Closed-loop system
Gcl = feedback(Gc*Gp, 1)
%% Plot results
hold on
stepplot(Gt1)
stepplot(Gt2)
stepplot(Gp)
stepplot(Gcl)
hold off
grid on
legend('Target Settling Time', 'Target Rise Time', 'Original Plant', 'PID Controller', 'location', 'east')
%% stepInfoTable
S1 = stepinfo(Gt1);
S2 = stepinfo(Gt2);
S3 = stepinfo(Gp);
S4 = stepinfo(Gcl);
stepInfoTable = struct2table([S1, S2, S3, S4]);
stepInfoTable = removevars(stepInfoTable, {'TransientTime', 'SettlingMin', 'SettlingMax', 'Undershoot', 'Peak', 'PeakTime'});
stepInfoTable.Properties.RowNames = {'Gt1', 'Gt2', 'Gp', 'Gcl'};
disp(stepInfoTable);
%% Cost function
function J = costfcn(param)
Gp = tf(20, [1 4.5 64]);
kp = param(1);
ki = param(2);
kd = param(3);
Gc = pid(kp, ki, kd);
Gcl = feedback(Gc*Gp, 1);
S = stepinfo(Gcl);
tr = S.RiseTime;
os = S.Overshoot;
Tr = 0.561; % desired Rise time
Os = 8.83; % desired Overshoot
J = 100*(tr - Tr)^2 + 50*(os - Os)^2;
end
その他の回答 (3 件)
Sam Chak
2022 年 12 月 24 日
編集済み: Sam Chak
2022 年 12 月 24 日
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 件のコメント
Paul
2022 年 12 月 27 日
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'
Sulaymon Eshkabilov
2022 年 12 月 24 日
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 件のコメント
Paul
2022 年 12 月 24 日
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)
8 件のコメント
Paul
2024 年 1 月 15 日
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')
Senol Gulgonul
2025 年 6 月 13 日 18:29
編集済み: Senol Gulgonul
2025 年 6 月 13 日 18:29
Recently I published a preprint on PID tuning for settling time and overshoot requirements by using IAE optimization at https://arxiv.org/abs/2505.17268
By using my algorithm I reached zero overshoot with Ts=2.26s
Method Kp Ki Kd Ts PO (%) IAE
SOSTIAE 0.0000 4.9777 0.1278 2.2667 0.0000 0.6429
you can set your target Ts and PO

参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!