Combo Lock Uses Relays And Logic Gates


Here’s a really fascinating circuit that implements a combination lock using relays and logic gates. Even with the schematic and written explanation of how it works we’re still left somewhat in the dark. We’ll either pull out some paper and do it by hand this weekend, or build it chunk by chunk in a simulator like Atanua. Either way, the project sparked our interest enough that we want to get elbow deep into its inner workings.

From the description we know that it uses a combination of CD4017, CD4030, CD4072, and CD4081 chips. You’re probably familiar with the 4017 which is a decade counter popular in a lot of project. The other chips provide XOR, OR, and AND gates respectively. The relays were chosen for two purposes. One of them activates when a correct combination has been entered, effectively serving as the output for the combo lock. The other two are for activating the clock and affecting a reset if the wrong combination is entered.

It makes us wonder if this would be incredibly simple to brute force the combination by listening for sound of the reset relay activating? It’s hard to tell from the video after the break if you can discern a wrong digit from a right once just based on sound.

22 thoughts on “Combo Lock Uses Relays And Logic Gates

      1. I have a dream that someday we will come up with at least a scripting language with context sensitive fuzzy, free flowing syntax.

        Then again that would mean people that don’t understand modus ponens let alone serious logic would be able to bend computers to their will.

        Rather frightening actually, in the ‘give a monkey a hand grenade and make the pin look like a banana’ sort of way.

  1. Interesting simple design, although it only offers like 4! = 24 different combinations.
    To make more combinations possible by using logic gates you could probably assign each of the 4 keys a 2-bit code and shift those 2 bits into 2 separate shift registers. After 4 or 8 shifts (or whatever number of key presses you want) you could compare the outputs of the shift registers with a preset number (with an HC688) and open the lock if they match. But of course this will take more integrated circuits to implement (or maybe the same number and a bunch of diodes to encode the keys into bits).

    1. There are very simple designs using only a 4017, what i think was a schmitt and gate, a couple of diodes and resistor networks.

      It’s the design used by all those old door key pads that were not network connected, unfortunately i have lost the design drawing i made of one, and i cant find the design online.

      It selects a row of pin headers for each output of the 4017 for each digit in the code, pressing the right one strobes the clock, pressing any of the wrong ones strobes the reset.

      The only downside is that this design does not work with a matrix keypad, it needs an 11pin 10 digit keypad where each key corresponds to an output pin, plus one common.

  2. Tried building complex stuff in minecraft with redstone? I once built a bank vault with an order sensitive combo lock. Another time I built a digital clock. Not too shabby if I say so myself, especially considering I’m only 15. :)

  3. It appears to be a state machine where pressing the correct button will activate a timer that advances a decade counter which selects the next state. Each state has two possible outcomes: start the timer or reset the counter. This is accomplished by a network of logic gates that reproduce some truth table.

    Put simply:
    correct_n = counter_n AND key_n
    incorrect_n = correct_n XOR key_n
    For any correct_n strobe the timer
    For any incorrect_n strobe the reset

    n means the number of the counter state and key.

    For example, if the counter is in the first state and the first key is pressed, the correct_1 signal goes up. A four input OR gate then sees if any correct_n signal is up and activates the timer which advances the counter.

    Meanwhile the XOR gate corresponding to the first key sees that the key is pressed, but since the correct_1 signal is also up, the incorrect_1 signal will remain low. If on the other hand the counter state was not 1 but 2, then the XOR gate sees the key signal but no correct_1 signal, and the incorrect_1 signal goes up. Again, a four input OR gate sees if any incorrect_n signals are up and activates the reset relay which resets the counter.

    The last state of the counter is to activate the relay K3 and since all counter_n signals are now low, pressing any key will trigger a reset.

    1. There’s also a clever trick.

      The counter advances on the rising edge of a signal, so pressing the correct key will advance the counter state almost instantly. Once the counter advances, the key you are pressing at the moment will be the incorrect key and will produce a reset signal before you can lift your finger.

      Except, they are using double throw relays, and the second pair of contacts is used to disconnect the reset signal while the timer is active, so pressing the wrong key within half a second of the right key does nothing.

      Holding the right key of the next state before the timer counts down however will keep the timer on indefinitely, so you can discover the first correct key by pressing it repeatedly. If it clicks every time, it’s the wrong key. Once you have the first key, you press it and immediately hold another key. If you can’t hear the timer click off, then that second key is the next correct key. If not, then one of the remaining two keys is the second key and you’ll find it next time. Repeat the same for the second state, and you’ll get the third and fourth keys at the same time without guessing.

  4. I just had a thought after reading this of using 4 different pots with knobs 1-10. and using a comparator to a known value for each. Add a switch that has to be pressed to test the combination (to keep the knobs from being spun). few other logic and timer sections and it might make a tough one to crack.

  5. I asume that this circuit was only built for the fun of it. If it were to be used for something serious, just about any 8 pin microcontroller would have been far superior.

  6. For my AS-Level Electronics project at school I created something very similar using only discrete logic gates. I believe it used AND, OR and XOR only. I will try and dig out the circuit diagram and share it.

    I love these kind of low level logic projects. Analogue electronics is black magic.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.