Documentation

Hardware-In-The-Loop Simulation Workflow

  • Products Used
  • Simscape™ , Simulink® Coder™ , Simulink Real-Time™

This figure shows the hardware-in-the loop simulation workflow. The connectors are exit points for returning to the real-time model preparation workflow.

This figure shows the real-time model preparation workflow. The connector is an entry point for returning to the real-time model preparation workflow from other real-time workflows such as the hardware-in-the-loop simulation workflow.

This figure shows the real-time simulation workflow. The connectors are exit points for returning to the real-time model preparation workflow.

Before performing the hardware-in-the-loop (HIL) simulation workflow:

  1. Prepare and configure your model for real-time simulation. For information, see Real-Time Model Preparation Workflow and Real-Time Simulation Workflow.

  2. Set up and configure the software, I/O interfaces, and connectivity for your development computer, target computer, and I/O board. For information, see Simulink Real-Time Setup and Configuration (Simulink Real-Time).

  3. If you are performing HIL simulation to test your controller:

    • Configure your controller.

    • Connect your controller to the real-time computer.

Perform Hardware-In-The-Loop Simulation

Generate, Download, and Execute Code

Use Simulink Real-Time to:

  • Generate and compile code on the development computer.

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

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

For information, see Generate, Download, and Execute Code.

Evaluate Accuracy

Compare the results from the simulation on the target computer to your reference results. Are the reference and modified model results the same? If not, are they similar enough that the empirical or theoretical data also supports the results from the simulation of the modified model? Is the modified model representing the phenomena that you want it to measure? Is it representing those phenomena correctly? If you plan on using your model to test your controller design, is the model accurate enough to produce results that you can rely on for system qualification? The answers to these questions help you to decide if your real-time results are accurate enough.

Evaluate Speed

To find out if your simulation generates an overrun, examine the task execution time (TET) report that Simulink Real-Time generates for the simulation.

Return to the Real-Time Model Preparation Workflow

Your model is not real-time capable if simulation on your real-time target machine generates an overrun or produces results that do not match your reference results closely enough. To make your model real-time capable by adjusting model fidelity, return to the real-time model preparation or real-time simulation workflow.

Adjust the fidelity or scope of your model, and then step through the other processes and decisions in the real-time model preparation workflow. Iterate on adjusting, simulating, and analyzing your model until it is fast and accurate enough for you to perform the real-time simulation workflow. Perform the real-time simulation workflow, and then attempt the hardware-in-the-loop simulation workflow again. For information, see Real-Time Model Preparation Workflow and Real-Time Simulation Workflow.

Return to the Real-Time Simulation Workflow

Your model is not real-time capable if simulation on your real-time target machine generates an overrun or produces results that do not match your reference results closely enough. To make your model real-time capable by adjusting the simulation solver settings, return to the real-time simulation workflow.

Perform the real-time simulation workflow, and then attempt the hardware-in-the-loop simulation workflow again. For information, see Real-Time Simulation Workflow.

Insufficient Computational Capability for Hardware-In-The-Loop Simulation

Your real-time target machine can lack the computational capability for running your model in real time. If your model fails to run in real time or produces unreliable results on your target machine after multiple iterations of the real-time workflows, consider these options for increasing processing power:

Related Examples

More About

Was this topic helpful?