Controlling pan and tilt servos from beaglebone

I want to control a LynxMotion pan and tilt unit from a BeagleBone using Julia, if possible. Ideally, I’d like to skip the use of a micro-controller altogether and communicate with the LynxMotion unit directly through the PWM ports of the BeagleBone (but maybe I need a shield in there). In fact, the reason I want to use a BeagleBone is because of its hardware PWM ports, which, if I understood correctly, are missing in a Raspberry Pi.

Is any of this possible?

seems like you can configure the Beaglebone’s PWM outputs by poking bits at a device in /sys/ see how this bash program does it:
https://github.com/justinpearson/Beaglebone-motor-from-command-line
I guess you can use write + open to do that bit prodding from julia.
idk if there is a package that has that kind of thing wrapped up or not.

Which I wish I had known a decade ago when I was doing motor control for a project, we had a beaglebone talking to a seperate microprocessor over serial to have that do PWM for motor control.

This is exactly what I would like to avoid. I’ve had RPI talk through serial to an Arduino, and while it work etc etc, skipping a micro-controller altogether would be the dream.

Oof, I hope to avoid too much fiddling… Maybe I can avoid some of that with the shield, or things like GitHub - ronisbr/BaremetalPi.jl: Julia library to access Raspberry Pi peripherals without requiring external libraries.

Hardware PWM is available of the Raspberry Pi computers on GPIO pins 12, 13, 18 and 19: Raspberry Pi Documentation - Raspberry Pi OS

They are controlled via ioctl() to a character device. So the thing to do in Julia is to load a suitable C shared library (libgpiod or pigpio library) and then call it via @ccall.

2 Likes

TIL! Thanks!

Maybe I can simply use GitHub - JuliaBerry/PiGPIO.jl: Manage external hardware using GPIO pins on the Raspberry Pi?

It doesn’t look too fiddly to me.
If the readme of the bash thing I link is correct.
Looks like a one liner for each function:

set_pwm_period!(ns) = open(io->print(io, ns), "/sys/devices/ocp.3/pwm_test_P8_34.12/period") 
set_pwm_offduty!(ns) = open(io->print(io, ns), "/sys/devices/ocp.3/pwm_test_P8_34.12/duty")

might take a little looking around to find out the device name for your particular make.
(Most of the bash script in that repo is just find the names for things)

1 Like