Pages: [1] 2   Go Down
Author Topic: External 32 KHz timer2 in order to shutdown  (Read 1523 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4762
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
attachInterrupt(1, onPulse, RISING);

It is the LOW interrupt please ?
Thanks a lot
Denis
Logged

0
Offline Offline
Faraday Member
**
Karma: 23
Posts: 3470
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Check out my experiments http://blog.blinkenlight.net

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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.

0
Offline Offline
Faraday Member
**
Karma: 23
Posts: 3470
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-wink
Logged

Check out my experiments http://blog.blinkenlight.net

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Stuff about power saving:

http://www.gammon.com.au/power
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4762
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4762
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Pages: [1] 2   Go Up
Jump to: