Controlling hundreds of LEDs

On Tue, 21 Dec 2004 20:54:09 +0000, Danny T wrote:

Dominic-Luc Webb wrote:

May I ask if you can take advantage of any of the status bits?

This is entirely possible. I've never played with the parallel port
before, so my first step today was to connect the 8 data pins up to
LEDs, all connected back to port 25 (ground) and see if I could send
data. (this worked - I have tacky dancing lights!)

I didn't touch the status ports, because I wasn't entirely sure if I
could use them in the same way as the data pins, or if they're
"special". Currently I'm using a horrible interop DLL (I'm writing
managed .NET code in C#) and writing to the dataports is simply a call like:

Output(888, 0); // All off
Output(888, 255); // All on

888 being the address of pin1. If I change this number, I don't know
what will happen - maybe the status ports are the same, maybe not. I'll
look it up tomorrow when I'm a little more awake :)

888 is the decimal address of pins 2 through 9, which is the data port.
Pin 1 is the strobe, which they say is active low; I'm guessing that they
mean that that one's inverted.
http://ee.cleversoul.com/parallel_port.html
http://www.galeon.com/jcgr/
http://www.infonewsindia.com/pinout/Index.html#6A

According to this chart, they've got LPT1 at 3BCh - that's wrong. It's
378h. 890d = 37Ah is the control port. You write to it to control pins
1, 14, 16, and/or 17. 889d = 379h is the status port, which reads in
pins 10, 11, 10, 13, and 15.

So, theoretically, you could set, say, pin 14 and use it as a "chip
select" for an 8-bit latch, or register. Write the data to 888,
read the memory byte where you've stashed your memory of the last
byte written, (where C1 is high) AND it with FEh to send the strobe
pulse, output that to 890 decimal, OR the byte with 1, send it, and
send 01 to turn off the pin 14 chip select. Now you've latched a
byte. You can use that to create chip selects to capture output
from the data port to any other latch - but you'd have to write
a 1 to, say, C2 (04h) to enable your "data" latch, write the
data to whichever of the other bank of latches has been selected
by the control latch. Or you could just pick either/or with one
of the other control bits - you could address 8 different ports
by manipulating 3 of the control bits. And you could decode one
8-bit port to address one of up to 256 outputs. :)

Have Fun!
Rich
 
On Tue, 21 Dec 2004 23:52:05 +0000, Si Ballenger wrote:

On Tue, 21 Dec 2004 21:13:40 +0000, Danny T <danny@nospam.oops
wrote:

Si Ballenger wrote:

74HCT259

Was just looking at the datasheet for this - I think it'll do exactly
what I want! Will need a lot of them hooked together though, and with
the 3 input pins of some being attached to output pins of others, it's
going to be a bit fiddly on the software side!

Can I just make sure I understand this correct...

Using the 3 input pins, I choose which output I'm modifying (a binary
value of 0 to 8), and send the input on the input pin. Then I clock(?)
the "latch" pin, which copies the input state to the output pin I
addressed, and then holds it at that until I change again?

In the latching mode (used to control the individual LEDs), you
use the A0, A1, and A2 input pins to select the chip output pin
you want to set high or low. You set the D data pin on the chip
at 0v for the chosen output pin to output 0v, or set the D pin to
+5v for the output pin to output +5v. Then you clock the LE pin
with +5v to latch the output pin in the desired state (0v or
+5v). The same A0, A1, A2, and D control lines can be connected
to all the 259 chips. You clock the LE input on the individual
chip you want to control. The As and the D can be done using four
of the output pins on the parallel port. The other parallel port
pins can be used for clocking theindividual chips You can use two
of the 259 chips in the demultiplex mode to clock the individual
259 chips used in the latching mode. Using the eight parallel
port data pins and 17 259 chips (2 in demultiplex and 15 in latch
mode), you could individually control 120 LEDs.
With three 74HC373
http://www.ortodoxism.ro/datasheets/HitachiSemiconductor/mXqqsxt.pdf
and
one ULN2808
http://www.allegromicro.com/sf/2801/
you can control 128 LEDs if you don't mind multiplexing them.

Cheers!
Rich
 
On Wed, 22 Dec 2004 10:54:59 +0000, Danny T wrote:

CFoley1064 wrote:

Hi, Danny. The 'HC595 is a serial input, parallel output IC. You output the
data one bit at a time (Data In). After every bit, you toggle the clock active
(CLK), then inactive to shift the data bit one further down the line. You then
present the next bit of data, clock again, and so on. After all the bits are
shifted in, you toggle the Latch pins active, then inactive to present all the
data that has been shifted into the ICs, one bit at a time, to the output pins
of the ICs.

Your hookup will go something like this (view in fixed font or M$ Notepad):


D2 o----o--------------------------o-------------------------o-------
| | |
D1 o--o--------------------------o-------------------------o---------
| | VCC | | VCC | |
| | + | | + | |
| | | | | | | |
| | .--------o----------. | | .---------o---------. | | .-----
| | | RST | | | | RST | | | |
| '-oLatch | | '-oLatch | | '-oLatch
| | | | | | | |
'---oCLK HC595 | '---oCLK HC595 | '---oCLK
| | | | |
| | | | |
D0 o------oData In SQ8o------oData In SQ8o-----oData
| 1 2 3 4 5 6 7 8 | | 1 2 3 4 5 6 7 8 | | 1
'--o-o-o-o-o-6-o-o--' '--o-o-o-o-o-o-o-o--' '----o
| | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | |
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
created by Andy´s ASCII-Circuit v1.24.140803 Beta www.tech-chat.de

No matter how many of the '595s you have chained together, you'll only need the
3 printer/PIC port output pins, D0, D1, and D2 (with the caveat about buffering
mentioned above).

Right, I think I understand - except for what you've labelled as SQ8 on
your diagram. Does this hold the "last" bit that's about to be dropped?
(and does this work based on the clock pin, and not the latch?) So if I
sent 16 bits (clocking active in between each), and *then* latch, would
I get 16 unique outputs, which I can then redraw before the next latch?
Yes:
http://www.semiconductors.philips.com/acrobat_download/datasheets/74HC_HCT595_4.pdf
page 5, Fig. 5.

Cheers!
Rich
 
On Tue, 21 Dec 2004, Dmitri(Cabling-Design.com) wrote:

Speaking of the scrolling screens, you may want to use the same approach:
use specialized LED controller ICs. Maxim makes a whole line of such
devices (so do other people).
Check out this page at maxim's website:
http://www.maxim-ic.com/quick_view2.cfm/qv_pk/1339
Dmitri,

As per my remarks about using frequency to get more permutations, one
concept I hoped someone might "latch" into is that LED brightness
should be possible to control by changing duty cycle. By changing the
rate at which 0's and 1's change, one can obtain such effects. So my
thoughts on utilizing frequency were not only directed towards selection
of LEDs and large numbers of permutations, but also brightness control.
I am curious if any of the controllers you know of permit brightness control
by duty cycle (as opposed to voltage) that would have a much wider dynamic
range than just two, like "bright" or "normal" intensities?

I guess one could envision a frequency-to-voltage converter to control
brightness by voltage, but I suspect changing duty cycles would be
energetically more efficient.

I guess one could also consider that frequency modulation and analog
circuitry has a lot of parallels with biological processes. Danny did
mention a long term goal of robotics. I am rather impressed with the
analog robots I have seen.

Dominic
 
Dominic-Luc Webb wrote:

On Tue, 21 Dec 2004, Dmitri(Cabling-Design.com) wrote:

Speaking of the scrolling screens, you may want to use the same
approach:
use specialized LED controller ICs. Maxim makes a whole line of
such
devices (so do other people).
Check out this page at maxim's website:
http://www.maxim-ic.com/quick_view2.cfm/qv_pk/1339

Dmitri,

As per my remarks about using frequency to get more permutations, one
concept I hoped someone might "latch" into is that LED
brightness
should be possible to control by changing duty cycle. By changing the
rate at which 0's and 1's change, one can obtain such effects. So my
thoughts on utilizing frequency were not only directed towards
selection
of LEDs and large numbers of permutations, but also brightness control.
I am curious if any of the controllers you know of permit brightness
control
by duty cycle (as opposed to voltage) that would have a much wider
dynamic
range than just two, like "bright" or "normal"
intensities?

I guess one could envision a frequency-to-voltage converter to control
brightness by voltage, but I suspect changing duty cycles would be
energetically more efficient.

I guess one could also consider that frequency modulation and analog
circuitry has a lot of parallels with biological processes. Danny did
mention a long term goal of robotics. I am rather impressed with the
analog robots I have seen.

Dominic
Well, as a matter of fact, brightness control is one of the major reasons
people get to use specialized ICs (second after multiplexing, of course).
All (I know of) of them would allow you to control brightness either
digitally for selected segments or analog for overall brightness of the
module. As far as I know, all use PWM for digital brightness control.

--
Dmitri Abaimov, RCDD
http://www.cabling-design.com
Cabling Forum, color codes, pinouts and other useful resources for
premises cabling users and pros
http://www.cabling-design.com/homecabling
Residential Cabling Guide
-------------------------------------



