Let's Make Robots!

Arduino XBee Serial Multiple Servo Solution

Here i present my Arduino XBee Serial Multiple Servo Solution

Here is a Sketch of the system (apparently sketching your ideas is the thing todo...........)

I thought i was home and dry with my Depron1, Depron2 project untill i found out that mixing serial data and servos (ie >2 servos) with the Arduino environment is just not possible (due to the complexity of the multiple interrupts).

Here is my solution so far :-

Take 2 Atmega 328 chips with the Arduino Bootloader.

We call them AtmegaSerial and AtmegaPWM

Connect the data pins (d0-d7) of both AtmegaSerial & AtmegaPWM together  - this will be your 8bit parallel data bus.

Connect the data pins (b8-b10) of both AtmegaSerial & AtmegaPWM together - this will be your 3bit parallel address bus.

Here is how it works :-

Serial data (servo positions) are TX_ed over an XBee link.

The RX Xbee ports the serial data to the AtmegaSerial chip, which then sorts and stores the servo positions into an string array.

The AtmegaPWM (servo driver) chip clocks its address bus  (b8-b10) in the background.

The AtmegaSerial chip is watching this address bus and applys the corresponding data to the data bus (d0-d7)

The AtmegaPWM (servo driver)  reads the data off the data bus and sends a PWM value to the servo(s), "Yo", we have contact.

Ok - Here at LMR you get to see the nuts and bolts.

Yes it works........... now i have to push it to see just how many Servos i can control with it.

I will not be testing more than 6 servos - unless a generous vendor would sponsor some more (haha).

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I’m probably missing the big picture, but are you only trying to control 6 servos via a Xbee?
Wouldn’t it be easier to use a serial servo controller and just hook the XBee straight onto that?

Thanks for the tip....... i was thinking along these lines....

....however i had a feeling that using an arduino (Atmel328) would be in simular direction.

Making it this way does make it cost effective, however i have now some code that eliminates the the second atmel.

This means that i can now send servo positions to the XBee and single Arduino (5 channel so far ....up to 10 if needed)

I have an Arduino Duemilanove here controlling 10 servos with commands sent through the hardware serial with no problems. I see you're using a software serial library, but is that essential, can't you just hook the xbee in the plane up to the hardware RX & TX? Are you using Arduino 018 as that has big improvements to the Servo library (since 017 I think)?

Yes i have also tried with the Hardware RXTX, but to no avail.. (Arduino 018)

I am using speeds up to 38400 Baud maybe this is an issue.

If you could post some of the set up code i would be more than interested or maybe you could blog the servo system you have....

http://letsmakerobots.com/node/22179 . It's being used for control from a joystick but that is harder to set up so I made a separate test program. It seems to work OK at 115200 but maybe it is getting some extra buffering from the USB to serial interface, I don't know.

This tip will make a lot of people happy - thanks for posting.

(i wasted many hours trying to solve this one........)

It works fine on my system, all i have to do now is add the Xbees.....

Wow that is really confusing.

Would an Arduino Mega have the abilities you need?

Maybe you need a ATmega1280 breakout board?

In nutshell :- 1 chip for serial only - 1 chip for PWM only - communication over data and address lines.

Then you get around the limitations of the arduino overloading its interrupts.

As i need only 5 servos at present i can stick to a simple system....(i have a mega in reserve)

....however to push it further ie 16 servo with xbee serial then a guess expanding to the 1280 would be a good idea.(but as far as i can calculate with arduino boot loader you will still need two chips anyway.

Thanks Eckard for your input.

I have not seen this before and this would be a neat way to go, i will have to try it out before i comment.

My first impression is that for every 2 servos you would need 1 dedicated arduino. (i need 5 for my project)

With my system you would need only 2 arduinos for maybe 8 servos (speculation arduino-mega would support more)

It would be a neat way of networking.