Host-Target Communication with External Mode Simulation

You can use external mode simulations for rapid prototyping. An external mode simulation establishes a communication channel between Simulink® on your development computer (host) and the target hardware that runs the executable file created by the code generation and build process.

Through the communication channel, you can:

  • Modify or tune block parameters in real time. When you change parameters in the model, Simulink downloads the new values to the executing target application.

  • Monitor and save signal data from the executing target application.

The low-level transport layer of the channel handles the physical transmission of messages. Simulink and the generated model code are independent of this layer. The transport layer and its interface code are isolated in separate modules that format, transmit, and receive messages and data packets.

Communication Mechanisms for External Mode

Simulink supports two communication mechanisms for external mode simulation. To decide which mechanism to use, see the information in this table .

Communication Mechanism Supported ByWhy Select

XCP, the Universal Measurement and Calibration Protocol

ERT and GRT system target files.

XCP external mode:

  • Uses a standard communication protocol.

  • Requires only a lightweight communication software stack on the target hardware.

  • Supports signal logging and streaming for Dashboard blocks and the Simulation Data Inspector. You can stream signals from within a referenced model hierarchy.

  • Provides documented ext_mode.h API for external mode target connectivity.

  • Supports streaming of execution-time metrics to the Simulation Data Inspector for host-based and support package external mode simulations.

For information about running XCP external mode simulations, see:

TCP/IP and serial (RS-232)

ERT and GRT system target files.

Simulink support packages.

You do not use the Simulation Data Inspector for visualizing, exporting, and saving data.

You want to use signal triggering.

For information about running TCP/IP and serial external mode simulations, see:

Simulink Feature Support for External Mode

This table summarizes feature support for both forms of external mode simulations.

FeatureXCP SupportTCP/IP and Serial Support

Parameter tuning

With Dashboard blocks

Yes

Yes

Of tunable (Simulink) block parameters

Yes

Yes

Simulation Data Inspector

Yes. Includes signals within referenced models.

No

Logic Analyzer

Yes. Includes signals within referenced models.

No

Blocks that receive and display signals from target application

DashboardYes

No

Floating Scope, Scope

Yes, provided signal logging is enabled for block input.

Yes

Spectrum Analyzer, Time Scope (DSP System Toolbox™)

Yes, provided signal logging is enabled for block input.

Yes

Display

Yes, provided signal logging is enabled for block input.

Yes

To Workspace

Yes, provided signal logging is enabled for block input.

Yes

User-written S-Function.

A method, which enables user-written blocks to support external mode, is built into the S-function API.

See matlabroot/simulink/include/simstruc.h.

Yes, provided signal logging is enabled for block input.

Yes

XY Graph

Yes, provided signal logging is enabled for block input.

Yes

Signal Viewing Subsystems

Yes, provided signal logging is enabled for subsystem input.

Yes

External Mode Simulations with Run on Hardware Board App

To run external mode simulations on target hardware supported by MathWorks® support packages, use the Run on Hardware Board app. For an external mode simulation, you:

  1. Build the target application on your development computer.

  2. Deploy the target application to the target hardware.

  3. Connect Simulink to the target application that runs on the target hardware.

  4. Start execution of generated code on the target hardware.

With the app, you can perform the steps separately or with one click. This table shows the workflow support that the app provides for your hardware board.

Workflow Feature or TaskTarget Hardware
Development ComputerHardware Board

One-click

Yes

Yes

Step-by-step

Connect

Yes

Yes

Start

Yes

Yes

Security for External Mode Simulations

Ensure that access to your development computer and the target hardware is secure.

Provide a secure communication channel between your development computer and the target application by applying the security measures listed in this table.

Communication ProtocolSecurity Measure

XCP on TCP/IP, TCP/IP

Run your development computer and target application within a trusted private network or virtual private network (VPN).

XCP on serial, serial

Use a point-to-point link between your development computer and target application, for example, a serial cable.

Before generating code for production, to reduce the risk of unintended access to the target application, disable external mode settings.

Related Topics