Maker Pro
Maker Pro

Decade Counter issue.

Virium

Jun 27, 2016
6
Joined
Jun 27, 2016
Messages
6
Good morning everyone.
Little problem with a decade counter.

I am using logic gates to simulate a 4 JK counters to count to decimal 9. The gist of the idea is, it counts numbers and when my DCD values reaches 1010 the AND2 gate on U32 resets all pins and starts counting from 0000.
This works fine as I am aware, the problem is when I start the simulation. It does not start with a binary 0000, but rather with a randomish number. And I am having troubles pinpointing the cause of that, the U32 gate and clock input all have effects on it, but what is the excact cause and best fix for it, ive tried forcing reset on the flipflops on the very start of simulation, but it still goes haywire.
Also it is ground referenced offscreen.

Thank you for reading.
 

Attachments

  • JKFlippidy.png
    JKFlippidy.png
    296.6 KB · Views: 91

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,728
Joined
Nov 17, 2011
Messages
13,728
At turn-on any flipflop can have an arbitrary state. In your case it is the delays of the gates the flipflops are made of which result in an arbitrary state of the flipflops at turn on.
It is always (in real life as in a simulation) a good idea to provide an initial reset to force the flipflops (and the associated logic) into a well defined and known state.
In your case, simply add another AND after U32 and apply an initial reset pulse.
 

Virium

Jun 27, 2016
6
Joined
Jun 27, 2016
Messages
6
I tried doing an initial reset, it starts out at 0 thats true, but as soon as the reset is done, it takes a random state again.
 

hevans1944

Hop - AC8NS
Jun 21, 2012
4,886
Joined
Jun 21, 2012
Messages
4,886
Since J-K flip-flops are readily available in various flavors, what is the point in trying to simulate one with discrete logic? Is this a homework problem?
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,728
Joined
Nov 17, 2011
Messages
13,728
I tried doing an initial reset, it starts out at 0 thats true, but as soon as the reset is done, it takes a random state again.
Truly random or the same state agian and again, just not 000?
Does it count correctly from that state on?

I currently don't have the time to analyze your circuit, but it does look more like you're using D-flipflops which results in a shift register, not a counter.

Start with a single flipflop. Analyze the behavior. Does it conform to your expectations what a JK-flipflop should behave like?
Only when you've got a single flipflop running o.k. build the counter.
 

Virium

Jun 27, 2016
6
Joined
Jun 27, 2016
Messages
6
Truly random or the same state agian and again, just not 000?
Does it count correctly from that state on?

I currently don't have the time to analyze your circuit, but it does look more like you're using D-flipflops which results in a shift register, not a counter.

Start with a single flipflop. Analyze the behavior. Does it conform to your expectations what a JK-flipflop should behave like?
Only when you've got a single flipflop running o.k. build the counter.
It appears you are correct, it was not quite a JK flip flop, made some errors in logic, fixed it, works.
 
Top