Society of Robots - Robot Forum

Software => Software => Topic started by: teoxan on September 22, 2010, 09:15:26 AM

Title: Connecting two Axons
Post by: teoxan on September 22, 2010, 09:15:26 AM

I'm trying to find a way to connect two Axons II.

I was thinking through I2C, I need one Axon to be a slave and the other a master. Slave Axon will feed data to master Axon who will decide all robot actions.

Any suggestions?

Thanks!

Theo
Title: Re: Connecting two Axons
Post by: rbtying on September 22, 2010, 09:51:30 AM
I2C would work, definitely, it just needs a little bit of thinking to set up. 
Title: Re: Connecting two Axons
Post by: Asellith on September 22, 2010, 09:53:05 AM
I2C can work and webbotlib supports slave and master I think. I2C has a hardware issue with the ATMEGA series when used in multimaster mode so watch out for that.

To be honest it would be easier to use UART for a point to point setup like your talking about. Unless you want to add more slaves later then UART is a lot easier to code and setup.
Title: Re: Connecting two Axons
Post by: Webbot on September 22, 2010, 10:38:48 AM
Its also possible to use a single UART to talk to multiple boards.
Lets say you have 4 Axons:-
Axon#1:   Receives from Axon#4, Transmits to Axon#2
Axon#2:   Receives from Axon#1, Transmits to Axon#3
Axon#3:   Receives from Axon#2, Transmits to Axon#4
Axon#4:   Receives from Axon#3, Transmits to Axon#1

So you have a 'ring' of boards on a UART network.

Then you can use a message 'packet' such as:

Byte 0 = Originator Axon ID number
Byte 1 = Destination Axon ID number
Byte 2 = number of message bytes that follow
Byte 3 = the message bytes

When a board receives a whole msg it looks to see if Byte 1 = my ID number. If not then just send the whole message on to the next Axon.
If it is for me: then don't pass the message on. If the message requires a reply then send a new message where Byte 0=me, Byte 1=Byte0 of the original msg, followed by the response.

If an Axon receives a msg where Byte0 = my ID then it means that the message has been passed the whole way around the ring - ie nobody responded (perhaps the Byte1 id is incorrect?!). In this case the msg should be removed otherwise it will keep going round and around forever.

Of course you could change Byte 1 to represent an action that the originator wants to be done. For example:
1 = Set left motor speed to the value in the 1 byte message
2 = Set right motor speed to the value in the 1 byte message
3 = Read sonar and return value
This way each board can decide if it is the one that needs to perform the action, and if not, then pass it to the next board.

EDIT: It also means that each board can be both a 'slave' (processes msgs) AND a 'master' (adds new msgs)


Title: Re: Connecting two Axons
Post by: Asellith on September 22, 2010, 01:16:19 PM
What kind of delay are we talking for a 2 way "conversation"? If 1 and 3 are talking I2C then it loops from 1 to 2 to 3 then 3 responds from 4 to 1. All 4 units are busy converting UART instead of avoiding objects or whatever they are suppose to be doing.

If timing isn't an issue and longer (a few extra ms) latency then I guess it would work.
Title: Re: Connecting two Axons
Post by: garrettg84 on September 25, 2010, 06:35:09 AM
What kind of delay are we talking for a 2 way "conversation"? If 1 and 3 are talking I2C then it loops from 1 to 2 to 3 then 3 responds from 4 to 1. All 4 units are busy converting UART instead of avoiding objects or whatever they are suppose to be doing.

If timing isn't an issue and longer (a few extra ms) latency then I guess it would work.

Maybe set some kind of switch up so that when one bot in the loop is busy, he jumper's the connection straight through to the next in the loop...
Title: Re: Connecting two Axons
Post by: Admin on September 25, 2010, 01:57:01 PM
I do Axon to Axon communication all the time, and I just use UART for it.

Its really no different than controlling a single Axon using Hyperterminal, at least in terms of code.