Sleep mode and timers?

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

I'm building a ultra-low powered temperature logger intended to run for months on just 3 AA batteries.

I want it to log the temperature with fairly precise intervals, something like 10 minutes or so. So the internal oscillator is ruled out, at least for driving the timers, the temperature will vary a lot!

So to save battery the µC needs to be in sleep mode 99% of the time, but from what I read in the datasheet I'm a little unsure if I can use the power-saving modes from which the CPU will wake up on timer interrupt!

In the datasheet p. 33 it says "Note: 1. Standby mode is only available with external crystals or resonators." - Nowhere it mentions which of the others (if any) will work with crystal. Looking at the typical characteristics on p. 253 it looks like "idle" mode should work, but I was hoping to get somewhat below 1mA at 2 MHz I'm planning to run it at.

Does anyone have any tips of how to save as much power as possible? Is there another way to keep track of time so I can use the internal oscillator? I've bought a Atmega8L. Also there's going to be a DS1624 temperature sensor, a 24AA64 EEPROM and a MAX3222 on the board, all have very low standby currents in the nA-µA range.

Brian

- Brian

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

lots of differnet ways to save power but it depends how you have or plan to write your software also how accurate your timing needs to be between active states.
In my application I can use powerdown mode 4uA and powersave mode at 46uA > 100uA duing active periods.
I use the wdt to get out of powerdownmode, which allows me to switch off all the timers.

250KHz ext osc, atmega168

--

"If it wasn't for bad luck I'd have no luck at all"

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

I'd like it to stay precise to within one hour or less every month. I'm pretty sure the internal oscillator will vary too much in frequency to get even anywhere near that? The temperture may vary from -10+30 deg C (approx 10-90 deg F)!

Brian

- Brian

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

Timer2 of ATmega48, ATmega88 and ATmega168 can run in asynchronous mode. That means the AVR clock would be the internal oscillator but Timer2 is driven by a 32kHz crystal. In Power Save mode the asynchronous clock is still enabled while the complete circuit consumes only 9µA @ 5V. You can get 32kHz crystals very cheap with a precision of 10ppm. The power consumption would be so low in sleep mode that only the self discharging rate of the batteries would define the lifetime of your circuit.

Regards
Sebastian

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

Date: 2007-MAR-4
Author: 徐斌
MCU: ATMEGA88V
OSC: Internal RC 8MHz:6CK/14CK+65mS,
WTD: Disabled
C complier: IAR owrkbench for AVR 420A
Downloader: 双龙下载器;未联接状态
Device of test: DT-9923B
Power supplier: QJ1502A

FuseBit un-divide(8/8):
Voltage Load Active Idle ADC-Noise PowerDown PowerSave
Status - DINT DINT DINT DINT Enabled_T2
5V None 9.92mA 5.50mA 4.68mA 6.2uA 574uA
3V None 3.84mA 1.78mA 786uA 3.2uA 321uA

FuseBit Divided(1/8):
Voltage Load Active Idle ADC-Noise PowerDown PowerSave
Status - DINT DINT DINT DINT Enabled-T2
5V None 4.53mA 4.29mA 3.61mA 6.2uA 193uA
3V None 855uA 477uA 368uA 3.2uA 125uA

Last Edited: Fri. Mar 9, 2007 - 03:16 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Rather than using the old Mega8 which is based on a low density silicon fabrication process you would be far better advised to look at one of the latest "PicoPower" devices where they use 0.12um fabrication and operate off far less power. You'll also find that the more modern devices offer more options for wake up and things like scalable oscillators so you can only whizz up the CPU speed when really necessary.

(the 168 that Dave mentions is about half way down the history line between old Mega8s and modern PicoPower)

Cliff

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

Oh boy is that spammer suzwht becoming annoying!!

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

sorry.

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

3 AA fresh alkaline is really quite a bit of juice--about 1AH IIRC.

So first I'd measure the draw when the AVR has the A/D alive and is doing its work. Then measure the time it needs to be alive to complete the task. Wake up, yawn & stretch & warm up the A/D, do a few conversions and process, prepeare for bed--maybe a millisecond or so. Actual logging time and write current will depend on your device. So now you know how many mAH/uAH it takes for each reading; how many readings will exhaust your batteries? If you can't reach then you have to start over--more power (3.6V lithium C-size has 8AH), lower consumption during wake, longer interval.

