Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I want to be able to exchange data between two units (in my case, two AVR processors), and I want to get away with using no more than 4 wires.

So what are the existing methods for doing this? I know there's USB, but that seems a bit overkill here since I don't need to for example support multiple connections over the same cable.

The requirements are not entirely set but I can at least give some approximations. The AVR processors I intent to use are ATTiny2313 and ATTiny13 which will run at 16 MHz (the ATTiny2313 will also run V-USB). Data throughput is extremely low since I will use this to implement a custom keyboard, so it will probably be something like a few hundred bits/s. The length of the wires will be something like up to one or two meters, maybe three.

share|improve this question
1  
I don't think this is a bad question, necessarily, so I don't think it warranted down-votes. However, it could be improved by elaborating a bit on what your requirements are. How much data do you need to transfer and in what time frame? What is the distance? Which AVR microcontrollers (because they differ in processing speed, built-in communications protocols, I/O pins, etc.). –  JYelton May 11 at 15:46
1  
Does a protocol care how many wires are used? –  Andy aka May 11 at 16:01
1  
How much data (bandwidth) are we talking about? –  Dave Tweed May 11 at 16:43
    
Ok, I'll try to edit the question accordingly. –  gablin May 12 at 10:09
    
@Andyaka: I replaced 'protocol' with 'method'. =) –  gablin May 12 at 10:16

3 Answers 3

Without going into too much detail (because a lot has been said about them here and how much information there is readily available about them), the two main buses you can use are I2C (I-squared-C) and SPI. You can also use UART. Most microcontrollers come with built in modules for this that do the legwork for you.

share|improve this answer
1  
+1 for UART, which is the most obvious and direct solution. –  Dave Tweed May 11 at 16:43
    
with the provided information +1 for UART as well. –  kenny May 11 at 16:57

Common methods are SPI and I2C, often supported by hardware on the microcontroller. I2C requires two signal wires, and SPI needs four including chip select.

SPI is very simple and can often run very fast. I2C can accommodate more than two devices on the bus, requires only two wires, but is relatively complex and can be much slower than SPI.

Both are most suitable for short distances -- like on the same board. For longer distances, you can consider RS-485 (using on-chip UART support) and CAN bus (some chips have hardware support).

Edit: If you use the UART you have to ensure that there is close enough matching between clock frequencies at the two ends that you don't get errors. That can preclude using internal RC clock oscillators, especially if it has to be reliable over a wide temperature range.

share|improve this answer

Traditional Ethernet runs on only one wire (well, one plus ground/shield). And the Chaosnet subset of Ethernet (which doesn't attempt to avoid packet collision and counts on the fact that collision will be retried after a random delay) is only about 20% slower than the full implementation.

With four wires and only two devices being connected, it should be easy; that's a dedicated pair in each direction. UART or other basic serial protocol with appropriate start/stop sequences to synchronize the transmission should work Just Fine.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.