Typical method for measuring overall energy usage of low-current circuit? - Page 1
Forum section: electronics / beginners

author: mortrek
author_rank: Contributor
timestamp: March 20, 2020, 03:55:26 pm
content: Is there a typical way that a hobbyist might empirically test the energy usage of a low power circuit (microcontroller in sleep mode that wakes up to do things).Seems to change between ~20-30uA and 3-10mA between sleep and the generally brief awake modes. I can calculate a very rough number, but would like an empirically derived one.I considered a uCurrent or just a high resistance shunt, then hooking it up to a scope, but I cannot seem to find a good source of the uCurrent and any shunt that lets me accurately measure uA-level signals on a Rigol 1054Z's high noise floor will have a massive voltage drop.So would it make sense to measure the wake time/currents using a more reasonable shunt and scope, measure the sleep currents using a good multimeter, and calculate/integrate the data to get an overall picture of energy consumption? Partly empirical and partly theoretical...I considered trying to build something using an uC+ADC+op-amp, etc. but I'm sure I'd run into some limitation that I am not experienced enough to know about yet, like such small numbers that they fall within the error range of the various devices. Also considered something like running the circuit from a large capacitor and calculating the overall consumption based on its discharge rate... if that would work. I guess then you have a dropping voltage... so use a DC-DC converter as well? ugh... so yeah I'm not sure how to do this the "smart" way.Thank you for any advice

author: AVGresponding
author_rank: Super Contributor
timestamp: March 20, 2020, 07:44:38 pm
content: Just use a good quality multimeter.Measure the sleep current, then measure the active current.A scope current probe that'll measure to the same accuracy and precision as a multimeter will cost a small fortune.To use a cap you'd need to measure its capacitance to a high degree of accuracy; you'll need an expensive LCR meter to do that and a good multimeter to measure the voltage as it discharges...

author: mortrek
author_rank: Contributor
timestamp: March 20, 2020, 08:25:09 pm
content: I've done this, but the "on" part is short and I'd need to know the time period it's on and the max current or even the shape if possible... It's usually only a matter of milliseconds every 8 seconds, but sometimes longer if it needs to do something.I know a scope probe won't be terribly accurate, which is why I was thinking a large value shunt to get the shape/reading of the higher current spikes with my scope. My BM869s reads about 3% accurate on the capacitance range I'd be using, and it's pretty accurate for voltage. The final value does not have to be 100% accurate, but preferably more accurate than a simple rough estimate.Do you know if the cap idea is feasible then? I was using a discharge formula where I'd just charge the cap and connect the circuit to it and time how long it takes to go from one voltage to another. I cannot use an electrolytic because they have terrible leakage that amounts to much more current than my circuit, but I was thinking of getting a large polypropylene cap instead. I could always characterize the small amount of leakage and subtract that out of the final calculation...

author: I wanted a rude username
author_rank: Frequent Contributor
timestamp: March 21, 2020, 02:10:57 am
content: The budget option I use is to modify the code to first stay in sleep for say five seconds, then enter its first power consuption state for five seconds, then its second, and so on in an infinite loop. Then it's easy to characterise the power consumption of all the states using just a multimeter.There are devices that sample power over time and give you nice graphs of it. I think STM or TI have one for about USD $50 ... hopefully someone can chime in with the model number.

author: TerminalJack505
author_rank: Super Contributor
timestamp: March 21, 2020, 02:41:20 am
content: Quote from: I wanted a rude username on March 21, 2020, 02:10:57 amTI's MSP-FET programmer/debugger has something they call EnergyTraceTMbut it works only with MSP430s and MSP432s.

author: David Hess
author_rank: Super Contributor
timestamp: March 22, 2020, 03:41:51 am
content: Quote from: mortrek on March 20, 2020, 03:55:26 pm10 milliamps with 20 microamp resolution is only 500 counts. 10 milliamps with 1 microamp resolution is 10,000 counts. Both are well within the dynamic range and accuracy of several types of measurement circuits. Even a transimpedance amplifier (current-to-voltage) followed by a good 12-bit or greater sampling converter could handle it; a lower bandwidth higher resolution DSO should be acceptable here. The more clever way is to build a charge dispensing current-to-frequency converter, and then literally count the number of pulses over the desired measurement period to get a very accurate integrated result; some frequencies counters support this sort of measurement.

