How to: power consumption of intermittent, spikey projects

Go To Last Post
60 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Seriously, how do y'all work out power consumption of interrmittent, spikey projects? I generally use one of two methods:

a) Measure the running current by disabling the sleep, measure the sleep by disabling the run, doing the math(s) according to the real run/sleep ratio.

b) Use my PC scope to record the voltage across a shunt, then using the RMS(IIRC) function.

 

Neither of these are ideal. Is there some specialist IC or circuit that does this sort of thing? Some sort of fast integrator or similar?

 

 

Four legs good, two legs bad, three legs stable.

Last Edited: Wed. Dec 6, 2017 - 11:49 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

John_A_Brown wrote:
Seriously, how do y'all work out power consumption of interrmittent, spikey projects?

That's a very good question which deserves splitting-out to General Electronics for a proper discussion ...

 

EDIT

 

Now split; it was originally here: https://www.avrfreaks.net/comment...

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. Dec 6, 2017 - 11:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

John_A_Brown wrote:

Seriously, how do y'all work out power consumption of interrmittent, spikey projects?

 

You buy a starter kit with on-board energy monitor and use it to monitor an off-board device...

 

https://www.silabs.com/community...

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Brian Fairchild wrote:

John_A_Brown wrote:

Seriously, how do y'all work out power consumption of interrmittent, spikey projects?

 

You buy a starter kit with on-board energy monitor and use it to monitor an off-board device...

 

https://www.silabs.com/community...

Which appears to be doing pretty much the same thing as my PC scope method, but with a slower sampling rate, unless you know otherwise.

 

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As Brian says, many dev boards now include power measuring facilities.

 

I also tend to use the scope-and-shunt method - although I find that a current-sense amplifier is useful to get a cleaner signal for the scope.

 

This came from a thread about Dave Jones - he has a little unit:

 

µCurrent GOLD

https://www.eevblog.com/projects...

 

If you have £50k to spend, you could get one of these:

DC Power Analyzer Image

https://www.keysight.com/en/pc-1...

 

I don't have that sort of money, but have worked for a client who had one - it really is the Proper Way to do this!!

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I wrote:
many dev boards now include power measuring facilities

and it's not just the dev boards - they often include support in their IDE.

 

Keil is jumping on the bandwagon: http://www2.keil.com/mdk5/ulink/...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

what is your spike?

is it just in <run> or <sleep> or are there other levels?

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here's a fairly typical one:

 

That's a LoRa node

 

 

This one is GSM:

 

It's not simple!

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have the Dave Jones current sense, thanks.

It's integrating the power consumption that interests me. I can't help feeling there's some analog way of doing it, but go ogling(as my smartphone writes it) says no.

 

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I upload the data from the scope (as CSV), and do it in Excel, or a Python script; eg,

 

 

This is the kind of thing that the tools I mentioned earlier do for you ...

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

  I can't help feeling there's some analog way of doing it

For a fast way to get an idea of the power use I have used a big capacitor as a battery, and then see how long it takes for the voltage drop from let's say 5V to 4.5. And then scale it up. (make sure that the cap. can give the power for the high spikes).  

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Edison once asked one of his engineers to provide him with the volume of one of his light bulb envelopes, after watching him wrestle with the calculations of the odd shaped bulb for several minutes, Edison grabbed the bulb, filled it with water, then poured the water into a beaker and read the volume from the scale.....

 

Perhaps you could use one of the coulomb counting ic's and have it measure the current consumed over a fixed time interval.....

 

https://learn.sparkfun.com/tutor...

 

Jim

 

 

 

Keys to wealth:

Invest for cash flow, not capital gains!

Wealth is attracted, not chased! 

Income is proportional to how many you serve!

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes,  I've toyed with that as an idea - must try it some day!

 

But it doesn't help in analysing the power "profile" to see where it's going - and, thus, where to focus optimisation ...

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

Yes,  I've toyed with that as an idea - must try it some day!

Yea, me too! So much to do, so little time!

 

