November 24, 2024, 12:43:30 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.


AP-16+, FC-4 and PROP-1 - SFX audio not playing

Started by Radiowave911, October 13, 2010, 08:30:55 PM

Previous topic - Next topic

Radiowave911

I have been working on a Volcano as an entry in our town's Halloween parade, which is coming up VERY soon (the 18th).  I just received the AP-16+ Tuesday, however I had everything else working fine prior to that.  The issue I am having is triggering the eruption sound effect on the AP-16+.  A block diagram of the way things are connected is at http://www.halloweenhauntings.org/gallery/main.php?g2_itemId=268.  The previous image in that gallery is a MPG video of the volcano, with the audio added in post-production.  The way the entire thing is supposed to flow is as follows:

In 'standby' (I.E. not erupting), the AMBIENT.WAV file plays (this works), the red rope lights for 'lava' flicker dimly (this also works), and the white 'spot' light is on full brightness (not much for a 25w bulb, but it works).
Once the smoke machine is up to temperature (indicated to the PROP-1 on pin 5), the trigger button lights up (an LED connected to output 3 on the PROP-1) to indicate it is able to be triggered.
When the trigger button is pressed, (connected to pin 6) the following sequence of events is supposed to take place:

1) The 'active' indicator lights (an LED connected to output 2) (This works)
2) The AP-16+ is supposed to play the file ERUPT.WAV (This does not work - the AMBIENT.WAV keeps playing).
3) The White light fades out (Works)
4) The smoke machine is triggered to dispense smoke (works) via a relay attached to output 4
5) The flicker values are changed so that the rope lights are brighter (works)
6) The red 'spot' flickers (uses the same values as one of the rope lights) (This also works).
7) After the 'eruption' ends, the smoke turns off, the sound is supposed to be stopped (restarting the AMBIENT.WAV file), and the white spot fades back up.

Everything works great EXCEPT the audio.  The AMBIENT.WAV file just plays on a continuous loop - like it is supposed to in the 'standbay' state, however the ERUPT.WAV does not play, and the AMBIENT.WAV does not stop, when the eruption sequence is active.  The code for this whole thing is:

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

'

'   File...... Volcano.BS1

'   Purpose... Volcano Eruption Control

'   Author.... R. T. Starliper

'              Copyright (c) 2010

'        Some Rights Reserved
'              http://halloweenhauntings.org   

'   E-mail.... <redacted>
'   Started... 29 - September, 2010

'   Updated... 3 - October, 2010

'

'   {$STAMP BS1}

'   {$PBASIC 1.0}

'

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





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

'

'   Program to use PROP-1 to control Volcano for Halloween parade entry

'   in the annual Halloween Parade sponsored by the Kiwanis Club of

'   Middletown.

'

'   Lamps 1 and 2 are rope lights for lava effect on volcano

'   Lamp 3 is a red spot on the cave girl

'   Lamp 4 is a white spot on the cave girl

'

'   Manual trigger is connected to input 6 (push switch)

'   Smoke Machine ready is connected to input 5 via relay

'   Smoke Machine trigger is connected to output 4 via relay

'   Prop Ready to trigger is connected to output 3 (LED)

'   Prop running is connected to output 2 (LED)

'   Lamps are controlled via FC4

'   Sound is controlled via AP16+ and includes ambient + eruption SFX

'

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

'

'   Version 0.1 - Septermber 29, 2010 - Initial testing program.

'   Version 0.2 - October 1, 2010 - Enhanced random routing and testing

'   Version 1.0 - October 2, 2010 - Sound Routines added.

'   Version 1.0 - October 3, 2010 - Test Successful (without AP16+).

'

'

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



SYMBOL  Sio             = 7                     ' No ULN

SYMBOL  TRIGGER         = PIN6                  '

SYMBOL  SMOKE_OK        = PIN5                  '

SYMBOL  SMOKE           = PIN4                  ' Trigger Relay via ULN

SYMBOL  READY           = PIN3                  ' Ready To Trigger LED

