Picaxe to use bed sensor mat

CLUELESS1

Senior Member
I have aquired a bed pressure mat, which I want to use with a Picaxe as an alarm when someone leaves the bed at night.

The company who sold it are not interested in telling me how it is wired, as it is not being used with one of their monitors.
The matt is made in China by a company called THF Hong Kong. I have emailed them but again I don't think they will help
not using their alarm.

There are four wires coming out on an RJ10 connector. Two wires have 12 ohms between them (unless it's my battery) and they short out to the other two wires when pressure on the matt. So a common to two switched outputs. However the switching is so erratic, a small movement on the mat and the circuits break (ie contacts open again)

I thought it might be wired to switch in zones but cannot seem to prove it as switching eratic.

Has anyone any experience of mats of this type?

http://www.tfehk.com/new/?sensor-mat-bed-floor,24
 
Last edited:

Dippy

Moderator
I doubt anyone here has used it.
It's probabaly the same principle as the cheapo burglar under-carpet matts.

Step 1. Draw a wiring diagram with the values you have measured for your records.


Erratic? I'm hardly surprised.
However, is it erratic when there is no presure on it?
Could you detect (in code or monostable) that when it is 'open circuit' for more than 10 seconds then person has jumped off?

You may need to think laterally or use a little imagination here - especially as you have it in front of you and we don't.;)
 

CLUELESS1

Senior Member
Thanks Dippy. I thought this mat which is normally sold with an alarm/pager was a dedicated type of mat, having either variable resistance (so you can track if somebody is sitting up in bed or about to leave) or zones to maximise area coverage to prevent false alarms.

However I found two wires are common, and by putting the other two switches into 2 pins in an 08M2, triggering 2 LED'S, I found the two switching areas are in parallel. So I think the mat is a typical security type mat with 2 parallel switches, one as pressure contact/feedback/alarm use, and the other for ant-tamper use.

So now it's making sense I need to put in a delay of some seconds to aleviate false outputs by general movement on the mat.
I am so pleased I am using a Picaxe for this project as allows easy tweaking.

Thanks again Dippy, have a good weekend.
 

Dippy

Moderator
How will you do your 'delay'? How will that work?
You'll need a test over a time period. As in; 'Has it been stable off for X seconds'?.
On the face of it (and based on complete guesswork regarding the erratic-ness) I'd be tempted to use an integrator type circuit.

Anyway, I'm sure you (or someone) will suss it so good luck.
My weekend will be fixing the roof and getting cooked like a bit of bacon ;)
 

CLUELESS1

Senior Member
Your a mind reader Dippy, yes how do I do it?

(if pinc.2=0 for 3 seconds then)

Because it might go on and off during the 3 seconds but be off at the end of 3 seconds so it thinks for 3 seconds it was off, wrong.

Actually, while writing, what if I put it in a loop and do a count for any off times?. Don't know what the event times themselves would be in a loop, ??

I thought today would be cooler, how wrong. Just had a security camera die in the sun, no fan. Good luck on roof, be careful.
 

AllyCat

Senior Member
Hi,

Is this mat on the floor (contact closing when stepped on) or on the bed (contact opening when person leaves)? Since it's probably designed to respond to the pressure of a foot (e.g. 50 kgs over an area of 100 sq cms) it may not work well (or at all) if on the bed.

Two ideas you might like to try: Use a PICAxe "touch" input to detect when the "plates" (or wires) in the mat get pushed closer together. You would need a small capacitance in series with the mat, perhaps 10pF (which might be made by simply twisting a length of insulated wires together).

Another idea I had many years ago was to "weigh" the bed with something like a load-sensitive "carpet protector" under one or more of the bed legs/castors. A Strain Gauge or Load Cell might be over-complex, but perhaps something can be done with a touch input again, the pressure pushing two metal plates (separated by a springy insulator) slightly closer together.

Cheers, Alan.
 

CLUELESS1

Senior Member
Hi Alan, thanks for answering. The mat is designed to be used for bed or floor. I am trying to use it in a bed. It's rectangular, designed to go across the bed so when the person sits up it opens contact. It's positioned in the upper body area, waist/head.

I am trying to establish a loop that will see if the mats contacts have opened for 4/5 seconds.

I like your idea on using touch with a picaxe, maybe I could add that in addition to give extra prevention of false alarms, nice one.

Back to my loop. (if pinc.2=0 for 3 seconds then)
 

SAborn

