iCufflinks improved battery life code change

Breakout boards, sensors, Drawdio, Game of Life, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

iCufflinks improved battery life code change

Postby scott-42 » Sun Jul 17, 2011 11:49 pm

I was going through the cufflinks source and it looks like you can improve the battery life by utilizing the idle sleep mode instead of actively running the CPU clock in the delay section. Is there any reason your not sleeping to preserve power between PWM value switches?

Basically you are delaying for about 17ms between each change of the PWM value. If you set the Watchdog timer to interrupt mode it is capable of waking the device from sleep. Setting the watchdog timer prescaler at 0 you get 2k cycles which is about 16ms. You should be able to sleep those entire 16ms instead of running the CPU and counting down the delay.
scott-42
 
Posts: 123
Joined: Mon May 30, 2011 9:46 am
Location: Santa Clara, CA


Re: iCufflinks improved battery life code change

Postby scott-42 » Mon Jul 18, 2011 5:54 pm

I sent some sample code via a github pull request. I'm ordering some tiny4s to try it out myself.
scott-42
 
Posts: 123
Joined: Mon May 30, 2011 9:46 am
Location: Santa Clara, CA

Re: iCufflinks improved battery life code change

Postby adafruit » Tue Jul 19, 2011 1:32 pm

please try it out! dont forget that the PWM module needs to stay active during the sleep mode - not sure how much less power it'll consume if that's still active!
User avatar
adafruit
 
Posts: 10483
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: iCufflinks improved battery life code change

Postby scott-42 » Tue Jul 19, 2011 2:21 pm

As soon as my order shows up I'll give it a try. Although it wont be until the end of the week even with 2nd day air. It should work as expected the only difference is the delay between PWM changes will be 1ms less (16ms instead of 17ms) but I could add back in a 1ms loop if it really matters. I was thinking more about battery savings instead of running the CPU full speed for a wasted 1ms.

During the Idle sleep mode the I/O clock is left active which is what the PWM uses. Since I didn't see any changes to the default clock setup, I assume that it is running the default 8MHz with a division factor of 8 which ends up 1MHz.

CPU in active mode 1MHz@2V is about a 0.2 mA draw.
CPU in idle sleep mode 1MHz@2V is about 0.02 mA draw.

Idle mode is a 10x improvement over active mode. The biggest draw is going to be the LED and I'll have to see what that is actually pulling once I have one. I ordered a SMLK34WBECW1 to test with.

Simple test circuit would use a charged super cap as the battery and test how long it takes to drain the cap and the chip shuts down. I can send you a hex file (or you can compile the source) if you want to test is out sooner otherwise it will have to wait until I actually have a chip to test with.
scott-42
 
Posts: 123
Joined: Mon May 30, 2011 9:46 am
Location: Santa Clara, CA

Re: iCufflinks improved battery life code change

Postby scott-42 » Wed Jul 20, 2011 5:37 pm

What is the value of R1 on the cufflinks? I want the demo circuit to be as accurate as possible. It is not in the schematics by the way, only that it is an 0805 size.
scott-42
 
Posts: 123
Joined: Mon May 30, 2011 9:46 am
Location: Santa Clara, CA


Re: iCufflinks improved battery life code change

Postby scott-42 » Thu Jul 21, 2011 5:39 pm

Here is the test data from the original code:
Code: Select all
Time, Max, Average, Min
7/21/2011 4:43:07 PM, 1.923 mA DC, 0.848 mA DC, 0.458 mA DC

Here is the test data from my modified code:
Code: Select all
Time, Max, Average, Min
7/21/2011 4:56:08 PM, 1.671 mA DC, 0.601 mA DC, 0.203 mA DC

So with just the sleep added the average power used drops by about 0.25 mA. There are a couple of other power save tricks I want to try, but at least this is a little improved over the original code.

Doing some math based on your 24 hour run time before changing batteries means this change should improve battery life to about 34 hours.

Math for the lazy. Assume a CR1220 is 35mAh. If the battery is drained after 24 hours, then the drain is 35mAh/24h = 1.458mA
Figure out the ratio: 0.848mA/1.458mA = 0.601mA/x => x = 0.601mA/0.848mA * 1.458mA => x = 1.033mA
35mAh/1.033mA = 33.87h
scott-42
 
Posts: 123
Joined: Mon May 30, 2011 9:46 am
Location: Santa Clara, CA


Re: iCufflinks improved battery life code change

Postby scott-42 » Thu Jul 21, 2011 7:03 pm

Fluke 289 Multimeter using Min/Max sampling while in mA mode. Sampled over a few minutes for each reading.

Power is coming from a bench supply set at 3V, positive goes directly into meter, meter out goes to circuit. The circuit is the same design as the schematic.

I think I can shave off even more from that power usage but getting the AVRISPv2 to play nice with the ATTiny4 is a pain in the butt. Got any tips on getting that TPI connection to work all the time?
scott-42
 
Posts: 123
Joined: Mon May 30, 2011 9:46 am
Location: Santa Clara, CA

Re: iCufflinks improved battery life code change

Postby adafruit » Thu Jul 21, 2011 9:49 pm

you can solder to the pads with 30 AWG wire
User avatar
adafruit
 
Posts: 10483
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: iCufflinks improved battery life code change

Postby scott-42 » Fri Jul 22, 2011 12:08 am

Some more good news, I was able to shave off a bit more using a couple more techniques. This is the final run load.
Code: Select all
Time, Max, Average, Min
7/21/2011 11:54:15 PM, 1.621 mA DC, 0.541 mA DC, 0.151 mA DC

Again, doing the math with the new average gets you about 37.63 hours or a 57% increase in battery life

I'm not sure there is much more to be gained in power savings.
scott-42
 
Posts: 123
Joined: Mon May 30, 2011 9:46 am
Location: Santa Clara, CA

Re: iCufflinks improved battery life code change

Postby scott-42 » Fri Jul 22, 2011 11:00 am

Turns out there is a little more to save. I've shrunk the code by cleaning up the data block and fixing the couple of glitch data points in it. I'll play around a bit more and post some results later.
scott-42
 
Posts: 123
Joined: Mon May 30, 2011 9:46 am
Location: Santa Clara, CA

Re: iCufflinks improved battery life code change

Postby scott-42 » Fri Jul 22, 2011 1:38 pm

Alright I think I'm done with this project for now. I took out half the data in the data block since so much of it was redundant. There were a couple of glitch data items in there as well which got removed. By removing half the data the CPU can sleep twice as long between updates to the PWM. This only saves a tiny bit of power 0.006 mA but significantly reduces the compiled app size.

So the maths tell me this new version at 0.535mA is about 38 hours of run time. (58.5% improvement over the 24 hour version)

Someone will have to test this with a real device and battery and report back on real world battery usage.
scott-42
 
Posts: 123
Joined: Mon May 30, 2011 9:46 am
Location: Santa Clara, CA

Re: iCufflinks improved battery life code change

Postby adafruit » Fri Jul 22, 2011 3:29 pm

good point, not all the pwm points have a delta. we will try out your funky fresh code and do a 'race' comparison between two cufflinks :)
User avatar
adafruit
 
Posts: 10483
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Next

Return to Other Adafruit products

Who is online

Users browsing this forum: mibignistinly and 10 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [105]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]