Arduino Forum

Using Arduino => Sensors => Topic started by: EKMallon on Apr 24, 2014, 10:08 pm

Title: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: EKMallon on Apr 24, 2014, 10:08 pm
I have a general question, that I am sure many people have solved before:  How do you stabilize both the voltage (to 3.3v) and the logic levels, when you are diving an unregulated Arduino system (eg: tinyduino, etc) directly from 3AA batteries.  In this system the input voltage will swing from 5.4 volts (if I use lithium AA's) down to 2.8 volts as the batteries discharge in a year long data logger deployment.  I have several I2C bus sensors (compas, accelerometer, temp, pressure, etc) with a max vcc of 3.3 volts.

I have been looking at the pololu 3.3V Step-Up/Step-Down Voltage Regulator S7V8F3 ( http://www.pololu.com/product/2122 ) as it has a shutdown pin that would allow me to completely de-power the sensors during the 99% sleep time of this application. But I still have to add a logic level shifter, to deal with the voltage changes on the mcu side of SDA/SCL and could use a little guidance finding one that is suitable.  I also don't know if I am causing myself grief by shutting down the sensors all the time, but for such long term deployments quiescent current is almost the most important issue in the whole design.

And it occurred to me that this must be a reasonably common problem, so perhaps someone has already built something like this? Is there a single, off the shelf module that will provide both voltage regulation, and logic level isolation, to an I2C bus in battery powered situations?
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: Grumpy_Mike on Apr 24, 2014, 11:01 pm
Quote
But I still have to add a logic level shifter, to deal with the voltage changes on the mcu side of SDA/SCL and could use a little guidance finding one that is suitable.

The logic level shifters have pull up resistors on both sides. Simply connect these to your supply on each side. As the arduino side's supply voltage changes so will the voltage of the conversion.
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: Chagrin on Apr 24, 2014, 11:12 pm
You're looking for a logic level converter like: http://www.adafruit.com/products/757. It's just two mosfets and four resistors; pretty easy to implement on your own as well. The BSS138 mosfet is pretty common and can be found for less than $.10.

For a regulator, you can find lots of LDO regulators that include a "shutdown" pin. When in shutdown they consume mere microamps of current. An LP2951 ($1) would be an example and is available in a DIP package -- needs just three capacitors to go with it. The S7V8F3 would work fine as well.
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: EKMallon on Apr 25, 2014, 06:10 am
Thank you both. 

But I was wondering if there was a single chip or break out board that did both functions at the same time - boost/buck voltage regulation to 3.3v and logic level shifting,  as an off the shelf part.  It just seemed like these might be a very common combination.
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: Grumpy_Mike on Apr 25, 2014, 07:44 am
Sorry it is not a common combination and I have never seen a joint board.
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: EKMallon on May 03, 2014, 01:42 am
Well I did eventually find one:
http://www.buildyourowndrone.co.uk/all-products/i2c-smbus-voltage-traslator-i2c-level-shifter-with-adapter.html

but I will have to wait for their reply to find out what voltage regulator they are using.  I need both boost & buck, with low quiescent current. (I know, I'm asking for alot)

For now though, I will probably cobble together the Sparkfun PCA9306 Level Translator Breakout:
( https://www.sparkfun.com/products/11955 )
with the Pololu 3.3V Step-Up/Step-Down Voltage Regulator S7V8F3
( http://www.pololu.com/product/2122 )

as that regulator will handle the full voltage swing from my 3x AA battery pack ( 5.4 v down to <3 v )




Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: Chagrin on May 03, 2014, 11:28 am
The schematic is listed on the page, but I guarantee that it's a 3.3V linear regulator. That linear regulator will more than likely be more efficient (get more from your batteries) than a switching regulator would.

A 5.4V to 3V pack would be three batteries each going from 1.8V to 1V. What kind of battery are you using?
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: Grumpy_Mike on May 03, 2014, 10:55 pm
Quote
That linear regulator will more than likely be more efficient (get more from your batteries) than a switching regulator would.

An odd statement. Have you anything to back that up?
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: Chagrin on May 04, 2014, 08:58 am

Quote
That linear regulator will more than likely be more efficient (get more from your batteries) than a switching regulator would.

An odd statement. Have you anything to back that up?

The S7V8F3 at 3.3V is around 95% efficient (peak) with 3.6V input per Pololu's docs. For a linear regulator that's .3V drop, or (3.3 / 3.6 =) 91% efficient. So no, it's not more efficient meeting the peak efficiency, but it's respectably close. But as he mentioned this is a long-running project, I'm thinking that the lower quiescent current (< 1uA) of a linear regulator compared to the ".1 ma" quiescent current of the S7V8F3 is likely to put the linear regulator ahead.
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: Grumpy_Mike on May 04, 2014, 11:01 am
And can you actually get a linear regulator that will work with just a 0.3V drop?
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: Chagrin on May 04, 2014, 11:47 am
Newark lists 106 options (http://www.newark.com/webapp/wcs/stores/servlet/Search?catalogId=15003&langId=-1&storeId=10194&categoryId=800000025503&sort=P_ATT_BASE_VALUE_1000874_EN_US&st=linear%20regulator&pageSize=25&beginIndex=1&showResults=true&aa=true&pf=810002745,810002763,810002768,810002772,810002811,810003054,810017478,810017520,810017525,810017801,810032585,810032598,810032599,810032609,810032618,810032922,810046122,810049653,810066418,810068182,810073662,810076907,810080545,810088745,810091055,810099520,810100186,810101974,810103099,810103215,810104893,810105181,810105769,810117234,811353648&max=810032585) with 300mv dropout or less.
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: Grumpy_Mike on May 04, 2014, 02:55 pm
OK thanks for posting.
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: EKMallon on May 09, 2014, 01:40 am
Thanks for the extra input guys! I will do some more homework.

The 1.8 volt top end is from lithium AA batteries IF I can use them.  In a 3-pack these run very close to the upper tolerance limit of my components, but  3000 mAh power is very attractive in a 1 year plus data logging situation. They also have a really nice flat power curve once they fall to 1.4-1.3 volts, so even if I shut the system down at 3 volts,  I get 90% of the power out of the cells.
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: JChristensen on May 09, 2014, 01:52 am
I have a solution but data storage is limited to 512kB. What is the logging frequency, and how many bytes per sample?
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: EKMallon on May 22, 2014, 08:52 am
bytes per record:  64-96, depending on how many sensors I have attached, but there is alot of optimization I could do there.
15 minute sample frequency (so 96 records per day), but I want to bring that down to 5 minutes when interesting "events" are occurring, such as a storm pulse, etc.   Looking at year long deployments so at the moment I don't think I can get down to 512k...currently using a 128 mb sd card.
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: JChristensen on May 22, 2014, 03:50 pm
Have you considered just running everything on 3.3V? I designed a data logger that runs on 2xAA cells and uses an MCP1640 boost regulator, that when not enabled, simply passes the battery voltage straight through. The logging cycle is: Wake up (via RTC interrupt), enable boost regulator, increase system clock speed to 8MHz, power sensors on, take readings, save data, program next wake time, power sensors off, reduce clock to 1MHz, disable boost regulator, go to sleep. Using 1MHz allows the MCU to operate down to 1.8V when running on battery voltage, but while reading sensors and saving data, everything runs on the regulated voltage.

The regulator can be configured to supply either 3.3V or 5V; exclusive of sensor requirements, everything else on the board is equally happy with either but of course 3.3V will provide better battery life. Sleep current is only a few microamps. It uses EEPROM for logging memory (hence the 512kB limitation). I've thought about redesigning it with an SD card but that's a low priority project.
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: teckel on May 22, 2014, 09:37 pm

Have you considered just running everything on 3.3V? I designed a data logger that runs on 2xAA cells and uses an MCP1640 boost regulator, that when not enabled, simply passes the battery voltage straight through. The logging cycle is: Wake up (via RTC interrupt), enable boost regulator, increase system clock speed to 8MHz, power sensors on, take readings, save data, program next wake time, power sensors off, reduce clock to 1MHz, disable boost regulator, go to sleep. Using 1MHz allows the MCU to operate down to 1.8V when running on battery voltage, but while reading sensors and saving data, everything runs on the regulated voltage.

The regulator can be configured to supply either 3.3V or 5V; exclusive of sensor requirements, everything else on the board is equally happy with either but of course 3.3V will provide better battery life. Sleep current is only a few microamps. It uses EEPROM for logging memory (hence the 512kB limitation). I've thought about redesigning it with an SD card but that's a low priority project.


For ultra low-power projects, I've found that voltage regulators in general (boost or buck) use too much power.  Instead, I go with using  3-4 batteries and a diode to drop the voltage a bit and to protect the circuit from batteries being inserted the wrong way.  The goal is to put the circuit slightly above the rated voltage with fresh batteries.  For example, I commonly have ATmega8 projects running at 5.5 volts with fresh batteries.  Sure, out of spec a bit, but I've never had anything blow up, even with 6 volts.  Same goes with a 3.3V system, 3 batteries with a diode.

By taking out the voltage regulator, you really can create a system that uses 1uA when the ATmega8 is in sleep mode.  Sure, you use an extra batter or two.  But batteries are cheap and you can design systems that can log or interact for SEVERAL years.  I have a few projects that draw less current than the battery looses just sitting on the shelf with nothing connected.  You need to shut everything down, even the brown-out detector.  If you need my ultra low-power code, write me, I'll probably eventually make it into a library.

My typical ultra-low power project will put the ATmega8 in almost total sleep (just waiting for a trigger pin or timer).  I typically attach an LED that blinks every minute so you know it's still working.  The trick with the LED to use the least amount of power is to use a very bright LED, use a larger resistor to limit the current to maybe 1mA, and use the built-in sleep of the ATmega8 for the time the LED is on.  In other words, turn on the LED (only using 1mA) put the ATmega8 to sleep for 15ms, wake back up, turn off the LED, then return to long sleep.  This uses less power because it's only using 1mA for 15ms instead of leaving the ATmega8 awake for 5ms during a shorter blink and consuming more than 10mA.  The little things add up, and I'm a bit of a current Nazi.

Also, I would not suggest reducing the clock speed to 1MHz.  I've found you'll use more power at 1MHz than at 8MHz.  The reason is first there's not much of a power savings from 8MHz to 1MHz, and secondly your code takes 8 times as long to run.  The end result is you actually use a lot more power at 1MHz.  16MHz would be slightly more efficient, but then you need external crystal/caps which raises component cost/complexity.  So, I typically use the internal 8MHz oscillator.  Makes it easy, cheap, and more energy efficient than 1MHz.

Keep in mind that I've spent hundreds of hours developing ultra low-powered systems.  I've measured the actual current used and calculated everything to the nth degree.  In other words, I'm not guessing what I'm saying is true, I've done it, countless times.  The ATmega8 is a VERY good platform if low power is the goal.  Also, I'm talking about using a ATmega8 chip and a custom circuit, not an Arduino, which will never work in an ultra low-power system.

Tim
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: teckel on May 22, 2014, 09:52 pm
Oh, there's one other thing.  Also when doing an ultra low-voltage system I monitor the input voltage by using the ATmega8's internal bandgap reference voltage.  Basically, I monitor the voltage of the batteries.  During development, I'll use a variable voltage source where I can turn down the voltage till the system fails.  I'll then add something like 10% to that voltage and set that as my limit.  Every so often (like once a day) the ultra low-powered system will get a battery voltage reading.  Once it's below the set range, the blinking changes from once every 60 seconds to a double flash or flashing every 8 seconds.  Something so you know the battery is low and needs to be replaced.

By the way, I've yet to actually reach a low battery level warning in an actual system because they really will last for around 7 years.  I've only simulated it.  I've also done projects where I could press a button and it would flash out the voltage via an LED.  So I know it works, just a little too well.  Duracell hates me ;)

Tim
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: JChristensen on May 23, 2014, 01:51 am
Sucks to be Duracell  :D

Sounds like you've got everything nailed. I'm familiar with most or all of the techniques you outlined and can't disagree. A major goal for my project was very low power, but that wasn't the only goal. It had to supply regulated voltage during the logging cycle and also provide the option of 3.3V or 5V. The 1MHz clock is not necessarily used for minimum power, it's to ensure the MCU is operating within spec when running on the battery only (which could be as low as 1.8V, which is the BOD setting I used). At any rate, it runs at 1MHz for relatively few cycles, just before sleeping. I had heard it said that 1MHz was the sweet spot for low power, but have not done the measurements myself so am not in a position to differ with your experience.

I'm really happy with the way the data logger works and the power consumption looks like it probably exceeded my expectations by a fair amount. The logging cycle can be as short as 15ms depending on sensors. Just received data from a couple loggers that were in Northern Michigan through the winter. The first was inside an insulated but unheated cabin where temperatures got down to 1°F.  Its regulator was configured for 3.3V. It started with a less-than-fresh pair of AA cells, that measured 3003mV at the start, and 2987mV after 184 days. The second logger was in an open shed. It used 5V, and its battery started at 3255mV and ended at 2844mV after 195 days with temperatures as low as -22°F. It had more sensors and more complex sensors than the first unit; I don't have current measurements but I imagine its sensors drew 2-4 times more current than those of the first unit, and for longer intervals.

I can tell you get a kick out of the low power capabilities these MCUs have. So do I!
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: teckel on May 23, 2014, 04:56 pm
I had heard it said that 1MHz was the sweet spot for low power


It really depends on the task.  If awake only long enough for computation, 8 or 16 MHz uses less power.  If you're waiting for a communications reply or something like that, 1 MHz would use less power.  So in your situation, I'm sure 1 MHz is the way to go.

Have you had any problems running at 1 MHz?  I got some unstable results at 1 MHz.  2 and 4 MHz were fine, but at 1 MHz there were timing issues.  It could have just been the sensors I was working with.

I'm really happy with the way the data logger works and the power consumption looks like it probably exceeded my expectations by a fair amount. The logging cycle can be as short as 15ms depending on sensors. Just received data from a couple loggers that were in Northern Michigan through the winter. The first was inside an insulated but unheated cabin where temperatures got down to 1°F.  Its regulator was configured for 3.3V. It started with a less-than-fresh pair of AA cells, that measured 3003mV at the start, and 2987mV after 184 days. The second logger was in an open shed. It used 5V, and its battery started at 3255mV and ended at 2844mV after 195 days with temperatures as low as -22°F. It had more sensors and more complex sensors than the first unit; I don't have current measurements but I imagine its sensors drew 2-4 times more current than those of the first unit, and for longer intervals.

I can tell you get a kick out of the low power capabilities these MCUs have. So do I!


Yes, I'm a little passionate about ULP MCUs.  I love the battery stats you provide, I do the same thing.  I have an ULP test unit I've setup as a torture device on my desk at work.  I just tested the voltage again and at 230 days the average AA battery voltage is 1.41 volts (down from a 1.62 volt start).  This is my torture device, which is setup to trigger much more frequent than normal.

What voltage regulators do you use?  I've been using the Microchip MCP1700/MCP1702 which has a very low quiescent current (2 µA).  What are you using for a boost regulator?

Tim
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: JChristensen on May 23, 2014, 07:35 pm
Hey Tim, when the Energizer Bunny retires, we sure know who to nominate for a replacement!  :D

Have had no trouble whatsoever with 1MHz in general, on ATmegas or on ATtinys, but I don't know that I've tried reading sensors much at the slower speeds. I could imagine that some of the libraries that do their own bit-banging and timing may be sensitive to system clock speed but I don't have specifics.

I use the MCP1640C or MCP1640D boost regulator for the data logger (the former should be a bit more efficient, the latter provides a little better regulation, again a distinction that makes little difference for my project I think). Typical shutdown current is sub-µA according to the datasheet. The only gripe I have with it is that I haven't been able to come close to the output current as advertised in the datasheet. It also has problems starting if the load is too large. But the data logger doesn't use much current so it's great for that application. I've used the MCP1700/02 in other projects and they work very well indeed.

Cheers ... jc
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: EKMallon on Aug 16, 2014, 10:59 pm
Just wanted to blow the dust off of this thread, as I found a really cheap vreg'd level shifter recently:

http://www.ebay.com/itm/251384699933?_trksid=p2059210.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

And I really appreciate the tips about how to make the project more energy efficient!  I have a few Pro-mini based loggers now and have been thinking of swapping out the Voltage regulator there for something with a lower quiescent current.

Although I have to admit I am no where near your ability levels, I have completed a power burn down test of my own, and thought I would post it hear just for giggles.  Keep in mind that I had very little electronics experience before this project. Also I am saving all the data to an SD card, which is a huge power burden for the logger, but more practical if I want people to build their own units later.

http://edwardmallon.wordpress.com/2014/08/14/project-update-power-tests-battery-issues/
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: JChristensen on Aug 17, 2014, 02:12 am
@EKMallon, wow, quite a story! I'd say that's a good start on a book about the project. I'm curious about the total amount of data logged. It sounded like the 30-minute interval was maybe longer than optimal. What would a better interval be, and how many bytes of data are logged for each interval?
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: EKMallon on Aug 17, 2014, 09:28 pm
The sensors attached to each logger vary, but generally I am juggling 96 ascii characters per record. I am using pString, even for number data, because it gives me protection from buffer overflows, which is REALLY important for a coding newbie like me who is swapping sensors all the time. When I concatenated the recent test data into a single csv file, it came to around about 40 mB in size. (about equivalent to 1 year at a 1.5 minute sample interval)

Also, I have been doing tests with the Rocket Scream Mini Ultra boards, and they are delivering incredibly low sleep currents, right out of the box. I am sure they ship these things with the BOD fuse turned off, which I am not that happy about for a logger application, but still, they are delivering the same kind of performance I have been seeing from the unregulated tiny-duino boards.  I have test's ongoing to see how gracefully they handle the situation when the power supply voltage falls below the rated input on their voltage regulator.    The MC5205 regulators on the regular Pro Mini & clone boards go into a  1/2 second  "Start & Shut down again"  loop when this happens, which I am sure is not good for the SD cards?

What I would like on systems with voltage regulators, is a more graceful fail over that simply passes  the power supply voltage through when it falls below the regulators spec'd input.  Some of my sensors would would start to deliver bad data at that point, but some are much hardier, and would keep going fine until I reached the SD card cutoff around 2.7 volts.
Title: Re: Is there a voltage regulated, level shifted I2C bus solution for AA powered unit
Post by: EKMallon on Aug 20, 2014, 06:34 pm
@Teckel:

I just wanted to say thanks for the low current LED tip! 

I had a ton of LED pips with "live" 1ms delays in my code.  Now I have 10k ohm limiters on the leds (yes they are pretty dim, but that's ok) , and since I had sleeping delays already (while waiting for sensor conversions) I just set these low current leds on for those instead of their previous pips.  The net result has been a significant improvement in the overall power performance of my loggers.  I will be looking in the regulator suggestions as well.

cheers!