November 23, 2024, 05:52:12 PM

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.


Prop Dropper Plus

Started by HauntedWolf, June 15, 2010, 08:50:05 AM

Previous topic - Next topic

HauntedWolf

Hey all,

I've been thinking about doing a prop dropper similar to the one Lynn asked about in the thread "Program for my prop1", but I want to plus it a bit.   I do not have the servos yet, so this is an idea that I just have running around in my head...

The prop dropper has a continuous server glued to a normal servo's horn.  The continuous servo has a string wrapped around it's horn that hold a lightweight prop, like a spider or bat.  When activated, the normal servo turns 90 degrees which causes the string on the continuous servo to unwind and drop the prop.  After a few seconds, the normal servo returns to the starting position and the continuous servo winds the string back up.  Video here http://www.youtube.com/watch?v=MNBsZ0a2iDI

In my version there will be no lights, but there will be 3 prop droppers (6 servos total).  I will have a trigger...PIR probably...when activated I would like a random prop dropper to be chosen and run.  Maybe even randomly select 1 or more to run (or none at all?).  Basically, I want to have a few of these in a hallway so my repeat victims won't know which one will actually drop.  There will be some static spiders hanging to help disguise the real ones.

Looking at the code Jon posted in the thread "Program for my prop1" I can see how the prop dropper itself works.  How can I randomly choose a prop dropper and control it?

Thanks in advance!
Robert

Haunted Wolf Hollow - http://www.hauntedwolfhollow.com

JonnyMac

Here's an untested first cut.  It compiles fine, but will require fine-tuning of servo values for the drop angle and raise speed.  Timing for the raise sequence will need to be determined as well.  This should get you going, though.

Note that the desire to have three droppers and random selection means that we had to use all variables -- no more room for additional features (though I will try to figure out how to make multiples drop).

' =========================================================================
'
'   File......  Prop_Dropper_3x.BS1
'   Purpose...
'   Author....  Jon "JonnyMac" Williams, EFX-TEK
'   E-mail....  teamefx@efx-tek.com
'   Started...
'   Updated...  15 JUN 2010
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN

SYMBOL  Raise3          = 5
SYMBOL  Raise2          = 4
SYMBOL  Raise1          = 3
SYMBOL  Drop3           = 2
SYMBOL  Drop2           = 1
SYMBOL  Drop1           = 0


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

SYMBOL  IS_ON           = 1                     ' for active-high in/out
SYMBOL  IS_OFF          = 0

SYMBOL  SVO_RAISE       = 125                   ' raised position
SYMBOL  SVO_DROP        = 200                   ' dropped position

SYMBOL  CR_STOP         = 150                   ' not spinning
SYMBOL  CR_LIFT         = 125                   ' adjust for speed


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

SYMBOL  pos1            = B0
SYMBOL  pos2            = B1
SYMBOL  pos3            = B2
SYMBOL  spd1            = B3
SYMBOL  spd2            = B4
SYMBOL  spd3            = B5

SYMBOL  dropper         = B6                    ' servo we're working with
SYMBOL  last            = B7                    ' last to drop

SYMBOL  timer           = W4
SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00111111                              ' make P0-P5 outputs

  pos1 = SVO_RAISE                              ' initialize servos
  pos1 = SVO_RAISE
  pos3 = SVO_RAISE
  spd1 = CR_STOP
  spd2 = CR_STOP
  spd3 = CR_STOP

  timer = 30000
  GOSUB Servo_Pause                             ' warm-up/re-trigger delay


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  RANDOM lottery                                ' stir random #
  GOSUB Refresh_Servos                          ' update servos
  timer = timer + 20 * Trigger                  ' update trigger timer
  IF timer < 250 THEN Check_Trigger             ' wait for 0.25 sec input

