How to measure average power use over time for small fluctuating circuit? - Page 1
Forum section: electronics / beginners

author: ziplock9000
author_rank: Regular Contributor
timestamp: September 21, 2018, 05:29:42 am
content: I have a microcontroller project that has a few electrically moving parts including lots of sensors and power hungry WIFI modules and such. I want to get an accurate power use profile of the device that I can use to systematically reduce the device's power usage with the aim to hopefully get it working on batteries. To be able to do this, I need to be able to measure how effective each change I make to the device's code and electronics to compare to previous states of the system. This means I need to take a power snapshot of the device over a certain time window that is at least as large as a complete cyclic repetition of its power cycle. (This just happens to be 1 minute at the moment, each time the WIFI triggers)I immediately realised that a DMM is no good for this so I used my DSO in roll mode to measure voltage (and by way of a dodgy 1 ohm current shunt resistor) and current over time. Using the DSO's built in maths function I multiplied the two two give me power over time.Well.. It's not good enough for the following reasons:1) On my DSO (Rigol DS1054) the maths function only works with data shown on-screen. This is not nearly accurate enough on either axis. On the Y axis there's just simply not enough bits of data and the output is quite quantised even when I use as much of the display as possible. The problem is even worse on the X axis (time) as data will fall off the end of the screen if the roll speed is too fast and sub-pixel data will not be registered if it's too slow. There's no good happy compromise between the two either, not without massive errors anyway.2) Even if it did work well, the data is power over time and I really want *average* power over time for a certain time window.. Say 10 minutes, 1 minute, 1 hour, whatever I choose. Currently the repeating cyclical phases is about 1 minute but that might change.How can I proceed with this on a budget?(Just an FYI.. we are talking about current draws that are (very roughly) 0ma, 25ma, 75ma and spikes of 300mA)I've attached an image of my crude attempts with my DSO

author: mtdoc
author_rank: Super Contributor
timestamp: September 21, 2018, 06:56:14 am
content: There are small, inexpensive power monitors that will do this. For example, I own one ofthese PortaPow devicesand it works well.

author: ziplock9000
author_rank: Regular Contributor
timestamp: September 21, 2018, 06:58:40 am
content: Interesting thanks. Do they measure down to a few mA and sample in the milliseconds?Also can you specify the sample window duration?Thanks.

author: mtdoc
author_rank: Super Contributor
timestamp: September 21, 2018, 07:07:26 am
content: Resolution is 1 microamp. I don’t know the sampling rate - but good question. You might need to contactthe manufacturer. They’re in the UK.Sample duration is manual - i.e. time it yourself...

author: ziplock9000
author_rank: Regular Contributor
timestamp: September 21, 2018, 07:12:56 am
content: I've just realised it's a UK company for once, so no huge price hike from a US import for a change, bonus!Yep, I've just sent them an email.1 microamp is more than enough for me, but it's the sample rate that I'm worried about. Most of the example uses are for things like charging phones that don't have spikes etc.Anyway this is a fantastic suggestion, thanks!(UPDATE: The display seems to update once a second.. If that's indicative of the sample rate then it's far too slow :/)

author: mzzj
author_rank: Super Contributor
timestamp: September 21, 2018, 07:30:52 am
content: RC filter with big capacitor can be very helpful in many cases when you need to average something.

author: ziplock9000
author_rank: Regular Contributor
timestamp: September 21, 2018, 07:44:24 am
content: Yeah that might work in the interim thanks.. I'm also toying with an idea of making something Arduino based but I really need something now.

author: ziplock9000
author_rank: Regular Contributor
timestamp: September 21, 2018, 08:28:16 am
content: I found the answer from an mjlorton video. It's 3 samples/sec which is not even close to being fast enough....

author: gamalot
author_rank: Super Contributor
timestamp: September 21, 2018, 08:42:34 am
content: Try your luck on ebay, those used DAQ equipment meets your requirements, I bought a Keithley KUSB-3108 (MCC DT9806 ) and spent only $80.

author: ziplock9000
author_rank: Regular Contributor
timestamp: September 21, 2018, 08:53:45 am
content: Keithley stuff is usually very expensive in the UK and gets snapped up quickly. A bit out of my price range too.But you've got me thinking about cheaper simple data acquisition USB devices. I'm taking a look at them now but don't see a sampling rate in the descriptions

author: maukka
author_rank: Unknown
timestamp: September 21, 2018, 09:00:55 am
content: If you're not in a hurry you could take a battery with a known capacity in Wh and see how long it lasts and calculate from that. If operating voltage is a concern, take into account the efficiency of the regulator.

author: ziplock9000
author_rank: Regular Contributor
timestamp: September 21, 2018, 09:02:50 am
content: Yeah that would work, but I was hoping for something a bit more elegant. It's looking more and more like a new Arduino based project maybe based on TM7705 based Data Acquisition Module. But I'd have to read up more on it.500sps might be good enough:https://www.instructables.com/id/Arduino-16-bit-500SPS-Dual-Channel-DAQ/

author: mzzj
author_rank: Super Contributor
timestamp: September 21, 2018, 10:34:23 am
content: One trick you can use for very low average currents is to use capacitor as a charge integrator. Measure voltage at the start and after 1 minute, calculate current from voltage drop and capacitance.(For best results measure the capacitance)If the capacitor size gets non-practical for higher currents or longer durations you can use Li-ion battery as a charge integrator.Li-ion coulombic efficiency(amh-hours in vs amp-hours out) is very high, for a good quality cell something in the range of 99% to 99,9% (you discharge 1Ah and charge 1.001Ah)Measure the current during charge and charge to exactly same voltage where battery was when you started the discharge and you can get better than 1% accuracy.

author: ogden
author_rank: Super Contributor
timestamp: September 21, 2018, 10:42:28 am
content: Quote from: ziplock9000 on September 21, 2018, 09:02:50 amYou don't need ultrahigh sped sampling in case only thing you want to measure - average power. The trick is - additional bulk capacitor between current shunt and device under test, to smooth current spikes and be able to run lower sampling rate.

author: mikerj
author_rank: Super Contributor
timestamp: September 21, 2018, 02:52:13 pm
content: Another possibility I have used in the past is to power the circuit from a pre-charged capacitor and measure the total voltage drop over a fixed period. More suited to very low power circuits, so the wifi might discount this.

author: mtdoc
author_rank: Super Contributor
timestamp: September 21, 2018, 05:56:57 pm
content: Quote from: ogden on September 21, 2018, 10:42:28 amYes, excellent point. If the OP has a limited budget, that is really likely the only way he will be able to do what he wants.

author: ziplock9000
author_rank: Regular Contributor
timestamp: September 23, 2018, 03:39:14 pm
content: Quote from: mzzj on September 21, 2018, 10:34:23 amWhat size capacitor would you recommend? 90% of the time the device is using ~26-40mA, with spikes up to maybe 400mA. The power cycle repeats itself after 1 minute, but I'd like to get a few repetitions of this if possible to average out over several cycles.Thanks.

author: ogden
author_rank: Super Contributor
timestamp: September 23, 2018, 04:30:53 pm
content: Quote from: ziplock9000 on September 23, 2018, 03:39:14 pmYou shall specify "spike". Ambient temperature spike can last few days

author: ziplock9000
author_rank: Regular Contributor
timestamp: September 23, 2018, 04:34:34 pm
content: DSO screenshot in the OP.I'd need to take further measurements at a higher time base to get accurate figures, but it's in the order of ~1ms

author: ogden
author_rank: Super Contributor
timestamp: September 23, 2018, 04:57:30 pm
content: Quote from: ziplock9000 on September 23, 2018, 04:34:34 pmIt's easy then:Source:https://en.wikipedia.org/wiki/Capacitance

