Power to the PocketPC


In my recent “Power to the Smartphone” entry, I talked about the biggest drains on Smartphone batteries.  In this one, we’ll talk about how this differs in PocketPCs.  Almost everything I said about Smartphones in the previous entry is also true on PocketPCs, so make sure you read that entry before this one.  Note also that, when I say “PocketPC” I’m really talking about “PocketPC Phone Edition” devices.  We still sell PocketPCs that aren’t phones, but they’re a shrinking market. 


 


One Man’s Fundamental…


There are two differences between PocketPC and Smartphone that I consider fundamental: touch and suspend.   PocketPCs have a touch screen while Smartphones don’t, and PocketPCs suspend while Smartphones are “always on.” 


Now “fundamental” and “important” aren’t necessarily the same thing.  You might tell me that PocketPC having pOffice is way more important than whether or not the device suspends, and I might not argue with you.  But, for a battery life discussion, differences in which applications come with the device aren’t all that relevant.


 


Touch: It’s not all that electric


The touch screen itself isn’t a very large drain on power.  It’s similar to a button.  When it’s not being pressed, it burns almost no power.  When it is being pressed, it burns some, but not very much.  There are much bigger fish to fry than the touch screen.


The touch screen’s big claim to fame when it comes to battery life is that it can cause other big power drainers to run.  For instance, if you leave your PocketPC on and put it in your pocket, your pocket might touch the screen and cause the backlight to turn on.  As you know from the previous article, turning on the backlight is huge. 


Most people suspend their PocketPCs before putting them away, but you also run the risk of having the device wake up in your pocket for a meeting reminder or something, and then not turning off because the screen is being touched.  The Treo 700w has a killer solution to this problem in the form of a screen lock.  AKU2 devices also have a screen lock, though they’re not as good as the Treo’s.  From both a battery life standpoint as well as a “hey, how did this contact get changed?” one, it’s generally a good idea to lock the screen.


 


Suspend: And in the darkness bind them


The biggest difference between Smartphone and PocketPC is what’s happening when the screen is dark.  On both, if you don’t use the device for a minute or two the screen will turn off.  On PocketPC, you can also make this happen immediately by pressing the power button.  That’s not the important part, though.  The important part is that, on Smartphone, when the screen is off, applications are still running.  On PocketPC, for the most part, they’re not.  From a power savings standpoint, this has advantages and disadvantages.


The main advantage is that it’s much harder for an application to drain your batteries on PocketPC than on Smartphone.  Apps can still do bad things, but they have to work at it.  On a Smartphone, the app just needs to keep using the CPU to drain the batteries.  On a PocketPC, the app needs to keep the system from suspending first, then it can keep using the CPU to drain the batteries.  It’s pretty easy to do that, so this isn’t much protection against malicious apps.  But it’s reasonably unlikely that they’ll do it accidentally.  That stock ticker that I talked about in the Smartphone entry wouldn’t have as bad an effect on PocketPC, since it wouldn’t run while the PocketPC is suspended.


That’s the good news.  The bad news is that, if you don’t have apps that use the CPU when they shouldn’t, then suspending is actually worse for your battery life than not suspending.  Check out the “Mike, what are you smoking?” section of this entry if you’re interested in why.   The extremely short description, though, is that waking up and suspending again on a PocketPC takes a lot more time (and power) than doing the equivalent on a Smartphone.  This is no big deal if you’re just turning the device on occasionally to check your calendar.  But, in today’s highly connected world of devices that frequently download new mail and get SMSes, etc, the Smartphone model starts to really win out. 


The other downside is something of a secondary effect.  When PocketPC suspends, it specifically tells every driver to power itself down.  Because the PocketPC spends the majority of its time suspended, an OEM driver writer might be tempted to not do much power management in the driver itself and just rely on the suspend to take care of it.  On a Smartphone, however, the drivers have to aggressively manage their own power as quickly as possible, since they can’t rely on the big hammer that is suspend.  The end result is that, depending on the drivers, when the system is awake, it may be burning more power than an equivalent Smartphone would. 


So, what can a PocketPC user do about this?  Your job is to get the system to suspend as soon as possible.  Don’t wait for it to time out.  Press the power button when you’re done using it.  Be careful with apps that specifically keep the system awake.   For instance, if you use pMSN and sign in to IM, the device won’t suspend, even if you press the power button.  If you need to stay signed in, that’s what you need to do.  But be aware that it will affect your battery life.  If you’re syncing every five minutes, but reading mail every ten, consider syncing less often.  Etc.


 


LCDs and Other stuff


The other stuff is important, but maybe obvious.  PocketPCs tend to be physically larger than Smartphones, so they often have the ability to have larger batteries.  On the other hand, they also tend to have physically larger screens that need bigger backlights which burn more power. 


There were a few questions regarding LCDs in the comments of the previous entry.  I’ll try to answer them here.  So everyone is on the same page, when I say, “LCD” I’m talking about the screen but not the backlight.  Also, what I say about LCDs is the same for PocketPC and Smartphone.


