Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

i2c voltage


  • Please log in to reply
17 replies to this topic

#1 Spork

Spork

    Advanced Member

  • Members
  • PipPipPip
  • 105 posts

Posted 04 October 2011 - 06:04 AM

I had posted this on a separate thread... It's the clock signal from my i2c line:

Posted Image

One division is 1v and it seems that SDA and SCL are pulled up to 3.7V. I just skimmed the i2c article on Wikipedia, again, and it says that the bus can operate at 3.3, 5, or other voltages. I guess I've put myself into the "other" category.

Question: Am I stressing A5 and A4 on the N+ with SCL and SDA pulled up to 3.7v? I'm guessing that the usual 3.3v analog max applies to A5 and A4, or is this not true when they're running i2c?

Here's an inventory of what's on my i2c bus:
BMP085, 3.3V supply, 10K pull ups on the breakout.
DS1307, 5V supply, 2.2k pull ups on the breakout.
24LC256, 5V supply, no pull ups.

At first I thought that the 10K and 2.2K would act as voltage dividers between the 5v and 3.3v, but the math doesn't seem to work out to the observed 3.7v.

#2 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 04 October 2011 - 06:28 AM

Question: Am I stressing A5 and A4 on the N+ with SCL and SDA pulled up to 3.7v? I'm guessing that the usual 3.3v analog max applies to A5 and A4, or is this not true when they're running i2c?

When you use I2C on Netduino, A4 and A5 pins are physically switched (*) from analog inputs (microcontroller pins AD4, AD5) to I2C pins (PA10, PA11), which are 5V tolerant.

(*) See FSA2257MUX in the schematics

#3 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 04 October 2011 - 07:19 AM

Here's an inventory of what's on my i2c bus:
BMP085, 3.3V supply, 10K pull ups on the breakout.
DS1307, 5V supply, 2.2k pull ups on the breakout.
24LC256, 5V supply, no pull ups.

Well, this is NOT a good picture...
The I2C does not fix the pullup voltage, but it's clear that the logic must be able to detect which is the logic zero from the logic one. If you have a 5V powered device, for instance, the logic one level falls typically from 70% to 100% of Vdd, that is 3.5V to 5V.

What is not happy, is that you have mixed up two different voltages of pullup. Now, just forget for a moment when either SCL or SDA are pulled low.
What would be the pullup "idle" level on both the lines?
From the 5V powered device (let's call as "D5") viewpoint, the idle should be +5V (or pretty close to). By the way, from the 3.3V device (aka "D3"), the idle level should be close to 3.3V.

Now, you have actually two problems:
  • the idle level is 3.7V, which is higher than the D3, but closer to the lower bound of the D5: you are going to make them working in a critical range both the devices;
  • if you read 3.7V as idle, it means that there MUST be an useless current flowing through the pullups, from the +5V, thru the pullup of D5, thru D3. Why should have to be this useless, yet dangerous current?
I write "dangerous", because the Netduino inputs are 5V tolerant, but NOT ANY device is tolerant!
If you take a look, the idle voltage is +3.7V, which is much closer to the 3.3V supply than the +5V. That's because every IC has implicitly a couple of diodes from any I/O to the VDD e to VSS. So, the current is flowing through a "forbidden" path, which is the substrate diode of the BMP05.

I know that's an advanced task, but your behavior is clear, and you cannot make it invisible!
You have only three choices:
  • make all the devices working under the same supply;
  • use two different I2C buses for each supply;
  • insert a double bidi-level adapter to decouple the different supplies.
Of course, I suggest to follow the first one, which is the simplest.
Cheers
Biggest fault of Netduino? It runs by electricity.

#4 Stefan W.

Stefan W.

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts

Posted 04 October 2011 - 07:23 AM

You have only three choices:
make all the devices working under the same supply;
use two different I2C buses for each supply;
insert a double bidi-level adapter to decouple the different supplies.
Of course, I suggest to follow the first one, which is the simplest.


I disagree here, it's not the simplest simply because there are devices which do use different supplies ... but a bidirectional level adapter is pretty simple, have a look at the tx line from http://www.sparkfun....nverter-v10.pdf - two resistors, one mosfet, and you're done (note the resistors act as pullups, so if you already have pullups on both sides - as you have - you can ditch them, so your level converter becomes a single transistor.
  • CW2 likes this
I believe that no discovery of fact, however trivial, can be wholly useless to the race, and that no trumpeting of falsehood, however virtuous in intent, can be anything but vicious.
-- H.L. Mencken, "What I Believe"

#5 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 04 October 2011 - 07:45 AM

I disagree here, it's not the simplest simply because there are devices which do use different supplies ... but a bidirectional level adapter is pretty simple, have a look at the tx line from http://www.sparkfun....nverter-v10.pdf - two resistors, one mosfet, and you're done (note the resistors act as pullups, so if you already have pullups on both sides - as you have - you can ditch them, so your level converter becomes a single transistor.

That's right, I didn't know about the ready-to-go breakout. Otherwise, I doubt about the users would choose to wire up some mosfets+resistors, instead of changing devices.
I would prefer to use devices sharing the same supply, without relying on what the breakouts offer.
Cheers
Biggest fault of Netduino? It runs by electricity.

#6 Spork

Spork

    Advanced Member

  • Members
  • PipPipPip
  • 105 posts

Posted 04 October 2011 - 08:34 AM

CW2: Thanks for clarifying that for me.

Mario: Thanks for your analysis. When you say in option #1 to "make all devices working under the same supply", do you mean "only choose devices with the same supply"? When you mention "double bidi-level adapter" in option #3 am I correct in assuming that you mean something like this?

Let's say I go with #3, because I can't find the four sensors I want all in 3.3V or all in 5V. I'll end up having the following voltage mix:

1) BMP085 3.3V
2) HH10D 3.3V
3) DS1307 5V
4) 24LC256 5V

