Author Topic: How to address I2C slaves with conflicting addresses?  (Read 7360 times)

0 Members and 1 Guest are viewing this topic.

Offline zaptaTopic starter

  • Super Contributor
  • ***
  • Posts: 6267
  • Country: us
How to address I2C slaves with conflicting addresses?
« on: April 21, 2014, 07:46:34 pm »
I want to design a circuit with an ATMEGA328P MCU (5V, 16Mhz) and a few LTC2943 (2, 4, or 8) connected as slaves on a single I2C bus (5V, 400KHz). 

The problem is that the LTC2943 has a fixed I2C address so connecting more than one on the same I2C buss will result in a conflict.

Any idea for a simple/compact circuit that will allow to select an individual LTC2943 at a time?  The ATMEGA328P has free i/o pins, possibly even one pin per LTC2943 slave.   This application is not price sensitive.
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13902
  • Country: gb
    • Mike's Electric Stuff
Re: How to address I2C slaves with conflicting addresses?
« Reply #1 on: April 21, 2014, 08:00:47 pm »
Common SCL and an SDA per chip, or a multiplexer (e.g. 405x analogue mux) to mux the SDA lines.
Or common SDA, and mux SCL as it's unidirectional, e.g. using a 74HC138
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline suicidaleggroll

  • Super Contributor
  • ***
  • Posts: 1453
  • Country: us
Re: How to address I2C slaves with conflicting addresses?
« Reply #2 on: April 21, 2014, 08:11:48 pm »
Common SCL and an SDA per chip, or a multiplexer (e.g. 405x analogue mux) to mux the SDA lines.
Or common SDA, and mux SCL as it's unidirectional, e.g. using a 74HC138

I agree on the analog mux.  A 4051 on the SDA line should work fine, as long as the pullups are weak enough that the ~200 ohm series resistance doesn't cause a significant voltage drop.

SCL is not unidirectional, I don't think the 74HC138 approach would work correctly.
 

Offline opty

  • Regular Contributor
  • *
  • Posts: 55
  • Country: ie
Re: How to address I2C slaves with conflicting addresses?
« Reply #3 on: April 21, 2014, 08:26:12 pm »
That is a pity there is no 'enable' input either... :(
 

Offline zaptaTopic starter

  • Super Contributor
  • ***
  • Posts: 6267
  • Country: us
Re: How to address I2C slaves with conflicting addresses?
« Reply #4 on: April 21, 2014, 08:29:37 pm »
Common SCL and an SDA per chip, or a multiplexer (e.g. 405x analogue mux) to mux the SDA lines.
Or common SDA, and mux SCL as it's unidirectional, e.g. using a 74HC138

1. I am using the AVR hardware I2C so SDA per chip will make things complicated. 

2. Analog mux'ing the SDA looks good. I presume I need to have a SDA pull up for each slave, on the mux N side, right? 

3. Is the SCL active only during transfers?  If it's continuous, I would prefer not to switch it asynchronously.  Since it's unidirectional, I presume I can use standard logic mux or 1:N decoder (non OC) and have a resistor only on the master side. Is it right
 

Offline zaptaTopic starter

  • Super Contributor
  • ***
  • Posts: 6267
  • Country: us
Re: How to address I2C slaves with conflicting addresses?
« Reply #5 on: April 21, 2014, 08:30:41 pm »
[SCL is not unidirectional,

How come? Even if there is only a single master on the bus?
 

Offline suicidaleggroll

  • Super Contributor
  • ***
  • Posts: 1453
  • Country: us
Re: How to address I2C slaves with conflicting addresses?
« Reply #6 on: April 21, 2014, 08:41:39 pm »
[SCL is not unidirectional,

How come? Even if there is only a single master on the bus?

Yes even if there is only a single master.  I2C slaves are allowed to manipulate the clock to communicate their current status back to the master.  It's called clock stretching.
 

Offline suicidaleggroll

  • Super Contributor
  • ***
  • Posts: 1453
  • Country: us
Re: How to address I2C slaves with conflicting addresses?
« Reply #7 on: April 21, 2014, 08:50:47 pm »
2. Analog mux'ing the SDA looks good. I presume I need to have a SDA pull up for each slave, on the mux N side, right?

As far as the master is concerned, a single pull up on the master side of the mux would be fine.  I'm not sure what the effect of clocking SCL with a disconnected SDA would be for the "unselected" slaves though.
« Last Edit: April 21, 2014, 08:52:46 pm by suicidaleggroll »
 

Offline Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4319
  • Country: us
  • KJ7YLK
Re: How to address I2C slaves with conflicting addresses?
« Reply #8 on: April 21, 2014, 08:53:44 pm »
Isn't this exactly why I2C bus multiplexers were invented?
Aren't they made specifically for switching I2C bus?  (vs. kludging general-purpose chips)
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13902
  • Country: gb
    • Mike's Electric Stuff
Re: How to address I2C slaves with conflicting addresses?
« Reply #9 on: April 21, 2014, 08:56:39 pm »
[SCL is not unidirectional,

How come? Even if there is only a single master on the bus?

Yes even if there is only a single master.  I2C slaves are allowed to manipulate the clock to communicate their current status back to the master.  It's called clock stretching.
..but in practice is only used by I2C slave peripherals on MCUs - I've never seen an I2C device that does clock stretching
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: How to address I2C slaves with conflicting addresses?
« Reply #10 on: April 21, 2014, 09:03:07 pm »
"How to address I2C slaves with conflicting addresses?"

Simple:

1) Don't allow yourself to get into that situation ever.

2) If you can't, life the ground of the i2c devices. I2C bus then applyes only to the device whose ground is grounded.

3) If all fails, refer to 1).
================================
https://dannyelectronics.wordpress.com/
 

Offline zaptaTopic starter

  • Super Contributor
  • ***
  • Posts: 6267
  • Country: us
Re: How to address I2C slaves with conflicting addresses?
« Reply #11 on: April 21, 2014, 09:04:36 pm »
..but in practice is only used by I2C slave peripherals on MCUs - I've never seen an I2C device that does clock stretching

From the LTC2943's datasheet:

"The LTC2943 is a slave only device. The serial clock line (SCL) is input only while the serial data line (SDA) is bidirectional."
 

Offline zaptaTopic starter

  • Super Contributor
  • ***
  • Posts: 6267
  • Country: us
Re: How to address I2C slaves with conflicting addresses?
« Reply #12 on: April 21, 2014, 09:07:21 pm »
Isn't this exactly why I2C bus multiplexers were invented?
Aren't they made specifically for switching I2C bus?  (vs. kludging general-purpose chips)

Any pointer to an actual device?
 

Online Kjelt

  • Super Contributor
  • ***
  • Posts: 6561
  • Country: nl
 

Offline zaptaTopic starter

  • Super Contributor
  • ***
  • Posts: 6267
  • Country: us
 

Offline AndyC_772

  • Super Contributor
  • ***
  • Posts: 4263
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: How to address I2C slaves with conflicting addresses?
« Reply #15 on: April 22, 2014, 06:46:07 am »
A 405x mux on SDA should work fine. A start condition in I2C is a high-to-low transition on SDA while the clock is high, and this can't happen if SDA is disconnected. So, no SDA = no bus transactions.

Clock stretching is rare on 'real' I2C slave devices, but it does get used if the slave device is a microcontroller. It takes time for software to recognise the slave address, look up the proper result and load it into the outgoing I2C shift register, and if it's a slow processor, the clock must be stretched.


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf