olpc-logbat is a bash script that logs various parameters of the battery subsystem. It must be run from the "Terminal Activity".
At a Terminal Activity command prompt, enter
Every 10 seconds you will see a line printed to the screen that looks similar to the following:
1199878696,93,6464170,-895442,2796,6993,Discharging,Full 1199878706,93,6464170,-899739,2798,6987,Discharging,Full 1199878716,92,6462340,-899479,2797,6981,Discharging,Normal 1199878726,92,6464780,-898828,2798,6975,Discharging,Normal
If you are charging a battery then the output will look similar to:
1200047276,17,6905200,1585286,2730,1651,Charging,Normal 1200047286,17,6907030,1583072,2734,1662,Charging,Normal 1200047296,17,6908860,1586458,2743,1673,Charging,Normal 1200047306,17,6910080,1586067,2752,1683,Charging,Normal 1200047316,18,6911910,1584635,2760,1694,Charging,Normal 1200047326,18,6914350,1586458,2769,1705,Charging,Normal 1200047337,18,6913740,1581770,2772,1715,Charging,Normal
In addition to writing these values to the screen olpc-logbat writes the data to a file. Every time you run olpc-logbat it creates a file in the current directory (normally /home/olpc) that looks like 'bat-<nickname>-<date>-<time of day hhmmss>.csv'. If you have spaces or special characters in your nickname then olpc-logbat does not handle them well and creates files with only parts of then name. A newer version of olpc-logbat will use the XO's hostname rather than the nickname.
The legend for the values is:
<Timestamp>,<SOC>,<Voltage>,<Current>,<Bat Temp>,<ACR>,<Status>,<Overall Level>
- POSIX time stamp of number of seconds since Jan 1, 1970
- State of Charge. A % number between 0 and 100% indicating how charged your battery is. This number is normally between 7% and 97%. Due to variations from battery to battery its difficult to get an exact measurement down to 1%. Therefor low is anything less than 15% and full is anything greater than 93%.
- Battery voltage in microVolts ( x 10E-6 ) The resolution does not really go down to microVolts but its easier not to do floating point math in the kernel driver. The above example shows a voltage of 6.90 and 6.91 volts.
- Signed number indicating the current into or out of the battery. Value in microAmps. The above charging example shows a charge current into the battery of 1.58 amps. The discharging example shows a draw current out of the battery of .895 to .899 amps or 895 to 899 milliAmps.
- Battery Temp
- Temperature of the battery in 100's of degree Centigrade. The above example is 27.3 to 27.7 degrees C. The battery can have quite a bit of rise above ambient temperature during charge and discharge. In a normal 25 degree room its not uncommon to see values up in to the 30 C range.
- Accumulated Current Register (ACR)
- ACR is a 16-bit 2's complement value that counts up or down depending on the amount of charge into or out of the battery. The value is in units of the counter inside the battery but it can be converted to milliAmpHours (mAh) by multiplying by .4167. A single value does not tell you much but the difference between any 2 readings gives you the net charge during that period. The above charging example delivered 26.6 mAh into the battery. (1715-1651)*.4167
- "Charging", "Not Charging", or "Discharging". "Not Charging" occurs when the battery is full but you are on external power.
- Overall Level
- "Low", "Normal" , or "Full". A basic indicator of where your charge level is.
 Common Diagnostic Usage
When requested to run olpc-logbat in response to a battery problem its normally so the developer can see whats going on with the battery during the charge/discharge cycle. The most common instructions will be to run a the Terminal Activity start olpc-logbat and then let the XO run until it abruptly shuts off due to the critical low battery voltage cutoff. Then remove the battery, power up the XO on an external power adapter, start olpc-logbat again and re-insert the battery. When the battery status light turns green or the olpc-logbat level says "Full" unplug the XO from external power and let it run down again until it shuts off. This will create 2 log files in the active directory when olpc-logbat was run (normally /home/olpc). Copy these files to a USB disk and email them to the requesting party.
 Other uses
 Dynamic Power Measurement
olpc-logbat is proving useful to measure the dynamic power usage and battery life of the XO while on battery power. This information is helping olpc-developers improve the power management system of the XO in the ongoing effort to extend the battery life as far as possible. Starting with the Update.1 release the XO will try to suspend when it senses that the system is not in interactive use by the user. To help collect useful power profile information while using the laptop on battery do the following:
- Upgrade your OS build to Update.1 or the latest Joyride build. Depending on release status you may need a Developer_Key to do this.
- Before using the XO run the Terminal Activity and start olpc-logbat
- Use the XO as you would normally. olpc-logbat will periodically take readings while in the background. When the XO is running it will be every 10 seconds when the XO is suspended so is olpc-logbat but once it resumes olpc-logbat will take a reading and the ACR difference indicates how much power was used since the last reading.
- When the battery gets low you can stop olpc-logbat by pressing Ctrl-C in the terminal activity and then recharge the laptop. For the power profiling all OLPC needs is the discharge info.
- email that information to richard at laptop dot org
 Solar Measurement
olpc-logbat is also being used to measure the effectiveness of the individual solar panels. email richard at laptop dot org for details.