How reliable is the BatteryLifePercent member of the SYSTEM_POWER_STATUS structure?

A customer was writing a program that called Get­System­Power­Status and used the SYSTEM_POWER_STATUS.Battery­Life­Percent value. The customer wanted to know whether a reported battery life percentage of 38% really means that the remaining battery life is between 37.5% and 38.5%.

Although the value is reported to 1% precision, the accuracy in practice is much worse. Similarly, the Battery­Life­Time is reported in seconds, but if your battery actually lasts exactly the amount of time predicted by that field (and not a second longer or shorter), it’s almost certainly a fluke. Even a stopped clock is right twice a day.

These battery levels come from the hardware itself, so you are at the mercy of whoever manufactured your motherboard. Some laptops update the values at 1-second intervals; others can take 5 seconds or more. In practice, these hardware-reported values have been found not to be particularly precise, and in odd cases have occasionally been spotted behaving in strange ways, such as spiking briefly and then returning to a sane value.

But if you use the values (as flaky as they might be), you’ll at least be in good company: These are the same values that the Windows Battery Meter displays.

Bonus chatter: There’s another interface for retrieving battery life information, and that’s WMI Win32_Battery.Estimated­Run­Time. The values for this also come from the hardware, but they are more unstable than the values returned by Get­System­Power­Status because the estimated run time is an extrapolation based on the current battery load. This makes it more sensitive to short-term fluctuations in energy consumption, creating the paradoxical situation where more accurate information is actually less useful.

Comments (13)
  1. NUXI says:

    I'm suprised you mention the motherboard as the biggest source of hardware uncertainty and not the circuitry on the battery itself that reports it's original max capacity, current max capacity, and current capacity.

    [I'm a software guy. Everything hardware I call the motherboard because I'm too stupid to understand the differences. -Raymond]
  2. lefty says:

    Microsoft (or other system developers) might do well to follow the lead of automobile manufacturers, and fib a little on the safe side.  I can run my car quite a while even after the gas gauge has dropped below "E".  But, I can't recall the last time I was able to run my laptop when the battery gauge said it was empty.

    On the other hand, it seems common enough for for a computer (or whatever device – this is certainly not unique to Windows-based laptops) to die when the battery gauge says there 30% or so left (or maybe it actually does drop to 0% first, but only seconds after reaching 30%).

    [if you tinker with the algorithm, people will compare it to the previous algorithm and the conclusion won't be "Windows is reporting my battery status differently" but rather "Windows drains my battery faster!" -Raymond]
  3. slippery slope says:

    Unlike lefty, I think that fibbing the battery meter is a bad idea. First, it's not precise enough that the software would be able to lie even convincingly. Second, people will just adjust to the new display and only plug in when the meter has been at zero for a while (like some do for gas). Then we'd have a display that starts from inaccurate information and adds extra inaccuracy. No thanks!

  4. Brian says:

    Running your car past E certainly works, but isn't very good for your engine, as bumps in the road and sloshing due to acceleration and turning can cause air to enter the fuel lines.

  5. configurator says:

    I wish there was a way to set the maximum battery life, or turn power management off altogether. My laptop hasn't been above 70% for a couple of years now, and as of the last three weeks it's constantly on 5%. Which means whenever I pull the power cord out it hibernates. Changing the critical battery level in power settings doesn't work – it gets reset to 5% immediately. And changing the critical action to sleep doesn't really work either. Since I actually have a very short battery life I wouldn't remove the power plug unless I'm just moving to the other room, which is pretty common – and every time I do that I now have to wait for a hibernate and then a resume.

  6. Joshua says:

    @configurator: I think you can disable the battery in device manager to accomplish that.

    If not, deleting My Computer from device manager and adding "Standard PC" will disable power management, at the cost of any second core and DEP.

  7. Andrew says:

    Any reported cases of GetBatteryLifePercent() just being implemented as 'return 100' for marketing purposes? :P

  8. Lazbro says:

    I'm curious how this battery indicator actually works, considering the whole point of thirty years of battery evolution was to create a battery that delivers stable power all the way from full to empty, then suddenly stops working?

  9. Lascaille says:

    The battery indicator works by [interrogating some hardware which] measures the battery output voltage before it reaches the 'voltage stabilizer' part of the power supply circuitry.

    LI batteries discharge quite consistently: fully charged you get a known high voltage per cell (3.7 to 4.2V depending on the type of battery), fully discharged you get a known low voltage per cell (3V ish). The 'discharge curve' is relatively flat – i.e if the measured output voltage is 50% of the way between 4.2V and 3V then the battery is 50% discharged, the same for 45%, 40%, etc.

    It is possible to discharge 'dumb' LI batteries beyond the point where they can be recharged; this is why consumer batteries will simply stop giving power beyond a certain point; internal protection circuitry prevents discharge beyond the point of no return.

    From the consumer's point of view, batteries do give stable power all the way from full to empty; then they suddenly stop working.

  10. Marc K says:

    I can think of many meetings when I sat down with an estimate of 2 hours of battery life remaining only to have the machine hibernate after an hour.  

    configurator: Put your machine into standby before you unplug it to move it to a new room.  It'll be much quicker to resume than hibernate.

  11. Lascaille says:

    You start your machine, it idles. You check the battery life remaining gauge – it says 2 hours. You close the gauge and then open your apps and start working…

    If you kept it open you'd see that the moment you start actually doing things, the battery life remaining estimate drops significantly – it updates about every 20 seconds depending on instantaneous power drain.

    If you really want a 'portable' you have to make sure the manufacturer's battery figures are 4+ hours or it'll just get irritating.

  12. Falcon says:

    I'd expect battery run time to be even more difficult to predict than file copy time.

  13. 640k says:

    I have got file copying times of "2 million minutes" in several different windozes when copying a few files. Have never seen anything remotely close to that on the battery meter.

    Battery meter I don't trust. Wifi reception I don't trust. For manufacturers, there's too much to win by lying about these things, it can't be trusted at all, it's only funny pixels on the screen, not actual conditions of anything.

    Software could of course do a better job. Software could record previous battery drains and compare to the current drain and predict the future from there. If user always use office 08-17 weedays, and always play games 20-22 every saturday, windows could use that information to predict the future much better. But it does not. It is only stupid.

    WMI can't be trusted either. Most of the information are of very low quality, corresponding APIs usually return much more accurate information about anything. The wmi repositories are also very fragile, break very easily.

Comments are closed.