Re: Controlling hundreds of LEDs

From: John Fields (jfields_at_austininstruments.com)
Date: 12/23/04


Date: Thu, 23 Dec 2004 15:34:59 -0600

On Thu, 23 Dec 2004 18:36:10 +0100, Dominic-Luc Webb <dlwebb@canit.se>
wrote:

>On Thu, 23 Dec 2004, Danny T wrote:
>
>> I'm confused now... By frequency, do you mean I can output things
>> distinguishably different than just the +5v I@m currently sending??
>
>
>Hi Danny,
>
>Yes. On the one hand, there is the absolute value 0 or 1, which could
>be interpreted as "digital" off or on, respectively. As in my stepper
>motor example, there is also the relative rate at which 0's and 1's are
>changing. The coils on a stepper motor respond to these changes and
>the shaft turns faster or slower. A speaker would be another example,
>also operated by a coil. Passing pulses (sets of 0's and 1's) at
>different rates (frequencies) could in principle yield different tones,
>much like what happens when you hit different buttons on your telephone,
>although, let us not get bogged down in details of how the registered
>trademark "Touch-tone" works. Just note that different frequencies are
>being generated when you hit different buttons. Choosing different
>combinations of buttons in a series could play different tunes, for
>instance.

---
The ratios of frequencies between adjacent notes on the equally
tempered scale is the twelfth root of two.  No such relationship
exists between the tones used to generate touch-tone DTMF.  Moreover,
the only outputs available from a normal touch-tone keypad are seven
two-note chords, so calling what you can get out of a touch-tone
keypad a 'tune' might be stretching it.
---
 
> There is no reason a single pin from your parallel port could
>not do something similar.
---
There's a very good reason why you can't:  Without some interesting
filtering on the single pin, it would be impossible (I think) to
generate two sine waves with different frequencies simultanously. 
---
>Consider what would happen if you sent 20 0's
>and then 20 1's, and repatedly this loop continuously and the output was
>a speaker.
---
No big deal; you'd be  feeding the speaker with a square wave.
---
>Distinguishing these two concepts: Feeding a counter IC, like a Johnson
>4017 at different rates from a pin of the parallel port would simply
>make the 4017 cycle through the stages faster or slower. Connecting LEDs
>to each of the stages would cycle through each LED, but would not
>necessarily change the brightness of each LED. 
---
Since the duty cycle would be constant, the brightness would remain
constant as well, once the persistence of vision fused the on-off
changes.
---
 
>If instead, you connected
>more directly from the port to an LED (using an appropriate resistor),
>you could not only turn it on, the rate at which you switch between 0's
>and 1's would dictate brightness.
---
No. the brightness would be determined by the ratio of time on to time
off, more particularly what we call the 'duty cycle', which is the
ratio of the time on to the time of the entire cycle.
---
> I think it ends up working similar to
>a diac/triac circuit that controls the brightness of a bulb by chopping
>up the current.
---
In the sense that the TRIAC can control where in the cycle the lamp
can turn on, that's correct.
---
>For starters:
>
>Try this, since you can program your parallel port; with whatever language
>you are programming in, you can have for/while loops that cycle between
>the 0 and 1 states. Add a pause between the instructions for setting 0 and
>1. Below is a code fragment I once wrote in C (for Linux). You can change
>frequency by changing the value of usleep. This would cause stepper motors
>to turn faster or slower. It could presumably also change the tone of a speaker
>or the brightness of an LED, etc.
---
If it changes the frequency of the signal coming out of the port it
will change the tone of a speaker and the rotational soeed of a
stepper, but it _won't_ change the brightness of an LED.  To do that
you'd need to change the duty cycle of the signal feeding the LED.
---
>Taking this to a further level of
>complexity, one could split the outgoing signal from each data pin
>(voltage or current divider, logic circuits, etc) to take advantage of both
>absolute 0 and 1 states, as in loading registers, etc and also the
>frequency information (direct pulse modulation of LED brightness) or
>via a frequency-to-voltage conversion (voltage dictates brightness). It
>represents one means of sending serial information via a parallel port.
>Similarly, a Morse code scheme sent from a single pin could also be used.
---
You need to understand why pulse-width modulation, (PWM) not
frequency, can change the brightness of an LED before you start
advocating the use of more complex hare-brained schemes.
Here:
If you start with a signal that looks like this:
        _______________________________________________________
ledon__|
The LED will initially be off, but when ledon goes high it will turn
on and stay on for as long as ledon remains high.
Now, let's make ledon generate this squarewave signal continuously:
        ___________________                     __________...
ledon__|                   |___________________|
       |<------Ton-------->|                   |
       |<------------------T------------------>|
Since the LED will be on 1/2 the time and off for the remainder of the
cycle (which is twice as long as Ton), if the frequency (or what we
call, in this case, the 'repetition rate' or 'rep rate') is high
enough so that our eyes can't distinguish between the on and off
states of the LED, the LED will appear to be half as bright as when it
was on all the time.  Similarly:
        ____________________________            __________...
ledon__|                            |__________|
       |<------------Ton----------->|          |
       |<------------------T------------------>|
will make the LED seem 75% as bright as it would be if it were on all
the time, and:
        _________                               _________
ledon__|         |_____________________________|         |___...
       |<--Ton-->|                             |
       |<------------------T------------------>|
would make it seem 1/4 as bright.
Our eye has a logarithmic response to light intensity, so the numbers
I gave aren't exactly right, but you get the idea...
-- 
John Fields

Quantcast