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)
time.sleep(5)
servo.stop_servo(PIN)
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