May 20, 2024, 10:25:41 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.


Prop-1, AP-16, FC-4 - inconsistent result

Started by Liam, October 26, 2011, 09:36:44 PM

Previous topic - Next topic

Liam

Hi all,

I have completed the program for my haunt introduction for this year, and am running into some inconsistencies in actual result. The first time I run the program after I start up the system, it runs fine. But the second, third, etc, times it cuts out the last 30 seconds of what the FC-4 should be doing.

My guess is that I'm filling up the EEPROM the first time I run it, and for some reason it's not clearing out after that, so can only go so far. Does this seem like a reasonable explanation? And if so, how do I alleviate the problem, or optimize my code to avoid the problem?

Any assistance is much appreciated. Here is the 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 ]---------------------------------------------

' Introduction narration for foyer of Ferris Haunt 2011.
'
' FC4:
'    Channel 1: Incandescent table lamp
'    Channel 2: Strobe light for mirror effect
'    Channel 3: Red floodlight for fire effect
'    Channel 4: E-firecracker
'
' Prop-1:
'    PIN7: Serial devices
'    PIN6: Trigger switch
'    PIN5: Fogger

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


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

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

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

SYMBOL  Baud            = OT2400

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

SYMBOL  ap16Status      = B4
SYMBOL  volume          = B5
SYMBOL  default_volume  = B6
SYMBOL  fireeffect      = W5

SYMBOL  timer           = W3

SYMBOL  flame1          = W4
SYMBOL   fire1          = B8

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

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

  flame1 = 1031                                 ' seed
  default_volume = 50                           ' set default volume
  volume = default_volume                       ' set AP-16 volume
  fireeffect = 0

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

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

Main:
  IF Trigger = 1 THEN Show                                      ' Flicker incandescent light while idle
  RANDOM flame1
  SEROUT Sio, Baud, ("!FC4", %11, "L", 1, fire1)
  GOTO Main

Show:
  SEROUT Sio, Baud, ("!FC4", %11, "F", 1, 255, 100, 50)          ' Fade out incandescent light
  GOSUB Fade_Audio                                              ' Fade out ambient track
  SEROUT Sio, Baud, ("!AP16", %00, "PW", "intro1", 13, 1)       ' Play narration track
  PAUSE 47142
  SEROUT Sio, Baud, ("!FC4", %11, "S", 0, 255, 0, 0)            ' mirror strobe
  PAUSE 1500
  SEROUT Sio, Baud, ("!FC4", %11, "S", 100, 0, 0, 0)             ' Set incandescent lamp back to default
  PAUSE 3839                                                    ' fire effect
  HIGH Fog
  GOSUB Flame_Effect                                            ' Goto flood light fire effect subroutine
  LOW Fog
  SEROUT Sio, Baud, ("!FC4", %11, "S", 0, 255, 0, 255)          ' Trigger e-firecracker
  PAUSE 2000
  SEROUT Sio, Baud, ("!FC4", %11, "S", 100, 0, 0, 0)             ' Set incandescent flood back to default
  PAUSE 3000
  GOTO Main

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

Fade_Audio:
  PAUSE 200
  volume = volume - 5
  SEROUT Sio, Baud, ("!AP16", %00, "L", volume, volume)        ' set AP-16 volume
  IF volume > 0 THEN Fade_Audio
  volume = default_volume
  SEROUT Sio, Baud, ("!AP16", %00, "L", volume, volume)        ' set AP-16 back to default volume
  RETURN

Flame_Effect:
  RANDOM flame1
  SEROUT Sio, Baud, ("!FC4", %11, "S", 0, 0, fire1, 0)
  fireeffect = fireeffect + 1
  IF fireeffect < 298 THEN Flame_Effect
  RETURN


Liam

Liam

Got it, just had to take a step away for a few minutes. I'm sending it back to Reset instead of directly back to Main, and that seems to do it.

Liam