3
\$\begingroup\$

I have multiple devices with the same address, and only one I2C bus. If I don't want to/can't use an address multiplexer, will the following arrangement work? (sorry for the messy schematic)

schematic

simulate this circuit – Schematic created using CircuitLab

SW1 and SW2 are microcontroller I/O, and are pulled low when we don't want to talk to the corresponding IC, and set to high impedance when we do want to talk to that IC. Can anyone see any problems with this, apart from with clock stretching? Assuming you choose diodes with a small voltage drop, like a schottky.

Edit:

Also assuming that the VIH and VIL all worked out with the diode drop and the VOH VOL.

The diodes could also go on the data lines instead, not sure if there would be any benefit/difference (maybe some I2C devices do something special when the clock goes low even if it's not their address? It's probably safer to not clock at all i.e. have the diodes on the clock lines.

\$\endgroup\$
1
  • \$\begingroup\$ yes, that's the point \$\endgroup\$
    – BeB00
    Commented Sep 11, 2017 at 19:15

3 Answers 3

6
\$\begingroup\$

I think I'd be tempted to do it this way.

schematic

simulate this circuit – Schematic created using CircuitLab

The Enables from the microcontroller basically act to enable the pull-up, though, depending on the device, the resistors could be internal to the micro, and you could turn them on and off when needed.

However, in reality, by the time you add all the diodes and resisters and route it all, a multiplexer would probably have been cheaper, would take less real estate, and require less IO pins.

\$\endgroup\$
0
6
+25
\$\begingroup\$

Your scheme uses 4 signals total. 2 are for the IIC bus, and two more to enable the clock line to each slave device. You therefore obviously do have extra signals available.

Instead of switching the clock lines, consider using two separate clock lines. That's only 3 lines total: SDA, SCL1, and SCL2.

IIC is very easy to implement directly in firmware. You can therefore use any ordinary digital I/O pins you like, toggling them between active low and high impedance. I have done this many times. The only wrinkle in this case is that the next level up has to tell the low level IIC code which clock line to use.

This also has the side effect of leaving a clock high when not in use.

Before you do all this, you should really look around for ICs that perform the function you want that have a configurable address. Just about all IIC chips I have used have the ability to have at least one address bit, usually 2-4, configurable.

\$\endgroup\$
3
\$\begingroup\$

Not sure why you would need those diodes when you basically want to disable the clock of the chip you do not want to address.

I think this is much easier and will do the same:

schematic

simulate this circuit – Schematic created using CircuitLab

I'm assuming you're using CMOS logic chips, then the 10 kohm will be no issue. Also assuming the Clock can drive 10 kohm to ground. If it is also a CMOS logic output, that will not be an issue.

\$\endgroup\$
11
  • 1
    \$\begingroup\$ The problem is that I2C is open drain, so that 10k resistor will not work. A different value might work, but I have a feeling that it wont. \$\endgroup\$
    – BeB00
    Commented Sep 4, 2017 at 15:08
  • \$\begingroup\$ Oh right I see, you mean just have one pull up resistor on the left. That might work at lower frequencies, but I'm not sure at higher ones. \$\endgroup\$
    – BeB00
    Commented Sep 4, 2017 at 15:10
  • \$\begingroup\$ My guess is that this will work even at 1 MHz or so. The input capacitance on IC pins is very small. \$\endgroup\$ Commented Sep 4, 2017 at 15:11
  • \$\begingroup\$ Testing it would be a good idea though, it may well be fine at 400khz \$\endgroup\$
    – BeB00
    Commented Sep 4, 2017 at 15:11
  • \$\begingroup\$ I think it's also about the wire length, as I2C is used a lot for sensors which tend not to be super close to the MCU \$\endgroup\$
    – BeB00
    Commented Sep 4, 2017 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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