Beagleboard Servo Motor Control Help

Hello,

I used to use an Arduino to control a servo motor but since I have a beagleboard-xm now, I want to use it. But I do not know how to do it and I am quite a newbie. So, could you please help me find the way?

Regards,
Amadeus

I use a serial port to communicate with arduino.

2012/12/14 amadeus <satanasxentius@gmail.com>

I used to use an Arduino to control a servo motor but since I have a
beagleboard-xm now, I want to use it. But I do not know how to do it and I
am quite a newbie. So, could you please help me find the way?

You can take a look at the following articles:

I was doing that too. But from now on, I only want to use beagleboard-xm.

I don’t have my BB-xM handy, but those links aren’t the way to do it. Its not a good practice to use GPIO and timing in userspace to generate servo signals. However, what you are looking for is a way to use hardware, and I’m sure you used PWM on your Arduino. I don’t think the BBxM was designed with low level hardware interface in mind, but the expansion header contains three PWM signals, meaning you have at most three hardware controlled servos. Pins 4, 8, and 10 on the expansion header are signals GPT9_PWMEVT, GPT11_PWMEVT, and GPT10_PWMEVT respectively. There was a kernel module developed at GSoC 2010 that made the pwm devices available through /dev files and ioctl.

http://elinux.org/BeagleBoard/GSoC/2010_Projects/Pulse_Width_Modulation

Basically all RC servos want a signal every 20 ms, so since Frequency = 1 / Period, 50 = 1 / .02 seconds, you want a 50 Hz PWM frequency. However the signal to the servo is between like 0.8 ms and 2.2 ms, so to vary your servo’s position, you need to set the duty cycle between 4% and 11% to set the servo’s position correctly. And now since its in hardware, whatever happens in userspace isn’t going to cause the servo to jitter. IMHO, any sort of hardware control to low level type devices should be done in kernel space with the control interface available to userspace (i.e. through a device file). I’ve actually been working on a kernel module to control the velocity of a DC motor with an encoder on it, so all I have to do is like “echo 3.2 > /dev/motor0” to set it to rotate at 3.2 radians a second.

  • Nathaniel

This is a test post as it seems I have some problems with my registration.

We start working on new AM3352 board http://olimex.wordpress.com/2012/12/10/am3352-olinuxino-design-is-planned/

Your comments and suggestions are welcome!

Thanks
Tsvetan

Small update - since the PWM frequency on the BBxM has to be a power of two, use a 64 Hz pwm frequency (15.625 ms period) and you’ll need to use between a 5.12% and 14.08% duty cycle (0.8 and 2.2 ms pulses respectively)

I don't have my BB-xM handy, but those links aren't the way to do it.

Since one of the three hardware PWM generators has low resolution,
there are essentially two of them remaining. So if there are more then
two motors to control, then those links explains what to do in such
case.

Its not a good practice to use GPIO and timing in userspace to generate servo
signals.

If you will actually read what these articles describes, you will see
that suggestion is to use kernel module and sources are available
here: GitHub - andreynech/rtdm-pwm: Xenomai RTDM driver to generate standard RC PWMs with GPIO on BeagleBoard xM

Interesting, but the kernel module is still bitbanging. I personally try to stay away from it when I can. Also if you are trying to control a lot of servos, why not use the Arduino or a dedicated servo controller?

Interesting, but the kernel module is still bitbanging. I personally try to
stay away from it when I can. Also if you are trying to control a lot of
servos, why not use the Arduino or a dedicated servo controller?

Because it might increase overall system complexity (additional
hardware components, more heterogeneous code, more complicated
build/test system, etc.), physical size/weight and price. If the main
computer has enough spare cycles to drive periphery without additional
external hardware, in many cases I would consider it as a preferred
way.

Our experiments (here is one example: http://youtu.be/6bkbPjGWVoo)
show that BBxM is powerful enough to generate at least two precise PWM
signals with GPIO, controlling two available hardware PWM generators,
compress video with h264 codec in real-time (using DSP), communicating
with bunch of I2C sensors such as sonars and compass, running
communication middleware and navigation logic. So for small hobby
robots I do not really see any reasons for additional
micro-controller.

Appears to be working fine.

Gerald