SYMBOL  RUNNING         = PIN2                  ' Eruption Routine Executing





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



SYMBOL  IsOn            = 1

SYMBOL  IsOff           = 0

SYMBOL  LampOn          = 255                   ' Maximum Brightness

SYMBOL  Normal          = 128                   ' Normal Brightness Level

SYMBOL  FC4             = %00                   ' FC4 Address 00

SYMBOL  AP16            = %11                   ' AP16 Address 11



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



SYMBOL  Lottery         = W1

SYMBOL   Lamp1          = B2                    ' FC-4 Channel 1 - Red Rope

SYMBOL   Lamp2          = B3                    ' FC-4 Channel 2 - Red Rope

SYMBOL  Lamp3           = B4                    ' FC-4 Channel 3 - Red Spot

SYMBOL  Lamp4           = B5                    ' FC-4 Channel 4 - White Spot

SYMBOL  COUNT           = W3

SYMBOL  MIX             = W4



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



SetUp:

  Lottery = 1234                                ' Seed the random value

  Lamp3 = IsOff                                 ' Turn off eruption spot

  Lamp4 = LampOn                                ' Turn on normal spot

  DIRS = %10011111                              ' P4, P5, P6 As inputs

  READY = IsOff

  SMOKE = IsOff

  SEROUT Sio, OT2400, ("!AP16", AP16, "X")     ' Reset AP16



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



Main:

  IF SMOKE_OK = IsOn THEN SmokeReady          ' Do not trigger if smoke

  READY = IsOff                               ' machine is not ready

  GOTO NotErupting



NextCheck:

  IF TRIGGER = IsOff THEN NotErupting

    RUNNING = IsOn

    SEROUT Sio, OT2400, ("!AP16", AP16, "PW", "ERUPT", 13, 1)

    GOSUB FadeOutSpot

    SMOKE = IsOn

    FOR COUNT = 0 TO 500

      GOSUB Mixer

      Lamp3 = Lamp1 // LampOn + Normal

      Lamp2 = Lamp2 // LampOn + Normal

      Lamp1 = Lamp1 // LampOn + Normal

      GOSUB UpdateLights

    NEXT

    SMOKE = IsOff

    GOSUB FadeUpSpot

    GOSUB ReturnToNormal

    GOTO SetUp



NotErupting:

    GOSUB Mixer

    Lamp3 = IsOff

    Lamp4 = LampOn

    Lamp2 = Lamp2 // Normal + 25

    Lamp1 = Lamp1 // Normal + 25

    GOSUB UpdateLights

    GOTO Main



SmokeReady:

    READY = IsOn

    GOTO NextCheck





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

Mixer:

  FOR MIX = 1 TO 3

    RANDOM Lottery

  NEXT

RETURN



UpdateLights:

  SEROUT Sio, OT2400, ("!FC4", FC4, "S", lamp1, lamp2, lamp3, lamp4)

RETURN



FadeOutSpot:

  FOR Lamp4 = 255 TO 0 STEP -5

  RANDOM Lottery

  Lamp3 = IsOff

  Lamp2 = Lamp2 // Normal + 25

  Lamp1 = Lamp1 // Normal + 25

  GOSUB UpdateLights

  NEXT

  Lamp4 = IsOff

RETURN



FadeUpSpot:

  FOR Lamp4 = 0 TO 255 STEP 5

  RANDOM Lottery

  Lamp3 = IsOff

  Lamp2 = lamp2 // Normal + 25

  Lamp1 = lamp1 // Normal + 25

  GOSUB UpdateLights

  NEXT

RETURN



ReturnToNormal:

  RUNNING = IsOff

  SEROUT  Sio, OT2400, ("!AP16", AP16, "X")

RETURN



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


Any thoughts as to what I am missing here?  I checked the address of the AP-16+, the dip switches appear to be set correctly.  Time is running out on this project...any help would be greatly appreciated.

JonnyMac

I suspect ERUPT.WAV has a format problem.  It must be:

WAV
PCM encoded
16-bit
stereo -- this is usually what we trip up on
44.1kHz (or lower) sample rate -- this sometimes catches people out, too.

