November 15, 2024, 02:26:24 AM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Using several devices and several trigger!

Started by michilson, August 19, 2009, 11:30:06 AM

Previous topic - Next topic

michilson

Hey guy I just purchased my new prop 1 controlers and have a quick question.

Can i run 2 Pir on the Same Prop 1? I have 2 PIR and 2 Air valves that i want to fire in a random time pattern so here's the example.

PiR A = Air Valve 1
PiR B = Air Valve 2

When PIR A = On
Random Delay = 0-5 Sec
Air Valve 1 = On
Hold .0200 sec

When Pir B = On
Random Delay = 3-10 Sec
Air Valve 2 = On
Hold .02 sec

This is kinda what i'm thinking they arrive tomorrow night and will be starting to write my programing code and will post if i need help.

I also have a simular question with 2 Vmusic players and 2 Pir and 3 exteral relay's? I know im gettin close to the Prop 1 Input limits!

Thanks Guys!

JonnyMac

I'm going to go on the wild assumption that you want these to PIR/Valve circuits to run independently and concurrently.  Right?  It can be done, but it's not easy -- see below.

FWIW, I don't recommend one VMUSIC player on a Prop-1 (or -2 for that matter), two is out-of-the question.  If you need to run two VMUSIC players you're going to need to use a Prop-2 to handle all the serial messages required for two players.


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


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


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


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

SYMBOL  PIR2            = PIN7                  ' SETUP = DN
SYMBOL  PIR1            = 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

SYMBOL  S_WAIT          = 0                     ' waiting for trigger
SYMBOL  S_HOLDOFF       = 1                     ' random hold-off
SYMBOL  S_RUN           = 2                     ' valve run time
SYMBOL  S_DELAY         = 3                     ' off delay between cycles


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

SYMBOL  flags           = B0
SYMBOL   trigger1       =  BIT6                 ' PIR on P6
SYMBOL   trigger2       =  BIT7                 ' PIR on P7

SYMBOL  idx             = B1                    ' loop control
SYMBOL  state1          = B2
SYMBOL  timer1          = B3
SYMBOL  state2          = B4
SYMBOL  timer2          = B5

SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' preset IOs
  DIRS = %00000011                              ' define outputs (1s)


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

' Loop at Main creates 100ms delay which is the unit of timing
' for other aspects of the program.

Main:
  flags = %11000000                             ' assume active
  FOR idx = 1 TO 20
    flags = flags & PINS                        ' scan inputs
    PAUSE 5
    RANDOM lottery
  NEXT

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

Update_T1:
  IF timer1 = 0 THEN Check_State1               ' skip if timer not running
    timer1 = timer1 - 1                         '   else update

Check_State1:
  BRANCH state1, (V1_0, V1_1, V1_2, V1_3)       ' check state
  state1 = S_WAIT                               ' fix if broken

V1_0:                                           ' wait for trigger
  IF trigger1 = IsOff THEN Update_T2
    state1 = S_HOLDOFF
    timer1 = lottery // 50 + 1                  ' 0.1 to 5.0s
    GOTO Update_T2

V1_1:                                           ' random hold-off
  IF timer1 > 0 THEN Update_T2
    state1 = S_RUN
    timer1 = 2                                  ' 0.2s run
    Valve1 = IsOn
    GOTO Update_T2

V1_2:                                           ' valve on
  IF timer1 > 0 THEN Update_T2
    state1 = S_DELAY
    timer1 = 5                                  ' 0.5s delay
    Valve1 = IsOff
    GOTO Update_T2

V1_3:                                           ' delay before next trigger
  IF timer1 > 0 THEN Update_T2
    state1 = S_WAIT

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

Update_T2:
  IF timer2 = 0 THEN Check_State2
    timer2 = timer2 - 1

Check_State2:
  BRANCH state2, (V2_0, V2_1, V2_2, V2_3)
  state2 = S_WAIT

V2_0:
  IF trigger2 = IsOff THEN Main
    state2 = S_HOLDOFF
    timer2 = lottery // 101 + 30                ' 3s to 10s
    GOTO Main

V2_1:
  IF timer2 > 0 THEN Main
    state2 = S_RUN
    timer2 = 2
    Valve2 = IsOn
    GOTO Main

V2_2:
  IF timer2 > 0 THEN Main
    state2 = S_DELAY
    timer2 = 5
    Valve2 = IsOff
    GOTO Main

V2_3:
  IF timer2 > 0 THEN Main
    state2 = S_WAIT
    GOTO Main


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


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


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

michilson

John as always thanks this is a great help a few questions as im not quit sure i follow all of this coding completely!

They should be tripped one the a delay then the other but there is a chance that they may be both active at nearly the same time if that affects this code!

If i want to increase or decrease the Random Delay lottery i change it under the ((timer1 = lottery // 50 + 1)) correct?
And if i want to change the hold time on the valve thats in the constants?

This will need to be set up and then walked to see how long it take the group to scare to go from the PIR to the Air blast so i need to understand how to adjust the code to fit it's timing loop.

I'm hoping the the random will help the repeat people not get hit twice with it randomizing the time delay from the point of Pir trigger to the point when it shoots the air blast. I'm going to try to install these on corners where the delay will allow some mebers to get by before it goes off...

The other question is

Is there a way to make it not use the same delay twice? so i wont run into the same person getting the blast twice taking out the fact that they might get shuffled in the group.

Thanks for all your help!

As for the Vmusic players I'll only be running a background sound track so it's one song. As for what i've seen on scary tery's website it shouldn't be to to program. I dont really need to have the vmusice feed back to the Prop i'll know the length of the sound bit and if i loop it the it's just place a wait line of code for the time frame and then stop the music and reset for the next group.

I'll post those questions once all the parts arrive and i get it's wired up and working.

Thanks so much is there some reference material on here to help me learn the coding better?

Thanks
Michael Chilson
Brookdale Haunted Halls
Meadville PA

JonnyMac

The reason we price the Prop-1 so inexpensively is to allow the user to have one controller per prop; any time we try to squeeze two completely independent sets of control into a single controller the programming gets nightmarish as you can see above.

You can change any of the "timer =" lines in the program; you didn't specify a re-trigger delay (state 3 in the program) so I just fixed in to 0.5 seconds; you could randomize this as well.  I wouldn't worry about repeat timing as it's not very likely to happen and in the case where the prop uses RANDOM and with a PIR there will always be some additional randomness because the PIR will trip a little differently based on the person(s) approaching (size, exact location, etc.).

Please start a separate thread for any VMUSIC questions; per forum guidelines there should only be one topic per thread.
Jon McPhalen
EFX-TEK Hollywood Office