Minimising power while waiting for interrupt

Just trying various techniques I haven't used before including using the EEPROM in a 20M2 for logging data, I wanted to output the stored data by RF link when a button's pushed to generate an interrrupt (circuit attached).

I tried SLEEP 1565 to power the PicAxe down for an hour or so between readings but found the interrupt didn't work. After significant research (the SLEEP command description in the manual makes no mention of this) I discovered that you can interrupt a PAUSE command, but not NAP or SLEEP (presumably WAIT & PAUSEUS would work as they're variants of PAUSE?).

So my question is, is there a better way of doing something very infrequently while using minimal power (logging a temperature every hour for instance) but retaining the ability to press a button at any time to read the data, without using an interrupt?

Thanks in advance for all help.
 

Attachments

You can use NAP or SLEEP within a loop, wake-up, check inputs and/or time and go back to sleep if there's nothing to do. Most of the time the PICAXE will be sleeping.

You can also drop the system clock speed, disable ADC channels and use other tricks to minimise power use.
Thanks Hippy, that's very helpful, I'll have a play with those suggestions.
 

Hemi345

Senior Member
With the 20M2, you could try using the srlatch with shorter sleeps.

Move your AXE213 data line to another pin to free up B.0 (SR latch input pin; SRI). Then connect your button to B.0 and connect B.1 (SRQ) directly to C.6 (In only pin). When you arm the srlatch, it monitors the SRI pin. When SRI detects a high (button press), it sets SRQ high which in turn would put C.6 high. So then create a "sleep and check" routine. Sleep for like 2 seconds then you check the status of C.6. If C.6 is low, go back to sleep for another 2 seconds. If C.6 is high, run your routine to transmit the stored data and then rearm the srlatch. As long as you keep your sleep and check routine short, the PICAXE will only be up and running for a very short time and sleeping for a majority of the time. The button press won't be instantaneous, but reasonably responsive considering your main objective is minimizing power.

On one of my projects that I am trying to save the battery as much as possible, I sleep for 10 seconds in between checks. I put an LED on the SRQ pin (in addition to tying it to C.6) so that when the button is pressed, the LED lights up indicating it recognized the button press and will process the command when it wakes up. When the SRlatch is rearmed, the LED goes out.
 

AllyCat

Senior Member
Hi,

A disadvantage with the SR Latch is that it has only one dedicated input pin and cannot be read directly by the program software, so additional output and input pins need to be used. Therefore, I'd just poll fast enough to catch a reasonable-length button push (on any convenient input pin), or perhaps add a capacitor on the pin to extend the detection window for a few seconds.

However, if you do want to use a latch, then the "Timer1 Gate" hardware has some advantages, as I discussed in #10 of this thread. The internal latch can be read directly with a PEEKSFR and has two direct input pin options and up to 6 more via the comparators (which can be accessed even in M2s, but would consume some power), without affecting the normal Timer operation in any way.

As suggested by hippy, I'd just use a Nap or Sleep between polling/counting events, but wouldn't bother trying a lower clock speed. Conversely, you may actually get a slightly lower average drain by running at 16 MHz (not 32 MHz which activates additional PLL hardware), noting that the Nap/Sleep delays do NOT change with higher setfreq values.

Cheers, Alan.
 
Top