awneil wrote:

But it doesn't help in analysing the power "profile" to see where it's going - and, thus, where to focus optimisation ...

Your correct, I wasnot thinking of optimization of functions (not sure what I was thinking!)

Time for more caffeine!

 

Jim

 

 

 

Keys to wealth:

Invest for cash flow, not capital gains!

Wealth is attracted, not chased! 

Income is proportional to how many you serve!

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wow, I like that Keysight instrument!

 

John, your two methods sound fine, but obviously each has trade offs.

You ought, I think, check the sampling rate on your O'scope's RMS function to see if it is sampling fast enough to catch the spikes your system generates.

If it is sampling too slowing and you miss a large portion of the spikes, then your reading will be in error on the low side, meaning you will over-estimate your battery life, (generally not a good thing).

 

The "problem" with the other method, of course, is evident when looking at the sample LoRa and GSM graphs.

You have to be able to accurately estimate the duty cycle for the various sub-systems.

 

Another option, with its own inaccuracies, is to build your own Keysight instrument with a couple of op-amps, (cost $5 vs $50K, with performance to match!).

Use the micro-current amplifier to feed an op-amp circuit set up as a voltage integrator.

The output voltage is then proportional to the current drawn, (and directly calculateable, although one would more likely just calibrate it for compensate for real world conditions).

 

Note that in practice you would need a good op-amp, rail-to-rail, with a bi-polar supply for good linear operation near the 0 V input range, and an op-amp with a very low input offset voltage spec.

The higher the signal from your current amp, the less the small errors in the op-amp matter.

 

One would usually use a micro to set the "gate interval", the "on time" during which the instrument is measuring the current flow, and then using an I/O pin to turn on an NFet to short out the cap to zero the system and start the next measurement interval.

 

An Atmel Butterfly, (micro, display, joystick, etc.); a breadboard, and a couple of op-amps and you're golden!

 

JC

 

Edit: Typo

 

Last Edited: Wed. Dec 6, 2017 - 04:11 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:

Wow, I like that Keysight instrument!

 

John, your two methods sound fine, but obviously each has trade offs.

You ought, I think, check the sampling rate on your O'scope's RMS function to see if it is sampling fast enough to catch the spikes your system generates.

If it is sampling too slowing and you miss a large portion of the spikes, then your reading will be in error on the low side, meaning you will over-estimate your battery life, (generally not a good thing).

 

The "problem" with the other method, of course, is evident when looking at the sample LoRa and GSM graphs.

You have to be able to accurately estimate the duty cycle for the various sub-systems.

 

Another option, with its own inaccuracies, is to build your own Keysight instrument with a couple of op-amps, (cost $5 vs $50K, with performance to match!).

Use the micro-current amplifier to feed an op-amp circuit set up as a voltage integrator.

The output voltage is then proportional to the current drawn, (and directly calculateable, although one would more likely just calibrate it for compensate for real world conditions).

 

Note that in practice you would need a good op-amp, rail-to-rail, with a bi-polar supply for good linear operation near the 0 V input range, and an op-amp with a very low input offset voltage spec.

The higher the signal from your current amp, the less the small errors in the op-amp matter.

 

One would usually use a micro to set the "gate interval", the "on time" during which the instrument is measuring the current flow, and then using an I/O pin to turn on an NFet to short out the cap to zero the system and start the next measurement interval.

 

An Atmel Butterfly, (micro, display, joystick, etc.); a breadboard, and a couple of op-amps and you're golden!

 

JC

 

Edit: Typo

 

I'm fairly sure the sampling rate is not high enough, but, as always, there is a trade-off. If I set the sampling rate to be high, the period over which I can monitor gets shorter.

I was thinking of an op-amp as integrator. What put me off was not being able to find any examples of such for this purpose on the web. That led me to believe the idea was flawed.

Maybe I'll do a bit of research.

 

 

@Jim, I looked at the coulomb counter. The device itself seems to take more current than the sort of device I'm wanting to test. I skimmed the datasheet in vain to look for a clue as to the sensitivity, i.e. the lowest current that would register. I usually find I need to factor in sub microamp currents.

 

 

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In addition to the Silabs kit that was already mentioned, Nordic Semi also has an inexpensive Power Profiler Kit. It is intended to support development with their Bluetooth chips, so the sampling rate is high enough for such spiky consumption. IIRC it has three shunt resistors and a fast enough 'auto-scaling' to cover a <1uA - ~50mA range.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just read your comment in the other thread about an 'accumulated power mode'. I'm using the Nordic PPK for this kind of battery life estimation.

 

The kit sends the measured values to a PC over USB, where a Nordic-provided display application makes a graph out of it. You can get short term averages directly from the display app, but for longer times the amount of data gets too large quickly.

The app is written in python and source is available, so I modified it to log accumulated power. I can now leave a device running for hours in some typical use case, and get an average power figure. I intended to add a histogram as well to verify sleep/awake ratios, but I haven't gotten round to doing that yet.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mrono wrote:
 Nordic Semi also has an inexpensive Power Profiler Kit.

Power Profiler Kit

https://www.nordicsemi.com/eng/Products/Power-Profiler-Kit

 

They've also been working with Sony Mobile Research and Incubation to turn it into a standalone instrument:

https://devzone.nordicsemi.com/blogs/1058/new-power-optimization-tool-called-otii-that-runs-/

https://www.qoitech.com/

 

and there's the Atmel Power Debugger:

http://www.atmel.com/tools/atpow...

 

That started off as part of the SAM L21 XPlained-Pro:

Atmel SAM L21 Xplained-Pro board

Xplained Pro Analog Module (XAM)

They gave me one to try a couple of years ago.

Sadly (but not untypically) they hadn't got the support for it at that point:

http://blog.antronics.co.uk/2015/04/23/new-tricks-for-lower-power-from-atmel/

 

 

There's Bay Libre's ACME:

http://baylibre.com/acme/

Although I also have doubts about the sampling rate of that for this kind of application.

The software was rather disappointing.

 

EDIT

 

ST have recently announced the X-NUCLEO-LPM01A  - STM32 Power shield, Nucleo expansion board for power consumption measurement:

http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/stm32-nucleo-expansion-boards/x-nucleo-lpm01a.html

I don't know how tied-in that is to jut ST products ...

 

 

#PowerMeasurement

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Thu. Dec 7, 2017 - 08:58 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think I might have a go at marrying up my Dave Jones uCurrent sense(that I have) with an LTC4150 coulomb counter. Looking at the datasheet, I can't see why this wouldn't work. Maybe I'll order one of the Sparkfun clones. I'm not sure how easy it will be to disconnect the Vdd from the current sense(which I think will be necessary). Depends on the PCB layout.

 

Actually, looks like it may be nigh impossible, I think the track is directly under the chip. Maybe I'll find a 10 pin MSOP breakout PCB instead.

Four legs good, two legs bad, three legs stable.

Last Edited: Thu. Dec 7, 2017 - 08:38 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Current controlled oscillator. Count the cycles

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
Current controlled oscillator. Count the cycles

 

Isn't that pretty much what the coulomb counters do? Maybe you could enlarge on that idea?

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Probably. The ‘obvious’ method is to sample at a reasonable rate using an adc - but there’s the issue of dynamic range etc. Using a current controlled oscillator, hopefully the dynamic range is better than the average adc and you just count clocks which is dead easy on a micro. You might be able to use a 555!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
there’s the issue of dynamic range etc.

Indeed there is.

 

Using a current controlled oscillator, hopefully the dynamic range is better than the average adc and you just count clocks

It would have to be a pretty fast oscillator in order to get a reasonable number of cycles to count during the brief current pulses typical of stuff like BT ...

 

And it would have to be able to change frequency very fast.

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
Current controlled oscillator. Count the cycles

 

Interesting idea.

 

