Oscillation error with flip-flop

An area for asking questions, making suggestion, share ideas and place circuit examples.
Post Reply
h3ckphy
Posts: 3
Joined: Sun Aug 09, 2020 2:07 am

Oscillation error with flip-flop

Post by h3ckphy »

Hello, guys.
I'm reading Charles Petzold's book "C.O.D.E" and there is an adding machine example that uses 8-bit latch to save the sum for further addition. Here's the circuit image from book: https://i.imgur.com/aVF9Rwp.png.
I've built this circuit in program, but it throws the error "Oscillation" when I try to add some numbers.
I attached project below, find category "14. Feedback and Flip-Flops" and circuit named "Adding Machine (2)" if you want to help me.
There is no error if I don't set first number by switches, which means adding 00000000 and latch contents.
"Add" button is actually the Clock input of the flip-flops.
I even tried to test components of the circuit separately (e.g. checked if the adding machine works properly or 8-bit latch saves data as it should) and they seem to work well.
But when I wire them like in the example in the book I'm getting error. I think the connection between latch output and adder's B input (it's the single 8-bit wire that goes back to adder) causes the problem, but I don't understand what exactly going on, because circuit is too complex for me, there is so much components.
Attachments
examples.zip
Category "14. Feedback and Flip-Flops"
Circuit "Adding Machine (2)"
(44.15 KiB) Downloaded 704 times
User avatar
admin
Site Admin
Posts: 407
Joined: Sun Jun 14, 2009 10:53 pm
Contact:

Re: Oscillation error with flip-flop

Post by admin »

Hi,
First of all if you have not yet read about the oscillation please read it here: https://logiccircuit.org/oscillation.html
In your circuit you are using flip-flops with clock that is working by level. So when the Add button is pressed each flip-flop is storing the data its receiving on it’s input. So now let’s see what is going to happened when you set the A0 to 1 and press the Add button. The adder will produce result 1 that will be sent to latch, which store it and send to adder. Now adder will add 1 from buttons and 1 from latch, so it produce 2 and send it to latch which store it and send back to adder which will add 1 from buttons and 2 from latch, and so on. The process will never end.
In order to fix it you will need to change you flip-flops to controlled by edge, not level. You can find such flip-flops in samples or build them yourself. For more details see: https://www.electronics-tutorials.ws/se ... seq_2.html
Having JK flip-flop you can build D flop flop.
Hope this helps,
Eugene
h3ckphy
Posts: 3
Joined: Sun Aug 09, 2020 2:07 am

Re: Oscillation error with flip-flop

Post by h3ckphy »

But why circuit cycles as you described? I'm just pressing "Add" button instantly and by that supplying voltage to Clock only for a moment. So after releasing button loop shouldn't even start, because when Clock becomes 0 latch output doesn't change. Maybe loop starts too fast before I release button and program catches it?
User avatar
admin
Site Admin
Posts: 407
Joined: Sun Jun 14, 2009 10:53 pm
Contact:

Re: Oscillation error with flip-flop

Post by admin »

Precisely, your circuit can't get to any stable state while your add button is pressed down.
h3ckphy
Posts: 3
Joined: Sun Aug 09, 2020 2:07 am

Re: Oscillation error with flip-flop

Post by h3ckphy »

Thank you very much for help!
imcute
Posts: 26
Joined: Mon Jan 02, 2023 6:43 pm

Re: Oscillation error with flip-flop

Post by imcute »

Did not look at your circuit,but anything that uses SR flip flops WILL oscillate
Don't use them.Use a master-slave JK flip flop.(jk flip flops just dont oscilate.and they can accept 1-1 inputs)
Post Reply