Maker Pro
Maker Pro

4017s lighting up 60 LEDs sequentially

lpsarsam

Dec 23, 2011
7
Joined
Dec 23, 2011
Messages
7
Hi :)

I am working on an LED clock that uses a pic microcontroller to output pulses every second (for the second 'hand') to a 4017 chip (which should be connected to other 4017s) to light up the LEDs sequentially.

My question is, how can I connect the 4017s together so they can light up the 60 LEDs sequentially using only 1 input.
A circuit diagram would be very useful.

Thanks :)
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,722
Joined
Nov 17, 2011
Messages
13,722
I don'Ät think the 4017 is the right IC for the job. You can cascade 4017s, but the result will dissapoint you: When the first 4017 counts tp 10, the next 4017 will count 1 up. Then the first 4017 will restart at 0 and again when it reaches 10 the second 4017 will count 1 up. And so on. Also for the 3rd, 4th ... 4017.

What you need is a shift register, e.g. 74HCT164 (http://www.fairchildsemi.com/ds/MM/MM74HCT164.pdf).
You connect the clock to all register simultaneously.
You also connect all CLEAR inputs together and to one pin of the PIC.
Connect Qh from IC1 to InA of IC2, QGH from IC2 to InA of IC3 etc.
Connect all InB inputs to Vcc using a 1kOhm Pull-Up resistor.
Now you can
1) With each clock light one more LED by keeping InA of the first IC high. Or
2) With each clock shift the lighted LED one position by keeping InA of the 1st IC only high during the first clock pulse, then setting InA to low during subsequent pulses.
The beauty of using a µC is that you can easily experiment here.
Use the CLEAR function (connected to another port of the PIC) to simultaneously clear all LEDs.
Make sure to limit the output current to <=4mA so you don't overload the ICs. If 4mA is not enough for your LEDs, use buffer stages (a simple Transistor with base resistor and collector resistor will do.

Harald
 

lpsarsam

Dec 23, 2011
7
Joined
Dec 23, 2011
Messages
7
Thanks, this seems to be exactly what I need. I will definitely get a couple of these and experiment with them :)
 

gorgon

Jun 6, 2011
603
Joined
Jun 6, 2011
Messages
603
You could also use a >=6bit binary counter, a number of 3bit to 8 decoders driving the leds. You'll also need a couple of gates to reset the counter at 60, back to 0.

You'll need 9 74hc138 decoders, 8 to drive the 60 leds and the last to select one of the others at the time.

TOK ;)
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,722
Joined
Nov 17, 2011
Messages
13,722
Technically right.
I count at least 10 ICs for that solution (9 decoders + 1 counter) hwereas a shift register solution will require only 8 ICs (8*8 bit shift registers = up to 64 LEDs).

The shift register solution will allow to either have only 1 LED alight at any time (that would suit the "seconds hand" idea of Iparasm) or you could have a ring of LEDs that becomes longer each second untilo at the 60th second all LEDs turn off simultaneously. Just an idea...


Harald
 

lpsarsam

Dec 23, 2011
7
Joined
Dec 23, 2011
Messages
7
Thanks, but I think the shift register idea would work better for this project. :)
Also, Harald, do you know of any shift registers like the one you showed me but through hole instead of surface mount, and if possible,have more LED outputs (for the convenience of needing to solder in less ICs)?
Thanks :)
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,722
Joined
Nov 17, 2011
Messages
13,722
You can get the same IC in through hole.
Alas, I don't know of shift register with more bits for this function. In the digital world, 8 is kind of a magic number :)

Harald
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Check out figure 7 on page 8 of this 4017 datasheet.

It's a bit more complex than using shift registers, but has the advantage of naturally operating in a ring without needing a single "1" fed to it.

It's also a bit more complex and a little harder to clear.
 

TedA

Sep 26, 2011
156
Joined
Sep 26, 2011
Messages
156
lpsarsam,

I'm not sure that regular logic ICs are your best bet. There are alternatives.

Regular CMOS logic parts, such as the CD4017 have pretty weak output pins; your LEDs may want more current than the rated output current for such parts.

Don't forget that you will need to limit the current to the LEDs. A standard logic output will require a series resistor, but ICs are available that incorporate current limiting on each output. This can reduce the parts count and wiring required.

National Semi used to make some serial in, parallel out shift registers that would do just what you need, with 30 or so outputs per package. These were made to drive LEDs, and had built-in current limiting on each output. I'm not sure if anyone still makes these. Maxim and ST do currently have smaller versions, with up to 16 outputs per package.

You should consider using PIC I/O pins to drive your LEDs directly, without using counters of shift register ICs. If you need more I/O pins than can conveniently be had on one PIC, you can use multiple PICs.

There was a time when microcontroller pins were costly and logic IC pins were much cheaper, but that was then.

You might find some advantage in multiplexing your LEDs, depending on how much current the LEDs require, and how powerful are your output pins. A four-way MPX scheme would allow a single 16 output driver such as the ST STP16CPC05 plus four transistors to drive all 60 LEDs.

Ted
 
Top