Select_Dropper:
  RANDOM lottery                                ' re-stir
  dropper = lottery // 3 + 1                    ' select dropper, 1 to 3
  IF dropper = last THEN Select_Dropper         ' do not allow repeat
    last = dropper                              ' save for next time

Drop_1:
  IF dropper > 1 THEN Drop_2                    ' skip if not this one
    pos1 = SVO_DROP                             ' set to drop position
    GOTO Drop_Delay                             '  and do it

Drop_2:
  IF dropper > 2 THEN Drop_3
    pos2 = SVO_DROP
    GOTO Drop_Delay

Drop_3:
  pos3 = SVO_Drop

Drop_Delay:
  RANDOM lottery                                ' re-stir
  timer = lottery // 3001 + 2000                ' 2 to 5 secs, random
  GOSUB Servo_Pause                             ' hold for drop time

Raise_1:
  IF dropper > 1 THEN Raise_2                   ' skip if not this one
    pos1 = SVO_RAISE                            ' raise position
    spd1 = CR_LIFT                              ' start prop lift
    GOTO Raise_Delay

Raise_2:
  IF dropper > 2 THEN Raise_3
    pos2 = SVO_RAISE
    spd2 = CR_LIFT
    GOTO Raise_Delay

Raise_3:
  pos3 = SVO_RAISE
  spd3 = CR_LIFT

Raise_Delay:
  timer = 3000                                  ' set for raise timing
  GOSUB Servo_Pause                             ' do it

  GOTO Reset                                    ' reset everything


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

' Refreshes all servos; provides ~20ms delay

Refresh_Servos:
  PULSOUT Drop1, pos1
  PULSOUT Drop2, pos2
  PULSOUT Drop3, pos3
  PULSOUT Raise1, spd1
  PULSOUT Raise2, spd2
  PULSOUT Raise3, spd3
  PAUSE 11                                      ' pad to 20ms
  RETURN

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

' Use in place of PAUSE
' -- set delay value (ms) in "timer" before calling

Servo_Pause:
  IF timer < 20 THEN SP_Exit
    GOSUB Refresh_Servos
    timer = timer - 20
    GOTO Servo_Pause

SP_Exit:
  RETURN


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

JonnyMac

Okay, I updated the program for multiple droppers.  Note: In order to allow each dropper to have a different length they are raised one at a time.  You will need to set the timing for each to match the drop length.

This program should provide interesting guidance for those wanting to push the Prop-1 a little harder.

' =========================================================================
'
'   File......  Prop_Dropper_3xMulti.BS1
'   Purpose...
'   Author....  Jon "JonnyMac" Williams, EFX-TEK
'   E-mail....  teamefx@efx-tek.com
'   Started...
'   Updated...  15 JUN 2010
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN

SYMBOL  Raise3          = 5
SYMBOL  Raise2          = 4
SYMBOL  Raise1          = 3
SYMBOL  Drop3           = 2
SYMBOL  Drop2           = 1
SYMBOL  Drop1           = 0


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

SYMBOL  IS_ON           = 1                     ' for active-high in/out
SYMBOL  IS_OFF          = 0

SYMBOL  SVO_RAISE       = 125                   ' raised position
SYMBOL  SVO_DROP        = 200                   ' dropped position

SYMBOL  CR_STOP         = 150                   ' not spinning
SYMBOL  CR_LIFT         = 125                   ' adjust for speed


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

SYMBOL  pos1            = B0
SYMBOL  pos2            = B1
SYMBOL  pos3            = B2
SYMBOL  spd1            = B3
SYMBOL  spd2            = B4
SYMBOL  spd3            = B5

SYMBOL  dropper         = B6                    ' servo we're working with
SYMBOL  last            = B7                    ' last to drop

SYMBOL  check           = B8                    ' low byte of timer!

