HOME

 

how to use the st0 input

Combination lock

to protect and serve

A versatile guardian | Schematic diagram | Truth tablei | For experimenters

 

A versatile guardian

Only one out of 9,999 possible codes has the power to unlock this simple, yet effective, electronic lock. A combination lock is not just a perfect system to protect your belongings, it is also a valid system to let everyone to know that you are vigilant: an electronic system with a silicon heart is controlling the area, day and night without interruption, so everyone is warned! You can use this combination lock circuit as a replacement or in addition to normal locks. It is very handy when a group is entitled to enter a common area, as parking lots or sport resort facilities for example.
It is often the case where traditional keys are expensive, not appropriate or just not convenient: not to mention when the keys need to be replaced very often (e.g. in the case of parking lots the cars can change). Compare the convenience of distributing a new access code to the requirement of making a new run of keys...
This electronic lock is excellent also for locking devices powered by the electricity. A phone line, a photocopier, children's TV, a fax or a water pump: these are just a little selection of devices that can be locked with a combination lock. And did we mention the option for adding a remote control?

Schematic diagram

The basic blocks of this electronic combination lock are the keyboard, the Nutchip and the relay.
The keyboard counts 10 keys, labelled with numbers 0 to 9. Four keys (actually simple normalli-open pushbuttons) connect directly to Nutchip inputs IN1...IN4. If you follow precisely the schematic we give, you get the combination 6-7-8-9. Any other key sequence will lock the device until the correct sequence is entered again. The correct sequence is determined by the truth table. In order to detect wheter a wrong key has been touched or not, the remaining keys (those not included in the combination) are connected in parallel and drive input ST0. This special pin causes the Nutchip to reset and restart it from state zero (st00), regardless of current state and other pin's situation. Therefore, touching the wrong key will cause the Nutchip to restart from state zero.

combination_lock.gif (11353 byte)

You can chose any other 4-digit combination; if, for example, you want to select the combination 1-7-8-9, all you have to do is to swap pushbutton P1 with P9. Once the keyboard is assembled, it is easier to change the combination changing the order the digits need to be entered (e.g. 1-9-8-7). In this case, you are not required to use the soldering iron, but instead just reprogram the truth table with a different one.

 

Truth Table

Let's list all the actions to be performed by the Nutchip in order to implement a combination lock:

  • the Nutchip must check that the inputs IN1...IN4 get activated one after another, according to the specified sequence, and that they are activate one at a time.
    When all of the combiantion's digits are typed in correctly, the relay energizes for 5 seconds
  • as soon as one of the inputs is activated without being in the correct sequence, the operation is aborted and the user must restart typing the sequence from scratch
  • should one of the pushbuttons not included in the combination be pressed, the operation is aborted and the user must restart typing the combination from scratch (this step is implemented in hardware, as all of the keys not included in the combination are connected to input -ST0, which causes the Nutchip to restart regardless of current state and inputs)
  • as an additional safety measure, there is a timeout of 5 seconds each time a new key is pressed. Should the timeout expire with no other keys pressed, the operation aborts and the user must restart typing the sequence from scratch

When the Nutchip is first powered up it is in state st00. in this state the relay is not powered. This satisfies the condition of the device to be reset when one of the keys connected to input -ST0 gets pressed.

Now imagine the user to press the key connected to input IN1. This advances gradually the Nutchip to state st01. Continuing with the right keys brings the Nutchip to state st2, then st3, and finally to state st4 which activates the realy (all outputs are set to 1) for a duration of 5 seconds.

We did already mention the effect of the keys connected to input -ST0; but what if one of the keys in the sequence is pressed at the wrong time? As you can see from state st00, st01, st02 and st03, the keys connected to the inputs are checked one by one during the whole sequence. Therefore, the Nutchip will reject the case when two or more keys are pressed at once, restarting from state st00, as well as for the case one of the keys included in the combination is pressed at the wrong time.

Note also that, with the exception of state st00, the last key pressed is not checked after chancging state: for example, input IN1 is not checked in state st01, input IN2 is not checked in state st02 and so on. This allows the user to keep the key pressed for some time before releasing it, making the operation more comfortable. Note also how all of the states have a 5 seconds timeout, so no operation can be left open forever.

 

keylock_table.gif (4656 byte)

Truth table of the combination lock.

You can get it from the file keylock.nut

 

Experimenter's appetizer

This project can be adapted to a variety of applications. Here are a few serving suggestions to stimulate your experimenter's appetite: