November 23, 2024, 08:04:36 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.


Multi led strobe lights

Started by Yard of monsters, November 01, 2010, 10:26:00 PM

Previous topic - Next topic

Yard of monsters

November 01, 2010, 10:26:00 PM Last Edit: November 23, 2010, 08:13:01 AM by INTERSHOPASSOC
 Looking for some help on a strobe light code. My idea is to have one led connected to each output of the prop-1 and have each one strobe at a different  rate. Would like to be able to change the flash rate to fit my needs for each output. Is this something the prop-1 can do. Thanks to anybody who can help.

bsnut

If you look at the Prop1 docs, the sample code that Jon did years ago, is for chasing lights like that is at a airport. I would try this first and the code can be changed to fit your needs. This means you can speed up the timing to give you the strobe light efx.
William Stefan
The Basic Stamp Nut

JonnyMac

If you're wanting the outputs to act completely independently then you may be asking for too much of the Prop-1.  It is a single-tasking controller, and not a very fast one at that some attempting to code multiasking is quite difficult and requires variable space, another element the Prop-1 is very trim on.

What kind of timing?
Jon McPhalen
EFX-TEK Hollywood Office

Yard of monsters

 The code I am using is below. All outputs are the same flash rate. If all outputs cant be independent maybe four at one rate and the other four at a different flash rate, or maybe every other two. Flash timing between 50 to 75.

SYMBOL  Leds            = PINS
SYMBOL  AllOn           = %11111111
SYMBOL  AllOff          = %00000000
SYMBOL  FlashTiming     = 50


  Leds = AllOff                                 ' clear LEDs
  DIRS = %11111111                              ' set outputs
Main:
  leds = ALLON
  PAUSE FlashTiming
  Leds = ALLOFF
  PAUSE FlashTiming
  GOTO main


JonnyMac

Fair warning: This is not easy code for beginners. 

While the BS1 may be slow, it is fairly sophisticated in terms of programming.  It does, in fact, allow for a form a slow multitasking using built-in programming constructs.  Remember, there is only one brain so attempting to control multiple, independent processes (even simple things like LED blinking), means dividing time.  So... you can't think in terms of milliseconds any more, rather think in terms of program loops.

I made this run six channels so I could check it on a trainer.  Adding two more channels is possible (there is enough code and variable space).  Just remember, every additional channel adds to the timing for each loop.  You'll have to play with the Flash constants to adjust each output.

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


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


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


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


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

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

SYMBOL  Flash0          = 2                    ' output settings
SYMBOL  Flash1          = 5
SYMBOL  Flash2          = 50
SYMBOL  Flash3          = 50
SYMBOL  Flash4          = 50
SYMBOL  Flash5          = 50


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

SYMBOL  chan            = B0

SYMBOL  timer0          = B2                    ' pin timers
SYMBOL  timer1          = B3
SYMBOL  timer2          = B4
SYMBOL  timer3          = B5
SYMBOL  timer4          = B6
SYMBOL  timer5          = B7


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

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


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

Main:
  chan = chan + 1 // 6                          ' update channel
  BRANCH chan, (Check0, Check1, Check2, Check3, Check4, Check5)
  chan = 0


Check0:
  IF timer0 = 0 THEN Ch0_Update                 ' timer expired?
    timer0 = timer0 - 1                         '  no, update timer
    GOTO Main

Ch0_Update:
  TOGGLE 0                                      ' toggle output
  timer0 = Flash0                               ' restart timer
  GOTO Main


Check1:
  IF timer1 = 0 THEN Ch1_Update
    timer1 = timer1 - 1
    GOTO Main

Ch1_Update:
  TOGGLE 1
  timer1 = Flash1
  GOTO Main


Check2:
  IF timer2 = 0 THEN Ch2_Update
    timer2 = timer2 - 1
    GOTO Main

Ch2_Update:
  TOGGLE 2
  timer2 = Flash2
  GOTO Main


Check3:
  IF timer3 = 0 THEN Ch3_Update
    timer3 = timer3 - 1
    GOTO Main

Ch3_Update:
  TOGGLE 3
  timer3 = Flash3
  GOTO Main


Check4:
  IF timer4 = 0 THEN Ch4_Update
    timer4 = timer4 - 1
    GOTO Main

Ch4_Update:
  TOGGLE 4
  timer4 = Flash4
  GOTO Main


Check5:
  IF timer5 = 0 THEN Ch5_Update
    timer5 = timer5 - 1
    GOTO Main

Ch5_Update:
  TOGGLE 5
  timer5 = Flash5
  GOTO Main


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


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


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

Yard of monsters

Thanks Jon.  Looks like this will work for me. Will play with the Flash when I get a chance.

Yard of monsters

Jon    Played with the flash timing. Works perfect. Thanks again.