November 23, 2024, 11:32:28 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.


Prop-1 / (2) FC-4 light control

Started by gadget-evilusions, September 23, 2009, 05:55:54 PM

Previous topic - Next topic

gadget-evilusions

A local haunted attraction purchased alot of EFX-TEK products at Transworld. Since I am local they asked if I could help in programming some of them. Here is what they asked me to program for their facade. Their are 6 channels of lights, on two FC-4s, controlled by a prop-1. Unfortunately the program runs out of space. Are their any tricks to shrinking down a program's size when using so manu SEROUT commands?
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

JonnyMac

Not likely -- you'll probably have to bump to a Prop-2.  The problem is all the data you're sending and this has to be stored in the Prop-1's program space which, as you know, is very small.

Another note: The FC-4 will finish one command before listening for another so when you have two fades stacked on top of each other you're going to see some issues.
Jon McPhalen
EFX-TEK Hollywood Office

gadget-evilusions

I should put in pauses after sending a command that are approximately as long as the command should take to run, right?
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

JonnyMac

Yes, a little longer is better so you aren't in the middle of a command when the FC-4 gets ready.  For example:

 SEROUT Sio, Baud, ("!FC4", %00, "F", 1, 2, 0, 255, 4)

There are 256 steps in the fade (255 - 0 + 1) at 4ms each so you should pause for at least 1024ms (256 x 4ms) after the command.
Jon McPhalen
EFX-TEK Hollywood Office

gadget-evilusions

This haunted attraction is going to swap out the prop-1 for a prop-2 that I have. Is there any way you could convert it to a prop-2 program? I have not familiarized myself enough with the variables, and constants for a prop-2 vs a prop-1 and they open tommorow (sorry). I belive the program code section would be the same other than be needing to add pauses after SEROUT commands.
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

johnb

Hi Brian,
Jon is at Disneyland today inspecting their installation of EFX-TEK products in their new attraction called Pixie Hollow, so I figured I would lend a hand here.

After looking at the code it occurred to me that it could be rewritten more efficiently and it would fit into a Prop-1.  You would put the SEROUT commands that update the FC-4s into a subroutine and simply pass variables to them instead of using a single SEROUT for each event.  Of all the commands, SEROUTs take up the most memory.
However, even if the code were rewritten, there would not be much room left over for changes or expansion, so I think it wise to move this to a Prop-2.

I've rewritten the code for the Prop-2.  Please find the code attached.

gadget-evilusions

September 24, 2009, 07:03:47 PM #6 Last Edit: September 25, 2009, 06:03:50 AM by gadget-evilusions
John,

Your an amazing man!

When you get time, no rush at all, could you make the program with the subroutines? I am curious to see the way you program it, because I was thinking the same thing, I just couldn't begin to think about how to do it.

Thank you again, and I am sure the Factory of Terror says thank you too.
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

BigRez

I was thinking the subroutine route, or more directly a sequencer program, would work better so I gave that a little try.  Still, even after taking all/most of the events and sequencing them with 5 parameters per sequence, it wouldn't fit into the prop-1.  I'm sure John or Jon could do a much better job at it and would love to see their attempt.

JonnyMac

Brian,

I wasn't trying to short you.  The other day another customer ran into the same problem and subroutines really didn't solve it.  Why?  Becuase we just traded the code space need for the SEROUT commands for setting up to four variables required for the subroutine -- turned out to be a pretty even trade.  Remember, there is only 255 bytes of Program space in the Prop-1 and a fade command requires 10 bytes to be transmitted (! F C 4 address F channel start end step).  For sophisticated FC-4 shows the Prop-2 is a better way to go.

Here's the subroutine added to our standard template so you can play with it.

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


' -----[ Program Description ]---------------------------------------------
'
' Sio     :: Serial IO to EFX-TEK accessories (RC-4, FC-4, etc.)
'            -- clip pin 1 of ULN2803 or replace with ULN2003
'
' Trigger :: Parallax-compatible PIR or N.O. button (mat switch, etc.)
'            -- connect N.O. button between P6.W and P6.R


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


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

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


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  Baud            = OT2400                ' B/R jumper removed


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

SYMBOL  timer           = B2

SYMBOL  chan            = B3
SYMBOL  lvlStart        = B4
SYMBOL  lvlEnd          = B5
SYMBOL  stpDelay        = B6


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00111111                              ' set output pins


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

Main:
  timer = 0                                     ' reset timer

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

  ' prop code here

  GOTO Main


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

Fade_FC4:
  SEROUT Sio, Baud, ("!FC4", %00, "F", chan, lvlStart, lvlEnd, stpDelay)
  RETURN

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


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


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

JonnyMac

Here's another Prop-2 version to try:

' =========================================================================
'
'   File...... Evilusions_FOT_Facade_FC-4.BS2
'   Purpose...
'   Author.... Brian Warner (Prop-2 translation by Jon Williams)
'   E-mail....
'   Started...
'   Updated... 26 SEP 2009
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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

Sio             PIN     15                      ' no ULN, SETUP = UP
Trigger         PIN     14                      ' SETUP = DN
Strobe          PIN      0


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

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

Yes             CON     1
No              CON     0

