November 22, 2024, 07:34:23 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.


Haunt intro show - program request

Started by Liam, October 22, 2011, 12:50:34 AM

Previous topic - Next topic

Liam

Hi all,

I'm in the last stages of putting my haunt together, and can't quite wrap my head around what I want to do. I am using a Prop-1, FC-4 and AP-16. Here's a quick run-own of the events that need to happen:

1. The AP-16 will loop the track "storm.wav" until I press a button to start the show. During this time, the FC-4 will flicker a light.
2. When the switch is pressed, the AP-16 will start playing the track "intro1.wav" and the FC-4 will fade out the lamp over a period of five seconds.
3. A few events happen throughout the show, but I can write those - they're easy.
4. At the end of the show, it goes back to the looped "storm.wav" and the flickering lamp.

The rest of the show between 3 and 4 I can write, I just can't figure out how to play the track without continually re-triggering it every time I check the trigger. I'm sure it's something dumb I'm missing, but anything to help make sense of this would be appreciated.

Thanks very much,
Liam

Liam

This is what I have so far, and it's not playing the audio. I'm sure my logic is off:


' =========================================================================
'
'   File...... Haunt_Intro_2011-v1.BS1
'   Purpose...
'   Author.... Liam Ferris
'              with parts borrowed from
'              Jon Williams, EFX-TEK
'              Copyright (c) 2008 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... lpferris@gmail.com
'   Started...
'   Updated... 26 AUG 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN1                  ' SETUP = DN

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

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

SYMBOL  Baud            = OT2400



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

SYMBOL  state           = B2
SYMBOL  subTimer        = B3
SYMBOL  ap16status      = B4

SYMBOL  timer           = W3

SYMBOL  flame1          = W4
SYMBOL   fire1          =  B8
SYMBOL   fire2          =  B9

SYMBOL  flame2          = W5
SYMBOL   fire3          =  B10
SYMBOL   fire4          =  B11


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

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

  flame1 = 1031                                 ' seed

  SEROUT Sio, Baud, ("!!!!!!FC4", %01, "X")     ' resync and reset
  SEROUT Sio, Baud, ("!AP16", %00, "X")


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

Main:
  RANDOM flame1
  RANDOM flame2
  fire1 = fire1 * 100 / 255
  fire2 = fire2 * 100 / 255
  fire3 = fire3 * 100 / 255
  fire4 = fire4 * 100 / 255
  SEROUT Sio, Baud, ("!FC4", %01, "S", fire1, fire2, fire3, fire4)
  timer = timer + 42

  BRANCH state, (Check_Loop, Play_Loop, Check_PIR, Show)

State_Error:
  timer = 0
  state = 0
  GOTO Main

Check_Loop:
  SEROUT Sio, OT2400, ("!AP16", %00, "G")
  SERIN Sio, OT2400, ap16Status
  IF ap16status = 5 THEN Check_PIR

Play_Loop:
  SEROUT Sio, OT2400, ("!AP16", %00, "PW", "storm", 13, 1)

Check_PIR:
  timer = timer * PIR                           ' scan PIR
  IF timer < 100 THEN Main                      ' valid signal
    state = 1                                   ' yes, advance state
    timer = 0                                   ' reset timer for next state
    subTimer = 0
    GOTO Main

Show:
  SEROUT Sio, OT2400, ("!AP16", %00, "PW", "intro1", 13, 1)
  SEROUT Sio, OT2400, ("!FC4", %01, "F", 1, 200, 0, 20)
  PAUSE 10000
  GOTO Main



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


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


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

Liam

Sorry for all the replies. It's time to go to bed, and this is what I have so far.

The loop track plays successfully, but the lights don't flicker. And when I hit the trigger, it does not go to the main show part.


' =========================================================================
'
'   File...... Haunt_Intro_2011-v1.BS1
'   Purpose...
'   Author.... Liam Ferris
'              with parts borrowed from
'              Jon Williams, EFX-TEK
'              Copyright (c) 2008 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... lpferris@gmail.com
'   Started...
'   Updated... 20 October, 2011
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN0                  ' SETUP = DN

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

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

SYMBOL  Baud            = OT2400



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

SYMBOL  state           = B2
SYMBOL  subTimer        = B3
SYMBOL  ap16Status      = B4

SYMBOL  timer           = W3

SYMBOL  flame1          = W4
SYMBOL   fire1          =  B8
SYMBOL   fire2          =  B9

SYMBOL  flame2          = W5
SYMBOL   fire3          =  B10
SYMBOL   fire4          =  B11


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

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

  flame1 = 1031                                 ' seed

  SEROUT Sio, Baud, ("!!!!!!FC4", %01, "X")     ' resync and reset
  SEROUT Sio, Baud, ("!AP16", %00, "X")
  SEROUT Sio, Baud, ("!AP16", %00, "L", 50, 50)


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

