Counter circuit from 0-9 then 9-0

Thread Starter

franzolivar

Joined Aug 3, 2024
8
I am an electronics newbie looking to design an LED flashing circuit with a counter that initially counts from 0 - 9, then counts from 9 - 0. My initial thought process is to have a flip-flop mechanism that triggers when 0 reaches 9 and 9 to 0 vice-versa. This FF mechanism will 'count' the number of times the counters reach 9 or 0 respectively.
The counter will start, and when the FF is in state 1, the circuit will count from 0 - 9 and update to state 2; when the FF is in state 2, it will count from 9 - 0 and update to state 1.

The flowchart provided below should look like the output I want to display:

1722689298924.png
However, the outputs will be in binary, so I need to use a 3:8 decoder to make it one LED at a time, but my outputs will be reduced by 2 since it is only 8 outputs. Is there any alternative for the circuit I thought of?
 

dl324

Joined Mar 30, 2015
18,355
Welcome to AAC!
I am an electronics newbie looking to design an LED flashing circuit with a counter that initially counts from 0 - 9, then counts from 9 - 0.
This is called an up/down BCD counter. Do you want to design your own counter or use a commercial part?
The flowchart provided below should look like the output I want to display:
That's an odd way to describe a counter.
However, the outputs will be in binary, so I need to use a 3:8 decoder to make it one LED at a time, but my outputs will be reduced by 2 since it is only 8 outputs. Is there any alternative for the circuit I thought of?
This requirement isn't shown in your flow chart.
 

AnalogKid

Joined Aug 1, 2013
12,148
At first glance, this looks like a 74192 (or CMOS equivalent) plus one SR (Set-Reset) flipflop. This can be two NAND or two NOR gates, depending on how the final logic polarities work out.

For the outputs, use a 4-to-16 decoder instead of a 3-to-8 decoder, and use only the first 10 outputs.

ak
 

Thread Starter

franzolivar

Joined Aug 3, 2024
8
Is this school homework?
No, this is a personal project I have started to work on just yesterday.

This is called an up/down BCD counter. Do you want to design your own counter or use a commercial part?
I am trying to design my own, and am looking for other ideas

That's an odd way to describe a counter.
Is this still considered a counter? I guess so

This requirement isn't shown in your flow chart.
I am confused. Do you mean to say that the flow chart is not detailed enough? If so, it’s actually incomplete; I only aimed to illustrate the general flow. I'm still unsure about how to design it properly, so I just presented the flow for now.
 

dl324

Joined Mar 30, 2015
18,355
I am trying to design my own
You mean drawing a state machine, truth tables (with flip flop excitation data), solving Karnaugh maps?
and am looking for other ideas
If you haven't designed counters before, using commercial parts will be easier.
Is this still considered a counter?
Kind of, except you're missing a lot of detail. Counters are usually defined using state machines/diagrams.

Here's one for Motorola's MC14526 binary down counter:
1722704285134.png
 

Thread Starter

franzolivar

Joined Aug 3, 2024
8
It will be easiest if you use an Arduino. Alternatively, you can use a CD4026 Decade Counter or
74LS192 (BCD/DECADE UP/DOWN COUNTER). Here is a tutorial on how to do this: https://www.theengineeringprojects.com/2022/03/up-down-counter-without-microcontroller.html
A simple counter counts in increasing or decreasing order but the Up-Down counter counts in increasing and decreasing order, both depending upon the input it has given.
I am trying not to rely on microcontrollers, since I want to discretely use ICs. Thanks for the article though! It seems very helpful.
 

Thread Starter

franzolivar

Joined Aug 3, 2024
8
You mean drawing a state machine, truth tables (with flip flop excitation data), solving Karnaugh maps?
Yes exactly. I am trying to learn by designing my own. However, it seems to be a too tall a task for me at the moment. I think I should start from learning existing components design and how they work, I guess
 

WBahn

Joined Mar 31, 2012
32,902
Your description of what you are trying to achieve is a bit vague.

As your system is running, do you want the '0' and the '9' to each last for two counts? In other words, as it's counting up do you want it to go 7-8-9-9-8-7, or would it be better to go 7-8-9-8-7?

You talk about one LED at a time and needing a 3:8 decoder, but you have ten states. How many LEDs are you actually talking about and exactly when do you want each LED to be illuminated?

How is the system placed in the Start state and how does it exit the start state?
 

MrChips

Joined Oct 2, 2009
34,855
So you want to design a counter that counts 0-1-2-3-4-5-6-7-8-9-8-7-6-5-4-3-2-1-0-1-...
You can do this with what is known as a finite state machine (FSM). I can show you how to do this but as far as I can see, this is just an academic exercise because the easiest implementation would use an MCU.

