Control a brushless motor with an ESC using an Arduino

FunduinoPublished on

Einen starken Modellbau-Motor über einen Fahrtregler steuern

Brushless-Motoren aus dem Modellbau sind klein, leicht und erstaunlich kräftig. Direkt an eine Spannungsquelle anschließen lässt sich so ein Motor aber nicht – dazwischen gehört ein ESC, ein elektronischer Fahrtregler.

In dieser Anleitung steuerst du einen solchen Motor mit dem Arduino an und regelst seine Drehzahl über ein Potentiometer. Der Trick dabei: Für den Arduino verhält sich ein ESC wie ein ganz gewöhnlicher Servo.

Electric ducted fan for model building
The turbine (EDF) with the brushless motor inside

You need this

10 kOhm rotary potentiometer - carbon film, 6 mm shaft, up to 30 V 10 kOhm rotary potentiometer - carbon film, 6 mm shaft, up to 30 V 0,90 € *Item no. F23106608About the product — 10 kOhm rotary potentiometer - carbon film, 6 mm shaft, up to 30 V
SimonK ESC 12 A - Speed controller for brushless motors with BEC SimonK ESC 12 A - Speed controller for brushless motors with BEC 8,41 € *Item no. F23108640About the product — SimonK ESC 12 A - Speed controller for brushless motors with BEC
EDF impeller turbine - brushless motor, Ø 27-70 mm, 3900-11000 kV EDF impeller turbine - brushless motor, Ø 27-70 mm, 3900-11000 kV — 35mm, ADF35-100 PLUS 11000KV 29,69 € *Item no. F23108733About the product — EDF impeller turbine - brushless motor, Ø 27-70 mm, 3900-11000 kV — 35mm, ADF35-100 PLUS 11000KV
Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino 11,12 € *Item no. F23107480About the product — Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
830-point Breadboard - solderless breadboard for Arduino 830-point Breadboard - solderless breadboard for Arduino 2,90 € *Item no. FUN-1010553About the product — 830-point Breadboard - solderless breadboard for Arduino
Breadboard Cables Male-to-Male - 40 Pieces, 20 cm Breadboard Cables Male-to-Male - 40 Pieces, 20 cm 1,74 € *Item no. FUN-1010558About the product — Breadboard Cables Male-to-Male - 40 Pieces, 20 cm

All 6 parts together 54,76 € *

* All prices include statutory VAT, plus shipping costs.

Why a Brushless Motor Needs an ESC

In this example, you control a fan - a powerful electric turbine with a brushless motor inside. These turbines are sold as EDFs (Electric Ducted Fans) or ducted fans. In model building, they power model aircraft or hovercraft.

Brushless motors have a special requirement when it comes to their power supply: They need alternating current and generally draw a lot of current. That's why you don't connect them directly to a power source. An electronic module goes in between to generate the appropriate alternating current - the ESC (Electronic Speed Controller).

The current output by the ESC determines the motor's speed. The Arduino tells it what speed to run at via a control signal.

Electric ducted fan for model building
The turbine (EDF) with the brushless motor inside

Wiring

Power comes from the power source through the ESC’s two thick wires - red and black. Three more thin wires come out of the ESC in a single three-pin connector:

  • Red (+) and black (-) supply power to the microcontroller. The ESC’s voltage regulator generates the 5 volts.
  • White carries the control signal from the Arduino to the ESC - on pin 8 in the sketch.

Connect the potentiometer that sets the speed to analog input A0.

Safety: A brushless motor spins up very quickly and with considerable force. Before your first test, secure the turbine so it cannot slip or lift off, keep fingers, cables, and loose objects away, and wear safety glasses. Set the potentiometer to zero before connecting the power supply—many speed controllers will not enable the motor otherwise.

Turbine with brushless motor and ESC speed controller beside it
On the left, the turbine with the brushless motor; on the right, the ESC wrapped in heat-shrink tubing.

Control the ESC

Because ESC technology comes from model building, an ESC is controlled just like a servo - using a PWM signal (pulse-width modulation). That's why the sketch uses the Servo library: it lets the Arduino generate the right signal in just a few lines.

The sketch reads the rotary knob, converts the value from 0 to 1023 to a value from 0 to 180, and sends it to the ESC.

Control speed using a potentiometer
// Add the servo library. It is used because an ESC is controlled in the same
// way as a servo from an electrical perspective.
#include <Servo.h>

// The ESC (Electronic Speed Controller) is defined as an
// object named "ESC".
Servo ESC;

int Potentiometer;  // Potentiometer output value
int Speed;          // Control value for the ESC

void setup()
{
  // The three values are the pin, minimum and maximum pulse width in microseconds.
  // 1000 and 2000 are standard values that work with most speed controllers.
  // If this doesn't work, look up your ESC's values in its datasheet.
  ESC.attach(8, 1000, 2000);
}

void loop()
{
  // Reads the value of the potentiometer on analog pin A0. It ranges from 0 to 1023.
  Potentiometer = analogRead(A0);

  // The map command converts the measured value to a value between 0 and 180
  // that the ESC can process.
  Speed = map(Potentiometer, 0, 1023, 0, 180);

  // The value is sent to the ESC, which controls the motor accordingly.
  ESC.write(Speed);
}
Rate the instructions

Comments

Ask a question or share an experience

Contact us if something doesn’t work. Please include your board and the error message.

We review every comment before publication. Your email address remains with us.