November 23, 2024, 03:31:01 PM

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-1 trainer and flicker

Started by imagineerdan, June 21, 2010, 01:49:19 PM

Previous topic - Next topic

imagineerdan

I am trying to use the prop-1 trainer to vary the candle flicker on a prop-1 board realtime. Is this possible? What would it look like? Thanks!

JonnyMac

Here's one possibility:

' =========================================================================
'
'   File...... Candles.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Speed           = 7
SYMBOL  Wicks           = PINS


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

SYMBOL  TmMin           = 25
SYMBOL  TmMax           = 75


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

SYMBOL  idx             = B2
SYMBOL  adjust          = B3

SYMBOL  delay           = W4
SYMBOL  lottery         = W5


' -----[ EEPROM Data ]-----------------------------------------------------


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

Reset:
  DIRS = %00111111
  lottery = 1031                                ' seed random value


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

Main:
  FOR idx = 1 TO 3                              ' stir random value
    RANDOM lottery
  NEXT
  Wicks = lottery

  delay = TmMax - TmMin + 1                     ' calculate span
  delay = lottery // delay + TmMin              ' calculate delay
  POT Speed, 100, adjust                        ' read pot
  delay = delay * adjust / 200                  ' adjust flicker rate
  PAUSE delay                                   ' wait
  GOTO Main
Jon McPhalen
EFX-TEK Hollywood Office

imagineerdan

That works well! How can I make the pot make the flicker have an even wider range. Meaning the maximum of the pot is really fast and the minimum is an ultra slow flicker?

JonnyMac

You can't speed it up because the POT function creates a delay of ~10ms; this is as fast as it goes (with a 0 reading from the POT there is no delay, PAUSE 0 is almost zero).

You can slow it down by changing the 200 in this line:

 delay = delay * adjust / 200                  ' adjust flicker rate

Since "adjust" could have a maximum value of 255 the pot adjustment (on the slow end) is 255 / 200, or x1.28.  If you wanted the adjustment to be as much as 2x, change 200 to 127 (255 / 127 = 2).  You do need to keep things in the order they are and make sure that "delay" (on coming into this section) is no greater than 255; if it is you'll get an internal roll-over error and the timing will seem weird).
Jon McPhalen
EFX-TEK Hollywood Office

imagineerdan

That will work perfectly! Thanks Jon what a great feature!