2 questions on I2C bus - pullups and branching

Thread Starter

Bhante

Joined Dec 15, 2009
64
Question 1)

I am unsure what pullups resistor value to use on the I2C bus. In the past I have used 4.7K with another device, but that was with 5V and I am now using 3.3V (description of context below)

Question 2)


On branching of the I2C bus between several devices - do I understand correctly that from the perspective of a simple circuit diagram view (i.e. neglecting capacitance issues etc), all the connections from devices/MPU to the SDA bus connect at a single point, and all the connections to the SCLK connect at a second single point? (Whereby the pullup resistor then goes from this single point to Vcc).

If there are more than two devices on the bus, to what extent does it matter how they are connected to each other? Do they have to be wired in a single line, or can they be wired radially from a point or a mixture of radial with serial? Does this affect the value of the pullup resistor? Are there cases where I need more than one pullup resistor for each of SDA/SCLK?

Context

I am putting an MPU in an espresso machine with various temperature sensors, clock, bluetooth, and other controls. The environment is rather hot - likely to be of the order of 40 degrees centigrade (maybe more, mabe less) in the region where several of the devices will be. The machine is normally on 24 hours per day.

I am using an ATmega328 based MPU at 3.3V. Other devices on the I2C bus include one or more MCP9800 temperature sensors, RTC, SD card, and probably I will want to add something at some stage. RTC is probably 3231.

The various devices will be mounted on a piece of wood and wired together with loose wires. The MCP9800 is mounted on a piece of veroboard together with the pullups and the PSU, and I thought of putting sockets on the same board for connections to all the other devices on the bus, hence question 2 above - effectively this would be a radially wired bus centred on the MCP9800 rather than on the MPU. I would probably add a few extra MCP9800's, and from a wiring perspective it would probably make sense to daisy-chain some of them. [The thermal sensors in very hot zones will be DS18B20, which are not on the I2C bus].

The datasheet for the MCP9800, if I understand it correctly, seems to imply that is some cases there might be more than one pair of pullups (were it is talking about self-heating of the sensor).
 

geekoftheweek

Joined Oct 6, 2013
1,201
4.7 k should work for 3.3 Volts. It's really a matter of what your connected devices are capable of sinking that will give you your lowest value for resistors. The highest value will be determined by capacitance which will alter rise and fall times to a point that is outside of the specification. Generally you only need one set of pull ups, but multiples can be helpful in certain situations.

A single "star" connection isn't necessary. In situations it can add extra capacitance due to longer wires, traces, and such needed to bring all connections to a single point. The best course is to keep the total length of all wires and traces as short as possible.

The pull up for the Alert pin will still be needed on the MCP9800.
 

Papabravo

Joined Feb 24, 2006
21,159
I2C was originally designed to be used on a single board and had limited drive capability and limited clock speed. You are correct in your notion that all SDA and SCL points are connected together. There may or may not be a strategically identifiable "single point". As long as long as the total length of each net does not exceed something like 12-18" you can locate the pullups anywhere. IIRC there is a minimum value and a maximum value for the pullups and after those limits are established, the choice is a tradeoff between speed and power consumption.

Take a look at the following application note from TI.

I2C Bus Pull-Up Resistor Calculation
 

Thread Starter

Bhante

Joined Dec 15, 2009
64
Many thanks geekoftheweek and Papabravo for your helpful replies.

The AppNote from TI was helpful - well, in theory, except that now I am more confused than ever!

Firstly I am somewhat unclear about the values of Vol max and Iol that are used in the examples because the values given in the 9800 datasheet and the graphs of Vol (not max!) against temperature and of Iol against temperature seem widely divergent to me, and the specified conditions don't seem to match up against each other between the graphs and the table.

The max value of Vol is tabled as 0.4V at Iol=3mA is this an arbitrary test value, isn't it dependent on Rp? Is this the current through the resistor, presumably?
The way Iol is used in the examples appears to imply otherwise, as it is just taken as 3mA without discussion - why?
Then Iol is tabulated with a MINIMUM of 6mA, at Vol=0.6 (no typical or max cited).
By contrast, the graph of Iol against temperature has Iol in the range 12 to 20mA for 3.3V at 5 to 85 centigrade at Vol=0.6.
The graph of Vol against temp is in the range 0.08 to 0.1V, at Iol=3mA; this is Vol not Vol max though. Vol max will obviously mean the maximum pin voltage that the device can treat as "low", i.e. a property of the device not the circuit - nevertheless for this to have any meaning it has to relate to actual voltages in the circuit, and the graphed values come nowhere near. I am probably looking at it completely wrongly. I can understand in principle that you have an RC network from the capacitance of the wires, that the capacitance of the wires has to be charged up for the voltage to sink below the Vol max value, and that this might not happen before the next clock pulse. However the values are another matter. And I would intuitively expect - in terms of RC networks - the problem to be hugely reduced going from fast mode to standard mode as the frequency is one quarter, but from the AppNote it looks like the advantage may be rather modest.