I think that you will find that you will be comfortably inside specs. [I've got a cheap LCD indoor/outdoor thermometer that has run continuously for well over 10 years and I don't even know what kind of battery is inside it.)

Now you need your timekeeping. A straightforward solution is to use an RTC chip with an alarm feature but with battery that adds US$3 to 5 to the project.

You could use the watchdog timer & timer interrupt, and adjust to long-term accuracy by calibrating it and using temperature to skip or add an event now-and-then.

The power draw of one of the timers (depends on AVR model) with a 32kHz crystal, high prescaler, and overflow interrupt may not be to bad.

With the new V & P chips, some with on-board temperature sensing that could be used to adjust oscillators, there are many combinations to choose from.

Lee

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

Sebastian: I have a 32Khz crystal lying around somewhere, so async timer2 sounds like a good idea. I try this!

Cliff: I'm not going to go with another AVR since i allreaddy have the Atmega8L, and it's a lot easier if I can do it without having to order anything! Maybe in a later project! :)

Lee: I don't need the ADC! DS1624 is a temperature sensor with I2C (TWI) bus! For now i will try the 32KHz crystal and see how it performs, I think it will ddo just fine for my needs, thanks.

Brian

- Brian

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

Just stick an old timex watch in there, set the countdown timer for 10 minutes and rewire the beeper output to your uC interrupt. The watch will run for years on it's battery and keep accurate time. Then you only need to wake up once every 10 mins =)

Clancy _________________ Step 1: RTFM Step 2: RTFF (Forums) Step 3: RTFG (Google) Step 4: Post

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

> 3 AA fresh alkaline is really quite a bit of juice--about 1AH IIRC.

1 Ah? Nope. Even AA-sized NiMH get up to 2.6 Ah these days, and the
rule of thumb is that Alkaline always has more capacity than NiMH.

I just googled for "Panasonic Alkaline datasheet", and that e.g. leads
to a document that rates an LR6 battery with 2.87 Ah at 75 Ohms of
load. The shelf life curves show something like at least 75 % of
capacity even after three years. So in order to eat up that remaining
75 % of capacity within these three years, you could draw an average
current of 245 µA. With a power-save current of 8 µA and an active
current of 800 µA (ATmega88 at 4.5 V), this would still allow for an
almost 1:3 active cycle.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

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

clpalmer: I think 32.768 KHz crystal with 10ppm precision should do pretty good! Allthough I will have to wake up for a few CPU clock-cycles every 8 seconds... ;)

Jörg: You are right, at least as long as we are talking rechargables, but I still think something like normal Duracell non rechargables hold at least 2Ah.

Brian

- Brian

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

I'm doing about the same thing with an Atmel Butterfly. I'm using the crystal controlled timer2 and it's working very well. During development, I noticed it was gaining about two seconds a day, so the time of day routine subtracts two seconds every 24 hours.

It's been logging temperatures for the last month while sitting in my car. I just went out there and checked the time of day. It has gained six seconds. That's considerably better than my wrist watch, but I suppose I've been lucky. By the way, the built-in 6 character LCD display and joystick on the Butterfly are very very very handy. All microcontroller development boards ought to have them.

The Butterfly, which has an atmega169p, draws about 2 microamps most of the time. I put the microcontroller in Power-Save sleep. Timer2 wakes it up each second which causes a flicker on my DMM. I don't know the magnitude of the pulse but it can't be much. I think the butterfly with the RTC running will run for several years using the on-board coin cell.

I use the ADC Noise Reduction sleep when doing the ADC conversion. This works very well. The 10 bit reading is as steady as a rock and very repeatable. I suppose I should do some kind of reasonableness check on the result, but I don't, and so far I haven't noticed any spurious results.

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

That's right, I'd forgotten that the Butterfly out-of-the-box is virtually a completed board for the OP's app. Maybe interface an external thermistor or other t sensor if desired.

Lee

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'm using the on-board thermistor, but I don't know how accurate it is. I could calibrate it, and maybe someday I will, but so far I haven't bothered.

The user's guide says its accuracy is ± 1°C from -10°C to 60°C. I want to log more extreme temperatures than that and I really should test it. I did stick it into my freezer and at that temperature is seems to read about 3°C too high.

Powering the Butterfly requires a bit more consideration than with Geronimo's design because apparently the on-board DataFlash can't tolerate more than 3.6 volts.

The ideal may be two Energizer 1.5 volt Lithium AA cells. These actually produce 1.7 volts when new.

Maybe two regular alkalines would be good. Their voltage drops too low with use but maybe they would last a year or two before that happens.

I used a CR123 3 volt lithium which is 2/3 AA size, and requires a cell holder to suit. According to the specs, as I read it, it doesn't have a lot more mah than the on-board coin cell, but at least it would handle the 15 ma pulse better when the DataFlash is written.

I suppose the on-board coin cell might work fine, but that seems way to easy :)

I guess if you really wanted to get serious it might be a good idea to bypass the Schottky diode that Atmel puts in series with the external power connection. There's another one in series with the on-board cell connection. They are no doubt a good idea to keep someone from accidentally charging the internal cell with an external one, or vice versa, as that could get messy. But I figure they drop 0.3 volts when writing to flash, or even when running the USART.

I should also mention that the older Butterfly can also run the RTC for years (or so I understand), and it uses the atmega169, not the new low power version. According to my crude measurements the old one draws 4 times the current in Power-Save sleep, 8 µa, versus 2 µa.

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

This is what I've come up with so far:

Just if anyone's interested, I don't expect anyone to comment it really, but you're welcome to if you want! :)

Brian

- Brian

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

No pullup resistors in SDA and SCL? You may be able to get away with the internal pull ups I guess.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Hey John, I've experimented with the TWI on a breadboard, no-pullups, 10-15cm of wires (2-3 inches), no problems! :)

This is going on a breadboard with less than 5cm of wires, so it should work. But of course I will test to see if it works when assembled. Adding pull-up later on will not be that much trouble on a breadboard.

Brian

- Brian

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

> Jörg: You are right, at least as long as we are talking
> rechargables, but I still think something like normal Duracell non
> rechargables hold at least 2Ah.

My data was for standard Panasonic LR6 ("AA") cells. As you can
easily find in the net, they are spec'ed for 2.87 Ah (at 75 Ohms
load). So yes, "at least" 2 Ah. Of course, you should be aware that
the cutoff voltage of this battery system is 0.9 V per cell, so your
entire circuit ought to work (accurately enough) down to 2.7 V in
order to be powered from three cells.

Btw., the fairly low active current of the ATmega88 came out as quite
a surprise to me. I wouldn't have assumed beforehand that you could
run it 1/3 of the total time in active mode for three years of
operation from 3LR6 power. This means if you are going to maintain an
active time of about 3 % (1/10th of the above), you could get away
with just an CR2032 cell instead (about 1/10th of the capacity of the
3LR6 combo).

p.s.: Rechargeables (at least NiCd/NiMH based) are completely unusable
for the job, due to their way too high self-discharge.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

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

Quote:
no-pullups,
You MUST have some pull ups of some sort somewhere even if you use the processor's internal pull ups resistors of 50K-100K. (about x10 what the "usual" resistors would be)

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

dl8dtl wrote:

p.s.: Rechargeables (at least NiCd/NiMH based) are completely unusable
for the job, due to their way too high self-discharge.

Not necessarily. There are now NiMH with low self discharge. Sanyo, one of the best manufacturers of NiMH, is now selling their eneloop brand. They claim these cells will maintain 85% of their initial capacity after a year, at room temperature. They seem to be excellent cells, and that's all I use now. They have 2000 mah AA cells and 800 mah AAA cells.

I really wanted to use them to power the Butterfly but the voltage was wrong because I use the DataFlash, and that chip is very particular.

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

But well, with their (or Panasonic's, who are IMHO comparable in quality
to Sanyo) LR6 cells, you'd get less self-discharge (75 % retained
capacity after 3 years) at a better price. I think in order to justify
the costs for the NiMH cells, you'd have to operate the device for 10
years or more...

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

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

John of course I'm using internal pullups, can they be disabled at all while using TWI?

I have been using some NiMH batteries I had lying around for testing purposes. I Settled on "Idle" power-down mode, it will give me quite a high power consumption (ca. 0.5mA), but it will enable me to use USART interrupts which makes it easier for me to communicate with the circuit.

0.5 mA should still give me somewhere around 5-6 months of batteri life!

It works! :)

Brian

- Brian

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

Quote:
can they be disabled at all while using TWI?
I believe that the peripherlas attached to TWI will try to interpret a low on the clock or data pins and everything will be in a mess when you try to use the TWI. Why do you want to disable the pullup resistors anyway? No power is being used by them unless a TWI transfer is in progerss.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

John I think you read something I didn't write!
I don't want to disable the pull-ups at all.

It all started when you wrote:

Quote:
You MUST have some pull ups of some sort

As I am using the hardware TWI I considered the internal pull-ups as something obligatory, I assumed they couldn't be turned off!(?) So my question wether they could be turned off was meant as a reply to why you wrote about the pull-ups... (Since they are automatically turned on)

Thinking about it I don't see any way I could turn off the internal pull-ups with the TWI still working.

Brian

- Brian

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

Quote:
John I think you read something I didn't write!
Lost in translation? Danish>English>Australian-English>Italian :lol:

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Quote:
Lost in translation? Danish>English>Australian-English>Italian

Yeah something like that :D
Well all I need to build now is one of those nifty weather-huts for it.

Brian

- Brian

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

Re: pull-ups

You can use the internal pull-ups for TWI just fine, just know that you may not get 100KHz bandwidth on the bus. Probably not an issue.

What is an issue is turning them off. I would not recommend that. The I/Os will draw more power in Hi-Z floating than if pulled-up.

I've worked on a project where an AVR had to keep time (RTC) for months in the sales channel on an 800mAh Li-ion battery. The I/O state while in power-save mode was all-important.
- Make unused pins outputs and drive them low.
- Never leave any pins floating.
- If you must drive against a pull-up/down, make it as weak as possible.

- kwr

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

What type of Xtal is it ??

Most 32Khz i have used , needed around 20pf as cap value

On some Megas you have internal 20pf caps , that can be enabled (but there are some "Unpublished" erratas for some of them here https://www.avrfreaks.net/index.p... , search for 32kh)

/Bingo
Ps: I could drop a few 32khz SMD-xtals in an envelope to you

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

Temperature calibration is a matter of comparing against a known. "Known" in this case probably shouldn't be something that's been lying in a drawer in the kitchen for the past N years. Here's how I calibrate our PT-100 RTDs at work:

We operate right around +15C to -5C, usually closer to +5C to -2C. So the calibration range is small. PT-100 RTDs have a pretty flat temperature curve, so I assume around my temperature range the response is flat. So I do a single-point calculation. At a given atmospheric pressure, ice water in an insulated container will have a given temperature very close to 0C. It's not dead-on, but I'm only calibrating to 0.1C, so it works.
I use whatever raw value I get as an offset so that my readout, when I dip that particular RTD in water, comes out 0 C.

For a wider range more suited to human survival, at least two points need to be measured. Ice water provides the 0 C point. Boiling water can provide the higher temperature point. But you need to know your atmospheric pressure for this as well. (Boiling point is far more pressure sensitive, so you really really need to know your atmospheric pressure.) Now you have an offset for your zero point, and a slope to set your high point. This still assumes a linear detector.

The best solution for temperature calibration is to compare your sensor against a known, in a system that lets you dial in a temperature and hold it there. Usually this means some sort of cooler, some sort of temperature controller with heaters, and a well-calibrated, traceable standard. (At this point I start to roll my eyes and ask if that level of calibration is really required for the application. With a few exceptions it's usually not.)

A two-point calibration and a decent sensor usually results in very good numbers. Provided the sensor's characteristics don't drift over time, it works quite well.

Tom

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

kwr: Again, I don't want to turn off the internal pull-ups, and I can't anyway! If possible this would effectively stop the TWI from working since it can't pull up or down SDA or SCL!
Right now I'm running the TWI at 50 KHz, I can't run it much faster at 1 MHz oscillater speed.
I did read the datasheet about unused pins, it just states to leave outputs at any logical level, high or low doesn't matter for power consumption! I choose low level though.

Bingo: I don't know much about the 32KHz Xtal, you are probably right about the 20pF caps! Timing seems to be a bit off with the 33pF caps, but within acceptable limits to me. It's a Xtal I have got from the stock we have at school, no more info supplied, it says "KDSOF" on the side of it.
Btw. the datasheet states that I do need to supply caps for the Mega8 except for revision "G", I don't think mine is a rev. G.

Tom: I don't really need to know how to calibrate a temperature sensitive resistor! My sensor is accurate to within 0,5C from 0-70C and reasonably linear from -15 to +105C. It even outputs the temperature in a fashion that I need not worry about converting it, for 10C it will output decimal 10!

The thing with ice-water for 0-adjustment is a very good idea though for sensors where 0C level is unknown!

Brian

- Brian