Main Content

Set COM Port for Upload and Communication in Simulink

In most of the Pixhawk® boards, the COM port required to upload the firmware (bootloader COM port) and the COM port required to establish the connection with computer over MAVLink (Communications COM Port) are the same. You can use the same port to upload the firmware and communicate with the Pixhawk board after the firmware is uploaded. In such cases, you can use the Automatically determine serial port for firmware upload option in Simulink® Model settings to detect the COM port.

Select Automatically determine serial port for firmware upload

No additional settings are required in External Mode, Connected I/O or PIL tab for the corresponding simulation modes. You can continue to use the same serial port.

Use the same host serial port

However, for some Pixhawk Series boards, the bootloader COM Port and the main communications COM Port are different. When you connect to such boards, the bootloader port appears first in the Device Manager. The port shows for a few seconds and then the main communications port appears. A sample GIF image is shown here. The bootloader COM port is needed for firmware upload and the communication port is needed for MAVLink communication.

From R2023a, if your Pixhawk board has different bootloader and communication serial ports, enabling the Automatically determine serial port for firmware upload option in Simulink Model settings detects the correct bootloader serial port for upload. You do not have to manually enter the upload serial port.

Use the same host serial port

For Pixhawk boards having different Communication serial port and upload port, you can still enable the Use the same host serial port option for External Mode, Connected I/O or PIL tabs for the corresponding simulation modes. If you enable this option, the correct serial port for communication is automatically detected even if the Pixhawk hardware has different Communication port other than the upload port.

Use the same host serial port

Note

In the PX4 Pixhawk Series hardware target, the automatic serial port detection is not supported. If you are using PX4 Pixhawk Series as the hardware target or if the auto detect option is not working, manually set the upload and communication ports as mentioned in Manually Set COM Port for Upload and Communication.

Manually Set COM Port for Upload and Communication

Set Bootloader COM Port for Firmware Upload and Deploy

  1. For the Simulink model, launch the Model Settings.

    Tool strip

    A sample image of the default settings for hardware implementation is shown here.

    Hardware implementation

  2. Clear the Automatically determine serial port for firmware upload option and enter the bootloader serial port in Serial Port for firmware upload (This should be the bootloader port).

  3. Deploy the Simulink model. On the Hardware tab, in the Mode section, select Run on board and then click Build, Deploy & Start.

Set Communication COM Port for Monitor & Tune (External Mode)

  1. Perform the settings for Build options as shown in the topic Set Bootloader COM Port for Firmware Upload and Deploy.

  2. In External mode tab, clear the Use the same host serial port for External Mode as used for firmware upload option and mention the main communications port in Host Serial Port (this must be different from the bootloader port you mentioned earlier in Build options).

  3. Run External Mode for the model.

Set Communication COM Port for PIL

  1. Perform the settings for Build options as shown in the topic Set Bootloader COM Port for Firmware Upload and Deploy.

  2. In PIL Tab, clear the Use the same host serial port for PIL as used for firmware upload option and mention the main communications port in Host Serial port (this must be different from the bootloader port you mentioned earlier in Build options).

Set Communication COM Port for Connected IO

  1. Perform the settings for Build options as shown in the topic Set Bootloader COM Port for Firmware Upload and Deploy.

  2. In Connected I/O tab, clear the Use the same host serial port for Connected I/O as used for firmware upload option and mention the main communications port in Host Serial Port (this must be different than the bootloader port you mentioned earlier in Build options).