Main Content

External Mode Simulations for Parameter Tuning, Signal Monitoring, and Code Execution Profiling

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 your model, Simulink downloads the new values to the executing target application.

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

  • Retrieve execution-time metrics if code execution profiling is enabled for the external mode simulation. An Embedded Coder® license is required.

The low-level transport layer of the channel handles the 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 SupportsReasons for Selecting Communication Mechanism

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.

XCP external mode simulations do not support your target hardware because of known limitations.

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 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

Dashboard libraryYes

No

Floating Scope, Scope

Yes

Yes

Spectrum Analyzer, Time Scope (DSP System Toolbox™)

Yes

Yes

Display

Yes

Yes

To Workspace

Yes

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

Yes

Record, XY Graph

Yes

Yes

Signal Viewing Subsystem

Yes

Yes

External Mode Simulations by Using 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 by using 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

Yes, if you set up connectivity between Simulink and your target hardware.

Step-by-step

Build for Monitoring

Yes

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

Deploy

Yes

Yes, if you set up connectivity between Simulink and your target hardware.

Connect

Yes

Yes

Start

Yes

Yes

External Mode Control Panel

Using the External Mode Control Panel, you can perform some of the functions that the Run on Custom Hardware app provides, for example, Connect, Start, and Disconnect. You can also open the External Signal & Triggering dialog box, which enables you to:

  • Select logged signals that you want to monitor.

  • Configure a trigger for uploading target application data.

For details, see XCP panel or TCP/IP and serial panel.

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