Go Down

Topic: Arduino Sleep Modes Tutorial (Read 6209 times) previous topic - next topic

donmorr

Apr 28, 2010, 02:53 pm Last Edit: Apr 28, 2010, 02:59 pm by donmorr Reason: 1
Hi All,
Not sure if this is the right sub-forum so post this in, but I'll go ahead anyway.
I've started a set of beginner tutorials on putting the Arduino's ATMEGA to sleep and waking it using the following methods:
  • via an external interrupt. The Diecimila will wake up only when an external interrupt occurs.
  • via the UART (USB serial interface). The Diecimila will remain asleep until data is received over the serial interface.
  • via an internal timer. The Diecimila will periodically wake up from sleep, carry out an action and go back to sleep.
  • via the watchdog timer. The Diecimila will periodically wake up from sleep, carry out an action and go back to sleep.

Anyway, I have two parts completed so far; Part 1 - an overview of the ATMEGA's Sleep modes and Part 2 - Wake Up Via An External Interrupt.
I hope to complete the remaining tutorials over the coming weeks.

If you have any suggestions on how to improve the tutorials, please pass them on.

Cheers,
Don


EDIT:
Cheers Paul :-)

Please follow this link to part 1 of the turorials:
http://donalmorrissey.blogspot.com/2010/04/putting-arduino-diecimila-to-sleep-part.html

PaulS

Quote
If you have any suggestions on how to improve the tutorials, please pass them on.


I have one. Post the link to them.
The art of getting good answers lies in asking good questions.

TBAr

Don, thanks for posting the blog entries.

I tried to comment on the blog, but it required registration, so I'll comment here.

It would be convenient if the links in the "Resources" section at the bottom of Part 1 were hyperlinks.

In Part 2, it looks like you copied the comment block for the enterSleep() function and pasted it above the loop() function, changing the description. You should change the name in that comment block too. There are various typos in other comments that won't affect the running of the code either, but you may want to hear about them anyway: detaach, "Setup pin2 as in interrupt...", and, in the downloadable .pde file only, debouce. (I have found that I can never proofread my own work, so I depend on the eyes of others to correct my typos too.) As a side note, I don't believe the comment at the beginning of the .pde file about suffering from debounce is true. The only effect pin 2 has on the program is to trigger the interrupt, which is disabled after the first "bounce."

Finally, and most importantly, you need to escape the ">" in the source code somehow so it displays correctly as
Code: [Select]
 if(seconds >= 3)
instead of
Code: [Select]
 if(seconds >= 3)
That would be useful for those who will copy and paste the code from that page instead of downloading the .pde file, which of course does not need that change.

A link to Part 3 after the source code in Part 2 would be handy too.

As you might expect, the source code in Part 3 and its associated .pde file have the same issues as in Part 2.

Looking forward to the completion of the series.

donmorr

Hi TBAr,
Thanks for the comments! Very helpful.
Cheers,
Don

Pauly

Thanks Don.  This is very helpful.  
Any idea when you might get to the internal timer or watchdog timer?

CrossRoads

I noticed that #include <avr/interrupt.h> or similar is not included. I struggled with getting ProMini & Deumilanove to wake up until I stumbled across that at another site.

Robert
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up