You might want to check you spelling as well; I drove myself nuts once by misnaming a file.

And double-check the option switch settings.  For your program they should be:

B/R = OFF
A1 = ON
A0 = ON

Note that these switches are only checked on power-up, so you may need to power down and back up if you make any changes.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

BTW, an easy way to test you file for format is to make a copy of it and call it SFX00.WAV.  Move the Audio Select knob to 0, make sure the ? (random) switch is off, then press the Start button.  If it plays then the audio format of the file is okay.
Jon McPhalen
EFX-TEK Hollywood Office

Radiowave911

It may be the format of the file.  I need to double check once I get home from work later - it may be a mono file, not stereo.  I was thinking I might go ahead and rename is as SFX01.WAV and use the PS command to play it instead anyway.  Do you see any issues with that, given the rest of my code?

JonnyMac

By using the SFXnn.WAV naming scheme you can check files easily.  I just did a cursory look at your code (checking AP-16+ syntax); it looks okay to me.
Jon McPhalen
EFX-TEK Hollywood Office

Radiowave911

Thanks.  I wil not be able to check until later tonight - I have family commitments to deal with first (it is scout night for my youngest daughter, I help with her troop).   I'll let you know how I make out.

Radiowave911

Still no joy.  I created several variations on the eruption file and saved them with SFXnn names (00 through 03).  I can play each of them with no problem manually by selecting the file number and hitting the button.  They will not play under program control, however.

I used the AP-16_Test.bs1 demo program, it behaved fine.  I thought there might be an issue with the FC4 and the AP16, so I tried changing where the AP16 serial command was sent in relation to the FC4 serial commands, no luck.  I was able to play the file under the volcano program control exactly once.  I called it by name (SFX03).  I was not able to duplicate that.

I am thinking, since I am running out of time, of using a second set of contacts on the trigger button (it is a DPDT) to manually trigger the AP16 to play the SFX03 file.  I have an unused pair on the cable going to the remote, I just have to solder them to the button itself, and terminate the other end so I can connect it to the terminals.

Running all of it under program control would be my first choice.  I am open to any suggestions.  My deadline to have this working is Sunday, at the very latest.

JackMan

Another thing you can do in a pinch would be to rename your file AUX01.WAV and use a relay to trigger IN1 on the AP-16+. Use an OUTx from the Prop-1 to energize the relay and connect the N.O. contacts of the relay to 3V3 and IN1 of the AP-16+.

bsnut

October 14, 2010, 08:14:44 PM #8 Last Edit: October 14, 2010, 08:53:28 PM by bsnut
I think, I found your problem with your setup.

SEROUT Sio, OT2400, ("!AP16", AP16, "PW", "ERUPT", 13, 1)

You can try to do this.

SEROUT Sio, OT2400, ("!AP16", %10, "PA", 7, 1)

I found this info on AP16+ docs on the above Syntax.

"PA" :: Play AUX##.WAV File
Syntax: "!AP16", address, "PA", #, loops
Reply: None
The "PA" (play SFX) command is used to play a specific AUX##.WAV file (1 to 8 ). The loops parameter is
used to specify the number of times to play the file (0 to 255); typically once (1). To continuously repeat the
specified file until another play or reset command, use zero (0) as the loops parameter.
Prop-1 Example
SEROUT Sio, OT2400, ("!AP16", %10, "PA", 7, 1)
In this example, the AP-16+ at address %10 will play AUX07.WAV one time. If the ambient Loop switch () is
closed and AMBIENT.WAV is on the SD card, it will restart when SFX01.WAV has finished playing.
William Stefan
The Basic Stamp Nut

JackMan

Bill,
   "PW" is used for a named WAV file which is what he's using (ERUPT.WAV). I believe he had it right.

Radiowave911

