May 20, 2024, 09:34:29 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.


Twinkling Stars

Started by id0, September 03, 2009, 10:11:49 PM

Previous topic - Next topic

id0

I'm looking for a way to use the Prop-1 to make six LEDs (one per port 0-5) twinkle similar to looking up at a star.  I was thinking that I could use the Candle program to do this, but is still doesn't look right.  I've tried reducing the delay and increasing the size of the cap with the LED.  I'm beginning to think that the RANDOM is causing me problems by having the output potentially stay off too long.  Perhaps the LED's should be on most of the time and only randomly go off every once in a while.  Maybe even do a pseudo PWM by keeping a counter for the six output and each loop see if each counter (up to 10) has reached it's defined limit...If it has then reset to zero and set the appropriate output to zero (so it kind of dims).  If the counter is zero, then the output is off, else the output is on.  Hmm...  Or is this something better handled by a controller with dedicated PWM on multiple?  Has anyone done anything like this before?  Thanks!

JonnyMac

Simulating nature is hard -- it always takes a lot of experimentation.

I came up with this program and it looks pretty good on the Prop-1 Trainer; I think it would look nicer running through a WickLED type circuit that would smooth out the flickers.  Give it a try.  The important thing to do is experiment with the timing until it looks right to you.

' =========================================================================
'
'   File...... Twinkle.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2009 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 03 SEP 2009
'
'   {$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  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  idx             = B2
SYMBOL  delay           = B3

SYMBOL  lottery         = W5


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

Reset:
 PINS = %00111111                              ' all on
 DIRS = %00111111                              ' set output pins

 lottery = 1031


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

Main:
 FOR idx = 1 TO 3                              ' big stir
   RANDOM lottery
 NEXT

 PINS = lottery                                ' some outs off
 RANDOM lottery                                ' re-stir
 DELAY = lottery // 15 + 15                    ' short off delay
 PAUSE delay

 PINS = %00111111                              ' all on
 RANDOM lottery                                ' re-stir
 DELAY = lottery // 100 + 50                   ' longer on delay
 PAUSE delay

 GOTO Main


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


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


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

id0

Thanks, Jon!  It does look pretty good.  I'll play with it and hook it up fiber optics that I'll be using (I'm making a small night sky panel for my son's room).  Out of curiosity, if I wanted something like a slow shimmer, maybe even slow fades, I assume that I'd have to go to a faster processor, probably one that will support hardware PWM.  Would the Prop-SX the be the logical choice for that?  Thanks again!

JonnyMac

September 07, 2009, 12:26:09 AM #3 Last Edit: September 07, 2009, 12:58:25 AM by JonnyMac
If you look in the code there are PAUSE statements that could be modified.  To keep things simple I would just drop caps across the the outputs; those will slow things down a bit.

That said, I did write a program for Disneyland last year that uses the Prop-SX to do shimmering stars.  It has 16 PWM channels (one for each output) and a master PWM control of the overall brightness (allows the stars to ramp on -- they loved the effect).  If you request it I will post that code in the Prop-SX forum (posting it here will cause confusion).

Jon McPhalen
EFX-TEK Hollywood Office