TI have an app note, AN-240, which has a number of circuits built around an LM331 V-F chip. FS is 200uA for one of the circuits shown and goes down to 20pA!

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I wonder what time resolution you really need. Is the battery going to ‘see’ microsecond pulses?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
I wonder what time resolution you really need. Is the battery going to ‘see’ microsecond pulses?

 

I guess it depends a bit on the size of any bulk capacitance.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Kartman wrote:
I wonder what time resolution you really need. Is the battery going to ‘see’ microsecond pulses?

I would have thought so. If not, you've discovered over-unity energy...

 

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Brian Fairchild wrote:

Kartman wrote:
Current controlled oscillator. Count the cycles

 

Interesting idea.

 

TI have an app note, AN-240, which has a number of circuits built around an LM331 V-F chip. FS is 200uA for one of the circuits shown and goes down to 20pA!

Interesting app note.  20pA might be underkill...

 

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

John_A_Brown wrote:

Interesting app note.  20pA might be underkill...

 

Couple one of those with a small AVR, a couple of button and an LCD display and you'd have an interesting useful product.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
 Is the battery going to ‘see’ microsecond pulses?

​Well of course it is - it's all energy consumption, and that energy has to come from the battery!

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Brian Fairchild wrote:
TI have an app note, AN-240

John_A_Brown wrote:
Interesting app note.  

Indeed: http://www.ti.com/lit/an/snoa594b/snoa594b.pdf

 

Only skimmed it, but did note that they make the point of having a high frequency.

 

cool

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
and there's the Atmel Power Debugger:

Power Debugger

Analog Hardware

http://www.microchip.com/webdoc/GUID-EAD481FD-28E6-4CD5-87FB-5165E7687C12/index.html?GUID-F0E592FF-579E-4828-92FA-D5699D9F5F4F

62.5Ksps

An assumption is the samples from the XMEGA128A1U are stored in the UC3A3's attached SDRAM.

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gchapman wrote:
An assumption is the samples from the XMEGA128A1U are stored in the UC3A3's attached SDRAM.

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can anyone explain to me how the circuit in figure 2 on AN-240 works?  I'm guessing the opamp is working as an integrator, as it has that cap in the feedback loop, the diodes on the input clamp the voltage to near zero, and the diode on the output stops it from going negative. But if the inputs are near zero, where does the current for the DUT come from?

 

Excuse my ignorance, analog stuff is black magic to me.

 

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

John_A_Brown wrote:
Can anyone explain to me how the circuit in figure 2 on AN-240 works? 

maybe someone on a TI analogue forum ?

 

you might even find the author over there ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Thu. Dec 7, 2017 - 02:48 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

John_A_Brown wrote:

...where does the current for the DUT come from?

 

I think that it gets it externally from its power supply with the DUT ground lead feeding into the circuit in fig 2.

 

I think the circuit works like this...

 

the incoming current is integrated across Cf. At a certain voltage, fed into the LM331 on pin 7 a comparator will fire and the capacitor will be discharged via pin 1. Rinse and repeat. The frequency at which the discharge happens is proportional to the input current.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, Brian. Makes a bit more sense to me now. Still not sure what part completes the current path to ground, the cap, the diode or the opamp?

 

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

At a quick look, pin 1of the lm331 is the current source. The other hint is the arrow.
Sounds like a good project for someone......

Last Edited: Thu. Dec 7, 2017 - 10:03 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Resurrecting an old thread here, but it's a problem I have recently encountered again with a LoraWan node that idles at tens of uA, but peaks at around 100mA. The Dave Jones uCurrent Gold doesn't have the dynamic range, and the Sparkfun coulomb counter(modified by replacing the sense resistor with a 0.2 to give a maximum current capability of 250mA, instead of the 1A as supplied), does not seem to be very accurate - even using it back-to-front, so that the chip's own current isn't included in the measurement.

So I'm looking at the supercap idea, as alluded to earlier in this thread by sparrow2.

 

