# A PIR That Actually WORKS With the Prop1!



## Zombie-F (Apr 12, 2004)

I think I've found a PIR that actually works extremely well with the propx line of controllers from EFX-TEK! If you have ever tried using the Parallax PIR that EFX-TEK sells on their web site you know first-hand that product sucks for motion detection. It throws out a fairly consistent string of "false triggers" where it thinks it saw motion when it in fact did not.

I was browsing the Sparkfun web site a while back and came across a PIR that runs on 5 - 12 VDC and has a 3-pin connector that will mate to the Prop1 controllers header pins. *CHECK IT OUT*. The best part is this PIR is the same price as the Parallax unit!








I got a few for x-mas from my brother (because I'm THAT nerdy). I've been meaning to test them out for some time to compare them against the Parallax PIRs that constantly throw false triggers (effectively making them useless).

This evening, I finally got around to getting them running and testing them out.

For starters, the wiring on them is not meant to work on the Prop1 out of the box. The +5V and ground pins on the PIR are reverse of where they are on the prop1's header pins. To remedy this, I simply cut three wires and spliced them together with the red and brown wires reversed. *It should be noted that on this PIR, RED is +5V, BROWN is Ground and Black is Signal.*








The alarm (signal) pin is an open collector meaning you will need a pull up resistor on the prop1 pin you connect the PIR to. For my test, I used PIN7 on the Prop1 and put the jumper to UP.

I wrote a simple snippet of code that will simply display the status of the PIR in a debug window:


```
' {$STAMP BS1}
' {$PBASIC 1.0}

' -----[ I/O Definitions  ]-------------------------------------------------
'
SYMBOL PIR = PIN7 ' 1 = No motion; 0 = motion detected


' -----[ Program Code  ]----------------------------------------------------
'
Main:
DEBUG CR, PIR ' display PIR status
GOTO Main
END
```
This PIR works opposite of how the Parallax PIR functions. When there is no motion and the PIR has settled down after startup, it will return a "1". Whenever it detects motion, it will return a "0."

Even without any debouncing (users of the Parallax PIR will know that term) there are hardly any false triggers. I watched the screen for a full minute with the PIR pointing away from me and saw (maybe) 1 or 2 false triggers. Every time I waved my hand past the unit, it would trigger a short burst of "0s" to the debug window and settle back down to "1's" shortly thereafter.

I was even able to get it to detect my motion from across the room (about 10' away).

Now, what does this mean? It simply means there is now a good alternative to the parallax PIR that can be used with a prop1 controller. I will still prefer Pete's dandy IR breakbeam over this because it's so cheap to build, but in cases when having a separate transmitter and receiver pair is too cumbersome or if you can't solder or read a schematic, this will work very well.


----------



## morbidmike (Sep 11, 2009)

holy crap I wish I understood this stuff better it seem's so awsome I'm an electrician but do not understand electronics pretty much at all Otaku had to make me a schematic for led lights does that make me basic lol....great post Zombie F


----------



## heresjohnny (Feb 15, 2006)

If you are nerdy, what does that make me? Wait, don't answer that.

How do you think it would work with small to medium sized animals? I am trying to scare some beavers away and heard that noise works, just need a decent trigger.


----------



## fritz42_male (May 5, 2009)

No need to cut and splice the wires, use a sewing pin and lift the locking tab and pull the wire and pin out. Do this with all 3 pins then rearrange and put back.

This is an OK unit but I ended up buying some similar units off an Aussie supplier that work 'the right way round' in that detection is high but they also have a little timer that helps prevent spurious triggers.

http://www.futurlec.com.au/Sensors/PIR_Module.jsp


----------



## Dr Morbius (Sep 21, 2004)

CRAP! I wish I knew about these BEFORE I finished and submitted my last Hauntcast segment...There I answer a Q about Prop sensors. I would have given these a mention for sure.


----------



## Zombie-F (Apr 12, 2004)

I've been experimenting with this some more this evening and writing code that will help debounce it. Since the output is inverted (0 is what is returned to the prop controller when it is triggered) the typical debounce code doesn't work.

I have also experimented with the fresnel lens removed and found that the detection is less sensitve and focused more without the lens. The lens makes it so the PIR detects motion over a greater angle so if you want the detection less sensitive removing the lens will work for that.

The following program will keep polling the input of PIN7 until the PIR is triggered for about 1/4 of a second. You can re-use the beginning of this program (everything before the Light: label) for your own needs and just delete the LED portion of the code as it is only there to give a visual feedback without using a debug window.


```
' {$STAMP BS1}
' {$PBASIC 1.0}
' ============================================================================
'
' Code © 2010 Unpleasant Street
' File....... PIR Test With LED.bs1
' Purpose.... Program to demo the Sparkfun PIR along with my own version of
' a debounce code to work with the inverted output state of this PIR.
' Author..... David Lindblom
' E-mail..... [email protected]
'
' ============================================================================

' -----[ Program Description ]------------------------------------------------
'
' This is a PROP-1 program designed to demonstrate how the Sparkfun PIR
' could be used in place of the Parallax PIR.  Code includes a version of
' debouncing that will work with the inverted (0 = trigger) output of this
' PIR unit.

' -----[ Revision History ]---------------------------------------------------
'
' PIR Test With LED.bs1 - March 26, 2010 - First Version.

' -----[ I/O Definitions ]----------------------------------------------------
'
SYMBOL  LED             = 0             ' LED attached to OUT0 with 470 ohm R
SYMBOL  PIR             = PIN7          ' 1 = No motion; 0 = motion

' ----[ Constants ]-----------------------------------------------------------
SYMBOL  scanDelay           = 8         ' Set time between PIR scans (in ms)

' -----[ Variables ]----------------------------------------------------------
'
SYMBOL  pirTime             = B2        ' For timing debounce of PIR
SYMBOL  fader               = B3        ' For timing of LED fade


' -----[ Program Code ]-------------------------------------------------------
'

Reset:
PAUSE 20000                            ' Allow PIR to stabilize for 20 seconds
                                       ' as well as delay between shows.

Main:
FOR pirTime = 1 TO 3                   ' Checks to make sure PIR is actually
PAUSE scanDelay                        ' Triggered for 1/4 second.  8ms x 3
IF PIR = 1 THEN Main                   ' If PIR is off, go back to main.
NEXT

Light:
' The LED Code is here just to try out the PIR.  Insert your own program code
' here in place of this.
HIGH LED                               ' Turn LED on
PAUSE 5000
FOR fader = 250 TO 0 STEP -5           ' Decrease brightness level.
    PWM LED, fader, 5                  ' Modulate LED off.
  NEXT
LOW LED
GOTO Reset

END
```


----------



## gmacted (Jan 18, 2006)

Nice find Zombie-F! I've been looking for a good PIR replacement for my audio players. Maybe you can bring them as a demo item for the next MA Make and Take. I would love to see them in action.


----------



## Zombie-F (Apr 12, 2004)

Will do! I need to install one into the deer head prop so I'll bring that along and one just hooked up to a prop1 and LED.


----------



## hpropman (Jul 27, 2008)

Zombie can you measure the voltage on the pin while it is high is it 3.3volt or 5 volt - when I use the parallax unit with the picaxe I add two transistors to change the 3.3v trigger pulse to 5 volts. I think that is the reason for all the false triggers with the parallax unit. With the single conditioning transistors I do not get any false triggers. 3.3 volts can can be seen as high or low by the controller depending on how the voltage fluctuates.


----------



## JonnyMac (Apr 5, 2007)

All PIRs are twitchy to one degree or another, the Parallax PIR is no better or worse than any other I've used. That's why we always recommend deboucing the PIR input. This code also works to prevent false triggers when long wire runs are used in electrically-noisy environments.

At the top of my Prop-1 programs you'll find this code:


```
Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

  ' prop code here
```
The Check_Trigger loop ensures that the trigger is on -- and stays on -- for at least 100ms; this defeats spurious outputs from PIRs and noise pulses picked up from long wire runs.


----------

