How to implement PID anti-windup in my m-file (i.e., without using Simulink)
23 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Antworten (1)
Sam Chak
am 20 Aug. 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
CLTF = minreal(feedback(Gc*OLTF, Gm)) % closed-loop
%% Defining system responses
% y = step(CLTF, t, opt);
step(CLTF, t)
S = stepinfo(CLTF)
Gu = minreal(feedback(Gc, OLTF*Gm))
step(Gu, t)
0 Kommentare
Siehe auch
Kategorien
Mehr zu PID Controller Tuning finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