Main:
  DEBUG "Main"
  RANDOM flame1
  RANDOM flame2
  fire1 = fire1 * 100 / 255
  fire2 = fire2 * 100 / 255
  fire3 = fire3 * 100 / 255
  fire4 = fire4 * 100 / 255
  SEROUT Sio, Baud, ("!FC4", %01, "S", fire1, fire2, fire3, fire4)
  timer = timer + 42

  BRANCH state, (Check_Loop, Check_Switch, Show)

State_Error:
  timer = 0
  state = 0
  GOTO Main

Check_Loop:
  DEBUG "Check_Loop"
  SEROUT Sio, OT2400, ("!AP16", %00, "G")
  SERIN Sio, OT2400, ap16Status
  DEBUG ap16Status
  IF ap16Status = 160 THEN Check_Switch
  DEBUG "Play_Loop"
  SEROUT Sio, OT2400, ("!AP16", %00, "PW", "storm", 13, 1)



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

Check_Switch:
  DEBUG "Check Switch"
  IF Trigger = 0 THEN Main
  GOTO Show

Show:
  DEBUG "Show"
  SEROUT Sio, OT2400, ("!AP16", %00, "PW", "intro1", 13, 1)
  SEROUT Sio, OT2400, ("!FC4", %01, "F", 1, 200, 0, 20)
  PAUSE 10000
  GOTO Main

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

JackMan

One thing I see right away is that you need to change your Trigger to PIN6 with the setup jumper DN. Your code as written has the Trigger on PIN0 and in the Initialization section you have PIN0 as an output.

Liam

Thanks for helping out, Jack! I finally got it to work, just have one problem. The flicker is very mechanical, and much slower than it was in the program that I borrowed it from. It seems like the light level refreshes around once a second, so it's not very convincing.

I thought I would have had to use a state machine, but I think that's overkill unless I really do need to do it that way to create a more natural flicker.

But hey, the loop plays, repeats when it's over, and the trigger starts the show, so I'm happy so far. Here's the new code:


' =========================================================================
'
'   File...... Haunt_Intro_2011-v1.BS1
'   Purpose...
'   Author.... Liam Ferris
'              with parts borrowed from
'              Jon Williams, EFX-TEK
'              Copyright (c) 2008 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... lpferris@gmail.com
'   Started...
'   Updated... 20 October, 2011
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

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

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

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

SYMBOL  Baud            = OT2400



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

SYMBOL  state           = B2
SYMBOL  subTimer        = B3
SYMBOL  ap16Status      = B4

SYMBOL  timer           = W3

SYMBOL  flame1          = W4
SYMBOL   fire1          =  B8
SYMBOL   fire2          =  B9

SYMBOL  flame2          = W5
SYMBOL   fire3          =  B10
SYMBOL   fire4          =  B11


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

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

  flame1 = 1031                                 ' seed

  SEROUT Sio, Baud, ("!!!!!!FC4", %11, "X")     ' resync and reset
  SEROUT Sio, Baud, ("!AP16", %00, "X")
  SEROUT Sio, Baud, ("!AP16", %00, "L", 50, 50)


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

Main:
  DEBUG "Main"
  IF Trigger = 1 THEN Show
  RANDOM flame1
  RANDOM flame2
  SEROUT Sio, Baud, ("!FC4", %11, "S", fire1, fire2, fire3, fire4)
  timer = timer + 1
  GOSUB Check_Loop

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

Check_Loop:
  DEBUG "Check_Loop"
  SEROUT Sio, OT2400, ("!AP16", %00, "G")
  SERIN Sio, OT2400, ap16Status
  DEBUG ap16Status
  IF ap16Status = 160 THEN Main
  DEBUG "Play_Loop"
  SEROUT Sio, OT2400, ("!AP16", %00, "PW", "storm", 13, 1)
  RETURN

Show:
  DEBUG "Show"
  SEROUT Sio, OT2400, ("!AP16", %00, "PW", "intro1", 13, 1)
  SEROUT Sio, OT2400, ("!FC4", %11, "F", 1, 200, 0, 20)
  PAUSE 10000
  GOTO Main

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


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



JackMan

I think you can do away with the Check_Loop section and just rename your storm.wav to Ambient.wav. Set the loop switch on the AP-16+ to ON and that track will play automatically until the intro command is sent, and then continue to play once the intro file is complete.  This will simplify the code and should speed up the flicker from the FC-4.

Liam

Nice, thanks again Jack. I'm giving it a try right now.

Liam