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.
Oscillation error with flip-flop
Oscillation error with flip-flop
- Attachments
-
- examples.zip
- Category "14. Feedback and Flip-Flops"
Circuit "Adding Machine (2)" - (44.15 KiB) Downloaded 2814 times
Re: Oscillation error with flip-flop
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
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
Re: Oscillation error with flip-flop
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?
Re: Oscillation error with flip-flop
Precisely, your circuit can't get to any stable state while your add button is pressed down.
Re: Oscillation error with flip-flop
Thank you very much for help!
Re: Oscillation error with flip-flop
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)
Don't use them.Use a master-slave JK flip flop.(jk flip flops just dont oscilate.and they can accept 1-1 inputs)