November 22, 2024, 04:42:00 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.


tv effect with prop1 controller

Started by afinkelstein, May 14, 2009, 02:30:36 PM

Previous topic - Next topic

afinkelstein

I created this effect for a show I was working on using 3 small lights and the programming on a light board. Then, in an automation class I recreated the effect using the prop1 controller board. The idea was to have the lights come on two at a time and go on and off at semi-random intervals and patterns to simulate the look of a tv. The tv holding the lights would be faced away from the audience so that just the light is seen, and when projected on the walls and actors it looks like the tv was on and functioning.

This is a cleaned up version of the final code. It could be done much simpler and better I know, but this was my first time working with the bs1 programming so I was kind of doing a quick and dirty version just to get it to work.


' {$STAMP BS1}

SYMBOL Timer1  = 500
SYMBOL Timer2  = 300
SYMBOL Timer3  = 700
SYMBOL Timer4  = 600
SYMBOL Timer5  = 400

SYMBOL Number  = B2
SYMBOL Counter = B3

Setup:
    DIRS = %00000111                  ' make pins 0,1,2 outputs

Main:
   'DEBUG "in main"
   RANDOM Number                      ' stir random generator
   Counter = Number // 5 + 1          ' create counter number between 1 and 5
   'DEBUG Counter
   IF Counter = 1 THEN One            ' if the counter is 1 run step1
   IF Counter = 2 THEN Two            ' if the counter is 2 run step2
   IF Counter = 3 THEN Three          ' if the counter is 3 run step3
   IF Counter = 4 THEN Four           ' if the counter is 4 run step4
   IF Counter = 5 THEN Five           ' if the counter is 5 run step5
GOTO Main                             ' back to Main

One:
   'DEBUG "in one"
   PINS = %00000011                   ' turn on lights 0 and 1, turn off light 2
   PAUSE Timer1                       ' pause for the amount of time in Timer1
   GOTO Main                          ' return to main

Two:
   'DEBUG "in two"
   PINS = %00000110                   ' turn on lights 1 and 2, turn off light 0
   PAUSE Timer2                       ' pause for amount of time in Timer2
   GOTO Main                          ' return to main

Three:
   'DEBUG "in three"
   PINS = %00000101                   ' turn on lights 0 and 2, turn off light 1
   PAUSE Timer3                       ' pause for the amount of time in Timer3
   GOTO Main                          ' return to main

Four:
   'DEBUG "in four"
   PINS = %00000011                   ' turn on lights 0 and 1, turn off light 2
   PAUSE Timer4                       ' pause for the amount of time in Timer4
   GOTO Main                          ' return to main

Five:
   'DEBUG "in five"
   PINS = %00000110                   ' turn on lights 1 and 2, turn off light 0
   PAUSE Timer5                       ' pause for amount of time in Timer2
   GOTO Main                          ' return to main

JonnyMac

Nice job!  Be careful of "quick and dirty," though -- those projects are never quick and always dirty!  :D

As you gain more experience you will learn to spot redundancies and code them out.  To show you what I mean, this version takes advantage of LOOKUP tables to do exactly the same thing with less code; this version uses 15% of the Prop-1 memory while your original uses 29%.  As your programs become bigger and more sophisticated you'll be happy to have space-saving tricks in your bag.

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


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


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


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

SYMBOL  Lamps           = PINS


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


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

SYMBOL  idx             = B2

SYMBOL  delay           = W4
SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00000111                              ' enable P0..P2 as outputs


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

Main:
  RANDOM lottery
  idx = lottery // 5
  LOOKUP idx, (%011, %110, %101, %011, %110), Lamps
  LOOKUP idx, (500, 300, 700, 600, 400), delay
  PAUSE delay
  GOTO Main


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


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


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


Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

You can get a little more variety in your output timing by doing this:

Main:
  RANDOM lottery
  idx = lottery // 5
  LOOKUP idx, (%011, %110, %101, %011, %110), Lamps
  RANDOM lottery
  idx = lottery // 5
  LOOKUP idx, (500, 300, 700, 600, 400), delay
  PAUSE delay
  GOTO Main


Or... you could simply randomize the time within the limits you are already using:

Main:
  RANDOM lottery
  idx = lottery // 5
  LOOKUP idx, (%011, %110, %101, %011, %110), Lamps
  RANDOM lottery
  delay = lottery // 401 + 300
  PAUSE delay
  GOTO Main


Finally, you could randomize the lamps as well.  This code ensures that the output never goes completely dark:

Main:
  RANDOM lottery
  idx = lottery & %111
  IF idx = %000 THEN Main
  Lamps = idx
  RANDOM lottery
  delay = lottery // 401 + 300
  PAUSE delay
  GOTO Main
Jon McPhalen
EFX-TEK Hollywood Office

afinkelstein

True, it wasn't really all that quick, but it was fun :-)

Thanks for the tips, those all look great and I will definitely try and incorporate them if I get the chance in future projects!