Let RPi Drive Brushless Motor

Materials needed:

Setup ESC throttle.

By default, we need to setup the minimum and maximum throttle of a brushless ESC. Different brand of ESC may have different way of setup, but most ESC accept the following:

1. Connect ESC to RPi through its white and black wires. The white wire is signal wire, which transfer PWM signal from RPi’s GPIO pin to ESC, so connect it to one GPIO pin, e.g. GPIO 4. The black wire is ground wire, connect it to one of RPi’s ground pins. Connect the output wires of ESC (three wires) to brushless motor (motor must be fixed, e.g. on a board). Note: do not connect ESC’s power wires (two wires, one red and one black) to battery. Reference: How to control a brushless motor with raspberry pi

2. Start and access to RPi. I recommend you to install RPIO to your RPi, which can generate semi-hardware PWM signal. There is alternative, like RPi.GPIO, which come with the distribution of Raspbian, but the PWM is generated by software, and I feel it’s not stable. To install RPIO is simple:

sudo apt-get install python-setuptools
sudo easy_install -U RPIO

3. Run python with sudo: sudo python. Type the following lines:

from RPIO import PWM
s = PWM.Servo()
s.set_servo(4, 2000)

The above commands will generate a 2000us (2ms) PWM signal, which is the maximum throttle of the ESC (see).

4. Connect ESC’s power wires to battery. You will hear some sound, like bee—-, or bee–bee, which means the maximum throttle was setup successfully, and waiting for minimum signal input. Now, back to RPi’s python console, and type the following quickly (before you hear any sound of the ESC):

s.set_servo(4, 1000)

This will generate the minimum pwm signal for ESC. If the minimum throttle was successfully setup, then you will hear some sound like: bee— bee-bee-bee 123. The bee— means minimum throttle was setup successfully, bee-bee-bee means that ESC detect the battery is a 3s battery, and 123 means that ESC is ready for input.

5. Type

s.set_servo(4, 1300)

in python’s console, the brushless motor should start to spin. Reference: How to controll brushless motor using ESC and PWM signal

Normal start

Any time, when connect ESC’s power wires to battery after the PWM signal was generated and connect to ESC, this will enter to the throttle setup procedure. To avoid this step, will need to power ESC before the 2ms PWM was generated. One simple method is always power ESC before start RPi. Now, let’s shut down RPi and start it again without disconnecting ESC’s power wires to battery. When RPi started, run python as a sudo user. In Python’s console, run the following command, and motor should start to spin:

from RPIO import PWM
s = PWM.Servo()
s.set_servo(4, 1300)

Theoretically, the motor should start when the PWM cycle is longer than 1ms, but due to different quality of the motor, some of them will not spin until they receive a higher voltage signal. You can start with s.set_servo(4, 1000), and increase with a step 10 to see when your motor start to spin.

Note: If your motor didn’t spin, one reason could be your ESC doesn’t work. I bought four ESCs, and only two of them work :(

Written on May 13, 2015