Author Topic: Resolved: I2C and the case of the disappearing device...  (Read 782 times)

0 Members and 1 Guest are viewing this topic.

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2507
  • Country: gb
Resolved: I2C and the case of the disappearing device...
« on: October 04, 2019, 10:07:21 pm »
... let me tell you a story...

I have a PCB which has two I2C devices on it and some pull up resistors from SCL to VCC and SDA to VCC.  I picked 47k as a value for the pull-ups  :o

Now to test the set-up I have been using an Arduino UNO (effectively a AVR 328P) using the 'Wire' library which uses TWI and turns on the internal pull-ups which are around 20k.

Testing (100kHz) shows that almost always I see the device nearest the UNO; the further device only appears sometimes.

Now I am assuming this is because I was wrong in picking 47k?  But why?
« Last Edit: October 04, 2019, 10:47:50 pm by NivagSwerdna »
 

Offline Dabbot

  • Regular Contributor
  • *
  • Posts: 198
  • Country: au
Re: I2C and the case of the disappearing device...
« Reply #1 on: October 04, 2019, 10:26:18 pm »
I don't see why it would be the resistors. Remove them, given the lib is using internal pull-ups? Can you disable the internal pull-ups? Try slower / faster operating frequencies?
 
The following users thanked this post: NivagSwerdna

Offline hexreader

  • Frequent Contributor
  • **
  • Posts: 272
  • Country: england
Re: I2C and the case of the disappearing device...
« Reply #2 on: October 04, 2019, 10:33:00 pm »
I know little about I2C, but 4k7 seems to be the most common value for pull-up. I have seen 10K and 2k2, but never 47K.

47K seems way too high to me.

As to why - no idea. I just copy schematics of professional products that I trust.
« Last Edit: October 04, 2019, 10:34:37 pm by hexreader »
 
The following users thanked this post: NivagSwerdna

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9964
  • Country: us
Re: I2C and the case of the disappearing device...
« Reply #3 on: October 04, 2019, 10:43:17 pm »
47k is way over the top.  There is a specification by NXP that shows how to calculate the resistors but 2.2k isn't too small.  I tend to use something around 4.7k.  Never as high as 10k.

Section 7 here:

https://www.nxp.com/docs/en/user-guide/UM10204.pdf
 
The following users thanked this post: NivagSwerdna

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2507
  • Country: gb
Re: I2C and the case of the disappearing device...
« Reply #4 on: October 04, 2019, 10:46:42 pm »
Thanks all...

I read the datasheet a bit more carefully  :palm: and found...

" In typical applications, values of 1.8 kΩ to 4.7 kΩ are used, depending on the bus capacitance, I/O voltage, and the desired communication speed. "

Which is consistent with your ideas above... looks like I was an order of magnitude out... I'll tweak it and see what happens.

 8)
 

Offline Neilm

  • Super Contributor
  • ***
  • Posts: 1560
  • Country: gb
Re: Resolved: I2C and the case of the disappearing device...
« Reply #5 on: October 05, 2019, 05:02:20 pm »
When I am doing a design with I2C I always measure the rise times of the signals. The devices will all say what rise times they are expecting so you can then tweak the pull up resistors as required. Bare in mind that too low will mean the devices could struggle to pull the bus down as the devices also have a maximum current they can deal with.
Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe. - Albert Einstein
Tesla referral code https://ts.la/neil53539
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf