Fareed Mohmed← All projects

Info page · no simulation · Arduino and electronics

BLDC Motor with an ESC and Arduino

How a brushless motor and its speed controller (ESC) work, and how an Arduino sets the throttle with a servo-style signal.

This topic cannot be run safely or meaningfully in the simulator, so this page explains it with diagrams, calculations and sample code instead. Everything here is original.

What you will learn

  • How an ESC makes a rotating field from DC
  • Why the ESC needs an arming signal
  • How to set the throttle with writeMicroseconds

In short

A brushless motor has three coils and magnets on the rotor. The ESC switches the battery current through the coils in order so that a magnetic field rotates and pulls the rotor round. The Arduino does not drive the motor. It sends the ESC a pulse every 20 ms. A 1000 microsecond pulse means stop and a 2000 microsecond pulse means full throttle.

Try this next

  • Add a button for a soft start.
  • Read the motor speed with an IR sensor and a slotted disc.
  • Make a throttle that never jumps more than 5 percent per step.

Safety: take the propeller off for every test. A small BLDC motor and a LiPo battery can hurt fingers badly and the LiPo can catch fire. Fit a fuse, never short the battery, charge it in a fireproof bag and never leave it unattended.

How it works

LiPo battery11.1 V (3S)ESC3 half-bridgesBLDC motor3 wiresArduinopin 9Servo signal1000 to 2000 usESC signal wireESC BEC5 V out (do not join to Arduino 5 V)

Inside the ESC a small processor switches six MOSFETs. It reads the voltage on the unused coil (back-EMF) to know where the rotor is. Without a rotor sensor it needs the motor to turn a little to start, which is why you hear a short start-up buzz.

Arming and throttle

#include <Servo.h>

Servo esc;
const int ESC_PIN = 9;
const int POT = A0;

void setup() {
  esc.attach(ESC_PIN, 1000, 2000);
  esc.writeMicroseconds(1000);               // minimum: arming signal
  delay(3000);                               // wait for the ESC beeps
  while (analogRead(POT) > 50) { }           // do not start until the knob is at zero
}

void loop() {
  int us = map(analogRead(POT), 0, 1023, 1000, 2000);
  esc.writeMicroseconds(us);
}

Parts list

PartWhat to look for
Brushless motor (outrunner, for example 1000 kV)Check the maximum current and voltage
ESC (for example 30 A) with BECCurrent rating about 1.5 x motor maximum
LiPo battery 3S, with connectorUse a LiPo bag and a fuse
Servo cable / jumper wiresESC signal to the pin, ESC black wire to Arduino GND
10 k potentiometerFor the throttle
Strong clamp or test standFix the motor before power on

Do and do not