this is another entry for the 555contest.com
A certain knock at the door may tell you if the person behind it is the one expected or just somebody else. Each knock on the door itself cannot tell you too much, it can be lighter or stronger and that’s all about it, there’s no information on pitch here. But a certain sequence of knocks can be an actual secret code. The secret knock is encoded in the actual timings of the knocks, the time between each knock creating a distinguished pattern.
In order to build a circuit that detects secret knocks, let’s first look at an oscilloscope capture of a random secret knock. The timings between pulses are different but are easily recognized by a human in order to identify the visitor. If a circuit were to be able to detect this, it should be able to detect is the knocks are arriving at their specific time, but also allow some tolerance.
This tolerance will translate into having intervals in which a knock (also referred to as a pulse) is expected to arrive and intervals in which a pulse should not arrive. This is shown with the red and green rectangles in the figure below, with green being required to receive a pulse and the red being forbidden to receive a pulse.
To achieve this I have cascaded a series of 555 timers in monostable mode that are triggered one after another with some specific rules which describe how the circuit works.
1. A first pulse will trigger the first timer, the first “red time”. Any further knocks arriving for a few seconds afterwards will not be allowed to trigger the first timer.
2. When the first “red time” is up, it will trigger the first “green time”.
3. If a knock is received during the “green time” it will trigger the second “red time”, if not, the sequence stops because the code is wrong.
4. The second “red time” is started, triggering the second “green time” when the time is up.
5. The second “green time” will trigger the third “red time” if a pulse is received during this time or else the sequence stops because the code is wrong.
6. The sequence of “red time” and “green time” repeats for a predetermined number of times as long as the conditions are met. The number of red and green sequences determines how long the code has to be, how many knocks.
7. Any pulse arriving during any “red time” means that the code is wrong and it will trigger a reset circuit that blocks further pulses for a number of seconds, stopping any propagation and making the next pulse start the sequence all over again.
8. If the required pulses arrive correctly throughout the sequence, the last pulse during the last “green time” will trigger a door opening mechanism.
Summing it up: a pulse on each “green time” and no pulse on each “red time” will ensure correct triggering of each of the timers of the sequence up to the last one which will get the door open.
Implementing the circuit
Below is the clickable jpeg version of the schematic which will open a large image but you may check the pdf version too.
The circuit is composed of 7 timing stages and a few other blocks which ensure its correct functionality. I will discuss each block in detail.
1. Amplifier, comparator and knock pulse generator block
This is the first block of the circuit. Its purpose is to get the signal form the microphone that is attached to the door and get a clean negative pulse out for triggering the other circuits. After getting amplified the signal gets compared to an adjustable level ensuring that the first 555, IC2, gets triggered and outputs a short, 3ms low level pulse. The second 555, IC3, will trigger after IC2 and keep it in reset for a short period after the pulse has arrived. This ensures that each knock can generate only a single trigger pulse. I’ve had problems while testing the circuit; the door generated a single pulse, but the desk I’ve used for experimenting generated two very close pulses.
2. Long pulse blocker
This block ensures that only a single pulse can trigger the series of timing stages and it is composed of two 555s. The first 555 measures a short delay after a pulse and then triggers the second which forces the net KNOCK_BLOCK to stay high(preventing triggering) for a period of about 4 seconds which allows only the first pulse to propagate to the first timing stage.
3. Timing stages
There are 7 timing stages which are meant to detect if the pulses arrive at correct timings. The 7 stages measure 7 intervals and along with the first pulse allows for an 8 pulse code to be recognized. Of course, less timing stages may be used and thus shortening the code.
In order to explain how they work, let’s analyze the second timing stage because there is another one before it and one after it. There are two 555s wired as monostables, with the first one measuring the “red time” and then triggering the second “green time” stage when it turns off. C15 and R48 ensure that a short low pulse appears at the trigger input of the second 555 when the output of the first goes low, triggering it.
The first 555 also resets the previous “green time” 555 when it is triggered, ensuring that at no moment there are two 555 with a high output. The outputs of the “red time” 555s from all the timing stages are OR-ed with the help of diodes which ensures that the RED_TIME net stays high whenever a “red time” is on. The same goes for the GREEN_TIME net which stays high whenever a “green time” is on.
There are two LEDs, a red and a green corresponding with a “red time” and a “green time” used as indication. All these LEDs from all the blocks share the same ground connection through a switch which allows them to be turned off while in normal operation, giving no indication on the correctness of the timings but they need to be used while programming the timings and learning the secret knock.
One of the points of decision is made in each of these blocks, triggering the next block if a knock is detected while the “green time” is on. This is done with the help of a transistor, in this particular block, T8. It can only conduct and trigger the next 555 if the base is a high level (the “green time” is on) and the KNOCK net is low, therefore it can only trigger the next stage if a knock appears during the “green time”.
This block takes care of the other type of wrong knock, a knock arriving during a “red time”. As the RED_TIME net is high every time a “red time” block is on, using a transistor in the similar way as above, a pulse will trigger the 555 if a knock arrives during a “red time”. There is still one extra detail: because the knock pulse has a certain length and the “red time” gets triggered by a correct pulse during a “green time”, for a short time at the beginning of a “red time” the circuit will see the last part of the correct knock pulse and might mistake it for a false one. To ensure this doesn’t happen, T3 along with a filtering capacitor, C8, will create a short delay, blocking the RED_TIME from rising immediately after the GREEN_TIME signal went low. This means that it will ignore the actual pulse at the beginning of the “red time” which is the pulse that started the “red time” in the first place.
By blocking the inverter after the knock pulse generator for a few seconds, the reset timer will ensure that all the circuits will go back to their low state and allow a new pulse to start the first timing block.
5. Door open timer and relay
The last block is the door open timer. It has a simple task, it will keep the relay energized for a time when it is triggered, ensuring that the door will be kept unlocked by some electromagnetic lock.
Additional notes on the full circuit:
1. There are some strange values for certain parts of the schematic, such as 320n for a capacitor. This is because it was easier for me to change the timing of that particular block by putting a 220n capacitor in parallel to the 100n already existent on the board.
2. I have abused some resistor values, mostly 10K. This is due to simplicity in building and to the fact that the resistor value is not critical at all. I’ve also used a 10K resistor for reset pull up when a simple wire would have done the job, again because it was faster to use a resistor then to cut a wire to length. This resistor abuse also means I only have less than 10 10K resistors from my 100 piece strip which I bought a few weeks ago.
3. Some of the timings chosen for a particular 555 are not critical at all and they are mostly justified by simple conditions, such as longer that that time, shorter than that and by the historical evolution of the circuit. For example, the long pulse blocker uses a 120ms timing for the first delay, when it actually has to be just a bit longer than the 3ms knock pulse and shorter than the 170ms that the knock pulse generator is blocked after each pulse. The value meets the conditions and has its origin in the fact that at the beginning I have used about 50ms for the knock generator which proved to be too long.
4. On the schematic there are no 100n filtering capacitors for each IC. They actually exist on the built circuit, but I decided not to clutter the schematic with them (ok, ok…. I actually forgot to draw them).
5. The circuit is, of course, complicated and could easily be replaced by a single microcontroller, but that’s not the point. The point is to build it using 555s.
The circuit summary: 210 components out of which 20 are 555s, 1 op amp, 19 transistors, a relay, 20 LEDs, 16 diodes and the rest are passives. No, I will not post a BOM, nobody should try to reproduce it. It’s too complicated!
And of course there is a magnificent video showing the circuit and trying it out into the late hours of the night. It actually takes me quite a few tries before I can get the door to open(read that as blue LED turning on), which basically shows that I shouldn’t try drumming and that a longer period for the “green time” should be desired in practice, in order to frustrate people less.
I’ve also got a build log with a series of pictures, showing how the circuit has evolved. It all started with the opamp:
and continued with the long pulse blocker which was working just fine
After that, the first timing stage was working well too
so I have started the assembly line for the next 3 stages
and then I started building the second row of timing stages (you can also see my super high tech fume extractor):
and this is the first time the whole detection worked:
I’ve then added the reset circuit
The finished version, including the relay
and a few pieces of my original schematics: