May 20, 2024, 08:34:04 AM

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.


Monster in the Box

Started by youngti, October 28, 2015, 01:54:59 PM

Previous topic - Next topic

youngti

Hi all,

I had to redo my Monster in the Box because the Sound for the box(ScaryTerry) board went out and I couldn't get a new one.  So I purchased the AP16.  I rewrote the code for the Prop one and rewired the entire box.  My goal was to get the boards out of the box and onto a central control board.  My thinking is that the sound board failed due to the violent motion of the box.  This box not only slams is lid but lurches forward as well.  What I did is to get a hitch wiring harness and also use two Cat5e connectors and cables.  The hitch harness is a higher voltage connector and I am using that for the two 110v lights, and the fog machine trigger(six wires in all).  The cat5e cable supplies two twisted pair each to the black wire on  the Air solenoids for the Prop1, four twisted pair to both the red wire on the  Air solenoids for the Prop1.  A second cat5e cable provides three wires to the PIR, then one twisted pair to the L speaker and one twisted pair to the right speaker.   The code loads fine on the prop1 and I have an ambient.wav and  SFX01.wav on the SD card in the AP16.  SD card is 4GB and formatted to FAT.  I used Audacity to edit the wav files and made sure there was no header on each.

I am trying to figure out if its a wiring issue, code issue or maybe distance issue. This is what happens when I test. 

The AP16 only produces a rhythmic popping noise.  The Box when triggered will activate for maybe a second at the most then turn off.  then will reset and do this again.  What is supposed to happen is the box will be in rest mode, the ambient.wav will play and then when triggered will play SFX01and run the show for about 10 seconds.  then reset and go back to resting mode.  Can you take a look at my code below and see if maybe I have made a coding mistake I cant see?  Also do you have any suggestions on the AP16?  Or any other aspect of what I describe above.  Thank you all for looking at this.  I know its only three days till Halloween so you all are busy but I have been up all night and I am having trouble thinking.

' =========================================================================
'
'   File...... Monster-in-a-Box_V3.BS1
'   Purpose...
'   Author.... Tim Young
'   E-mail....
'   Started... 08-14-09
'   Updated... 10-28-2015
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = UP, no ULN RC4
SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  Base            = PIN1                  ' BaseCylinder
SYMBOL  Lid             = PIN0                  ' LidCyilinder

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

SYMBOL  Baud            = OT2400

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0
SYMBOL  showrun        = 10000                 ' show is 10s

SYMBOL  FogRun          = 2000                  'Fog on for 2 seconds

SYMBOL  MinJump         =   100                 ' timing for lid/box jumps
SYMBOL  MaxJump         =   250

SYMBOL  LightTime       = 30000

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

SYMBOL  relays          = B0
SYMBOL   LightR         =  BIT0
SYMBOL   LightL         =  BIT1
SYMBOL   Fogger         =  BIT2
SYMBOL   K4             =  BIT3

SYMBOL  timer           = W3                    ' event timer
SYMBOL  delay           = W4                    ' run delay
SYMBOL  lottery         = W5                    ' random #
SYMBOL   lottoLo        =  B10
SYMBOL   lottoHi        =  B11

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

Reset:
  PINS = %00000000                              ' clear IOs
  DIRS = %00100011                              ' define output pins

  SEROUT Sio, Baud, ("!RC4", %00, "X")          ' clear RC-4 outputs
   SEROUT Sio, Baud, ("!AP16", %01, "PS", 1, 0)  ' SFX01 in loop mode

  timer = timer * 120                           ' make 0 to ~30s
  PAUSE timer

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

Main:
  timer = 0

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

SEROUT Sio, Baud, ("!AP16", %01, "PS", 2, 0)  ' SFX01 loop

Start_Fog:
  Fogger = IsOn


Lidactive:
  RANDOM lottery                                ' re-stir
  delay = MaxJump - MinJump + 1                 ' get span
  delay = lottery // delay + MinJump            ' calc jump timing
  Lid = IsOn - Lid                              ' toggle cylinder

LightFlash:
  RANDOM lottery                                ' create new outputs
  LightR = LottoLo
  LightL = LottoHi
  RANDOM lottery                                ' re-stir random
  delay = lottery // 201 + 50                   ' between 50 and 250 ms
  PAUSE delay                                   ' hold
  timer = timer + delay                         ' update timer
  IF timer < LightTime THEN LightFlash          ' check run time
  GOSUB Update_RC4

Baseactive:
  RANDOM lottery                                ' re-stir
  delay = MaxJump - MinJump + 1                 ' get span
  delay = lottery // delay + MinJump            ' calc jump timing
  Base = IsOn - Base                              ' toggle cylinder

  PAUSE delay                                   ' hold
  timer = timer + delay                         ' update run timer
  IF timer < showrun THEN Lidactive               ' if not done, go again
    GOTO Reset




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

Update_RC4:

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

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

JackMan

October 28, 2015, 02:48:43 PM #1 Last Edit: October 28, 2015, 02:50:30 PM by JackMan
Two things, make sure your AP-16 address is set correctly. Your code has "%01" which means the dip switches must be set to A1=off, A0=on. Get rid of the AP-16 command in the reset section, make sure the Ambient dip switch is set to ON and your ambient file is named "Ambient.wav"  The ambient file will play automatically.
Lastly, the command to play your SFX01 should be: SEROUT Sio, Baud, ("!AP16", %01, "PS", 1, 1)  ' play SFX01

