How to implement PID anti-windup in my m-file (i.e., without using Simulink)

10 ビュー (過去 30 日間)
Ali
Ali 2020 年 9 月 12 日
回答済み: Sam Chak 2022 年 8 月 20 日
Hi everyone,
I'm working on my own MATLAB PID code that should be initiated within an external algorithm coded as a function in another m-file.
The PID part (without anti-windup) looks like this one:
%% Initialization stage
clc
clear
s = tf('s');
t = (0:0.05:30)';
opt = stepDataOptions('InputOffset', Offset, 'StepAmplitude', 1);
OLTF = 1/(1.2 * s + 1); % open-loop
%% Defining "closed-loop":
Gm = 1/(0.1*s + 1);
Kp = 3.71580598721178; % proportional gain
Ki = 3.30711176584135; % integral gain
Kd = 1.80393204651312; % derivative gain
TauD = 0.0; % derivative low-pass filter time constant
Gc = Kp + Ki/s + Kd*s / (TauD * s + 1); % controller transfer function
CLTF = feedback(Gc * OLTF, Gm); % closed-loop
%% Defining system responses
y = step(CLTF, t, opt);
I'm struggling to implement anti-windup in this m-file code.
I think there is one approach by thinking of it as a parallel transfer function, but I don't have any clue!
Any help is highly appreciated .. Thank you so much

回答 (1 件)

Sam Chak
Sam Chak 2022 年 8 月 20 日
Hi @Ali
Not sure if you are still interested. If the output of is within the range of the actuator, then the anti-windup is probably not needed. Instead of letting , assign a positive value should do the trick. The selected PID gains remain unchanged. is assigned.
The response looks pretty fast when compared to the previous . If the range of the actuator is within , then no saturation occurs.
%% Initialization stage
s = tf('s');
t = (0:0.05:5)';
% opt = stepDataOptions('InputOffset', Offset, 'StepAmplitude', 1);
OLTF = 1/(1.2 * s + 1); % open-loop
%% Defining "closed-loop":
Gm = 1/(0.1*s + 1);
Kp = 3.71580598721178; % proportional gain
Ki = 3.30711176584135; % integral gain
Kd = 1.80393204651312; % derivative gain
TauD = 1e2; % derivative low-pass filter time constant
Gc = Kp + Ki/s + Kd*s/(TauD*s + 1) % controller transfer function
Gc = 373.4 s^2 + 334.4 s + 3.307 --------------------------- 100 s^2 + s Continuous-time transfer function.
CLTF = minreal(feedback(Gc*OLTF, Gm)) % closed-loop
CLTF = 3.112 s^3 + 33.9 s^2 + 27.9 s + 0.2756 ---------------------------------------------- s^4 + 10.84 s^3 + 39.56 s^2 + 27.95 s + 0.2756 Continuous-time transfer function.
%% Defining system responses
% y = step(CLTF, t, opt);
step(CLTF, t)
S = stepinfo(CLTF)
S = struct with fields:
RiseTime: 0.4323 TransientTime: 0.6408 SettlingTime: 0.6408 SettlingMin: 0.9059 SettlingMax: 1.0123 Overshoot: 1.2305 Undershoot: 0 Peak: 1.0123 PeakTime: 1.0297
Gu = minreal(feedback(Gc, OLTF*Gm))
Gu = 3.734 s^4 + 43.79 s^3 + 67.38 s^2 + 28.23 s + 0.2756 ---------------------------------------------------- s^4 + 10.84 s^3 + 39.56 s^2 + 27.95 s + 0.2756 Continuous-time transfer function.
step(Gu, t)

カテゴリ

Help Center および File ExchangePID Controller Tuning についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by