Ultra-low power timer/counter, Attiny4313

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

I've on my second iteration of a motion sensor/temp/[humidity/door sensor] board. This one is based on the Attiny4313 (just because, really). It features a very low power motion sensor, DS18B20 temp sensors, XBee for reporting motion/temp. The XBee runs in timer mode to wake up the MCU to do temp; the motion sensor wakes up the MCU on motion.

I'd like to be able to run on battery power. The motion sensor is very low power (46 uA). The XBee, in sleep mode, is reasonable.

The problem is motion sensing; In the powered version I throttle motion sensing by not reporting every motion report, but throttle back to one every few minutes. But, if I sleep the MCU, I no longer have any timer to tick off time.

The obvious solution is an RTC, but RTC modules, at least domestic ones, are expensive.

Does anyone have any other solution to this? It really needs to run below 100 uA, preferably well below. It could even, in theory, just be a very low power time that runs at, say, 1Hz and kicks the MCU, though start up time, etc. might consumer too much power even at 1Hz, not sure how short a start up time I can program and it work well. Or just some kind of easy-to-read 32-bit counter with very low power 1 kHz clock. etc.

I can't be the first to run into this problem...

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

Quote:

The XBee, in sleep mode, is reasonable.

Is it still low power with the wakeup function enabled?

Quote:

The obvious solution is an RTC, but RTC modules, at least domestic ones, are expensive.


Domestic to what? US? Some are about $1 in moderate quantities.

Quote:

But, if I sleep the MCU, I no longer have any timer to tick off time.


Why not? What is the power consumption of a suitable sleep mode and keeping a timer running off the internal clock? (Hmmm--do you have a crystal for XBee comms?) Are you using a '4313A for lower power consumption? Us common bit-pushers use the watchdog timer to wake periodically from deep sleep.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

theusch wrote:
Quote:

The XBee, in sleep mode, is reasonable.

Is it still low power with the wakeup function enabled?

According to their design guidance, it works well if you are waking up every 10 min or so, which is the planned timing, though it might be too often; you need to run the XBee for 30 sec or so, and it is a power hog. That will need some experimentation. I need a current data logger….

Quote:

Quote:

The obvious solution is an RTC, but RTC modules, at least domestic ones, are expensive.


Domestic to what? US? Some are about $1 in moderate quantities.

Ah, maybe I've been looking at the wrong chips and need to expand my search. The ones I seen from digikey were ~$10. $1, if limited support components were needed, would be tolerable.

Quote:

Quote:

But, if I sleep the MCU, I no longer have any timer to tick off time.


Why not? What is the power consumption of a suitable sleep mode and keeping a timer running off the internal clock? (Hmmm--do you have a crystal for XBee comms?) Are you using a '4313A for lower power consumption? Us common bit-pushers use the watchdog timer to wake periodically from deep sleep.

I'm using the 4313, well, because I'm set up for it and I can. This isn't commercial so just-for-the-hell-of-it flies :)

You nailed it, I'm using a crystal for the comms. The watch dog timer still seems to be a bit of a hog; maybe I should go back and revisit its power usage. And I need to sort out what happens if I shorten the start-up time a lot; do I really need the crystal to full 'stabilize'? The difference in power between like 65ms and 1ms (going from memory here) is quite significant if you are firing every 1s.

Still, really cheap RTC could solve a lot of problems; especially if it had alarm interrupts, I could put the XBee in pin sleep and really drive down the power cost.

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

Quote:

I'm using the 4313, well, because I'm set up for it and I can. This isn't commercial so just-for-the-hell-of-it flies Smile


Sheesh--I'm really getting lousy gas mileage using my dump truck for commuting.

Quote:

The watch dog timer still seems to be a bit of a hog; maybe I should go back and revisit its power usage.

The datasheet might indicate 4uA in power-down mode, IIRC. Hog compared to what?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Digikey has lots of options. The MCP7940 is available for $0.70 in singles, uses an external crystal, caps, and a few resistors, and has alarm capabilities ( or square wave output ). It should do a reasonable job and its operating current is 25uA. Of course, that's only one of many.

Another question might be, do you need a crystal for serial communications. If you had an RTC with a clock output, it might be possible to calibrate the internal RC oscillator using it. Then the startup time could be greatly reduced without risking the processor running with an unstable clock.

Martin Jay McKee

As with most things in engineering, the answer is an unabashed, "It depends."

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

theusch wrote:

Sheesh--I'm really getting lousy gas mileage using my dump truck for commuting.

I wasn't complaining. I'm not sure where the snark is coming from.

Quote:

The datasheet might indicate 4uA in power-down mode, IIRC. Hog compared to what?

That would be without timers running, or the crystal, I think.

Last Edited: Mon. Oct 28, 2013 - 10:43 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mckeemj wrote:
Digikey has lots of options. The MCP7940 is available for $0.70 in singles, uses an external crystal, caps, and a few resistors, and has alarm capabilities ( or square wave output ). It should do a reasonable job and its operating current is 25uA. Of course, that's only one of many.

