November 24, 2024, 03:05:13 AM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


Prop 2 and Wick LED

Started by youngti, October 17, 2010, 08:07:54 PM

Previous topic - Next topic

youngti

Okay, so I lost my original program to control Wick LED on all 16 pins on the prop 2.   I have tried to re-create and so far have had no luck.  I can get up to pin 6 activated but I know I am missing somthing.  I pulled this for one that Jon did a while ago in http://www.efx-tek.com/php/smf/index.php?topic=375.0.  Can you help me figure out what I am missing here?

Thank you so much.

  ' =========================================================================
'
'   File...... Candles.BS2
'   Purpose... Light faux candles (with LED wicks)
'   Author.... EFX-TEK (www.efx-tek.com)
'              Copyright (c) 2007 EFX-TEK
'   E-mail.... teamefx@efx-tek.com
'   Started...
'   Updated... 25 OCT 2007
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' This program controls up to six faux candles. Each candle "flame" is
' comprised of three LEDs, a resistor, and a capacitor.  The capacitor
' allows the flame to fade when the Prop-1 controller output goes off,
' creating a more realistic flame effect.


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

Candles         VAR     OUTS                    ' candle outputs, P0 - P15


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

FlickBase       CON     20                      ' flicker base timing


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

flicker         VAR     Word                    ' random flicker value
idx             VAR     Byte                    ' loop control
wicks           VAR     Byte                    ' to test for dark
rate            VAR     Byte                    ' flicker rate


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

Reset:
  DIRS = %1111111111111111                      ' make P0 - P15 outputs
  flicker = 1225                                ' seed random generator


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

Main:
  FOR idx = 1 TO 3                              ' tumble random generator
    RANDOM flicker
  NEXT

Check_Dark:
  wicks = flicker & %1111111111111111           ' test value
  IF wicks = %0000000000000000 THEN Main        ' if all off, try again

Flame_On:
  Candles = wicks                               ' update outputs
  rate = flicker & $0F + FlickBase              ' randomize timing
  PAUSE rate                                    ' hold flames
  GOTO Main                                     ' start again

JonnyMac

You can simplify the program -- give this a try:

' =========================================================================
'
'   File...... Candles.BS2
'   Purpose... Light faux candles (with LED wicks)
'   Author.... EFX-TEK (www.efx-tek.com)
'              Copyright (c) 2007-2010 EFX-TEK
'   E-mail.... teamefx@efx-tek.com
'   Started...
'   Updated... 17 OCT 2010
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' This program controls up to 16 faux candles. Each candle "flame" is
' comprised of three LEDs, a resistor, and a capacitor.  The capacitor
' allows the flame to fade when the Prop-2 controller output goes off,
' creating a more realistic flame effect.


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

Candles         VAR     OUTS                    ' candle outputs, P0 - P15


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

FlickBase       CON     25                      ' flicker base timing


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

flicker         VAR     Word                    ' random flicker value

idx             VAR     Byte                    ' loop control
delay           VAR     Byte                    ' flicker rate


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

Reset:
  DIRS = $FFFF                                  ' make P0 - P15 outputs
  flicker = 1225                                ' seed random generator


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

Main:
  FOR idx = 1 TO 3                              ' tumble random generator
    RANDOM flicker
  NEXT

Check_Dark:
  IF flicker = $0000 THEN
    GOTO Main                                   ' try again
  ELSE
    Candles = flicker                           ' update outputs
  ENDIF

Set_Delay:
  RANDOM flicker                                ' re-stir
  delay = flicker // 51 + FlickBase             ' 25 to 75
  PAUSE delay                                   ' hold

  GOTO Main
Jon McPhalen
EFX-TEK Hollywood Office

youngti

October 18, 2010, 12:26:16 AM #2 Last Edit: October 18, 2010, 12:40:40 PM by youngti
Perfect, Thank you.  That was very quick, did you have this already or did you wipp it together that quickly?

JonnyMac

I just modified your program -- I've written lots of "candles" code so it wasn't a big stretch.
Jon McPhalen
EFX-TEK Hollywood Office

youngti

You guys are soooo Coooooool.  This is one of the main reasons that I have been a EFX-TEK customner.  I don't know of anohter company that treats it customers the way you guys do.