Model Predictive Control Toolbox™ provides code generation functionality for controllers designed in Simulink® and MATLAB®.
After designing a controller in Simulink software using the MPC Controller block, you can generate code and deploy it for real-time control. You can deploy the controller to all targets supported by the following products:
Simulink PLC Coder™
The sampling rate that a controller can achieve in real-time environment is system-dependent. For example, for a typical small MIMO control application running on Simulink Real-Time, the sampling rate can go as low as 1–10 ms. To determine the sampling rate, first test a less aggressive controller whose sampling rate produces acceptable performance on the target. Next, increase the sampling rate and monitor the execution time used by the controller. You can further decrease the sampling rate as long as the optimization safely completes within each sampling period under the normal plant operations.
For more information, see Simulation and Code Generation Using Simulink Coder and Simulation and Structured Text Generation Using PLC Coder.
The MPC Controller block is implemented using
Function block. To see the structure, right-click the block
and select Mask > Look
Under Mask. Open the
After designing an MPC controller in MATLAB, you can generate C code using MATLAB Coder and deploy it for real-time control.
To generate code for computing optimal MPC control moves:
Generate data structures from an MPC or Explicit MPC
For more information, see Generate Code To Compute Optimal MPC Moves in MATLAB.