# Measuring total energy used by a project

Is there a cheap/simple way I can empirically measure the total energy used by my project over a sample time of several minutes?

It's a microcontroller based system which repeatedly wakes up, does some work then sleeps. Typically it will be awake for < 10ms. Looking at the voltage drop across a 1Ω shunt resistor with an oscilloscope, I've measured the energy consumption of each work period by calculating the area under the curve. Using an ammeter I've found the quiescent current during sleep.

In theory, knowing the sleep period I could calculate an energy estimate. But, I'd like to test the system as a black-box without making assumptions about the firmware.

Is there a device or method for accurately measuring the total energy usage of a device over a long period? (preferably something cheap).

-
Power meters used by electric companies? You could install one before the plug of the device and read the consumptions. Still, there has to be a cheaper and simpler solution that that. –  AndrejaKo Jun 1 '11 at 10:35
My project is going to draw very small amounts of power. Each wake period is measured in micro coulombs. My house power meter works in kWH. –  Toby Jaffey Jun 1 '11 at 10:38
Well you said it yourself. Coulombs. Why not take a look at something like this maybe? –  AndrejaKo Jun 1 '11 at 10:43

Charge up a cap to a known voltage. Then power this circuit from the cap for whatever time period. When done, measure the voltage left in the cap. Change the size of the cap to whatever is appropriate for the power draw and length of the test. Here's the formula:

$Amps = Farads * \frac{(V_{start} - V_{End})}{Seconds}$

The result, amps, will be the average amps for the duration of the test. Remember that the cap is measured in Farads, so don't use microfarads instead.

The cap voltage drop during the test should be fairly small, maybe 0.1 or 0.2 volts. Any larger and you get other weird effects influencing your measurements.

And another note: Most caps have terrible tolerances on their capacity. Calibrate first using a 1% or 0.1% resistor load instead of your micro-controller circuit. Try to have your V_Start and V_End approximately close to what you'd have for the real test to maximize accuracy. Oh, if you can avoid it, don't leave your multimeter attached for the duration of the test, only for measuring the start and end voltages.

That's the best thing I could think of for measuring very low power stuff over seconds or minutes. If properly calibrated it should also be quite accurate.

-
capacitors also have leakage current; most of them specify it as X ohms in parallel with the capacitor where X >= min(X0, T0/C) so that they specify a minimum resistance and a minimum time constant. The minimum time constants tend to be in the neighborhood of 1000 seconds, so you're OK with seconds or maybe a minute or two, but any longer than that and you've got problems. (This obviously gets worse if you have leakage on circuit board traces) –  Jason S Jun 3 '11 at 12:59
@Jason S I didn't get into leakage, but depending on the cap and the duration of the test it could be a factor. But, you can calibrate/compensate for it. If you're careful enough you could almost eliminate it as an issue for a test duration of many minutes. As for leakage on the circuit board traces, I would classify that as "energy used by the PCB" and is fair game to measure along with the rest of the circuit. –  user3624 Jun 3 '11 at 14:32

I've come across this issue before. My best way around the problem was to build an RC filter to smooth out the input current. Something such as the circuit shown in the figure below.

Of course, acceptable values of R and C need to be chosen and you may find that you need to use a few large capacitors in parallel for C. With this filtering circuit in place you can use a regular DMM with an average function (used where the ammeter is shown in the circuit above) to measure the DUT's average current. If you tried to connect the DMM in series with the DUT without the filter then the burden voltage from the shunt resistor in the DMM would cause the DUT to fail when it switched from sleep mode into active mode. With this filter, the capacitor can supply the excess current needed when the device is switched into active mode and then slowly charge back up while the DUT is asleep.

The graph below shows the idea very roughly. The red trace represents the devices true current draw while the green trace represents the filtered current draw. Because the filtered current draw is more slowly-changing, the DMM's average function will be able to estimate it much more accurately. Also, the DMMs burden voltage becomes a non-issue.

The capacitor will of course have some leakage current, it's worth trying to characterize this if you want to know the average current very accurately. This term can usually be safely ignored however because any leakage current will only increase the measured average draw. ie. the 'real' draw must be higher than this so you're not going to overestimate the device's deployment time.

-

I've done this with a small resistor in series with the circuit and then, like you, using the area under the curve to find the total energy used. We used an oscilloscope to capture the modes of operation and just added it all up from there.

To confirm our initial oscilloscope work I then rigged up a NI DAQ and some LabVIEW software to continuously measure the energy used for 10 full periods of operation. The low power sleep of the PIC caused an issue as the 1MΩ inputs on the DAQ loaded it so I buffered the DAQ with a 200TΩ input impedance electrometer (Keithley 6514A) to stop this from happening.

To be honest, although the data was accurate it was not that much different from making a couple of assumptions about the sleep mode current draw and then using the scope method.

If you want the best of both you could use the scope method to measure the operating current and then see if you can get access to a source meter for the sleep mode current draw, again there will be some assumptions but nothing to drastic.

-