Question about i2c pullups and pololu level shifter

Status
Not open for further replies.

MichaelMeissner

Senior Member+
I was moving my fancy camera shutter release from the breadboard to a protoboard when I noticed something.

Part of the device has a Pololu level shifter (https://www.pololu.com/product/2595) that I use to drive neopixel/ws2812b LEDs. The level shifter has a 10K pullup resistor for each low voltage pin before hooking it to the MOSFET to shift the voltage to the high voltage pin. I hook up A3 for the neopixel lights, and also hook up A4/A5 for the i2c devices that need 5v instead of 3.3v. I hadn't gotten around to adding the normal 2.2K or 4.7K pull-up resistors to A4/A5, but I noticed it worked fine when I connected i2c devices to either 3.3v (using the original A4/A5 and 3.3v power) or 5v (using the level shifted A4/A5 and VIN power).

At the moment, I only use the bog standard 100kHz i2c bus for devices, and I've only tried it with a single i2c device with fairly short wires. I assume in this setup, that I might not be able to go to 400kHz for i2c, and I probably am limited to the number of devices to put on the i2c bus. Is this correct? At the moment, I don't care about higher speeds, and I generally only have an occasional i2c device, but I always like to know what the limits are in wiring up a board.

Thanks in advance.
 
I've done a little bit of reading about multiple resistors and formula for 2 resistors in parallel is 1/((1/r1) + (1/r2)), not counting things like increased wire length, and extra capacitance.

Thus:
  • If I add a 2.2K resistor, it would be equivalent to a 1.8K single resistor, which is too low (and explains why it didn't work when I tried it in a previous iteration);
  • If I add a 3.3K resistor, it would be equivalent to a 2.5K single resistor;
  • If I add a 4.7K resistor, it would be equivalent to a 3.2K single resistor;
  • If I add a 8.2K resistor, it would be equivalent to a 4.5K single resistor;
  • If I add a 10K resistor, it would be equivalent to a 5.0K single resistor.
 
In all my searches on I2C I would eventually land at TI document written long time ago which gives formulas for allowed resistor range. Unfortunately it uses line capacitance that is not easy to predict or calculate. Here is one of the incarnations of that document: http://www.ti.com.cn/cn/lit/an/slva689/slva689.pdf

As far as I can tell 10K pullup in standard mode is OK for line capacitance under 120 pF. In fast mode the formula gives something like 35 pF maximum which might be hard to achieve, so you'd need to lower resistance by adding resistors in parallel (I believe it is best to place those additional resistors as close to shifter board as possible). Of course it cannot be too low and for that the document gives another formula based on drain capacity of the weakest device on the bus and on voltage differential it has to sink. While the maximum depends mostly on physical bus design the minimum depends on the connected devices and supply voltage. 1.8K from your example might not be too low in some configurations, especially in fast mode at 3.3V.
 
The schematic on that board confirms it is doing what is shown in this document (it has some explanation if needed):
http://www.nxp.com/documents/application_note/AN10441.pdf

The builtin 10K's are probably fine for low speed 100kHz operation. Like you already assumed, if you load additional slaves on the bus you might need to lower the pullup resistance to counter the capacitive load (although the shifter itself splits the master-side and slave-side loading).

This page has some nice plots of various pullups:
http://dsscircuits.com/articles/86-articles/47-effects-of-varying-i2c-pull-up-resistors
 
Nox771: Thanks. I had already seen that article, but I didn't have the math for multiple resistors.

I do think for the audio/prop shields, that I need to drop the 5v i2c shifting, or else I will need a a very large resistor to combine with the the 10k resistor of the level shifter and 2.2k resistor of the sheild.
 
Wait a second, this wasn't clear in the original post. So you have pull-ups in the shifter AND in the device it is connected to? 10K + 2.2K in parallel?
Then the only option you have is to remove 2.2K off the board. ADDING any more resistors will REDUCE the total even more.

And you cannot drop level shifter unless your device is capable of working on 3.3V power supply OR it's I2C inputs are compatible with 3.3V bus voltage. I would not recommend using 5V bus voltage even if master is tolerant to it.

Your options in short:
1. Keep shifter but remove unnecessary 2.2K pull-ups from device
2. Keep shifter, remove all pull-ups from 5V side, add 2 external pull-ups of your own choice to 5V bus.
3. Get rid of shifter, power device from 3.3V. (this only works if device can work at 3.3, of course)
4. Get rid of shifter, remove 2.2K pull-ups from device, add 2 external pull-ups of your choice to 3.3V bus. (this only works if device I2C input is compatible with 3.3V bus)

Also you mentioned "VIN power" on the device. Some devices do have separate power input for their I/O circuits. This is extremely convenient as it allows device to communicate on any bus voltage.
In this case you have one more (and the very best option):

5. get rid of level convertor, power device from 5V, BUT power device I/O circuit from 3.3V (which MUST be used as pull-up voltage for I2C bus - check schematics)
 
Last edited:
No, in the build I'm currently working on, there are only pull-ups in the shifter. In a previous variant of the board, I had soldered in 2.2K resistors (in addition to the level shifter), and I couldn't get the i2c devices to work. When I had to restart due to other issues, I was going step at a time, adding components, one at a time, checking whether everything was connected correctly. I hadn't gotten around to adding the resistors, and I decided to try i2c devices, and it worked. Then I reread the description of the shifter, and saw it had built-in level shifters.

However, after this is done, I was contemplating doing something with the prop shield and/or the audio shield. Since these have 2.2K level shifters built-in, I calculated that the 2.2k resistors + the 10k resistors would not work too well, without a larger resistor to bring things back in the proper level for i2c.

So for those builds, I will not connect 18/19 to the level shifter. I need the level shifter for neopixels (ws2812b's). But since the level shifter has 4 pins, it was simple to hook up 18/19 on the chance that I might need to talk to a 5v i2c device.

On the prop shield, pins 11 and 13 are shifted (just like pin 17 on the LC), so I won't need to do shifting for neopixels. I only have one i2c device that absolutely requires 5v (an old 16x2 LCD), but i2c LEDs are brighter with 5v instead of 3.3v. Also, I have to be careful not to put too much load on the 3.3v WRT to leds when I'm using Teensy 3.1/3.0 and LC.

Unfortunately, I don't think either the prop shield or audio adapter have solder jumpers to remove the i2c pull-up resistors. It would be helpful if every i2c board had an option to remove the pull-ups or add the pull-ups, but a lot don't.

Everything is a trade-off, but it is helpful to know what the trade-offs are. This discussion has clarified in my mind what some of the trade-offs are.
 
Last edited:
The brightness of LED depends on the current, not voltage. If you want them brighter with 3.3V, you can reduce the resistor on the LED (but make sure it's not too much for the LED).
 
Last edited:
I calculated that the 2.2k resistors + the 10k resistors would not work too well, without a larger resistor to bring things back in the proper level for i2c.
I am still puzzled by this and similar statements in earlier posts. What do you mean when you talk about "adding larger resistor"? No matter how large resistor is, adding it in parallel will REDUCE total resistance even further.

Anyway, the datasheet for HT16K33 states VIH on SDA/SCL as 0.7*VCC, which is 2.31V at 5V supply. Perfectly compatible with 3V bus voltage.
All you need to do is remove those 2 pull-up resistors (you can clearly see them on the photo next to connector holes, they marked "103") and then use your own pull-ups connected to 3.3V
 
Just to clarify previous post:

It is not a good idea to use 5V I2C bus with 3.3V master device, even if master has 5V tolerant pins. It might work, but you can also fry it in the long run. What you can do depends entirely on the specific slave device you are trying to control.

1. If device has dedicated VIO input for bus voltage - you are lucky. Simply connect it to 3.3V and power device from 5V. Check schematics and make sure built-in pull-ups also connected to VIO. If there are no built-in pull-ups then add your own to 3.3 rail.
2. If device does not have VIO input and there are NO built-in pull-ups then check device datasheet.
2A. If SDA/SCL levels in datasheet are compatible with 3.3V bus then you are lucky again - use your own pull-ups to 3.3V and it should work.
2B. If SDA/SCL levels are not 3.3V compatible then you need level shifter.
3. If device does not have IO voltage input and there are built-in pull-ups then you have another two options:
3A. If levels are compatible and you feel comfortable with soldering then remove those built-in pull-ups and use your own to 3.3 rail.
3B. If levels are not compatible or you don't want mess with board then you need level shifter.

In both 2B and 3B cases when you use level shifter there is strong possibility that it comes with its own pull-ups. On 3.3V side this is usually OK and you can connect it directly to master. On 5V side you use exactly same logic as above, taking into account the presence of the pull-ups on both shifter and device. If they are only on one of them everything should work right away. If they are on both sides - use parallel resistance formula to check total resistance. If it is outside of allowed range (for chosen speed and bus capacitance) then removing them from either device or shifter should do the trick.
 
Status
Not open for further replies.
Back
Top