Problems with PWM output on BeagleBone Black

I am trying to output a PWM signal from one of the PWM pins on my BBB to an ESC (info here Quick Start Guide - Advanced Power Drives), but the ESC is not arming. I have done config-pin P9.14 pwm to set the pin to output PWM, and I am using the following code to run the motor for a second:

import Adafruit_BBIO.PWM as PWM
import time

motorPin = “P9_14”

duty_cycle = 10
PWM.set_duty_cycle(motorPin, duty_cycle)

while(duty_cycle > 0):

    duty_cycle = duty_cycle - 5;
    PWM.set_duty_cycle(motorPin, duty_cycle)

I know that in Arduino, the write_microseconds() function would be used to set endpoints, but I don’t know how to do that with the BeagleBone or if it is necessary to calibrate the endpoints. I suspect this is most likely a pin configuration problem, but it seems that the way to configure the PWM pins has been in flux and most sources of instructions are many years old.

As such, if anyone can help me to solve this issue, it would be highly appreciated!

I’d next verify that the config-pin worked, like this:
config-pin -q P9-14

you may have missed the ‘-a’ part of setting the pin, should be
config-pin -a P9-14 pwm

rather than expect your ESC to work first time, I’d try to examine the signal with an oscilloscope (ideally) or with a multimeter (almost as good)… even an led might be used if the correct settings can be applied (like period 1sec, duty cycle 50%).

good luck

Hello @Omnicoop ,

I think the Adafruit Library has ceased unless people are rewriting it currently. I have not checked on the link you listed yet.

Also, /dev/bone/pwm/* should show some PWM channels that have symlinks to the peripheral onboard the BBB.

I am pretty sure. I think that the Compatibility Layer states this “fact” in specific kernels.


P.S. For 4.19.x, things should work w/ /sys/class/pwm/* but in 5.10.x! Dun-dun-dun. It should be the /bone/ file in the /dev/ directory.

Hello gomer,

I did try the -a option, as well as the -q to view the actual mode, and it still didn’t work unfortunately.

I will definitely try using an oscilloscope to view the signal.

Just as a check on my math - the datasheet for the ESCs says this:

End Points

In order for your ESC to perform correctly when using a PWM input, make sure that the endpoints coming from the receiver are between 1000-1020 uS for the lower endpoint and 1980-2000 uS for the upper endpoint.

If the lower endpoint is above 1020 uS, the ESC will not arm. Similarly, if the receiver is outputting less than 1980 uS, you will not reach the full power range.

The ESC’s can receive up to 500Hz PWM, with standard TTL 3.3V or 5V inputs. If the input voltage is less than 2.7V, the drive voltage of the receiver is not high enough and the ESC will not respond to signal inputs.

So in order to get into that range, I tried my code above with a 500Hz frequency and a 55% duty cycle - I believe that would be the same as writing 1100 microseconds to the code (because 55% * (1/500) = 0.0011 seconds)? And that should be in the correct range, near the lower limit for the readings that the ESC can accept?

Thanks for your help!

Hello silver2row,

Do you have an alternative library that you would recommend?

I was also poking around in the pwm folder already, and did see folders for 8 channels there, each with files called “duty cycle”, “period”, and so on. I am not sure how to interpret whether the configurations there are correct, and I do not know what a symlink is or what the compatibility layer is. Apologies, I am new to this - I have only been learning how to use the BBB (and linux in general) for a few weeks!

Thank you for your help!

As @silver2row has indicated, the library you reference is ancient, but you could probably find an old Angstrom image on - latest-images to make it work. This approach seems to me easier than finding a more modern library to match your more current BBB image. I’d get real familiar with the adafruit tutorial PWM | Setting up IO Python Library on BeagleBone Black | Adafruit Learning System and find the proper image to match it.

Before you fine tune for your ESC, I recommend that you verify the PWM (via scope, MM or led) with simpler settings … like 1HZ period, 50% duty cycle.

good luck

Hello @Omnicoop ,

Oh! I found that has some nice PWM tutorials for handling Servos. You can probably adapt one of their ideas into a PWM instance on the BBB.


P.S. I found this online at the git repo. for Motors — BeagleBoard Documentation .

I was able to get it to work - turns out that the issue was just that I didn’t have the signal ground connected to the right place! I am using a power distribution board and I connected it there rather than to the BeagleBone ground directly, which of course did not work!

Otherwise, the only other thing I had to do was find the right duty cycle to send the ESC to get it to start up, as a nonzero duty cycle will not allow the ESC to initialize. For a 500Hz PWM frequency, sending a 50% duty cycle worked to get the ESCs initialized, and I was then able to get the motor to spin from 0 to 100% by varying the duty cycle from 50 to 100!

Thank you for the help guys, and apologies that it was mostly a wiring error on my end - clearly I am an aerospace engineer and not an electrical engineer!

1 Like