blob: 985b9c0682a5b184406042f5c13953b81f360b90 [file] [log] [blame]
page.title=Measuring Device Power
@jd:body
<!--
Copyright 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<div id="qv-wrapper">
<div id="qv">
<h2>In this document</h2>
<ol id="auto-toc"></ol>
</div>
</div>
<p>You can determine device power consumption for Android devices that include a battery fuel gauge
such as a Summit SMB347 or Maxim MAX17050 (available on many Nexus devices). Use the in-system
gauge when external measurement equipment is not available or is inconvenient to
connect to a device (such as in mobile usage).</p>
<p>Measurements can include instantaneous current, remaining charge, battery capacity at test start
and end, and more depending on the supported properties of the device (see below). For best
results, perform device power measurements during long-running A/B tests that use the same device
type with the same fuel gauge and same current sense resistor. Ensure the starting battery charge
is the same for each device to avoid differing fuel gauge behavior at different points in the
battery discharge curve.</p>
<p>Even with identical test environments, measurements are not guaranteed to be of high absolute
accuracy. However, most inaccuracies specific to the fuel gauge and sense resistor are consistent
between test runs, making comparisons between identical devices useful. We recommend running
multiple tests in different configurations to identify significant differences and relative power
consumption between configurations.</p>
<h2 id="power-consumption">Reading power consumption</h2>
<p>To read power consumption data, insert calls to the API in your testing code.</p>
<pre>
import android.os.BatteryManager;
import android.os.ServiceManager;
import android.content.Context;
BatteryManager mBatteryManager =
(BatteryManager)Context.getSystemService(Context.BATTERY_SERVICE);
Long energy =
mBatteryManager.getLongProperty(BatteryManager.BATTERY_PROPERTY_ENERGY_COUNTER);
Slog.i(TAG, "Remaining energy = " + energy + "nWh");
</pre>
<h2 id="avail-props">Available properties</h2>
<p>Android supports the following battery fuel gauge properties:</p>
<pre>
BATTERY_PROPERTY_CHARGE_COUNTER Remaining battery capacity in microampere-hours
BATTERY_PROPERTY_CURRENT_NOW Instantaneous battery current in microamperes
BATTERY_PROPERTY_CURRENT_AVERAGE Average battery current in microamperes
BATTERY_PROPERTY_CAPACITY Remaining battery capacity as an integer percentage
BATTERY_PROPERTY_ENERGY_COUNTER Remaining energy in nanowatt-hours
</pre>
<p>Most properties are read from kernel power_supply subsystem attributes of similar names.
However, the exact properties, resolution of property values, and update frequency
available for a specific device depend on:</p>
<ul>
<li>Fuel gauge hardware, such as a Summit SMB347 or Maxim MAX17050.</li>
<li>Fuel gauge-to-system connection, such as the value of external current sense resistors.</li>
<li>Fuel gauge chip software configuration, such as values chosen for average current computation
intervals in the kernel driver.</li>
</ul>
<p>For details, see the properties available for <a href="#nexus-devices">Nexus devices</a>.</p>
<h2 id="maxim-fuel">Maxim fuel gauge</h2>
<p>When determining battery state-of-charge over a long period of time, the Maxim fuel gauge
(MAX17050, BC15) corrects for coulomb-counter offset measurements. For measurements made over a
short period of time (such as power consumption metering tests), the fuel gauge does not make
corrections, making the offset the primary source of error when current measurements are too small
(although no amount of time can eliminate the offset error completely).</p>
<p>For a typical 10mOhm sense resistor design, the offset current should be better than 1.5mA,
meaning any measurement is +/-1.5mA (PCBoard layout can also affect this variation). For example,
when measuring a large current (200mA) you can expect the following:</p>
<ul>
<li>2mA (1% gain error of 200mA due to fuel gauge gain error)</li>
<li>+2mA (1% gain error of 200mA due to sense resistor error)</li>
<li>+1.5mA (current sense offset error from fuel gauge)</li>
</ul>
<p>The total error is 5.5mA (2.75%). Compare this to a medium current (50mA) where the same error
percentages give a total error of 7% or to a small current (15mA) where +/-1.5mA gives a total
error of 10%.</p>
<p>For best results, we recommend measuring greater than 20mA. Gain measurement errors are
systematic and repeatable, enabling you to test a device in multiple modes and get clean relative
measurements (with exceptions for the 1.5mA offset).</p>
<p>For +/-100uA relative measurements, required measurement time depends on:</p>
<ul>
<li><b>ADC sampling noise</b>. The MAX17050 with its normal factory configuration produces +/-1.5mA
sample-to-sample variation due to noise, with each sample delivered at 175.8ms. You can expect a
rough +/-100uA for a 1 minute test window and a clean 3-sigma noise less than 100uA (or 1-sigma
noise at 33uA) for a 6 minute test window.</li>
<li><b>Sample Aliasing because of load variation</b>. Variation exaggerates errors, so for samples
with variation inherent in the loading, consider using a longer test window.</li>
</ul>
<h2 id="nexus-devices">Supported Nexus devices</h2>
<h5 id="nexus-5">Nexus 5</h5>
<table>
<tbody>
<tr>
<th>Model</th>
<td>Nexus 5</td>
</tr>
<tr>
<th>Fuel Gauge</th>
<td>Maxim MAX17048 fuel gauge (ModelGauge™, no coulomb counter)</td>
</tr>
<tr>
<th>Properties</th>
<td>BATTERY_PROPERTY_CAPACITY</td>
</tr>
<tr>
<th>Measurements</th>
<td>The fuel gauge does not support any measurements other than battery State Of Charge to a
resolution of %/256 (1/256th of a percent of full battery capacity).</td>
</tr>
</tbody>
</table>
<h5 id="nexus-6">Nexus 6</h5>
<table>
<tbody>
<tr>
<th>Model</th>
<td>Nexus 6</td>
</tr>
<tr>
<th>Fuel Gauge</th>
<td>Maxim MAX17050 fuel gauge (a coulomb counter with Maxim ModelGauge adjustments), and a 10mohm
current sense resistor.</td>
</tr>
<tr>
<th>Properties</th>
<td>BATTERY_PROPERTY_CAPACITY<br>
BATTERY_PROPERTY_CURRENT_NOW<br>
BATTERY_PROPERTY_CURRENT_AVERAGE<br>
BATTERY_PROPERTY_CHARGE_COUNTER<br>
BATTERY_PROPERTY_ENERGY_COUNTER</td>
</tr>
<tr>
<th>Measurements</th>
<td>CURRENT_NOW resolution 156.25uA, update period is 175.8ms.<br>
CURRENT_AVERAGE resolution 156.25uA, update period configurable 0.7s - 6.4h, default 11.25 secs.<br>
CHARGE_COUNTER (accumulated current, non-extended precision) resolution is 500uAh (raw coulomb
counter read, not adjusted by fuel gauge for coulomb counter offset, plus inputs from the ModelGauge
m3 algorithm including empty compensation).<br>
CHARGE_COUNTER_EXT (extended precision in kernel) resolution 8nAh.<br>
ENERGY_COUNTER is CHARGE_COUNTER_EXT at nominal voltage of 3.7V.</td>
</tr>
</tbody>
</table>
<h5 id="nexus-9">Nexus 9</h5>
<table>
<tbody>
<tr>
<th>Model</th>
<td>Nexus 9</td>
</tr>
<tr>
<th>Fuel Gauge</th>
<td>Maxim MAX17050 fuel gauge (a coulomb counter with Maxim ModelGauge adjustments), and a 10mohm
current sense resistor.</td>
</tr>
<tr>
<th>Properties</th>
<td>BATTERY_PROPERTY_CAPACITY<br>
BATTERY_PROPERTY_CURRENT_NOW<br>
BATTERY_PROPERTY_CURRENT_AVERAGE<br>
BATTERY_PROPERTY_CHARGE_COUNTER<br>
BATTERY_PROPERTY_ENERGY_COUNTER</td>
</tr>
<tr>
<th>Measurements</th>
<td>CURRENT_NOW resolution 156.25uA, update period is 175.8ms.<br>
CURRENT_AVERAGE resolution 156.25uA, update period configurable 0.7s - 6.4h, default 11.25 secs.<br>
CHARGE_COUNTER (accumulated current, non-extended precision) resolution is 500uAh.<br>
CHARGE_COUNTER_EXT (extended precision in kernel) resolution 8nAh.<br>
ENERGY_COUNTER is CHARGE_COUNTER_EXT at nominal voltage of 3.7V.<br>
Accumulated current update period 175.8ms.<br>
ADC sampled at 175ms quantization with a 4ms sample period. Can adjust duty cycle.</td>
</tr>
</tbody>
</table>
<h5 id="nexus-10">Nexus 10</h5>
<table>
<tbody>
<tr>
<th>Model</th>
<td>Nexus 10</td>
</tr>
<tr>
<th>Fuel Gauge</th>
<td>Dallas Semiconductor DS2784 fuel gauge (a coulomb counter), with a 10mohm current sense
resistor.</td>
</tr>
<tr>
<th>Properties</th>
<td>BATTERY_PROPERTY_CAPACITY<br>
BATTERY_PROPERTY_CURRENT_NOW<br>
BATTERY_PROPERTY_CURRENT_AVERAGE<br>
BATTERY_PROPERTY_CHARGE_COUNTER<br>
BATTERY_PROPERTY_ENERGY_COUNTER</td>
</tr>
<tr>
<th>Measurements</th>
<td>Current measurement (instantaneous and average) resolution is 156.3uA.<br>
CURRENT_NOW instantaneous current update period is 3.5 seconds.<br>
CURRENT_AVERAGE update period is 28 seconds (not configurable).<br>
CHARGE_COUNTER (accumulated current, non-extended precision) resolution is 625uAh.<br>
CHARGE_COUNTER_EXT (extended precision in kernel) resolution is 144nAh.<br>
ENERGY_COUNTER is CHARGE_COUNTER_EXT at nominal voltage of 3.7V.<br>
Update period for all is 3.5 seconds.</td>
</tr>
</tbody>
</table>