Skip to content

Sapog ESC Firmware

Sapog firmware is an advanced open source sensorless PMSM/BLDC motor controller firmware designed for use in propulsion systems of electric unmanned vehicles.

While it can be controlled using traditional PWM input, it is designed to operate over CAN bus using DroneCAN.

Where to Buy

Multiple vendors sell ESC hardware that runs sapog firmware:

Hardware Setup

ESCs are connected to the CAN bus using a Pixhawk standard 4 pin JST GH cable. For more information, refer to the CAN Wiring instructions. ESC order does not matter.

Firmware Setup

ESCs come with an existing build of Sapog installed. If you want to update:

To build the firmware:

git clone --recursive
cd sapog/firmware
make RELEASE=1

This will create a file *.application.bin. in build/. This binary can be flashed through the autopilot over DroneCAN via the sapog bootloader. See DroneCAN Firmware Update.

Refer to the project page to learn more, including how to flash without using the DroneCAN bootloader (i.e. on a not-yet-programmed device) or for development.

Flight Controller Setup

Enabling DroneCAN

Connect the ESCs to the Pixhawk CAN bus. Power up the entire vehicle using a battery or power supply (not just the flight controller over USB) and enable the DroneCAN driver by setting the parameter UAVCAN_ENABLE to '3' to enable both dynamic node ID allocation and DroneCAN ESC output.

Automatic ESC Enumeration using QGroundControl

This section shows how to enumerate any Sapog-based-based ESCs "automatically" using QGroundControl.


You can skip this section if there is only one ESC in your setup, because the ESC index is already set to zero by default.

To enumerate the ESC:

  1. Power the vehicle with a battery and connect to QGroundControl

  2. Navigate to Vehicle Setup > Power in QGC.

  3. Start the process of ESC auto-enumeration by pressing the Start Assignment button, as shown on the screenshot below.

    QGC - DroneCAN ESC auto-enumeration

    You will hear a sound indicating that the flight controller has entered the ESC enumeration mode.

  4. Manually turn each motor in the correct direction of its rotation (as specified in the Airframe Reference), starting from the first motor and finishing with the last motor. Each time you turn a motor, you should hear a confirmation beep.


    Make sure to turn each of the motors in the correct direction, as the ESC will automatically learn and remember the direction (i.e. motors that spin clockwise during normal operation must also be turned clockwise during enumeration).

  5. After the last motor is enumerated, the confirmation sound should change to indicate that the enumeration procedure is complete.

  6. Reboot PX4 and the Sapog ESCs to apply the new enumeration IDs.

The following video demonstrates the process:

Manual ESC Enumeration using Sapog


We recommend automated Sapog ESC Enumeration using QGroundControl shown above rather than manual enumeration (as it is easier and safer).

You can manually configure the ESC index and direction using the DroneCAN GUI Tool. This assigns the following Sapog configuration parameters for each enumerated ESC:

  • esc_index
  • ctl_dir


See Sapog reference manual for more information about the parameters.

PX4 Configuration

Assign motors to outputs using the Acutator configuration screen.


See DroneCAN Troubleshooting

Further Information