November 23, 2024, 10:31:26 AM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Faux candle mod

Started by bzelten, June 18, 2009, 09:08:03 AM

Previous topic - Next topic

bzelten

I have an application that uses the faux candle program and need to modify it to turn on all 6 output at the same time with the random flicker.
How can I do this it sounds easy. 

EricTheMannn

Post as much info as you can, the program you're referencing documents on the product, exactly what you want the faux candles to do etc..  The more information you can provide the easier it will be to provide you with an answer.

Also there is a huge amount of information on this forum, here's a bunch of info on basic code http://www.efx-tek.com/php/smf/index.php?topic=595.0 all of those documents are full of information.

Hope this helps a bit

-Eric
WooHoo

bzelten

Here is the code I'm using. It works fine for flickering random outputs but I have an application that needs 6 outputs to flicker at the same time.

' =========================================================================
'
'   File....... Faux_Candles.BS1
'   Purpose.... Simulate six candles with LEDs; with wind/trigger input
'   Author..... Team EFX
'   E-mail..... teamefx@parallax.com
'   Started.... 19 MAR 2005
'   Updated.... 01 JUN 2005
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Simulates candle flicker by passing random values to the "candle" output
' pins (P0 - P5).  When TriggerWind is high, the candle appears to burn
' slowly and steadily.  When TriggerWind is low, the candle flickers as
' though it was subjected to a stiff breeze.


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


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

SYMBOL  TriggerWind     = PIN7                  ' active-low (1 -> 0)


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

SYMBOL  Yes             = 1                     ' for active low input
SYMBOL  No              = 1


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

SYMBOL  flicker         = W0                    ' random flicker
SYMBOL  blankTest       = W1                    ' test for extended blank
SYMBOL  candles         = B4                    ' new candle outputs
SYMBOL  flickVal        = B5                    ' width of darkness
SYMBOL  flickDly        = B6                    ' delay between updates


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


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

Reset:
  PINS = %00000000                              ' all candles off
  DIRS = %00111111                              ' make LED pins outputs


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

Main:
  RANDOM flicker                                ' tumble random generator
  IF TriggerWind = Yes THEN Has_Wind

No_Wind:
  flickVal = %0011                              ' load calm values
  flickDly = 60
  GOTO Chk_Blackout

Has_Wind:
  flickVal = %1111                              ' load windy values
  flickDly = 50

Chk_Blackout:                                   ' test bits for all zeros
  blankTest = flicker & flickVal                ' isolate test bits
  IF blankTest > 0 THEN Update_Candles          ' if not blank, do update
    flicker = flicker + 1                       '   else insert a 1

Update_Candles:
  candles = flicker & %00111111                 ' use active candle pins
  PINS = candles                                ' update LEDs
  PAUSE flickDly                                ' delay between updates
  GOTO Main

  END


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


Thanks,
Bert

JonnyMac

It sounds like you need the standard candle program -- try this one.

' =========================================================================
'
'   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  Wicks           = PINS


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

SYMBOL  TmMin           = 25
SYMBOL  TmMax           = 75


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

SYMBOL  idx             = B2
SYMBOL  delay           = B3

SYMBOL  lottery         = W5


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


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

Reset:
  DIRS = %00111111                              ' make P0 - P5 outputs
  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
  PAUSE delay                                   ' wait
  GOTO Main
Jon McPhalen
EFX-TEK Hollywood Office

bzelten

This works to flicker the 6 outputs randomly but what I need is a random flicker that will turn on the 6 outputs at the same time. What I am doing is flickering a large number of LED lights and want to spread the load out across the 2803. So I need all 6 outputs to flicker at the same time.

Thanks

EricTheMannn

Maybe use a single output with all the LED's attached to it?

I believe you can change the  "SYMBOL  Wicks           = PINS"  & " DIRS = %00111111" part of the program to "SYMBOL  Wicks           = PIN X"  X meaning the pin you desire to connect the LED's To,  For example "SYMBOL  Wicks   = PIN 0" & The DIRS would change to "DIRS = %00000001 "

Keep us posted on the project! :)


-Eric
WooHoo

bzelten

I need all 6 channels 1 channel will only handle 500 ma. continues. I need more, plus using multiple outputs will insure that if a channel is shorted or over loaded it will not kill all the lights.

JonnyMac

So you're saying you want a whole mess of outputs doing exactly the same [random] thing?  If that's the case, use this program:

' =========================================================================
'
'   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  Wicks           = PINS


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

SYMBOL  TmMin           = 25
SYMBOL  TmMax           = 75


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

SYMBOL  idx             = B2
SYMBOL  delay           = B3

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                             ' outputs differ

  PIN0 = lottery                                ' all outputs the same
  PIN1 = PIN0
  PIN2 = PIN0
  PIN3 = PIN0
  PIN4 = PIN0
  PIN5 = PIN0

  delay = TmMax - TmMin + 1                     ' calculate span
  delay = lottery // delay + TmMin              ' calculate delay
  PAUSE delay                                   ' wait
  GOTO Main
Jon McPhalen
EFX-TEK Hollywood Office

bzelten

That's what I'm looking for.

Thanks Jon.

jeffh

thanks
i'll try this code.


Quote from: JonnyMac on June 19, 2009, 04:15:31 AM
It sounds like you need the standard candle program -- try this one.

' =========================================================================
'
'   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  Wicks           = PINS


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

SYMBOL  TmMin           = 25
SYMBOL  TmMax           = 75


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

SYMBOL  idx             = B2
SYMBOL  delay           = B3

SYMBOL  lottery         = W5


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


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

Reset:
  DIRS = %00111111                              ' make P0 - P5 outputs
  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
  PAUSE delay                                   ' wait
  GOTO Main


jeffh

this is perfect for using the standard setup on a prop1. i loaded and it is what i needed.

, thank you
Quote from: JonnyMac on June 19, 2009, 04:15:31 AM
It sounds like you need the standard candle program -- try this one.

' =========================================================================
'
'   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  Wicks           = PINS


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

SYMBOL  TmMin           = 25
SYMBOL  TmMax           = 75


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

SYMBOL  idx             = B2
SYMBOL  delay           = B3

SYMBOL  lottery         = W5


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


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

Reset:
  DIRS = %00111111                              ' make P0 - P5 outputs
  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
  PAUSE delay                                   ' wait
  GOTO Main