I'm looking at using a 4F 5.5V supercap, and charging it to around 4.2V (same as a charged LiPo that it's replacing for the test), and then running the DUT until the cap drops to 3.5V or thereabouts.

I plan on using an ESP8266 module to read the voltage periodically, so that I can post the results to Google sheets.

If I'm using a 5V supply, can I just charge the cap through a resistor, or is there a better way(that doesn't involve to much faff)?

According to my rough measurements I've made so far, my device averages around 125uA worst case, so I estimate around 6 hours run time, which should be enough.

 

Any suggestions or insights gratefully received.

 

 

 

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

John_A_Brown wrote:
a LoraWan node that idles at tens of uA, but peaks at around 100mA.

Now that is a big peak!

 

surprise

 

A similar application here:  https://www.antronics.co.uk/portfolio/lora-eh

 

although, IIRC, the peak was "only" about 30mA

 

But still, getting the dynamic range to view the full current "span" is a challenge.

 

What I tend to do is just characterise the "idle" and "peak" currents separately.

 

I use my Rigol DSO and a Python script for the data capture:

 

  1. Start a sweep (maybe wait for trigger)
  2. Wait for sweep to finish
  3. Upload trace data
  4. rinse & repeat ...

 

 

EDIT

 

and, before the Rigol, I had an old Tektronix TDS200:

 

http://www.antronics.co.uk/downloads/M1306B_Current_Traces.pdf

 

 

EDIT 2

 

Should've re-read all the earlier posts - I think I'm mostly repeating myself here!

 

frown blush

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Tue. Feb 4, 2020 - 10:40 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have always used the same approach, i.e. measure the sleep current, measure the transmit current, do a bit of arithmetic.
This one's a bit busier, though. There's an interrupt at 5S 10mS, 5S 10mS...
An interrupt every 5 minutes.
Plus possible random interrupts from sensors.
The device in question, a Heltec Cubecell, seems to go back to sleep gradually, apparently full sleep is achieved after calling the sleep function 6 times!
All in all, it's a bit more complicated than the sort of low power stuff I'm used to dealing with. Hence the quest for a different approach.
If I had the budget, I'd look at the Otii offerings, but I'm mainly retired and time-rich cash-poor.

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

These are supposedly the bomb:

https://www.kickstarter.com/proj...

 

 

On a recent project, I had to measure consumption of a NB_IoT cellular module - these go from microamps to 100's of milliamps pretty quickly. I used a pac1934 chip from our friends at microchip to measure the data and a little micro (Ardubino) to read the device and output the data via serial to a python script that read the serial stream and put it into a file. Load the data into Excel, draw graph etc. Job Done. The PAC1934 has 15bit current resolution and 16 bit voltage resolution. I could've done with more dynamic range, but it was good enough to give me a better insight with the bits and pieces I had on hand.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

John_A_Brown wrote:
I'm mainly retired and time-rich cash-poor.

Do you have a digital scope that you could use for the data acquisition.

 

Failing that, how about making yourself a data acquisition system - maybe based on a Raspberry Pi or suchlike ?

 

I did try googling once for current sense amplifiers with a logarithmic output - ISTR there was a fair few ideas ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

All interesting, but any insight on charging my supercap?

 

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
These are supposedly the bomb:

https://www.kickstarter.com/proj... 

Looks like that kickstarted has now finished.

 

Now order here:  https://www.joulescope.com/?r=ks - only $800; not clear if they're actually shipping yet, or if that's still just pre-orders ... ?

 

BTW, The Otii is $581 from Digikey:  https://www.digikey.com/product-detail/en/qoitech-ab/OTII-ARC-001/1916-1000-ND/8275323

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

John_A_Brown wrote:
any insight on charging my supercap?

isn't that a separate topic ... ?

 

wink

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A Supercap isn't quite a replacement for a LiPo - internal resistance is quite different, so the Supercap might report your overall runtime a bit low. However, if the supercap in question is something like a Maxwell supercap, then things might be different as these have very low impedance.

 

If you charge your cap with a constant current source, then estimating the amount of charge you put in is a bit easier - linear slope vs exponential curve.

Last Edited: Tue. Feb 4, 2020 - 11:47 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, I have a digital scope. I have used it before But it's a dynamic range problem again. Also, my digital scope won't let me sample at a fast enough speed for several hours.

 

$800, $581... I'm talking £25 solutions here.

 

 

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

John_A_Brown wrote:
my digital scope won't let me sample at a fast enough speed for several hours.

Hence the sweep - save - repeat suggestion.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
Do you have a digital scope that you could use for the data acquisition.
is what Paul operated :

Measuring Microamps & Milliamps at 3 MHz Bandwidth (PJRC)

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In one project we used a supercap as a backup power source in case of a line power loss.

In that project we used a series diode and a current limiting resistor to prevent a full discharged SC from overloading the 5v power supply.  YMMV

the LOP alarm (555 and piezo buzzer) would chirp for many hours.

Jim

 

 

Keys to wealth:

Invest for cash flow, not capital gains!

Wealth is attracted, not chased! 

Income is proportional to how many you serve!

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just thinking out aloud...

 

10uA to 100mA range. So 10,000:1. If we go for 1uA resolution we need 100,000:1 dynamic range and it's around 17 bits; trim that to 65536:1 and we have 16 bits. 16 bit ADCs are in audio territory and can be cheaply had with 48kHz sampling aka 21us.

 

So a current sense resistor strapped across the differential inputs of an audio ADC and we have an output datastream representing our current. Feed that into an AVR and we now have a serial ascii stream of our current. Feed that into Excel via an FTDI chip and you have all the graphing and integration you need.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There's an interrupt at 5S 10mS, 5S 10mS...

Am I reading this  correctly, you have a 10 mSec duration ISR running every 5 Seconds?

 

Does that ISR use the 100+ mA, vs the fractions of a uA in between?

 

With such a huge dynamic range just looking at the duty cycle for the high current operations will likely give you a good lower estimate of the current usage, (battery drain).

(This measurement omits the low current mode usage.)

 

Then, using an over simplification, just add in the current drain for the low power mode as if it was continuous, the entire time, (an overestimate), (i.e. assume no high current mode).

Add that to the high current calculations. and you have a good upper limit of the current usage, (battery drain.).

 

Actually subtracting out the high current usage time from the low current usage time as if it were continuous is likely to be a small number, and besides you are getting upper and lower bounds for the device by using the above technique.

 

Given that you want "hard numbers", and that I've not used the cap method to measure current/power/energy/whatever, a few thoughts still came to mind.

 

You will likely want to hook up your Supercap to a resistor and use your O'scope to measure the RC discharge curve (time). 

The reason to do that is because the 5 F supercap has a wide variation in its actual capacitance.

You can measure your resistor's "exact" resistance, (or use a 1% part, etc.), which is far more accurate that the "5 F" rating.

With a known R, and a nice RC discharge curve, you can calculate the actual capacitance of your cap, (to within the accuracy of the R, V and O'scope measurements).

 

You will, if I understand the overall approach, need that "exact" cap value, to make your energy usage calculations.

 

Your question of how to charge the cap seemed odd.

Am I missing something?

I'd attach it to a power supply with a series resistor.

The series resistor will limit the (essentially a short circuit) inrush current as the cap begins to charge.

How big?

Don't know, I don't have a napkin at hand to do some calc's… (smirk).

Start with a big R and your O'scope  and your power supply.

Who care if it takes 5 minutes to charge the cap, you mentioned a 6 hour discharge interval for your test.

(In rush current = V/R, as one assumes the cap is 0 ohms, so easy to decide how much current you want.)

Then use the RC time constant to estimate how long it will take to charge up to 99.whatever % of the Vsupply voltage.

 

You can use a SPDT manual switch or a relay, to disconnect the power supply and its resistor from the cap, and connect the cap to the device under test.

Flip the switch and start your timer.

 

I can make any project more complex...

So I'd use a micro with a display and have the display show me the time and the voltage on the cap, (and control the relay).

(If the micro has the ADC resolution needed for the Cap voltage measurement then this is trivial, otherwise you need to add an external 12 Bit, 14 bit, 16 bit … ADC)

 

With a few more lines of code the micro can capture and display the time when the cap hit your desired threshold voltage, as well as show real-time (sampled) measurements of the voltage as it decays, and of course show you the initial voltage.)

 

Since it seems that you want some pretty "good" data involving low current (low energy) measurements, you will also want to make a list of errors in the measurement process.

Some that come to mind are the accuracy of:

 

Supercap capacitance measurement

Cap voltage measurements, (initial voltage, trip threshold, etc.)

Cap self discharge rate, (with no load attached)

Energy used by the ADC to make its measurements, (obviously varies with how frequently you take a measurement)

The actual current, baseline and peaks, of the device under test, as a function of the variable Vcc, (as the Supercap discharges)

 

Each one of these factors can be individually accounted for.

For example with this setup you could take some current measurements near the Vcc = 4.whatever, and again at the Vcc = 3.whatever voltage, to see how they compare, and then estimate its impact on your overall measurement accuracy.

Then run the test over the full discharge voltage range, for a longer time and better "averaging" etc.

 

Sounds like a weekend project! wink

 

JC

 

Edit: Typos

Last Edited: Tue. Feb 4, 2020 - 08:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:

There's an interrupt at 5S 10mS, 5S 10mS...

Am I reading this  correctly, you have a 10 mSec duration ISR running every 5 Seconds?

 

I sometimes have an LED that I flash for 10mS every 5 seconds.

 

 

Does that ISR use the 100+ mA, vs the fractions of a uA in between?

No. It uses about 16mA.

 

With such a huge dynamic range just looking at the duty cycle for the high current operations will likely give you a good lower estimate of the current usage, (battery drain).

(This measurement omits the low current mode usage.)

 

Then, using an over simplification, just add in the current drain for the low power mode as if it was continuous, the entire time, (an overestimate), (i.e. assume no high current mode).

Add that to the high current calculations. and you have a good upper limit of the current usage, (battery drain.).

 

Actually subtracting out the high current usage time from the low current usage time as if it were continuous is likely to be a small number, and besides you are getting upper and lower bounds for the device by using the above technique.

 

Given that you want "hard numbers", and that I've not used the cap method to measure current/power/energy/whatever, a few thoughts still came to mind.

 

You will likely want to hook up your Supercap to a resistor and use your O'scope to measure the RC discharge curve (time). 

Planning on doing that.

The reason to do that is because the 5 F supercap has a wide variation in its actual capacitance.

You can measure your resistor's "exact" resistance, (or use a 1% part, etc.), which is far more accurate that the "5 F" rating.

With a known R, and a nice RC discharge curve, you can calculate the actual capacitance of your cap, (to within the accuracy of the R, V and O'scope measurements).

 

You will, if I understand the overall approach, need that "exact" cap value, to make your energy usage calculations.

 

Your question of how to charge the cap seemed odd.

Am I missing something?

I'd attach it to a power supply with a series resistor.

That's what I was planning on doing, seems fairly safe to charge a 5.5V cap from 5V via a resistor. Constant current would likely need a higher voltage to be viable.

The series resistor will limit the (essentially a short circuit) inrush current as the cap begins to charge.

How big?

Don't know, I don't have a napkin at hand to do some calc's… (smirk).

Start with a big R and your O'scope  and your power supply.

Who care if it takes 5 minutes to charge the cap, you mentioned a 6 hour discharge interval for your test.

(In rush current = V/R, as one assumes the cap is 0 ohms, so easy to decide how much current you want.)

Then use the RC time constant to estimate how long it will take to charge up to 99.whatever % of the Vsupply voltage.

 

You can use a SPDT manual switch or a relay, to disconnect the power supply and its resistor from the cap, and connect the cap to the device under test.

Flip the switch and start your timer.

I was planning on using an N FET to switch the charging.

 

I can make any project more complex...

So I'd use a micro with a display and have the display show me the time and the voltage on the cap, (and control the relay).

(If the micro has the ADC resolution needed for the Cap voltage measurement then this is trivial, otherwise you need to add an external 12 Bit, 14 bit, 16 bit … ADC)

 

With a few more lines of code the micro can capture and display the time when the cap hit your desired threshold voltage, as well as show real-time (sampled) measurements of the voltage as it decays, and of course show you the initial voltage.)

 