author: mzzj
author_rank: Super Contributor
timestamp: September 23, 2018, 05:10:56 pm
content: Quote from: ziplock9000 on September 23, 2018, 03:39:14 pmBit high current for ordinary electrolytic cap but totally doable with ultracapacitorsLets say that your circuit uses about 50mA average and you want to measure 5 minutes = 60*5*0,05 = 15 Amp-seconds, if you use 15 farad capacitor the voltage would drop 1 volt.1 volt drop is bit exessive unless its battery powered equipment, maybe aim for ~0.3 volt drop if its supposed to run from 5v fixed voltage supply, that would mean 45F ultracapacitor.2x100F ultracapacitors in series would handle 5 volt supply and give you 50F capacitance. Leakage current might need a further look depending on case.Or just filter the crap out of it with enough big electrolytic after the shunt resistor, 1 ohm shunt and 100000uF capacitor will filter the 400mA 1ms peak down to 4mA

author: iMo
author_rank: Super Contributor
timestamp: September 23, 2018, 05:17:16 pm
content: QuoteYou may try with two 600F 2.7V supercaps wired in series. That may give you a few minutes with 2A spikes max, with a drop from 5V to 4.5V. It may cost you $80 however.Doublecheck the calculation, estimate only.

author: ogden
author_rank: Super Contributor
timestamp: September 23, 2018, 05:39:10 pm
content: If we assume that 0.1V drop is tolerable during 1ms spike @0.4A:(0.4Amp * 0.001sec)/0.1Volts = 0.004 farads = 4000 uF. No need for supercapacitor.

author: iMo
author_rank: Super Contributor
timestamp: September 23, 2018, 06:07:37 pm
content: The OP wants to measure over several minutes, afaik. Also, he/she is using a few "electrically moving parts", maybe servos. Therefore 2A peaks are possible..

author: ogden
author_rank: Super Contributor
timestamp: September 23, 2018, 07:07:25 pm
content: Quote from: imo on September 23, 2018, 06:07:37 pmSeveral minutes? What you are talking about? If you need power supply for several minutes - don't use capacitor but power supply!You know - one that is mains powered, ok? Bulk capacitor is needed to store enough energy for high current spike which is specified by OP as 0.4A, to decrease dV/dT - so you can sample current/voltage at lower sample rates.If you wonder what I and OP are talking about here, you are advised to read my post:Quote from: ogden on September 21, 2018, 10:42:28 am

author: mzzj
author_rank: Super Contributor
timestamp: September 23, 2018, 07:36:09 pm
content: Quote from: ogden on September 23, 2018, 05:39:10 pmYou get rid of voltage ripple but still have "somewhat big" peaks on current measurement depending on your shunt resistor value.OP's needs or scope shots are bit open to interpretation but guessing from the scope shot he has 1ms peak every 1 second?4000uF cap with 1ohm shunt would reduce 400mA 1ms peak alone to ~90mA peak over the ~0.4mA average.

author: ziplock9000
author_rank: Regular Contributor
timestamp: September 23, 2018, 08:21:41 pm
content: Quote from: imo on September 23, 2018, 06:07:37 pmThe most demanding part is a WIFI module. As stated earlier, the largest peak is 300-400mA.

author: ogden
author_rank: Super Contributor
timestamp: September 23, 2018, 09:21:19 pm
content: Quote from: ziplock9000 on September 23, 2018, 08:21:41 pmHey, when instead of chatting you will solder capacitor on your device input terminals and actually try something?

author: David Hess
author_rank: Super Contributor
timestamp: September 24, 2018, 12:29:18 pm
content: My better handheld multimeter has a minimum, maximum, and averaging function which can make these measurements over arbitrarily long times. A multimeter with averaging would be perfect for this.

author: ziplock9000
author_rank: Regular Contributor
timestamp: September 24, 2018, 09:08:44 pm
content: I imagine they do this digitally by taking samples as mentioned in my OP. I'm going to make an assumption here that the sample rate is going to be at least 2 order of magnitude too slow for my use (which isn't really that high speed anyway) of around 1 to 10x second whereas I need at least 1ms. For example all of my DMM, bench and mobile are WAAYY off and don't catch the MAX spikes or even the MINS that are much longer in duration.

