# 0-59 up/down counter problem on Circuitverse

#### zxxaxx

Joined Jun 19, 2022
6
Hey everyone, im new here. Im a computer engineering undergraduate, first semesters and stuff, and my professor just asked for this overcomplicated project that i simply cannot solve.

He wants us to make a counter that has 3 buttons> 1st one, turns the system on/off; 2nd, makes the counter goes up or down; 3rd one, the counter is set on odd/even patterns.

The problem really is when I try to make the system reset at 59. I tried "locking" (i dont know a better word, sorry) the circuit at 59 normally, using AND + NOTGATE, and everything goes amazing, but its such a pain in the a$$when i have to do it "down" too. It simply does not work. Can someone enlighten me? I'm fairly new to this and I'm really trying my best, but this is just pissing me off.... Thank you. #### crutschow Joined Mar 14, 2008 32,846 Your words are somewhat confusing. Schematics are the language of electronics, so please post one of what you have. #### dl324 Joined Mar 30, 2015 15,815 Welcome to AAC! The problem really is when I try to make the system reset at 59. I tried "locking" (i dont know a better word, sorry) the circuit at 59 normally, using AND + NOTGATE, and everything goes amazing, but its such a pain in the a$$ when i have to do it "down" too. It simply does not work. Can someone enlighten me? I'm fairly new to this and I'm really trying my best, but this is just pissing me off....
The complete text for the problem, your schematic, and not making up your own terminology would be helpful.

#### zxxaxx

Joined Jun 19, 2022
6
Thanks for your patience and sorry, as i said, im a beginner and i dont really know the correct terms, specially because im from a foreign country and things get lost in translation.

I have to build a JK flip flop counter that has the following 3 push-buttons:
PB0 - on/off
PB1 - First press, the counter goes up (0, 1, ..., 59, 0, ...). Second press, the counter goes down (59, 58, ... 0, 59, ...)
PB2 - First press, the counter goes in a even pattern (0, 2, ..., 58, 0, ...). Second press, the counter goes in a odd pattern (1, 3, ..., 59, 1, ...) .

My biggest problem is with the PB1 setting. I know that, If i want the circuit to reset at "...9" in the units and "5..." in the dozens, I just have to do 2 RESET circuits (presented at the left and right), repeating at the "...6" in the dozens (which is 110) and "...10" in the units (which is 1010).

The thing is: it only works when the PB1 is set at UP. When I change it to DOWN, it just changes everytime; sometimes, it only counts from 50-40-20 and then repeats. What am I possibly doing wrong?

Here's the circuit I did till now:

#### dl324

Joined Mar 30, 2015
15,815
I have to build a JK flip flop counter that has the following 3 push-buttons:
Post the complete text for the problem, your work for the counter logic, and better pictures of the components (that show the JK flip flop inputs).

Why did you use JK flip flops if you're going to use them as T flip flops?

Pro tip: Don't draw wires on/over symbols. Don't use unnecessary wire jogs. Label all inputs/outputs to symbols (flip flops) where functionality isn't obvious (like AND gates).

When is this problem due?

Can someone enlighten me?
Ask questions and note that we're not going to do your homework for you.

#### zxxaxx

Joined Jun 19, 2022
6
Post the complete text for the problem, your work for the counter logic, and better pictures of the components (that show the JK flip flop inputs).
That's the whole text, it's a very short one. I didnt do any counter logic, besides the BCD decoder.

Why did you use JK flip flops if you're going to use them as T flip flops?
I saw a similar up/down circuit involving JK flip flops and decided to try with them. My professor, however, set the project with D flip flops.

Pro tip: Don't draw wires on/over symbols. Don't use unnecessary wire jogs. Label all inputs/outputs to symbols (flip flops) where functionality isn't obvious (like AND gates).

When is this problem due?
Thanks for the tip, Im still working things out so it's, indeed, a mess; my professor asked for us to not do through finite state machine since its a much more intensive work because of the 7 bits.

I still have 15 days left.

Ask questions and note that we're not going to do your homework for you.
That's not the case whatsoever.
Here's more succinct questions, if that's what you ask for

- Is it possible to be done with D flip flops?
- Can I do a up/down counter that is set from 0-59 and resets from then, without having to do a whole finite state machine truth table?

#### dl324

Joined Mar 30, 2015
15,815
my professor asked for us to not do through finite state machine since its a much more intensive work because of the 7 bits.
You mean 6 bits? 6 is doable by hand. Not fun, but definitely possible. But then, you'd need a binary to BCD converter. Since you're not breadboarding, it wouldn't be nearly as tedious.

