
How do I set the saturation output for PID objects in MATLAB?
7 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2020 年 10 月 12 日
編集済み: MathWorks Support Team
2020 年 11 月 9 日
I want to set the saturation output of a PID object in MATLAB to enable the implementation of an anti-windup PID control scheme.
採用された回答
MathWorks Support Team
2020 年 11 月 9 日
編集済み: MathWorks Support Team
2020 年 11 月 9 日
PID objects in the Control System Toolbox are LTI (linear time-invariant) systems of a special type. Because of that, there is no property for output saturation in PID objects. To simulate "anti-windup" in MATLAB, you can setup a custom state-space system and call the "lsim" function to simulate the time response of that system with nonlinear properties such as saturation. Below is a simple script that performs closed-loop PI control with back calculation that can be used as a starting point.
UseBackCalculation = true; % enable/disable anti-windup (back calculation)
G = ss(tf(1,[1 2 1])); % plant
Kp = 2; Ki = 2; % PI controller gains (parallel)
Ts = 0.1; % controller sample time
tau = 1; % reset time constant
UB = 1.2; LB = -1.2; % saturation limits
% initial condition
r = 1;
y = 0;
x = zeros(2,1);
actionI = 0;
% closed-loop simulation (200 steps)
N = 200;
for ct=1:N
% error
e = r - y;
% control action
actionP = Kp*e;
u = actionP + actionI;
% saturation control action
u_sat = max(min(u,UB),LB);
% anti windup
if UseBackCalculation
actionI = actionI + (Ki*e + (u_sat-u)/tau)*Ts;
else
actionI = actionI + Ki*e*Ts;
end
% plant output
[Y,T,X] = lsim(G,[u_sat;u_sat],[0;Ts],x);
% for next iteration
x = X(end,:)';
y = Y(end);
y_vec(ct) = y;
u_vec(ct) = u_sat;
end
clf;
figure(1);
plot(1:N,y_vec,'*r',1:N,u_vec,'+b');
xlabel('Time'); ylabel('Signal');
legend('Model Response','Control Signal')
if UseBackCalculation
title('With Anti-Windup (Back Calculation)');
else
title('Without Anti-Windup');
end

0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で PID Controller Tuning についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!