Use Warp 10 for tests and qualification of "compatible" laptop batteries.
At SenX, we work with a few Macbooks, and with DELL XPS 15 9560 computers. With 32GB of RAM you can easily upgrade, and i7 kabylake CPU, these are still very good computers for developers. But these computers have a now well-known problem: the infamous swollen battery.
The LiPo batteries fill up with gas bubbles, and the swollen battery push up the touchpad, slowly destroying it.
The problem is that it is nearly impossible to get these 6GPTY batteries from DELL easily. Nothing on their online store, no answer from ser_spares_parts@dell.com. So… We're left with "compatible batteries" we can find on Amazon or specialized resellers. Why not. But how do you test them before placing an order for all the computers of the company? You can do it with Warp 10 of course!
Battery monitoring
On Linux, battery information is just files like any other one. In /sys/class/power_supply/BAT0/
, you can cat voltage_now for example, to read the battery voltage in microvolts.
To qualify a battery, you need to record continuously the following files:
- voltage_now: the voltage
- current_now: the current
- charge_now: the estimated remaining capacity
- charge_full: the estimated full capacity.
Your system computes and display 100.0 * charge_now / charge_full.
Follow the Warp 10 getting started to deploy Warp 10 locally on your computer, then come back here to setup the battery monitoring.
In the /opt/warp10/calls
directory, create a shell script called batteryInfo.sh
, with this content:
#!/bin/sh
# Warpscript:
#
"x" "batteryInfo.sh" CALL
" " SPLIT "data" STORE
# Output the maximum number of instances of this "callable" to spawn (in case of concurrent calls)
# The absolute maximum is set in the configuration file via "warpscript.call.maxcapacity"
echo 5
# Loop, reading stdin, doing our stuff and outputing a line of data to stdout
while true
do read anything
# ignore input VOLTAGE=$(cat /sys/class/power_supply/BAT0/voltage_now)
CURRENT=$(cat /sys/class/power_supply/BAT0/current_now)
CH_NOW=$(cat /sys/class/power_supply/BAT0/charge_now)
CH_FULL=$(cat /sys/class/power_supply/BAT0/charge_full)
echo "${VOLTAGE} ${CURRENT} ${CH_NOW} ${CH_FULL}"
done
Now, use the Warp 10 scheduler to record the data every 10 seconds: create /opt/warp10/warpscripts/battery/10000/battery_monitor.mc2
:
NOW 't' STORE
'x' 'batteryInfo.sh' CALL ' ' SPLIT 'data' STORE // split the line into a list of string
[
NEWGTS 'xps.bat.voltage' RENAME
{ 'unit' 'V' } RELABEL
$t NaN NaN NaN $data 0 GET TODOUBLE 1e6 / ADDVALUE
NEWGTS 'xps.bat.current' RENAME
{ 'unit' 'A' } RELABEL
$t NaN NaN NaN $data 1 GET TODOUBLE 1e6 / ADDVALUE
NEWGTS 'xps.bat.charge' RENAME
{ 'unit' 'mAh' } RELABEL $t NaN NaN NaN $data 2 GET TODOUBLE 1e3 / ADDVALUE
NEWGTS 'xps.bat.charge_full' RENAME
{ 'unit' 'mAh' } RELABEL $t NaN NaN NaN $data 3 GET TODOUBLE 1e3 / ADDVALUE
]
'DataLakeW' UPDATE // replace with your own write token
Cycling Batteries
The qualification process is simple. You need to remove auto-sleep or auto-off in your OS options and let the computer die… Then charge it to full charge, and repeat.
charge_full is theoretically 8500mAh.
charge_now is computed by the battery controller: Once the battery is detected as fully charged, charge_now is initialized to charge_full. As soon as the discharge begins, the battery controller integrates current_now, and charge_now decreases slowly.
With a brand-new battery, the gauge displayed by the OS should be exact.
But if the battery was stored for 4 years (in unknown conditions), it will suffer. Even the "DELL genuine/original/believeUsItIsNotCounterfeit" batteries may have been stored for years. What happened is that charge_full is far from 8500mAh. If charge_full is 4000mAh, your computer will die showing 50% battery remaining…
But every battery will lose capacity while you use them. So, the battery controller is designed to gently recalibrate itself every charge cycle. It means that if it detects the battery is dying while the charge_now is still at 2000mAh, charge_full must re-calibrated. This re-calibration is a slow process, and an engineer at DELL choose a 250mAh recalibration step, hard-coded somewhere in the controller.
So, if your new battery capacity is around 7500mAh instead of 8500mAh, you need at least 4 full discharge cycles in order for the controller to re-calibrate itself.
Tip: do battery cycling during the night. You really cannot trust the battery indicator.
Grafana dashboard
For a quick dashboard, install Grafana on your computer. You can follow this guide to install Warp 10 data source.
Then, create simple dashboards:
The most important one is the one that will display charge_full and charge_now. The WarpScript is just two FETCH:
The battery level can be computed with charge_full and charge_now. As data is aligned by design, you don't even need to BUCKETIZE, just keep it simple and do math with your GTS:
To enhance the lisibility of on/off status of the computer, hide the line and display dots only:
Load tests
Bad batteries not only have less capacity but also have a bigger series resistor. It means some energy will be burned inside the battery. This energy cannot be counted by the battery controller… So, you need to do discharge tests at low and high loads.
- Little or no system load: current_now is around 2A
- High system load: current_now is around 6A.
To load your system, simply compile an infinite loop:
echo "int main(void){while(1)continue;}" | gcc -x c -o infiniteLoop -
Then, run ./infiniteLoop &
8 times to make sure to saturate your CPU!
Test results
Test of "compatible" batteries
The first measure with a multimeter, right after mounting the battery in the laptop gives me 9V. This is clearly a deep discharge state. Not a real surprise, these batteries were stored for years.
- The computer die, still believing there is between 20% and 50%
- It dies at 20% remaining after normal use
- It dies at 50% remaining at heavy load
- Despite the cycles, the battery controller just re-calibrate once!
Look closely at this high load discharge:
- During the discharge, the battery controller measures 4000mAh taken from the battery
- During the charge, the battery controller measures 5500mAh put in the battery
Conclusion: This battery has a huge internal resistor. Maybe the cells were not so bad at the beginning, but the storage killed them. Moreover, the wires were too long to fit correctly.
After two different suppliers of compatible batteries, my conclusion is that it is better to work with my 4000mAh swollen battery that is able to compute battery level correctly. So, I dig again with DELL, spending hours on phone to wait for the good service… And I was able to get DELL original batteries.
Test of DELL batteries
When I mount the DELL battery in my laptop, the first measure of battery with a multimeter was 10.2V. This is also a deep discharge, but storage conditions may have been better.
The first cycles, at low system load, show the charge_full is incorrect. The computer dies at 20% battery. But it gets better and better after only five cycles!
Indeed, charge_full recalibrates after each cycle, which is great and really different from the compatible batteries tested before! After just 5 cycles, the percent gauge of the laptop was working as expected.
The 6th cycle is interesting. Not only the charge_now is correct, but if you look closely at the charge curve, you see the 3 cycles of high-performance charge:
- The first part of the cycle: charge at 7A. An empty battery accepts this.
- Then, charge at 3.5A.
- For the remaining 20% left, decrease current until fully charged, following a current/voltage law
Conclusion
- This monitoring gave me enough proof to send back one of the compatible batteries to the supplier.
- Don't forget to ask for a return policy before.
- This is a very basic usage of Warp 10, there is no analytics, just basic DataViz.
- Be brave, spend hours on the phone with DELL until you get a quotation. For information, we bought them from DELL at €95. A correct price for a still good XPS laptop.
- Finally, I now have a 7200mAh battery instead of a 4000mAh swollen battery that was raising up the touchpad.
Read more
Connecting Tableau and Warp 10
InfluxDB: Keep it simple (reloaded)
WarpStudio v2: What's new in our Web IDE?
Electronics engineer, fond of computer science, embedded solution developer.