The new Raspberry Pi B Model B+ is here - Pick one up in the store and check our detailed guide!

Ice Tube Clock Extended Battery Hack

by jarchie on Thu Jan 31, 2013 6:12 pm

I replaced a dead battery in my Ice Tube Clock earlier this week and thought it might be nice to increase battery life. On my multimeter, the current draw of an unmodified Ice Tube Clock while sleeping was 47 uA with 3.3 volt power supply. That is reasonably efficient, but with the picoPower features of Atmel processors, I was able to make the clock a bit more efficient. With this hack, one battery should last for the lifetime of the clock. :-)

(1) From the schematic, R1 can be attached directly to the +5v regulator output, moving the attachment before D2. In that configuration, D2 prevents the divider from drawing current while the clock is sleeping. To make that change, I cut the trace between R1 and Vcc and soldered the red wire between the voltage regulator and R1. (The yellow wire was added later.) Sleep current fell to 33 uA.

Image
Image
EDIT: With the software changes described below, connection between the 5v regulator output pin and the ATmega328p PC1 pin (yellow wire) is no longer necessary.

(2) After replacing the ATmega168 with an ATmega328p flashed with my xmas-icetube firmware, sleep current fell to 29 uA.

(3) Without external power, the output of the voltage regulator should fall to ground level; with external power, the output of the regulator should rise to Vcc. Thus, restoration of power may be monitored digitally by connecting the output of the voltage regulator to PC1 on the ATmega (the yellow wire pictured above). A complimentary software modification allowed the firmware to disable the analog comparator when PC1 is low. Sleep current fell to 25 uA.

(4) Brown-out detection (BOD) is definitely a nice feature, but a user should know to replace the battery if the clock behaves strangely after sleeping or if the clock fails to keep time while sleeping. So BOD can be disabled. After disabling BOD, sleep current fell to 6 uA. (Disabling both the analog comparator and BOD allows the internal voltage reference to power down.)

(5) During sleep, the clock does little more than wake once per second to increment the current time. Since a software lockup is unlikely, the watchdog timer is unnecessary. After disabling the watchdog during sleep, sleep current fell to 1.7 uA.

A typical CR1220 cell contains about 40 mAh worth of power, and at 1.7 uA, a single coin cell can power the clock for around two and a half years!

The software portion of this hack is available from http://www.github.com/johngarchie/xmas-icetube/ , and may be enabled by uncommenting the PICO_POWER macro definition in config.h .
Last edited by jarchie on Mon Mar 24, 2014 12:02 pm, edited 1 time in total.
--John <www.jarchie.com/email>
jarchie
 
Posts: 393
Joined: Sun Jun 24, 2012 1:16 pm
Location: Santa Cruz, California, United States

Re: Ice Tube Clock Extended Battery Hack

by adafruit_support_rick on Fri Feb 01, 2013 9:43 am

Nice work! Did you discover all these tricks just by doing this, or did you learn them elsewhere?
User avatar
adafruit_support_rick
 
Posts: 10801
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: Ice Tube Clock Extended Battery Hack

by jarchie on Fri Feb 01, 2013 4:29 pm

Steps (1), (2), and (3) seem specific to this project, and I have not seen them elsewhere. Steps (4) and (5) turn off unneeded features, and I've seen that strategy used several places.

Some time ago, I read an excellent tutorial at sparkfun as well as a Atmel picoPower tutorial.

"Adventures in Low Power Land"
http://www.sparkfun.com/tutorials/309

"AVR4013: picoPower Basics"
http://www.atmel.com/devices/atmega328p ... =documents
--John <www.jarchie.com/email>
jarchie
 
Posts: 393
Joined: Sun Jun 24, 2012 1:16 pm
Location: Santa Cruz, California, United States

Re: Ice Tube Clock Extended Battery Hack

by wildtang3nt on Wed Jun 26, 2013 9:22 pm

Will other firmwares still run properly with this mod installed? Not that I have any plans to stop using your excellent code, I'd like to be able to experiment with the other 3 AVR chips I've got laying around :)
Proud owner of (among other wonderful things):
Li-Poly MintyBoost
RGB LCD Pi Plate & Pi Dish
Ice Tube Clock & USBTinyISP
wildtang3nt
 