author: mortrek
author_rank: Contributor
timestamp: March 22, 2020, 02:17:24 pm
content: A low bandwidth high resolution DSO is probably out of my price range. My Rigol is 8bit, and say the 5MHz 16bit Picoscope is sometimes $1000+.I'll look into the transimpedance amplifier solution combined with a 16bit ADC that I already have (ADS1115). Also the current to frequency converter, like the LM331? The support circuitry for that gets kind of complex, and I'm worried that it'd become a big project, but I will be looking into it as well.Thank you

author: TerminalJack505
author_rank: Super Contributor
timestamp: March 22, 2020, 05:04:53 pm
content: You might look into the various so-called Coulomb counter ICs. Such as the LTC4150, LTC2943, or the DS2761. Adafruit has a breakout board based on the LTC4150.These ICs can give you a good idea about the overall energy usage of a circuit. I don't know how well they will work for real-time energy monitoring--if that is something you need.

author: David Hess
author_rank: Super Contributor
timestamp: March 23, 2020, 11:26:54 pm
content: Quote from: mortrek on March 22, 2020, 02:17:24 pmThe LM331 might do it but I was thinking in terms of a comparator, operational amplifier, and discrete design. Check outLinear Technology application note 14for ideas. And I agree, it would be a lot of design work compared to a bought solution if you can find one.With the proper universal time/counter, some really neat things can be done. For instance the processor can toggle an output to indicate the time period during which current should be measured. That is routed to the arm input of the universal timer/counter which then counts only charge delivered during that period over long durations resulting in a very high resolution and low noise measurement. Some oscilloscopes can make this sort of "gated" measurement also.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: March 24, 2020, 12:11:37 am
content: Let's assume you've got a 12V input, and want to control a 5V uC.Keep it simple: Use a LM317 to get your 5V output.You can put a shunt resistor between the 12V rails and the LM317 to measure the current. The voltage drop over the resistor does not matter much, because the LM317 gives you a steady 5V as long as the input is above 7V or so.On the first attempt keep it simple: a 1 Ohm power resistor, which gives a voltage drop of 1V @ 1A.But you want 2 current ranges, let's assume you also want a current measurement range of 1mA max.So you put a 2nd shunt resistor of 1kOhm in series with the other shunt resistor, for a 0 to 1mA current measurement.This does not work properly of course. Even if you put the full 12V over the 1k Resistor, it will only conduct 12mA.However, if you put a diode parallel to the 1k resistor, then that diode will limit the voltage over the shunt resistor to around 600mV.The diode will conduct little current when it's voltage is below 400mV or 500mV or so (also temperature dependent).Now you can measure currents up to about 500uA over the 1kOhm shunt, and currents of up to around 1A with the voltage over the 1Ohm shunt resistor.But the goal was to have a sensitive range of up to 1mA... Also simple, just put 2 (or even 3) diodes in series to increase the voltage drop before the diodes start conducting current.You can use a DMM to directly measure the voltages over the shunt resistors, or you can extend this in steps. For example you can add current mirrors to the shunt resistors, and a resistor to GND, to make a voltage that is referenced to GND. This can then be easily measured with the ADC of a microcontroller.If you then also add a knob to adjust the output voltage of the LM317 and an adjustable current limit you have a very usable power supply.The biggest advantage of this topology is that you have fairly high voltages over the shunt resistors that are easy to measure with relatively cheap opamps.You will still want to use an opamp with a low offset voltage, but it is much less critical than with the usual very low value shunt resistors. Designing and building this will also teach you a lot about analog electronics.

author: mliberty
author_rank: Contributor
timestamp: March 25, 2020, 12:54:36 pm
content: Disclaimer: I am the creator ofJoulescope, an inexpensive and easy to use instrument for just this purpose.I agree with the posters above regarding the traditional, time-consuming way of determining product current consumption. Manually configure your target in each mode, then measure the current consumption of that mode. Be wary of your multimeters burden voltage! You can then determine how much time your device spends in each mode. You can either use an oscilloscope with a shunt resistor to measure the time spent in each mode. If all modes are software controlled, you can also use a few spare GPIO to drive out the mode to a logic analyzer. You can then use this data directly or create a model of how often your device is in each mode. This allows you to compute the current and estimate battery life.Check out this article which has some tips:https://www.testandmeasurementtips.com/how-to-measure-current-and-energy-use-accurately-faq/

author: mortrek
author_rank: Contributor
timestamp: March 27, 2020, 06:38:39 pm
content: If I were developing projects for a living, I'd definitely want something like your Joulescope. However, I cannot justify the $800.The logic analyzer/oscilloscope idea is a good one though. Getting precise timings for the different modes and then combining that with known measurements for each mode is probably going to be the easiest way. It's not perfect, but I've already tried some of the other suggestions and they have their flaws.