Main Content

External Mode

External mode enables Simulink® on the host computer to communicate with the deployed model on the PX4® flight controller during runtime. This feature helps you to tune the parameters and perform real-time monitoring of the model running on the PX4 Autopilot.

Communication interface

Select the transport layer that the External mode uses to exchange data between the host computer and the PX4 flight controller.

Settings (except for PX4 Host Target)

Default:Serial

Settings for PX4 Host Target

Default:TCP/IP

Use the same host serial port for External mode as used for firmware upload

Use this parameter to set the same host serial port for External mode as the one used for Serial port for firmware upload.

Note

This parameter does not appear if you select PX4 Host Target as the Hardware board.

Settings

Default:on

Host Serial Port

Use this parameter to explicitly define the serial port for External mode on the host computer, if it is different from the one that you have used for firmware upload. External mode uses this port for communication between the PX4 flight controller and host computer.

Note

This parameter does not appear if you select PX4 Host Target as the Hardware board.

Settings

Default: COM6

Hardware board Serial Port

Use this parameter to define the serial port for External mode on the PX4 flight controller. If you are using the micro-USB port for External mode, this corresponds to the default value /dev/ttyACM0. External mode uses this port for communication between the PX4 flight controller and host computer.

Note

This parameter does not appear if you select PX4 Host Target as the Hardware board.

Settings

Default: COM6

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.

Note

This parameter does not appear if you select PX4 Host Target as the Hardware board.

Settings

Default: on

Logging buffer size (in bytes)

Specify the number of bytes to allocate for the buffer in the hardware during 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 PX4 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 PX4. 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: 1024

Verbose

Select this check box to view the External mode execution progress and updates in the Diagnostic Viewer or in the MATLAB® Command Window.

See Also