This topic shows how to test an existing model predictive controller by adding it to a Simulink® model.
Open your Simulink model.
Add an MPC Controller block to the model.
If your controller includes measured disturbances, add the md
inport to the MPC Controller block.
Double-click the MPC Controller block.
In the Block Parameters dialog box, on the General tab, select Measured disturbance (md).
Click OK.
Connect the plant and controller signals in the Simulink model. Connect:
The plant inputs to the manipulated variable (mv
) inport of the
MPC Controller block.
The plant measured outputs to the measured output (mo
) inport
of the MPC Controller block.
The measured disturbances, if any, to the plant and to the measured disturbance
(md
) inport of the MPC Controller block.
Any unmeasured disturbances or unmeasured outputs to their corresponding plant inport and outport.
The reference signals to the reference (ref
) inport of the
MPC Controller block.
Specify the controller.
Double-click the MPC Controller block.
In the Block Parameters dialog box, in the MPC Controller field,
specify the name of an mpc
controller from the MATLAB® workspace.
Click OK.
(Optional) Modify the controller.
After specifying a controller in the MPC Controller block, you can modify the controller:
Using MPC Designer:
In the Block Parameters dialog box, click Design.
In MPC Designer, tune the controller parameters.
In the MPC Designer tab, in the Result section, click Update and Simulate > Update Block Only.
The app exports the updated controller to the MATLAB workspace.
Using commands to modify the controller object in the MATLAB workspace.
Run the Simulink model.
Tip
If you do not have a Simulink model of your plant, you can generate one that uses your MPC controller to control its internal plant model. For more information, see Generate Simulink Model from MPC Designer.
mpc
| MPC
Controller | MPC
Designer