Set Up External Mode Connectivity Between Simulink and Target Hardware
For external mode simulations, you can use the
target Package to
provide connectivity between Simulink® and your target hardware.
This diagram gives an overview of the components of an external mode simulation.
The target package provides classes for the implementation of components. This table lists the main classes.
|Target hardware||Provide MATLAB® with a description of target hardware.|
You can use the classes to:
To provide Monitor & Tune,
Deploy, Connect, and
Start functionality, the Run on Custom Hardware app
requires the use of
|Connectivity||Provide communication protocol for data transfer between Simulink and target hardware.|
|Provide target hardware with details of the communication channel and the rtiostream API (Embedded Coder) implementation.|
Customise Connectivity for XCP External Mode Simulations
For code that is generated by using ERT (
ert.tlc) and GRT
grt.tlc) system target files, you can run external mode simulations
that use the XCP communication protocol:
On your development computer.
On other target hardware by using support packages.
If your system target file for custom target hardware is derived from the ERT or GRT
system target files, use classes from the
target Package to
customise connectivity. For example,
This example shows how you can customise connectivity for XCP-based external mode simulations. To set up connectivity between Simulink and the target hardware:
Customize Connectivity for TCP/IP or Serial External Mode Simulations
For TCP/IP or serial external mode simulations, you can customize connectivity through a workflow that:
Implements transport and communication protocols.
Specifies the execution tool for the target application by using the
To set up connectivity between Simulink and the target hardware, use the workflow described in Customise Connectivity for XCP External Mode Simulations with these differences:
After step 1, using the information in Choose Communication Protocol for Client and Server and Create a Transport Layer for TCP/IP or Serial External Mode Communication, implement the client and server sides of external mode communication for TCP/IP or serial protocols.
Do not perform step 5 and step 6.
Execution Tool Template
This section provides a pseudocode example for a
service interface. The tool starts and tracks an application on the target hardware.
classdef MyExecutionTool < target.ExecutionTool methods function errFlag = startApplication(this) % Call "customDownloadTool" to download the application. [status, result] = ... system(sprintf('customDownloadTool %s', this.Application)); if status == 0 errFlag = false; else disp(result); errFlag = true; end end function errFlag = stopApplication(~) % Add code here to stop the application, if possible. errFlag = false; end function [status, errFlag] = getApplicationStatus(~) % Add code here to return the application status, if known. status = target.ApplicationStatus.Unknown; errFlag = false; end end end
- External Mode Simulations for Parameter Tuning, Signal Monitoring, and Code Execution Profiling
- External Mode Simulation by Using XCP Communication
- Choose Communication Protocol for Client and Server
- Create a Transport Layer for TCP/IP or Serial External Mode Communication
- Set Up PIL Connectivity by Using target Package (Embedded Coder)