If the preferred i2c voltage for N+ is 3.3V, I'd start with a 3.3V bus to the BMP085 and HH10D. Then I'd use a double bidi logic level converter to bridge over to a 5V bus to which I'd connect the DS1307 and 24LC256. I'd need pull up resistors for SDA and SCL, either on the 3.3V side or the 5V side -- once one side is pulled up to its proper level, the logic level converter would take care of the other side, right?

Stefan: You replied while I was writing everything, above. I see that you referenced the same level adapter I did, and have answered my question about pull ups in this scenario. I'm about to redo this project by designing a couple PCBs. Given the components/breakouts I'll be mounting on the PCB, it seems like it would be simplest to go with the 10K pull ups on the level adapter. I'll just have to learn how to remove the surface mount resistors from the BMP085 breakout board -- or maybe it's easier to cut the traces that lead to them.

#7 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 04 October 2011 - 08:56 AM

Yes, the level shifter is the same as Stefan pointed. The 24LC256 can work also at 3.3V. Instead of the DS1307, you may use the NXP PFC8593, which is much better. Cheers
Biggest fault of Netduino? It runs by electricity.

#8 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 04 October 2011 - 09:41 AM

note the resistors act as pullups, so if you already have pullups on both sides - as you have - you can ditch them, so your level converter becomes a single transistor.

Exactly, NXP application note Level shifting techniques in I2C-bus design (pdf) recommends the same.

#9 Stefan W.

Stefan W.

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts

Posted 04 October 2011 - 10:34 AM

Stefan: You replied while I was writing everything, above. I see that you referenced the same level adapter I did, and have answered my question about pull ups in this scenario. I'm about to redo this project by designing a couple PCBs. Given the components/breakouts I'll be mounting on the PCB, it seems like it would be simplest to go with the 10K pull ups on the level adapter. I'll just have to learn how to remove the surface mount resistors from the BMP085 breakout board -- or maybe it's easier to cut the traces that lead to them.