Posts: 32
Joined: Thu Aug 09, 2012 1:31 pm
Location: Hamilton, Ontario, Canada

Re: Ice Tube Clock Extended Battery Hack

by jarchie on Thu Jun 27, 2013 9:18 pm

I'm not sure.

In theory, an alternative firmware could enable the microcontroller's pull-up resistor on PC1 or set PC1 as an output. Since this hack connects PC1 directly to the voltage regulator, this hack could potentially damage the microcontroller (too much current), the regulator (back-powering), or both.

Even so, you might be able to make this hack compatible with any configuration of PC1. To limit current, maybe use a 500k resistor in place of the yellow wire. To prevent back-powering, maybe connect a diode between the regulator's input and output pins such that current is allowed to flow from the +5v output to the +9v input.

...or...

Just wait a week or so for me to test and push my latest changes to the xmas-icetube code. I may have found a better way to conserve power during sleep. The hardware change is simpler and should be compatible with any firmware.
--John <www.jarchie.com/email>
jarchie
 
Posts: 393
Joined: Sun Jun 24, 2012 1:16 pm
Location: Santa Cruz, California, United States

Re: Ice Tube Clock Extended Battery Hack

by wildtang3nt on Fri Jun 28, 2013 1:04 am

Alright, good thing I held off on doing any hardware mods (besides the photoresistor dimmer hack) :)

Also, may I just say that I LOVE your firmware, and for about 2 weeks I was still finding new options and features in the menu.
Proud owner of (among other wonderful things):
Li-Poly MintyBoost
RGB LCD Pi Plate & Pi Dish
Ice Tube Clock & USBTinyISP
wildtang3nt
 
Posts: 32
Joined: Thu Aug 09, 2012 1:31 pm
Location: Hamilton, Ontario, Canada

Re: Ice Tube Clock Extended Battery Hack

by jarchie on Fri Jun 28, 2013 10:07 pm

Alright, good thing I held off on doing any hardware mods (besides the photoresistor dimmer hack) :)


To be honest, you probably would have been okay. I think that the Adafruit firmwares and other alternatives I've seen (CaitSith2, DigiSage, Jsgf, wbp) all leave PC1 in the input configuration with the pull-up disabled. So I suspect that you could have tried other firmwares without anything bad happening. And the new sleep method will be backward compatible with clocks already modified for the soon-to-be deprecated extended battery hack. Those clocks will still run at ~1.8 uA without any further hardware mods--it's just that the connection between the voltage regulator and PC1 will be unnecessary and unused.

Also, may I just say that I LOVE your firmware, and for about 2 weeks I was still finding new options and features in the menu.


Thank you for the kind words!
--John <www.jarchie.com/email>
jarchie
 
Posts: 393
Joined: Sun Jun 24, 2012 1:16 pm
Location: Santa Cruz, California, United States

Re: Ice Tube Clock Extended Battery Hack

by jarchie on Fri Jun 28, 2013 10:46 pm

My most recent changes are now on GitHub. The new sleep code should extend sleep time from ~5 weeks to ~5 months without any hardware mods. Cutting the trace from the resistor divider and connecting the resistor divider directly to the power regulator--as described in step 1 of the original post--will extend sleep time to ~2.5 years. There is no longer a need for the connection between PC1 and the regulator (the yellow wire pictured in the original post), and that's the connection that in theory could be incompatible with other firmwares.

Clocks already modified for the now-deprecated extended battery hack will continue to work fine. Although the connection between PC1 and the voltage regulator is no longer used, a connection there will not cause any problems with the newest version of xmas-icetube. I hope to maintain this backwards compatibility forever. And there is no longer any need for the software portion of the extended battery hack, so there is no longer a compile-time option to enable the feature.

