RC Brushless DC motor & ESC

An off-the-shelf RC hobbyist brushless DC motor & ESC is controlled from mbed using PWM

Hello World

Import programESC_DC_Brushless_motor_test

Runs an RC Brushless DC motor using with an ESC module. Mbed supplies the PWM control signal for the ESC. See https://developer.mbed.org/users/4180_1/notebook/using-a-dc-brushless-motor-with-an-rc-esc/ for more info

Library

Import programESC_DC_Brushless_motor_test

Runs an RC Brushless DC motor using with an ESC module. Mbed supplies the PWM control signal for the ESC. See https://developer.mbed.org/users/4180_1/notebook/using-a-dc-brushless-motor-with-an-rc-esc/ for more info

Notes

Brushless DC motors

Brushless DC motors are smaller and weigh less than equivalent DC (Brushed) motors, but they require a more complex speed control circuit. Brushless DC motors are used in most drones and they typically have 3 wires instead of 2. The electronic speed control (ESC) circuit needs a microprocessor with PWM outputs and three power MOSFET half-bridge drivers (two transistors each to drive a pin high, low, or not connected) to drive the three motor windings. Firmware can sense the motor’s back EMF and eliminate the need for an encoder to generate the correct sequence and timing of the PWM output signals which generate a three phase AC-like signal for the motor. Some high-end brushless DC motors also have encoders. The control signal in most ESCs for drones works the same as standard RC servo signals, a 1-2ms. wide pulse every 20ms.

BDCM ESC

A brushless DC motor for drones with an electronic speed control module.

Helloworld Demo

RC ESC modules and brushless DC motors are mass produced for the hobbyist market and are low cost. The setup used here runs around US $35. RC ESC modules use the same PWM signals as RC servos. The mbed servo class is used to send the PWM signal to control the motors. The tricky bit is that ESCs require a special startup calibration and arming sequence. The ESC uses the motor to send beep codes at power up and during the arming procedure. When the ESC powers up, three beeps sound. Next, a full throttle signal is sent, followed by a low throttle. On an RC radio control transmitter, the user moves the stick up, waits for a beep code and pulls the stick down all the way followed by another beep code. In the mbed code, time delays were added to simulate the user waiting for the beep codes. This ESC uses the BL_Heli_S firmware that requires a microprocessor with three hardware PWM bits for smoother speed control. Some newer ESC modules use ARM cores. Older ones often have 8051 based processors. The ESC module would not operate on only 5V DC. An old 9VDC 1A wall wart was used in the demo. The control signal is optoisolated. The motor used in the demo is rated at 2600 kV. In the case of brushless DC motors, kV means RPMs per Volt (not kilovolts!).

Wiring

mbedESC moduleBrushless DC motorMotor Power Supply/Battery
gndblack servo cable wire
p21white servo cable wire
black motor power wiregnd
red motor power wirearound 7.4-14.8 VDC 2A
(2S to 4S LiPo battery pack)
Three small solder padsThree motor leads


ESC
Backside of ESC board with six MOSFETs and lots of caps. Motor solder pads on right.

Safety Note

The propeller is moving so fast that it can cut your finger it you get near it!
Note: The motor is so small and powerful that it will be necessary to mount it for testing (even without a prop)! A quick stop will twist all the cables into a tight braid without a mount. Since the black outside case of the motor rotates, it is hard to hold with your hand. There are four threaded screw holes on the back of the motor case and the motor comes with screws for mounting. The center of the backside of the motor rotates, so it needs a large center hole when mounting.

By swapping any pair of motor leads at the ESC or changing the software configuration of the ESC, the motor will rotate in the reverse direction. They can even be setup for bidirectional operation, so that inverted flight is possible. Drones with 4 motors have the two pairs of diagonal motors rotating in the opposite direction to minimize rotational torque on the airframe which keeps it a bit more stable and easier to turn. CW or CCW refers to the direction of the shaft threads. The prop nut is less likely to spin off if the threads are opposite the motor rotation.

The mbed motor test stand demo. With a few holes, this board would fly!

To run the demo code, power must be turned on to the motors first (it sends three beeps at power up). Next power up the mbed (or release the reset pushbutton, if it is used instead of a power cycle).

