May 20, 2024, 09:18:30 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.


Controling PIR output after triggering it

Started by MikeMac, October 06, 2010, 04:58:08 PM

Previous topic - Next topic

MikeMac

October 06, 2010, 04:58:08 PM Last Edit: October 07, 2010, 05:11:47 AM by MikeMac
I have a PIR going into a Prop 1 board to trigger relays on the RC-4 board.
When the PIR is triggered( by walking in front of its beam) it causes the relay to change states and turn on 120V to power a light. I set a PAUSE condition in the code so that the light stays on for 5 seconds after the PIR is triggered.

The problem i am finding is that when the PIR is triggered and the light goes on, I can still walk in front of the PIR and it seems to trigger it again so that when the 5 second PAUSE
is over the light turns on again immediately. The PIR seems to hold a HIGH until the PAUSE condition is over and then opens the relay again.

Any suggestions?

thnx

BigRez

It'll be a big help to see your code - without it, we'd be just guessing at a gazillion things that could be causing what you describe. (Well not a gazillion, but a whole bunch.)

gadget-evilusions

If your still in front of the pir, or near it, it very well could still be outputting to the Prop-1. You would either need to remove your self quickly from the area, or insert another pause statement after the light turns off to force some "off time" between triggers. In haunt situations where I have alot of customers all the time, this is what I have to do for my animatronics to not just continuously trigger.
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

JonnyMac

QuoteIm a newb and this is my first post.

Nobody cares and you get no sympathy or special treatment around here!  ;D  BTW, our forum guidelines -- that I'm guessing you skipped right over -- suggest that you don't identify yourself as a "newbie."  It's annoying.  ;)

PIRs are very difficult to test with, especially since they have a wide field-of-view and want to stay tripped once they are tripped.  You might want to "snoot" the PIR by putting it into a piece of PCV -- this limits the field-of-view for applications like yours.

And, as Mike points out, if you're having trouble with code it's a good idea to post it -- it's hard to troubleshoot what you cannot see.
Jon McPhalen
EFX-TEK Hollywood Office

MikeMac

October 07, 2010, 05:09:16 AM #4 Last Edit: October 07, 2010, 05:19:48 AM by MikeMac
' =========================================================================
'
'   File......  Activate Relays with PIR
'   Purpose...   Haloween Prop
'   Author....   Michael MacNeil , Andrew Grant
'   E-mail....
'   Started...    Sept.30,2010
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================

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

' Stepping in front of a PIR sensor will activate lights and a piston to move a Haloween prop.

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

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

SYMBOL PIR = PIN0

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

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0

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

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

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

Main:

IF PIR = IsOff THEN Main ' wait for PIR activity

SEROUT 6, OT2400, ("!RC4", %10, "R", 1, 1)        'turn on relays 1 and 2
SEROUT 6, OT2400, ("!RC4", %10, "R", 2, 1)

PAUSE 5000            ' wait 5 seconds      

SEROUT 6, OT2400, ("!RC4", %10, "X")       ' reset all relays


GOTO Main ' back to Main

JackMan

October 07, 2010, 06:24:05 AM #5 Last Edit: October 07, 2010, 06:27:49 AM by JackMan
Give this a try. Note your PIR needs to be on PIN6 and your serial connection to the RC-4 on PIN7. This program gives you a 60 second delay before the PIR can re-trigger the prop. It also gives you a 60 sec initial warm up needed for the PIR.

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

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

' Stepping in front of a PIR sensor will activate lights and a piston to move a Haloween prop.

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

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

SYMBOL Sio    = 7                               ' SETUP = UP; no ULN
SYMBOL PIR    = PIN6                         ' SETUP = DN

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

SYMBOL  IsOn   = 1
SYMBOL  IsOff   = 0

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

SYMBOL timer    = B2

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

Reset:
 PAUSE 60000                                ' PIR warm-up/post delay


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

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



 SEROUT Sio, OT2400, ("!RC4", %10, "R", 1, 1) 'turn on relays 1 and 2
 SEROUT Sio, OT2400, ("!RC4", %10, "R", 2, 1)
 PAUSE 5000                                                     ' wait 5 seconds
 SEROUT Sio, OT2400, ("!RC4", %10, "X")        ' reset all relays
 GOTO Reset


JonnyMac

You can turn on both relays like this:

  SEROUT 6, OT2400, ("!RC4", %10, "S", %0011)
Jon McPhalen
EFX-TEK Hollywood Office

MikeMac

October 07, 2010, 10:07:25 AM #7 Last Edit: October 07, 2010, 10:25:16 AM by MikeMac
Quote from: JackMan on October 07, 2010, 06:24:05 AM
Give this a try. Note your PIR needs to be on PIN6 and your serial connection to the RC-4 on PIN7. This program gives you a 60 second delay before the PIR can re-trigger the prop. It also gives you a 60 sec initial warm up needed for the PIR.

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

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

' Stepping in front of a PIR sensor will activate lights and a piston to move a Haloween prop.

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

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

