May 20, 2024, 08:33:24 AM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Using a PIR Sensor

Started by JonnyMac, February 13, 2007, 10:16:11 AM

Previous topic - Next topic

JonnyMac

Some PIR sensors can have a bit of "ragged" output which, under some circumstances, can lead to false triggering.  A simple way to prevent false triggering of your prop is to wait until the PIR signal is present for at least 1/4 second -- very short in human terms, but a very long time in microcontroller terms.  A neat little math trick, called "combinatorial logic" lets us update or clear the PIR timer variable with one line of code.

' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  PIR             = PIN6                  ' SETUP = DN


' -----[ Constants ]-------------------------------------------------------

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0


' -----[ Variables ]-------------------------------------------------------

SYMBOL  pirTimer        = B2


' -----[ Initialization ]--------------------------------------------------

Reset:


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

Main:
  pirTimer = pirTimer + PIR * PIR
  PAUSE 10
  IF pirTimer < 25 THEN Main

  ' control code here

  END


' -----[ Subroutines ]-----------------------------------------------------


' -------------------------------------------------------------------------


' -------------------------------------------------------------------------


' -------------------------------------------------------------------------


' -------------------------------------------------------------------------


' -------------------------------------------------------------------------


' -----[ EEPROM Data ]-----------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

clinefx1

If I wanted even more protection from false triggers is it as eazy as changing " IF pirTimer < 25 THEN Main" to  IF pirTimer < 35 THEN Main?


Chris

JonnyMac

Yes, what you're doing is forcing the program to look for a longer "on" time before triggering your device.  We also recommend shielding PIRs in PVC pipe.  Our friend, "Scary" Terry Simmons did a great write-up on his web site: http://www.scary-terry.com/itw/pirsensor/pirsensor.htm
Jon McPhalen
EFX-TEK Hollywood Office