Give your battery a thorough checkup

Mar 13, '03 09:46:00AM

Contributed by: Anonymous

There has recently been discussion in some online forums (Slashdot and Apple) about the Mac OS 10.2.4 upgrade reducing the capacity of some laptop batteries. Some have thought it might not be a hardware problem, but instead that the system is merely underreporting the battery capacity. And it definitely has not affected everyone, as some people report they are either unaffected or improved by the update.

Because of this, it becomes more important than ever for owners of Apple laptops to monitor their battery's capacity. There are some easy ways to do this. If you want to go the very easy route, there are two applications out there that are of use here: X-Charge and XBattery. X-Charge is freeware, but X-Battery has a modest $15 shareware fee and has a great deal more features.

There is also a Unix script that was written by Matthew Pearson of Sun ESP Software.

[robg adds: Read the rest of the article for the script, along with some selected results and quotes from people who have run it on their portables.]

The script:

#!/bin/bash

[ -x /usr/sbin/ioreg ] && \
    /usr/sbin/ioreg -p IODeviceTree -n "battery" -w 0 | \
    sed -ne '/| *{/,/| *}/ {
        s/^[ |]*//g
   /^[{}]/!p
    }' | \
    awk '/Battery/ {
    gsub("[{}()\"]","", $3)
      gsub(","," ",$3)
  split($3,ct," ")
  # extract flag value and convert to hex
       sub("Flags=","",ct[2])
        str=sprintf("Flags=%d/0x%03x",ct[2],ct[2])
    sub("Flags=[0-9]*",str,$3)
        # get max and current charge levels
   sub(".*=","",ct[4])
   sub(".*=","",ct[5])
   printf("%s [%.1f%%]\n",tolower($3),100*ct[5]/ct[4])
    }'

# EOF

I am not sure if ioreg is installed with the basic Apple installation. I do know that the GUI for that command, IORegistryExplorer, is one of the Developer Tools. Make sure to set the executable bit (chmod +x script_name). This script produces the following output:

voltage=# flags=[hex value] amperage=# capacity=# current=# [##.#%]

The results for "capacity" and "current" are in microamperes per hour (mAh).

For comparative purposes, here are a few people's results from this script, along with their comments about the state of their system.

voltage=11928 flags=4/0x004 amperage=1023 capacity=4192 current=3692 [88.1%]

"FWIW, the output on my 88% charged iBook 800 (12", combo drive, november '02 model, bought in January) ... I can squeeze 5+ hours out of this (just typing text, screen dimmed to the one but darkest setting, CPU speed set to 'automatic'), so the battery is definitely good." [link]

voltage=16670 flags=5/0x005 amperage=1200 capacity=4017 current=3928 [97.8%]

"A friend of mine who has a newer machine."

voltage=16564 flags=5/0x005 amperage=1200 capacity=2942 current=2931 [99.6%]

"My TiBook 500 ... i have no idea what it was doing before the updates, but i leave it plugged in 24/7." [link]

voltage=10943 flags=4/0x004 amperage=983 capacity=1814 current=1570 [86.5%]

"I own a 500 MHz iBook and over the last few months my battery has precipitously dropped from 3 hours/charge to as low as 45 minutes a charge."

voltage=12236 flags=5/0x005 amperage=1200 capacity=219 current=214 [97.7%]

"My battery is very sick." [link]

My own results are:

voltage=16666 flags=5/0x005 amperage=1200 capacity=3544 current=3538 [99.8%]

Like the first individual, I can turn my brightness down to the lowest possible setting and still get about five hours' worth of battery use from my system. But God knows, I'm going to be very closely monitoring my battery capacity, and the 'Battery Capacity' graph in XBattery will prove to be very helpful in this regard.

So, the question remains: how do you compare your end result to what your battery should be, fresh from the factory? Just check it against this Knowledge Base entry. Using this, for example, I can tell that a fresh battery for my 14.1" iBook would be at 3.9 Ah, and thus my 3.544 Ah battery still has 91% of its original capacity. Of course, I'm not 100% sure of this, given that the 12" iBook owner above claims to have a capacity of 4.192 Ah, when the article says that said battery has a 3.9 Ah maximum.

ADDENDUM: The Knowledge Base article cited above may not be accurate for determining your battery's original, brand new capacity. When your voltage is multiplied by your capacity, does it match up with what the Apple Store advertises as your particular battery's watt-hour capacity?

iBook (12.1") - 42 watt-hours
iBook (14.1") - 56 watt-hours

PowerBook (12.1") - 47 watt-hours
PowerBook (15.2") - 61 watt-hours
PowerBook (17") - 55 watt-hours

Look at magitekkn's comments below for further exploration and analysis.

[robg adds: This works as expected, and is a very nice tool! It's now a permanent fixture on our iBook G3/500...]

Comments (66)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030311220217671