Another problem is the values in the example: Rp min-max 967 ohms to 1.77kohms for fast mode at 3.3V. Multiply tr by 4 for standard mode gives max of 7.1kohms; but assuming capacitance is near the maximum of 400pF, divide by to gives max of 3.5kohms. Where does the value 200pF in the example come from - assumed to be calculated from actual traces for some hypothetical example circuit, presumably?

Are my proposed loose single wires for the connections between wires going to have capacitance massively over the 400pF limit?

As an order of magnitude, what would be the capacitance for a single loose wire, say about 15cm long? Dependent on wire diameter, I think.

Probably I should assume I am going to have to keep the number of devices to the absolute minumum. Not so easy, it seems!
 

Papabravo

Joined Feb 24, 2006
21,159
Many thanks geekoftheweek and Papabravo for your helpful replies.

The AppNote from TI was helpful - well, in theory, except that now I am more confused than ever!

Firstly I am somewhat unclear about the values of Vol max and Iol that are used in the examples because the values given in the 9800 datasheet and the graphs of Vol (not max!) against temperature and of Iol against temperature seem widely divergent to me, and the specified conditions don't seem to match up against each other between the graphs and the table.

The max value of Vol is tabled as 0.4V at Iol=3mA is this an arbitrary test value, isn't it dependent on Rp? Is this the current through the resistor, presumably?
The way Iol is used in the examples appears to imply otherwise, as it is just taken as 3mA without discussion - why?
Then Iol is tabulated with a MINIMUM of 6mA, at Vol=0.6 (no typical or max cited).
By contrast, the graph of Iol against temperature has Iol in the range 12 to 20mA for 3.3V at 5 to 85 centigrade at Vol=0.6.
The graph of Vol against temp is in the range 0.08 to 0.1V, at Iol=3mA; this is Vol not Vol max though. Vol max will obviously mean the maximum pin voltage that the device can treat as "low", i.e. a property of the device not the circuit - nevertheless for this to have any meaning it has to relate to actual voltages in the circuit, and the graphed values come nowhere near. I am probably looking at it completely wrongly. I can understand in principle that you have an RC network from the capacitance of the wires, that the capacitance of the wires has to be charged up for the voltage to sink below the Vol max value, and that this might not happen before the next clock pulse. However the values are another matter. And I would intuitively expect - in terms of RC networks - the problem to be hugely reduced going from fast mode to standard mode as the frequency is one quarter, but from the AppNote it looks like the advantage may be rather modest.

Another problem is the values in the example: Rp min-max 967 ohms to 1.77kohms for fast mode at 3.3V. Multiply tr by 4 for standard mode gives max of 7.1kohms; but assuming capacitance is near the maximum of 400pF, divide by to gives max of 3.5kohms. Where does the value 200pF in the example come from - assumed to be calculated from actual traces for some hypothetical example circuit, presumably?

Are my proposed loose single wires for the connections between wires going to have capacitance massively over the 400pF limit?

As an order of magnitude, what would be the capacitance for a single loose wire, say about 15cm long? Dependent on wire diameter, I think.

Probably I should assume I am going to have to keep the number of devices to the absolute minumum. Not so easy, it seems!
The quality of the results depends on the quality of information you have. In design work there are two basic kinds of information: anecdotal and experimental. The anecdotal information comes from datasheets, and the experimental data comes from measurements. In most cases we use the anecdotal information, make a choice and call it a day. In other cases we want to do an experiment and find out if we can push the limits but still maintain some margin for reliability. It may turn out that on your particular board with its particular set of circumstances that I2C will work across the entire spectrum of pullup resistor choices and then some. It may also turn out that your particular board may encounter problems even inside the thoeretical range. Whatever you do, it has to be better than picking a value at random, but I don't think it pays to spend hours, days, or weeks trying for some elusive optimal choice. In many cases the choice might revolve around a purchasing requirement to limit the number of different parts on a board. When you settle on 1.82K and the purchasing manager asks if 2.21K will do, you shrug and say what, exactly?
 
Last edited:

Thread Starter

Bhante

Joined Dec 15, 2009
64
Do you have any idea what the capacitance of a single 15cm long loose wire would be (jump lead)? What kind of wire would keep the capacitance down reasonably?
 
Top