BCD Counter starts at random number

An area for asking questions, making suggestion, share ideas and place circuit examples.
student999
Posts: 9
Joined: Tue May 21, 2024 11:27 am

BCD Counter starts at random number

Post by student999 »

BCD counter outputs some undefined behavior. It should count from 0000-9999, but it starts at a random value (eg. 2304), whereas im sure it will work.
Im at my wits end.
Thanks

Alan
Last edited by student999 on Wed May 29, 2024 12:29 pm, edited 1 time in total.
User avatar
admin
Site Admin
Posts: 417
Joined: Sun Jun 14, 2009 10:53 pm
Contact:

Re: BCD Counter starts at random number

Post by admin »

Hi Alan,
JK flip-flops are flipping to a random state at power on. That is why you see it starting at the random state.
You will need to reset them at power on. Please read this discussion: viewtopic.php?t=3
and especially the last suggestion from ehennig.
On the other note you have repeated the same circuitry 4 times, both for counters and for displays. I suggest you move repeated stuff to separate circuits and use them on the main diagram.
Regards,
Eugene
student999
Posts: 9
Joined: Tue May 21, 2024 11:27 am

Re: BCD Counter starts at random number

Post by student999 »

admin wrote: Tue May 21, 2024 12:20 pm Hi Alan,
JK flip-flops are flipping to a random state at power on. That is why you see it starting at the random state.
You will need to reset them at power on. Please read this discussion: viewtopic.php?t=3
and especially the last suggestion from ehennig.
On the other note you have repeated the same circuitry 4 times, both for counters and for displays. I suggest you move repeated stuff to separate circuits and use them on the main diagram.
Regards,
Eugene
Thanks, i got the REST state (0000) to work, but there is another issue if you don't mind, i added stop logic to stop the counters at specific values, but the program throws an Oscillation error, i think it is related to feeding the output of a circuit to an input of another, but i don't see the issue. Would you please look into it?

The Connection between the logic circuits and the counters is the output of the counter logic in to an XOR with 1, which if the counter reached the value the output of the gate would be 0, the zero would be put together with the output of the counter logic (into XOR) to ensure that the counter reached the value, the result of that is put to an AND gate with the next counter logic and so on.

Attached is the counter circuit and the 4 counter stop logic files.

Thanks,
Alan
Last edited by student999 on Wed May 29, 2024 12:30 pm, edited 1 time in total.
student999
Posts: 9
Joined: Tue May 21, 2024 11:27 am

Re: BCD Counter starts at random number

Post by student999 »

Ok, I found that the problem is with the XORs that are connected with the high pulse (1), but im not sure how to mitigate and circumvent the problem, because these XORs are crucial to the logic that stops the counter (putting the J and K to a hold state of 00) .

Sorry for the many requests, but i really need the help.

Thanks,
Alan
User avatar
admin
Site Admin
Posts: 417
Joined: Sun Jun 14, 2009 10:53 pm
Contact:

Re: BCD Counter starts at random number

Post by admin »

First the expression x XOR 1 is equal to NOT x. So, I don't know what you are trying to do here.
Second it is very hard to understand your circuit as it is so big. If you move the repeated parts to separate circuits it will be much easier to test and find issues, not to mention to look at your diagrams.
Finally, you are trying to use reset input of your JK flip-flops (Clr) to zero it during counting, when it reaches 10. The Clr input is asynchronous input that should be used mainly for initial reset. To turn counter to 0 once it reaches it's maximum (in your case 9) you should use J and K inputs on proper clock edge. Otherwise, you will get very nasty side effects. In your design it actually reaching and outputting 10 before it gets reset to 0.
The oscillation indeed occurs when you make a loop where some output changing from - to 1 and back indefinitely.
student999
Posts: 9
Joined: Tue May 21, 2024 11:27 am

Re: BCD Counter starts at random number

Post by student999 »

