help with using "sleep"

orko007

New Member
I am using both picaxe 08M's and 14M's. I use them in a controller where they get used constantly for a period of time but then may sit for days without use but with power to the picaxe all the time.

What I would like to do is if there are no inputs used for say 5 minutes or some other interval to goto sleep so it consumes less power but them "wake up" when any of the inputs used are pressed. normally the program just sits in a loop waiting for an input (button)

Is this something I can do with the sleep command?

also how much is the power consumption reduced when using the sleep command?


THanks,
Chris
 

Technical

Technical Support
Staff member
You can't wake from sleep, it just sleeps for the time period specified (multiples of 2.3 seconds). So if you don't mind that you may hae to hold the switch down for a couple of seconds before anything happens, you can use
Code:
disablebod
sleep_loop:
sleep 1
if pin1 = 1 then skip
goto sleep_loop
skip:
enablebod
etc
disabling bod helps reduce the standby current
 

lbenson

Senior Member
The forum consensus seems to be that for lowest power for extended periods while awaiting an input which may come at any time, slow the clock down to 31kHz and use DISABLEBOD. The thread pointed to below illustrates this (ignore the part about battery backup if it doesn't apply to you).

http://www.picaxeforum.co.uk/showthread.php?t=8353

The thread refers to other threads in which the issues are discussed in more detail. At 31kHz you can still execute over a dozen instructions per second--enough to check for a wake-up pushbutton a couple of times a second in a tight loop. When you get the wake-up, you immediately switch to full speed until your inactivity threshhold is passed again. With only the pushbutton being checked for (all other outputs de-activated and unused inputs tied to 0V) current draw can be brought down to about 2% of normal.
 

Dippy

Moderator
Absolutely.

Don't forget that if you are underclocking that it will affect pauses and baud rates (eg Sertxd) too.
So, when initially testing/debugging you may wonder why it behaves strangely.

I also would suggest that you only disable BODs after your code/circuit is up and running i.e. leave it 'til last. When playing around and twiddling you can sometimes get some funnies if your brownout reset is not enabled.

For technical details, wrestle with the appropriate PIC data sheet. All the info is contained within those hundreds of pages - you'll go cross-eyed to start with , but keep at it.
 
Top