Extended I2C Bus

Thread Starter

robsworld

Joined Nov 5, 2015
83
Hi, I'm working on a project that uses many I2C devices but having trouble increasing the bus capacity.

The project uses an Arduino and I have a PCA9507 bus extender connected to the Arduino and my devices connected to it.

https://www.nxp.com/docs/en/data-sheet/PCA9507.pdf

This works really well but of course up to a point. With this I can connect 10 devices using 1ft USB patch cables between everything. All connections are via USB cables. Without the PCA9507 I can only connect 2 or devices so it definitely works.

But I need more, my thought was just keep putting these PCA9507's inline to recharge the bus however it doesn't work. It doesn't crash the bus but does nothing to allow more capacitance.

Any ideas I can try?

Thanks
 

Papabravo

Joined Feb 24, 2006
14,672
Hi, I'm working on a project that uses many I2C devices but having trouble increasing the bus capacity.

The project uses an Arduino and I have a PCA9507 bus extender connected to the Arduino and my devices connected to it.

https://www.nxp.com/docs/en/data-sheet/PCA9507.pdf

This works really well but of course up to a point. With this I can connect 10 devices using 1ft USB patch cables between everything. All connections are via USB cables. Without the PCA9507 I can only connect 2 or devices so it definitely works.

But I need more, my thought was just keep putting these PCA9507's inline to recharge the bus however it doesn't work. It doesn't crash the bus but does nothing to allow more capacitance.

Any ideas I can try?

Thanks
I2C is probably the wrong solution to what you are trying to accomplish. Instead of trying to put 5 kilos of refuse into a 1 kilo bag, how about stating your requirements for what you are trying to do. In order to engineer a solution you have to establish the requirements.
 

andrewmm

Joined Feb 25, 2011
650
this might be of use, differential I2C
https://hackaday.com/2017/03/31/an-introduction-to-differential-i²c/

https://www.nxp.com/products/interf...-i2c-bus-buffer-with-hot-swap-logic:PCA9615DP

https://hackaday.com/2017/02/08/taking-the-leap-off-board-an-introduction-to-i2c-over-long-wires/

I2C over very long lengths is very possible, The speed does decrease though,

Its also easier if you only have one master, don't try to use multi master, and if you do not use clock stretching,
( if you dont know what either of these is , you don't have them )
 

Papabravo

Joined Feb 24, 2006
14,672
It's the total capacitance of the cable and the impedances of the receivers in parallel that are the killers for off-board I2C. Tread carefully. Don't forget to adjust the strength of the bus pullup resistor(s).
 

Thread Starter

robsworld

Joined Nov 5, 2015
83
Thanks for the replies and I'm happy to say I may have got it working.
I2C is probably the wrong solution to what you are trying to accomplish. Instead of trying to put 5 kilos of refuse into a 1 kilo bag, how about stating your requirements for what you are trying to do. In order to engineer a solution you have to establish the requirements.
Yeah I know I shouldn't really be using I2C for what I'm doing but this project has been expanding from initial plans so I'm stuck with it for now. If I was to redo everything using a different protocol what would you recommend?

- Speed isn't a big issue, as long as it feels real time I'm happy. I'm running I2C at 100KHz which is plenty fast enough.

- The biggest requirement is amount of data it can stream, I have modules that read different sensors and send out 10-30 bytes in a message and I would like more but Arduino wire library doesn't seem to want to send more so I send multiple but would love to send as one message. I get carried away so would like no max lol.

- And as this thread implies cable length is needed, not massive but would like to know it could be 100ft without issue. Don't mind using boosters just don't want too many like I2C.

- Really like 4 wires, 2 data, GND and +12v for USB cables.

- There is only 1 master and all other devices are slaves, up to say 35, which is ok but wouldn't mind slave to slave or slave to master comms, would allow more interaction between devices.

- And finally I'm not the smartest guy out there so need something fairly simple that works with Arduino based microcontrollers. This one is more important than slave to slave.

You mentioned the pullup resistors on the devices, this one I've struggled with as I can't work with those formulas and don't have any real equipment so went with 10k on all devices. Currently the are 19 devices running, 8 more to go. On the output side of the buffer I have 1.5k as 10k seemed to cause harm to them. No issues at 1.5k. How bad does this sound?

this might be of use, differential I2C
https://hackaday.com/2017/03/31/an-introduction-to-differential-i²c/

https://www.nxp.com/products/interf...-i2c-bus-buffer-with-hot-swap-logic:PCA9615DP

https://hackaday.com/2017/02/08/taking-the-leap-off-board-an-introduction-to-i2c-over-long-wires/

I2C over very long lengths is very possible, The speed does decrease though,

Its also easier if you only have one master, don't try to use multi master, and if you do not use clock stretching,
( if you dont know what either of these is , you don't have them )
Thanks for the links, they were a good read. What I don't like about the D12C is 4 wires needed for data, I like USB cables and need 2 wires for power but it's good to know as only hardware needs updating. As I mentioned above its one master and remaining are slaves so this would be ok.

Well for now the PCA9507's are doing what I need after figuring them out a little better. They prefer branching out vs series. In series the boost isn't nearly as great as if its branched out. With this setup the furthest device is 37ft away and there's 37 USB plugs being used to connect everything, that must be the good luck. Working great after 10 hours. If anyone is interested I can post the final layout with 8 more devices and maybe more length.

Thanks again

i2c-connections.jpg
 

Papabravo

Joined Feb 24, 2006
14,672
I would use one of the industrial networks based on a CAN physical layer. You can get 100 meters at 500 kbps. Basic message length is 8 bytes, but fragmentation protocol is available for constructing messages of arbitrary length.
 

Gibson486

Joined Jul 20, 2012
327
There is a tech sheet that shows which device you can use.

https://www.nxp.com/docs/en/application-note/AN255.pdf

It is not exhaustive, but it is a starting point.

The reality, however, is that maybe i2c is not that best option. Or maybe it is, bit you need to rethink your architecture (multiple mcus?). Or even a different protocol. I do not know what the constraints are, so I am not qualified to give you that answer.
 

Thread Starter

robsworld

Joined Nov 5, 2015
83
Thanks for the suggestion Papabravo, I will look into it.

Thanks for that tech sheet Gibson486, that will be an interesting read to see the difference in available chips, too bad it doesn't have the PCA9507 in the mix.

Changing the protocol wouldn't be the most difficult thing as I made all the devices as well using ATmega32U4, only use one chip that's needs I2C but I can replace it as it's nothing special.
 
Top