Author Topic: I2C calculator  (Read 2513 times)

0 Members and 1 Guest are viewing this topic.

Offline Nikos A.Topic starter

  • Regular Contributor
  • *
  • Posts: 238
  • Country: cy
I2C calculator
« on: July 26, 2021, 09:22:05 am »
Hi guys,

I did a spreadsheet calculator based on the I2C-bus specification https://www.nxp.com/docs/en/user-guide/UM10204.pdf to calculate the I2C pull-up resistors. Could someone validate this calculator?

I have used the equations for Rmin and Rmax in Section 7 pg 55 and Tables 9 & 10 pg 47-48

In my application, I will use the standard mode (100kHz) and Vcc = 1.8. Taking into account the bus capacitance I calculate Rmin = 480ohms and Rmax = 35k.
Between the range 480ohms - 35k what resistor should I select?

If I want to use fast mode (400kHz) then I calculate Rmin = 480ohms and Rmax = 10.5k
Between the range 480ohms - 10.5k what resistor should I select?

Also another engineer told me that regarding I2C bus, there are two things you need to worry about: total bus capacitance and input impedances of the node. My calculator do not take into account the input impedance of the nodes.. Should I take it into account and how should I modify my calculator in that case?

Thanks
Nick
 

Online Siwastaja

  • Super Contributor
  • ***
  • Posts: 8172
  • Country: fi
Re: I2C calculator
« Reply #1 on: July 26, 2021, 10:08:33 am »
Smaller value increases margin against noise, but increases power consumption during transactions: whenever a device outputs '0', current I = Vcc / Rpu flows through that resistor.

I just usually default to 4.7k unless it's a high-speed bus or shares enough devices that 4.7k is uncomfortably close to the maximum value (obtained with similar calculations you presented), in which case I reduce it to 2.2k. Or obviously for BOM optimization, some close-by value.

For low power design, increasing speed instead of the pull-up value and getting back to sleep faster is likely better choice.

I also prefer to leave a bit safety margin on the low side because the driver's Rds_on (i.e., the transistor resistance) may be underestimated in some formulas. This output pin resistance forms a voltage divider, rising "zero" voltage above zero, again bad for noise margins. For example, if Rio = 50 ohms, Rpu = 500 ohms, Vdd=3.3V, zero level will be 50/550 * 3.3V = 0.3V. This may be still acceptable but just barely so. For this reason alone, I never go below 1kOhm. If I have to "for speed", I2C is clearly the wrong choice.

But as you found out, generally, the suitable range of resistor values is wide. Pick something in the middle of that range, when unsure.
« Last Edit: July 26, 2021, 10:15:17 am by Siwastaja »
 

Offline Renate

  • Super Contributor
  • ***
  • Posts: 1460
  • Country: us
Re: I2C calculator
« Reply #2 on: July 26, 2021, 10:43:45 am »
Best results for minimum current and maximum speed would be with a constant current pullup.
I don't think that I've ever seen that done though.
 

Online Siwastaja

  • Super Contributor
  • ***
  • Posts: 8172
  • Country: fi
Re: I2C calculator
« Reply #3 on: July 26, 2021, 01:58:26 pm »
Best results for minimum current and maximum speed would be with a constant current pullup.
I don't think that I've ever seen that done though.

Yes, that can be done and I think I have heard of someone doing that, but really, makes no sense, it's like retrofitting a modern computer controlled direct fuel injection system into a carburetor based cheap lawn mover which is used twice a year.

I2C is supposed to be minimized cost, highly integrated, minimized number of parts, and slow. The real speed optimization is getting rid of the pull-up concept completely, not trying to improve it. For example, SPI easily performs at up to 50MHz on a PCB, and if that is not enough, then we are discussing real differential high-speed physical interfaces.

Low power consumption is mostly achieved by avoiding excess communication. If large amounts of data is moved around through I2C, something's weird in the design. Usually it's used to configure some settings initially, or query slowly changing measurements like temperature or battery voltage.
« Last Edit: July 26, 2021, 02:00:16 pm by Siwastaja »
 

Offline Nikos A.Topic starter

  • Regular Contributor
  • *
  • Posts: 238
  • Country: cy
Re: I2C calculator
« Reply #4 on: July 26, 2021, 07:40:24 pm »
Thank you for your answer guys!!
 

Offline Nikos A.Topic starter

  • Regular Contributor
  • *
  • Posts: 238
  • Country: cy
Re: I2C calculator
« Reply #5 on: July 27, 2021, 07:16:27 am »
Hi again,

I just want to comfirm the following advice that an engineer provide me. He told that I must take into account the input impedance of the I2C nodes.

He told me the following:

"As a rough estimate, count on about 50K as the input impedance of each digital input. So here is an example:
Assume you have five devices on the bus, at 50K input impedance each, and you chose a pull up resistor of 10K

1. Equivalent input impedance seen by the driver is 10K.

2. The maximum logic high level you will see is 1/2 of your unloaded logic high. That's because of the potential divider effect of 10K:10K. So, if you have 3.3V logic, you will now see 3.3V/2, or 1.65V. That will not be enough to register as a logic 1.

3. If you had a 2K pull up instead, your logic 1 voltage would be (10K/12K) x 3.3V, or 2.75V. That is enough to register as a logic 1.
"

Is this rough estimation about 50k of imput impedance valid and should I take it into account before selecting pull-up resistors?
The input impedance of the nodes is provided in datasheets? I am straggling to find such kind of information
 

Online Siwastaja

  • Super Contributor
  • ***
  • Posts: 8172
  • Country: fi
Re: I2C calculator
« Reply #6 on: July 27, 2021, 09:04:35 am »
No, that's complete bullshit and makes zero sense. Maybe it's some advice pre-CMOS inputs, i.e., 1970's? But all I2C devices in existence have CMOS inputs, the resistive input impedance of which is comparable to PCB surface leakages, this is in tens to hundreds of megaohms, there will be no voltage divider effect.

But while input impedance can be assumed infinite, as I said earlier, output resistance is non-zero and can't be ignored in the small range of pull-up values, i.e., somewhere below 1k.

Capacitive loading can be called "input impedance" of course, and it acts like a voltage divider during state change, creating the maximum frequency rating, but that you have already addressed.

Ignore that "engineer" from now on.
« Last Edit: July 27, 2021, 09:08:44 am by Siwastaja »
 
The following users thanked this post: Nikos A.

Offline Nikos A.Topic starter

  • Regular Contributor
  • *
  • Posts: 238
  • Country: cy
Re: I2C calculator
« Reply #7 on: July 27, 2021, 01:00:51 pm »
No, that's complete bullshit and makes zero sense. Maybe it's some advice pre-CMOS inputs, i.e., 1970's? But all I2C devices in existence have CMOS inputs, the resistive input impedance of which is comparable to PCB surface leakages, this is in tens to hundreds of megaohms, there will be no voltage divider effect.

Thank you Siwastaja
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf