Electronics > Projects, Designs, and Technical Stuff

I2C calculator

(1/2) > >>

Nikos A.:
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

Siwastaja:
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.

Renate:
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.

Siwastaja:

--- Quote from: Renate 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.

--- End quote ---

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.

Nikos A.: