Author Topic: Low power counter  (Read 8874 times)

yoopee

  • NewMember
  • *
  • Posts: 10
Low power counter
« on: August 10, 2016, 04:54:58 PM »
hi to all,
I want to use moteino as a low power pulse counter. Do you think there is some counter running during the deep sleep mode, so I can count pulses on some pin?

Thanks

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Low power counter
« Reply #1 on: August 10, 2016, 08:08:11 PM »
It depends, what is the pulse counter generator? And how much power does that use?
Basically you can wake your Moteino on hardware interrupts (HIGH/LOW pulses) then add the pulses and send packets once every N pulses or something similar.
But for instance if you have an optical sensor that generates the pulses which uses a few mA then it's not that low power anymore.
To achieve low power you have to be well in the sub mA range. Like 1-50uA is a good number to get decent life from a small battery.

yoopee

  • NewMember
  • *
  • Posts: 10
Re: Low power counter
« Reply #2 on: August 11, 2016, 07:56:26 AM »
thanks for reply, Felix!

As a counter I meant simple counter, for ex. if I will change state on digital pin from 1 to 0, this will increase counter value +1. It is easy to do it when MCU is not in sleep mode. But if I want to count pulses (for ex. from gas meter, which has reed relay) in low power and then send it off, it seems impossible to do it with one MCU only.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Low power counter
« Reply #3 on: August 11, 2016, 08:03:56 AM »
It's not impossible, you just have to ensure that your power budget is according to your expectations and that your pulse generator is either external (it's own power) or if internal it is put to sleep (unless it uses very little power).
Something has to wake the MCU from sleep, that will be the pulse from your source. Then the MCU will recognize that and increase your counters, then take any action and go back to sleep, repeat etc.
I have a PulseMeter example for RFM69. This does just that, except it's a more complex scenario where the MCU computes gallons per minute and other metrics, and sends them periodically to the base even when there is no pulse activity. You could implement something similar for your scenario.
FWIW if this is next to a power meter I would expect there to be a power source there and not have to worry much about the node being ultra low power. Is that not the case?

yoopee

  • NewMember
  • *
  • Posts: 10
Re: Low power counter
« Reply #4 on: August 11, 2016, 08:23:50 AM »
hmmm...good idea with waking up the mcu with external pulse. But I am afraid this can be used only for "few-pulses-for-a-day" cases only if I want my node as low power and battery powered. For ex. if there will be 10 pulses to a minute, the node will drain too much.
So maybe some cmos counter  IC can be a good solution?

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Low power counter
« Reply #5 on: August 11, 2016, 11:54:30 AM »
hmmm...good idea with waking up the mcu with external pulse. But I am afraid this can be used only for "few-pulses-for-a-day" cases only if I want my node as low power and battery powered. For ex. if there will be 10 pulses to a minute, the node will drain too much.
So maybe some cmos counter  IC can be a good solution?
If you manage the hardware properly, you can easily handle 10 pulses per minute without substantial power drain.  The trick is to have all other hardware powered off, use the MCU as a counter and immediately go back to sleep after each pulse.

Example:
Assume 7uA MCU sleeping, 8mA when woken to count the pulse, time awake=1mS, interval between pulses=6seconds, your average current will be 8.3333 uA if this condition was continuous 24/7.  Note that the 'awake' average power is only 1.3333uA in this case.  At 8.3333uA continuous drain, a pair of AAA batteries would give you about 17 years of life if Murphy didn't throw other problems at you (like corrosion, etc).

Now, obviously you'll want to send this information at some point, but if you keep that duty cycle low (once every ten minutes, once every hour, etc) then your device will still last years on a couple of batteries.

Tom
PS:  You can use LPL's nifty neat new timer breakout to power up the radio and any other devices you need on a periodic basis for reporting the data.  It can also wake the MCU, and, with this wake up, the MCU initializes the radio, sends the report, and turns it back off and goes to sleep.
« Last Edit: August 11, 2016, 11:59:18 AM by TomWS »

yoopee

  • NewMember
  • *
  • Posts: 10
Re: Low power counter
« Reply #6 on: August 12, 2016, 05:07:27 PM »
Quote
Assume 7uA MCU sleeping, 8mA when woken to count the pulse, time awake=1mS, interval between pulses=6seconds, your average current will be 8.3333 uA if this condition was continuous 24/7.  Note that the 'awake' average power is only 1.3333uA in this case.  At 8.3333uA continuous drain, a pair of AAA batteries would give you about 17 years of life if Murphy didn't throw other problems at you (like corrosion, etc).

this sounds pretty low power! I will do some tests on weekend...

Do you have any tips how to measure low currents in time? I'm trying to use the oscilloscope, measuring voltage drop on the shunt resistor, but results are not the best. There is so much interference on the waveform...
The second possibility I was thinking of was using low capacity li-po battery and measure the time how long it will stay charged.

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Low power counter
« Reply #7 on: August 12, 2016, 06:41:57 PM »
Quote
Assume 7uA MCU sleeping, 8mA when woken to count the pulse, time awake=1mS, interval between pulses=6seconds, your average current will be 8.3333 uA if this condition was continuous 24/7.  Note that the 'awake' average power is only 1.3333uA in this case.  At 8.3333uA continuous drain, a pair of AAA batteries would give you about 17 years of life if Murphy didn't throw other problems at you (like corrosion, etc).

this sounds pretty low power! I will do some tests on weekend...

Do you have any tips how to measure low currents in time? I'm trying to use the oscilloscope, measuring voltage drop on the shunt resistor, but results are not the best. There is so much interference on the waveform...
The second possibility I was thinking of was using low capacity li-po battery and measure the time how long it will stay charged.
If you're looking to measure current in the high uA to mA range then get an INA169 breakout board.  This is very useful for seeing the current peaks and their duration on an oscilloscope.  I haven't found anything that has a 3-4 decade dynamic range for time varying loads.  The uGold current amplifier is very good for giving you at least 7 decades of DC current measurement range.

Tom


yoopee

  • NewMember
  • *
  • Posts: 10
Re: Low power counter
« Reply #8 on: August 13, 2016, 05:02:23 AM »
Quote
...has a 3-4 decade dynamic range for time varying loads.

Does it means that measured current range will be between 0.001-0.0001A? So the uGold is much better? They seems out of stock everywhere, so I will probably build one.

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Low power counter
« Reply #9 on: August 13, 2016, 07:46:14 AM »
Quote
...has a 3-4 decade dynamic range for time varying loads.

Does it means that measured current range will be between 0.001-0.0001A? So the uGold is much better? They seems out of stock everywhere, so I will probably build one.
With an INA169 sensor, you can accurately measure 100:1 current range (after that it's too noisy IMO).  The range that is being measured is set by a monitor resistor that you can easily change from 1K to 100K giving you another 100:1 variation, although you need to switch the resistor in the process.  The benefit is that the monitor point is ground referenced so this is ideal for a scope, hence time varying loads.  I wouldn't try to measure anything less than 10uA with the INA169 but this is typically not necessary for time varying loads.

uCurrent Gold probably has 1000:1 range on any switch setting and each switch setting is 1000:1 range separation (1mV/nA, 1mV/uA, 1mV/mA) but the output is floating so you need to measure the voltage difference between two pins and is ideal for a multimeter.  You can buy the uCurrent Gold directly from Australia (they'll ship to US for a nominal fee).  This is what I did and it arrived within a week.

I use both methods.  Hope this helps.

Tom

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
Re: Low power counter
« Reply #10 on: August 14, 2016, 10:26:58 AM »
Tom et al,

I am curious if anyone has any good data on just how long it takes and how much power is consumed to power the 328P up after its power supply has been totally cut using the TPL5110.  The data sheet seems to just list the unhelpful worst case scenario time and current but I'm curious what actual real-world numbers look like.  I don't have a scope or the knowledge to use one, so I have to rely on those of you with electrical engineering backgrounds/equipment/leanings.

yoopee

  • NewMember
  • *
  • Posts: 10
Re: Low power counter
« Reply #11 on: August 15, 2016, 04:56:07 AM »
Quote
With an INA169 sensor, you can accurately measure 100:1 current range (after that it's too noisy IMO).

thanks, I will order one and try it with my oscilloscope.

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Low power counter
« Reply #12 on: August 15, 2016, 08:08:51 AM »
Tom et al,

I am curious if anyone has any good data on just how long it takes and how much power is consumed to power the 328P up after its power supply has been totally cut using the TPL5110.  The data sheet seems to just list the unhelpful worst case scenario time and current but I'm curious what actual real-world numbers look like.  I don't have a scope or the knowledge to use one, so I have to rely on those of you with electrical engineering backgrounds/equipment/leanings.
I don't have that data handy, but, you are correct that this would be a meaningful part of the information needed with this type of setup.  The startup time would depend on any startup/warmup time required by any sensors you're using, but a good baseline would be a generic Moteino/Flash/RFM69 combo.  Unfortunately, I'm currently heads down on a project and probably won't be able to gather this for a couple of weeks. 

Tom

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
Re: Low power counter
« Reply #13 on: August 15, 2016, 08:36:52 AM »
No worries Tom.  No rush at all on my part, just an idle curiosity that no amount of Googling seems to be able to answer which is perplexing given the popularity of battery powered 328P-based projects.  Any useful information you can eventually provide is most appreciated.

Kindest regards,
Chris

yoopee

  • NewMember
  • *
  • Posts: 10
Re: Low power counter
« Reply #14 on: August 22, 2016, 06:24:50 AM »
Quote
The range that is being measured is set by a monitor resistor that you can easily change from 1K to 100K giving you another 100:1 variation, although you need to switch the resistor in the process.

So, I've ordered INA169 from Adafruit. What were you thinking with the "monitor resistor"? There are two resistors on the board, the shunt, which is 0.1ohm and the load resistor, which is 10kohm.