blob: 985b9c0682a5b184406042f5c13953b81f360b90 [file] [log] [blame]
Heidi von Markham4ed95332015-09-02 17:22:40 -07001page.title=Measuring Device Power
2@jd:body
3
4<!--
5 Copyright 2015 The Android Open Source Project
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18-->
19<div id="qv-wrapper">
20 <div id="qv">
21 <h2>In this document</h2>
22 <ol id="auto-toc"></ol>
23 </div>
24</div>
25
26<p>You can determine device power consumption for Android devices that include a battery fuel gauge
27such as a Summit SMB347 or Maxim MAX17050 (available on many Nexus devices). Use the in-system
28gauge when external measurement equipment is not available or is inconvenient to
29connect to a device (such as in mobile usage).</p>
30
31<p>Measurements can include instantaneous current, remaining charge, battery capacity at test start
32and end, and more depending on the supported properties of the device (see below). For best
33results, perform device power measurements during long-running A/B tests that use the same device
34type with the same fuel gauge and same current sense resistor. Ensure the starting battery charge
35is the same for each device to avoid differing fuel gauge behavior at different points in the
36battery discharge curve.</p>
37
38<p>Even with identical test environments, measurements are not guaranteed to be of high absolute
39accuracy. However, most inaccuracies specific to the fuel gauge and sense resistor are consistent
40between test runs, making comparisons between identical devices useful. We recommend running
41multiple tests in different configurations to identify significant differences and relative power
42consumption between configurations.</p>
43
44<h2 id="power-consumption">Reading power consumption</h2>
45
46<p>To read power consumption data, insert calls to the API in your testing code.</p>
47
48<pre>
49import android.os.BatteryManager;
50import android.os.ServiceManager;
51import android.content.Context;
52BatteryManager mBatteryManager =
53(BatteryManager)Context.getSystemService(Context.BATTERY_SERVICE);
54Long energy =
55mBatteryManager.getLongProperty(BatteryManager.BATTERY_PROPERTY_ENERGY_COUNTER);
56Slog.i(TAG, "Remaining energy = " + energy + "nWh");
57</pre>
58
59<h2 id="avail-props">Available properties</h2>
60
61<p>Android supports the following battery fuel gauge properties:</p>
62
63<pre>
64BATTERY_PROPERTY_CHARGE_COUNTER Remaining battery capacity in microampere-hours
65BATTERY_PROPERTY_CURRENT_NOW Instantaneous battery current in microamperes
66BATTERY_PROPERTY_CURRENT_AVERAGE Average battery current in microamperes
67BATTERY_PROPERTY_CAPACITY Remaining battery capacity as an integer percentage
68BATTERY_PROPERTY_ENERGY_COUNTER Remaining energy in nanowatt-hours
69</pre>
70
71<p>Most properties are read from kernel power_supply subsystem attributes of similar names.
72However, the exact properties, resolution of property values, and update frequency
73available for a specific device depend on:</p>
74
75<ul>
76<li>Fuel gauge hardware, such as a Summit SMB347 or Maxim MAX17050.</li>
77<li>Fuel gauge-to-system connection, such as the value of external current sense resistors.</li>
78<li>Fuel gauge chip software configuration, such as values chosen for average current computation
79intervals in the kernel driver.</li>
80</ul>
81
82<p>For details, see the properties available for <a href="#nexus-devices">Nexus devices</a>.</p>
83
84<h2 id="maxim-fuel">Maxim fuel gauge</h2>
85
86<p>When determining battery state-of-charge over a long period of time, the Maxim fuel gauge
87(MAX17050, BC15) corrects for coulomb-counter offset measurements. For measurements made over a
88short period of time (such as power consumption metering tests), the fuel gauge does not make
89corrections, making the offset the primary source of error when current measurements are too small
90(although no amount of time can eliminate the offset error completely).</p>
91
92<p>For a typical 10mOhm sense resistor design, the offset current should be better than 1.5mA,
93meaning any measurement is +/-1.5mA (PCBoard layout can also affect this variation). For example,
94when measuring a large current (200mA) you can expect the following:</p>
95
96<ul>
97<li>2mA (1% gain error of 200mA due to fuel gauge gain error)</li>
98<li>+2mA (1% gain error of 200mA due to sense resistor error)</li>
99<li>+1.5mA (current sense offset error from fuel gauge)</li>
100</ul>
101
102<p>The total error is 5.5mA (2.75%). Compare this to a medium current (50mA) where the same error
103percentages give a total error of 7% or to a small current (15mA) where +/-1.5mA gives a total
104error of 10%.</p>
105
106<p>For best results, we recommend measuring greater than 20mA. Gain measurement errors are
107systematic and repeatable, enabling you to test a device in multiple modes and get clean relative
108measurements (with exceptions for the 1.5mA offset).</p>
109
110<p>For +/-100uA relative measurements, required measurement time depends on:</p>
111
112<ul>
113<li><b>ADC sampling noise</b>. The MAX17050 with its normal factory configuration produces +/-1.5mA
114sample-to-sample variation due to noise, with each sample delivered at 175.8ms. You can expect a
115rough +/-100uA for a 1 minute test window and a clean 3-sigma noise less than 100uA (or 1-sigma
116noise at 33uA) for a 6 minute test window.</li>
117<li><b>Sample Aliasing because of load variation</b>. Variation exaggerates errors, so for samples
118with variation inherent in the loading, consider using a longer test window.</li>
119</ul>
120
121<h2 id="nexus-devices">Supported Nexus devices</h2>
122
123<h5 id="nexus-5">Nexus 5</h5>
124
125<table>
126<tbody>
127<tr>
128<th>Model</th>
129<td>Nexus 5</td>
130</tr>
131<tr>
132<th>Fuel Gauge</th>
133<td>Maxim MAX17048 fuel gauge (ModelGauge™, no coulomb counter)</td>
134</tr>
135<tr>
136<th>Properties</th>
137<td>BATTERY_PROPERTY_CAPACITY</td>
138</tr>
139<tr>
140<th>Measurements</th>
141<td>The fuel gauge does not support any measurements other than battery State Of Charge to a
142resolution of %/256 (1/256th of a percent of full battery capacity).</td>
143</tr>
144</tbody>
145</table>
146
147
148<h5 id="nexus-6">Nexus 6</h5>
149
150<table>
151<tbody>
152<tr>
153<th>Model</th>
154<td>Nexus 6</td>
155</tr>
156<tr>
157<th>Fuel Gauge</th>
158<td>Maxim MAX17050 fuel gauge (a coulomb counter with Maxim ModelGauge adjustments), and a 10mohm
159current sense resistor.</td>
160</tr>
161<tr>
162<th>Properties</th>
163<td>BATTERY_PROPERTY_CAPACITY<br>
164BATTERY_PROPERTY_CURRENT_NOW<br>
165BATTERY_PROPERTY_CURRENT_AVERAGE<br>
166BATTERY_PROPERTY_CHARGE_COUNTER<br>
167BATTERY_PROPERTY_ENERGY_COUNTER</td>
168</tr>
169<tr>
170<th>Measurements</th>
171<td>CURRENT_NOW resolution 156.25uA, update period is 175.8ms.<br>
172CURRENT_AVERAGE resolution 156.25uA, update period configurable 0.7s - 6.4h, default 11.25 secs.<br>
173CHARGE_COUNTER (accumulated current, non-extended precision) resolution is 500uAh (raw coulomb
174counter read, not adjusted by fuel gauge for coulomb counter offset, plus inputs from the ModelGauge
175m3 algorithm including empty compensation).<br>
176CHARGE_COUNTER_EXT (extended precision in kernel) resolution 8nAh.<br>
177ENERGY_COUNTER is CHARGE_COUNTER_EXT at nominal voltage of 3.7V.</td>
178</tr>
179</tbody>
180</table>
181
182
183<h5 id="nexus-9">Nexus 9</h5>
184
185<table>
186<tbody>
187<tr>
188<th>Model</th>
189<td>Nexus 9</td>
190</tr>
191<tr>
192<th>Fuel Gauge</th>
193<td>Maxim MAX17050 fuel gauge (a coulomb counter with Maxim ModelGauge adjustments), and a 10mohm
194current sense resistor.</td>
195</tr>
196<tr>
197<th>Properties</th>
198<td>BATTERY_PROPERTY_CAPACITY<br>
199BATTERY_PROPERTY_CURRENT_NOW<br>
200BATTERY_PROPERTY_CURRENT_AVERAGE<br>
201BATTERY_PROPERTY_CHARGE_COUNTER<br>
202BATTERY_PROPERTY_ENERGY_COUNTER</td>
203</tr>
204<tr>
205<th>Measurements</th>
206<td>CURRENT_NOW resolution 156.25uA, update period is 175.8ms.<br>
207CURRENT_AVERAGE resolution 156.25uA, update period configurable 0.7s - 6.4h, default 11.25 secs.<br>
208CHARGE_COUNTER (accumulated current, non-extended precision) resolution is 500uAh.<br>
209CHARGE_COUNTER_EXT (extended precision in kernel) resolution 8nAh.<br>
210ENERGY_COUNTER is CHARGE_COUNTER_EXT at nominal voltage of 3.7V.<br>
211Accumulated current update period 175.8ms.<br>
212ADC sampled at 175ms quantization with a 4ms sample period. Can adjust duty cycle.</td>
213</tr>
214</tbody>
215</table>
216
217
218<h5 id="nexus-10">Nexus 10</h5>
219
220<table>
221<tbody>
222<tr>
223<th>Model</th>
224<td>Nexus 10</td>
225</tr>
226<tr>
227<th>Fuel Gauge</th>
228<td>Dallas Semiconductor DS2784 fuel gauge (a coulomb counter), with a 10mohm current sense
229resistor.</td>
230</tr>
231<tr>
232<th>Properties</th>
233<td>BATTERY_PROPERTY_CAPACITY<br>
234BATTERY_PROPERTY_CURRENT_NOW<br>
235BATTERY_PROPERTY_CURRENT_AVERAGE<br>
236BATTERY_PROPERTY_CHARGE_COUNTER<br>
237BATTERY_PROPERTY_ENERGY_COUNTER</td>
238</tr>
239<tr>
240<th>Measurements</th>
241<td>Current measurement (instantaneous and average) resolution is 156.3uA.<br>
242CURRENT_NOW instantaneous current update period is 3.5 seconds.<br>
243CURRENT_AVERAGE update period is 28 seconds (not configurable).<br>
244CHARGE_COUNTER (accumulated current, non-extended precision) resolution is 625uAh.<br>
245CHARGE_COUNTER_EXT (extended precision in kernel) resolution is 144nAh.<br>
246ENERGY_COUNTER is CHARGE_COUNTER_EXT at nominal voltage of 3.7V.<br>
247Update period for all is 3.5 seconds.</td>
248</tr>
249</tbody>
250</table>