Here is how the new code works: if Brown out Detection (BOD) enabled in the fuses, BOD can be disabled when the clock goes to sleep. In this configuration, BOD is re-enabled before executing any code, and because BOD requires the internal voltage reference, the clock enables both BOD and the internal voltage reference before waking to execute the once-per-second timekeeping interrupt. That's important because the voltage reference is required for detecting power restoration via the analog comparator, and the voltage reference takes a relatively long time to start.

At the start of the once-per-second interrupt, the analog comparator is enabled, and by the end of the once-per-second interrupt, the analog comparator has produced an accurate voltage comparison between the resistor divider and the internal voltage reference. If voltage is higher than the internal reference, the clock wakes; if the voltage is lower, the clock disables BOD and the analog comparator, which automatically powers down the unneeded internal reference, and sleeps for the remainder of the second.

The end result is that an unmodified Ice Tube Clock runs at 10.6 uA, a 4-fold increase in efficiency. The resistor divider still consumes ~9 uA. So step 1 in the original extended battery hack further reduces consumption to 1.8 uA, so there is no longer a need for an extended battery hack compile-time option. Furthermore, the ATmega's PC1 is left as an input with no pull-up, so you can still connect it directly to the regulator, as in clocks modified for the original extended battery hack, but doing so has no detectable effect on sleep current with my equipment.

During sleep, I now use BOD, the internal voltage reference, and the analog comparator, but only for a tiny fraction of each second. So the the microcontroller should--and probably does--use more current, but it seems to be only a fraction of a microamp, and a fraction of a microamp is a small price to pay for the protection of BOD.


After thought: I suspected that my multimeter has dubious accuracy in the low microamp range, so I wanted to double-check that. I put a 270k resistor in series with my 3.3v power supply and a hardware-modified Ice Tube Clock. My multimeter estimated the resistance at 273.3k, and since that was within the 5% tolerance of the resistor, I assumed 273.3k was the correct value. My 3.3v power supply outputs 3.391 vots, according to my multimeter. The voltage drop across the resistor was 0.479 vots. So when the sleeping clock was supplied with 3.391 - 0.479 = 2.912 volts, it consumed 0.479 volts / 273300 ohms = 1.75 uA, according to Ohm's law. But the measured current (with 273.3k resistor in place) was only 1.5 uA. My conclusion is that my multimeter probably cannot measure fractions of a microamp accurately, so please interpret my original post and the results above accordingly...

After thought after my after thought: In my comment to the most recent commit pushed to GitHub, I reported that the new sleep code with hardware modification required 1.5 uA of power--better than the original extended battery hack! This was not a typo. It is what my multimeter displayed earlier this month. Today my multimeter displayed 1.8 uA for the same test, which supports my theory that my multimeter cannot measure fractions of a microamp accurately.
--John <www.jarchie.com/email>
jarchie
 
Posts: 393
Joined: Sun Jun 24, 2012 1:16 pm
Location: Santa Cruz, California, United States

Re: Ice Tube Clock Extended Battery Hack

by wildtang3nt on Sat Jun 29, 2013 11:35 pm

Nice work, I haven't had a chance to re-flash my clock yet. I'm waiting on a new top and back piece being cut by a local shop so I can properly integrate an Ultimate GPS and external antenna, I'll probably do it then since I'll have the case taken apart anyway.

I suppose if Adafruit has plans on doing a revision 2.0 of the design, this would be a handy modification to keep in mind if it should work with all firmwares :)
Proud owner of (among other wonderful things):
Li-Poly MintyBoost
RGB LCD Pi Plate & Pi Dish
Ice Tube Clock & USBTinyISP
wildtang3nt
 
Posts: 32
Joined: Thu Aug 09, 2012 1:31 pm
Location: Hamilton, Ontario, Canada

Re: Ice Tube Clock Extended Battery Hack

by wildtang3nt on Fri Jul 05, 2013 11:39 pm

I've flashed your latest firmware onto my clock, but have not done the hardware side of the extended battery hack yet. All seems to be working well though. I'm to understand that even in this configuration it should save some power vs. the Adafruit firmware?

My clock might end up with close to the original sleep power consumption anyway since I'm planning to connect the VBAT line of my Ultimate GPS to the clock's battery. A CR1225 battery can probably fit, but it could be tough removing it. Would installing the GPS' battery as well as soldering the 3V lines together effectively double the battery life?
Proud owner of (among other wonderful things):
Li-Poly MintyBoost
RGB LCD Pi Plate & Pi Dish
Ice Tube Clock & USBTinyISP
wildtang3nt
 
Posts: 32
Joined: Thu Aug 09, 2012 1:31 pm
Location: Hamilton, Ontario, Canada

Re: Ice Tube Clock Extended Battery Hack

by jarchie on Sun Jul 07, 2013 4:51 pm

I'm to understand that even in this configuration it should save some power vs. the Adafruit firmware?


That is correct, installing an ATMEGA328P and flashing the latest xmas firmware will reduce sleep power consumption to 11 uA--a 75% reduction relative to an unmodified Ice Tube Clock.


I'm planning to connect the VBAT line of my Ultimate GPS to the clock's battery.


That would certainly work. The GPS datasheet states that it will consume 7 uA during sleep. With the latest xmas firmware, the clock would consume total of 18 uA duing sleep--still a 60% reduction relative to an unmodified Ice Tube Clock. Connecting VBAT as you suggest would allow the GPS to power its internal real-time clock and remember satellite locations during sleep. The GPS could then acquire a lock in seconds, instead of minutes, after main power is restored.

But since the Ice Tube Clock already has a built-in real time clock, the clock will display it's own time until the GPS acquires a lock. Unless the clock has been sleeping for many months, the internal time should be fairly accurate. So I don't see a major advantage to shortening the time required for the GPS to acquire a lock, but perhaps I am missing something.


Would installing the GPS' battery as well as soldering the 3V lines together effectively double the battery life?


Personally I would play it safe and use only one battery.

Using two CR1220s in parallel should work, but you would always need to make sure the two CR1220 batteries are identical (e.g. same brand and same level of discharge). Otherwise the stronger battery will waste energy charging the weaker battery, and since coin cells are not designed to be charged, one of the batteries could be damaged and leak caustic material.
--John <www.jarchie.com/email>
jarchie
 
Posts: 393
Joined: Sun Jun 24, 2012 1:16 pm
Location: Santa Cruz, California, United States

Re: Ice Tube Clock Extended Battery Hack

by wildtang3nt on Fri Jul 12, 2013 2:53 am

In light of the minuscule amount of power the GPS uses during sleep, I'd say you're probably right, parallel cells might be more trouble than they're worth. However, being able to swap batteries without losing time and settings might be worth it, no?

As for the need for warm starting the GPS. I find that unless you use an external active antenna with a low-noise amplifier such as the one Adafruit sells, the GPS can take some minutes to gain a lock, and sometimes not at all if there is too much interference. Versus 5-10 seconds with warm start and a good antenna. Maybe I am just impatient :) I did buy the external antenna and am currently waiting on new case sides with appropriate mounting holes to install it, so perhaps the battery is not needed.
Proud owner of (among other wonderful things):
Li-Poly MintyBoost
RGB LCD Pi Plate & Pi Dish
Ice Tube Clock & USBTinyISP
wildtang3nt
 
Posts: 32
Joined: Thu Aug 09, 2012 1:31 pm
Location: Hamilton, Ontario, Canada

Re: Ice Tube Clock Extended Battery Hack

by jarchie on Fri Jul 12, 2013 1:42 pm

...being able to swap batteries without losing time and settings might be worth it, no?


Sounds like a matter of personal preference. The time will be lost, until the GPS reacquires a signal, but settings should be saved to EEPROM and should be restored when the microcontroller restarts. (If they are not, please let me know... That would be a bug!)

...the GPS can take some minutes to gain a lock, and sometimes not at all if there is too much interference.


I was unaware of the reliability issue, but it makes sense. And if the start-up time bothers you, that certainly seems like sufficient reason to provide GPS battery power.

Happy hacking! :-)
--John <www.jarchie.com/email>
jarchie
 
Posts: 393
Joined: Sun Jun 24, 2012 1:16 pm
Location: Santa Cruz, California, United States