1
\$\begingroup\$

I'm desigining several modules (e.g. sensors, motor controller, etc.) that need to communicate over I²C. These modules can be up to 15ft (5m) away from the base module (I²C master - Spark Photon) - although most will be less than 5ft away. To keep connections simple, I would like to be able to daisy-chain these modules.

Each module uses an ATTiny84/85 which handles the various functions of each module (e.g. ADC/DAC). Each micro also acts as an i2c slave (configurable address) and responds to commands from the I²C master (Spark Photon).

I'd really like to use (abuse) an ethernet (RJ45) style cable. Given that ethernet cables are widely available in various lengths and relatively inexpensive, they would be ideal. I could provide power (3.3V & 5V) and ground as well as the I²C lines to each module and still have spare wires I could potentially use in a future revision. I could even use two twisted pairs to shield the i2c lines. Maybe? The only downside I see here is that someone might be using a crossover cable, which could potentially mess things up.

Alternatively I could use USB cables (A style female extension cables). If I give up separate power lines and use a voltage regulator on the modules that require 3.3V. I'm not sure if my length requirements would be met here, but if daisy-chaining works, this shouldn't be a big problem.

Are there RJ45 connectors that would allow me to use a wire-to-board style connector (e.g. Molex Mini-Latch)? I'd really like to not have to deal with the precision milling and the cost through-hole or surface mount style connectors require.

The same would go for USB style connectors.

UPDATE: It appears that I²C is indeed a viable solution. My biggest concern at this point is the cable to use and if there are connectors available that do not need to be directly soldered onto the PCB (wire-to-board would be ideal).

\$\endgroup\$
  • 1
    \$\begingroup\$ I²C is not optimal for longer distances as the wire capacity starts to degrade your signal integrity, also if you want to daisy chain them, would the total wire length not be even longer and make things even worse? \$\endgroup\$ – Arsenal Feb 17 '15 at 20:52
  • \$\begingroup\$ Going to need a driver for this to maintain high slew rates at high speed at long distance. \$\endgroup\$ – Jon Feb 17 '15 at 20:54
  • \$\begingroup\$ Hmm. I didn't think of that. Although I did a quick google search and found this: P82B715 \$\endgroup\$ – davethebrave Feb 17 '15 at 21:07
  • \$\begingroup\$ Indeed; parasitic capacitance is your main enemy here. Also, keep in mind that the ATTiny doesn't have I2C; it has "I2C", which is only a wrapper around a (single) hardware serial component. To make them repeaters, you'll have to use SoftwareSerial for at least one. \$\endgroup\$ – Jon Feb 17 '15 at 21:13
  • 2
    \$\begingroup\$ I've interfaced I2C to an Arduino and noticed that slowing down the bus speed does not break the protocol. If capacitance becomes a problem then simply slow things down. I2C is not time-based (unlike OneWire or RS-232). \$\endgroup\$ – captcha Feb 17 '15 at 21:33
2
\$\begingroup\$

If "daisy-chaining" means that data will come in on "I2C0" and be repeated out "I2C1", you shouldn't have many problems other than your slaves being too busy responding to interrupts to measure anything.

"Daisy-chaining" could also mean bussing them.

In either case, consider raising your voltage and/or using a buffer/line-driver (at least between the longest runs). This approaches a redesign of RS-232.

Simple and might be good enough:

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
  • \$\begingroup\$ Thats actually a pretty nice little schematic \$\endgroup\$ – Funkyguy Feb 17 '15 at 21:35
  • 1
    \$\begingroup\$ I would like to take the credit, but its just a scaled-up "equivalent circuit" of most MCU pins :) \$\endgroup\$ – Jon Feb 17 '15 at 21:41
  • \$\begingroup\$ I actually meant daisy-chaining more in the sense that each module has 2 connectors, and the lines, specifically the I²C lines, are shared between them. So in essence it's bussing them. \$\endgroup\$ – davethebrave Feb 17 '15 at 21:52
1
\$\begingroup\$

The datasheet for the P82B715 I2C bus extender claims it can drive I2C signals up to 50m over twisted pair cables such as Cat5e, although they say 30m is a safer figure. That is still way more than what you require.

These figures assume a data rate of 100 kHz; since you will be communicating over a much shorter distance you might get away with a faster rate, either 200kHz or even 400kHz.

enter image description here

As you can see from the schematic, you can have more than two P82B715 chips connected together on the same external bus (signified by the four dotted lines going off the bottom of the diagram), so it can take the shape of a star network instead of just point-to-point.

The IC's are available from Digi-Key for three to four dollars.

\$\endgroup\$
  • \$\begingroup\$ That's exactly what I was hoping for. Thanks @tcrosley! I don't think speed is a big problem. Essentially I just request data from each connected sensor at 2Hz or less and send commands to the motor controller even less frequently, if at all. So 100kHz will be adequate. \$\endgroup\$ – davethebrave Feb 17 '15 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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