November 23, 2024, 11:14:20 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.


Help adding PIR

Started by RosehallManor, October 11, 2009, 09:23:19 AM

Previous topic - Next topic

RosehallManor

Hey fellow haunters,

Last year I acquired a barrel spitter from a friend and it was programmed to use a pressure pad.  I decided to switch to a Parallax PIR this year.  I got the program om my friend and it is done using another type of IR sensor.  I have tried cutting and pasting the PIR segment from other progams with no success.  C someone help me to get this right??  Here is the program:

' INPUT_OUTPUT.BS1
' {$STAMP BS1}
' {$PBASIC 1.0}
'
'''''''''''''''''Barrel Spitter''''''''''''''''''''''''''''''
'There will be a IR sensor that will "see" the people
'and after a short delay make the corpse jump and spit.

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'output channels
SYMBOL lift = PIN1
SYMBOL spit = PIN2
SYMBOL IR = PIN7

'program constants
SYMBOL on             = 1
SYMBOL off            = 0
SYMBOL triggered      = 1
SYMBOL not_triggered  = 0

Begin:
'set up channels
  OUTPUT 0
  OUTPUT 1
  OUTPUT 2
  OUTPUT 3
  OUTPUT 4
  OUTPUT 5
  INPUT  6
  INPUT  7

'variables


Main:

IF  IR = not_triggered THEN Main   'Loop until photoeye is triggered

Start:
  'DEBUG "starting sequence", IR, CR


PAUSE 500             'delay .5 seconds before starting sequence

lift = on               'raise the corpse
PAUSE 3000              'corpse up 3.0 seconds

spit = on               'corpse spit
PAUSE 800               'spit for .8 seconds
spit = off              'stop spitting

PAUSE 1000              'pause 1 second

'spit = on              'corpse spit
'PAUSE 200              'spit for .2 seconds
'spit = off             'stop spitting

lift = off               'lower the corpse

'DEBUG "Done Sequence - Pausing before restart", CR

PAUSE 10000                'wait 10 seconds before checking pressure pad
'DEBUG "restarting program", CR

PAUSE 5000     ' Wait 5 seconds to repeat cycle


GOTO Main

'================[ subroutines ]======================

END










Thanks

JonnyMac

Okay, you almost NEVER need to use the keywords INPUT and OUTPUT in a prop-control program.  To setup IOs (inputs and outputs) you can do it in one fell swoop with the DIRS command (see code below).  Also, we recommend using P6 as the trigger input (pir, switch, whatever) as this allows programs like this to be tested on the Prop-1 Trainer.

BTW, inserting DEBUG statements is usually a last resort thing, too, as it does have a slight effect on timing (DEBUG on the BS1 processor is slow).

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


' -----[ Program Description ]---------------------------------------------
'
' Trigger :: Parallax-compatible PIR or N.O. button (mat switch, etc.)
'            -- connect N.O. button between P6.W and P6.R


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


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN

SYMBOL  Spit            = PIN2                  ' V+/OUT2
SYMBOL  Lift            = PIN1                  ' V+/OUT1


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  timer           = B2


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00000110                              ' setup IOs (1 = output)

  PAUSE 20000                                   ' PIR warm-up / reset delay


' -----[ Program 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

  Lift = IsOn                                   ' lift corpse
  PAUSE 3000

  Spit = IsOn                                   ' spit once
  PAUSE 800
  Spit = IsOff

  PAUSE 1000

  Spit = IsOn                                   ' spit twice
  PAUSE 200

  GOTO Reset                                    ' stop spit & drop


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


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


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

JonnyMac

BTW, the reason you were having trouble is that it seems your prop was originally designed for an active-low input, whereas the PIR is an active-high device.  Our standard template (used in the program above) deals with the PIR as needed.
Jon McPhalen
EFX-TEK Hollywood Office