November 22, 2024, 10:20:54 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.


New Task to Raise the dead in a coffin.

Started by Wraithrat, October 12, 2008, 10:49:52 PM

Previous topic - Next topic

Wraithrat

I have applied your code to the next task I have which is to raise coffin doors then raise a skeleton from the coffin and play one of 8 random sounds as in the first example you gave me.  Following the sounds there will be a slight pause then lower the skeleton and finally close the doors.  I am using another PIR as the trigger.  I have coded the following and set everything up but get no response when I deploy the PIR.  Any suggestions for troubleshooting?  Thanks.

'==========================================================================
'
'   File......ALBER PROP.BS1
'   Purpose...
'   Author....Dennis Owen
'             Assisted by Jon Williams, EFX-TEK
'             Copyright (c) 2008 EFX-TEK
'             Some Rights Reserved
'             --see http://creativecommons.org/licenses/by/3.0/
'   E-mail....dhowen@sfcn.org
'   Updated...12 OCT 2008
'   {$STAMP BS1}

'=========================================================================

'------[ Program Description ]---------------------------------------------
' 1/2 Coffin Prop coming out of ground that opens doors, raises a skeleton
' (Albert) then follows with one of 8 different random screams.  Albert
' then is lowered back into his coffin and the doors close.  Prop is
' triggered with a PIR from EFX-TEK.

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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN (PIR)

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

SYMBOL  IsOn            = 1                     ' active-high
SYMBOL  IsOff           = 0

SYMBOL Yes              = 1
SYMBOL NO               = 0

SYMBOL  Baud            = OT2400               ' B/R jumper removed

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

SYMBOL  relays          = B0
SYMBOL  Doors           = BIT0
SYMBOL  Albert          = BIT1

SYMBOL  status          = B1
SYMBOL  Playing         = BIT15

SYMBOL  sfx             = B2                    ' sound fx segment
SYMBOL  last            = B3

SYMBOL   timer          = W4
SYMBOL   lottery        = W5                    ' random #


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00000000                              ' set outputs

  SEROUT Sio, Baud, ("!!!!!!!AP8", %00, "X","!RC4", %00, "X")
  relays = %0000

  PAUSE 30000                                   ' PIR warm-up / slow delay


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

Main:
  Timer = 0                                  ' reset the PIR timer

Check_Trigger:
  RANDOM lottery
  PAUSE 5                                    'loop pad
  timer = timer + 5 * Trigger                ' update timer
  IF timer  < 100 THEN Check_Trigger         ' wait for 0.1 sec input

Open_Doors:
  Doors = IsOn                               'open doors (Relay 1)
  GOSUB Set_RC4
  PAUSE 10                                   ' delay for 1 seconds

Raise_Albert:
  GOSUB Random_AP8                           ' play random scream
  Albert = IsOn                              ' bring Albert up (Relay 2)
  GOSUB Set_RC4
  GOSUB wait_AP8                             ' let scream finish
  PAUSE 30                                   ' wait for another 3 secs
  Albert = IsOff                              ' Lay Albert back down to rest
  GOSUB Set_RC4
  PAUSE 10                                   ' wait for Albert to retract
  Doors = IsOff                              ' Close doors (Relay 1)
  GOSUB Set_RC4

  GOTO Reset

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

Random_AP8:
  RANDOM lottery
  sfx = lottery // 8
  IF sfx = last THEN Random_AP8             'don't repeat sfx
    last = sfx                              ' save for next cycle

  ' drops through to Play_AP8

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

Play_AP8:
  SEROUT Sio, Baud, ("!AP9", %00, "P", sfx)
  RETURN

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

' wait for AP8 to finish

Wait_AP8:
  PAUSE 70
  SEROUT sio, baud, ("!AP8", %00, "G")
  SERIN  sio, baud, status
  IF playing = Yes THEN Wait_AP8
    RETURN

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

Set_RC4:
  SEROUT Sio, Baud, ("!RC4", %00, "S", relays)
  RETURN
' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------

JonnyMac

Hints:
* Add a DEBUG line after the trigger section to see if you're getting a PIR trigger or not
* Make sure you have the B/R, A1, and A0 jumpers removed from the AP-8 and RC-4
* The RC-4 should be connected to the Prop-1 (for power), the AP-8 connected to the RC-4
* Check the polarity of your WRB wires -- it's easy to plug them in backward

Your program has some subtle errors.  You were using PAUSE 10 instead of PAUSE 1000 in a couple places, and you had "AP9" instead of "AP8" in your play command.  Copy this version and give it a try.


' ==========================================================================
'
'   File......ALBER PROP.BS1
'   Purpose...
'   Author....Dennis Owen
'             Assisted by Jon Williams, EFX-TEK
'             Copyright (c) 2008 EFX-TEK
'             Some Rights Reserved
'             --see http://creativecommons.org/licenses/by/3.0/
'   E-mail....dhowen@sfcn.org
'   Updated...12 OCT 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
' =========================================================================

' -----[ Program Description ]---------------------------------------------
'
' 1/2 Coffin Prop coming out of ground that opens doors, raises a skeleton
' (Albert) then follows with one of 8 different random screams.  Albert
' then is lowered back into his coffin and the doors close.  Prop is
' triggered with a PIR from EFX-TEK.


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN (PIR)


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

SYMBOL  IsOn            = 1                     ' active-high
SYMBOL  IsOff           = 0

SYMBOL  Yes             = 1
SYMBOL  N0              = 0

SYMBOL  Baud            = OT2400               ' B/R jumper removed


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

SYMBOL  relays          = B0
SYMBOL   Doors          =  BIT0
SYMBOL   Albert         =  BIT1

SYMBOL  status          = B1
SYMBOL   playing        =  BIT15

SYMBOL  sfx             = B2                    ' sound fx segment
SYMBOL  last            = B3

SYMBOL  timer           = W4
SYMBOL  lottery         = W5                    ' random #


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00000000                              ' set outputs

  SEROUT Sio, Baud, ("!!!!!!!AP8", %00, "X","!RC4", %00, "X")
  relays = %0000

  PAUSE 30000                                   ' PIR warm-up / slow delay


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

Main:
  timer = 0                                     ' reset the PIR timer

Check_Trigger:
  RANDOM lottery
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer  < 100 THEN Check_Trigger            ' wait for 0.1 sec input

Open_Doors:
  Doors = IsOn                                  ' open doors (Relay 1)
  GOSUB Set_RC4
  PAUSE 1000                                    ' delay for 1 seconds

Raise_Albert:
  GOSUB Random_AP8                              ' play random scream
  Albert = IsOn                                 ' bring Albert up (Relay 2)
  GOSUB Set_RC4
  GOSUB Wait_AP8                                ' let scream finish
  PAUSE 3000                                    ' wait for another 3 secs
  Albert = IsOff                                ' Lay Albert back down to rest
  GOSUB Set_RC4
  PAUSE 1000                                    ' wait for Albert to retract
  Doors = IsOff                                 ' close doors (Relay 1)
  GOSUB Set_RC4

  GOTO Reset


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

Random_AP8:
  RANDOM lottery
  sfx = lottery // 8
  IF sfx = last THEN Random_AP8                 ' don't repeat sfx
    last = sfx                                  ' save for next cycle

  ' drops through to Play_AP8

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

Play_AP8:
  SEROUT Sio, Baud, ("!AP8", %00, "P", sfx)
  RETURN

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

' wait for AP8 to finish

Wait_AP8:
  PAUSE 70
  SEROUT Sio, Baud, ("!AP8", %00, "G")
  SERIN  Sio, Baud, status
  IF playing = Yes THEN Wait_AP8
    RETURN

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

Set_RC4:
  SEROUT Sio, Baud, ("!RC4", %00, "S", relays)
  RETURN

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

Wraithrat

That did it!!!!  Thanks so much.  You were right on - I did get the wires backward.  The devil's in the details.  Anyway, I am very pleased with the results. This will be a great addition to my props.  You guys are GREAT!