Hi folks,
We’re trying to operate the new Basic ESC off of a Raspberry Pi 3 B+ for some research here at school. Unfortunately we’re using Python, and in the RPi.GPIO library typically used to govern the output pins, the PWM is specified by first giving a frequency, and then specifying a percentage duty cycle.
For instance:
P = GPIO.PWM(11,100)
would specify pin 11 as an output with a 100 Hz frequency. Writing something like:
P.ChangeDutyCycle(10)
would give the pin a 10 percent duty cycle. However, the Basic ESC wants you to set PWM in microseconds. Is it possible to convert something like 1100 μs, 1900 μs into the aforementioned variables so that they can be used in my code?
Alternatively, does anyone have any experience/ know of any python libraries that can be used on the Pi to call PWMs like 1100 μs,1900 μs, etc?
Thanks in advance,
Andrew
Hi Andrew,
You can absolutely convert these values to get a microseconds output. If you set the frequency to 100 Hz, like you show, then the period of each cycle is 1 second / 100 = 0.01 s = 10,000 µs
. Given that period, you can figure out the appropriate duty cycle like this:
1100 µs / 10,000 µs = 11.0% duty cycle
1900 µs / 10,000 µs = 19.0% duty cycle
So, varying the duty cycle from 11-19% would provide the full range of thruster control.
-Rusty
Hi Rusty,
I’ve tried this out several times using various frequencies and duty cycles. It doesn’t seem to be working though or only drives the motor intermittently.
Ordinarily I get just a single beep and no motor motion. Sometimes I get two beeps. Is there any documentation on what the beeps indicate?
I did set this up with an Arduino successfully beforehand, I’m sure it is configured correctly.
Thanks
Hi Andrew,
Alright. The ESCs need to be initialized with a “stopped” signal at 1500 µs before they will operate properly. Make sure your program is sending that value for a few seconds first and then try other values. You should hear the ESC go through a sequence of beeps.
-Rusty
Hey Rusty,
I finally got it working perfectly! The issue was that the ordinary PWM library “RPi” used with the Raspberry Pi uses software PWM, which doesn’t have the accuracy to deliver that initialization pulse width. A library called PIGPIO uses hardware PWM and drives the Basic ESC perfectly though.
Thanks for the support,
Andrew
1 Like
Andrew,
Awesome, nice work! That’s good to know for future users who might have the same issue!
-Rusty