2

I'm designing an arduino based board which will uses I2C port a lot. I want to be able to connect several slave devices, and/or connect several mother boards together (at least 4 would be great). The I2C will run at 400kHz @ 3.3V. The flat cable between the boards can be up to 2 meter long.

Edit : When I say I plan to use 4 main boards at the same time, only 1 of them will be the master/host.

  • Pull up resistors

My problem is not really about choosing the right value of the pullup resistor (for that I found this interesting article). It's more about "design patern".

According the aforementioned article, I should use resistor between 4.7kR and 1.5kR. It's ok as long as I only have one main board with its pullups and slaves with no pullups, but if I connect several main boards together, the pullup resistor will be in parallel, and then too low.

Should I add some jumpers to enable/disable the pull-up resistors ? I don't like this solution at all, it takes space on the PCB and is not handy. And I want my board to be easy to use, just plug things together and everything works.

If I use 4.7kR resistors and hook up 4 main boards together, I will have a equivalent pullup of 1.2kR, which is pretty low, and then it will consume more current (my device is battery powered), the devices will have to sink all that current (I can't predict the sink capability of the slaves that will be connected to the I2C port).

  • Shielded cable

Should I use shielded cable between devices as it will be quite long (up to 2 meters) and the voltage quite low (3.3V)?

  • Connector

Finally, I didn't found any "regular" I2C connector. The most common seems to be 4 pin SIL connector with pins in that order : GND, VCC, DATA, CLOCK (on seeed's grove or tinkerkit for example). Sounds good to me, but any suggestion is welcome.

  • Naming

Bonus question : should I write "I2C" or "TWI" on my PCB ? According to wikipedia TWI seems to be an incomplete implementation of the I2C protocol. Tinkerkit uses "TWI", but "I2C" seems to be more common in electronics.

Passerby
  • 72,580
  • 7
  • 90
  • 202
Rodot
  • 51
  • 4
  • I2C is not really made to connect multiple initiators together. For that you really need to be adapting the SMBus protocol that has an arbitration protocol defined. – Michael Karas Oct 13 '13 at 21:03
  • My question was not very clear, in fact I meant that you can use one main board as master and extension boards as slaves, or several main board but with only one of them being master. Thanks for your answer, I will look into that. But I think I will use I2C anyway because it's more popular in arduino world. – Rodot Oct 14 '13 at 15:14
  • 1
    I2C absolutely supports arbitration of multiple bus masters. – Jon Watte Oct 28 '13 at 19:05

4 Answers4

4

wire capacitance is what you are fighting - you can only go as fast as you pullup resistors can charge the parasitic capacitance of the wires - in the real world you make a good guess and then once you start working with the circuits drop a 'scope on on the data line - if you see a bunch of nice square waves you're good to go. On the other hand if you see a bunch of shark fins some of which don't make it all the way high before the clock edge you're either going too fast or need a smaller pullup

Taniwha
  • 1,636
  • 9
  • 8
3

Armoured cable has nothing to do with distances and voltages - if someone is likely to put a spade through the cable, armour it, otherwise don't. Perhaps you meant shielded cable, which is a different thing entirely - armoured cabled is mechanically protected by having an mechanically strong barrier around it, shielded cable is electromagnetically protected by having a light weight conductive, earthed sheath.

If you want to be able to have multiple masters, they you probably don't want I2C, and instead could use one of several other protocols which do allow for that. As I understand it, I2C is designed for communicating between chips within a PCB, the assumption is that you don't connect between PCBs so there isn't a standard connector - the cables would have to be fairly short (your 2m cable is two times too long for any I2C implementation I've seen). The prototyping board connections you mention aren't really how I2C works in the wild - it's within a single board, not a pluggable system.

Pete Kirkham
  • 1,976
  • 12
  • 16
  • Yes I meant shielded, and I think 1m cable would be ok. Thank you for your answer. I can't "+1" your answer yet, I don't have enough reputation. – Rodot Oct 13 '13 at 21:33
2

Write capacitance or inductance is not very likely to matter at 2m and 400 kbit.

I2C does specify multi-masters arbitration, so you could have multiple masters if you wanted. You could even have the same board be both master and slave.

I2C is not specified for long runs. That's why there is no standard connector. It may work still. I'd try STP cable probably with two pairs if you need to supply power.

I'd use 4.7 or so kOhms pull up per master. The current used when signaling zeros is the same outer main board, so you can count this into the power budget per board. Another option is to only pull up when not powered from the bus, and only put a battery on one of the boards.

Jon Watte
  • 5,650
  • 26
  • 36
1

i2c does have multi-master, 4x 4.7k would be about 3mA or so at 3,3, which could be a problem for some i2c chips but not many. The RasPi uses 1.8K pullups and they don't seem concerned with sink current.

Definately don't use anything less than 4.7k if you expect to use up to 4 devices. Maybe even use 1% accuracy resistors as they aren't really much more expensive than common 10%.

Category 5 cable is only 52pf per meter. If you use shielded stranded cat5, you could probably be just fine with 14-25K resistors. Basically the cable capacitance makes an RC lowpass filter with the pullup resistor, and the capacitance times the resistance tells you how long it will take to charge to about 63% of its final voltage. Most i2c chips use TTL levels that consider even 1 volt as a logical high, and there is no resistor besides series resistance of the chip pin limiting how fast it can be pulled down.

For i2c, you want to be sure the rising edge of the clock gets to the receiver before the data on the data line can change, and you want to be sure the data line has settled before the clock rising edge arrives.

If your lines have equal capacitance, the second concern mostly goes away because the clock is sent a bit after the data. If using cat5, maybe use the two conductors in a pair for SDA and SCL? It probably won't be an issue.

Because there is no resistor when pulling down, the data could change almost instantly at the end, The first concern means you probably want your time constant to be at most a little more than half your bit time.

Long distance i2c is not considered the "right" way but can work fine. Prototype first, try 18K or so with cat5 or similar good cable and see how far you can go, make sure i2c provides all the features that you need.

Also, beware that if you ever want to ass a soldered on i2c slave to the motherboard, you will need a separate i2c interface from the ones used or talking between motherboards, or else you might have address conflicts between the slave devices on the two motherboards.

EternityForest
  • 691
  • 4
  • 6