November 22, 2024, 07:27:31 PM

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.


Help with two Separate actions

Started by eboomer, October 28, 2009, 04:23:46 PM

Previous topic - Next topic

eboomer

well i have two props but does the same thing.  when the unsuspecting person trips the sensor, a well directed nozzle of air is shot at the person.  i have these at two different places in my haunt.  i tried to write a program to have them separately work or should i say independently but i can't work it right.  i had my laptop in the garage where i have the controller and wouldn't you know it, knocked it over and killed it.  i think the hard drive took a dive.  so now i am starting at zero!  help at this latter stage of the game would be a plus! 

BigRez

You're gonna be asked to provide details... 

What kind and how many sensors? 
Are they both run from the same prop-1? 
How is the air blasted at the person?
How long does the air blast? 
Is there a delay between blasts?

Sorry about the hard-drive. 

eboomer

i have two pir sensors at to different locations.
they are both connected to prop 1
i need for them to act independently because the sensors are set in two separate rooms.
a blast of air will shoot down when they trip the pir sensor in a 3 second burst.  ( i can adjust to desired time)
the reason for the independent workings is because two different rooms with people at various different times, thus it has to reset afterwards.

the program that was left back on the prop 1 failed miserably.  evidently the program that i had put in it kept the air flowing throught the 12v solenoids and attempted to reset but never made it.  i had borrowing a laptop that doesn't have a serial port!  rummaging through my prop 1 parts box for my usb to serial. i know i have it somewhere!  any help would definitely be appreciated!  sorry for the rambling!

JonnyMac

Yes, rambling is not helpful.  Please be concise and specific with future requests -- it makes life easier for us all.

As to this request; what you're asking is more difficult than you think.  Here's the answer -- but be careful not to modify it until you fully understand how the program behaves.  Note that blaster timing is done in 0.1-second increments based on the trigger scan timing.  When a trigger is active the blaster runs for 1 - 2 seconds.  After that there is a random delay of 5 to 10 seconds to prevent immediate re-triggering.

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


' -----[ Program Description ]---------------------------------------------
'
' Trigger2 :: Parallax-compatible PIR or N.O. button (mat switch, etc.)
'             -- connect N.O. button between P7.W and P7.R
'
' Trigger1 :: 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  Trigger2        = PIN7                  ' SETUP = DN
SYMBOL  Trigger1        = PIN6                  ' SETUP = DN

SYMBOL  Valve2          = PIN1
SYMBOL  Valve1          = PIN0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  triggers        = B0
SYMBOL   tr2            =  BIT7
SYMBOL   tr1            =  BIT6

SYMBOL  idx             = B2

SYMBOL  timer2          = W3
SYMBOL  timer1          = W4
SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00000011                              ' set output pins


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

Main:
  triggers = %11000000                          ' arm T1 and T2 for scan
  FOR idx = 1 TO 20                             ' 100ms scan (20 x 5ms)
    RANDOM lottery
    PAUSE 5
    triggers = triggers & PINS                  ' scan inputs
  NEXT


Check_Timer1:
  IF timer1 = 0 THEN Check_Trigger1             ' timer running?
    timer1 = timer1 - 1                         ' yes, decrement
    IF timer1 > 0 THEN Check_Timer2             ' done?
      IF Valve1 = IsOff THEN Check_Timer2       ' yes, check valve
        Valve1 = IsOff                          ' turn off (if running)
        RANDOM lottery
        timer1 = lottery // 51 + 50             ' set random hold-off
        GOTO Check_Timer2

Check_Trigger1:
  IF tr1 = No THEN Check_Timer2                 ' skip if no trigger
    Valve1 = IsOn                               ' activate valve
    RANDOM lottery
    timer1 = lottery // 11 + 10                 ' set random burst


Check_Timer2:
  IF timer2 = 0 THEN Check_Trigger2             ' timer running?
    timer2 = timer2 - 1                         ' yes, decrement
    IF timer2 > 0 THEN Main                     ' done?
      IF Valve2 = IsOff THEN Main               ' yes, check valve
        Valve2 = IsOff                          ' turn off (if running)
        RANDOM lottery
        timer2 = lottery // 51 + 50             ' set random hold-off
        GOTO Main

Check_Trigger2:
  IF tr2 = No THEN Main                         ' skip if no trigger
    Valve2 = IsOn                               ' activate valve
    RANDOM lottery
    timer2 = lottery // 11 + 10                 ' set random burst
    GOTO Main


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


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


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