# Sapog ESC Firmware
Sapog (opens new window) 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 https://github.com/PX4/sapog cd sapog/firmware make RELEASE=1
This will create a file
build/. This binary can be flashed through the autopilot over DroneCAN via the sapog bootloader. See DroneCAN Firmware Update.
Refer to the project page (opens new window) 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 (opens new window)-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:
Power the vehicle with a battery and connect to QGroundControl
Navigate to Vehicle Setup > Power in QGC.
Start the process of ESC auto-enumeration by pressing the Start Assignment button, as shown on the screenshot below.
You will hear a sound indicating that the flight controller has entered the ESC enumeration mode.
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). :::
- After the last motor is enumerated, the confirmation sound should change to indicate that the enumeration procedure is complete.
- 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 (opens new window). This assigns the following Sapog configuration parameters for each enumerated ESC:
See Sapog reference manual (opens new window) for more information about the parameters.
# PX4 Configuration
Assign motors to outputs using the Acutator configuration screen.