EDIT: 7 variables for up/down and 8 for odd/even. That's a bit much to do by hand. Does what you've implemented do that?
Is it possible to be done with D flip flops?
Yes.
Can I do a up/down counter that is set from 0-59 and resets from then, without having to do a whole finite state machine truth table?
You can, but it's not a "clean" design and you have to use the set/reset inputs as you appear to be doing.

In any case, post a symbol of the flip flop with the inputs and outputs labeled. If you're supposed to use D flip flops, why did you use JK configured as toggle flip flops? Not following instructions would cost you points.

15 days is more than enough time, even if you're carrying a full load. I do counter designs like this for fun and entering the components in a logic simulator takes more time than actually designing the counter.

EDIT: Is your design able to count up and down? It looks like the clock is parallel for all flip flops, but I think it would be easier if you used carry/borrow logic to increment/decrement the other counter.

Last edited:

#### ci139

Joined Jul 11, 2016
1,874
Why not solve it "logically" (in binary/hex) and suit the BDC stuff in later - you force your problem to correlate with what you presume should be a simple solution - that very assumption may hold back your success - solve for each sub task then fit together

(it shouldn't take over 2...4 hours if you're familiar with digital circuitry or a work day + some if not so)

#### dl324

Joined Mar 30, 2015
15,815
For grins, I did a design for a 59-0 counter using JK flip flops:

As I recall, the 4 bit binary to BCD converter was 18 gates. I didn't feel like wiring the set and reset inputs on the flip flops. The simulator I use defaults unconnected inputs to LOW.

I blocked out the logic to avoid giving away solutions, and style, to future students who might need to design such a counter.

#### dl324

Joined Mar 30, 2015
15,815
For more grins, I implemented up and down in the same counter:

#### ci139

Joined Jul 11, 2016
1,874
the even odd pattern is clocking the 2¹ bit instead of the 2⁰ - while preserving the least

the single press button with 2 fn. is
1. PB0 , PB2 : an auto-reset after ?? 10s...20s of "silence" to fn.1 otherwise assume fn.next (or the operation of your choice)
2. // PB1 , PB2 - just latch in between the modes
3. PB1 only :
5. (opt.1) wait 1..2s before auto-alternating . . . then alternate (count) at speed an operator can follow
6. (opt.2) assume counting at selected function when the delay in between presses does not exceed 2s - otherwise ignore upcoming inputs for 4...6s

you should have some sys.-state register + initialization (after - power on evt.) circuitry

#### zxxaxx

Joined Jun 19, 2022
6
Hey everyone! Thanks for the overall help and sorry for being so late. I tried implementing the circuit with D flip flops and it kinda worked. I'll keep this thread updated once I develop something more concrete, and, at the deadline, I'll post what I solved (if so hahah). Here goes the quotes:

EDIT: 7 variables for up/down and 8 for odd/even. That's a bit much to do by hand. Does what you've implemented do that?
Up/down yes. Still have to implement the odd/even but its easy since, in binary, the even numbers end with 0 and the odd with 1.
The real pet peeve here is having to reset the circuit up/down when it reaches "5..." and "...9", in both ways, as I said. Once I figure it out how to do it, i'll be able to do the whole circuit in the blink of an eye, I believe.

For more grins, I implemented up and down in the same counter:
Niceeeee, thanks for the display!

the PB0 +5V example (not the best 1 tough)
Nice! thanks a lot, but i think it exceeds my limited knowledge in the area lol... im only in the 2nd semester, they didnt teach us more advanced circuitry and this is my 2nd project so far...

#### dl324

Joined Mar 30, 2015
15,815
Up/down yes.
I don't see how it can count down; or up for that matter. The reset conditions are different for down and, since you didn't implement a true modulo 6 counter for the most significant digit, you have to do a preset on it when the circuit counts down from 00.
Still have to implement the odd/even but its easy since, in binary, the even numbers end with 0 and the odd with 1.
That's how I would have implemented counting odd/even counting. The problem didn't say that in odd/even mode the count had to change on every clock, only that it needed to count by odd or even numbers, so the easy thing would be to do something with the least significant bit and let it change on every other clock.
Niceeeee, thanks for the display!
My style, which I didn't show you, is a derivative of the styles used by TI, Motorola, and RCA. This is the style TI used:

This up/down counter should give you some clues as to how you should approach your problem.