Senior Member
Perhaps a back to basics is required where a harware solution is used, where the mat charges a capacitor via a resistor (a simple RC time constant) and the picaxe just do a ADC reading of the cap, if the value is above a set value than trigger alarm, if below than do nothing.

A bleed down resistor might be needed to drain off the cap so it dont become a combined cap voltage over a extended time period.
 

techElder

Well-known member
Clue, you want to be in a programmed loop that, when completed, sets off your alarm.

Within that loop, you want to be detecting the bed mat switch open/closed state.

If the bed mat switch remains closed (or opens then closes), then you reset your programmed loop variable continuously. (Every time the bed mat switch closes your programmed loop variable is reset.)

This gives you control (or noise reduction) with the programmed loop variable.

More iterations of the programmed loop means that more incidental "bouncing" of the bed mat switch can occur without setting off your alarm.
 

Dippy

Moderator
Too hot. Lunchtime...

Is this like one of those vinyl faced burglar matts?
And it goes under the bottom bed sheet?
You are going to have a very hot & sweaty occupant :)

Maybe you could do an interrupt or IF in a loop or with a timer to act like an integrator.
(Oh, I've just seen T-clod's post...)
But, you've got make sure your switching, with it's intermittentness, will give you a logic LOW/HIGH at all times.
In years gone by I found cheapo mats to be unreliable.
This could be a long thread so I'll wish you success :)
 

CLUELESS1

Senior Member
Thanks both, two very good suggestions. I now have good alternative ideas to try out . I did not think of the restarting/re-value loop idea. Back to work, thanks again
 

CLUELESS1

Senior Member
Thanks Dippy. No, this is a white mat. Apparently if black mats are used on the floor, someone with dementia think it's a hole and jump over them!

I have been playing with a loop, it works in the simulator but flies through the code in real life, and I cannot increase my loop value?

Code:
VV:
b3=10000
For b1=1 to b3
if pinc.2=1 then
goto VV
end if
next

' Timeout,left bed 
low c.4
Roof: Wait until it's cloudy and cooler!
 

CLUELESS1

Senior Member
Hello Alan,

You just beat me, I put a pause in the loop. Now I can have several open/closed contacts events before it finally ending the loop.
Now to play with touch, as a secondary input. Thanks
 

hippy

Technical Support
Staff member
Back to my loop. (if pinc.2=0 for 3 seconds then)
Sounds like just the thing the BUTTON command was designed for, though I don't off-hand know exactly what values would be used in such a command.

Otherwise something like below, where 'counter' will reach around 3000 if there is no one on the mat for 3 seconds (3000ms) ...

Code:
Symbol counter = w0

counter = 0
Do
  If pinC.2 = 0 Then
    counter = counter + 1
    Pause 1
  Else
    counter = 0
  End If
Loop Until counter >= 3000
Goto PatientHasEscapedTheBed
You might have to make that "If pinC.2=1 Then" and might have to tweak the ">= 3000".

Added : Missed there was a page 2 of posts, so you might have already got there!
 

CLUELESS1

Senior Member
Thanks Hippy, yes my previous page (re loop) works well, however I also like your code, easy to tweak.

Just trying to get a "Touch" event working, however the only way I can see my ADC value going to zero is by me holding my fingers accross the capacitor in seriees with the mat. I think because its a long, unscreened cable (BT 4 wires terminating in an RJ10 plug (modem/ADS type), then any capacitance change in the mat switch foils are lost.
The mat seems to be triggering well with the current code, it would have been good to have had another Picaxe input as a failsafe. The other option is SAborn's idea of a R/C charging circuit, looking at the ADC value, however again long unscreened wire might get unwanted results.
I might buy another cheap ,at for the floor, and then have two things to look at for someone on the move.
 

Dippy

Moderator
Just for information; the R/C is an integrator (post#4); I should have explained.

Yes, why not a mat under a bed-side rug. No-one will think it's a hole and it'll protect it from people in high-heels :)
Haven't you/we been through all this before recently?
 

CLUELESS1

Senior Member
The last project was without having bought a mat. It was for a chair alarm, and ended with using a hall switch. A cord with a clip at one end and a magnet on the other. The idea being you clip the clip onto the persons clothing, and the magnet clips onto a box containing a hall switch. When the person gets up off the chair they pull the magnet off the control box, and the hall switch triggers the alarm.

This project is for a bed. The mat was supplied by a company who also make alarms. They refused to help me identify how it was wired and answer why it was erratic (making and breaking contact in slight pressure changes)

Re high heels, my wifes uncle would be very pleased to have a dolly bird walking around in high heels, however no chance. !
 
Top