Trace Signals with 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 (Simulink Coder) and Control External Mode Simulation Through External Mode Control Panel (Simulink Coder)).

Note

Do not use Simulink external mode while Simulink Real-Time™ Explorer is running. Use only one interface or the other.

This procedure uses the model xpcosc. xpcosc contains a Simulink Scope block.

  1. Open model xpcosc.

  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 the Signal & Triggering button.

  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.

  9. Click Apply, and then Close.

  10. In the External Mode Control Panel dialog box, click OK.

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

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

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

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

  15. Build and download the real-time application to the target computer. On the Real-Time tab, click Run on Target.

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

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