MAVLINKHUD

DroneCAN: The Modern Bus

Executive Summary

I2C and UART are legacy protocols. They are point-to-point, prone to noise, and have no standard configuration interface. DroneCAN (formerly UAVCAN v0) is a robust, differential-signaling bus. It allows you to daisy-chain GPS, Compass, ESCs, and Rangefinders on a single twisted pair of wires. It features "Plug and Play" node allocation and centralized configuration.

Theory & Concepts

1. Publish / Subscribe Architecture

MAVLink is often Request/Response. DroneCAN is Pub/Sub.

  • Publisher: A GPS node broadcasts uavcan.equipment.gnss.Fix messages on the bus. It doesn't know or care who is listening.
  • Subscriber: The Flight Controller subscribes to uavcan.equipment.gnss.Fix.
  • Benefit: Multiple devices can listen to the same sensor (e.g., a Companion Computer and the Autopilot) without fighting for the serial port.

2. Dynamic Node Allocation (DNA)

On a CAN bus, every device needs a unique 7-bit Address (Node ID).

  • The Problem: In manual systems (CANopen), you have to set DIP switches on every device to avoid conflicts.
  • The DNA Solution:
    1. A new device boots up with Node ID 0 (Anonymous).
    2. It broadcasts a "Hello" message with a 16-byte Unique ID (UUID).
    3. ArduPilot (The DNA Server) hears this. It looks up the UUID in its database.
    4. ArduPilot assigns a permanent Node ID (e.g., 55) to that UUID.
    5. The device saves "55" to flash and uses it forever.

3. SLCAN (Tunneling)

How do you configure a CAN GPS if it doesn't have a USB port?

  • The Tunnel: ArduPilot acts as a bridge. It wraps raw CAN frames inside MAVLink packets (CAN_FRAME).
  • The Tool: The "DroneCAN GUI Tool" on your PC sends these MAVLink packets. ArduPilot unwraps them and puts them on the CAN bus. The response follows the reverse path.
  • Result: You can update firmware and change settings on a GPS module while it is installed in the drone.

Key Parameters

Parameter Default Description
CAN_P1_DRIVER 0 1=First Driver. Enables the CAN interface.
CAN_D1_PROTOCOL 1 1=DroneCAN.
GPS_TYPE 9 9=UAVCAN. Tells ArduPilot to look for GPS on the CAN bus.

Source Code Reference

Practical Guide: Configuring CAN Nodes (SLCAN)

You bought a Here3 GPS. How do you change its LED color? You can't plug it into USB. You must tunnel through the Autopilot.

Step 1: Enable the Driver

  1. Set CAN_P1_DRIVER = 1.
  2. Set CAN_D1_PROTOCOL = 1 (DroneCAN).
  3. Reboot.

Step 2: Establish the Tunnel

  1. Connect Mission Planner via USB.
  2. Press Ctrl+U (UAVCAN Screen).
  3. Click "SLCan Mode CAN1".
    • What happens: Mission Planner sends a command to ArduPilot to stop acting like a Flight Controller and start acting like a CAN Adapter. The MAVLink stream will die. This is normal.
  4. You should see a list of nodes appear (e.g., "Here3 GPS", "ZTW ESC").

Step 3: Configure the Node

  1. Click the "Parameters" button next to the GPS node.
  2. A new window appears showing the GPS's internal parameters.
  3. Change LED_COLOR or whatever you need.
  4. Write Params.
  5. Critical: Reboot the flight controller to exit SLCAN mode and return to normal flight.