extend picaxe battery life

spi007

New Member
Hi All,

I have a project where my code is looking for a button press and then excutes a routine.
I'm using the PICAXE-08M2
Currently my code looks like this
Code:
main:		if pinC.1 = 1 then timerbegin		; if button pressed start timer
		pause 50				; dbounce setting
		goto main			; otherwise look for button push again
But I'm doing this with a small watch battery and the battery dies too quickly.
My question:
Is there a better way of doing this? Instead of using battery power constantly looking for the button push would my battery last longer if I used an interrupt or some other method?
Can I have my microcontroller sleep/hibernate or turn off until the button is pushed?
 

Hemi345

Senior Member
I think without the hardware interrupt features like the X2 models have, youre sort of limited on what you can do. Have a look at this thread:

http://www.picaxeforum.co.uk/showthread.php?8353-Low-Power-Battery-Backup-Reference-Design&highlight=08m+blinking+years

Another option is to design a power circuit based on the push button. Like have the button pull the base on a NPN transistor high which would pull the base of PNP low which would power up the PICAXE. The PICAXE's first order of business would be to hold the NPN's base high. Then when the program is finished, have it put the NPN's base low which would turn off the PICAXE. Here, check out this thread, lots of pictures are better than me trying to describe it:

http://www.picaxeforum.co.uk/showthread.php?22601-circuit-help-momentary-switch-for-power-on-picaxe-to-power-off
 
Last edited:

spi007

New Member
Wow thats a really good ideal about the power circuit!!! Thank you Sir I will have to look into this.

Just becuase I'm curious and at this time I'm thinking a software solution might be easier for me... Do you have any experience with the permenate sleep command?

edit*
I see now the 08m2 doesn't offer permenant sleep... nor hibernate... but i'm looking for something similar on the software side, any ideals?
edit*
 
Last edited:

PaulRB

Senior Member
For a simpler solution, try replacing pause 50 with nap 3.

Or... remove the pause altogether. Put setfreq k31 before the loop and setfreq m4 as first command at the timerbegin label.
 
Last edited:

chipwich

Member
Actually, the M2 series have great power management available in software. As was suggested, the easiest starting points are to replace PAUSE statements with NAP and SLEEP statements. In my experience, this alone cuts current draw in half to a few hundred micro-amps, though it does reduce timing accuracy.

You should also consider using a 20M2 which operates down to 1.9v, whereas the 08M2 needs about 2.3v. Also, look into the "disablebod" command which allows you to get a bit more out of your batteries.

The PICAXE operate off a wide range of voltages. You can take advantage of this by adding in an extra cell if it doesn't exceed the Max voltage. For example, if you're using 3v (2x1.5v), then consider an extra cell for 4.5v (3x1.5v) which will extend usable time.

You can also underclock the chip with the SETFREQ command, though this may mess up serial communications, or affect PICAXE downloads. I haven't used this, so perhaps someone else can explain the +/- of underclocking.

Lastly, button cells have extremely low capacities of about 200 mAh. AA (at about 2000 mAh) or even AAA (about 800 mAh) are much better, if you can use them. You can compare battery capacity in the table at wikipedia: http://en.wikipedia.org/wiki/List_of_battery_sizes .
 
Last edited:

westaust55

Moderator
@SPI007,
It can be worth you doing a search of the PICAXE forum to see what others have done.
I recall there is a thread about a PICAXE 8-pin chip operating on 2 x AA cells and flashing an LED at some interval for a couple of years.

Here are a few for reading to get you started:
http://www.picaxeforum.co.uk/showthread.php?21254-Doing-something-once-a-day-with-minimum-battery-usage
http://www.picaxeforum.co.uk/showthread.php?23077-Absolute-lowest-power
http://www.picaxeforum.co.uk/showthread.php?21260-Methods-of-conserving-power
 

spi007

New Member
So I was pulled into a different project and forgot about this one for a while... but I'm back on it now!

@westaust55 thank you for those post; I've read through them and some good info in there.

@Tinkerjim thank you, that circuit example looks to be perfectly what I'm looking to do! Now I just need to order some parts solder away and see what happens.
 

MarkOfZero

New Member
I have a similar need. Is there any way to allow any one (or more) of several button presses to turn the PicAxe ON, and then detect when any one of the buttons is released? After release, I would like to turn the PicAxe OFF.
 

Hemi345

Senior Member
Having multiple buttons control powering on the PICAXE and would get messy but it can be done by connecting the outputs of all the buttons to the gate/base of the power transistor using diodes on each to prevent the primary functions of the button from being messed up when one of the other buttons are pressed.

The same circuit above that would latch the power on can be used to turn it off. As I said above, the first order of business when the PICAXE starts up, will be to pull the base/gate pin high to keep the PICAXE powered up when the button is released. Then when you want to shut it down, you tell the pin to go low in your code.
 

MarkOfZero

New Member
Thanks Hemi345 for the schematic.

The idea is for a wireless (Bluetooth) "wearable" chorded keyboard device. It is mostly OFF. But, comes on at the touch of any of the input buttons. Chorded (or single) key input is registered whenever the user lets go of any of the buttons. After a short period of non-use, the device would be powered down.
(An On/OFF switch would be much easier. But, a large inconvenience for the user.)
 
Top