Real-Time Simulation

Simulink® Real-Time™ Simscape™ checks, Simscape HDL Workflow Advisor

Deploying a plant model allows you to test your control algorithm. You can deploy your Simscape Electrical™ model for real-time simulation, including hardware-in-the-loop (HIL) simulation, using generated C code or HDL code.

Generate C code to deploy a nonlinear, linear, or switched linear model that requires a 20 µs or greater simulation sample time. If you have a license for Simulink Coder™, you can generate C code for deployment to a real-time target machine. If you have a license for Embedded Coder®, you can generate C code for deployment to an embedded system. If you have a license for Simulink Real-Time, you can use Simscape checks to prepare your Simscape Electrical models for code generation. You can then use the Simulink Real-Time Explorer to:

  • Generate and compile code on a development computer.

  • Download the real-time application to a target computer.

  • Execute the real-time application remotely from the development computer.

To learn how to generate and deploy a C code version of a Simscape model, see Real-Time Model Preparation Workflow (Simscape), Real-Time Simulation Workflow (Simscape), and Hardware-In-The-Loop Simulation Workflow (Simscape).

Generate HDL code to deploy a linear or switched linear model that requires a 1 µs or greater simulation sample time. If you have a license for HDL Coder™, you can generate HDL code from your Simscape Electrical model without first manually converting the model to a Simulink model by using the Simscape HDL Workflow Advisor. The sschdladvisor function generates an HDL code compatible version of your model. You can then generate code from the HDL implementation model and deploy your plant model to an FPGA for HIL simulation.

To learn how to generate an HDL version of a Simscape model, see Generate HDL Code Using the Simscape HDL Workflow Advisor (Simscape).

Topics

Real-Time Model Preparation Workflow (Simscape)

Follow the real-time model preparation workflow to make your Simscape model real-time capable.

Hardware-In-The-Loop Simulation Workflow (Simscape)

Follow the hardware-in-the-loop (HIL) simulation workflow to deploy a Simscape model to your real-time target machine using Simulink Coder and Simulink Real-Time.

Real-Time Simulation Workflow (Simscape)

Configure the solvers in your Simscape model for real-time simulation.

Prepare Simscape Electrical Models for Real-Time Simulation Using Simscape Checks

Learn how Performance Advisor Checks can help you optimize your Simscape Electrical model for real-time simulation.

Generate HDL Code Using the Simscape HDL Workflow Advisor (Simscape)

Learn how to convert Simscape models to HDL Code for FPGA Deployment.

Generate HDL Code from Simscape Models (HDL Coder)

How to generate HDL code from Simscape switched linear models.

Deploy Simscape™ Plant Models to Speedgoat FPGA I/O Modules (HDL Coder)

How to deploy the generated HDL code from Simscape models to Speedgoat IO modules.

Validate HDL Implementation Model to Simscape Algorithm

How to validate and resolve mismatch in simulation results between Simscape algorithm and HDL implementation model.

Improve Sampling Rate of HDL Implementation Model Generated from Simscape Algorithm

Learn about oversampling in generated HDL implementation model and how the model sample time relates to sample time of original Simscape algorithm.

Troubleshooting

Troubleshoot Conversion of Simscape DC Motor Control to HDL-Compatible Simulink Model (HDL Coder)

How to troubleshoot generation of implementation model from Simscape models with few nonlinear elements such as DC Motor Control.

Troubleshoot Conversion of Simscape™ Permanent Magnet Synchronous Motor to HDL-Compatible Simulink Model (HDL Coder)

How to troubleshoot generation of implementation model from models with significant nonlinear elements such as Permanent Magnet Synchronous Motor.