Maker Pro
Maker Pro

Creating a latch circuit with logic gates

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.
 
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.
Getting no-where as in funny results?
Have you debounced the switches?
 
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.
 

Attachments

  • Circuit-page-001.jpg
    Circuit-page-001.jpg
    130.3 KB · Views: 136
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.
 
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.
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.
 
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. =)
 
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?
 
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?
Do you have an clever way of using the pushbuttons to trigger a single clock pulse?
I thought this too.
 
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
 
....before the data clocks through
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.
 

hevans1944

Hop - AC8NS
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.
 
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.

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.
 
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:
Top