Main Content

Model Predictive Control of a Single-Input-Single-Output Plant

此示例显示了如何在Simulink®中控制具有输入饱和的双积分植物。金宝app

Define the Plant Model

Define the plant model as a double integrator (the input is the manipulated variable and the output the measured output).

plant = tf(1,[1 0 0]);

Design the MPC Controller

Create the controller object with a sampling period of 0.1 seconds, a prediction horizon of 10 steps and a control horizon of and 3 moves.

mpcobj = mpc(plant, 0.1, 10, 3);
-->The "Weights.ManipulatedVariables" property is empty. Assuming default 0.00000. -->The "Weights.ManipulatedVariablesRate" property is empty. Assuming default 0.10000. -->The "Weights.OutputVariables" property is empty. Assuming default 1.00000.

Because you have not specified the weights of the quadratic cost function to be minimized by the controller, their value is assumed to be the default one (0 for the manipulated variables, 0.1 for the manipulated variable rates, 1 for the output variables). Also, at this point the MPC problem is still unconstrained as you have not specified any constraint yet.

Specify actuator saturation limits as constraints on the manipulated variable.

mpcobj.MV = struct('Min',-1,'Max',1);

使用Simulink模拟金宝app

Simulink is a graphical block diagram environment for multidomain system simulation. You can connect blocks representing dynamical systems (in this case the plant and the MPC controller) and simulate the closed loop.

% Check that Simulink is installed, otherwise display a message and returnif~mpcchecktoolboxinstalled('simulink') disp(“金宝app需要Simulink才能运行此示例。”)return结尾

Open the pre-existing Simulink model for the closed-loop simulation. The plant model is implemented with two integrator blocks in series. The variable-step ode45 integration algorithm is used to calculate the continuous time loop behavior. The MPC Controller block is configured to use the workspacempcobjobject as controller. The manipulated variables and the output and reference signal. The output signal is also saved by the To-Workspace block.

mdl ='mpc_doubleint'; open_system(mdl)

Simulate closed-loop control of the linear plant model in Simulink. Note that before the simulation starts the plant model inmpcobjis converted to a discrete state space model. By default, the controller uses as observer a Kalman filter designer assuming a white noise disturbance on each plant output.

sim(mdl)% you can also simulate by pressing the "Run" button.
- >将“ model.plant”属性转换为状态空间。- >将模型转换为离散时间。假设未在测量的输出通道#1中添加干扰。- >“ model.noise”属性为空。假设每个测得的输出上都有白噪声。

The closed-loop response shows good setpoint tracking performance, as the plant output tracks its reference after about 2.5 seconds. As expected, the manipulated variable stays within the predefined constraints.

Close the open Simulink model without saving any change.

bdclose(mdl)

See Also

Objects

Apps

Blocks

相关话题