Results 1 to 10 of 10

Thread: Learning Logic Circuits - D Latch

  1. #1
    Junior Member
    Join Date
    May 2008
    Age
    40
    Posts
    55
    Thanks
    16
    Thanked 10 Times in 9 Posts
    Rep Power
    197
    Reputation
    135

    Question Learning Logic Circuits - D Latch

    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 ->
  • #2
    Senior Member
    bob_m_54's Avatar
    Join Date
    Jan 2011
    Posts
    2,093
    Thanks
    1,054
    Thanked 1,151 Times in 689 Posts
    Rep Power
    634
    Reputation
    20178

    Default

    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.

  • The Following User Says Thank You to bob_m_54 For This Useful Post:

    jimmyc (30-07-17)

  • #3
    Premium Member
    Skepticist's Avatar
    Join Date
    Apr 2009
    Posts
    1,139
    Thanks
    714
    Thanked 670 Times in 525 Posts
    Rep Power
    475
    Reputation
    12780

    Default

    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.

  • The Following User Says Thank You to Skepticist For This Useful Post:

    jimmyc (30-07-17)

  • #4
    Premium Member
    Skepticist's Avatar
    Join Date
    Apr 2009
    Posts
    1,139
    Thanks
    714
    Thanked 670 Times in 525 Posts
    Rep Power
    475
    Reputation
    12780

    Default

    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

  • #5
    Senior Member
    trash's Avatar
    Join Date
    Jan 2008
    Location
    Tamworth
    Posts
    4,089
    Thanks
    148
    Thanked 3,229 Times in 1,451 Posts
    Rep Power
    1288
    Reputation
    47674

    Default

    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.

  • The Following User Says Thank You to trash For This Useful Post:

    jimmyc (05-08-17)

  • #6
    Premium Member
    Skepticist's Avatar
    Join Date
    Apr 2009
    Posts
    1,139
    Thanks
    714
    Thanked 670 Times in 525 Posts
    Rep Power
    475
    Reputation
    12780

    Default

    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.

  • #7
    Senior Member

    Join Date
    Dec 2011
    Location
    Tasmania
    Posts
    871
    Thanks
    1,491
    Thanked 961 Times in 418 Posts
    Rep Power
    548
    Reputation
    18421

    Default

    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.

  • The Following User Says Thank You to shred For This Useful Post:

    jimmyc (05-08-17)

  • #8
    Premium Member
    Skepticist's Avatar
    Join Date
    Apr 2009
    Posts
    1,139
    Thanks
    714
    Thanked 670 Times in 525 Posts
    Rep Power
    475
    Reputation
    12780

    Default

    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.

  • The Following User Says Thank You to Skepticist For This Useful Post:

    jimmyc (05-08-17)

  • #9
    Senior Member
    bob_m_54's Avatar
    Join Date
    Jan 2011
    Posts
    2,093
    Thanks
    1,054
    Thanked 1,151 Times in 689 Posts
    Rep Power
    634
    Reputation
    20178

    Default

    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.

  • The Following User Says Thank You to bob_m_54 For This Useful Post:

    jimmyc (05-08-17)

  • #10
    Junior Member
    Join Date
    May 2008
    Age
    40
    Posts
    55
    Thanks
    16
    Thanked 10 Times in 9 Posts
    Rep Power
    197
    Reputation
    135

    Default

    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.

  • Tags for this Thread

    Bookmarks

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •