Real-Time Simulation
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.
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.
Topics
- Choose Between CPU and FPGA for HIL Simulation
Choose hardware for hardware-in-the-loop (HIL) simulations by balancing timing requirements, complexity, and cost for your application.
- Generate HDL Code for FPGA Platforms from Simscape Models
Learn how to convert Simscape models to HDL Code for FPGA Deployment.
- Generate and Validate HDL Code for Simscape Model (HDL Coder)
Generate HDL code from Simscape switched linear models.
- Improve FPGA Sampling Frequency of HDL Implementation Model Generated from Simscape Algorithm (HDL Coder)
Oversampling in generated HDL implementation model, and relation between model sample time and sample time of original Simscape algorithm.
- Validate HDL Implementation Model to Simscape Algorithm (HDL Coder)
Validate and resolve simulation mismatch between Simscape algorithm and HDL implementation model.
- Modeling Guidelines for Simscape Subsystem Replacement (HDL Coder)
Simscape modeling best practices for replacing Simscape subsystem with state-space algorithm.



