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:
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%).
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?
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!
Oh! I found that git.beagleboard.org has some nice PWM tutorials for handling Servos. You can probably adapt one of their ideas into a PWM instance on the BBB.
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!