Developing the EFS CAN-DShot ESC Adapter Board Firmware

This document contains more details about the firmware for the CAN-DShot ESC Adapter board.

Table of Contents

Important Links for the CAN-DShot ESC Adapter Board

Overview - Current State of Firmware (at time of writing)

What Has Been Done

  • DShot code converted from STM32L5 development board to STM32L4 CAN ESC adapter board STM32 project, meaning that the CAN ESC adapter board can control an ESC with DShot.

  • efs-canard integrated with DShot code, so CAN ESC adapter board can receive throttle inputs from flight controller and mission planner through CAN (see video above).

Protocols

  • The flight controller communicates with the ESC CAN adapter through CAN (STM32L4 does not support FDCAN).

    • this is implemented with efs-canard. The board accepts throttle values from CAN messages and calls DShot functions to control the ESC.

  • The CAN ESC adapter controls the ESC over DShot.

    • implemented with memory to peripheral DMA in dshot.c

    • a complementary timer pin (e.g. TIM1 CH1N) was used for DShot output generation due to the wiring of the board. This is the same as a normal timer output except HAL_TIME_*() was replaced with HAL_TIMEx_*() function calls.

    • DShot is currently normal DShot 150 (not bidirectional).

Setting up Development Environment

Below are instructions to setup everything you need to start developing the CAN ESC adapter firmware (at the time of writing).

  1. Install STM32CubeIDE. It is used for developing, configuring, and flashing firmware to the STM32 MCU on this board.

  2. Clone, import, and open the can-esc firmware repository.

  3. Wire up the CAN ESC adapter board:

    1. ST-link between your laptop/development machine and the CAN ESC adapter board (see https://uwarg-docs.atlassian.net/wiki/x/1wD9VQ,https://uwarg-docs.atlassian.net/wiki/x/XICRlw)

    2. logic analyzer is helpful for probing outputs like DShot.

    3. CAN connection to the flight controller and DShot connection to the ESC:

      1. efs_can_dshot_wiring.svg
        Example Wiring Diagram for Testing
      2. here is an example of what the setup could look like:

        20241127_195017.mp4

         

  4. Connect flight controller to your computer if you want to test CAN functionality. You’ll need to install ArduPilot Mission Planner to do so.

  5. You are now ready to start writing firmware! Please see these troubleshooting and common pitfalls in case you come across similar issues while working on the board.

Troubleshooting and Pitfalls

Below are some pitfalls encountered when developing firmware for this board and tips to address them.

Similar Boards

This board was developed in parallel with a few other boards that share the same dronecan/libcanard code. It may be helpful to see the implementation of these boards for more examples.

Other Helpful Resources