Tuning a PID controller to desired Overshoot, settling time and rise time

718 次查看(过去 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.

采纳的回答

Sam Chak
Sam Chak 2024-1-14
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)
Gcl = 2.006 s^2 - 14.68 s + 131.9 --------------------------------- s^3 + 6.506 s^2 + 49.32 s + 131.9 Continuous-time transfer function.
Scl = stepinfo(Gcl)
Scl = struct with fields:
RiseTime: 0.5610 TransientTime: 2.0757 SettlingTime: 2.0757 SettlingMin: 0.9003 SettlingMax: 1.0883 Overshoot: 8.8301 Undershoot: 0 Peak: 1.0883 PeakTime: 0.9200
stepplot(Gref), hold on
stepplot(Gcl), grid on
stepplot(Gp), hold off
legend('Target System', 'PID Controller', 'Original Plant', 'location', 'east')

更多回答(3 个)

Sam Chak
Sam Chak 2022-12-24
编辑:Sam Chak 2022-12-24
This is the Root Locus compensator design approach, first attempt.
s = tf('s');
Gp = 20/(s^2 + 4.5*s + 64)
Gp = 20 ---------------- s^2 + 4.5 s + 64 Continuous-time transfer function.
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)))
C = 1.8 (s^2 + 4.5s + 64) --------------------- s (s+12) Continuous-time zero/pole/gain model.
Gcl = tf(feedback(C*Gp, 1))
Gcl = 36 s^2 + 162 s + 2304 --------------------------------------- s^4 + 16.5 s^3 + 154 s^2 + 930 s + 2304 Continuous-time transfer function.
% Can check in MATLAB whether the design requirements are satisfied.
S = stepinfo(Gcl)
S = struct with fields:
RiseTime: 0.5599 TransientTime: 0.9725 SettlingTime: 0.9725 SettlingMin: 0.9055 SettlingMax: 1.0000 Overshoot: 0 Undershoot: 0 Peak: 1.0000 PeakTime: 2.1337
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)
Gpid = 1 s Kp + Ki * --- + Kd * -------- s Tf*s+1 with Kp = -0.125, Ki = 9.6, Kd = 0.16, Tf = 0.0833 Continuous-time PIDF controller in parallel form.
% Proof
zpk(Cpid)
ans = 1.8 (s^2 + 4.5s + 64) --------------------- s (s+12) Continuous-time zero/pole/gain model.
  5 个评论
Paul
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')
CL0 = Generalized continuous-time state-space model with 1 outputs, 1 inputs, 3 states, and the following blocks: AnalysisPoints_: Analysis point, 1 channels, 1 occurrences. PID: Tunable PID controller, 1 occurrences. Type "ss(CL0)" to see the current value, "get(CL0)" to see all properties, and "CL0.Blocks" to interact with the blocks.
Then, in systune, the "location" input would 'e'

请先登录,再进行评论。


Sulaymon Eshkabilov
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

Paul
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)
ans = struct with fields:
RiseTime: 0.5654 TransientTime: 1.7893 SettlingTime: 1.7893 SettlingMin: 0.9077 SettlingMax: 1.0880 Overshoot: 8.7988 Undershoot: 0 Peak: 1.0880 PeakTime: 1.1967
Use systune to design the PID gains
CL = systune(CL0,Rtrack);
Final: Soft = 3.09, Hard = -Inf, Iterations = 44
The PID controller is:
showTunable(CL)
PID = 1 s Kp + Ki * --- + Kd * -------- s Tf*s+1 with Kp = -0.101, Ki = 6.45, Kd = -23.9, Tf = 1.37e+04 Name: PID Continuous-time PIDF controller in parallel form.
Those negative gains look peculiar!
The closed-loop step response is
stepplot(CL)
stepinfo(CL)
ans = struct with fields:
RiseTime: 0.4233 TransientTime: 2.0735 SettlingTime: 2.0735 SettlingMin: 0.8039 SettlingMax: 1.0237 Overshoot: 2.3675 Undershoot: 0.0210 Peak: 1.0237 PeakTime: 1.5024
Presumably there are other Tuning Goals that can be applied to get the desired response.
  7 个评论
Sam Chak
Sam Chak 2024-1-15
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])
Gp = 1 ----------- s^2 + s + 1 Continuous-time transfer function.
stepinfo(Gp)
ans = struct with fields:
RiseTime: 1.6390 TransientTime: 8.0759 SettlingTime: 8.0759 SettlingMin: 0.9315 SettlingMax: 1.1629 Overshoot: 16.2929 Undershoot: 0 Peak: 1.1629 PeakTime: 3.5920
%% 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!
Gref = 36 --------------- s^2 + 12 s + 36 Continuous-time transfer function.
%% Tuning goal
Req = TuningGoal.StepTracking('r', 'y', Gref);
stepinfo(Req.ReferenceModel)
ans = struct with fields:
RiseTime: 0.5597 TransientTime: 0.9724 SettlingTime: 0.9724 SettlingMin: 0.9019 SettlingMax: 0.9999 Overshoot: 0 Undershoot: 0 Peak: 0.9999 PeakTime: 1.9879
%% Tune CL0 according to tuning goals specified in Req
CL = systune(CL0, Req);
Final: Soft = 7.96e-13, Hard = -Inf, Iterations = 96
CLsys = getIOTransfer(CL, 'r', 'y');
Gcl = tf(CLsys)
Gcl = From input "r" to output "y": 36 s^2 + 36 s + 36 --------------------------------- s^4 + 13 s^3 + 49 s^2 + 48 s + 36 Continuous-time transfer function.
%% Display the values of all tunable Control parameters
showTunable(CL)
Gc = 1 s Kp + Ki * --- + Kd * -------- s Tf*s+1 with Kp = 2.75, Ki = 3, Kd = 2.77, Tf = 0.0833 Name: Gc Continuous-time PIDF controller in parallel form.
%% Show performances of tuned Closed-loop system
stepinfo(CL)
ans = struct with fields:
RiseTime: 0.5597 TransientTime: 0.9724 SettlingTime: 0.9724 SettlingMin: 0.9019 SettlingMax: 0.9999 Overshoot: 0 Undershoot: 0 Peak: 0.9999 PeakTime: 1.9879
%% 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
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')

请先登录,再进行评论。

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by