Pages: [1]   Go Down
Author Topic: Need Guidance : Arduino and Sleep modes - DIY watch design  (Read 963 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 1
Posts: 70
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Guys,

I have been building a DIY Watch project for a while now and now have a brand new prototype to work with


HW details available here : http://www.banson.fr/wiki/doku.php?id=rawlx

This cute LED PCB-based watch is now waiting for its power saving SW to be able to run genuinely on a 3.7V 2450 cell battery.

I'm now struggling with the global SW architecture of the ATMEGA code to be able to run it as long as possible. I've been digging for a while inside the documentation and the tutorials for sleep/idle modes and i'm looking now for advices on the solution chosen.

Here is how I see it now :

By default unit sleeps. Time is stored internally inside a variable which is set at initial startup.

- TIMER1 is the only peripheral activated when sleeping, it counts endlessly.

- When TIMER1 overflow occurs, an ISR is trigged, ATMEGA wakes to update the Time variable according to the elapsed 65536 TIMER1 ticks, and system is put back to sleep, TIMER1 continuing its duty.

- When button is pressed, another ISR is triggered, waking up the ATMEGA. Time variable is updated according to TIMER1 accumulator cournter, and displayed using the leds for a bried amount of time.

Is this approach reasonable? Can I use the Arduino low power library, or do you advise to do it by hand by tweaking ATMEGA registers? I'm still more at ease with Arduino IDE so as far as possible, I'd like to stick to the Arduino world as much as i can.

I'm still not completely sure I can put the whole chip to sleep except the TIMER1 counter, and if everything can be waken up the way I want to do it.

Thanks in advance for your feedback/suggestions,

Vincent

note : I have chosen not to use a RTC for visual aspect reasons, and I'm ready to use low frequency crystal as ATMEGA clock to reduce power consumtion as well. I have a few 32khz and 2Mhz crystals to mess around with.
« Last Edit: October 22, 2013, 06:00:18 pm by D4p0up » Logged

Arduino sound Reseach - http://bit.ly/fullmaj [fr][en] | Homemade Free VST - http://zomg.zxq.net [en]

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

Which sleep mode did you have in mind, and what is your target power consumption?

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


Offline Offline
Jr. Member
**
Karma: 1
Posts: 70
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you nick for this very complete (and didactic) documentation. I would like to put the device into the lowest consmutpion mode still fitting my needs. I'm going to read in detail your findongs and come back to you.
Logged

Arduino sound Reseach - http://bit.ly/fullmaj [fr][en] | Homemade Free VST - http://zomg.zxq.net [en]

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

Thanks!

This might help you too:

http://www.gammon.com.au/forum/?id=11504&reply=10#reply10

With one external crystal (if you can somehow fit that in) you can get the consumption to around 1 µA.
Logged


Offline Offline
Jr. Member
**
Karma: 1
Posts: 70
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Awesome, is it also the case for Timer1? I could wake the chip every two seconds then.
Logged

Arduino sound Reseach - http://bit.ly/fullmaj [fr][en] | Homemade Free VST - http://zomg.zxq.net [en]

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

According to the datasheet, it is Timer 2 that will wake from SLEEP_MODE_PWR_SAVE.

However you could increase the time, change:

Code:
  OCR2A =  31;              // count to 32 (zero-relative)                 

to:

Code:
  OCR2A =  63;              // count to 64 (zero-relative)                 
Logged


NSW Australia
Offline Offline
Faraday Member
**
Karma: 87
Posts: 3534
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Unless you have a crystal running a counter all the time - you do not have a timepiece.

(And even then it has to be a good crystal.)
Logged

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

That reminds me of the day when I was at a "watch vendor" (aka jewellery shop) and I asked about how well the various watches kept time. The salesperson looked confused at the question.
Logged


NSW Australia
Offline Offline
Faraday Member
**
Karma: 87
Posts: 3534
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That reminds me of the day when I was at a "watch vendor" (aka jewellery shop) and I asked about how well the various watches kept time. The salesperson looked confused at the question.

Dare I ask this: ... Female?
Logged

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

I don't want to get into male/female stereotypes. smiley-razz

Let me put it this way: a lot of staff in jewellery shops are female.
Logged


Offline Offline
Jr. Member
**
Karma: 1
Posts: 70
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Got through all of your post, made my Fuse setup and architecture, will be testing soon.

Last question, can I use the Arduino IDE to do it, using my Uno as ISP ? I need to configure the config files I guess, some more reading required.

Again, nick you totally nailed my needs with your post.

Massive Kudos,

Vince
Logged

Arduino sound Reseach - http://bit.ly/fullmaj [fr][en] | Homemade Free VST - http://zomg.zxq.net [en]

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

I personally use my hex uploader:

http://www.gammon.com.au/forum/?id=11638

But the Arduino (Uno) as ISP should work, and saves you having to use SD cards.
Logged


Offline Offline
Jr. Member
**
Karma: 1
Posts: 70
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Working  exactly as intended, many thanks. Here's a short video of current capabilities. Thanks again nick !

http://youtu.be/g2tXVPLfgjk

Vince
Logged

Arduino sound Reseach - http://bit.ly/fullmaj [fr][en] | Homemade Free VST - http://zomg.zxq.net [en]

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

Looks nicely made. smiley
Logged


Pages: [1]   Go Up
Jump to: