This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Generate, Download, and Execute Code

To perform hardware-in-the-loop simulation on target hardware, 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.

Requirements for Building and Executing Simulink Real-Time Applications

Before building and executing your real-time application:

  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) and MATLAB Command-Line Interface (Simulink Real-Time).

Create, Build, and Download a Real-Time Application

To generate code for the model on your development computer, and then to transfer the code to your real-time computer:

  1. Set the Simulink Real-Time code generation configuration parameters. For information, see Set Configuration Parameters (Simulink Real-Time) and MATLAB Command-Line Interface (Simulink Real-Time).

  2. Start the target computer. For information, see Start Target Computer (Simulink Real-Time).

  3. To compile your code, link your hardware, and download the real-time application to your target machine in one step, in the Simulink editor, click the Build Model button . For information, see Build and Download Real-Time Application (Simulink Real-Time).

Execute Real-Time Application

After you build and download a real-time application to the target computer, you can run the real-time application.

  1. In the Simulink window, on the toolbar, set the simulation mode to External.

    Selecting external mode allows you to connect your development computer to your real-time target machine.

  2. To connect your development computer and target machine and to transfer your model parameters to the target machine, click the Connect to Target button .

  3. To execute your real-time application on the target machine, click the Run button .

See Also

Related Examples

More About