SYMBOL Sio    = 7                               ' SETUP = UP; no ULN
SYMBOL PIR    = PIN6                         ' SETUP = DN

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

SYMBOL  IsOn   = 1
SYMBOL  IsOff   = 0

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

SYMBOL timer    = B2

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

Reset:
 PAUSE 60000                                ' PIR warm-up/post delay


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

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



 SEROUT Sio, OT2400, ("!RC4", %10, "R", 1, 1) 'turn on relays 1 and 2
 SEROUT Sio, OT2400, ("!RC4", %10, "R", 2, 1)
 PAUSE 5000                                                     ' wait 5 seconds
 SEROUT Sio, OT2400, ("!RC4", %10, "X")        ' reset all relays
 GOTO Reset



This is  a significant improvement. I have also housed the PIR in a 3" PVC end cap as suggested.
I still have these issues:
- I thought I read a PIR document that said the PIR sustains a HIGH output for 2 - 4 sec after it has been tripped. This seems to be the case because if I trip the PIR a few  secs before the 60 second PAUSE is over the Relays turn on at the end of the 60 sec PAUSE. Can I basically stop the PIR's output during the 60 sec PAUSE so that it can only effect the Relays after the PAUSE is over.
- I set up the Prop 1 board as described above. But I dont have a jumper for the SETUP section of P7. If I dont have a jumper on P7 is that the same as being in the UP position?
- What position should the jumper be on the PIR itself.. H or L?
         

BigRez

QuoteCan I basically stop the PIR's output during the 60 sec PAUSE so that it can only effect the Relays after the PAUSE is over.
Yes, you can add a small routine to make sure the trigger is off immediately after the pause.  Add this before Main: and after the PAUSE

TrigOff:
  IF PIR > 0 THEN TrigOff
   
   


QuoteIf I dont have a jumper on P7 is that the same as being in the UP position?
No jumper is the same as a jumper being on DN.  If you have one on pin6, you can use that one since the PIR should be in the down position anyway.  If not, perhaps you have a 2- or 3-wire jumper and can use that to short the two connections.

QuoteWhat position should the jumper be on the PIR itself.. H or L?
I normally have the jumper on the HIGH connection. This could be why the PIR remains high for a second or so after triggering.  The docs say that in the low position, the PIR will pulse the output high with each trigger - I wonder it it remains high for a second or so in this case.

JonnyMac

October 07, 2010, 10:45:57 AM #9 Last Edit: October 07, 2010, 10:49:28 AM by JonnyMac
I say this every year, at least a dozen times: PIRs are notoriously difficult to test with.  Period.  The cheap ones (like the Parallax unit we carry for customer convenience) are twitchy at best.

There is no way to tell the PIR to be off.  The jumper on the Parallax PIR does nothing (the guy who created that product did a sloppy, hurry-up job and it was never implemented).  

Now... what I have done in a couple of instances is created a little code section that waits for the PIR to be "quiet."  If you have a Bx variable you can get up to 25 seconds timing with this -- this code is set for 5 seconds of no output:

Wait_PIR_Quiet:
 timer = 0

PIR_Recheck
 PAUSE 100
 IF PIR = IsOn THEN Wait_PIR_Quiet
 timer = timer + 1
 IF timer < 50 THEN PIR_Recheck


This scans the PIR and will not drop through until there has been no output for 5s (50 x 100ms).  You can extend this by using a Wx variable.
Jon McPhalen
EFX-TEK Hollywood Office

JackMan


Quoteif I trip the PIR a few  secs before the 60 second PAUSE is over the Relays turn on at the end of the 60 sec PAUSE. Can I basically stop the PIR's output during the 60 sec PAUSE so that it can only effect the Relays after the PAUSE is over.

MikeMac,
   That is what the program is designed to do. It's giving you a 60 sec delay before the PIR can trigger the Prop-1. If someone trips the PIR just before the delay is over the program will execute if PIN6 is getting a signal from the PIR. If you need more than 60 seconds just add another PAUSE below the first one.

MikeMac

Quote
Wait_PIR_Quiet:
 timer = 0

PIR_Recheck
 PAUSE 100
 IF PIR = IsOn THEN Wait_PIR_Quiet
 timer = timer + 1
 IF timer < 50 THEN PIR_Recheck


This scans the PIR and will not drop through until there has been no output for 5s (50 x 100ms).  You can extend this by using a Wx variable.


Where would I insert this into the code?


JonnyMac

You're beginning to cobble things together without consideration of the final goal -- this "salad making" approach isn't always the best.  You've been presented with several possibilities, but they don't all belong together.  Read through the suggestions and use what's best to get the results you desire.
Jon McPhalen
EFX-TEK Hollywood Office

bsnut

Quote from: JackMan on October 08, 2010, 05:39:46 AM
Insert it right below the "PAUSE 60000" in Reset.
The reason behind this is to let the PIR warm up to good operating temp and provides pre-delay after the prop was triggered the first time.

The code that Jon wrote for you will be inserted in the area call "Program Code" just after the label named "Main:".

This should give you an idea were the code is inserted in the program.
William Stefan
The Basic Stamp Nut