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

11 visualizaciones (últimos 30 días)
Ali
Ali el 12 de Sept. de 2020
Respondida: Sam Chak el 20 de Ag. de 2022
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

Respuestas (1)

Sam Chak
Sam Chak el 20 de Ag. de 2022
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)

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by