Shop OBEX P1 Docs P2 Docs Learn Events
controlling many LED''s - requested info — Parallax Forums

controlling many LED''s - requested info

ArchiverArchiver Posts: 46,084
edited 2000-07-25 01:28 in General Discussion
'Massive' LED use with generic shift registers.
Thrown together on 7-24-2000 1pm by "Anubis" Mikorians@y...

DISCLAIMER
Actually, (I apologize) it was the R.S. 74hct164e that I was using,
and basically, it's an unlatched 8 bit shift register. By unlatched,
I mean that the bits will (scopewise) appear to cascade down the
output pins of the chip as your processor sends it the bits, now
your eye may or may not be able to detect this happening depending
upon how many registers you've daisy chained together and how fast
your program can 'clock in' the bits to the register. Persistence of
vision comes into play here. I've written this document for
beginners, so have patience, all will become clear eventually.
Note that you COULD use a register output to control a -coil-based-
load, with the use of either a transistor or a robust chip such as
the ULN2803. I have controlled uni-polar steppers with this
arrangement with fair success.

If you can find a LATCHED shift register, (what we'll call the deluxe
version of the shift register), the output pins will all change at
the same time after they've been 'clocked in' and you've raised the
enable(?latch?) pin (missing on the 164) to high. This would, of
course then require 3 pins to operate.

THE SHIFT REGISTER IN QUESTION

+
+
| |
-1 Daa 7 Vcc(+5) 14-
-2 Dab 4 Q7 13-
-3 Q0 H Q6 12-
-4 Q1 C Q5 11-
-5 Q2 T Q4 10-
-6 Q3 1 -MR 9-
-7 Gnd 6 CP 8-
| 4 |
+
+

Q PINS (REGISTER OUTPUTS)
The 'Q' pins are, of course, the 5v outputs from the shift register.
LED's can only handle about 2.4VDC, so the ohm's law rule of thumb
here is (5-2.4)/.02a (20ma) = 130ohm (min.) resistors between the 5v
outputs and each LED. You may find this formula of use in the future.
Plain old 150ohm or 220ohm resistors work just fine. More is better
(and dimmer). For future reference, these are called 'logic level
outputs'.

These register outputs seem robust and able to handle LED level
current. I found that I had no difficulty using them with the usual
220ohm resistors between the outputs and any LED. One can hook up
a 7 segment display to a shift register without difficulty and be
able to 'twiddle' any segment on or off. One can also save a few
bucks with a 'resistor package' These look like chips and contain
8 resistors. Be slightly careful with these, as they don't take
heat as well as normal resistors do. They're ok though.

THE OTHER REGISTER PINS
Daa and Dab are where our data bits go in to the register. I've seen
circuits where Dab was just tied to high, but I couldn't get mine to
work that way. I tied Daa and Dab together as a single input. The
R.S. pinout diagram shows them as an AND gate.

It's a REALLY good idea to put a .1uf capacitor between +5 and Gnd on
a shift register as they are VERY sensitive to ANY power fluctuations
and can be quite temperamental buggers.

CP is the clock pulse input. The 2nd pin we'll attach to our stamp.

__
MR is the memory reset line. You don't actually have to use this, but
it's there for your convenience. Bearing in mind that you'll use
shiftout to change any bits, you'll also probably be shifting out
ALL 8 of them, and a reset shouldn't be necessary- since anything
previous (trash data) will be cleared out when you do so. I simply
place a shiftout with 0's at the very start of my stamp program.
***We'll be tying this line to +5. Switching this line to ground will
cause a reset to occur. (The line over the symbol name means that it's
inverted, and that it should normally be high to avoid a reset).

SAMPLE CIRCUIT WITH ONLY 1 SHIFT REGISTER

+
+
| | +
+
| | | |
+-1 Daa 7 Vcc(+5) 14-+-||-+ |
Stamp2 pin 5--+ | 4 | | |
+-2 Dab H Gnd 7
+ |
| C -MR 9
+ 220ohm LED
Stamp2 pin 6----8 CP T Q0 3
/\/\/\---->|---Gnd
| 1 Q1 4
/\/\/\---->|---Gnd
| 6 Q2 5
/\/\/\---->|---Gnd
| Q3 6
/\/\/\---->|---Gnd
| Q4 10
/\/\/\---->|---Gnd
| Q5 11
/\/\/\---->|---Gnd
| Q6 12
/\/\/\---->|---Gnd
| Q7 13
/\/\/\---->|---Gnd
| |
+
+

Software for Stamp2:

Q var byte
Dataline var out0
Clockpulse var out1

Output 0:Output 1:Q=0:Shiftout Dataline,Clockpulse,1,[noparse][[/noparse]q\8]

Bear also in mind that when the stamp sleeps or hits and END of
program
that it tends to 'wink' its output lines once in a while, and that
this can cause spurious data to appear on the shift register.
To avoid this, one can end the program thusly-

EndLoop:
Goto EndLoop

Note that this doesn't permit the stamp to sleep, and uses more
current.


ADDING MORE SHIFT REGISTERS
To add more shift registers, simply wire the Q7 line of the first
shift
register to the Daa+Dab line of the next one. ONLY the STARTING (1st)
register's Daa+Dab line goes back to the stamp pin 5.
ALL CP wires are all tied together AND to the stamp pin 6.

Basic Diagram: chip1 chip2 chip3

Stamp pin 5>
<Daa+Dab
Q7>
<Daa+Dab
Q7>
<Daa+Dab
Q7>...

CP CP CP
| | |
Stamp pin 6>
+
+
+



This neat arrangement has only one major drawback:
an odd number of bits. The first register lacks a Q7 now (you can
tie an LED to it, but it's a copy of Q0 on the next register),
so only 15 bits - NOT 16 BITS - are actually available.
Here's the proper program.

*2 shift registers*

Software for Stamp2: Alternate stamp2 program:

Q1 var byte Q var word
Q2 var byte Data var out0
Data var out0 Clock var out1
Clock var out1

Output 0:Output 1:Q1=0:Q2=0 Output 0:Output 1:Q=0
Shiftout Data,Clock,1,[noparse][[/noparse]Q1\7,Q2\8] Shiftout Data,Clock,1,[noparse][[/noparse]Q/15]
'Q1.bit0(7) is unused (bit 8) 'Q.bit0(15) is unused (Bit 16)
Sign In or Register to comment.