If you examine the unique states of this FSM, there are a total of 20 unique states. Hence the FSM will need 5 bits.
The first step is to draw a truth-table showing each state and the next state on the next clock pulse.
Note that states 0-9 are different from states 9-0. Hence you will use the 5th bit to differentiate between the two sequences.

At this point, you will recognize that the 5th bit is the same as your UP/DOWN flip-flop. Hence you can take advantage of UP/DOWN BCD Counter IC such as 74LS190.

You can decide which route you wish to take.
 

dl324

Joined Mar 30, 2015
18,355
Yes exactly. I am trying to learn by designing my own. However, it seems to be a too tall a task for me at the moment. I think I should start from learning existing components design and how they work, I guess
It's not really that difficult if you know how to use flip flops, logic gates, know how to use a logic simulator or be able to breadboard circuits, how to troubleshoot, how to draw truth tables (I usually skip skip state machines), how to simplify logic using Karnaugh maps.

If you breadboard counters, I'd suggest using CMOS. TTL is too power hungry, has more limited operating voltages, and are relatively expensive now. The CMOS intended to replace TTL also have a limited range of operating voltages.

If you use CD4xxx, they operate from 3-15V, so powering from a 9V battery is an option.

CMOS is sensitive to ESD, so you need to take appropriate precautions. This isn't much of a concern with TTL, but availability and cost are.
 

WBahn

Joined Mar 31, 2012
32,902
So you want to design a counter that counts 0-1-2-3-4-5-6-7-8-9-8-7-6-5-4-3-2-1-0-1-...
You can do this with what is known as a finite state machine (FSM). I can show you how to do this but as far as I can see, this is just an academic exercise because the easiest implementation would use an MCU.

If you examine the unique states of this FSM, there are a total of 20 unique states. Hence the FSM will need 5 bits.
What are the 20 states as you see them from your sequence above. I only see 18. You might also have a start state that things are initialized in until some event kicks things off. I've asked the TS to clarify that.
 

WBahn

Joined Mar 31, 2012
32,902
It's not really that difficult if you know how to use flip flops, logic gates, know how to use a logic simulator or be able to breadboard circuits, how to troubleshoot, how to draw truth tables (I usually skip skip state machines), how to simplify logic using Karnaugh maps.

If you breadboard counters, I'd suggest using CMOS. TTL is too power hungry, has more limited operating voltages, and are relatively expensive now. The CMOS intended to replace TTL also have a limited range of operating voltages.

If you use CD4xxx, they operate from 3-15V, so powering from a 9V battery is an option.

CMOS is sensitive to ESD, so you need to take appropriate precautions. This isn't much of a concern with TTL, but availability and cost are.
The CMOS families in production today have pretty robust ESD protection on them -- you can handle them about the same as comparable TTL chips. Not saying that it isn't always a good idea to exercise reasonable care, but a lot of people get scared off of working with CMOS because they are convinced that they have to have all kinds of special equipment and training to even look at them.
 

MrChips

Joined Oct 2, 2009
34,855
What are the 20 states as you see them from your sequence above. I only see 18. You might also have a start state that things are initialized in until some event kicks things off. I've asked the TS to clarify that.
You are correct. There are 18 states. I didn't count them. I just assumed that there are two times ten states.
 

MisterBill2

Joined Jan 23, 2018
27,632
This looks like an application for a CD4516 IC, which I believe is a binary/BCD up down counter so you could have it count up, and when an "11" was decoded set an external FF to latch the command to count down, Then on the down count, when it rolled from 0 to 16, to reset the FF to command an up count.. That scheme would lose a count in each cycle but there was no statement that such is not allowed.
 

MisterBill2

Joined Jan 23, 2018
27,632
Another option, even easier, is two CD4017 counters in cascade, so that after count 9 (displayed as the TEN led, the second counter outputs are enabled, displaying in the opposite direction so that 1 displayed as 9, and 2 displayed as 8
 

Thread Starter

franzolivar

Joined Aug 3, 2024
8
So you want to design a counter that counts 0-1-2-3-4-5-6-7-8-9-8-7-6-5-4-3-2-1-0-1-...
Yes, exactly.
If you breadboard counters, I'd suggest using CMOS.
Sure, I'd take that into consideration, thanks.

This looks like an application for a CD4516 IC, which I believe is a binary/BCD up down counter so you could have it count up, and when an "11" was decoded set an external FF to latch the command to count down, Then on the down count, when it rolled from 0 to 16, to reset the FF to command an up count.. That scheme would lose a count in each cycle but there was no statement that such is not allowed.
Another option, even easier, is two CD4017 counters in cascade, so that after count 9 (displayed as the TEN led, the second counter outputs are enabled, displaying in the opposite direction so that 1 displayed as 9, and 2 displayed as 8
I'll look into those, thanks!

Thank you all for replying. I will post updates when I am done trying each of and looking into each of your suggestions. :D
 
Top