Thanks to both of you for the suggestions.  There is also a PS command to play SFXnn files.  I was able to make it work exactly once under prop control, but not again.  Wiring in another relay may be an easier option than opening the remote box.  I have one output that is unused on the PROP-1.  I know I can manually play any of the SFXnn files I want, so that may be an option as well - I could potentially trigger it using the dry contact start input and a relay, or maybe even the 12-24V trigger, fired directly from the ULN on the PROP1.  I plan to tinker with it tomorrow night.  By Saturday evening, I fully intend to have it working - one way or another.

Time is running out - I have to get this working soon, since the parade is Monday night.  Worst case, the AP16 just plays the AMBIENT.WAV file and there is no sound effect for the eruption itself.

JackMan

Since you are only playing 1 file on the AP-16+ you could indeed use the 12-24V input triggered directly from the Prop-1. If you use a relay to trigger an AUX file via IN1, it looks like you can energize the relay from OUT2 of your current program which turns on the "Running" LED.

Radiowave911

Quote from: JackMan on October 14, 2010, 08:40:16 PM
Since you are only playing 1 file on the AP-16+ you could indeed use the 12-24V input triggered directly from the Prop-1. If you use a relay to trigger an AUX file via IN1, it looks like you can energize the relay from OUT2 of your current program which turns on the "Running" LED.

I hadn't thought of using the run LED output.  I could also potentially use that output as the 12V trigger source for the board as well.  Thanks for the suggestion.  I will have to look into that tomorrow night.

I honestly suspect that the board, for whatever reason, is not even receiving the command to play the file.  I was just reading through the docs (again!) and read that if an invalid name is specified (with the PW command) while AMBIENT.WAV is playing, the ambient file will be restarted.  The ambient file is completely unaffected when the effect file is supposed to play.  This tells me that the command is not being received.  The status LED stays steady green, according to the docs it should flash red slowly for a missing file, rapidly for a bad serial command.  It stays steady green.  Once Halloween is past and I have time to work with it. I will set it up on the bench and see if I can figure out what is happening.  My gut is telling me it is an issue somehow related to the FC-4 also using serial comms and being daisy-chained after the AP16.

bsnut

October 14, 2010, 09:49:55 PM #13 Last Edit: October 14, 2010, 10:11:51 PM by bsnut
Jack,

I was following Jon's lead on the way the files need to be named. Like to take the easy way.

I also changed the post show what you were talking about.

William Stefan
The Basic Stamp Nut

JonnyMac

I'm a little lost... I thought you said the test program worked.   

QuoteMy gut is telling me it is an issue somehow related to the FC-4 also using serial comms and being daisy-chained after the AP16.

No, I don't think so, and to be sure I just put an RC-4 (which has the same processor/serial circuit as FC-4) in between my Prop-1 and AP-16+ and everything is fine.  Then I put the AP-16+ in betwen the Prop-1 and RC-4 -- both devices still work just fine.

Here's a condensed test program that I'm presently running on my AP-16+/RC-4 setup.  Once you get this working you should be good to go (though you are at 0 program space and you might look for opportunities to condense).

' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN


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

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

SYMBOL  Baud            = OT2400


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

SYMBOL  status          = B0                    ' status (B0 for bit access)
SYMBOL   Playing        = BIT7                  ' 0 = idle, 1 = playing

SYMBOL  id0             = B2
SYMBOL  id1             = B3
SYMBOL  id2             = B4


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

Reset:
  PAUSE 2000                                    ' let AP-16 power up

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


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

Main:
  SEROUT Sio, Baud, ("!AP16", %11, "V")         ' get version
  SERIN  Sio, Baud, id0, id1, id2               ' receive ID string

  DEBUG CLS
  DEBUG "AP-16+ Version: ", #@id0, #@id1, #@id2 ' display it
  DEBUG CR

Test_Play:
  SEROUT Sio, Baud, ("!AP16", %11, "PW", "SFX00", 13, 1)

Get_Status:
  PAUSE 50
  SEROUT Sio, Baud, ("!AP16", %11, "G")         ' get status
  SERIN  Sio, Baud, status
  IF playing = IsOn THEN Get_Status

  PAUSE 1000
  GOTO Main


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


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