If you are designing a PCB for this anyway, why use the premade level adapter and why remove pullups? (I'd put two transistors on a PCB for the level switching and use the pullups that your sensors already have, maybe add another pullup on the 3.3V side for faster rise times, 10k is a bit weak for a bus with multiple devices).
I believe that no discovery of fact, however trivial, can be wholly useless to the race, and that no trumpeting of falsehood, however virtuous in intent, can be anything but vicious.
-- H.L. Mencken, "What I Believe"

#10 Spork

Spork

    Advanced Member

  • Members
  • PipPipPip
  • 105 posts

Posted 05 October 2011 - 01:41 AM

This is a really helpful discussion...

Mario: Thanks for pointing out that the 24LC256 can run at 3.3V. When I see things like "Vcc Range: 2.5V to 5.5V" I usually assume that I should stick to the high end of the range. But I guess that's not so. As for the NXP PCF8593, I hadn't heard of it before you mentioned it. I've been restricting myself to stuff on sites like Adafruit and SparkFun on the assumption that the items they sell there probably work well with 'duinos. Have also been trying to stick with devices that have proven drivers available in these forums. But maybe I'll try an all 3.3V design using the PCF8593 and fall back to the DS1307 and level shifting if I run into any trouble.

CW2: Thanks for the pointer to the PDF on i2c bus design.

Stefan: I may use some breakout boards because of my morbid fear of surface mount. I've always assumed that surface mount was invented for industrial robots and that I shouldn't attempt it. I suppose I should try it before I write it off, but the BMP085 looks like a lost cause to me:

Posted Image

#11 Stefan W.

Stefan W.

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts

Posted 05 October 2011 - 09:08 AM

Stefan: I may use some breakout boards because of my morbid fear of surface mount. I've always assumed that surface mount was invented for industrial robots and that I shouldn't attempt it. I suppose I should try it before I write it off, but the BMP085 looks like a lost cause to me:

I also use breakouts for smd-mounted things, however for the logic level converter you aren't restricted to SMD - you can still get transistors in a to-92 package :)
I believe that no discovery of fact, however trivial, can be wholly useless to the race, and that no trumpeting of falsehood, however virtuous in intent, can be anything but vicious.
-- H.L. Mencken, "What I Believe"

#12 Spork

Spork

    Advanced Member

  • Members
  • PipPipPip
  • 105 posts

Posted 06 October 2011 - 02:41 AM

Heh... I'm so new at this that I didn't know that transistor package types had names. So thanks for mentioning TO-92. I found a more detailed version of the note mentioned by CW2 and it lists four MOSFETs they consider suitable for i2c level conversion. One of them is BSN10 in a TO-92, so I'll use two on my PCB.

Next problem is Eagle. One tutorial says: "As with any new technical software, it's like learning a new language. Once you know the intricacies, you'll love it." So far, I'm having a hard time believing that I could ever love Eagle. The GUI seems horribly awkward, and although the library seems huge, it doesn't seem to have the components/devices I want to use in my design. Even when it has the devices I want, it doesn't have the package variety I want.

#13 Spork

Spork

    Advanced Member

  • Members
  • PipPipPip
  • 105 posts

Posted 07 October 2011 - 01:18 AM

Was looking for some supplier that has all the parts I want, and the BSN10 doesn't seem to be very available. So, I'm now thinking I'll use the P82B96 dual bidirectional bus buffer (data sheet, application notes). Digi-Key has the DIP version in stock.

#14 Robert L.

Robert L.

    Advanced Member

  • Members
  • PipPipPip
  • 100 posts

Posted 07 October 2011 - 02:54 AM

Was looking for some supplier that has all the parts I want, and the BSN10 doesn't seem to be very available. So, I'm now thinking I'll use the P82B96 dual bidirectional bus buffer (data sheet, application notes). Digi-Key has the DIP version in stock.


Years ago, I tried many approaches with the I2C bus (not Netduino projects, but "day job" projects), but the only chip that worked and gave me reasonable margins was the PCA9510. It's by Phillips who invented the I2C bus. The bidirectional feature of the I2C bus makes it very hard to work with especially if there are multiple masters (senders) on the bus.

#15 Stefan W.

Stefan W.

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts

Posted 07 October 2011 - 10:37 AM

I just read the DS1307 datasheet for something else and noticed that you don't need a level converter for it. As you already have the breakout, you could just remove the pullups on the breakout and add external pullups to 3.3V - the DS1307 has a logic 1 threshold of 2.2V which is well below 3.3V. So while you power the device at 5V, the data lines can operate at 3.3V "high".
I believe that no discovery of fact, however trivial, can be wholly useless to the race, and that no trumpeting of falsehood, however virtuous in intent, can be anything but vicious.
-- H.L. Mencken, "What I Believe"

#16 Spork

Spork

    Advanced Member

  • Members
  • PipPipPip
  • 105 posts

Posted 08 October 2011 - 01:17 AM

Robert & Stefan: Thanks for the additional comments.

Stefan: As per your suggestion, I went ahead and cut the pull ups on the 5V DS1307. The only pull ups are now 10K resistors to 3.3V on the Adafruit BMP085 breakout. This seems to have the desired effect w.r.t. bus voltage:

Posted Image

Voltage delta on the clock is now about 3.28V which I'm guessing is close enough to 3.3V. In the screen shot, above, the trigger level is set to 2.2V which, as you pointed out, is the logic 1 level for the 5V DS1307. I'm still learning what's relevant (for my purposes) in data sheets, but I see that the DS1307's specifies a minimum high period of 4.0 us. So, I set the X cursors on the Nano to measure the time above 2.2V. Time above 2.2V is about 4.4 us.

Compared to the screen shot I posted at the beginning of this discussion, the clock signal is now noticeably less square. I think I can fix that by lowering the pull up resistance to 3.3V, which I'd do by putting appropriately valued resistors in parallel with the BMP085's 10Ks. Making the signal more square will give some extra clearance on the DS1307's min high period, right? Oh, and I see that the clock frequency is now down to 88.7kHz, which should also be helped by tuning the pull up resistance.

I'm going to run a few hours of tests against this configuration. So far, all the devices are working correctly. I had noted infrequent BMP085 failures before this mod, so it will be interesting to see if they are gone after the mod.

#17 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 14 October 2011 - 04:38 AM

Better in late than never...
I realized that the I2C-Bus cannot work with voltages over +3.3V.
More on topic here.
Cheers
Biggest fault of Netduino? It runs by electricity.

#18 Spork

Spork

    Advanced Member

  • Members
  • PipPipPip
  • 105 posts

Posted 18 October 2011 - 03:47 AM

Thanks, Mario.

If I'm reading figure 2-1 in the SAM7X512 data sheet correctly, it seems that the i2c (TWI) hardware is built on top of the ADC hardware. If so, I guess it's logical that it would have the same 3.3V limit as the ADC.

Read wrong, I think... ADC and TWI use APB (advanced peripheral bus) but i2c is not built on ADC. So, I guess that it's just similar to the ADC in terms of its 3.3V limit.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.