AVR I2C Communication

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all,
In a recent project im working on, ill be using 3-4 Laptop Batteries...Now these laptop batteries are Li-Ion Batteries with SMBus Technology which is similar to I2C protocol..
Using this I2C protocol on AVR...i can easily communicate with the battery and obtain the relevant data like Voltage,Current & Temprature etc etc...
Now the thing is since the Address of the Smart Battery is fixed(0x16) for all Laptop Batteries...
How can i communicate with several SMBatterys using a single I2C interface...?
One of the possible solution i thought about is to implement software I2c on idividual pins that are separetely connected to each battery..and read them polling...But i think there is some better way of doing this...

Please help with your suggestions..
Thanx & Regards.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Use separate SCL lines for each battery.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Or use a data multiplexer that will attach the selected battery to the I2C bus. I just used two cd4066's to make four same-addressed sensors operate on the same bus. Use an individual port pin to select the pair of switches for the device you want to talk to and the TWI routine.

It will require you to know which battery you are talking to, but it will work

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lennart wrote:
Use separate SCL lines for each battery.

I guess it matters little, but I would have suggested separate SDA lines, to avoid other batteries seeing start or stop condition every time the clock changes state. Of course then the other batteries will see clocks during bus idle condition, so not much better either.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Using the switch method I suggested will prevent that as both the SDA and SCL lines will be isolated for each battery until selected

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thats an awesome idea using a Multiplexer..
Thanx alot guyz...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I hope this does not come too late, but there are also specialized I2C multiplexer chips, that are essentially analog switches that can be controlled via the same I2C bus as you would multiplex anyway.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just tried CD4066, seems to work OK..10K pullup resistors are connected to SDA & SCL line...But sometimes Im not able to get the data out of the slave device...
Here is the schematic...Please suggest any solution for this

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just figured it out...
I hooked other 2 10K resistors at the data & Clock lines at the slave side...& it started working..
One more thing is that its not actually neccessary to use 2 Bilateral switches per slave..
Just switching either clock or data line still works...
Thanx for your help guyz..