I'm working on a quadcopter controlled by a Raspberry Pi 3 and I'm having some issues controlling the Electronic Speed Control (ESC). I'm a bit of a newbie so please be patient.

I bought the Afro Race Spec Mini 20Amp Multi-Rotor Speed Controller with BEC that is supposed to work with a 1Khz freq, and I managed to control the speed of the motor using the GPIO.PWM module with poor results: the signal sent apparently is not very accurate and the motor spinning is quite noisy and irregular.

Then I switched to the RPIO module and after many nights I managed to make it work with the Raspberry Pi 3 by cloning the metachris version:

git clone https://github.com/metachris/RPIO.git --branch v2 --single-branch

The code I'm trying to use is something like:

import time
from RPIO import PWM

PIN = 18

servo = PWM.Servo() #using default pulse with 20ms -> 50Hz

servo.set_servo(PIN, 1200)


I was expecting some kind of movement of the motor but nothing is happening.

Since the ESC is supposed to work at 1Khz frequency, should I set the pulse width accordingly? In this case should be:

 servo = PWM.Servo(1000) 

If so, I can't do this because the minimum value appears to be 3000 microseconds.

Can I do anything to overcome this issue? Am I doing something wrong?

Also, during a series of tests I managed to control the motor setting:

servo = PWM.Servo(8000) 

and changing the servo with random values:

servo.set_servo(PIN, random_value)

but I'm not able to replicate how I did it!

My questions are:

  • If the ESC is supposed to work with a 1000Hz frequency how come did it work with a pulse-width 8000 -> basically 125 Hz ?

  • Is there something I'm missing? ESC calibration, wrong values or anything?

Any help or suggestion would be much appreciated

2 Answers 2


Try the following from the command line. I'm assuming you mean Broadcom GPIO 18 (pin 12).

sudo pigpiod # start the pigpio daemon

pigs pfs 18 1000 # set 1kHz PWM on GPIO 18
pigs prs 18 1000 # set duty cycle range 0-1000, (same as micros)

pigs p 18 500 # send 500 micro pulses
pigs p 18 200 # send 200 micro pulses
pigs p 18 700 # send 700 micro pulses

Experiment with the pulse lengths.

  • Thank you very much, your suggestion has been really helpful. Feb 8, 2017 at 10:11

Thanks to the comment from joan I was able to make it work and I want to share my solution. Apparently it's all about calibrating/initializing the ESC.

In my example I've used the library PIGPIO that you can find at http://abyz.me.uk/rpi/pigpio/

Once you install the library and start the daemon with

sudo pigpiod # start the pigpio daemon

you're ready to send signals to the GPIO pins. In my case I set the frequency to 1Khz and the range 0-1000

pigs pfs 18 1000 # set 1kHz PWM on GPIO 18
pigs prs 18 1000 # set duty cycle range 0-1000, (same as micros)

Then you need to find the right pulse in order to initialise your ESC. After many attempts I found the value 155 was good for mine.

pigs p 18 155 #send 155 micro pulses

This initialises the ESC and you can hear a long beep indicating the ESC is ready to work.

From now on any value in the range 165-300 let the motor move at a specific speed (the steps are 5 micro pulses, so 165-170-175...)

Hope it helps someone else as well.

  • Just a couple of notes. You can use servoblaster and RPIO.GPIO as well as pigpio to control servos/ESCs. The pigs utility is useful for testing. If you need better resolution you can start the pigpiod daemon with 2, or 4 µs steps (-s option). Servoblaster and RPIO.GPIO will have similar options.
    – joan
    Feb 8, 2017 at 10:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.