3

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.

BeB00
  • 5,303
  • 2
  • 18
  • 34

3 Answers3

6

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.

Trevor_G
  • 46,364
  • 8
  • 68
  • 151
6

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.

Olin Lathrop
  • 310,974
  • 36
  • 428
  • 915
3

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.

Bimpelrekkie
  • 80,139
  • 2
  • 93
  • 183
  • 1
    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. – BeB00 Sep 04 '17 at 15:08
  • 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. – BeB00 Sep 04 '17 at 15:10
  • My guess is that this will work even at 1 MHz or so. The input capacitance on IC pins is very small. – Bimpelrekkie Sep 04 '17 at 15:11
  • Testing it would be a good idea though, it may well be fine at 400khz – BeB00 Sep 04 '17 at 15:11
  • 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 – BeB00 Sep 04 '17 at 15:12
  • If it does not work, lower the 10 k resistor. They could even be 1 kohm depending on what the clock can drive. – Bimpelrekkie Sep 04 '17 at 15:12
  • The 10k ohm resistors in series with the clk inputs will muck things up if these chips do clock stretching. – The Photon Sep 04 '17 at 15:12
  • True, but so will the diode – BeB00 Sep 04 '17 at 15:13
  • If you cannot get it to work like this then I suggest using some logic or a multiplexer even. – Bimpelrekkie Sep 04 '17 at 15:14
  • Yup I kindof want to avoid having more ICs – BeB00 Sep 04 '17 at 15:15
  • Having thought about this a bit more, I think the diodes may be better, because with this scheme, the more devices you add the lower the high voltage on the clock becomes. If you want 6 devices (so 5 will be low at any one time), to maintain a 2.6 VIH (which is pretty low) from a 3.3V pullup at 1K5 (arduino due), youll need at least 35K series on each line. This is pretty big, and may start affecting the signal, especially when you're that close to the threshold. – BeB00 Sep 04 '17 at 22:18