PICAXE AND PIR SENSOR

kooch

New Member
Does anyone know how to interface a PIR sensor with the analogue input pin of the 28 pin PICAXE?
 

hippy

Technical Support
Staff member
Firstly, by "PIR sensor" do you mean a PIR module which comes as part of a burglar alarm or security system to be screwed to the wall, or do you mean the pyroelectric sensor used within them ?

If the former, then the output is usually an open-closed switch formed by a relay, which can be used just as normal switch would be with the PICAXE.

If the later, it depends on the type of pyroelectric sensor used. Some have a 'Source Follower' built in which produces a voltage which could connect directly to a PICAXE, others may need op-amp amplification. If this isn't a 'sensor in a can', it may require even more complex electronics.

You'd need to identify the make and model of the sensor to determine how it should be used.

 

kooch

New Member
It is a PIR SENSOR 5M STANDARD WHITE (RC). Rapid code 61-5130 Man. Code AMN11112. It is a small 3 pin sensor. Pins are Vdd (5V), GND, and Out. The data sheet suggests that a load can be operated using 'out pin' to switch on a transistor activating the load. I thought the varying voltage of 'out' would have been enough for an analogue input to recognise, but no joy.
 

Dippy

Moderator
If you read the Data Sheet it says its a logic output - see the table (3_ and plot of the output on page 2.

This product is also marketed under the NAPION name. If you could get the AMN21112 then that would give you an analogue output.

This data sheet gives more details:-
<A href='http://www.farnell.com/datasheets/36210.pdf' Target=_Blank>External Web Link</a>

Same meat, different gravy.
 

wilf_nv

Senior Member
This is a micropower fully integrated PIR module on a chip with various lenses and optional features suitable for many applications.

Note that both analog and digital output signals are not valid immediatly after powerup and may need up to 30 seconds to stabilize.

The digital output is open &quot;drain&quot; to Vcc and requires a 100K resistor to 0V for full output signal swing.

Both analog and digital output types have limited output drive current but are compatible with PICAXE input pins.

Edited by - wilf_nv on 21/12/2006 10:09:43
 

Dippy

Moderator
May I ask why you want analogue?

Some people get the wrong-end-of-the-stick when looking at PIR analogue outputs.
 

eclectic

Moderator
Kooch.
I&#8217;ve got a Maplin YD85 PIR sensor.
http://www.maplin.co.uk/Search.aspx?criteria=YD85&amp;doy=20m12&amp;source=15

Similar datasheets here, as K76
http://www.electronickits.com/kit/complete/surv/ck209.htm

I don&#8217;t know the full differences between 11112/YD85, but the YD85
works with a 28X, both on ADC0 or Input 0.

&#8216;Scope traces show digital output.

e
 

BrendanP

Senior Member
Am I right Dippy to think that the analogue output variety of PIR would give a different (higher/lower) output signal if the PIR was facing say, a human as opposed 2400watt bar heater?
 

Dippy

Moderator
Never tried it Brendan but I would have thought quite a big difference.

I only mentioned it as typical PIR sensors are designed for changes in radiant heat - and if you take into account the fresnel lens arrangement they'd be not much good for static measurements. Basically, its heat and movement that gets them going.

Some years ago I was trying to do a passive scanner and used a narrow home-made parabolic section reflecting onto a PIR element + op-amp and connected to scope. The reflector rotated back-and-forth and produced a scan on the scope. It worked but I got bored with it after 10 minutes.

For stationary heat measurements you'd have to use something like used in IR thermometers (thermopiles?) (Sounds like a medical complaint after a curry I know).
 

hippy

Technical Support
Staff member
I believe it depends on the sensor. A single element sensor appears to give an analogue output proportional to heat/wavelength, and multiple element sensors can give multiple analogue outputs, but most three-legged multiple element sensors seem to be wired as a bridge or in differential mode so would likely give an output proportional to difference; such as would occur using a combination of lenses and movement of the source.

I expect that most sensors used in &quot;motion detectors&quot; would not be very good at differentiating individual sources, only the movement of those sources. The AMN1 devices linked to earlier are specifically called &quot;motion snsors&quot;.
 

wilf_nv

Senior Member
Sensors with analog outputs can be processed to extract rate of change information. When several sensors are used in an array the magnitude and timing of the signals can provide directional information about the moving object.

A single element sensor output drifts slowly with changes in ambient temperature and background IR.

A dual element sensor measures the midpoint of two elements internally connected in series and amplifies the difference in output signals while canceling changes in ambient IR and ambient temperature.

Each element is a piezo like material that generates a electrical signal from mechanical stresses induced by changing IR gradients on the surface of the element.

The element output voltage and current is very small and is buffered by a FET and amplified before it is detected with a single threshold comparator as a digital signal or provided as an analog output that can be A/D converted for further processesing.

 

Dippy

Moderator
Careful shrouding/focussing/processing from a cheap/easily-available dual PIR sensor can also give directional info. I tried it some time ago.

Just remembered:
<A href='http://www.robot-electronics.co.uk/shop/Thermal_Array_Sensors2086.htm' Target=_Blank>External Web Link</a>
Piles!
 

wilf_nv

Senior Member
A don't see how any amount of shrouding, focussing or processing will give direction information from a single PIR (pyro electric) sensor.

Two pyroelectric sensors can give relative timing and magnitude of change info that can be used to determine direction and speed of a moving object in a simple environment.

Perhaps some dual element PIR sensor that brings out seperate connections for each element could be used?

The 8 element thermopile sensor linear aray in the link will give a static temperature measurement for each element (relative to ambient). Position can be determined from relative magnitude of each pixel as a hot spot. Direction of motion can be derived from changing position of the hotspot.

Scanning this thermopile arrray with a servo, as shown in the application, effectively provides a two dimensional array of 32x8 pixels for 2D thermal &quot;imaging&quot;.
 

Dippy

Moderator
My previous post:-
&quot;Careful shrouding/focussing/processing from a cheap/easily-available dual PIR sensor can also give directional info.&quot;

Note careful use of the word &quot;DUAL&quot;!!

As in the very, very, very common dual-element PIR sensor eg. Murata et al.

Gee, and I thought my specs were bad, tee hee!!!

If you process and view the wave produced by a moving target on a scope you will see how direction can be calculated. Using a slit or fresnel lens will magnify the effect. But if you've never tried it then you won't get my drift.

It does work - I've done it!! But only if you read my post properly.

But, hey, its Christmas - have a good time everyone!!
 

wilf_nv

Senior Member
Wearing specs and paying attention but I didn't see the light until Dippy &quot;teeheed&quot; me and made me dig a little deeper between the lines.

<A href='http://www.glolab.com/focusdevices/focus.html' Target=_Blank>External Web Link</a>

gives the hint I was looking for:

<i>A commonly used pyroelectric infrared sensor has two sensing elements internally connected in a voltage bucking configuration. </i>

So when exposed to a warm IR source, one of the two elements generates a positive polarity output signal while the other generates a negative going signal.

The module output signal is the sum of these two internal out of phase signals .

This is useful for the background radiation is detected equally on both elements and the two opposite signals cancel out. If one element is exposed to a PIR signal while the other element is not, it generates a signal which is not canceled and which appears on the module output pin.

As shown in the 3rd graphic, the module output signal reacts to a warm object entering the field of view and being detected first on the right element, by generating a positive pulse first while an object entering the field of view detected first on the left element generates a negative pulse first.

The polarity of the first pulse could therefore provide direction information.

For a warm object leaving the field the polarity of the last pulse could also be used for direction info.

Note that the polarity of the first and last pulse from each element are reversed.

Normally, a multi-facetted Fresnel lens is used because this lens causes many tiny moving images of warm objects in the field of view to be projected on on off the two PIR sensor elements. This results in a stream of positive and negative pulses from the module output making it easy to detect movement in the field of view.

This +/- pulse train of an object moving through middle of the field of view would be difficult to analyze.

A simple lens, pinhole, mask or baffle makes the output signals of the dual elements easier to analyze but reduces sensitivity.

When dealing with a pulse train, features such as differences in time between pulses or relative amplitudes might be used to determine which pulse belongs to which element. Another method might visually chop or superimpose a carrier signal or diffuse the aperture of one of the two elements to differentiate its output signal from the other element.

So it is possible but more difficult to use the summed output of a single PIR module with dual elements to determine direction of motion because it is not easy to determine which element is active at any time especially if signals overlap.

The analog signals from two separate PIR module outputs could be processed much more easily, for example, by measuring the phase relationship of the two pulse signals to determine direction and speed.

Thanks Dippy, next time I'll dig first and comment later to spare you another bout of the teehees.

On that note, to Dippy and everyone else on this wonderful forum: Enjoy! and not just now but always, goodwill to one and all.

wilf



Edited by - wilf_nv on 24/12/2006 03:17:23
 

Dippy

Moderator
Tee hee.

It was a long time ago I did it, before PICAXE was invented, (it was even pre-Stamp) so all was hardwired with op-amps and it worked quite well.
However, to anyone thinking of doing it using PICAXE ADC (dead easy) I would just say that a) don't expect high speed performance and b) the physical arrangement (focussing for example) is harder than the processing.
 
Top