// Calibrate and arm ESC and then sweep through motor speed range
// To run: Hold down reset on mbed and power up ESC motor supply
// Wait for three power up beeps from ESC, then release reset on mbed
// See https://github.com/bitdump/BLHeli/blob/master/BLHeli_S%20SiLabs/BLHeli_S%20manual%20SiLabs%20Rev16.x.pdf
// for info on beep codes and calibration
#include "mbed.h"
#include "Servo.h"
PwmOut ledf(LED1); //throttle up test led with PWM dimming
PwmOut ledr(LED2); //throttle down test led with PWM dimming

Servo myservo(p21);

int main()
{
    myservo = 0.0;
    ledf = ledr = 1;
    wait(0.5); //detects signal
//Required ESC Calibration/Arming sequence  
//sends longest and shortest PWM pulse to learn and arm at power on
    myservo = 1.0; //send longest PWM
    ledf = ledr = 0;
    wait(8);
    myservo = 0.0; //send shortest PWM
    wait(8);
//ESC now operational using standard servo PWM signals
    while (1) {
        for (float p=0.0; p<=1.0; p += 0.025) { //throttle up slowly to full throttle
            myservo = p;
            ledf = p;
            wait(1.0);
        }
        myservo = 0.0; //Motor off
        ledf = ledr = 0;
        wait(4.0);
        for (float p=1.0; p>=0.0; p -= 0.025) { //Throttle down slowly from full throttle
            myservo = p;
            ledr = p;
            wait(1.0);
        }
        myservo = 0.0; //Motor off
        ledf = ledr = 0;
        wait(4.0);
    }
}

Import programESC_DC_Brushless_motor_test

Runs an RC Brushless DC motor using with an ESC module. Mbed supplies the PWM control signal for the ESC. See https://developer.mbed.org/users/4180_1/notebook/using-a-dc-brushless-motor-with-an-rc-esc/ for more info

Applications

Racing drones use live video feedback from a camera and can reach speeds near 150 MPH. This motor and speed control can be used in mid size racing quadcopters like the one seen below:

/media/uploads/4180_1/rsx255.jpg

Here is an mbed student project using one of the motors and ESCs to build the lift motor for a hovercraft:




Here is another video of an mbed controlled quadcopter:



On quadcopters, a flight controller module with a gyro, accelerometer and perhaps a compass, GPS and Sonar is used to stabilize the copters attitude and perhaps even altitude. Without a flight controller to stabilize the copter, it will quickly spin or tumble out of control faster than a human pilot can respond. The user’s remote control radio transmits control inputs to the radio receiver module and the receiver passes user control inputs to the flight controller. The flight controller drives the ESC modules while keeping the copter stable. When a flight controller is upgraded with a magnetometer (compass), GPS, barometric sensor (altimeter) and perhaps an air speed sensor it becomes capable of autonomous flight and navigation. This type of device is often called an autopilot. Most flight controllers run an RTOS and floating point hardware is useful to speed up control loops. A small flight controller module, a SP F4evo, is shown below with an ARM Cortex M4 core. Four ESCs are available on one board the same size for quadcopters (called a 4 -in-1 ESC).

/media/uploads/4180_1/spf4.jpg

ESC Options and Programming

It is also possible to program many options and parameters on the ESC. This can be done using the control sticks with feedback beeps, or using a GUI on a PC with a microcontroller sending data to the ESC. Some ESCs can also work with I2C or Serial signals in addition to PWM. Hard core drone racers spend a lot of time tuning engines.

/media/uploads/4180_1/blheli.jpg

BLHeli software talks to the ESC using an FTDI cable to adjust motor settings. The mbed “FTDI-style” program and setup below was used with BLHeli to reprogram the ESC’s motor settings using the GUI when connecting to the mbed’s USB virtual com port at 19200.

Import programBLHeli_FTDI_Cable

Used to tune ESC controllers using BLHeli firmware

BLHeli Suite Wiring

mbedESCDiode
gndblack servo wire
p10 RXwhite servo wire+
p9 TX- (band)

Power must be cycled on the ESC after writing new values before they take effect.

Interesting Drone Videos

Drone racing: First Person View (FPV)


A Recent Drone race with a prize of $1,000,000


Bad ways to use drones


Please log in to start a discussion or ask a question.