Measuring energy consumption#
Once you have a prototype, or your first hardware, measure where you stand. As the first of Akin’s Laws of Spacecraft Design puts it, engineering is done with numbers, and analysis without numbers is only an opinion. The energy budget is an estimate. The measurement tells you whether the design meets it, and which assumptions were wrong.
How instruments measure#
- Voltage
A voltmeter measures voltage directly with amplifiers and an analog-to-digital converter (ADC). This is the easy part.
- Current
Instruments do not count electrons. They measure a side effect of current. Galvanometers and Hall effect sensors measure the magnetic field around a conductor, but they are rarely sensitive enough for sleep currents. A shunt ammeter measures the voltage across a known resistor, the shunt, and computes the current with Ohm’s law. Active circuits, such as transimpedance amplifiers, also convert current to voltage, but they are more complex and can have stability issues.
- Power and energy
An instrument that samples voltage and current at the same time multiplies them to get power, then sums power over time to get energy. Summing current over time gives charge.
What makes current hard to measure#
- Dynamic range
A low-power product may sleep at a few microamps and draw tens of milliamps or more when active, a range of 10,000 to 1 or more. Measuring the sleep current accurately and the active current without clipping, in the same capture, takes an instrument with very wide dynamic range.
- Bandwidth and sample rate
An instrument that samples once per second shows only what changes once per second. To see interrupts and other short events, you need time resolution on the scale of microseconds, which takes a bandwidth of tens to hundreds of kHz. More bandwidth than your circuit can deliver adds nothing; see How much bandwidth you need.
- Burden voltage
A shunt ammeter in series with your product drops some voltage across its shunt and connections, which is called the burden voltage or insertion loss. Too much, and the product’s supply sags when it draws current. The microcontroller can brown out and reset, and the measurement no longer shows how the product behaves.
- Ease of use
A measurement that is hard to make gets made less often, and the product suffers for it.
- Accuracy and precision
As with any measurement, the result must be close to the true value and repeatable.
Measurement options#
- Multimeter
Good for static measurements only, because it reports a value about once per second. Put the product into one mode, measure it, and repeat for each mode. Then combine the values with the time in each mode, as in the energy budget. This is tedious, and it misses everything that happens between readings. Multimeters also often have a high burden voltage on their current ranges: 0.6 V is common, and 0.6 V of drop on a 1.8 V supply will not leave your product working normally.
- Oscilloscope
Good for seeing changes over time. To measure current, insert a shunt resistor in the supply and measure the voltage across it. Be careful: oscilloscope inputs are usually referenced to earth ground for safety, and the shunt usually is not. Connecting a probe ground to either side of the shunt can short your supply to earth. You can measure with two probes and subtract them, but the result has a large offset error. A differential probe or a current probe works, at a cost. You can isolate the setup with a battery-powered oscilloscope, or a battery-powered supply and target. Never defeat the oscilloscope’s earth connection: it is there to protect you. Even then, oscilloscopes have 8 to 12 bits of resolution, which is not enough to measure from microamps to amps. They show the active modes well, and the sleep current poorly.
- Bench multimeters with waveform capture
These combine a high-resolution multimeter with oscilloscope-like capture. They still have the multimeter’s burden voltage, which limits the range you can use without affecting your product, so their usable dynamic range is lower than their digits suggest.
- Source measure units (SMUs)
An SMU is a power supply that measures its own output current, so it has no burden voltage in series with the product. Check its dynamic response: how quickly it holds the voltage when the load current steps.
- Dedicated power analyzers
High-end, dedicated equipment works well, at a high price.
- Joulescope
An autoranging shunt ammeter and voltmeter designed for this measurement. It switches shunt resistors fast enough that your product keeps running through current changes, so it keeps the burden voltage low across a range from nanoamps to amps. It connects to a computer by USB to record and explore waveforms. For the specifications of each instrument, see Products.
How much bandwidth you need#
Your product limits the bandwidth before the instrument does. The supply, the cables and the instrument all have some resistance, and your product has capacitance on its supply input. Together they form a low-pass filter with bandwidth:
With 10 µF of bypass capacitance, a modest value, and 0.1 Ω of supply resistance, the system bandwidth is 160 kHz:
Source resistance |
Bandwidth with 1 µF |
Bandwidth with 10 µF |
|---|---|---|
0.01 Ω |
16 MHz |
1.6 MHz |
0.1 Ω |
1.6 MHz |
160 kHz |
1 Ω |
160 kHz |
16 kHz |
10 Ω |
16 kHz |
1.6 kHz |
100 Ω |
1.6 kHz |
160 Hz |
1000 Ω |
160 Hz |
16 Hz |
So there is no reason to buy 100 MHz of measurement bandwidth for a product with bypass capacitors. Too little bandwidth misses events, though: an instrument with a few hundred hertz of bandwidth will not show interrupts. The Bandwidth page explains how bandwidth changes what a current pulse looks like, and why charge and energy stay accurate at any bandwidth.
Setting up the measurement#
Keep cables short to reduce noise pickup and resistance.
Know your instrument’s burden voltage and bandwidth, and your measurement requirements.
Avoid ground loops. Make sure the setup has a single path to earth ground, or is fully isolated. Debug probes and USB serial adapters connect your product to your computer a second time, which can create other paths for current that bypass the instrument and add noise. See Ground loops and Leakage current.
Reduce noise with twisted pairs, a star ground and a quiet supply; see Noise.
Measure early and often. Every change to the hardware or firmware can change the energy consumption, and the cost of a fix grows with the time between introducing a problem and finding it.
Do not short out the power supply while probing your board.
Turning a capture into a budget#
A long capture of a working product contains the measured version of your energy budget: the sleep current, every wake-up, and how long and how often each one happens. To extract it, see From estimate to measurement.