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.

Some Simulink support packages. For details, see https://www.mathworks.com/hardware-support.html?q=&page=1.

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, GRT, and RSim 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 Subsystem

Yes, provided signal logging is enabled for subsystem input.

Yes

External Mode Simulations with the Run on Custom Hardware App

To run external mode simulations on your development computer or target hardware that is not supported by MathWorks® support packages, use the Run on Custom Hardware 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 target hardware.

Workflow Feature or TaskTarget Hardware
Development ComputerCustom Hardware

One-click

Yes

No, unless you register custom launcher in Simulink.

Step-by-step

Build for Monitoring

Yes

Yes. Software builds target application on development computer by using the toolchain that you specify.

Deploy

Yes

No, unless you register custom launcher in Simulink. Deploy target application manually.

Connect

Yes

Yes

Start

Yes

Yes

Related Topics