Delving the depths of computing,
hoping not to get eaten by a wumpus

By Timm Murray

Arduino -- Brushless Motor Control

2013-10-15


NOTE: This post was moved over from WumpusUAV.com. The Indiegogo campaign was not successful, so I’m copying some key posts from there to over here and shutting the site down.

Brushless ESCs are more efficient than the regular DC motors of old. However, they need to be controlled more carefully, so they need a dedicated controller for each motor. I’m using the Turningy Plush 18A. Some of the details might change for other motor controllers, but should be broadly correct.

Hardware Setup

The common pinout on the ESC has three wires. The black is ground, red is +5V, and then some other color is signal.

The Arduino Servo library docs say that servos tend to take a lot of power, so you shouldn’t run more than one or two directly off of the Arduino board’s own +5V line. However, a typical servo doesn’t have any other power connector. Brushless ESCs do, in the form of an extra +5V and GND wire. The Arduino board may be able to power 4 ESCs just fine. I haven’t done any measurements to confirm that. The PCB designed for the WumpusUAV has a seperate 7805 voltage converter for the ESCs.

Software Setup

The motor controller takes a signal like the ones that were previously used to control RC servos. This is sometimes called PWM, but it isn’t at all like the PWM typically used to dim LEDs and such. Thus, it is controlled using the Arduino Servo libary.

The Servo library can controll any servo on any digital output pin. The usual servos (used for things like stearing on an RC car, or the ailerons on an RC plane) take a value between 0 and 179 degrees. For Brushless ESCs, this translates directly into throttle settings.

The ESC takes a few seconds to startup, during which we need to send a zero value. The Turningy has an audiable beep that gives diagnostic information during this time.

The code below will attach to an ESC on pin 8, send a zero throttle for 10 seconds (which is probalby more than necessary), and then start sending a throttle of 10 (179 being top throttle). Brushless motors can be surpirisingly powerful, so you don’t want to run them to hard during testing.

#include 

#define MIN_READING 0
#define MAX_READING 1023
#define MIN_DEGREES 0
#define MAX_DEGREES 179
#define PERCENT_THROTTLE 75
#define STARTUP_WAIT_MS 10000
#define MIN_PULSE_WIDTH 1000
#define MAX_PULSE_WIDTH 1000
#define PIN 8


Servo motor;
unsigned long start_time;


void setup()
{
    motor.attach( PIN, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH );
    start_time = millis();
}

void loop()
{
    unsigned long now_time = millis();
    unsigned long since_start = now_time - start_time;

    int throttle, want_throttle;

                                                                                
    if( STARTUP_WAIT_MS < since_start ) {                                                    
        want_throttle = 10;                                                     
    }                                                                           
    else {
        want_throttle = 0;
    }

    motor.write( want_throttle );
}


Copyright © 2024 Timm Murray
CC BY-NC

Opinions expressed are solely my own and do not express the views or opinions of my employer.