One question was why black and white LCDs burn less power than color ones.  The main answer is that every dot (pixel) on a black and white screen takes one transistor, while every dot on a color screen takes three.  Transistors burn power.  Also, color screens tend to have more pixels than black and white ones (they’re higher resolution).  And, since there are more pixels in the same space, they tend to be packed more tightly together.  That means that you need a brighter backlight to shine through the tight mesh of them.  Finally, because pure black and white is high contrast, you need less light for your eyes to see it.  Some black and white external screens (like on a flip phone) don’t even have backlights. 


There was also a question on whether choosing a dark or bright background has any effect on power.  On a big LCD screen, it really doesn’t.   On some LCD technologies, it might have a small effect.  For instance, if you think about the black and white LCD on a calculator, when it’s not showing anything the screen is “white” and when it’s showing numbers, those numbers are “black.”  Not showing anything probably burns a little less power than showing something.  For a color LCD, though, there’s little, if any, difference between black and white.  However, there’s an upcoming technology called “OLED” where black doesn’t burn any power and white burns power.  So, depending on the technology, we’ve got black background being better than white, white background being better than black, and it not mattering.  Confusing?  The good news is that none of this matters.  The amount of power the LCD uses is completely insignificant compared to the backlight, and there aren’t many hours out of the day where the LCD is on but the backlight is off.


I hope these articles have answered your questions about PocketPC and Smartphone batteries.  As always, if you have more, ask away in the comments section.


Mike Calligaro


