Code Generation

Generate code and deploy controllers on real-time targets

Once you have validated a model predictive controller in Simulink®or MATLAB®, you can generate code and deploy it for real-time control applications. For more information, seeGenerate Code and Deploy Controller to Real-Time Targets.

Functions

expand all

review Examine MPC controller for design errors and stability problems at run time
mpcmoveCodeGeneration Compute optimal control moves with code generation support
getCodeGenerationData Create data structures for mpcmoveCodeGeneration
mpcqpsolver Solve a quadratic programming problem using the KWIK algorithm
mpcqpsolverOptions Create default option set for mpcqpsolver

Blocks

expand all

MPC Controller 装病者e model predictive controller
自适应MPC控制器 装病者e adaptive and time-varying model predictive controllers
Explicit MPC Controller Design and simulate explicit model predictive controller
Multiple MPC Controllers 装病者e switching between multiple implicit MPC controllers
Multiple Explicit MPC Controllers 装病者e switching between multiple explicit MPC controllers
Adaptive Cruise Control System 装病者e adaptive cruise control using model predictive controller
Lane Keeping Assist System 装病者e lane-keeping assistance using adaptive model predictive controller
Path Following Control System 装病者e path-following control using adaptive model predictive controller

Topics

Code Generation Basics

Generate Code and Deploy Controller to Real-Time Targets

Model Predictive Control Toolbox™ software provides code generation functionality for controllers designed in Simulink and MATLAB.

QP Solver

The model predictive controller QP solver converts an MPC optimization problem to a general form quadratic programming problem.

金宝appCode Generation

装病者ion and Code Generation Using Simulink Coder

装病者e your MPC controller in Simulink and generate real-time code that uses either double or single precision signals.

仿真和结构化文本Generation Using Simulink PLC Coder

装病者e your MPC controller in Simulink and generate structured text for programmable logic controllers.

Using MPC Controller Block Inside Function-Call and Triggered Subsystems

To ensure that an MPC controller works properly inside a Function-Call or triggered subsystem, configure theMPC Controllerblock to use inherited sample time and invoke the subsystem periodically with the same sample time defined in the MPC controller object.

MATLABCode Generation

Generate Code To Compute Optimal MPC Moves in MATLAB

Generate C code to compute manipulated variable moves for real-time applications.

Solve Custom MPC Quadratic Programming Problem and Generate Code

You can implement a custom MPC control algorithm that supports C code generation in MATLAB using the built-in QP solver,mpcqpsolver.

Custom QP Solver

装病者e and Generate Code for MPC Controller with Custom QP Solver

Generate code for a model predictive controller that uses a custom quadratic programming solver.

OPC Simulation

Real-Time Control with OPC Toolbox

Implement an online model predictive controller application using the OPC client supplied with the OPC Toolbox™.