External Mode
Communication interface
Select the transport layer External mode uses to exchange data between the host computer and the target hardware.
Settings
Default:
XCP on TCP/IP
XCP on TCP/IP
TCP/IP
Run external mode in a background thread
Force the external mode task in the generated code to execute in a background thread.
When external mode runs in the model thread, external mode executes after each execution step of the model and collects data at the base rate of the model. When model code consumes most of the thread execution time in each time step, external mode execution overruns into the next time step. This overrun delays the start of the next model execution step and degrades the real-time behavior of the deployed model.
You can configure external mode to run in a background thread. When external mode runs in a background thread, it executes in the time between the end of model code of one time step and the start of the next time step. By not blocking the model step, external mode can be used in systems that require real-time execution. This configuration enables direct observation of the deployed model on the hardware board as it would behave in standalone operation. This diagram shows the execution timing of external mode running in the foreground and background threads.
When model code consumes most of the execution time for each time step, external mode in the background thread starves for execution time. Without the time to collect and transmit data from the hardware board to the host computer, data packets drop. This case results in gaps in the data logging.
To help avoid dropped data packets in deployed models where real-time execution takes priority over data logging, configure external mode to operate as a background task.
Note
Enabling the Run external mode in a background thread
parameter
is not recommended for models that use a very small time step or that might encounter task
overruns. These situations can cause Simulink® to become unresponsive.
Settings
Default:disabled
Logging buffer size (in bytes)
Specify the number of bytes to preallocate for the buffer in the hardware during Universal Measurement and Calibration Protocol (XCP)-based External mode simulation. Specify Logging buffer size (in bytes) to a value large enough to accommodate the logged signals.
When specifying the buffer size, the maximum value of this parameter must not exceed the available NVIDIA® hardware memory, which the Simulink Real-Time™ also uses to store other items. For example, in addition to signal logging data, the software also uses the NVIDIA hardware memory for the Simulink Real-Time kernel, real-time application, and scopes.
Assume that your model has six data items (time, two states, two outputs, and task
execution time). If you enter a buffer size of 100000
, the target object
property tg.MaxLogSamples
is calculated as floor(100000 / 6) =
16666
. After the buffer saves 16666 sample points, it wraps and further samples
overwrite the older ones.
Settings
Default:
100000
Port
Set the value of the TCP/IP port number, from 1024 to 65535. External mode uses this IP port for communication between the target hardware and host computer.
Settings
Default:
17725
Verbose
Select this check box to view the external mode execution progress and updates in the Diagnostic Viewer or in the MATLAB® command window.
Settings
Default:
disabled