Comments (70)

  1. Tryst says:

    I have a i-mate K-JAM in work that is a smartphone, and that has touch screen – so there are smart-phones out there that have touch screen.

  2. MikeCal says:

    The K-JAM is a PocketPC, not a smartphone.  Smartphone doesn’t support touch screens, so if you have a WindowsMobile device with a touch screen, you have a PocketPC.  It’s possible that this will change in some future version, but that’s how it is now.

    Mike

  3. matt says:

    What a good read.  Thanks for sharing.

  4. marty says:

    Excellent information, thanks!  Its amazing how much battery life I save reducing backlight to half.  Screen lock is indispensible because the device wakes up randomly.  If only power button could invoke screen lock automatically!

    If I were to ask any question, it would be to explain why those freezes sometimes in the middle of the night that drains the battery (even while charging) and can cause me to miss my wake-up alarm.  I thought it was storage card related or third-party app related, but without either it still sometimes happens.

  5. BTW, as far as the power consumption of the Bluetooth unit is concerned (see the BT-related remarks in the Smartphone article), I’ve made some tests with current PPC PE devices and found out that always enabling the BT unit will only reduce the battery life with 20-40% in the worst case (when you don’t at all use your PDA and it just sits idling). In everyday situations, with current devices, the additional power drain caused by the enabled BT unit will be even lower (that is, it’s not because of the enabled BT unit that you end up having to recharge the PDA every day but because of you use it.)

    I’ve published the results at http://www.pocketpcmag.com/blogs/index.php?blog=3&p=1151&more=1&c=1&tb=1&pb=1 – feel free to read if interested.

  6. MikeCal says:

    I’m definitely not saying to stop using BTh.  What I’m saying is that, if you’re NOT using BTh, you should turn it off.  Even if the power drain was only 5%, if you’re not getting anything for that 5%, why waste it?

    Mike

  7. If you do, then you can always find some very interesting items at the Windows Mobile Team Blog. All sorts of helpful tips are there to help your experience be just that much better.There was a recent entry that I…

  8. Juhani Shuonen says:

    QUOTING… If only power button could invoke screen lock automatically!

    There’s a small utility which invokes device lock automatically when device suspends (ie. within 3 minute timeout or by power button pressing)

    see : http://mobilitytoday.com/forum/showthread.php?t=13030

  9. Werner Ruotsalainen says:

    Mike, thanks for the clarification. Indeed I misinterpreted your statement "If you’re using BTh, you need to have it on.  If you’re not, you should turn it off to conserve power."

    BTW, in the meantime, I’ve started making some serious (it takes days) Bluetooth / IrDA power consumption measurements on my HTC Wizard and on the hx4700.

    The BTh unit consumes very-very little additional power consumption on the Wizard.

    The BTh unit on the hx4700, on the other hand, with the new, 2.01 WM5 ROM version (as opposed to any other WM2003SE/WM5 version ever produced for the device), seem to be really buggy: it introduces a +85 mA power consumption plus. That is, users should beware of this bug when using the new WM5 version on the hx4700.

    I’ve also measured the power consumption of the super-bright, continuously lighting blue LED on the hx4700. It’s between 1 and 2 mA’s.

  10. Santiago Urueña says:

    And what about the PocketPC Phone Edition? Are the apps always on like the Smartphone, or do they suspend (except the radio stack). I suppose the latter… Thanks for writing so good posts and for sharing your knowledge.

    Santi

  11. MikeCal says:

    Although we still sell PocketPCs that aren’t phones, that’s a shrinking market. Our efforts are almost entirely behind PocketPC Phones and Smartphones.  At this point, when I say "PocketPC" I’m really talking about PocketPC Phone Edition.  

    That said, most of what I said above applies to non-Phone PocketPCs as well.

    Mike

  12. kuifje says:

    Hi Mike,

    thank you for taking the time to eleborate on different subjects in plain terms. Each of your blogs is a little gem. As it happens I know something about the working of LCD’s, so I thougth you, or your readers might appreciate some clarification on some of the LCD related points you mention.

    The main reason color LCD’s use more power is not the fact that there are three times more transistors (this is negligeable), or the mesh takes up more space, leaving less room for the light to pass through (not negligeable but small). The fact is, each subpixel is in fact a black and white pixel, with a small plastic filter preventing all light but the red/green/blue respectively to pass through. So the filter in a blue pixel (the darkest colour) stops about 90% (!) of the light passing through it, red about 70% and green (the brightest color) still around 40%, depending on the maximum saturation you want the display to achieve. The increase in power consumption of course comes from the increased backlight intensity you need to achieve the same brightness as a black and white.

    Second, having a a dark or white background DOES have an effect on power. An LCD pixel is a capacitor which needs to be charged alternatively positive and negative (to the same absolute value in a still image) to prevent deterioration of the liquid crystal. Now black or dark pixels (the "ON" state) need to be charged to 2 or 3 times the voltage as light pixels. Furthermore (inherent property of liquid crystals), the capacitor in black pixels is about twice the size of that in white pixels. Because of this double trouble, black pixels consume about 6 times the power as white pixels. This is a small but non-negligeable effect. How much? I don’t know.

    Keep up the good work, it is much appreciated.

  13. Tweakradje says:

    Mike,

    Do you know what hklmCurrentControlSetControlPower

    "SuspendToUnattendedMode"=dword:00000001

    does to the power consumption in suspend mode?

    And what can be the benifits to suspend to Unattended mode? No alerts?

    Cheers

  14. MikeCal says:

    That’s good to know, kuifje.  Thanks for the information.  You know more about LCDs than my hardware engineers do.  (-:  

    Even given that information, though, I believe that the most power an LCD can burn (showing the worst color) is still extremely small compared to what the backlight does.  Since most of the time the screen is on, the backlight is too, I believe that users won’t see a significant change in their battery life if they choose a light background or a dark one.  Definitely let me know if that’s not true.

    Tweakradje, I’m not familiar with that key.  I wonder if it’s a standard one or specific to your device.  From context though, I’m pretty sure what it does is keep the system from suspending.  Instead it will go to a power mode called "Unattended."  In that mode, the screen is off, but the system is still running.  You still get alerts, etc.  It’s really intended for applications that run periodically in the background (like Acive Sync running syncing on a schedule).  My "Power To the System" entry gives some more information on the different power states, including Unattended.  http://blogs.msdn.com/windowsmobile/archive/2005/08/10/450186.aspx

    Mike

  15. Nino.Mobile says:

    Software / Hardware SOTI Pocket Controller Professional v5.07 is out Pocket PC Thoughts is reporting

  16. George Styles says:

    Hi,

    Thanks for an interesting article. I have a question… I used to have a HTC Wizard WM5 phone, and have recently upgraded to the (rather lovely) Hermes (VarioII) phone.

    I have a bluetooth GPS received. On my old phone, I could load my GPS software (Mapopolis), connect to the GPS, and it would start logging my trail. I could press the power button to suspend the PPC and (contary to the ‘processor suspended’ claim in your article) it would carry on logging my trail while the phone was ‘suspended’. What was going on? was the bluetooth serial port waking the phone every 1s when a new GPS signal was received, or was it buffering it somehow?

    This was however the behaviour I wanted, and I found it didnt have any devastating effect on the battary life (eg, i got hours and hours out of it).

    On my new phone, as soon as I suspend it, it breaks the Bluetooth connection to the GPS, so the trail stops at the point I suspended it. Furthermore, it then fails to re-connect to the GPS without turning bluetooth off and on (from connection manager).

    Is there any way I can tell my new phone to NOT turn off bluetooth when it suspends?

    thanks

    George

  17. MikeCal says:

    There is a method an application can use to keep the system alive when the power button is pressed.  The application can request that the system enter "Unattended Mode."  While an unattended mode app is running, the system will act very much like a Smartphone (it will use something similar to the "Always On" power model).  

    It sounds like the Wizard was going into Unattended Mode when you had your GPS software running but your new device doesn’t.  I’m not sure what was configuring your old device to act the way it was, as that’s not standard.  

    If you’re a programmer, I can tell you the calls to make to put your device into unattended.  There aren’t any standard settings that work on all devices that enforce this, though.

    Mike

  18. Andy says:

    There ‘power to …’-posts were very informative… I started some testing because I planned to make an application for my PPC-Phone, but I want to run it all the time… so I wondered how it would affect the battery-life to keep the PPC ‘active’ all the time. I figured out that ‘Always On’ (with backlight off), is definately not an option.

    Since I am a programmer, I am interested in those calls to put the device in unattended mode… Then I can redo my experiment and see if can realize my dream-app 🙂

    Andy

  19. George Styles says:

    Mike – thank you for your answer… I (think!) i am a programmer… maybe I just need to write another simple app that runs in the background, requesting the ppc stays in unattended mode? am i being over optimistic hoping that these calls are available from managed code? or failing that from a dllimport? thanks george

  20. MikeCal says:

    Hey George.  There are two separate things you need to know.

    First to enter Unattended Mode call

    PowerPolicyNotify(PPN_UNATTENDEDMODE, TRUE);

    (I don’t think there’s a managed wrapper, but you should be able to pInvoke it.)

    To leave Unattend, call

    PowerPolicyNotify(PPN_UNATTENDEDMODE, FALSE);

    When in unattended, the system will run normally, but when you press the power button, it’ll drop to Unattended mode instead of suspended.  In that mode, the screen, backlight, touch panel, and audio are off, but the system is still running.

    However, the system will still time out to suspended on its own.  To keep that from happening, you need to do something to keep the system from timing out.  You have a few options there.  For one, you can go into the control panel and tell the system to never suspend on battery power.  Alternately, you can have your program call

    SystemIdleTimerReset();

    every 30 seconds or so.  

    The problem with both of these methods is that if the system will only ever turn its screen off if you press the power button.  If it turns on for any other reason the screen will stay on (though the backlight will still turn off).  

    Getting the device to have the system continue but the screen to time out puts you into somewhat uncharted waters.  There is something you can do in the registry, but it’s not guaranteed to work.  We can talk more about that if you’re interested.

    Mike

  21. George Styles says:

    Thanks 🙂 i will try and put a program together after my holiday next week, and let you know how I get on via this forum. thanks again. George

  22. Quibard says:

    Mike, what about Infrared? I’ve seen a device, WM2003SE, that would gain almost 100% more battery life (from 4 to 7 hours) by just turning off IR. The explanation given was that IR is an active listener and keeps polling other devices in range, eating up batteries…

  23. MikeCal says:

    The last couple of devices I’ve worked on haven’t had IR, so I’m not sure how much power it draws.  However, it’s certainly in the same kind of boat as Bluetooth.  If you’re using it, use it.  If you’re not, turn it off.  No point in burning the power if you’re not going to use it.  

    Mike

  24. Xander says:

    Hi Mike great article.  I was pondering something the other day.  Back during my Palm days there was a useful application that could modify the critical voltage threshold the system used to determine whether you had a low battery level.  Palm had defaulted it to 3.75 but many found this to be much too conservative and used the application to lower it to about 3.4-3.5.  This usually provided a big boost in uptime while still leaving enough juice to power the memory for a couple days afterwards(during the days of volatile memory).  I’m sure this was looked into during the transition from wm2003 to wm5 but how much was this value actually changed?  I haven’t seen any hard numbers and I’m sure it varies between devices but is it possible to further lower this number?    

  25. MikeCal says:

    Xander, pre-persistent storage (WM2003 PocketPCs), we required that the OEM’s battry driver report that it was out of charge when it still had enough power to keep the ram alive for 72 hours.  On a 128M device, that tended to be 40% of the battery capacity.  

    Now that we’re on persistent storage, we’ve removed that requirement completely.  In general, WM5 devices shouldn’t turn off until the batteries are actually empty.  

    Now, it’s certainly possible that someone made a mistake somewhere.  Maybe there’s a device where the OEM forgot to remove the 72 hour rule, etc.  But I believe that most devices took advantage of this change.

    It’s also possible that they report being empty before they actually are for other reasons.  For instance, LiIon batteries are physically damaged if you drain them too far.  It’s possible that some devices report being empty before that point to protect the batteries.  Etc.

    Because this is all handled by the OEM’s drivers, there’s no generic way to change it.  It’s possible that your device has settings you can modify where another wouldn’t.  

    Mike

  26. icanfly says:

    Hi Mike, great articles on power consumption there 🙂

    I own a HTC Wizard running WM5, but I believe my question is not unique to this device: No matter what I do, ActiveSync keeps reappearing in my running tasks list every 10 minutes or so, even when the screen has been shut off with the power button and there has been absolutely no activity whatsoever. WiFi, BT and Infra are all turned off, I sync over USB, so I don’t see any valid reason for the app to be running. If I kill it in the task list, it’s just magically reappears in a little while. If I’m reading your articles right this means that it’s constantly eating up my valuable CPU power, doing… nothing? Can you please help me understand this better? Does it actually need to constantly run in the background and if not, how do I turn it off? Thanks in advance for your help.

  27. Swee says:

    Hi Mike

    Thanks for your article. I’ve just got a PPC phone recently, bumped into your blog and has been finding it very informative.

    I have a question though. I come across multiple comments from forums that the permanent battery indicator that comes with the AKU2 of WM5 is actually draining a lot of power. I’m not sure if this is true. Can you help comment on this?

    I certainly love the indicator and hope to keep it if it is not the a power hungry application.

  28. MikeCal says:

    It’s very unlikely that showing a battery icon is draining power.  The only way I can imagine that happening is if the system was constantly checking the battery level to update the icon.  But, to my knowledge, that’s not happening.

    When you installed AKU2, did you enable always up to date sync?  If you get a lot of mail, which results in your device syncing more often, that would drain power faster than if you weren’t syncing very often in the past.  One particular place to check is syncing during off-peak hours.  Maybe you don’t need your phone to be burning power keeping your email up to date when you’re asleep, etc.  This is especially bad if you, like me, have bad cell reception at home.  When reception is bad, the cell radio burns more power trying to get a signal.  

    These are more likely culprits than the battery icon for draining power.

    Mike

  29. icanfly says:

    Hi Mike,

    You never got around to answering my question on the ActiveSync app two entries back. Can you plesae give me some info on that?

    Cheers

  30. Amol says:

    Hi Mike,

    We are developing an application which does search for BT devices and then connects to them. But when device goes in to suspended mode,

    application fails to start search on WM5. It works fine on WM3.

  31. Alexey says:

    Could you please comment on how to implement following thing: I need an ppc application to connect to remote server and wait for some data from server, say for 30 minutes. What happens when device goes to suspend? Is there a way to wake a device when data from server arrives? Or is the only solution to this using unattended state?

    Which way does ActiveSync direct push mail works, as far as I know it does roughly the same – opens tcp connection to Exchange server and waits for data from it.

  32. Alex says:

    I’ve read your articles about smartphones and PPC power. I’ve found them very interesting, as well as all your blog. Great job, thanks for sharing all that information.

  33. Martine says:

    Hi guys,

    I have 3 barcode gun with pocket pc and the maximum I can put for power auto shutoff is 5 minute. How I can disable the auto shutoff (registry or anything else)

    Thank you

    Regards

    Martine

  34. MikeCal says:

    Martine, the settings page that determines this is controlled by the OEM, so it might not be exactly how I’m describing it.  But, typically on a PocketPC it’s Start->Settings->System->Power  That usually has a checkbox that says "On Battery power: Turn off the device if not used for."  I’m assuming that’s where you’re currently setting the time to 5 minutes.  If you clear the checkbox, it shouldn’t turn off automatically anymore.  It will still turn off if you press the power button.

    If the OEM has removed that checkbox, there are other possibilities, but let’s start with that one and see if it works.

    Mike

  35. As mentioned in the commentary says:

    I’m interested in putting a device in unattended mode and letting the screen time out, then bringing it back up.  It’s the latter part that’s the problem without a kickstart from the hardware.  You mention in an earlier response a way to do this using the registry – right now I’m playing with PowerPolicyNotify and assorted PPN_ constants in both a driver and an app without any luck.  Any chance you could unpack that method as a PocketPC community Christmas present?

  36. Rajeev says:

    I’m also interested in Alexey’s question regarding how ms direct push mail (specifically, keeping the ping conneciton open for so long and being able to receive data back) works in a "suspended" state.

  37. Sarwa says:

    I have written an application using C# and SQL Server mobile for WM 5 device. Its a PPC Phone device with SD Card in which database is kept.

    My application has a background thread which periodically comunicates with the database that is stored in SD card. But when device goes in unattended state application looses all database connections. I am using PowerPolicyNotify(PPN_UNATTENDEDMODE, TRUE) to force my PPC to not to go in suspended state.

    This works fine when my database is in main memory but when I put database on SD card it doesn’t work.

    Can I force the device to not to go in Suspended or Unattended state even if user press PowerOff button.

  38. MikeCal says:

    Sarwa, in unattended mode, the system will still suspend if there’s no user activity for whatever the timeout was set to.  You still need to call SystemIdleTimerReset() every 30 seconds if you want your app to keep the system from suspending.

    Rajeev, sorry I don’t know the code Active Sync is using to have the system wake up when the ping returns.  I know that the cellular radio is what is waking the system up, but I don’t know how it was set up to do this.

    Mike

  39. JeanB says:

    Hi,

    I read all the "Power to the …" articles and many other things on the web but I haven’t found a solution for my problem.

    I am developping a software that receives and processes text messages (sms) on a pocket pc phone edition (wm 2005).

    When my device is suspended and receives a text message (SMS), the system wakes up for a few milliseconds, it executes some code, but automaticaly falls back to sleep after that. (As I have another thread that processes the incomming message, this part of code is never executed, the system went to suspend state before it could be executed).

    I tryed to call the method SystemIdleTimerReset() just after the device wakes up, this part of code is executed but has no effect, the system still goes to suspend mode after a few milliseconds (the screen flashes, displaying a white screen, then black again).

    I didn’t have this problem on OS windows mobile 2003 (I am now working on wm 2005).

    Funny thing is that when the system takes care of the text messages by itself (using the process tmail.exe), the problem doesn’t occur, the device wakes up and stays on…

    Does anyone had the same problem and has a solution to resolve this issue? Is there any message I have to send to force the device to stay awake for a longer time ?

    Thanks for your answer, I am stuck…

    jb

  40. JeanB says:

    Ok, I fixed it.

    Just in case it happens to someone else, I give the trick :

    I just called the method SetSystemPowerState(NULL,POWER_STATE_ON,POWER_FORCE);

    to force the system to stay on just after the system woke up…

    And it does the job, I am not sure this is the clean way to do it but at least it works…

    BTW, if you work with an old version of Embedded VC++ (my case), you have to get the right library first (install the appropriate SDK, then copy the file pm.h in you project directory and create a link to the folder containing coredll.lib)

    jb

  41. MikeCal says:

    I don’t think that’s what you want to do.  That will force the device into the on state, turn on the screen, enable the touch screen (possibly causing strange things to happen if the device is in a pocket and the screen is being touched), and set a long timeout.

    What happened when you did the PowerPolicyNotify that I suggested in the linked comment?  That should do exactly what you want.  It should put the system into unattended, allow it to stay awake for just the amount of time that your SMS app needs while keeping the screen off.  Then, as soon as you leave unattended mode (also in the linked comment) the system will immediately shut back down.

    Mike

  42. FabioL says:

    Hi Mike,

    My program runs in background, scheduled with CeSetUserNotificationEx. When the device wakes up they will be on UNATTENDED mode or I need to set it? And the embedded radios (GPS, Phone, BT, WiFi) still working on that mode?

    Tks,

    Fabio

  43. MikeCal says:

    That’s correct.  The only way for the system to know that your app intends to run in unattended mode is for you to tell it.  That’s what the PowerPolicyNotify’s are for.  Yes, the radios should be on in unattended.  I really did discuss this at length in the thread I linked.

    Mike

  44. FabioL says:

    Thanks for your answer.

    Fabio

  45. Felipe Gonzalez says:

    Hi very educational read, thx for sharing, i have the following doubt.  I hve just installed emoze, a free pushmail client for PPC, now, it integrates through the included messaging application, and lets you configure alerts (new mail, etc), through the OS control panel "alerts and notifications" icon.  Now, i’ve configured the system to play a sound and vibrate when a new mail arrives (this is integrated on the messaging application).  Now, when the device is on and i receive a new email the alert is generated successfully and plays the sound and vibrates.  Now when the device is off (screen off) i just get the vibration, sound is not delivered, if i turn the vibration off, there is no way of knowing you have a new email.  When i turn on the phone, the messaging app has the new message, so it has been processed successfully.  I wonder if this power management stuff affects sound alerts in some way or the other. or if something in the registry can be done to change it.  Other aplications not dependent on the OS notification system work well when screen is off.   Your thoughts ?

  46. MikeCal says:

    I don’t know exactly how emoze works, but I can speculate based on your description.  I’m going to guess that emoze puts the system into Unattended mode while it’s syncing.  During unattended the audio driver is powered off.  So if the program tries to play a beep, you won’t hear it.  Typically, the vibration driver is not powered off in unattended, so you would still feel the vibration.

    If this is the case, the correct thing for emoze to do is SetPowerRequirement on the audio driver before playing the sound, the ReleasePowerRequirement when the sound is done playing.  That will temporarily power up the audio to allow it to play the sound.

    It is possible for you to change the registry so that an exception is made for the audio and it’s not powered off during unattended.  Doing this isn’t easy, but it’s possible.  It’s also completely untested, and I don’t know what other effects making the change will have.  So I don’t suggest it.

    Mike

  47. charlie3 says:

    This freeware amp meter does not work on my month old Samsung i730 but would be nice if something like it were built in so users can observe power demands and decide priorities. http://www.freewarepocketpc.net/ppc-download-acbpowermeter-v1-1.html

    It would be nice if the power output of wifi was adjustable.

    User adjustable power consumption warnings might be helpful.  

    Pocket pc power management and profiles deserves deserves the same kind of attention as my notebook PC.

    My Samsung i730 is one month old.  When people ask I say it’s a useful computer and mediocre cell phone on account of ruggedness not compatible with mass and battery life issues when the device is only carried as a phone.  It’s also annoying that the device tends to freeze overnight and that missed calls and voice messages not being displayed more prominantly.

    Microsoft blogs are a good idea.  Thanks for doing this.

    Charlie

  48. Serena says:

    Is there a timer that we can set to wake up the Pocket PC after it has been turned off automatically? such as we want to set the Pocket PC so that it can turn itself on 10 minutes after it is off?

    Thanks!

  49. MikeCal says:

    Serena, the typical way to do that is to use CeRunAppAtTime.  You can’t say, "Turn on 10 minutes after you turn off" but you can say "Turn on at this time."  Since you can find out what time it is now, this also allows, "Turn on 10 minutes from now."  Etc.

    Mike

  50. Manitu says:

    Hi Mike

    Nice articles, but I have a problem with GPS and unattended Mode. Unattended Mode itself works fine, so when the device suspends the app is still running, but i want to communicate with the internal GPS (HTC P3600) on COM9, and this one stops working after the suspend.

    Even after Resume I have to close and reopen the GPS Device again, tried both, the GPSID and directly communicating via serial port.

    I tried to set the PowerRequirements for COM9 with

    SetPowerRequirement("COM9:", DEVICE_POWER_STATE.D0, POWER_NAME, null, 0);

    but GPS still stops after suspend.

    Any Tipps ?

    Thanx Manitu  

  51. MikeCal says:

    Manitu, "suspend" and "unattended" are different things.  You said that the app runs in unattended, but the com port stops working after suspend.  Do you mean that the com port stops working in unattended?  Or are you asking how to keep the com port from shutting down on suspend?

    Mike

  52. Manitu says:

    Hi Mike

    After start of my Application I do a

    PowerPolicyNotify(UnattendedMode(0x0003), 1)

    and a Thread is Running receiving all power notifications. So when I now Press the Power Button i ge t a Suspend(0x00200000) notification. My App continues running, (I started a timer that writes every second the time into a listbox, so I know that I don’t miss a Event).

    To be able to play a sound in UnattendedMode, I have to

    SetPowerRequirement("WAV1:", DEVICE_POWER_STATE.D0, POWER_NAME, null, 0);

    otherwise it wouldn’t work.

    So I tried the same with the comport so that GPS continues working after pressing the Powerbutton, but that doesn’t work (tried both the internal GPS on COM9: and a Bluetooth GPS Mouse connected to COM8:)

    After the Resume I have to Close and Reopen the Port.

    Hope You understand what I try to do.

    Thanx Manitu

  53. MikeCal says:

    Manitu, is your app also calling SystemIdleTimerReset() every 30 seconds?  Maybe the system is suspending on its own later?

    I’m asking because most OEMs don’t make their serial drivers power managed.  That would mean two things:

    1) Calling SetPowerRequirement on them wouldn’t do anything.

    2) They’re not going to be shut down until a full suspend.

    Because of 2, the com port shouldn’t be shut down if you’re in unattended mode.  So, my best guess is that the system is still suspending.

    Mike

  54. Manitu says:

    Hi Mike

    Thanx for your answer, it seems that PowerManagment for the GPS Device isn’t implemented.

    I don’t call SystemIdleTimerReset, and my App is still running wenn I press the Power Button, I know that, because I update the screen every second and I play a sound, and I can hear it.

    So I have to close the GPS device on Suspend notification, and reopen it on Resume notification.

    Thanx Manitu

  55. Miguel Santos says:

    Hi,

    I’m facing the same problem as Manitu…

    But in my case I use SystemIdleTimerReset, but the GPS is going off, altough I call also PowerPolicyNotify(UnattendedMode(0x0003), 1).

    How can we now if the driver is off or on?

    I’m sure I’m in unattended mode because I’m calling a WebService when I have the backlight off…

    Any comments?

    thanks Miguel

  56. Elliot says:

    The battery on my pocket pc is fine and yet the ppc goes off at 30% . what can i do?

  57. Mick says:

    Hi Mike,

    Great Article, in fact great series of articles.

    I have used the information that you have provided to prevent my phone from suspending, and I continue to reset the idle timer so that I never suspend, I will only go to unattended mode well my app is running, but as soon as I enter unattended mode my wifi connection drops off.

    I’m making a very specific app that needs to always have an active network connection, which in come conditions wifi might be the only connection available.  Is there a way for me to override the wifi turning itself off?  how well is that going to work on other phone besides the one HTC that am testing on?

    thanks again for the great articles, they really have helped clear things up.

    Mick

  58. MikeCal says:

    Mick,

    We unfortunately didn’t make hard guidelines on what OEMs should do with WiFi in Unattended.  Some OEMs will shut it down and others won’t.  If the OEM put WiFi under the control of Power Manager, then you can keep it running with the SetPowerRequirement(), but there’s no imposed requirement from us that WiFi be under control of Power Manager.  Sorry I don’t have a better answer for you.

    Mike

  59. Docdan says:

    There exists the freeware app ACBPowerMeter (mentioned in a previous post), which people are using to monitor the current usage of PPCs and measure their battery’s capacity (in mah).

    I would like to know how this app works, what hardware/software hooks enable this app to measure current consumption and whether it can be considered to be accurate. As I’m sure you are aware, current and power measurements are a tricky business for a device since current (and therefore also power) requires an INLINE (series) monitor, like a known resistor value or an active series pass transistor set up to signal current output. These circuit elements by design actually lessen the amount of voltage available to the actual device and thus it would have to be a design priority to include a current monitor, otherwise the device is better off without it and just have a simple voltage monitor (which doesn’t have these issues).

    So, do PPC device in fact have current monitoring circuits that are software accessible via some WM API ? What assumptions must the ACBPowerMeter use to compute its power and current measurements (does it assume a fixed Li battery voltage ?) Is it likely to be very accurate ?

    Thanks.

  60. MikeCal says:

    Docdan, I have no idea how you could accurately measure power with an app.  I can think of ways to infer power draw.  It’s relatively easy to get CPU times, LED blink rates, and knowledge of when the Backlight turns on, etc.  If you knew which parts were in the device you could deduce how much power they’re drawing, etc.  It would be hard to tell if the audio amplifiers are powered, etc.

    The way I do power analysis is with hardware.  I remove the battery and attach a power supply to the battery leads.  The power supply tells me exactly how much power its supplying to the phone, and dumps that data over USB to a nice little app that shows me graphs in real time.  With no battery there, all power being drawn needs to be coming from the supply, so I know EXACTLY what’s happening.

    Mike

  61. 40th Floor says:

    Current use can be read from the regular power status api, which has been around forever it seems.  Not all devices will report this, some will be negative (when on battery), or always positive.

    GetSystemPowerStatusEx2

    SYSTEM_POWER_STATUS_EX2

    BatteryCurrent

    Amount of instantaneous current drain in milliamperes (mA). This member can have a value in the range of 0 to 32,767 for charge, or 0 to –32,768 for discharge.

    BatteryAverageCurrent

    Short-term average of device current drain (mA). This member can have a value in the range of 0 to 32,767 for charge, or 0 to –32,768 for discharge.

    BatteryAverageInterval

    Time constant in milliseconds (ms) of integration used in reporting BatteryAverageCurrent.

    BatterymAHourConsumed

    Long-term cumulative average discharge in milliamperes per hour (mAH). This member can have a value in the range of 0 to –32,768. This value can be reset by charging or changing the batteries.

  62. Craig Hockenberry is a smart guy. He’s been around for a while, and has an impressive track record in the Mac software world. I don’t, but that’s not going to stop me from arguing with him about background apps on…

  63. DanHTC says:

    I just got my HTC Touch and this blog has been great in helping me figure out how to conserve power.  One thing I’ve noticed is that when I leave the pocketPC charging overnight (while connected to activesync to keep in sync), once the device lock appears (which I set for around 5 minutes), the screen will not shut off.  Is there any way to get the screen to shut off with inactivity without having it shut down entirely (and disconnect activesync) and without disabling its automatic lock feature?

  64. Jaykay says:

    Hi Mike,

    thanks for your excellent blog.

    I need to write a program to keep running while in the unattended mode. Using systemidletimerreset, as you had suggested, would keep the screen light on, unless I manually press the power button. How do I continue to run the program for 1 hour in the background, in unattended mode but allows the screen to light off like as if it’s suspending but allowing my program to run.

    What’s the alternative method you had suggested in one of your comment/reply?

  65. Over the years, I’ve delivered several “Top 10” sessions and called them different things. Top Snafus,

  66. Martina says:

    This is very nice site for me wish he all the best.

  67. ipsi says:

    That explains a lot, I think. It mostly explains why I’m not getting proper IMAP-IDLE support on my nice new Treo Pro, despite the software being fully capable of it. Hell, even the automatic, every 15 minute IMAP poll doesn’t work if I hit the power button or otherwise turn the screen off…

    If you happen to know of a way to get the Palm Treo Pro (or any HTC device, maybe it’ll be the same on the Pro…) into Unattended mode without having to write/install a program (Visual Studio is not cheap) then I’d really appreciate knowing about it.

    All the above is assuming, of course, that this is still how things work in WM 6.1. If it’s not, then I’ve got no idea why my email client (FlexMail) decides to stop synching as soon as the screen turns off…

    Hopefully you’ll spot this message at some point :).

  68. Frank Seydel says:

    HI, from O2 XDA neo (WM5) recently i switched to ipaq 614c.

    Now when i am travelling I do enjoy mp3 a lot. The neo always switched off back light completley suspending mode, and I could listen to mp3 w/o interruption. The 614 either turns completeley off after a minute. Or, having adjusted the power off settings, is in suspend, yet the light inspite of shutting off just dims down a bit even though i´ve set it to switch off! In fact it only would switch off when I press the power button. So listening to music drains my battery drasticaly. Any suggestion would be highly appreciated. Regards Frank from Germany

  69. BaGRoS says:

    How i run my application in background?

    If I switch power button my application stops…

    This is alarm clock :/

    I write in VB.NET

    bagros@o2.pl