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