admin wrote: Thu May 23, 2024 4:59 pm First the expression x XOR 1 is equal to NOT x. So, I don't know what you are trying to do here.
Second it is very hard to understand your circuit as it is so big. If you move the repeated parts to separate circuits it will be much easier to test and find issues, not to mention to look at your diagrams.
Finally, you are trying to use reset input of your JK flip-flops (Clr) to zero it during counting, when it reaches 10. The Clr input is asynchronous input that should be used mainly for initial reset. To turn counter to 0 once it reaches it's maximum (in your case 9) you should use J and K inputs on proper clock edge. Otherwise, you will get very nasty side effects. In your design it actually reaching and outputting 10 before it gets reset to 0.
The oscillation indeed occurs when you make a loop where some output changing from - to 1 and back indefinitely.
Thanks for your reply, Appreciate it.

> First the expression x XOR 1 is equal to NOT x. So, I don't know what you are trying to do here.

I'm trying to input the output of a counter stop logic (which if it reached the value, 6 for example the output of its circuitry would be 1), with the high pulse (which would be 1), the output is of course 0, now because the value is 0, the J and K would be 0, meaning a hold state, where even if it gets a clock pulse the counted value would not change.

Sorry for the confusion.

> Second it is very hard to understand your circuit as it is so big. If you move the repeated parts to separate circuits it will be much easier to test and find issues, not to mention to look at your diagrams.

I'll copy each counter and its stop logic to their respective logical circuits, plus i will try to make as testable as i can.

> Finally, you are trying to use reset input of your JK flip-flops (Clr) to zero it during counting, when it reaches 10. The Clr input is asynchronous input that should be used mainly for initial reset. To turn counter to 0 once it reaches it's maximum (in your case 9) you should use J and K inputs on proper clock edge. Otherwise, you will get very nasty side effects. In your design it actually reaching and outputting 10 before it gets reset to 0.

Ohh, is that why it randomly skips values, i thought that a strobe technique would fix the problem, considering that the propagation delay is nasty and can lead to undesirable behavior.

> The oscillation indeed occurs when you make a loop where some output changing from - to 1 and back indefinitely.

But when i follow the logic it shouldn't occur?, the logic is only activated when the final counter's stop logic is met, then it descends to all the counters in the same way, i think i don't see the problem clearly.

As i said im going to separate the circuits then send them

Thanks
student999
Posts: 9
Joined: Tue May 21, 2024 11:27 am

Re: BCD Counter starts at random number

Post by student999 »

Hello Again,

Here are two counters separated into their respective logic circuits, and the same goes for the others, they work individually, but the problem arises when i attempt to connect them together (the Oscillation error above).

Thanks
Last edited by student999 on Wed May 29, 2024 12:30 pm, edited 1 time in total.
User avatar
admin
Site Admin
Posts: 417
Joined: Sun Jun 14, 2009 10:53 pm
Contact:

Re: BCD Counter starts at random number

Post by admin »

Here I simplified it for you. Look at "Counter 0 simple" and "Counter 1 simplified".
Attachments
BCD_COUNTER_1000s_WIPsimple.CircuitProject
(975.44 KiB) Downloaded 2849 times
student999
Posts: 9
Joined: Tue May 21, 2024 11:27 am

Re: BCD Counter starts at random number

Post by student999 »

admin wrote: Thu May 23, 2024 10:38 pm Here I simplified it for you. Look at "Counter 0 simple" and "Counter 1 simplified".
Weird, it says its from another version and won't open.

I really don't know whats going on with the Oscillation error, if you can help point me in the right direction, i tried all sorts of wiring but nothing works.

Thanks
student999
Posts: 9
Joined: Tue May 21, 2024 11:27 am

Re: BCD Counter starts at random number

Post by student999 »

Ok, i found the gate that triggers the problem, it is the XOR that gets input from the counter stop logic, and outputs into the JK flip flops.
But how can i workaround this problem. I'm beyond confused.
Post Reply