Cascading CD4017s

Thread Starter

NigelL12

Joined May 8, 2020
8
I have previously cascaded three CD4017s to effectively count to 25 which worked well. I now require a circuit thar can count to seventy! That would require nine 4017s and the and gates (4081) to achieve this. I have been told it won’t work properly but not by anyone who has tried this or a similar exercise. The cascading is as per the Texas Instruments data sheet and they do not say there is a limit on cascading. The power supply is a stable regulated 5.1 volts and the output currents drawn will be about 0.4mA. The clock frequency is low, of the order of single figure Hz, and with careful layout I can’t see why it should not work. Does anyone have any experience with this or any useful suggestions. Obviously I don’t want to build a circuit if it is destined for failure, hence my asking the question.
 

crutschow

Joined Mar 14, 2008
38,331
I see no reason it can't be extended indefinitely.

But why not use a binary or BCD-decade counter which would only require two chip to count to 70?
 

Irving

Joined Jan 30, 2016
5,004
Why do you need so many? Were you just counting to 25, or using 25 discrete outputs?

The CD4017 is, from memory, a decade counter. it has 10 outputs for 0 - 9 and a carry to clock the next decade, so two will count to 100... unless you need the individual 70 outputs...

@crutschow - you're obviously a faster typist than me!
 

MrChips

Joined Oct 2, 2009
34,630
It will work as long as you are not going to attempt to decode the outputs in order to detect a terminal count.
With cascaded ripple counters the propagation delays will result in false decoding.
 

Tonyr1084

Joined Sep 24, 2015
9,744
Some methods I've used:
1592403415699.png1592403453748.png
You can replace the 4013 with another 4017 and use each of its outputs to switch on a transistor, thus extending the count all the way up to 100 if so desired. And you use only two 4017's. I'm searching my library for THAT diagram. When I find it I'll post it.
 

Tonyr1084

Joined Sep 24, 2015
9,744
After lots of searching, the best I can find is this diagram: Notice output 0 drives a transistor that grounds the first 10 LED's. Output 1 drives the second transistor which grounds the second 10 LED's. This circuit has been cropped because of something I've been messing with for years. It's a little different from what is normally done when driving LED's but I can't find the diagram I wanted, which would show how to cascade up to 100 LED's. With a little tinkering you could add a third counter and cascade up to 1000 LED's. Literally, there's no end to how far you can go with it.

The first counter moves from one LED to the next. The second counter selects which set (in sets of 10) is grounded through a resistor. [edit] I think I have the clock circuit drawn wrong. And zero through nine are outputs in sequence, not pin numbers. [end edit]
1592407407708.png

Here's one I found on the internet: Again, you can have up to 10 sets of 10 LED's driven from just two 4017's.
1592407838654.png
 
Last edited:

MrChips

Joined Oct 2, 2009
34,630
I have previously cascaded three CD4017s to effectively count to 25 which worked well. I now require a circuit thar can count to seventy! That would require nine 4017s and the and gates (4081) to achieve this. I have been told it won’t work properly but not by anyone who has tried this or a similar exercise. The cascading is as per the Texas Instruments data sheet and they do not say there is a limit on cascading. The power supply is a stable regulated 5.1 volts and the output currents drawn will be about 0.4mA. The clock frequency is low, of the order of single figure Hz, and with careful layout I can’t see why it should not work. Does anyone have any experience with this or any useful suggestions. Obviously I don’t want to build a circuit if it is destined for failure, hence my asking the question.
When your chip count gets very high it is worthwhile looking for other solutions.

1) You can get multi-stage counters in one chip, e.g. CD4020, CD4040, CD4060.
2) With an MCU you can get any time sequence or delay in a one-chip solution.
 

Tonyr1084

Joined Sep 24, 2015
9,744
To recap my approach: Use of two 4017's and a clock circuit such as a 555 can count sequences up to 100. If you want 70 you can connect the reset pin to output #7. After the 69th count (70th counting the first zero) your chip can reset and start the 70 LED sweep again. If you want an odd number reset you'd need an 2 input AND gate connected to two pins to trigger the reset. Suppose you wanted 55 counts: One input to the AND gate would be connected to the fifth output on the first counter and the fifth output on the second counter. The output of the AND gate would be connected to the reset pins of both counters. When the 55th count occurred a reset would send everything back to the first count (zero).

I used mine as chase lights. A fascinating toy for back when we used to smoke the happy stuff, sit and watch in the dark as Pink Floyd or Lead Zeppelin played. The strobe of the LED's was tied to the audio amplitude and audio frequency. Blew our minds. May be a reason why the top is so smooth (my avatar).
 

Thread Starter

NigelL12

Joined May 8, 2020
8
After lots of searching, the best I can find is this diagram: Notice output 0 drives a transistor that grounds the first 10 LED's. Output 1 drives the second transistor which grounds the second 10 LED's. This circuit has been cropped because of something I've been messing with for years. It's a little different from what is normally done when driving LED's but I can't find the diagram I wanted, which would show how to cascade up to 100 LED's. With a little tinkering you could add a third counter and cascade up to 1000 LED's. Literally, there's no end to how far you can go with it.

The first counter moves from one LED to the next. The second counter selects which set (in sets of 10) is grounded through a resistor. [edit] I think I have the clock circuit drawn wrong. And zero through nine are outputs in sequence, not pin numbers. [end edit]
View attachment 209993

Here's one I found on the internet: Again, you can have up to 10 sets of 10 LED's driven from just two 4017's.
View attachment 209995
Thank you for your informative reply, I like the idea of the transistors switching using the output of the second 4017 but I cannot see how this will work for me. I need to either switch on one of seven transistor operated circuits multiple times or pause the counter in a particular order. For example, circuit one will activate on counts 5, 9, 20, 26, 33, 37, 41, 52, 57 and 64. I therefore thought that the outputs could be fed with diodes to one of seven rails connected to the relevant transistors. The outputs requiring a pause would feed via a resistor to the appropriate CE pin which would also be grounded via a transistor. A triggering pulse to the transistor would then short the inhibit signal and counting would resume. Output 70 would reset back to zero. At least that is the theory!
 

Irving

Joined Jan 30, 2016
5,004
This is why it's always a good idea to state the whole problem up front.

To be honest, I think your requirements are much more easily and flexibly dealt with using a microcontroller rather than discrete logic - an Arduino will do all you need and more with near zero assembly and probably under $15.

But if you want to go the logic route you don't need so many devices, a single chip 8bit counter will give you 0 - 255 and some logic to extract the specific counts will work well.
 

Thread Starter

NigelL12

Joined May 8, 2020
8
I see no reason it can't be extended indefinitely.

But why not use a binary or BCD-decade counter which would only require two chip to count to 70?
I did not make myself clear in the original post, I should have said 70 discrete outputs to be used to activate a number of different circuits.
 

Irving

Joined Jan 30, 2016
5,004
Yes, but you don't need the discrete outputs if all you do with them is combine them with logic to encode one of 7 switched outputs. By stating the whole problem we can see it's much more easily solved than the approach you were proposing - assuming we now have the whole picture.

Here's my paraphrasing of your requirement:

I want to switch on one or more of seven (or more?) outputs at specific counts in a range of 0 - 70. At each (some?) specified count I want to pause until a trigger input releases the count. At count 70 (or some future value?) I want to reset the count to zero. Clock speed is a few Hz.

Is that a fair statement of your need?
 

Thread Starter

NigelL12

Joined May 8, 2020
8
Yes, but you don't need the discrete outputs if all you do with them is combine them with logic to encode one of 7 switched outputs. By stating the whole problem we can see it's much more easily solved than the approach you were proposing - assuming we now have the whole picture.

Here's my paraphrasing of your requirement:

I want to switch on one or more of seven (or more?) outputs at specific counts in a range of 0 - 70. At each (some?) specified count I want to pause until a trigger input releases the count. At count 70 (or some future value?) I want to reset the count to zero. Clock speed is a few Hz.

Is that a fair statement of your need?
Yes that pretty much sums it up.
 

Irving

Joined Jan 30, 2016
5,004
In which case the recommended solution would be the Arduino approach as this is by far and away the simplest way to do it. You would probably still need the transistor array to drive the outputs.

If you want to go the 'logic' route I have some suggestions that greatly simplify/reduce the logic gate requirement.
 

Thread Starter

NigelL12

Joined May 8, 2020
8
In which case the recommended solution would be the Arduino approach as this is by far and away the simplest way to do it. You would probably still need the transistor array to drive the outputs.

If you want to go the 'logic' route I have some suggestions that greatly simplify/reduce the logic gate requirement.
I have thought about the Arduino approach but this is completely new territory for me and that is why I was thinking of the logic route, however illogical it may seem. The circuitry would be stood idle for extended periods with no power supply at times, would this cause the loss of a program in the Arduino? The outputs will need to supply currents up to about 700mA maximum but generally nearer 300mA so I will definitely need transistors.
If you could make some suggestions about the best ‘logic’ route I would appreciate that. Even if I do not end up doing that, it will be educational and help me understand circuitry better. Thank you for the time and effort you are expending on my question.
 

Irving

Joined Jan 30, 2016
5,004
The microcontroller based solution won't lose the program. In the simplest solution it'll start up from count of 0 when power is restored - unless you want it to remember where it had got to and start from there; that's an easy option to add. It is by far the most easy, flexible, future-proof and cost-effective approach. I'll admit it's new territory if you've not been there before, but it's easy to learn and I can take you through it step by step. There are two options here, a board-level solution using the ubiquitous Arduino or one of its derivatives, or a single chip solution using a Microchip PIC all-in-one device - which is the route I'd take if building something fairly permanent as it has the lowest cost & component count - 1 chip and a dozen or so connections in total.

The 'issue' with the logic route is the decoding of individual states. If you use an 8bit counter, for each 'state' you want to decode you need an 8 input AND gate (in practice it would be a NAND but that's by-the-by for now). That could add up to a fair few gates if you have many combinations - you have 10 chips for circuit 1 on its own! So I can see why you thought 7 x CD4017 was a solution. But we can be cleverer. If we think of the combination of the bits as an address we can envision a 'memory' chip having 256 addresses and 1 data-bit where each of those specific addresses of interest contains a '1' and all other addresses contain a '0'. Extending that idea we can have a memory chip with 256 addresses, each having 8 data-bits - one for each of your 7 outputs and 1 spare. So now 1 chip decodes all possible output states and the great thing is, it only needs (ignoring the pause/reset logic) 8 connections from counter to memory chip and 2 chips instead of the 70+ connections, 7 chips and 70+ diodes needed for your solution. The spare 8th data-bit is your 'pause or reset to 0' output (with a little more cleverness that I'll not explain now for succinctness). And the only other thing you need is a programmer for the memory chip, which you can pick up for under a tenner on eBay.

I'd still recommend the Arduino route however, its so much simpler and flexible.
 

Thread Starter

NigelL12

Joined May 8, 2020
8
The microcontroller based solution won't lose the program. In the simplest solution it'll start up from count of 0 when power is restored - unless you want it to remember where it had got to and start from there; that's an easy option to add. It is by far the most easy, flexible, future-proof and cost-effective approach. I'll admit it's new territory if you've not been there before, but it's easy to learn and I can take you through it step by step. There are two options here, a board-level solution using the ubiquitous Arduino or one of its derivatives, or a single chip solution using a Microchip PIC all-in-one device - which is the route I'd take if building something fairly permanent as it has the lowest cost & component count - 1 chip and a dozen or so connections in total.

The 'issue' with the logic route is the decoding of individual states. If you use an 8bit counter, for each 'state' you want to decode you need an 8 input AND gate (in practice it would be a NAND but that's by-the-by for now). That could add up to a fair few gates if you have many combinations - you have 10 chips for circuit 1 on its own! So I can see why you thought 7 x CD4017 was a solution. But we can be cleverer. If we think of the combination of the bits as an address we can envision a 'memory' chip having 256 addresses and 1 data-bit where each of those specific addresses of interest contains a '1' and all other addresses contain a '0'. Extending that idea we can have a memory chip with 256 addresses, each having 8 data-bits - one for each of your 7 outputs and 1 spare. So now 1 chip decodes all possible output states and the great thing is, it only needs (ignoring the pause/reset logic) 8 connections from counter to memory chip and 2 chips instead of the 70+ connections, 7 chips and 70+ diodes needed for your solution. The spare 8th data-bit is your 'pause or reset to 0' output (with a little more cleverness that I'll not explain now for succinctness). And the only other thing you need is a programmer for the memory chip, which you can pick up for under a tenner on eBay.

I'd still recommend the Arduino route however, its so much simpler and flexible.
Thanks for all the help and information. I will go away and do a crash course on Arduinos and see where that gets me. If I run into serious problems I will be back requesting help! In the meantime I will try to fathom it out myself. I believe that is a good way to learn.
 
Top