Main Content

External mode

Communication interface

Use the ‘serial’ option to run your model in the External mode with serial communication.

When running a model in External mode over serial, Simulink® generates error if the Hardware Serial Port parameter is set to Serial 0. The error is generated because the External mode uses serial port 0 to communicate with the Arduino board by default. Browse to WiFi properties, and ensure that the Hardware Serial Port parameter is set to a port other than Serial 0.

Warning

External mode over XCP on WiFi on Simulink models having more than 3 multirate systems result in a connection error.

Settings

Default:

  • Serial — For AVR-based boards

  • XCP on Serial — For ARM-based boards

  • Serial

  • TCP/IP

  • WiFi

  • XCP on Serial

  • XCP on TCP/IP

  • XCP on WiFi

Host interface

Select the interface through which the host computer communicates to target Arduino board for signal monitoring and parameter tuning.

Note

This parameter appears only if you choose XCP on Serial as the Communication interface.

Settings

Default: Simulink

If you use the third-party product CANape® for calibrating parameters, select CANape from the drop-down list. When you perform Monitor & Tune action, an A2L file is generated, which lets you navigate through the model and access parameters and measured values directly in CANape.

Use a dedicated timer to improve time stamp accuracy

Enable this parameter to use a dedicated timer to log data in real time when monitoring signals and tuning parameters (external mode simulation) and thereby improve the time stamp accuracy. If you do not select this parameter, the model logs the data only during simulation.

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, ensure that:

  • The maximum value of this parameter does not exceed the available Arduino® 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 target computer 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.

  • You enter a logging buffer size larger than the available RAM on Arduino. When you download and initialize the real-time application, the hardware displays a message, ERROR: allocation of logging memory failed. To avoid this error, either install more RAM or reduce the buffer size for logging, and then restart the hardware. To calculate the maximum buffer size available for your real-time application logs, divide the amount of available RAM by sizeof(double), or 8. Specify that value in the Logging buffer size (in bytes) value.

Settings

Default: 1000000

Set logging buffer size automatically

Use this parameter to automatically set the number of bytes to preallocate for the buffer in the hardware during simulation.

Settings

Default: on

Verbose

Select this check box to view the External Mode execution progress and updates in the Diagnostic Viewer or in the MATLAB® Command Window. This parameter appears when you select TCP/IP or WiFi for Communication interface.