November 24, 2024, 10:05:09 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.


Fastest possible speed on LEDs

Started by gadget-evilusions, March 29, 2007, 08:41:22 PM

Previous topic - Next topic

gadget-evilusions

March 29, 2007, 08:41:22 PM Last Edit: March 29, 2007, 09:22:39 PM by gadget-evilusions
What would be the fastest I could cycle through the 8 outputs on the prop-1 controlling as many led's on each output as possible. I have someone who wants to do a black light cage maze and I wanted to make blocks of about 30 uv leds and control at least one block on each out put, and cycle through them. I probably won't need to cycle through them more than once a second but just curious how fast I really could get? Thanks.
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

JonnyMac

You should use a big driver like a TIP120 (Darlington) to handle that many LEDs on each output.

Here's a very quick way to cycle through all eight outputs; adjust the PAUSE as desired (without it, all LEDs appear to be on and a bit dim because the outputs are switching so fast).

' {$STAMP BS1}
' {$PBASIC 1.0}

SYMBOL  idx     = B2

Setup:
  DIRS = %11111111

Main:
  FOR idx = 0 TO 7
    LOOKUP idx, (1,2,4,8,16,32,64,128), PINS
    PAUSE 50
  NEXT
  GOTO Main
Jon McPhalen
EFX-TEK Hollywood Office

gadget-evilusions

Could you explain the program to me a bit. I am not sure how that is cycling through the outputs.
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

JonnyMac

Sure.  The program starts by making all the pins outputs (using the DIRS register; a 1 bit makes the associated pin an output).  In the main body the program uses a FOR-NEXT loop to create an index (in idx) for a LOOKUP table.  LOOKUP will move the value (from the table) at the index to the output variable -- in this case that is the PINS register which goes right to the outputs.  Let me show you the table values in decimal (as in the program) and in binary (as they appear on the outputs) as this will help you visualize what's happening:

  1 - %00000001
  2 - %00000010
  4 - %00000100
  8 - %00001000
16 - %00010000
32 - %00100000
64 - %01000000
128 - %10000000


Here's another way to do the same thing -- this might have been a better example:

Main:
  FOR idx = 0 TO 7
    HIGH idx
    PAUSE 50
    LOW idx
  NEXT
  GOTO Main


Keep in mind that as there are many roads that lead to Rome, there are many ways to solve a given programming problem -- knowing a variety of solutions gives us the flexibility we need to cover any contingency.

Jon McPhalen
EFX-TEK Hollywood Office

gadget-evilusions

Now that makes sense. Thank you once again.
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components