| Author |
Message |
|
|
Posted: Jul 27, 2007 - 11:16 PM |
|


Joined: Jul 14, 2005
Posts: 261
Location: Denmark (Sønderborg)
|
|
I need to link 15+ ATmega16 together so they can talk together...
What is the best solution ???
Every uC has to be able to talk to all the other uC's... |
_________________ uC's: Atmega16, 32, 64, 128 and Attiny13
Lang.: C
Interests: Small scale robots AND sensor monitoring system
|
| |
|
|
|
|
|
Posted: Jul 28, 2007 - 12:07 AM |
|


Joined: Apr 12, 2007
Posts: 298
Location: Windsor, UK
|
|
Make a 'token' ring with 2 wires. One clock, one data. Declare a master on the ring and give an address to each of the IC.
The master makes the clock, and sends a header with the address of each IC in turn. If an IC receives it's address it can then 'take over' the data line until it sends a terminator and 'release' the data line. The master then sends a header to the next IC etc etc.
Packet looks like :
<16 bits pattern repeated a few times to synchronize everyone, do that judt in czse sync is lost, or at reset time...>
<start of frame><4 bit address of IC A sent by master><4 bit destination address of IC B sent by IC A now that it knows it's it's turn to speak><payload bytes><terminator sequence>
The ICs look for their ID in the first 4 bits in case they have something to send, and in the following 4 bits in case they are sent something.
having 15 ICs meand there is one address left for 'broacast' potentialy.
This protocol doesn't need to handle collisions, the master decides of the 'speak' order. |
|
|
| |
|
|
|
|
|
Posted: Jul 28, 2007 - 12:12 AM |
|

Joined: Apr 01, 2004
Posts: 3812
Location: New Mexico
|
|
|
|
|
|
|
Posted: Jul 28, 2007 - 12:15 AM |
|


Joined: Jul 27, 2001
Posts: 7429
Location: St. Leonards-on-Sea (UK)
|
|
You could also use wireless.
Leon |
_________________ Leon Heller
G1HSM
|
| |
|
|
|
|
|
Posted: Jul 28, 2007 - 12:28 AM |
|

Joined: Apr 01, 2004
Posts: 3812
Location: New Mexico
|
|
| Also, using a bus interface, unless you pack those 15 ATMega16's quite tightly, your tranmission line will be long with respect to the rise time of the signals. You'll want to have impedance-controlled paths between the MCU's with proper termination. Given that you need your signal to be valid across the entire bus length, use parallel rather than series termination. |
_________________ Kevin Rosenberg
http://b9.com
http://kevin.hypershots.com
|
| |
|
|
|
|
|
Posted: Jul 28, 2007 - 09:54 AM |
|


Joined: Dec 17, 2005
Posts: 1498
Location: Europe- Estonia- Tallinn
|
|
use 9 bit USART communications. Very neat and IMHO easyer to use and more reliable than TWI. Also interrupt driven so you don't have to see, if the one addressed was this M16 or the one next to it. You just have to "listen" to the name, and if it's not yours you won't hear/listen to the message itself. Datasheet has more info on it. IMHO it's the best communication between multiple chips as it has no constant master making the clock signal. And it takes the same number of lines as TWI (2+GND).
Cheers,
Rain |
|
|
| |
|
|
|
|
|
Posted: Jul 28, 2007 - 10:24 AM |
|


Joined: Jul 14, 2005
Posts: 261
Location: Denmark (Sønderborg)
|
|
Thx folks for the many replays.
I can see that I need to give a litle more data..
The uC's will set i my coffee table (70x120cm) so the data lines wont need repeaters (I hope )
The Token ring sounds interesting, but is this over TWI or what ???
Blody-orc
I was also thinking on using the UART... but can i juse this between like 15 uC´s ???
wont it be a lot of extra wires ???
if every uC should talk together ??? |
_________________ uC's: Atmega16, 32, 64, 128 and Attiny13
Lang.: C
Interests: Small scale robots AND sensor monitoring system
|
| |
|
|
|
|
|
Posted: Jul 28, 2007 - 12:00 PM |
|


Joined: Dec 17, 2005
Posts: 1498
Location: Europe- Estonia- Tallinn
|
|
| OK sry. my mistake. 9 bit USART still needs one master and others are slaves. Then it seems, that TWI is a better option indeed. |
|
|
| |
|
|
|
|
|
Posted: Jul 28, 2007 - 03:02 PM |
|

Joined: Apr 01, 2004
Posts: 3812
Location: New Mexico
|
|
| buserror's "token ring" is a ad hoc protocol, somewhat similar to TWI. But, is not a formal specification like TWI with support for collisions or multimasters. An AVR datasheet will give you rather full details on the TWI protocol. Be sure to carefully read the multi-master section. |
_________________ Kevin Rosenberg
http://b9.com
http://kevin.hypershots.com
|
| |
|
|
|
|
|
Posted: Jul 28, 2007 - 07:06 PM |
|


Joined: Nov 22, 2002
Posts: 12048
Location: Tangent, OR, USA
|
|
RS485 is a hardware design for multiple talkers and listeners. Minimal hardware is capable of at least 32 nodes in the network.
Alas, there is no RS485 protocol. You can design anything you want. Token passing is good. A "super-master", managing access by other devices is another way. Variants of CSMA (carrier sense multiple access) also work well. There are also a number of commercial defined protocols for this, though I don't recall their names at the moment.
Jim |
|
|
| |
|
|
|
|
|
Posted: Jul 28, 2007 - 07:25 PM |
|

