NMPC for a simple tank
4 次查看(过去 30 天)
显示 更早的评论
I tried to implement a NMPC for a simple tank system. Reference for the output variable (tank height) was say: 50 m, no matter how much I tried different combinations of prediction and control horizons and sample time, I couldn't achieve desired output (reference tracking).
Sample code:
% Init
nlobj_Tank = nlmpc(1,1,1);
nlobj_Tank.Model.StateFcn = @StateFunc_Tank;
Ts = 0.02;
nlobj_4Tank.Ts = Ts;
nlobj_4Tank.ControlHorizon = 2;
nlobj_4Tank.PredictionHorizon = 10;
% Validate
x0 = 10;
mv0 = 100;
validateFcns(nlobj_Tank, x0, mv0)
% Bounds
nlobj_Tank.ManipulatedVariables(1).Min = -1;
nlobj_Tank.ManipulatedVariables(1).Max = 800;
nlobj_Tank.ManipulatedVariables(1).RateMin = -0.1;
nlobj_Tank.ManipulatedVariables(1).RateMax = 100;
nlobj_4Tank.States(1).Min = 0;
nlobj_4Tank.States(1).Max = 1000;
% Actual plant model
Plant_state = @(x, u) StateFunc_4Tank(x, u) + 0.01*rand(1,1);
% Setpoint or Output reference
Out_ref = [50];
all_MV = zeros(25,1);
all_X_plant = zeros(25,1);
mv_now = mv0;
x_now = x0;
for i = 2:1:25
[mv_now, opt, info] = nlmpcmove(nlobj_Tank, x_now, mv_now, Out_ref);
all_MV(i,:) = mv_now;
x_now = Plant_state(x_now, mv_now);
all_X_plant(i,:) = x_now;
end
Code for tank: StateFunc_Tank;
%% Trying the single tank NMPC
z= zeros(1,1);
a=10; %Area of the tank
R=0.1; %resistance of valve
%dh/dt = Fin - R sqrt(h)
z(1) = (1/a)*(u(1)-(R*sqrt(x(1))));
I am quite new for control and MPC implementation. Can somebody guide me how to implement a NMPC? What are the tuning parameters/ methodology to do the same? How to validate and visualize the NMPC results?
For MPC we have MPC desginer app and many tutorials but for NMPC I couldn't find any resources. Any help would be great.
Thanks
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Model Predictive Control Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!