Keycoder for Electronic Lock

Introduction: Keycoder for Electronic Lock

This is a simple programable 4 button combination code.

interface module and as such can be used on a number of projects where a keyless lock control may be required. Only the PCB to generate the required signal to initiate a locking mechanism is shown, the locking mechanism is left to the user.

The PCB uses a combination of surface mount and through hole components which are all readily available, a steady hand and fine tip soldering iron will be required to mount the SMT components. For ease of construction the DIP's are mounted in sockets. Screw terminals are used to connect the 9V battery (5V min to 15V max), and output.

I created the PCB layout using Eagle Cad and this was manufactured at OSH Park.

Supplies

Component List

3× 10k Resistor 1206

2× 20k Resistor 1206

4× SWITCH SPST-NO

1× 3 Way PCB Terminal Block 2.54mm pitch

1× 2 Way PCB Terminal Block 2.54mm pitch

2× 16 pin IC Socket optional

1× 14 pin IC Socket optional

1× 8 pin IC Socket optional

1× PCB 2 layer board

2× 47k Resistor 1206

1× 10n Capacitor 1206

1× 100n Capacitor 1206

2× BSS123 NFET SOT23

2× CD4027 Dual JF Flip Flop 16DIP

1× CD4081 Quad 2 input AND 14DIP

1× 555 Timer 8DIP

1× LED RED 3mm

16x Terminal pins 2.54mm spacing

Step 1: Circuit Description

The circuit is realised using CMOS logic gates, a timer chip and a handful of discrete components.

The central element is the JK flip flop of which four are used, this requires the CD4027which contains two flip flops, therefore two of these are required.

The CD4027 is available with 16 pins in DIP and SMD, the pin out and functionality are the same irrespective of the package.

The truth table shows the state of operation.

LH = Low to High transition, HL = High to Low transition, NC = No change, X = Don’t care.

For this application S and R inputs are both low therefore in this case the last three lines of the truth table can be ignored.

Therefore, the output state of the Flip Flop (FF), will be determined by the high level on the J or K input when the clock (CLK), is on the rising edge (LH).

Each of the first three keys of the keyboard are connect to the J input of a FF which detects the key state, with the key un-pressed the input is low (default is pulled low by a resistor), when the key is press the J input goes high when CLK changes LH. The causes the Q output to go high.

The 2nd FF is gated by a combination of the state of the previous 1st FF and CLK via an AND gate.

The CD4081 quad 2 input AND is available with 14 pins in DIP and SMD, the pin out and functionality are the same irrespective of the package

If the 1st FF’s output was high the 2nd FF’s output will go high when clocked, if the 2nd key was pressed.

The 3rd FF is gated by a 2nd AND gate (via the 2nd FF’s output), and CLK.

The K inputs of all the FF’s are connected together via the 4th key, pressing this provides a high level which on the next LH of the input CLK forces the Q outputs low and resets all the FF’s. If the key is un-pressed the input is held low (default is pulled low by a resistor).

In addition to the manual reset provided by the 4th key, a power on reset (POR), is provided by the capacitor/resistor (CR), network formed by the capacitor across switch 4 and the pull-down resistor on the K inputs.

When the power is applied the CR network provides a HL pulse to the K inputs and with the J inputs all pulled low by a resistor (J=L, K=H), the Q outputs are all low.

The output of the 3rd FF is connected to one input of a 2 input EXOR, the other input is connected to a POR network.

Single gate EXOR’s are available but their maximum operation voltage is 5.5V, which is at the low end of the CMOS operating voltage. In any event the intention is to operate the circuit at 9V

To this end, an EXOR using resistors, NFET’s and the 3rd AND gate was created.

The output of the EXOR gates CLK via the 4th AND gate to the input of the 4th FF were J=H and K=LH toggles the output of the FF. When Q=L the lock is set, when Q=H the lock is unset.

The clock is generated using a 555 timer configured in Astable mode..

Step 2: Assembly

Attach the surface mount devices first, this prevents blocking of these components by the larger through hole components and at this stage the board is flat which simplifies assembly.

Next solder the IC sockets unless fitting the IC's directly to the board.

However, IC sockets can simplify debug and replacement in the event of issues.

Fit the terminal pins unless resorting to wire links.

The terminal blocks being the last to be soldered as they sit higher than the other components.

Step 3: Operation

The condition as to whether the unit is set or unset is indicated by an LED, this can be extended above or remotely from the main board as per requirements.

The LED stays on when set. (also the power up default).

Setting and un-setting is accomplished by entering a 4-button combination, the correct code turns on the LED indicating the system is set and the correct code turns off the LED.

An incorrect code sequence applies a reset to the system requiring the code sequence to be re-entered from the beginning.

The required code is set by jumpers (allowing the code to be changed easily), or links (hard coded, less flexible).

Hard coding negates the terminal posts simplifying construction, but makes changing the code less convenient

The links are arranged in groups of two in a 4 x 4 matrix.

The column aligns with the corresponding switch, one column per switch.

The row aligns with the switch order from 1 to 4.

Taking S1 as an example.

Under S1 there are 4 links in the corresponding column, if the 1st link is made it assigns this as the 1st button in the code sequence,

If the 2nd link is made it assigns S1 as the 2nd button in the sequence etc.

The same methodology is applicable to all the buttons.

Step 4: Troubleshooting

Problems can occur and if they do how can they be tackled.

The first thing to do is look for the obvious.

IC in the wrong location, wrong orientation or pin(s) not soldered or poorly soldered, poor socket insertion or bent pin.

Component in wrong position, wrong value, wrong orientation or poor soldering.

Solder bridging,

Supply voltage on the wrong terminals, supply leads swapped, incorrect voltage.

Even the PCB could have an open or shorted track(s)

Don't tell yourself it cannot possibly be a particular issue without verifying it

Be the First to Share

    Recommendations

    • Maps Challenge

      Maps Challenge
    • First Time Author Contest

      First Time Author Contest
    • Summer Fun: Student Design Challenge

      Summer Fun: Student Design Challenge

    Comments