SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By mrjogo
#153664
I'm building a hobby 6-DOF robotic arm and am wondering what the best way is to communicate between the processors (3-4 AVRs, 18 inches max separation). I'd like to have the control loop run on the computer, which sends commands to the microprocessors via an Atmega32u4 USB-to-??? bridge.

Some ideas I'm considering:
  • RS485
    • Pros: all processors on same wire, differential signal more robust
    • Cons: requires additional chips, need to write (or find?) protocol to prevent processors from transmitting at the same time
  • UART loop (ie, TX of one processor is connected to RX of next)
    • Pros: simple firmware, processors have UART built in
    • Cons: last connection has to travel length of robot, each processor has to spend cycles retransmitting messages
  • CANbus (I know very little about this)
My main considerations are hardware and firmware complexity, performance, and price (I can't buy an expensive out-of-box system).
User avatar
By Ross Robotics
#153675
I agree with Blackfin, I2C is fast and has more options as far as debugging and error checking. Just remember to use pull-ups on the lines.

I have 3 custom Ardunos talking to each other in my robot and use I2C for the communication protocol.
By stevech
#153682
I2C is the best... but don't use high speeds (multi-MHz) so that the wiring can be longer and not as sensitive to noise and capacitance of wiring.

I2C's main advantage is that you can address messages to nodes.

For simplicity, one micro should be the I2C master; others are slaves.
By stevech
#153684
I2C is probably the most widely used inter-microprocessor method. Usually wires are just a few inches. Hence the advise for low bit rates and attention to keeping the impedance of the wire low, because it's not a differential media unless you add a level converter for that.

No matter the medium, be sure to put bit error detection in the data messages, e.g., an extra byte on the end of the message which is the checksum, CRC or some such.
By WethaGuy
#153686
Do you really need 3-4 AVR's to control your arm? Seems like one ATmega328 should be enough to do it all on the robot arm end. Maybe I'm missing something.

Also, you can use a cheap RF-12 module to make a wireless serial connection between your computer (thru an mcu or FTDI) and the arm. This would provide more freedom to move the arm away from being right beside the computer. Ideally, you could just use a cheap bluetooth dongle on your computer and a bluetooth modem. But, those are a bit more $.
By mrjogo
#153692
With 12+ motors and sensors, running it all off of one AVR gets a little cramped (specifically in the timer department). The distances are also on the long side for transmitting analog signals without noise/impedance issues.

I've thought about doing RF (specifically XBee), but the cost/benefit/complexity just doesn't seem worth it. Maybe as an upgrade in the future.
By stevech
#153711
Re using wireless for sub-meter data communications range:

If wires can be run in any fashion at all, avoid wireless.
To quote old professor at Stanford: "Wireless isn't a thousand times harder than wired, it's a million times harder!"

And costly and prone to interference.