November 22, 2024, 03:30:59 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.


program for lab dog from hell

Started by leucus, September 09, 2007, 09:42:55 AM

Previous topic - Next topic

leucus

Hey john, (just kidding) Jon, first time i have posted myself from bransons haunted adventure park.  I would like to take you up on your offer to write a program for a more complex prop we are building.  We have been able to get a bunch of simple prop 1s up without any major problems but this one is more complex.  We are getting very good at modifying existing codes off the forums and ones you have wrote.  Below is a summary of the props actions.
Description:
large wooden crate (48"l, 30"w, 36"t) is sitting angled into the hallway of our lab animal kennel area.  lighting is subdued leds and scene is high gore, cages are torn open, blood, fur everywhere.  genetic testing is theme for this area of the haunt.  as guest approach pir sets prop off which causes crate door to slide to right in metal track powered by pneumatic cylinder, pause to allow door to definetly clear but not long enough to lose scare value.  deformed dog extends out on large pneumatic about 30 inches and a second cylinder then makes it move up and down giving an attacking motion.  i would like to trigger sound as soon as the door slides open and keep the prop active for 10 seconds and then stay inactive  for 20 seconds to prevent retriggering by guest.  The up and down motion of the third cylinder needs to be eratic throughout the extention of the second cylinder.  the crate door slides shut after cylinder two ceases and pulls dog back into crate.  This needs to happen with enough delay to make sure dog has made it home.

pin usage and description:
pin6 = pir
pin7 = sound Ap8
pin0 = door slide cylinder
pin1 = dog extention cylinder ( we could make this cylinder move a little throughout the cycle to give a more realistic look)
pin2 = dog attack up and down cylinder

jon this is my first post so be nice and i hope i got it descriptive enough for you.  let me know if you need anything else (call me on my cell if you want i am sure you have the number).  will look forward to the post and thanks for all the constant help

JonnyMac

What!  I'm always nice (just because I'm an actor and live in Hollywood that doesn't mean I'm phoney nice like that Rosy O'Donnell).   ;D

The program is actually simpler to execute than you think.  Have a look:

' =========================================================================
'
'   File...... Lab_Dog.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated...
'
'   {$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  Jumper          = PIN2                  ' jumper cylinder
SYMBOL  BadDog          = PIN1                  ' dog extender
SYMBOL  Slider          = PIN0                  ' door slider


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

SYMBOL  IsOn            = 1
SYMBOL  IsOpen          = 1
SYMBOL  IsOut           = 1

SYMBOL  IsOff           = 0
SYMBOL  IsClosed        = 0
SYMBOL  IsHidden        = 0


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

SYMBOL  timer           = W4
SYMBOL  lottery         = W5                    ' random value


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

Reset:
  PINS = %00000000                              ' all off
  DIRS = %00000111                              ' set outputs

  PAUSE 20000                                   ' warm-up / retrigger delay
  timer = 0                                     ' clear timer for PIR


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

Main:
  RANDOM lottery                                ' stir random value
  PAUSE 10
  timer = timer + 10 * PIR                      ' update PIR timer
  IF timer < 250 THEN Main                      ' wait for valid signal

  SEROUT Sio, OT2400, ("!AP8", %00, "P", 0)     ' start audio

  Slider = IsOpen
  PAUSE 500                                     ' adjust for effect

  BadDog = IsOut
  PAUSE 1000                                    ' allow extension

Jump_Around:
  FOR timer = 1 TO 170                          ' 170 x 50 ms = 8.5 secs
    RANDOM lottery                              ' restir random value
    Jumper = lottery                            ' lottery.0 --> Jumper
    PAUSE 50
  NEXT

  Jumper = IsOff
  BadDog = IsHidden
  PAUSE 1500                                    ' allow full retractions

  GOTO Reset


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


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


' -----[ EEPROM Data ]-----------------------------------------------------


Note that by using the PINx definitions and setting output pins manually with DIRS we can just write values (1 for on, 0 for off) to output pins.  This is what makes the jumper work.  We go into a FOR-NEXT loop and re-stir the random number, then copy that number to the output.  Since an output pin is just one bit, what we're actually doing is copying BIT0 of lottery to the pin; since lottery is changing each time through the loop we get random bouncing on that pin.  You can run the program on a trainer board to see the action of the outputs (just a test without audio).

Suggestions: Mount the PIR and speaker in the box with the dog; PIRs are twitch and have a wide field of view so you want to limit the PIR's field such that your "victims" are right in front of the box before it activates.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

September 09, 2007, 11:53:57 AM #2 Last Edit: September 09, 2007, 11:58:01 AM by JonnyMac
Here's another way to do the jumping that gives better resolution (the one above is 50 ms, this one is 1 ms) -- while this method is a bit trickier and uses an extra variable, I think it works best and it's how I do things (those that have seen the Chucky prop have seen this in action).

' =========================================================================
'
'   File...... Lab_Dog_v2.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated...
'
'   {$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  Jumper          = PIN2                  ' jumper cylinder
SYMBOL  BadDog          = PIN1                  ' dog extender
SYMBOL  Slider          = PIN0                  ' door slider


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

SYMBOL  IsOn            = 1
SYMBOL  IsOpen          = 1
SYMBOL  IsOut           = 1

SYMBOL  IsOff           = 0
SYMBOL  IsClosed        = 0
SYMBOL  IsHidden        = 0


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

SYMBOL  delay           = B2                    ' for random delays
SYMBOL  timer           = W4
SYMBOL  lottery         = W5                    ' random value


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

Reset:
  PINS = %00000000                              ' all off
  DIRS = %00000111                              ' set outputs

  PAUSE 20000                                   ' warm-up / retrigger delay
  timer = 0                                     ' clear timer for PIR


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

Main:
  RANDOM lottery                                ' stir random value
  PAUSE 10
  timer = timer + 10 * PIR                      ' update PIR timer
  IF timer < 250 THEN Main                      ' wait for valid signal

  SEROUT Sio, OT2400, ("!AP8", %00, "P", 0)     ' start audio

  Slider = IsOpen
  PAUSE 500                                     ' adjust for effect

  BadDog = IsOut
  PAUSE 1000                                    ' allow extension

  timer = 0                                     ' clear timer for jumping

Keep_Jumping:
  Jumper = Jumper ^ 1                           ' togger jumper pin
  RANDOM lottery                                ' re-stir
  delay = lottery // 201 + 50                   ' make 50 to 250
  PAUSE delay
  timer = timer + delay                         ' update jump timer
  IF timer < 8500 THEN Keep_Jumping             ' go for 8.5 secs

  Jumper = IsOff
  BadDog = IsHidden
  PAUSE 1500                                    ' allow full retractions

  GOTO Reset


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


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


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

leucus

hey Jon, thanks for the fast reply, do have one dumb question, does the program allow for the slider to close back?  i would assume it will, due to the all pins off status in reset.  Is this a correct assumption?

JonnyMac

You are correct -- when the program jumps back to the Reset section all outputs are cleared and the sliding door will close.
Jon McPhalen
EFX-TEK Hollywood Office