Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

My board which is made with atmega operates on battery, it should turn on every 6 hours and log some data, then go back to deep sleep to save battery consumption. I use atmega32 and not atiny because of complexity of tasks and sensors connected to the circuit.

What I have found so far, is that I can keep track of time using an RTC IC.

I've read datasheets of some RTC IC's but they don't provide any such capability as generating a signal for atmega's external interrupt at specific intervals so it can wake up from deep sleep. (What I need is something similar to cron-task, if you are familiar with it.)

And of course search terms like "atmega scheduled task" and alike did not work.

How can I efficiently (in terms of power consumption) wake atmega up from deep sleep periodically?

share|improve this question
    
Searh for RTC chip with an "(time of day) alarm" ouput. Eg. cypress.com/?docID=45855 –  jippie Jul 10 at 6:40
4  
How accurate do you need it to be? –  Ignacio Vazquez-Abrams Jul 10 at 6:43
    
@loolooyyyy This thread on Arduino forum might provide some insight. That thread is fairly agnostic, and it doesn't involve anything Arduino-specific. Also, an important term, which you might look up, is cyclic sleep. –  Nick Alexeev Jul 10 at 6:52
1  
I've been doing something similar recently however I'm using the DS1339B that has that feature and might be worth checking out. –  PeterJ Jul 10 at 7:22
    
Do you use the internal oscillator? If so, you can hook a watch crystal up to the clock ports and set the fuses for it to drive timer 2 - then use the watchdog time to wake up from deep sleep only a few times per second. Update a counter and wake up 'for real' when 6 hours have passed. –  RJR Jul 10 at 12:58

2 Answers 2

up vote 2 down vote accepted

I am working on a very similar project, that operates once every hour for about 15 seconds, and sleeps for the rest of the time. In an effort to conserve battery power (the device is deployed in the field for an average of 6 months at a time), using WDT interrupts was impractical because constantly counting interrupts was a huge battery draw.

My system uses a Microchip MCP7940M RTC, which has a multifunction pin, that allows you to directly connect to the hardware interrupt. The chip communicates with the processor using I2C.

The only issue is that the Alarm output, which would trigger the interrupt, can only be set for minutely, hourly, daily, weekly, monthly or yearly. To get to every six hours you would still have to count interrupts, but the power draw would be significantly less because you can put the device to sleep in between interrupts.

share|improve this answer

You can use the Watchdog timer to issue an interrupt instead of reseting the chip. The chip will wake up even from the deepest sleep mode on the watchdog interrupt.

You will want to set the biggest prescaler for the Watchdog timer (8 seconds) and count interrupts. If the counter has not yet reached the predefined amount, immediately go back to sleep, otherwise, execute logging code.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.