Main Content

Trace Signals by Using Simulink External Mode

You can use Simulink® external mode to establish a communication channel between your Simulink block diagram and your real-time application. The block diagram becomes a user interface to your real-time application. Simulink scopes can display signal data from the real-time application, including from models referenced inside a top model. You can control which signals to upload through the External Signal & Triggering dialog box. See Select Signals to Upload and TCP/IP or Serial External Mode Control Panel.

If using external mode simulation with the model serving as the interface to the real-time application and the model contains referenced models, use the Simulation Data Inspector to log signal data. Do not use Floating Scope or Scope Viewer blocks to display signals in the referenced models for external mode simulation.

Note

Do not use Simulink external mode while Simulink Real-Time™ Explorer is running. Use only one interface to control the real-time application.

Set Up for External Mode Simulation

This procedure uses model slrt_ex_osc. This model contains a Simulink Scope block. To set up triggering for the external mode simulation:

  1. Open model slrt_ex_osc.

  2. Open the external mode control panel. In the Simulink Editor, on the Real-Time tab, click Prepare > Control Panel.

  3. In the external mode control panel, click Signal & Triggering.

  4. In the External Signal & Triggering dialog box, set the Source parameter to manual.

  5. Set the Mode parameter to normal. In this mode, the scope acquires data continuously.

  6. Select the Arm when connecting to target check box.

  7. In the Delay box, enter 0.

  8. In the Duration box, enter the number of samples for which external mode is to log data, for example, 1000. The External Signal & Triggering dialog box looks like this figure.

    Use the External Signal & Triggering dialog box to configure the simulation.

  9. Click Apply, and then Close. In the External Mode Control Panel dialog box, click OK.

Set Stop Time and Simulate

To set the stop time and run the simulation:

  1. In the Simulink toolbar, increase the simulation stop time to, for example, 50.

  2. Save the model as ex_slrt_ext_osc. On the Simulation tab, from Save, click Save As.

  3. If a scope window is not displayed for the Scope block, double-click the Scope block.

  4. Connect to the target computer. On the Real-Time tab, toggle the Disconnected indicator to Connected.

  5. Build and download the real-time application to the target computer. Click Run on Target.

    The real-time application begins running on the target computer. The Scope window displays plotted data.

    The external mode scope displays the MuxOut signal.

  6. To stop the simulation, on the Real-Time tab click Stop.