Joined: Feb 19, 2003
Posts: 2233
Location: Seattle, WA
|
|
| CAN seems like a good solution except that the ATMEGA16 doesn't have a built in CAN controller. This could be easily remedied with a CAN controller chip like the Microchip MCP2515. RS-485 would work as well though you'll have to do a bit more work to protect against collisions. I2C multi-master would probably work as well, though you'd be really pushing the limits of the range of I2C. |
|
|
| |
|
|
|
|
|
Posted: Jul 28, 2007 - 09:10 PM |
|


Joined: Apr 12, 2007
Posts: 298
Location: Windsor, UK
|
|
From what I understand of multi-master, you have a group of masters, and a group of slaves, and any master can talk to the slaves by negociating the bus.
Having the MCUs switching back and forth between master (to talk) and slave (to be talked to) is probably not ideal.
RS485 seems a bit overkill, you can have links that are miles long, but whatever you do you need extra power rails for it... I don't think you can do rs485 on naked pins... (?)
What I described is similar to i2c, save that all the devices 'peek' on the line to receive their messages. I've been using a nearly identical system between multiple MCUs (not 15 tho) and it works very well, just by bitbanging the protocol using a timer for the master, and a pin-change interupt for the 'slaves'. |
_________________ Author of simavr - Follow me on twitter : @buserror
|
| |
|
|
|
|
|
Posted: Jul 28, 2007 - 09:46 PM |
|


Joined: Jul 14, 2005
Posts: 261
Location: Denmark (Sønderborg)
|
|
Hmm I think I'm gonna use TWI/I2C
But nleahcim, what limits ??? |
_________________ uC's: Atmega16, 32, 64, 128 and Attiny13
Lang.: C
Interests: Small scale robots AND sensor monitoring system
|
| |
|
|
|
|
|
Posted: Jul 28, 2007 - 09:47 PM |
|


Joined: Dec 17, 2005
Posts: 1498
Location: Europe- Estonia- Tallinn
|
|
| TWI has capacitive limits. You can't run the TWI lines forever because you get noise into the clock line. |
|
|
| |
|
|
|
|
|
Posted: Jul 28, 2007 - 10:00 PM |
|

Joined: Apr 01, 2004
Posts: 3812
Location: New Mexico
|
|
| You can read about the capacitive limits on your datasheet. For the 644P datasheet, the maximum bus capacitance is 400pF. The datasheet further specifies a maximum pin capacitance of 10pF. That leaves you with a minimum of 250pF of PCB trace capacitance with your 15 devices (assuming the '16 specs are the same as the '644P). You can calculate your capacitance per length using a PCB trace calculator such as the one at http://www.technick.net/public/code/cp_ ... alculator. Again, to maintain your signal integrity you should use impedance controlled traces and parallel termination. |
_________________ Kevin Rosenberg
http://b9.com
http://kevin.hypershots.com
|
| |
|
|
|
|
|
Posted: Jul 28, 2007 - 10:09 PM |
|


Joined: Jul 14, 2005
Posts: 261
Location: Denmark (Sønderborg)
|
|
noo damn and I where just thinking about making some wires between them
Is there any TWI repeaters out there? |
_________________ uC's: Atmega16, 32, 64, 128 and Attiny13
Lang.: C
Interests: Small scale robots AND sensor monitoring system
|
| |
|
|
|
|
|
Posted: Jul 28, 2007 - 10:14 PM |
|

Joined: Feb 19, 2003
Posts: 2233
Location: Seattle, WA
|
|
|
B4Me wrote:
noo damn  and I where just thinking about making some wires between them
Is there any TWI repeaters out there?
NXP makes some. I2C is designed to be a board level bus - it is not designed to be run through loose wires like you are planning on doing. Yes, you can get it to work - but you're going out of spec which is never, ever a smart thing to do.
I really think 485 would be your best bet. You'd need RS-485 transceivers but they are inexpensive. |
|
|
| |
|
|
|
|
|
Posted: Jul 28, 2007 - 10:20 PM |
|

Joined: Apr 01, 2004
Posts: 3812
Location: New Mexico
|
|
| You can create impedance controlled cables with known capacitane as well. Simple ribbon cable with ground wires between each signal line has a characteristic impedance and capacitance you can research. |
_________________ Kevin Rosenberg
http://b9.com
http://kevin.hypershots.com
|
| |
|
|
|
|
|
Posted: Jul 28, 2007 - 11:13 PM |
|

Joined: May 24, 2004
Posts: 5996
Location: Tampere, Finland
|
|
One thing more about the USART. You could arrange the 15 devices in a ring, where only one-way communications is possible. If a message was not for the next device in chain, it is passed to the next device in chain. If a node sees the same message it was transmitting, then there was nobody to catch that message.
But yes maybe I2C is better here anyway.
- Jani |
|
|
| |
|
|
|
|
|
Posted: Jul 28, 2007 - 11:27 PM |
|


Joined: Jul 14, 2005
Posts: 261
Location: Denmark (Sønderborg)
|
|
hmm I think I'll try out with I2C and if I can't get it to work I'll try the USART ring method...
Cause 485 will need extra components.. |
_________________ uC's: Atmega16, 32, 64, 128 and Attiny13
Lang.: C
Interests: Small scale robots AND sensor monitoring system
|
| |
|
|
|
|
|