Since it seems that you want some pretty "good" data involving low current (low energy) measurements, you will also want to make a list of errors in the measurement process.

Some that come to mind are the accuracy of:

 

Supercap capacitance measurement

Cap voltage measurements, (initial voltage, trip threshold, etc.)

Cap self discharge rate, (with no load attached)

Energy used by the ADC to make its measurements, (obviously varies with how frequently you take a measurement)

The actual current, baseline and peaks, of the device under test, as a function of the variable Vcc, (as the Supercap discharges)

 

Each one of these factors can be individually accounted for.

For example with this setup you could take some current measurements near the Vcc = 4.whatever, and again at the Vcc = 3.whatever voltage, to see how they compare, and then estimate its impact on your overall measurement accuracy.

Then run the test over the full discharge voltage range, for a longer time and better "averaging" etc.

 

Sounds like a weekend project! wink

 

JC

 

Edit: Typos

Thanks for the thoughts.

I am really just hoping to validate the readings I made with the coulomb counter. Since this thing is supposed to last for over a year with a 3AH battery, I am just seeking reassurance that my calculations/measurements are in the ballpark. I don't have a year to wait to check this out.

 

 

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Am I reading this  correctly, you have a 10 mSec duration ISR running every 5 Seconds?

 

I sometimes have an LED that I flash for 10mS every 5 seconds.

 

To clarify, the ISR takes very little time(LED off/on, set timer for next IRQ). But once woken, the chip takes some time to go back to sleep.

 

 

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I plan on using an ESP8266 module to read the voltage periodically,

Make sure your voltage dividers, ADC inputs, etc don't add micromps of loading, or it will throw off measuring your actual microamp DUT load profile. 

If your monitoring burden can't be reduced, at least you can account for it in the results.

 

You didn't state exactly what you hope to measure...total joules consumed? Avg current? Peak Current?  

Are you doing this to try to estimate battery life?  Of course, applying an actual battery at some point is always recommended (at least for sanity check).

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

I plan on using an ESP8266 module to read the voltage periodically,

Make sure your voltage dividers, ADC inputs, etc don't add micromps of loading, or it will throw off measuring your actual microamp DUT load profile. 

If your monitoring burden can't be reduced, at least you can account for it in the results.

Yes. Will either account for it, or use another FET switch.

You didn't state exactly what you hope to measure...total joules consumed? Avg current? Peak Current?  

Are you doing this to try to estimate battery life?  Of course, applying an actual battery at some point is always recommended (at least for sanity check).

I have run on a battery(1000mAH) for several days at a time, but this tells me very little, as I'm looking for over a year on 3AH.

 

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 but this tells me very little, as I'm looking for over a year on 3AH.

Be careful, or self-discharge will tell you very much bad news.  For example, NI-MH discharges about 20% per month (if I recall correctly).  Make sure you analyze & account for this factor into any long-term predictions.

 

You can also hook up 10 units together to help speed up testing,taking into account all of the relevant factors (usually reducing current by 10x gives more than a 10x life improvement, neglecting self-discharge).

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The battery will be a primary cell, probably Lithium Thionyl Chloride. I'm not over concerned about self discharge.
Ten units? I have two. The client has the third, and more modules will come from China, which has its own problems right now.

Thanks again for all the suggestions.

Four legs good, two legs bad, three legs stable.