Go Down

Topic: External 32 KHz timer2 in order to shutdown (Read 2146 times) previous topic - next topic

denisj

Hi there all,
I'm a newbe and i finish to read some articles
about power saving of arduino.
i just want to ask you a little question.

I have a pulse counter that i want to make it to save more power possible.
This pulse sensor must read a LED pulse of my current power meter
and then send it via RF every 5 minutes to another arduino base.
Must work using 2 X 1.5 V Batts.

If i understand the most of CPU can be shut down in order to consume less power.
The problem is that i need an accurate timer in order to know
the time between the last 2 pulses every about 5 minutes.

So if I power down the arduino, i lost the mills().
But if i use an external timer2 using an external 32 KHz crystal
i can wakeup and have also the accurate timer2 mills... is this true ?
Is this correct that i understand please ?

Thanks a lot
Denis

Nick Gammon

I don't quite see how you would know when the LED blinks if it is asleep.

You might be best off trying to keep current low, but awake. For example, running off 3V would keep consumption down. Definitely use a "bare" board, not an Arduino development board (ie. no USB, voltage regulator etc.). Configure it to run at 1 MHz (run off the internal oscillator with "divide by 8" fuse set).

I am guessing you could get current down to around 1 mA at that rate. Using a 2 x AA battery with (say) a rating of 3000 mAH that would last you 3000 hours (125 days).

You could have the RF transmitter switched on by a MOSFET so every 5 minutes or so you power up the transmitter, send the readings, and power it down again.

Quote
The problem is that i need an accurate timer in order to know the time between the last 2 pulses every about 5 minutes.


If you have a way of knowing when the pulses come, even when it is asleep (interrupt?) then you could attach a clock chip (RTC) board with a battery backup. That would remember the time, even if the main processor is asleep.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Nick Gammon

Quote
But if i use an external timer2 using an external 32 KHz crystal i can wakeup and have also the accurate timer2 mills... is this true ?


Someone had a project about that recently here. He was making a clock or something.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

GoForSmoke


This pulse sensor must read a LED pulse of my current power meter
and then send it via RF every 5 minutes to another arduino base.


I know of one type of meter that sends a data packet every 1.0 seconds. If I only had to send data every 5 minutes then I would get a packet, send my data and sleep until just less than 5 minutes -- enough to let the board get up to speed to read the next packet.

Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

denisj

Hi there and thanks all for the answer.

Now I don't remember where I read but I remember that tha cpu can sleep
but have also the external interrupt active.
Is this true ?

The LED pulse is read from a photo transistor
like here: http://forum.jeelabs.net/files/monitor_design_v01.png

It must wake up every 5 min in order to send the data via RF
but also must wake up every pulse that arrive via interrupt in order to count it.

Can I put it in sleep but external interrupt active please ?

Thanks again
Denis

Nick Gammon


Now I don't remember where I read but I remember that tha cpu can sleep but have also the external interrupt active.
Is this true ?


Absolutely. But the only external interrupt that will wake it from deep sleeps is the LOW interrupt, which means the pin has to be brought low. If you can arrange that, fine.

Maybe the pin change interrupt would work for a transition but I haven't tested that. Actually page 70 of the datasheet seems to say that a pin change interrupt could be used to detect a rising or falling level:

Quote
Pin change interrupts on PCINT23..0 are detected asynchronously. This implies that these interrupts can be used for waking the part also from sleep modes other than Idle mode.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

denisj

Dear Nick,
thanks again for the help

I don't know what type of interrupt I use ... i just copy paste the command from some source around
I know that I activate it using:
Code: [Select]
attachInterrupt(1, onPulse, RISING);

It is the LOW interrupt please ?
Thanks a lot
Denis

Udo Klein

I would also suggest a bare bones chip + RTC. I have very strong doubts that it would be even remotely easy to beat a dedicated RTC with regard to both power consumption and accuracy.
Check out my experiments http://blog.blinkenlight.net

dc42

Why not put it into sleep mode but leave counter/timer 1 counting clock cycles (and waking the processor up every 5 minutes), and counter/timer 2 counting input pulses from the phototransistor?

You can run the whole chip from a 32768Hz crystal, unless you need a faster clock speed when sending the data via RF.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Udo Klein

Running @32kHz implies flashing @8kHz. This is a major pain. For low power I would run @1Mhz internal clock + use an RTC. Deep sleep till the RTC triggers the wakeup. Then perform whatever is necessary and go to sleep again. Unlike a crystal the RC oscillator will be ready much earlier. It also consumes less power.

Also keep in mind to shut down all parts that are not really needed (e.g. unneeded timers, brown out, I2C, ADC). The datasheet holds the details ;)
Check out my experiments http://blog.blinkenlight.net

Nick Gammon

Stuff about power saving:

http://www.gammon.com.au/power
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

GoForSmoke

This makes me think about the vast number of projects where AVR is a bit overkill.

Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

denisj

Thanks a lot all of you guys ... it's wonderfool to see a lot of help.

I just ordered yesterday some 32,768 MHz crystals in order
to begin to test it.

So after i read (but not understand all) the wonderfool article post by Nick (http://www.gammon.com.au/power)
i understand this steps:

- i must run it using the Timer2 trained by an 32MHz external quartz in order to have an accurate time after wake up
- i must program the atmel in order to use 8MHz (i anyway need at last 4Mhz in order to use the RFM12B for rf transmitter)
- for the LED pulse i will use the LOW interrupt wake-up on pin 5 of atmel
  (i hope will fill the LOW status, cause now in my program i use the RISING status)

Is everything right until now ?
The Timer2 is work in "Power Down" mode ? ..or it's work only in "Power Save" mode ?

I just must understand about how to program the atmel in this case.
If I understand I can not use the normal flash using the bootloader
cause of use of internal 8MHz RC clock... it is there a bootloader that can use 8MHz internal clock ?

Thanks a lot again
Denis

Nick Gammon

Quote
cause of use of internal 8MHz RC clock... it is there a bootloader that can use 8MHz internal clock ?


Yes there are 8 MHz bootloaders. The Lilypad is one I think.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

GoForSmoke

There's Arduino as ISP to minimal config breadboard 8 Mz.
http://arduino.cc/en/Tutorial/ArduinoToBreadboard

AFAICT this warning applies to UNO's with 168 chips, not 328's, see the chip-specific part in parenthesis. I can tell as far as my 328-chip UNO bootloading and programming 328P-PU's
using material and wiring from that link.

Quote
Note that these techniques only work with the Arduino Duemilanove w/ an ATmega328, not the Arduino Uno (or older Arduino boards w/ an ATmega168).


Hard to predict change, that comment must be ooooooooooooooold!
Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

Go Up