author: David Hess
author_rank: Super Contributor
timestamp: September 25, 2018, 12:14:56 am
content: Quote from: ziplock9000 on September 24, 2018, 09:08:44 pmThat is not how multimeters work.Except in special cases, the input is *integrated* over a whole number of power line cycles so it is already averaged over some integer multiple of 16.7 (60 Hz) or 20.0 (50 Hz) milliseconds. The reason for this is to produce nulls in the frequency response at the power line frequency and its harmonics which considerably helps normal and common mode rejection of power line interference.Averaging mode if the meter supports it continuously averages these results.But the actual response of the meter before integration extends to kHz or 10s of kHz and can be determined by looking up the AC frequency response. An AC input signal of 60Hz will show 0 when measured in DC mode but a DC pulse will produce the correct average within the AC measurement bandwidth. So for instance a 0 to 10 volt DC pulse with 50% duty cycle at 1kHz will measure 5 volts DC.Measuring minimum or maximum values are limited by the integration time of each sample. Some meters use a faster than normal integration time or include separate peak detection to capture faster events.

author: ziplock9000
author_rank: Regular Contributor
timestamp: September 25, 2018, 12:34:19 am
content: It's a good job I used the phrases "I imagine" and "I assume"...Unfortunately the DMMS I own are way off on MAX and MIN compared to my scope, thus I'd not trust the average either.

author: mtdoc
author_rank: Super Contributor
timestamp: September 25, 2018, 01:24:40 am
content: Quote from: David Hess on September 24, 2018, 12:29:18 pmYou’d need two of such meters, one for voltage and another for current (preferably with low burden voltage) to do this, no?

author: ziplock9000
author_rank: Regular Contributor
timestamp: September 25, 2018, 06:50:40 am
content: The largest cap I have is a 6800uF and it didn't make much difference. I placed it between the shunt and the DUT from the high to low rail. There was minimal smoothing

author: BrianHG
author_rank: Super Contributor
timestamp: September 25, 2018, 07:06:28 am
content: Place your own shunt resistor between your power source and your device under test (DUT).Place a series resistor of 100k and a 100000uf6.3v cap together, parallel across the shunt resistor.Have an optional switchable 1k or 10k resistor in parallel with the 100k to allow fast charging of the 100000uf6.3v cap.Measure the voltage across the 100000uf6.3v cap and calculate your current based on the shunt resistor.You will have a smooth average voltage readout which you can then calculate the current from.It should take around 1-2minutes for the average current to steady out.47000uf 6.3v or 33000uf6.3v cap should also be good.

author: ziplock9000
author_rank: Regular Contributor
timestamp: September 25, 2018, 07:10:35 am
content: That's what I tried to do with a smaller cap. I'll have to order a bigger one. I've got no supercaps that are more than 3v

author: BrianHG
author_rank: Super Contributor
timestamp: September 25, 2018, 07:14:00 am
content: You can use 1megaohm with your 6800uf cap. That should smooth things out, except, you will need to either work out your meter's internal resistance to correct for that huge series resistor, or, disconnect the meter from the cap, and touch the meter on the cap for 1-2 seconds to take a reading every 30 seconds or so.You can also use a voltage follower J-Fet input opamp to get the cap voltage without a DC load.

author: David Hess
author_rank: Super Contributor
timestamp: September 25, 2018, 01:58:30 pm
content: Quote from: ziplock9000 on September 25, 2018, 12:34:19 amThere is a big difference between min/max and average.The input is averaged over the integration time so the min/max returns the minimum or maximum of a bunch of averages which is often useless. But the average returns the average of a bunch of averages which is exactly what you want.Test it yourself using the trigger output of your function generator. My better handheld multimeter returns a 1% error at 40kHz.

author: mzzj
author_rank: Super Contributor
timestamp: September 25, 2018, 03:57:43 pm
content: Quote from: BrianHG on September 25, 2018, 07:14:00 am1 megaohm gets you in trouble with electrolytic capacitors leakage currents. Typical 6800uF cap leakage current could be anything in 5 to 50uA range at half the rated voltage.