JackMan

October 28, 2015, 02:59:16 PM #2 Last Edit: October 28, 2015, 03:31:05 PM by JackMan
Also, you need this line in the trigger code right under "PAUSE 5"  IF Trigger = 0 THEN Main
Without that you could get eventually get a false trigger.

Disregard, that part is fine.

Just noticed you're not clearing the "timer" after the prop triggers.
Right above "Lidactive" insert timer = 0
You are also using the variable "timer" in several different sections in conjunction with two different constants, Showrun and LightTime. The Showrun constant is set for 10s but your LightTime constant is 30s. Not sure what you are trying to accomplish there.

youngti

Thank you for you reply.  I did what you suggested and it is still not working.  I have everything set as you suggested and the AP16 still just makes a pop....pop.....pop....pop...ect noise. 

The SD card I have is a Kingston Micro SD with adapter.

JackMan

OK, you should probably address the AP-16 issue as a separate problem and test it disconnected from the Prop-1.
If it doesn't play your files, then let's get that figured out first.

youngti

Okay sound is working now.  Power supply was not large enough.  Was a 12v .5a  which I read as a 5amp.  One problem solved.  Still not activating like it should.  So I have a Prop1 connect to the RC4, the AP16 should be connected off the RC4 correct?

JackMan

Doesn't matter which order, the serial connection is a daisy chain.

youngti

That is what I thought.  any other suggestions?

JackMan

Post your corrected code so we can go from there.

youngti

Here is the corrected code.  I have taken our the ShowTime as redundant.  Still the ambient sound will play, but when triggered it goes less than a second so and doesn't do what its has done before I started all this.

' =========================================================================
'
'   File...... Monster-in-a-Box_V3.BS1
'   Purpose...
'   Author.... Tim Young
'   E-mail....
'   Started... 08-14-09
'   Updated... 10-28-2015
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = UP, no ULN RC4
SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  Base            = PIN1                  ' BaseCylinder
SYMBOL  Lid             = PIN0                  ' LidCyilinder

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

SYMBOL  Baud            = OT2400

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0

SYMBOL  FogRun          = 2000                  'Fog on for 2 seconds

SYMBOL  MinJump         =   100                 ' timing for lid/box jumps
SYMBOL  MaxJump         =   250

SYMBOL  LightTime       = 30000

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

SYMBOL  relays          = B0
SYMBOL   LightR         =  BIT0
SYMBOL   LightL         =  BIT1
SYMBOL   Fogger         =  BIT2
SYMBOL   K4             =  BIT3

SYMBOL  timer           = W3                    ' event timer
SYMBOL  delay           = W4                    ' run delay
SYMBOL  lottery         = W5                    ' random #
SYMBOL   lottoLo        =  B10
SYMBOL   lottoHi        =  B11

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

Reset:
  PINS = %00000000                              ' clear IOs
  DIRS = %00100011                              ' define output pins

  SEROUT Sio, Baud, ("!RC4", %00, "X")          ' clear RC-4 outputs

  timer = timer * 120                           ' make 0 to ~30s
  PAUSE timer

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

Main:
  timer = 0

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

SEROUT Sio, Baud, ("!AP16", %01, "PS", 1, 1)  ' play SFX01

Start_Fog:
  Fogger = IsOn


Lidactive:
  RANDOM lottery                                ' re-stir
  delay = MaxJump - MinJump + 1                 ' get span
  delay = lottery // delay + MinJump            ' calc jump timing
  Lid = IsOn - Lid                              ' toggle cylinder

LightFlash:
  RANDOM lottery                                ' create new outputs
  LightR = LottoLo
  LightL = LottoHi
  RANDOM lottery                                ' re-stir random
  delay = lottery // 201 + 50                   ' between 50 and 250 ms
  PAUSE delay                                   ' hold
  timer = timer + delay                         ' update timer
  IF timer < LightTime THEN LightFlash          ' check run time
  GOSUB Update_RC4

Baseactive:
  RANDOM lottery                                ' re-stir
  delay = MaxJump - MinJump + 1                 ' get span
  delay = lottery // delay + MinJump            ' calc jump timing
  Base = IsOn - Base                              ' toggle cylinder

  PAUSE delay                                   ' hold
  timer = timer + delay                         ' update run timer
  IF timer < lighttime THEN Baseactive               ' if not done, go again
    GOTO Reset




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

Update_RC4:

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

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


youngti

Does not even start.  I have tried to start it manually.  Did this by taking the loop switch off and disconnecting the prop1 from it.  Then selecting position 1 wont play.  But the air solenoids, lights and fog machine get a second or less of activation then fall silent.

JackMan

We're kinda goin' in circles here, I thought you said the AP-16 files were playing fine after you got the proper power supply?

youngti

I thought it was.,  I just did a test.  I have a known good SD card for another prop.  Works fine in that props AP16.  But when I move it to the MIB AP16 and I disconnect it from the Prop1.  The two files on it are SFX00 and SFX01.  When the switch is on 0 nothing plays when pressing the manual button.  Move to 1 and nothing plays pressing the manual button.  But I take that SD card and put it in the original prop it plays just fine.

When I put the original SD card for the MIB now even ambient does not play.  What the hell and I doing wrong?

I know there maybe two separate problems here.

JackMan

There is definitely 2 separate problems, there are errors in the Prop-1 code that I see now. When you power up the AP-16 are you getting the solid green LED?