Best method to conserve battery power

CLUELESS1

Senior Member
I am making a battery operated alarm in which pressure mats are connected. The alarm is to raise awareness to an elderley person getting out of a bed, or getting out of a wheelchair. Only one pressure mat will be plugged in at any one time, however I have two problems. One mat has contacts closed with pressure, the other opens. So how can I differentiate which mat has been plugged in. Secondly with an input being closed contact that opens to cause an event, is there a better way to handle this to conserve battery power, as when closed current will be flowing in the circuit and this could be for long periods. Hope I have explained things and not confused.
 

Revolvr

New Member
An easy way is to use 2 inputs. Configure one with a pull-up resistor and the other with a pull-down resistor. See Manual3, page 26.

When the switch is closed current will flow through the resistor, which is usually around 10K Ohms. Could be higher, but computing the current flow is easy (I = V/R) and you will find it is very low.

Also the PICAXE can be kept in low power mode by using NAP. Periodically wake up, say every half second, check the sensor, and go back to sleep.

If you cannot use 2 inputs, then it could be done in software, where you look for a change in state, either high to low, or low to high, to trigger the alarm.
 

CLUELESS1

Senior Member
Many thanks, did not know about NAP, will look it up. Having two inputs, one preset to being held high, the other low is a good idea, just need to find a way to start looking for a change in state to give time to turning on and plugging in sensor mat, maybe a long pause after turn on. Thanks again, that's given me a starting point. Have a good weekend. Regards
 

Dippy

Moderator
With the appropriate PICAXE you can Sleep and Interrupt from Sleep (I thought but I'm a bit rusty). See Sleep and Hint.
 

srnet

Senior Member
As Dippy suggests, the X2 PICAXE parts support the 'sleep 0' command, and will wake up on an interrupt.

With careful design of the circuit, you should be able to get sleep current below 20 or 30uA, so a set of AA alkalines would last 5 yeart or more.
 

CLUELESS1

Senior Member
Thanks Dippy. I saw reference to sleep, which I think from reading offers longer powering down modes than NAP. However I think NAP is going to be better because I need to not miss any period where the pressure floor matt gets walked on.
I think I have worked it out, will try tomorrow, but I will have 1 Picaxe input held high, and another held low. Then I will have 1 input socket where the mat is plugged in. ! matt has contacts closed by default, the other open. I will connect both Picaxe inputs to the input socket via steering diodes to split high/low closures. I will use a pause statement to allow the unit to be turned on before a mat is plugged in to allow the logic to prepare itself for change.

I just hope it's not a case of okay in practice but no good inreality!
 

Circuit

Senior Member
Thanks Dippy. I saw reference to sleep, which I think from reading offers longer powering down modes than NAP. However I think NAP is going to be better because I need to not miss any period where the pressure floor matt gets walked on.
I think I have worked it out, will try tomorrow, but I will have 1 Picaxe input held high, and another held low. Then I will have 1 input socket where the mat is plugged in. ! matt has contacts closed by default, the other open. I will connect both Picaxe inputs to the input socket via steering diodes to split high/low closures. I will use a pause statement to allow the unit to be turned on before a mat is plugged in to allow the logic to prepare itself for change.

I just hope it's not a case of okay in practice but no good inreality!
I think that you may not be quite on the right track with your steering diodes etc. PICAXE X2 parts have hardware interrupts that can wake a PICAXE from sleep. You can set these to respond to either "rising or falling edges" - that is going from a high to a low or from a low to a high. I think that you might plug your two mats separately into two PICAXE HINT pins and then configure one interrupt pin to respond to a change from low to high and the other to respond to high to low. Then send the PICAXE to permanent sleep; SLEEP 0. The thing will then use very low current indeed; especially if you switch off brown-out etc. as described in other threads relating to low power operation which you have been guided to already I think. See Manual 2 Page 86 for details of the hardware interrupt and Manual 1 Page 11 for the appropriate HINT pins to use.
 

CLUELESS1

Senior Member
Thanks eclectic, I will have a look at that.
Thanks circuit. There are two pressure mats but only one control/alarm unit. Ony one mat will be plugged in at any one time. I want to avoid having a switch or two seperate sockets for mats, as the carer runs the risk of not setting the alarm correctly. Therefore I thought using 2 Picaxe pins, one biased high the other low. Then if I connected diodes into each input (diodes in correct polarity for each input) then joined at the other ends into one socket that would work? However will look more at what you say. I was going to use an 08M2 as very little other functions wanted.
 

Dippy

Moderator
Confused reader here (easily done btw).

2 mats, but only one "plugged in at any one time".
compared to
2 connections and a switch.

Which is the carer most likely to forget?


I'm now confused regarding the actual function and any electrical connection limitaions.
Are you saying you can only have one physical connections for one mat ?

With regard to all your diodes; it's time for a drawing of the 'system' :)
You can see all this - we can't.

PS. Why can't you use 2 N/O mats and save some grey cells for all of us? ;)
 

rossko57

Senior Member
Can you use a plug with spare pin, or a jack socket with break contacts, so that Picaxe can determine if/when something is plugged in?
That would still leave the problem of determining which mat, in case someone is already stood on it at plug in time.

Are you able to add resistors into the mat circuit, in the lead or plug perhaps? This would allow for determing both type and presence.

Simple, use two incompatible plugs?
 

CLUELESS1

Senior Member
Thanks Dippy, Circuit. My diodes idea failed, I was forgetting the mat switch only switched to ground or high, not both.

Basically 2 mats. I received them today, was told they switched in opposite to each other but they both close with pressure!

I have a hand held alarm box, 1 socket to accept 1 mat at a time. Now I know they are basically the same one problem gone. The scenario is 1 mat on the bed, need to set alarm if the person gets out of bed (moves off mat). The other goes on the floor in front of a chair to alarm the person has got out of the chair (stands on matt). So what I think I will do is have a switched socket on the alarm box (battery power through contacts. I need then code to start that looks at what the status is of the mat to begin with, ie closed or open, and then after this the alarm should get triggered if the opposite occurs. ie if started closed and then opens then trigger alarm. So I think now I should be able to fix it ok now sorting what the mats do. Thanks for the help, info on power saving etc. Sorry if it looked like a time waster, did not intend.
 

lbenson

Senior Member
Regarding Rossko57's suggestion of adding resistors so that you can plug in both mats at the same time and determine the status of each (using ADC), this is similar to the "Fully Supervised Loop" (FSL) system used in some home security alarms. See the first post in this tread for an FSL example with one switch:

http://www.picaxeforum.co.uk/showthread.php?25199-Pin-protected-Web-enabled-28X2-Home-Security-System

With thought, there could be two switches. You wouldn't need the fault-detection parts, only a 2-switch on/off detection. See this thread, starting about post 29, for some discussion of FSL issues:

http://www.picaxeforum.co.uk/showthread.php?25100-Burglar-Alarm

On the other hand, if a shortage of pins in the 08M2 is the reason for being able to read only one mat at a time, it might be far easier to just move up to the 14M2.

I would agree that the need for the caretaker to plug in the appropriate mat might well be the greatest cause-of-fault for this system as described.
 

CLUELESS1

Senior Member
Thanks, I did not think about using ADC, that's probably what Rossko57 was suggesting. That would identify which of the two mats was being used. As I said, only 1 mat is used at any one time, so thats my answer, thanks again.
 
Top