The electronic lock is connected to an access control system, which ensures that only the selected appliance is switched on and prevents false operation of the system.
Fig. 1 shows the block diagram of the electronic card lock. The lock has three main parts: Card sensor, microcontroller and appliance (load). The card sensor senses the code on the card (holes punched on the card) and provides the signal to the microcontroller. The microcontroller compares the code and switches on the corresponding device.
The ILQ74 is a quad optically-coupled pair with a gallium-arsenide infrared LED and a silicon npn photo transistor. Switches S2 and S3 are used to provide power to the LEDs for glowing and interrupt signal to the microcontroller.
Microcontroller AT89C51 is the heart of the card lock. It is an 8-bit microcontroller with 4 kB of flash, 128 bytes of RAM, 32 input/output (I/O) lines, two 16-bit timers/counters, six interrupt sources, a full-duplex serial port, on-chip oscillator and clock circuitry.
Power-on reset is provided by the combination of resistor R9 and capacitor C3. Switch S1 is used for manual reset. A 12MHz crystal along with two 22pF capacitors provides the basic clock frequency to microcontroller AT89C51.
Port pins P2.0 through P2.7 of the microcontroller are pulled high with resistor network RNW1, which is further connected to the collectors of optocouplers IC2 and IC3, respectively. Port pins P1.0 through P1.2 are used to drive the relay, green LED and red LED, respectively.
The outputs of the optocouplers are fed to the microcontroller to compare the code. If the code matches with the code stored in the microcontroller, port pin P1.0 of AT89C51 goes high to drive relay RL1. At the same time P1.1 also goes high, driving the green LED (LED9) to indicate successful operation. Diode D5 acts as a freewheeling diode for relay RL1. Glowing of the red LED (LED10) indicates that the code does not match.
To derive the power supply for the circuit, the 230V AC mains is stepped down by transformer X1 to deliver a secondary output of 12V, 500 mA. The transformer output is rectified by a full-wave rectifier comprising diodes D1 through D4, filtered by capacitor C1 and regulated by IC 7805 (IC4). Capacitor C2 bypasses the ripples present in the regulated supply. LED11 acts as the power indicator and R13 limits the current through LED1. Fig. 3 shows the pin details of regulator 7805 and BC337.
An actual-size, single-side PCB for the electronic card lock is shown in Fig. 4 and its component layout in Fig. 5. Assemble the circuit on a PCB as it minimises time and assembly errors. Carefully assemble the components and double-check for any overlooked error. Use IC base for placing the microcontroller on the PCB. Check the supply voltage. Align the LDRs and LEDs such that these directly face each other. Cover the LDRs with suitable masking to protect these from other light sources. The card is shown in Fig. 6.
Insert the card into the card sensor slot, close switch S2 and then press switch S3. The internal LEDs of the optocoupler glow depending on the holes on the card. The internal transistors of the optocoupler drive into saturation and its collector goes low.
Download PCB and Component Layout PDFs: click here
Download Source Code: click here
The software for the electronic card lock is written in Assembly language and compiled using the Keil µVision4 compiler. The generated hex code is burnt into the microcontroller by using a suitable programmer. The program works as per the flow-chart shown in Fig. 7.
The author is M.Tech from DCRUST Murthal University.