Skip to content

ufnalski/dshot_pwm_dma_l432kc

Repository files navigation

DShot protocol in action (STM32L432KC)

An STM32 HAL example of arming and sending a reference speed to an ESC (electronic speed controller) that supports DShot (Digital Shot) protocol.

Dshot protocol in action at the university

Dshot protocol in action at home

Motivation

Quadcopters are inherently unstable. They only become stable due to control. That makes them excellent plants1 to elevate your control system design skills. There are many ways to start your journey with drones. You can buy a complete device that is ready to use out of the box, with all the necessary firmware preinstalled. This is for people who need it fly now and want to focus on gaining flying experience2. Some of us take the hard way and build their first drone from scratch including all the software needed to stabilize it and control it remotely. A hardcore DIYer would probably consider developing even his or her own ESCs. Here we take a bit less exteme approach and use a commercial ESC. Oh, and in this example we address only arming, setting a spin direction, and sending a reference speed to the ESC. You can consider it being the very first step in developing your own drone.

Missing files?

Don't worry 🙂 Just hit Alt-K to generate /Drivers/CMCIS/ and /Drivers/STM32L4xx_HAL_Driver/ based on the .ioc file. After a couple of seconds your project will be ready for building.

If you are new to the DShot protocol and BLHeli_S/BLHeli_323 firmware

BLHeliSuite32 Overview

BLHeliSuite32 Setup

BLHeliSuiteSiLabs Setup

Exemplary hardware for breadboarding

Warning

Propellers that spin at tens of thousands rpm are not toys ❗

Warning

LiPo batteries are not toys either - learn to handle them before you use one in your project ❗

Hints

The PWM pin operates in the push-pull mode. However, if the ESC is powered before the uC, it is advisable to have a pull-down resistor (e.g. 4k7 to draw below 1 mA from the GPIO), to get consistent behaviour at the startup phase (the DShot line idles low). It's a good practice not to have signal lines flapping in the breeze. Exactly the same pin is used to configure the ESC over UART (19200). Remove the resistor for the UART communication.

Sources and inspirations

A couple of next steps

Get familiar with attitude and heading reference systems (AHRS):

Play with a selected one. Some examples are:

There are eval boards ready for breadboarding from e.g. Adafruit Industries.

Then build a test rig to safely evaluate your control algorithms. Check some common approaches on YT:

Search for more: drone/quadcopter test bench/platform/jig/rig/stand.

Call for action

Create your own home laboratory/workshop/garage! Get inspired by ControllersTech, DroneBot Workshop, Andreas Spiess, GreatScott!, ElectroBOOM, Phil's Lab, atomic14, That Project, Paul McWhorter, and many other professional hobbyists sharing their awesome projects and tutorials! Shout-out/kudos to all of them!

Warning

Electric drives - do try them at home ❗

190+ challenges to start from: Control Engineering for Hobbyists at the Warsaw University of Technology.

Stay tuned ❗

Footnotes

  1. https://en.wikipedia.org/wiki/Plant_(control_theory)]

  2. Check the regulations before you do that - in most countries you have to undergo some basic training and get an official certificate to be allowed to fly a drone.

  3. BLHeli comes from brushless helicopter. _S denotes an 8-bit version developed by Silabs. _32 indicates a 32-bit version.

  4. Why not a bench power supply? If you already have one capable of delivering 30 A, lucky you 🙂 If not, it is usually much cheaper to buy a battery. It's roughly 25 EUR vs. 250 EUR. You can charge the battery from any CC/CV power supply if you know what you are doing. If you are not sure, use a quality charger. I'm quite happy with iMAX B6 Mini from SKYRC (approx. 35 EUR).

Releases

No releases published

Packages

No packages published