November 17, 2024, 08:34:42 AM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


PIR trigger, with Optional Dry Contact Trigger

Started by John Wohlers, July 09, 2008, 04:22:56 PM

Previous topic - Next topic

John Wohlers

I am working on a prop that I would like to have multiple options for triggering.  I am planning on building in the standard PIR trigger, but I would also like the option to plug in a dry contact type trigger as well.   I am having a little difficulty trying to figure out what would be the best way of doing this.

The basic sequence of events would be, prop senses motion, or if the dry contact switch is plugged in  and pressed, prop triggers... sound triggers, solenoid fires for 10 seconds...  etc...

I understand the basic one trigger, play sound, etc... code sequences.  I plan on using an OR in the IF to check for triggering which should work correct?

What I am really having trouble with is how to wire in the 2nd optional trigger.  I was figuring it should be wired to  P5, (P7 being for audio, P6 for the PIR, OUT 0 for solenoid) which would mean I need to have a 4.7k resistor in the circuit tied to V+ to keep the input from floating. This would essentially act as if there was a setup jumper for P5 set to UP, correct?  Not having the external switch connected would then still not be a problem, correct?

Sorry if this is overly basic, but I'd rather not damage the prop-1, or spend enormous amounts of time figuring out why things are behaving differently than I think they should.

John \/\/ohlers

JonnyMac

Here's a starter program that can monitor/debounce a PIR connected to P6 and a normally-open pushbutton on P5 (use P5.W and P5.R).

' =========================================================================
'
'   File...... Dual_Trigger.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2008 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 09 JUL 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  PIR             = PIN6                  ' SETUP = DN
SYMBOL  Trigger         = PIN5                  ' ULN acts as pull-down


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

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0

SYMBOL  Baud            = OT2400


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

SYMBOL  timers          = W1
SYMBOL   pirTimer       = B2
SYMBOL   btnTimer       = B3


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00011111                              ' make P0-P4 outputs


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

Main:
  timers = 0                                    ' reset both timers

Check_Triggers:
  PAUSE 5                                       ' loop pad
  pirTimer = pirTimer + 5 * PIR                 ' update PIR timer
  IF pirTimer = 100 THEN Run_Show
  btnTimer = btnTimer + 5 * Trigger             ' update button timer
  IF btnTimer = 100 THEN Run_Show
    GOTO Check_Triggers

Run_Show:

  ' prop code here

  GOTO Main


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


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


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


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


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


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


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

John Wohlers

Thanks Jon.  I was not aware the ULN would also act as a pulldown.
John \/\/ohlers