EDIT: It occurs to me that if you designed modulo 6 and 10 counters, you wouldn't need to use set or reset on the flip flops which would simplify the borrow/carry/clear/preset logic. Do you know how to do a 5 variable Kmap?

Last edited:

#### ci139

Joined Jul 11, 2016
1,874
they didnt teach us more advanced circuitry
if it's what you study - wouldn't you read anything extra on your own interest (especially nowadays - when such is accessible by the "2-clicks" in the internet)

#### dl324

Joined Mar 30, 2015
15,815
I still have 15 days left.
You're down to less than a week. Have you made significant progress?

If you can design mod6 and mod10 counters, you don't have to worry about preset and reset logic. Though the clocking for the 10's counter turned out to be a bit more complicated than using min/max count as the clock.

#### zxxaxx

Joined Jun 19, 2022
6
You're down to less than a week. Have you made significant progress?

If you can design mod6 and mod10 counters, you don't have to worry about preset and reset logic. Though the clocking for the 10's counter turned out to be a bit more complicated than using min/max count as the clock.
Hi, Dennis! Sorry for being so late, once again. Yes, I did the mod6/mod10 counters! Still managing to make the circuit work correctly! I have one question, can you guys help me solve this part? I'm trying to set the "enable" input on (E=1) ONLY when the PB1 or PB2 are pressed; once they are pressed, if you press them again, the "enable" input remains =1. It only turns off (E=0) when you press PB0 (PB0=0). Heres a diagram I did for trying to solve this with finite state machine:

I figured out 1 D flip flop would work and the expression I found thru Kmap was D0=Q0*P0+P0+P0*P1 (D0 being "next state" and Q0 being "actual state") but once I set out the circuit, it doesnt work properly, it keeps changing with time.

#### dl324

Joined Mar 30, 2015
15,815
PB0 - on/off
PB1 - First press, the counter goes up (0, 1, ..., 59, 0, ...). Second press, the counter goes down (59, 58, ... 0, 59, ...)
PB2 - First press, the counter goes in a even pattern (0, 2, ..., 58, 0, ...). Second press, the counter goes in a odd pattern (1, 3, ..., 59, 1, ...) .
I'm trying to set the "enable" input on (E=1) ONLY when the PB1 or PB2 are pressed; once they are pressed, if you press them again, the "enable" input remains =1.
It would be helpful if you used the same terminology used in the problem. Enable is PB0.

Post a schematic for what you tried.

Do you see a problem with the requirements for the actions of PB1 and PB2?

Last edited:

#### zxxaxx

Joined Jun 19, 2022
6
It would be helpful if you used the same terminology used in the problem. Enable is PB0.

Post a schematic for what you tried.

Do you see a problem with the requirements for the actions of PB1 and PB2?

I need the "enable" in both counters to be "=0" when PB0=0 or 1 so the counters wont start to count as soon as I press the PB0, which is supposed to work only as a ON/OFF button. Once I press either PB1 or PB2, they start to count normally, only to be turned off by PB0=0, which is the 2nd press.
I suppose I have to work with a flip flop for that.

MOD10 counter:

MOD6 Counter:

#### dl324

Joined Mar 30, 2015
15,815
You're supposed to design a mod 60 up/down counter. Your counters will only count up. Since you didn't actually design synchronous counters of the appropriate modulus, you need to use the set and reset inputs on the flip flops. That's going to cause a problem when counting up or down because you need to carry or borrow.

If you had actually designed synchronous mod 6 and mod 10 counters, you wouldn't have to worry about setting or resetting the flip flops. Each counter would know what the count should be on the next clock based on which direction it's counting.

Some schematic drawing tips.
1. We never draw wires over symbols. If you see any that do this, my advice would be to ignore them and look for something from someone who looks like they know what they're doing.
2. Don't overlap symbols.
3. When you're drawing schematics with repeated logic, you should strive to draw them the same.
4. The wire jogs to the decoders could be avoided by lining them up with the counters.
5. The wire crossings could be avoided by ordering the outputs of your counter blocks to be in the same order as the decoders.
6. The dots at wire bends are distracting (but you can't do anything about a stupid schematic editor/simulator).
7. Since the logic simulator shows logic state, you should use a wire between every logic element (not run them together). Even if it didn't show state, you should still use a wire to connect them.
8. The inputs and outputs of all symbols should be labeled. I can infer that the inputs along the bottom of the flip flops are enable, set, and reset, but labeling them makes it clearer. EDIT: except logic gate symbols.

Last edited: