cabled I2C PCB considerations

blazini36

Active member
I'm re-doing a project that originally used an Arduino Mega. I wanted to use a Teensy 4.1 but it's short on pins and voltage level...etc. I have to make some changes basically to work around some firmware issues and I figure I may as well just switch to the Teensy since I have to redo the PCBs. The original thing was a Break out board for the Mega and a 32key matrix keypad/w LEDs. On the new design I'm using MCP23017's on the keypad. and this has to go over cable about 2ft long. When I do board to board stuff with the Teensy I generally use a TCA39309 which is an I2C level translator (3.3v to 5v).

I started to do the schematic with the level translator but then I thought about how finicky I2C is. I came across the P82B715DR bus extender that's meant specifically for cabled I2C but it's suggested to use one on both ends of the cable. I'll likely use some 4C, 2 twisted pair, 2 shielded 18awg cable as I have plenty of it on hand with JST connectors on both ends. The thing I'm not sure about is if it's necessary or it's overkill to use the bus extender ICs vs just using the level translator on the Teensy BOB.

For reference the Teensy BOB will be replacing the BOB with the Arduino Mega and the other end of it is the keypad that's mounted to the hinged door (not in photo)

20240302_222916_small.jpg
 
It’s probably overkill, I’ve run 5v i2c over at least 25ft. It just depends what speed you are looking to run at. Best thing to do is to just test it.
 
Yeah I think I'll just use the level translator, These are just chips for IO pushbuttons
Another thought might be to put a cheap microprocessor at the remote end that watches the buttons, and communicates the results over a serial UART, using something like RS-422 or RS-485 (or even home-brew connection with checksums).
 
I don't think I wanna go that route. The keypad requires 64 IO, so I'd still have to use some kind of expander or mux ICs on the keypad even if I did use a small microcontroller. Stacking 3 layers of serial just to read/write buttons/LEDs is a bit much. It'd be easier just to use the bus extenders if I have issues.

I finished up the design on the Teensy BOB and I2C keypad using 4 16bit I2C expanders. I think the level shifted I2C will be fine, worse comes to worse I may have to play with the pullup resistors on either side.
 
I don't think I wanna go that route. The keypad requires 64 IO, so I'd still have to use some kind of expander or mux ICs on the keypad even if I did use a small microcontroller. Stacking 3 layers of serial just to read/write buttons/LEDs is a bit much. It'd be easier just to use the bus extenders if I have issues.

I finished up the design on the Teensy BOB and I2C keypad using 4 16bit I2C expanders. I think the level shifted I2C will be fine, worse comes to worse I may have to play with the pullup resistors on either side.
I probably wasn't clear. I meant you would put a cheap microprocessor at the remote end along with all of the I/O expanders to handle the buttons. That microprocessor does the button reading using the 4 or so I2C expanders, and it uses a single UART to communicate reading the buttons.

I would imagine given I2C is a protocol that needs communication in both directions, that with longer cables, you will have more problems with noise. With UART, you can put noise handling into the protocol by using something like RS-422 or RS-485 (I don't remember the specifics of these), or just use a simple couple of bytes to indicate which button was read and add a checksum along with logic to resend packets, etc. And if you use the hardware options, you don't have to write much code to get this to work (you would need to set up flow control like RTS/CTS).

But it is likely a matter of scale. Perhaps you only need something like a UART with error recovery for longer cables than you are using. Perhaps not.
 
I know exactly what you meant. Like I said, it's 3 layers of serial protocols just to read some buttons. USB->Teensy, TeensyRS485->keypadMCU, KeypadMCU->I2C eapanders

The cable is 2ft long, what I was asking in the original post was if it might be necessary to use bus extenders, which are just small ICs meant to extend the I2C bus over a cable. You're suggesting I add a microcontroller to the keypad and everything that goes along with that, and RS422/RS485 differential transceivers on both PCBs? Lol if bus extenders is overkill for 2 ft of cable then that's serious overkill and beyond that it's overhead. I've added Attiny's to PCBs for various reasons like replacing ADC chips and configuring step drivers but it's not making sense for this purpose.

BTW, UART doesn't have "error recovery", it's just TTL serial. RS422 and RS485 don't have any "noise handling" anything. They're differential signalling standards, which has inherrent noise immunity. If I was really worried about noise I would just use the SPI version of these chips and transmit SPI over RS422 as RS422 is purely an elecrical spec for full duplex differential signalling. It literally just splits a single ended signal into a differential pair and then recombines it on the other end. I2C is half duplex, they make special differential I2C extenders that work on the same principle as half duplex RS485.....this is all overkill for 2ft of cable. The extenders I mentioned are basically just signal conditioners and are good for 50meters, but even that is probably overkill.
 
Back
Top