Connect with us

Creating a latch circuit with logic gates

Discussion in 'General Electronics Discussion' started by Sadlercomfort, Apr 9, 2015.

Scroll to continue with content
  1. Sadlercomfort

    Sadlercomfort Ash

    424
    53
    Feb 9, 2013
    Hi guys,

    I'm trying to create a circuit which takes 9 push-to-make switches, and switches a single output to high when you type in a specific combination. I've been experimenting with latch circuits using two NOR gates but am getting no where.

    I know that i can use AND Gates, which will set the output to high when the specific combination is put in. But getting the beginning of latch circuit working is difficult. The combination is 8 digits, so the circuit needs to remember if the same number is pressed more than once.
     
  2. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
    Getting no-where as in funny results?
    Have you debounced the switches?
     
  3. Colin Mitchell

    Colin Mitchell

    1,418
    314
    Aug 31, 2014
    There is a 9 button combination lock on the web.
    You need to have a lot of skill to design this type of circuit.
     
  4. Sadlercomfort

    Sadlercomfort Ash

    424
    53
    Feb 9, 2013
    Hi guys, I managed to create something, It works a treat but is complicated.

    The inputs a clocked through at 10Hz, just enough time to capture the input once. I've used AND Gates and Inverter's so the output is switched when the correct combination is pressed. I used an enter button, so when the user fails to type in the correct number it defaults to another number.
     

    Attached Files:

  5. Sadlercomfort

    Sadlercomfort Ash

    424
    53
    Feb 9, 2013
    Not sure how to reset them all.
     
  6. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
    Perhaps tie the output of the 'default' student ID to the 'clear' input on the flipflops?
     
  7. Sadlercomfort

    Sadlercomfort Ash

    424
    53
    Feb 9, 2013
    Yeah, that's actually what I'd like to do. The Clear pins on all the flipflops are connected together, and kept high as the inputs are being entered. Then when the output is received successfully, it operates a push-to-break switch and sets the Clear pins low to reset.

    However, I can only do this using a push-to-break switch. Is there anyway to tie the output of the ID's to operate a transistor, which sets the Clear pins low with an 'open circuit'.

    So its like an automatic push-to-break circuit.
     
  8. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
    Yes there certainly is. I can't draw it for you at the moment, but you can use a transistor and a resistor to do this. Now... it won't be 'normally open', but it would be 'normally high'.
    I'll explain best I can:
    A resistor is connected to Vcc, A transistor is connected between the resistor and ground.
    The point at which the resistor and transistor connect is what we are interested in.
    When the transistor is off, no current flows, so Vcc will be present at the point we are interested in.
    When the transistor is on, the point we are interested in essentially gets shorted to ground.
     
  9. Sadlercomfort

    Sadlercomfort Ash

    424
    53
    Feb 9, 2013
    I totally understand, I'm familiar with that arrangement. I've set it up but with 5v at the base, and it clears the flip flops nicely. However it doesn't work using the final output from the IDs, because of a slight voltage drop.

    I found some sort of Schmitt Trigger Inverter which seems to correct the voltage and switches the base nicely. =)
     
    Gryd3 likes this.
  10. Arouse1973

    Arouse1973 Adam

    5,164
    1,080
    Dec 18, 2013
    If they have pressed some correct switches I assume you want these reset when they press a wrong one?
    Adam
     
  11. Laplace

    Laplace

    1,252
    184
    Apr 4, 2010
    Noticed that the gate diagram shows the JK inputs of each FF are connected together, so when the JK is HI the FF will toggle the Q outputs on the negative clock transition, and when the JK is LO the Q outputs will remain unchanged. Also, each triad of FF's is connected as a 3-bit binary ripple counter, so whatever value Q0,Q1,Q2 becomes will depend on how long the number pushbutton is depressed. My question: Is knowing how long to hold down the pushbutton meant to be an extra security feature?
     
  12. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
    Do you have an clever way of using the pushbuttons to trigger a single clock pulse?
    I thought this too.
     
  13. Sadlercomfort

    Sadlercomfort Ash

    424
    53
    Feb 9, 2013
    Yeah, I was wondering that.. If the button is pressed to long it sets the second Q output on the FF to High.

    A single pulse would be great. Reducing the clock frequency only increases the amount of time you need to hold the push-to-make switch before the data clocks through
     
  14. Colin Mitchell

    Colin Mitchell

    1,418
    314
    Aug 31, 2014
  15. Laplace

    Laplace

    1,252
    184
    Apr 4, 2010
    The point was that the data is not clocking through, rather it is gating a counter. To make a JK-FF behave like a D-FF (where the data does clock through) it would be necessary to connect one of the JK inputs to the pushbutton and the other kept at logic LO.
     
    Gryd3 likes this.
  16. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
  17. hevans1944

    hevans1944 Hop - AC8NS

    4,460
    2,075
    Jun 21, 2012
    It appears that any permutations of the code containing all the required digits (including the repeated digits) will "open" the lock. In your example, code 121992 is the valid code, but so is 119922, 219219, etc. Is this what you really want to do (after fixing the problems with the J-K flip-flop wiring)?

    A true combination lock will "remember" not just the digits entered but also the order of entry before comparing the entries against the valid lock code. The user must press an "ENTER" button after entering their code sequence. Then, and only then, will the lock open if the correct sequence of digits has been entered.

    Pressing "ENTER" also clears the memory of the previously entered code sequence, whether that sequence was valid or not. This allows a user to "start over" if they realize they have keyed in the wrong sequence. The only indication of a valid sequence after "ENTER" is pressed is the lock opens.

    It is a good idea to provide optical or audible feedback each time a digit button is pressed. This allows the person attempting to gain entry to know that a button press has been "accepted" by the system for subsequent validation.

    A more difficult to defeat combination lock will allow not only repeats of the same digit but also simultaneous entry of two or more digits, followed by additional digits until the code entry sequence is completed. Again, optical or audio feedback will be helpful. I would suggest that a single light be illuminated or an audible tone be sounded (for use by the blind) when any switch is pressed, the light to remain illuminated or the audible tone to remain on until all switches are released. The light extinguishing or the absence of the audible tone would be the cue that the next switch (or simultaneous actuation of switches) is ready for entry.

    Again, it is important that there be no indication that the correct number of entries has been made, or the correct switches have been pressed. The only indication of code verification occurs when the "ENTER" button is pressed, whereupon the code sequence that was entered is validated (lock opens) or is rejected (lock does not open). An alarm should sound if a certain number of incorrect validation attempts, say ten or twelve, are made with the "ENTER" button.

    All the above is relatively simple to program into a microcontroller; not so much with flip-flops and combinatorial logic, although that is possible. Setting up the validation code sequence should also be a consideration because this should be changed from time to time. A USB memory stick with the latest validation sequence code stored as a text file could be used for this if microprocessor implementation is considered. There could even be different codes for different users and data logging with time stamps of user attempts to gain entry. A Raspberry Pi would probably be a low-cost solution.

    I am reasonably confident that security companies already offer this type of combination lock, but it is fun to "roll your own" from time to time, especially if it is part of a learning process.
     
  18. Sadlercomfort

    Sadlercomfort Ash

    424
    53
    Feb 9, 2013
    I'm not sure if I understand you fully. But then I'm not that familiar with JK's or D-type Flip Flops.

    I didn't realise the flaw in the design, where different arrangements of the same combination would work. 1122999 for example. The circuitwizard software I'm supposed to use doesn't include any microcontrollers I'm familiar with.

    Optical verification of the correct code sequence should be easy to set up.

    I've made it reset the JK's when the user presses enter three times. I've also made the JK's reset when the correct code is typed in, ready for the next user.
     
  19. Sadlercomfort

    Sadlercomfort Ash

    424
    53
    Feb 9, 2013
    Oh yeah, I don't know how to fix the JK flip flop wiring.

    The JK's automatically reset when 3 unsuccessful combinations have been entered OR when the a correct combination has been entered. Using the transistor to make the JK's low.

    The problem is the output resets aswell, so I need to find a way to make it hold its state, while resetting the JK's. I've tried using another FlipFlop at the output to remember its state, but this creates a voltage drop and which no longer switches the base of the transistor to clear the JK's.


    Untitled.jpeg
     
    Last edited: Apr 11, 2015
  20. hevans1944

    hevans1944 Hop - AC8NS

    4,460
    2,075
    Jun 21, 2012
    What!? This is a homework assignment? I thought you were doing this for the pure fun of it, and as an intellectual challenge.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-