##-----------------------------------------------##
Article posted with Cabling-Design.com Newsgroup Archive
http://www.cabling-design.com/forums
no-spam read and post WWW interface to your favorite newsgroup -
sci.electronics.basics - 8240 messages and counting!
##-----------------------------------------------##
 
On Thu, 23 Dec 2004 07:48:32 GMT, Rich Grise <rich@example.net> wrote:

On Wed, 22 Dec 2004 09:17:47 -0600, John Fields wrote:

On 22 Dec 2004 14:17:04 GMT, cfoley1064@aol.com (CFoley1064) wrote:


If you're doing 5X7 matrix displays, you don't have access to all 70 LED pins
anyway. You have to address them as row/column. If you do it that way, you
will minimize the shift register outputs. But, like the professional displays,
you then have to be concerned about a multiplexing setup where you use
persistence of vision to go across the columns fast enough that they don't
appear to flicker.

---
If you're simply scrolling text, there's no multiplexing needed.

If you're just clocking bits through a bank of shift registers, there's
no multiplexing _possible._
---
Of course. That, however, doesn't change the validity of my statement.
---

You have to be able to control rows and
columns 8 bits at a time. This does reduce the chip count dramatically -
2 vs. 8 for 64 LEDs.
---
Yes, but if you have even a modest 8 character 5X7 marquee array, like
this:

| 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 |
................................................
................................................
................................................
................................................
................................................
................................................
................................................
| 1 || 2 || 3 || 4 || 5 || 6 |

and you're broadsiding columns and multiplexing 48:1, you'll need 7
row and 48 column drivers, with your row drivers needing to source or
sink 48 times the current needed by a single lamp, and your column
drivers needing to sink or source seven times that, a whopping 336
times the requirement of a single lamp for the eqivalent brightness of
a static display. For 20mA LEDs, that comes to 960mA for the row
drivers and 6.72A for the column drivers!!!

On top of that, in order to avoid flicker, the array would need to be
refreshed at about 30 Hz, which means exercising the columns at 1440Hz
while doing the scrolling, so the software overhead for a one-off has
grown considerably over that for a simple static scrolling marquee and
RFI problems may be rearing their ugly heads.

Bottom line is, for a one-off, muxing may not be as cheap as it looks,
even with the saving of 41 chips (about $8) and the 656 pads and real
estate needed to mount them to a PCB ($?) for the array above.

--
John Fields
 
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. There is no reason a single pin from your parallel port could
not do something similar. 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.

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. 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. I think it ends up working similar to
a diac/triac circuit that controls the brightness of a bulb by chopping
up the current.

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. 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.


step_function()
{
for(i=1; i<=step_value1; i++) {

/* Set the data signals (D0-7) of the port */
outb(0, BASEPORT);

/* Sleep for a while */
usleep(10000);

outb(direction1, BASEPORT);
usleep(10000);

}

for(i=1; i<=step_value2; i++) {
outb(0, BASEPORT);
usleep(10000);
outb(direction2, BASEPORT);
usleep(10000);
}
}



Dominic
 
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
 
On Thu, 23 Dec 2004 15:34:59 -0600, John Fields
<jfields@austininstruments.com> wrote:

A little different notation under the timing, just for the sake of
clarity...


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__| |___________________|
|<------T/2-------->| |
|<------------------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__| |__________|
|<-----------3T/4----------->| |
|<------------------T------------------>|

will make the LED seem 75% as bright as it would be if it were on all
the time, and:

_________ _________
ledon__| |_____________________________| |___...
|<--T/4-->| |
|<------------------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
 
"Dominic-Luc Webb" <dlwebb@canit.se> wrote in message
news:pine.LNX.4.44.0412231437400.2353-100000@uno.canit.se...
snip
I am curious if any of the controllers you know of permit brightness
control
by duty cycle (as opposed to voltage) that would have a much wider dynamic
range than just two, like "bright" or "normal" intensities?
The latest such controller I've worked with allows the pilots of Lynx
helicopters to vary the brightness of cockpit displays to cater for ambient
from night (using night vision goggles) to full sunlight.
No big deal. Been around for ages.
One thing that the wonderful frequency stuff seems to ignore is the need to
continually use almost all of the cpu power and write huge amounts of data
to the port. Using latches to store the LED controls allows the cpu to do
something else for 99% of the time. Also reduces interference emitted from
your LED circuit - could be a source of trouble with the neighbours if you
interrupt their tv/radio...
hth
Neil
 
On Thu, 23 Dec 2004 15:34:59 -0600, John Fields
<jfields@austininstruments.com> wrote:


---
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
^^^^^
12

two-note chords, so calling what you can get out of a touch-tone
keypad a 'tune' might be stretching it.
--
John Fields
 

Welcome to EDABoard.com

Sponsor

Back
Top