Main Content

Simulink Real-Time Workflows

After you create a Simulink model of your control system and simulation shows the system response, it is useful to simulate the model in real-time by using real-world I/O.

Simulink Real-Time lets you build a real-time application from your model, run the application on a target computer in real time, and interface real-world I/O to the application.

There are several workflows that you can use for deploying the real-time application, controlling the application, and visualizing the operation of the real-time application.

Deployment Approaches

Deploying a real-time application consists of building a real-time application on the development computer and installing it on the target computer. There are several ways to deploy a real-time application:

  • Simulink Editor — From the Real-Time tab, click Run on Target. This selection provides a one-click operation for a model build, a real-time application load onto the target computer, and an application start on the target computer. You can use the UI for step-by-step build, load, connect model, and start operation by selecting from the buttons available from Run on Target.

  • Simulink Real-Time Explorer — If you have completed the model build, you can use the Simulink Real-Time Explorer to load the real-time application onto the target computer and start the application.

  • MATLAB commands — To deploy a real-time application to the target computer, in the MATLAB Command Window, type:

    tg = slrealtime;
    % creates target object tg for the default target computer
    
    connect(tg);
    % connects Simulink Real-Time to the target computer
    
    slbuild('model_name');
    % builds the real-time application from the model
    
    load(tg,'model_name');
    % installs the real-time application and loads 
    % it on the target computer
    
    start(tg);
    % starts the real-time application run
    
    % let the application run until stop time expires or . . .
    
    stop(tg);
    % stops the real-time application run

After you deploy the real-time application to the target computer, you can configure the target computer to run the application as the startup application when you start the target computer. This configuration is useful when you use the target computer for standalone mode operation instead of using the target computer for connected mode operation. For more information, see Deploy and Configure a Startup Real-Time Application.

Simulink Real-Time Operation Modes

Simulink Real-Time has operating modes and connection options for the development computer and the target computer.

When you start the target computer, it boots the real-time operating system (RTOS). The target computer always boots in standalone mode. In this mode, the target computer is operating independently of the development computer. If you previously deployed a real-time application to the target computer and configured the target computer to run the application on startup, the target computer runs the startup application. In standalone mode, you can control the target computer by using the command line interface from the target computer keyboard (console) or by using an SSH utility (for example, PuTTY) from the development computer.

After you start the target computer, on the development computer, you can connect to the target computer by using:

  • Simulink Editor Real-Time tab

  • Simulink Real-Time Explorer

  • MATLAB commands to create a target object and connect the target object to the target computer

Any of these methods put the target computer into connected mode operation. In connected mode, you can interact with the target computer by deploying real-time applications to the target computer and executing other operations.

Interfaces to the Real-Time Application

To control the real-time application on the target computer, there are a number of available interfaces. Each interface provides different types of support for controlling and interacting with the real-time application.

Interface to Real-Time Application

More Information

Simulink Editor — The Real-Time tab lets you operate the basic and more advanced Simulink® Real-Time™ workflows. Working from left-to-right on this tab, you can select and connect to a target computer, and then use the one-click operation of the Run on Target button to build, deploy, and run the real-time application. For more advanced workflows such as parameter tuning, the Signal Table selection in the Prepare section of this tab lets you interact with the real-time application when simulating in external mode.

Build and Download Real-Time Application by Using Run on Target

Simulink Real-Time Explorer — The explorer lets you load the real-time application onto the target computer and start the application. For more advanced workflows such as parameter tuning, on the Signals tab and Parameters tab, you can interact with the real-time application. The Simulink Real-Time Explorer provides a hierarchical display of application signals. You can select signals to stream to the Simulation Data Inspector for results visualization.

Execute Real-Time Application in Simulink External Mode by Using Step-by-Step Commands

Use MATLAB commands — Simulink Real-Time provides a selection of MATLAB functions for deploying and controlling real-time applications. This command interface supports developing MATLAB scripts for frequently used operations and access to operations that are not available from the Simulink Editor Real-Time tab or from the Simulink Real-Time Explorer.

Execute Real-Time Application with MATLAB Language