November 22, 2024, 02:40:51 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.


6 channel dimming marquee chaser

Started by jukingeo, October 21, 2007, 05:43:47 PM

Previous topic - Next topic

jukingeo

Hello All,

This is a very simple, but also very pleasing looking Marquee style chaser.  It is set up for 6 channels, but you could easily expand on it by changing the '8 to 13' values in the FOR NEXT loops and also the HIGH/LOW LED subroutines.  You could also alter the timing values, but the ones I selected will producing a pleasing effect as is.  This program could also be easily adapted to the BS1.

Enjoy!

' =========================================================================
'
'   File...... A really nice 6 Letter Marquee With Fading Capability
'              This is a 'For Next' / 'Gosub' loop explotation experiment
'   Description:  This is a surprisingly complex flashing pattern that
'                 includes PWM dimming action.  Yet through use of FOR NEXT
'                 loops and GOSUBS, the program code is pretty simple.
'                 The program is fixed to LED outputs 8 to 13.
'                 While I have figured out all the timing to what I feel is
'                 the most pleasing effect...feel free to experiment!
'   WARNING!...   IF YOU WANT THIS PROGRAM TO CONTROL ACTUAL LIGHTS, YOU
'                 MUST CONNECT THE OUTPUTS TO A DIMMABLE SOLID STATE RELAY
'                 **PROGRAM WILL NOT WORK WITH MECHANICAL RELAYS.
'   Purpose...
'   Author.... Geo
'   E-mail.... jukingeo@optonline.net
'   Started...
'   Updated...
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================



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




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

faderate         VAR     Byte           ' PWM fading
led                 VAR     Nib            ' LED Output setting
ledon              VAR     Nib            ' Keep LED set to high
cycle              VAR     Nib            ' For Darkchase loop
flash              VAR     Nib            ' For Flash loop

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


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

Main:

ledon = 8

  FOR led = 8 TO 13                    ' This loop section fades LED outputs
    FOR faderate = 0 TO 255            ' 8 - 13 on in order.
     PWM Led, faderate, 3
    NEXT
     HIGH ledon
     ledon = ledon + 1
  NEXT
  PAUSE 1000                           ' Time delay before next loop starts
  FOR cycle = 1 TO 3                   ' This iterates the next loop 'x' times
    FOR led = 8 TO 13                  ' This loop section 'dark chases' the LEDs
      GOSUB Darkchase
    NEXT
  NEXT
  PAUSE 1000                           ' Time delay before next loop starts
  FOR flash = 1 TO 2                   ' This loop flashes the entire display
    GOSUB golow                        ' 'x' times (flash).
    PAUSE 150                          ' Time LED off delay
    GOSUB gohigh
    PAUSE 600                          ' Time LED on delay
  NEXT
  PAUSE 1000                           ' Time delay before next loop starts
  FOR led = 8 TO 13                    ' This loop section rapidly fades out the
    FOR faderate = 255 TO 0 STEP 7     ' LEDS from left to right using PWM
      PWM led, faderate, 3
    NEXT
  NEXT
  PAUSE 1000                           ' Time delay before next loop starts
GOTO main                              ' Rinse and repeat.


Darkchase:                             ' Darkchase subroutine

  LOW led
  PAUSE 85
  HIGH led
  PAUSE 100

RETURN

golow:                                 ' Turn LEDs off for flash subroutine
  LOW 8
  LOW 9
  LOW 10
  LOW 11
  LOW 12
  LOW 13
RETURN

gohigh:                                ' Turn LEDs on for flash subroutine

  HIGH 8
  HIGH 9
  HIGH 10
  HIGH 11
  HIGH 12
  HIGH 13

RETURN

JonnyMac

For efficiency, I would change a couple routines:

Go_Low:
  OUTH = %00000000
  RETURN

Go_High:
  OUTH = %00111111
  RETURN


There's no need to have all those redundant code fetch/decoded/execute instructions -- this method is much faster.  Note that this method is predicated on having the following declaration in your Initialization section:

  DIRH = %00111111
Jon McPhalen
EFX-TEK Hollywood Office

jukingeo

Quote from: JonnyMac on October 21, 2007, 07:41:03 PM
For efficiency, I would change a couple routines:

Go_Low:
  OUTH = %00000000
  RETURN

Go_High:
  OUTH = %00111111
  RETURN


There's no need to have all those redundant code fetch/decoded/execute instructions -- this method is much faster.  Note that this method is predicated on having the following declaration in your Initialization section:

  DIRH = %00111111

Thanx, Jon

I knew there was probably a way to streamline things.   This was actually something I threw together really quick and I did it without look up tables or anything...just FOR NEXT loops and subroutines.  The results far exceeded my expectations and for such a small program, I figured I would share it.  But apparently you did find a way to even make it smaller :).

I knew this would be a great program for anyone that wants to have a sophisticated looking marquee sign for a haunted attraction or for even something more permanent.

Overall I really amazed myself with this one in that it does show what you can do with the dimming capabilities of the BS-2.

I made a revision of this PWM code on the chaser/ random flasher program you written for me and implented this into the Flux Capacitor/ Random light flasher program you written for me a while back.  The chase for the flux capacitor looks fantastic now with the dimming action.  It does look more like a 'pulsating' effect rather than chasing.  I know this isn't movie accurate but it looks WAY better.

I am really amazed at what this little microcontroller can do.  It DOES get me curious as to what the SX can do...or even the Propeller chip.

Geo