Real Time Clock Chip for Waking up from Sleep

Hi,

Has anyone used Real Time Clock Chip for Waking up the arduino from sleep. I am using a WDT but the max time it gives is 8 sec. I am using an IF condition in the Interrupt loop to make the time bigger before the actual stuff is done. However, the CPU does come out of sleep every 8 sec. I have been reading stuff on the older forum and there some one suggested the use of Real TIme Clock Chip.

I have considering the use of Asynchronous Timer 2 and the pins are optimized for a 32KHZ crystal. I wanted to ask whether the 32KHZ crystal is provided with an Ardunio UNO or we have to attach external crystal to the pins.

If any body has used RTC Chip, can u please tell me how have u integrated it with Interrupts to wake up the system ?

If you get an RTC chip that has an alarm output (like the DS1305: http://datasheets.maxim-ic.com/en/ds/DS1305.pdf) you can hook that to Pin 2 (Interrupt 0) and wake the CPU from Power-down mode. You can set the alarm for intervals as long as a week and as short as a second.

John's suggestion is a good one, but OTOH I'd like to ask what the problem is with waking up every 8 seconds.

Regarding the 32kHz crystal, no it is not built in or otherwise provided. It would be connected to pins 9 and 10 (on the DIP package*) instead of a system clock crystal. This means that the system clock then has to be supplied by the internal RC oscillator. One of those tradeoffs.

  • Brought to you by the Department of Redundancy Dept.

Thanks for such a good suggestion. The problem with waking up every 8 seconds is that I want to put the ardunio to sleep for hours. That I accomplish by the conditional loops but I read in the ATMEL documentation that it takes around 1 sec to wake up from the power down mode. So that is a cosiderable amount if you consider the loop of going to sleep and waking up for 450 time making it an hour.

Does the alarm output mean to be 5 V rising edge of falling edge and how much power does this chip consume.

BR,

Have a look at:

http://www.engbedded.com/fusecalc

The maximum time to wake seems to be 65 mS. Hardly a whole second.

I have done some stuff about power saving here:

One thing you can do to save a lot of power is to run it off 3.3V rather than 5V. And if you use a 8 MHz crystal rather than 16 MHz then the 8 seconds becomes 16 seconds - and, it uses less power.

The clock chip itself uses power, so if you use it to wake the Atmega, then you are transferring the problem to the clock chip. Although as I read the datasheet, the clock chip can still send an alarm when powered down (and running off the backup battery). However I would want to test that for myself, and see if, overall, this is more efficient than just putting your main chip to sleep.

The other thing to bear in mind is the self-discharge rate of batteries. I presume you are trying to keep power consumption down because you are using a battery, but as I discuss on the linked page, some batteries have quite high self-discharge rates. So saving a microamp in your processor might be meaningless if the battery self-discharges, in effect, at 1000 uA.

Thank you so much for your link. You have done quite a lot of work and ofcourse this would help me a lot.

Regarding the bare bone boards, Can u share me the basic circuitry which i need to connect on the bredboard to get the micro controller working atleast for the sleep part. The problem in my case is that I would be using a USB host shield to provide power to another device during the wake up time. Therefore, I need to have the USB chip on the board. What I am assuming from your discussion and posts on other sites is that the USB chip consumes quite a lot of power. But I guess I have to keep it.

Secondly, you have told about using the clock at a lower speed. Can u share the instruction for that. I have an idea that we can set the clock to 8 MHZ before going to sleep and once we have woken up we set it to 16 MHZ in the interrupt routine and then set it back to 8 MHZ once we are back in the loop function. Do You have any idea for this ?

I am also looking to switch the current to another device using relay functionality. And the relay would be turned on once the microcontroller comes back to sleep. I have checked out the basic circuits one given in the arduion play ground. I am unable to guess where would I place the positive and ground connection of the device which i need to run from the relay.

It will use less power but the Watchdog Timer uses a separate 128 kHz Watchdog Oscillator so the intervals won't change.

Vik009:
Does the alarm output mean to be 5 V rising edge of falling edge and how much power does this chip consume.

Read the data sheets. The INT0 input needs a level change to wake the chip from sleep.
The chip uses a maximum of 25.6 (2V) or 86 (5V) microamps when keeping time. If keeping time with the battery it uses 0.4 microamps. I guess that means you can use an output pin to provide power to the chip when awake, then go back to battery power when the ATmega powers down.

Vik009:
I am also looking to switch the current to another device using relay functionality. And the relay would be turned on once the microcontroller comes back to sleep. I have checked out the basic circuits one given in the arduion play ground. I am unable to guess where would I place the positive and ground connection of the device which i need to run from the relay.

Driving a relay takes a good deal of power. Are you saying you want the relay to stay activated even after the ATmega goes back to sleep? I would think you'd want to use a latching relay for that so you don't use power just to keep some contacts closed.

i mistakenly wrote about using the relay while the micro controller is in sleep. Actually it is the other way round. I need to keep the relay on while the controller is awake and when the controller goes to sleep, the relay is turned off. I am thinking of powering up the USB host shield via the relay. Is this the right way or should I just set a bit and put that as VCC for the USB host shield board.

If the USB host shield draws less than about 30 mA you can drive it directly from a logic pin. More than that and you will need a relay or other switch to control the power. A logic-level MOSFET would probably do the trick and draw little power when off. Don't forget a pull-down resistor on the Gate so the Gate isn't left floating when the ATmega goes to sleep.