SYMBOL  timer           = W4
SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00111111                              ' make P0-P5 outputs

  pos1 = SVO_RAISE                              ' initialize servos
  pos1 = SVO_RAISE
  pos3 = SVO_RAISE
  spd1 = CR_STOP
  spd2 = CR_STOP
  spd3 = CR_STOP

  timer = 30000
  GOSUB Servo_Pause                             ' warm-up/re-trigger delay


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  RANDOM lottery                                ' stir random #
  GOSUB Refresh_Servos                          ' update servos
  timer = timer + 20 * Trigger                  ' update trigger timer
  IF timer < 250 THEN Check_Trigger             ' wait for 0.25 sec input

Select_Dropper:
  RANDOM lottery                                ' re-stir
  dropper = lottery // 8                        ' select droppers
  IF dropper = 0 THEN Select_Dropper            ' no blanks
  IF dropper = last THEN Select_Dropper         ' do not allow repeat
    last = dropper                              ' save for next time

Drop_1:
  check = dropper & %001                        ' this dropper active?
  IF check = 0 THEN Drop_2                      ' if not, skip
    pos1 = SVO_DROP                             ' set to drop position

Drop_2:
  check = dropper & %010
  IF check = 0 THEN Drop_3
    pos2 = SVO_DROP

Drop_3:
  check = dropper & %100
  IF check = 0 THEN Drop_Delay
    pos3 = SVO_DROP

Drop_Delay:
  RANDOM lottery                                ' re-stir
  timer = lottery // 3001 + 2000                ' 2 to 5 secs, random
  GOSUB Servo_Pause                             ' hold for drop time

Raise_1:
  check = dropper & %001                        ' this dropper active?
  IF check = 0 THEN Raise_2                     ' if not, skip
    pos1 = SVO_RAISE                            ' raise position
    spd1 = CR_LIFT                              ' start prop lift
    timer = 3000                                ' raise time for #1
    GOSUB Servo_Pause                           ' do it

Raise_2:
  check = dropper & %010
  IF check = 0 THEN Raise_3
    pos2 = SVO_RAISE
    spd2 = CR_LIFT
    timer = 3000                                ' raise time for #2
    GOSUB Servo_Pause

Raise_3:
  check = dropper & %100
  IF check = 0 THEN Reset
    pos3 = SVO_RAISE
    spd3 = CR_LIFT
    timer = 3000                                ' raise time for #3
    GOSUB Servo_Pause

  GOTO Reset                                    ' reset everything


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

' Refreshes all servos; provides ~20ms delay

Refresh_Servos:
  PULSOUT Drop1, pos1
  PULSOUT Drop2, pos2
  PULSOUT Drop3, pos3
  PULSOUT Raise1, spd1
  PULSOUT Raise2, spd2
  PULSOUT Raise3, spd3
  PAUSE 11                                      ' pad to 20ms
  RETURN

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

' Use in place of PAUSE
' -- set delay value (ms) in "timer" before calling

Servo_Pause:
  IF timer < 20 THEN SP_Exit
    GOSUB Refresh_Servos
    timer = timer - 20
    GOTO Servo_Pause

SP_Exit:
  RETURN


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

HauntedWolf

Leave it to me to push the Prop-1 to it's limits!  ;)

Thanks Jon, I'll give it try once I have everything....
Robert

Haunted Wolf Hollow - http://www.hauntedwolfhollow.com

JonnyMac

Note, too, that you can mix-and-match.  You could use the beginning part of the first program to drop just one prop (randomly, of course) and then the latter half of the second program to (a bit modified) to raise the prop; this would let you have individual drop lengths for each output.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Here's an improved version of the first program (one prop drops per trigger); this version uses BRANCH instead of IF-THEN to route the code.

' =========================================================================
'
'   File......  Prop_Dropper_3x_v2.BS1
'   Purpose...
'   Author....  Jon "JonnyMac" Williams, EFX-TEK
'   E-mail....  teamefx@efx-tek.com
'   Started...  15 JUN 2010
'   Updated...  16 JUN 2010
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN

SYMBOL  Raise3          = 5                     ' servo channels
SYMBOL  Raise2          = 4
SYMBOL  Raise1          = 3
SYMBOL  Drop3           = 2
SYMBOL  Drop2           = 1
SYMBOL  Drop1           = 0


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

SYMBOL  IS_ON           = 1                     ' for active-high in/out
SYMBOL  IS_OFF          = 0

SYMBOL  SVO_RAISE       = 125                   ' raised position
SYMBOL  SVO_DROP        = 200                   ' dropped position

SYMBOL  CR_STOP         = 150                   ' not spinning
SYMBOL  CR_LIFT         = 125                   ' adjust for speed


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

SYMBOL  pos1            = B0
SYMBOL  pos2            = B1
SYMBOL  pos3            = B2
SYMBOL  spd1            = B3
SYMBOL  spd2            = B4
SYMBOL  spd3            = B5

SYMBOL  dropper         = B6                    ' target channel
SYMBOL  last            = B7                    ' last dropped

SYMBOL  timer           = W4
SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00111111                              ' make P0-P5 outputs

  pos1 = SVO_RAISE                              ' initialize servos
  pos1 = SVO_RAISE
  pos3 = SVO_RAISE
  spd1 = CR_STOP
  spd2 = CR_STOP
  spd3 = CR_STOP

  timer = 30000
  GOSUB Servo_Pause                             ' warm-up/re-trigger delay


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  RANDOM lottery                                ' stir random #
  GOSUB Refresh_Servos                          ' update servos
  timer = timer + 20 * Trigger                  ' update trigger timer
  IF timer < 250 THEN Check_Trigger             ' wait for 0.25 sec input

Select_Dropper:
  RANDOM lottery                                ' re-stir
  dropper = lottery // 3                        ' select channel, 0 to 2
  IF dropper = last THEN Select_Dropper         ' do not allow repeat
    last = dropper

Drop_Prop:
  BRANCH dropper, (Drop_1, Drop_2, Drop_3)
  GOTO Reset

Drop_1:
  pos1 = SVO_DROP                               ' set to drop position
  GOTO Drop_Delay                               '  and do it

Drop_2:
  pos2 = SVO_DROP
  GOTO Drop_Delay

Drop_3:
  pos3 = SVO_Drop

Drop_Delay:
  RANDOM lottery
  timer = lottery // 2001 + 3000                ' 3 to 5 secs, random
  GOSUB Servo_Pause                             ' hold for drop time

Raise_Prop:
  BRANCH dropper, (Raise_1, Raise_2, Raise_3)
  GOTO Reset

Raise_1:
  pos1 = SVO_RAISE                              ' raise position
  spd1 = CR_LIFT                                ' start prop lift
  timer = 3000                                  ' raise time for #1
  GOSUB Servo_Pause                             ' do it
  GOTO Reset

Raise_2:
  pos2 = SVO_RAISE
  spd2 = CR_LIFT
  timer = 3000                                  ' raise time for #2
  GOSUB Servo_Pause
  GOTO Reset

Raise_3:
  pos3 = SVO_RAISE
  spd3 = CR_LIFT
  timer = 3000                                  ' raise time for #3
  GOSUB Servo_Pause
  GOTO Reset


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

' Refreshes all servos; provides ~20ms delay

Refresh_Servos:
  PULSOUT Drop1, pos1
  PULSOUT Drop2, pos2
  PULSOUT Drop3, pos3
  PULSOUT Raise1, spd1
  PULSOUT Raise2, spd2
  PULSOUT Raise3, spd3
  PAUSE 11                                      ' pad to 20ms
  RETURN

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

' Use in place of PAUSE
' -- set delay value (ms) in "timer" before calling

Servo_Pause:
  IF timer < 20 THEN SP_Exit
    GOSUB Refresh_Servos
    timer = timer - 20
    GOTO Servo_Pause

SP_Exit:
  RETURN


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