It's too hard to tell what you have done from the tinkercad gallery pic. If I was you, I'd draw out the schematic, with the IC pin numbers etc, then start again and rewire your circuit.
Hello Tech heads,
I have been watching some YouTube videos on logic circuits and I have found an easy to use breadboard simulator to test and play with designs at
I am trying to build a D Latch and I am unable to get the circuit to latch, instead it follows the state of the data input.
Currently I am using two push button switches (in tinkercard holding shift whilst clicking a switch makes the switch stay on), a 4 AND gate IC and a 4 NOR gate IC with some LEDs to show the status of inputs and outputs. ()
The idea is that the data input should only be able to change the state of the outputs when the enable input is high, and once the enable input is low the inputs should retain their state (like a basic 1 bit memory), like the below circuit diagram and truth table.
I am sure that I have made a basic mistake however I can not see it for the life of me.
Any assistance would be appreciated.
Look Here -> |
It's too hard to tell what you have done from the tinkercad gallery pic. If I was you, I'd draw out the schematic, with the IC pin numbers etc, then start again and rewire your circuit.
jimmyc (30-07-17)
Maybe the 2 AND gates should be NAND gates?
Constructing a 'D' type flip flop from discrete gate chips is a good learning thing but for a real world application I'd be using a 74LS74 which contains 2 D type flip flops with preset and clear inputs. They're frequently used for dividing a clock signal's frequency by 2.
Last edited by Skepticist; 30-07-17 at 10:56 PM.
jimmyc (30-07-17)
If you apply Demorgans theorem, a NOR gate is the equivalent of an AND gate with inverted inputs and the opposite also applies IE a NAND gate is the same as an OR gate with inverted inputs.
So basically you could build any logic cct using exclusively NAND or NOR gates (you can tie the inputs together to make an inverter)
You have a hex inverter (74HC04) and a quad NOR (74HC02) that I can see so that's all you need along with a single inverter from the 04 chip
So just wire it all up using the 4 NOR gates and 1 inverter. The only change in your truth table will be E needs to be low for D to toggle the flipflop
I can see the problem.
The circuit is correct and it will work exactly as described. The problem is that theory and reality sometimes need tweaking.
So the circuit works like this. You either press and hold to D button (1) or you don't (0).
The data is written to the latch with the E Enable button. Pushed momentarily.
The theoretical circuit doesn't voltage sink the inputs. The input is just floating and relies on the added circuitry to pull the line high and low.
TTL is also rather fussy. If It's not 5V or 0V then it's ... well... analog (ie trouble).
OK... so on your breadboard I can see that you you have +5V pulling the line high via the LED and it's ballast resistor. (This might pose a problem on it's own).
We'll just assume it works.
Next is pulling the lines low. Again, you appear to have pull down resistors. However .... I can see in the diagram two wires from the positive rail connecting to each pull down resistor.
This keeps them forever high.
The positive rail is connected via the push button. These little SMD push buttons are single pole single throw. Even though they have 4 pins, two on each side are connected together. When the button is pushed, all four are closed circuit to each other.
The way to confirm that this is the problem is to put your multimeter across the pull down resistors and measure the voltage across them. It should be zero when the button is idle.
It should be +5V when the button is pushed.
Yes I am an agent of Satan, but my duties are largely ceremonial.
jimmyc (05-08-17)
Adjusted the schematic and truth table for using all NOR gates
As Trash suggests, you need to give the inputs a default state EG by using pullup resistors to power supply +ve (say 10k) on the D and E inputs)
This is exactly the same circuit to illustrate what I was saying earlier
And this arrangement using a second inverter will give the same truth table as your original layout
Last edited by Skepticist; 31-07-17 at 12:25 PM.
Are you using 74 series ICs or the 4000 series (CMOS) ICs? The exact part numbers would help.
Trash is on the right track, I think. 74 series inputs tend to interpret "open circuit" as a logic "1", but CMOS inputs can do some really strange things if left open. Inputs on unused gates in the IC can cause the unused gate to "take off" and oscillate - that can produce some really weird behaviour. Make sure you've tied the inputs on any unused gates to your positive rail or to ground.
If you've got long power cables to your board, a decoupling capacitor or two near the ICs is good practice. I've never seen a lack of decoupling capacitors cause problems with a fairly static setup like you're experimenting with though.
If or when you move into using flip flops, you will need to worry about debouncing your inputs, but it doesn't matter for this one.
jimmyc (05-08-17)
Looking at the breadboard pic it's a 74HC02 and a 74HC04, CMOS equivalent of 7400 chips with a wider operating voltage range and lower input currents.
jimmyc (05-08-17)
Yes, you need pull down resistors to prevent an indeterminate input to your devices. A 4.7K resistor from your inputs to ground will mean the gates will see a 0 (seeing as you're using pos logic) when the switch is open. Without the pull down resistor, the input is indeterminate.
jimmyc (05-08-17)
Thank you to everyone for taking the time to have a look and give me suggestions. I will have a play and see how I go.
Bookmarks