#SELECT $STAMP
  #CASE BS2, BS2E, BS2PE
    T1200       CON     813
    T2400       CON     396
    T4800       CON     188
    T9600       CON     84
    T19K2       CON     32
    T38K4       CON     6
  #CASE BS2SX, BS2P
    T1200       CON     2063
    T2400       CON     1021
    T4800       CON     500
    T9600       CON     240
    T19K2       CON     110
    T38K4       CON     45
  #CASE BS2PX
    T1200       CON     3313
    T2400       CON     1646
    T4800       CON     813
    T9600       CON     396
    T19K2       CON     188
    T38K4       CON     84
#ENDSELECT

SevenBit        CON     $2000
Inverted        CON     $4000
Open            CON     $8000

Baud            CON     Open | T38K4            ' for EFX-TEK accessories


FullBright      CON     255
DimLo           CON     32
DimHi           CON     128


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

lottery         VAR     Word
timer           VAR     Word
delay           VAR     Word

idx             VAR     Byte
tix             VAR     Byte
flicks          VAR     Byte
level           VAR     Byte
chan            VAR     Byte
addr            VAR     Byte
lvlStart        VAR     Byte
lvlEnd          VAR     Byte
stpDelay        VAR     Byte


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

Reset:
  OUTH = %00000000 : OUTL = %00000000           ' clear all
  DIRH = %00000000 : DIRL = %00000001           ' set outputs

  ' preset lights
  SEROUT Sio, Baud, ["!FC4", %00, "S", 255, 128, 0, 0]
  SEROUT Sio, Baud, ["!FC4", %01, "S",   0, 255, 0, 0]


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

Main:
  FOR tix = 1 TO 5                              ' hold for 5mins
    PAUSE 60000
  NEXT

  FOR flicks = 1 TO 200
    RANDOM lottery
    level = lottery // (DimHi - DimLo + 1) + DimLo
    SEROUT Sio, Baud, ["!FC4", %00, "L", 3, level]
    PAUSE 9
  NEXT

  chan     = 3                                  ' fade up to full bright
  lvlStart = level
  lvlEnd   = FullBright
  stpDelay = 8
  GOSUB Fade_FC8
  PAUSE (ABS(lvlEnd - lvlStart) * stpDelay) + 5

  chan     = 2                                  ' fade up to full bright
  lvlStart = 128
  lvlEnd   = FullBright
  stpDelay = 8
  GOSUB Fade_FC8
  PAUSE 7000

  ' fade ch1 and ch2 down; maintain ch3
  FOR level = 255 TO 0
    SEROUT Sio, Baud, ["!FC4", %00, "S", level, level, 255, 0]
    PAUSE 5
  NEXT
  PAUSE 3000

  ' cross-fade #3 from 100% to 0% and #4 from 0% to 100% 2028ms
  SEROUT Sio, Baud, ["!FC4", %00, "C", 0, 3, 4, 8]
  PAUSE 20000

  ' cross-fade #4 from 100% to 0% and #5 from 0% to 100% 2028ms
  chan     = 4
  lvlStart = FullBright
  lvlEnd   = 0
  stpDelay = 8
  GOSUB Fade_FC8
  chan     = 5
  lvlStart = 0
  lvlEnd   = FullBright
  stpDelay = 8
  GOSUB Fade_FC8
  PAUSE 20000

  FOR idx = 1 TO 2
    chan     = 5
    lvlStart = FullBright
    lvlEnd   = 128
    stpDelay = 8
    GOSUB Fade_FC8
    PAUSE 3000
    chan     = 5
    lvlStart = 128
    lvlEnd   = FullBright
    stpDelay = 8
    GOSUB Fade_FC8
    PAUSE 5000
  NEXT

  chan     = 2
  lvlStart = 0
  lvlEnd   = FullBright
  stpDelay = 8
  GOSUB Fade_FC8

  ' cross-fade #5 from 100% to 0% and #4 from 0% to 100% 2028ms
  chan     = 5
  lvlStart = FullBright
  lvlEnd   = 0
  stpDelay = 8
  GOSUB Fade_FC8
  chan     = 5
  lvlStart = 0
  lvlEnd   = FullBright
  stpDelay = 8
  GOSUB Fade_FC8
  PAUSE 10000

  ' quad fades (1 & 3 up to middle, 2 & 4 down to middle)
  FOR level = 0 TO 128
    SEROUT Sio, Baud, ["!FC4", %00, "S", level, (255-level), level, (255-level)]
    PAUSE 5
  NEXT
  PAUSE 10000

  ' kill all
  SEROUT Sio, Baud, ["!FC4", $FF, "X"]          ' $FF = all FC-4s

  Strobe = IsOn
  PAUSE 30000

  GOTO Reset


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

' Creates virtual FC-8; pass channel as 1 - 8

Fade_FC8:
  IF (chan =< 4) THEN
    addr = %00
  ELSE
    addr = %01
    chan = chan - 4                              ' align for #01
  ENDIF

  SEROUT Sio, Baud, ["!FC4", addr, "F", chan, lvlStart, lvlEnd, stpDelay]
  RETURN

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


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

gadget-evilusions

Your program worked perfectly Jon. Thank you.
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components