Another question might be, do you need a crystal for serial communications. If you had an RTC with a clock output, it might be possible to calibrate the internal RC oscillator using it. Then the startup time could be greatly reduced without risking the processor running with an unstable clock.

Thanks for the pointer, that sounds like it might be a good option. The RTC as calibrator is definitely something to pursue I think. In my initial experiments, I got a lot of issues with internal RC @ 1MHz. I switched to crystal, and it improved, but I only really go rid of the framing errors but going to 8MHz. My theory is that the USART timing is poor at 1MHz (clock division issues?). Anyway, I never tried RC @ 8MHz, nor tried calibrating it; it may well be good enough, especially calibrated. Un calibrated I'd worry about manufacturing variance. If not this rev, then almost definitely v3! Off to read some data sheets for cheap RTCs!

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

Quote:

That would be without timers running, or the crystal, I think.


Well, yeah--that's what power-down is.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

I've gotten 4313's down pretty low by sleeping the cpu and having the watchdog interrupt wake it. Takes a couple ma to run one of the other timers, but really low for the WDT.

Annoyingly, on xMega, the WDT can reset, but not interrupt.

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut. 

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

Mr.Paul wrote:
The obvious solution is an RTC, but RTC modules, at least domestic ones, are expensive.

There is no need for external RTC.
Simple use a little bit bigger AVR (ATmega48)
and use it's T2 with a watch crystal connected as internal RTC.
It consume about 1µA.
To use the UART, you can adjust the internal RC oscillator with it.

Peter

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

Mr. Paul,
I'm working on something similar where I need to detect motion every second. I'm using the watchdog timer to save power and it is working great. However, I'm using a PIR from Parallax and it consumes way to much current. Would mind sharing the circuit you are using for the motion detection? I need to detect motion for up to 10 feet and alert my ATTiny. I'm using 3 AA batteries and would like it to last 3-6 months.
Thank you!!

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

I use the Panasonic ones, available at Digikey:

http://www.digikey.com/product-s...

These are pretty easy on current, under ten microamps when there is no motion for some models. Note they come in a large variety of ranges, patterns and voltages.

This can give you a good overview:
http://pewa.panasonic.com/assets...

They are quite nice to use. I built my first board using a parallax (wall wart powered) and it is still running in daily use, but I like using the Panasonics quite a bit more.

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

Mr.Paul wrote:
This one is based on the Attiny4313 (just because, really). ...
Does anyone have any other solution to this? It really needs to run below 100 uA, preferably well below.

Try a slightly more modern part, like ATxmega8E5 ?

That has many oscillators, and many choices of Low power, and burst-calibrate.

Data spec : 0.6μA
RTC from ULP clock, WDT, sampled BOD enabled and 8MHz
internal oscillator in low power mode, T = 25'C

but it also has
8MHz int. oscillator
Normal power mode 65 μA
Low power mode 45 μA

So I think that needs to be added.
Other values are
Internal ULP oscillator 100 nA
32.768kHz int. oscillator 27 μA

The ULP osc has lowest accuracy, but it can be point calibrated from the higher speed ones, or even a crystal.

Should be fine for infrequent 'wake up and check' use.

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

Mr.Paul wrote:
This one is based on the Attiny4313 (just because, really). ...
Does anyone have any other solution to this? It really needs to run below 100 uA, preferably well below.

Try a slightly more modern part, like ATxmega8E5 ?

That has many oscillators, and many choices of Low power, and burst-calibrate.

Data spec : 0.6μA
RTC from ULP clock, WDT, sampled BOD enabled and 8MHz
internal oscillator in low power mode, T = 25'C

but it also has
8MHz int. oscillator
Normal power mode 65 μA
Low power mode 45 μA

So I think that needs to be added.
Other values are
Internal ULP oscillator 100 nA
32.768kHz int. oscillator 27 μA

The ULP osc has lowest accuracy, but it can be point calibrated from the higher speed ones, or even a crystal.

Should be fine for infrequent 'wake up and check' use.

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

Who-me wrote:

Try a slightly more modern part, like ATxmega8E5 ?

That is an interesting part and perhaps down the road I'll try a project with it. In this case, I'm not trying to solve a general problem: if I wanted to do that, I could buy a finished unit off the shelf and save myself a lot of trouble. I've set out some specific and -- interesting to me -- restraints, one of those being using the 4313. Hence why the original question was fairly constrained.

I'm definitely going to consider it down the road, though on first glance it doesn't come in DIP which takes away a lot of prototyping fun (though I am working on making that less of an issue in the long run) and can't run on 5V, which is sometimes pretty handy. The price is pretty awesome for the level of functionality, though, I will say. Once I get set-up for PCB milling, I'll see if it can do that density and consider using it once I am happy I've beat the 4313 into the ground :)

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

Paul,
Fantastic! I just ordered a couple of PIRs from Digikey. Love the different types. Thanks a bunch. I will be setting these up and measuring the consumption. I'm hoping to start my ATTiny or ATMega from the INT0 pin when motion is detected. This should keep everything on low power when there is no activity.
Thanks a bunch!
~Stephane