I'm contemplating a project that would require several AVRs talking to each other over a bus. They'd be separated by as much as 6 feet.
It seems like both I2C and SPI can let a series of micros communicate over a bus, but I haven't seen anything talking about how long that would be. Has anyone tried connecting these protocols over distances of several feet?
Answer
As others have said, SPI and I2C can be used over long distances as long as the pull-up resistors, clock frequencies and so on.
The main alternatives (which will give better noise immunity) are RS485 and CAN. Both of these use differential lines in order to minimise noise issues and are better suited to this length of data transmission than I2C or SPI. However, I don't think many (any?) AVRs come with built-in CAN peripherals, which make CAN use much easier.
I would say that the most important thing to consider when picking a bus is to ensure that the protocol you use for communicating between devices includes a CRC or equivalent so that you can determine whether a message has been received correctly (CAN has this as part of the packet). Considering this, it's also useful to have an ACK/NACK type response as part of the protocol so that a corrupted message can be re-transmitted.
No comments:
Post a Comment