STM32 Electronic speed controller (ESC)

From Stm32World Wiki
Revision as of 03:03, 18 July 2022 by Lth (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Electronic speed controller (ESC) is a device which can control a Brushless DC electric motor. This page is meant as a place to write down research notes and it is most definitely a work in progress.


The first ESCs were typically controlled by applying a PWM signal to a pin. Since then many other both analogue and digital approaches have been developed. This section list some of these along with benefits and drawbacks.

Pulse width modulation (PWM)

To be added


To be added


To be added


The choice of the optimal MCU is somewhat complex. The following input/output is necessary:

  • USB (DP/DM)
  • SPI Slave (CLK, MOSI, MISO and CS)
  • SPI Master (CLK, MOSI, MISO and CS for flash storage)
  • SWD (CLK, DIO)
  • UART (RX, TX for debugging)
  • 3 x Analog In for current measurement
  • 3 x PWM capable high-side outputs
  • 3 x low side outputs
  • 3 x interrupt capable inputs for zero crossing detection

Experimentally trying to do this on an STM32F411 (of Black Pill fame) result in this:

ESC Pinout Test.png

In other words, the 48 pin STM32F411CE is quite sufficient for this purpose.

MOSFET Half Bridge Driver

To be added

Current Sensing

It is important to be able to measure the current running through the motor coil. Technically it would probably be sufficient to measure the overall current but another approach would be to measure each of the 3 coils.

In principle there are two ways to measure current. The basic one is to run the current through a shunt resistor and then measure the voltage drop across that resistor. More advanced current sensors based on hall effect are available. The benefit of the hall effect sensors is a much lower resistance (and thus voltage drop and energy wasted) but they are pricey.

If we are designing towards 80 amps and use a 0.005 Ohm shunt resistor we get the following values

Current (A) Voltage (V) Power (W)
1 0.005 0.005
10 0.05 0.5
80 0.4 32

This illustrates why it is probably beneficial to measure the coils individually since some power is burned in the shunt resistor. By measuring the 3 circuits above power is divided by 3, so rather than 32 W we get down in the 10 W range.

Miscellaneous documentation