Anda di halaman 1dari 59

PASSWORD BASED SECURITY DOOR LOCK SYSTEM

A PROJECT REPORT Submitted by

ARPAN SINHA CHHAVI GOYAL DEEKSHA AGGARWAL SNEHA

0102092808 0412092808 0562092808 0602092808

in partial fulfillment for the award of the degree Of

BACHELORS OF TECHNOLOGY
In ELECTRONICS AND COMMUNICATION ENGINEERING AT

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

GB PANT ENGINEERING COLLEGE OKHLA INDUSTRIAL ESTATE NEW DELHI 110019

DECEMBER 2011

LIST OF TABLES CHAPTER NO. 3. TABLE NO 3.1.1 3.1.2 3.4.1 3.5.1 3.5.2 TABLE TITLE PAGE NO 11 11 16 18 20

Alternate functions of Port 1 Alternate functions of Port 3 Pin Description of AT24C02 Pin description of 16x2 LCD command codes

ii

LIST OF FIGURES CHAPTER FIG NO. NO. 2. 2.1 FIGURE TITLE Circuit diagram of PASSWORD BASED SECURITY DOOR LOCK SYSTEM 3 3.1.1 3.1.2 3.2.1 3.2.2 3.2.3 3.3.1 3.3.2 3.4.1 3.5.1 3.5.2 3.6.1 3.6.2 3.7.1 3.7.2 Microcontroller AT89S52 Pin Configuration of AT89S52 Symbol of an LED Parts of an LED Recombination in an LED Variants of Push Button Tact Switch Working of Push Button Tact Switch Pin Diagram of AT24C02 16X2 LCD Pin diagram of 16x2 LCD Types of resistors Colour coding of resistor Ceramic Capacitor Electrolytic Capacitor 9 10 13 13 14 15 15 16 17 18 22 23 24 24 26 26 27 28 30 32 PAGE NO. 6

3.8.1(a) Step Down Transformer 3.8.1(b) 9-0-9 Step Down Transformer 3.9.1 3.10.1 3.11.1 3.12.1 7805 IC Full Wave Rectification IN4007 diode Equivalent circuit of crystal oscillator

iii

4.

4.1 4.1.1 4.1.2 4.2.1 4.3.1 4.4.1 4.5.1

Interfacing of Microcontroller 16X2 LCD Display Interfacing of AT89S52 with 16X2 LCD Display Interfacing with Push button switches Interfacing Microcontroller with reset switch Interfacing of crystal oscillator with Microcontroller Interfacing of output LED with Microcontroller

34 34 35 36 37 37 38

iv

DECLARATION

We hereby declare that the project work entitled PASSWORD BASED SECURITY DOOR LOCK SYSTEM submitted to the G.B.Pant Engineering College, Delhi is a record of an original work done by us under the guidance of Mrs. Monika Garg, and this project work is submitted in the partial fulfillment of the requirements for the award of the degree of Bachelor of Technology in Electronics & Communication Engineering. The results embodied in this thesis have not been submitted to any other University or Institute for the award of any degree or diploma.

Arpan Sinha (0102092808)

Chhavi Goyal (0412092808)

Deeksha Aggarwal (0562092808)

Sneha (0602092808)

Date: Place:

G.B. PANT ENGINEERING COLLEGE DELHI GGSIP UNIVERSITY: NEW DELHI BONAFIDE CERTIFICATE

THIS IS CERTIFIED THAT THIS PROJECT REPORT PASSWORD BASED SECURITY DOOR LOCK SYSTEM IS THE BONAFIDED WORK OF ARPAN SINHA, CHHAVI GOYAL, DEEKSHA AGGARWAL & SNEHA WHO CARRIED OUT THE PROJECT WORK UNDER MY SUPERVISION.

SIGNATURE MAMTA JAIN HEAD OF THE DEPARTMENT ECE

SIGNATURE MONIKA GARG SUPERVISOR (ASSISTANT PROFESSOR) ECE


vi

ACKNOWLEDGEMENT
We place on record and warmly acknowledge the continuous encouragement, invaluable supervision, timely suggestions and inspired guidance offered by our Lecturer, Department of Electronics and Communication Engineering, G.B.Pant Engineering College, Delhi in bringing this project to a successful completion.

We are grateful to Mrs. Mamta Jain, Head of Department of Electronics and Communication Engineering and Mrs. Monika Garg, Assistant Professor (E.C.E) for permitting us to make use of the facilities available in the department to carry out the project successfully. Last but not least we express our sincere thanks to all of our friends who have patiently extended all sort of help for accomplishing this undertaking.

Finally we extend our gratefulness to one and all who are directly and indirectly involved in the successful completion of this project work.

ARPAN SINHA CHHAVI GOYAL DEEKSHA AGGARWAL SNEHA

ABSTRACT
Home/office security is a prime concern for everyone. Access control is the ability to permit or deny the use of a system by a particular entity. The main idea of designing digital locking system is to provide more secure security system than mechanical lock; here key pad is used to enter the password. If that password matches with the password already stored in flash of the controller then the LED blows which can be replaced by a DC motor in future for practical application for opening the door and if the password is entered wrong more than three times then the buzzer is activated. System can work in two modes- User Mode and Master Mode. User mode password is changeable and the user can login through the user mode only. Master mode password is fixed and cannot be changed. It is used to change the user mode password. Master code is not known to everyone, it is kept only for security purpose. Whenever a user would like to access the system, he is asked for a password which is provided to him and if the password entered by him is correct he is allowed to access the system otherwise the door will not be opened and INCORRECT will be displayed on the LCD display, which means either he is not authorized to access the system or he may forget the password.

TABLE OF CONTENTS CHAPTER NO. LIST OF TABLES LIST OF FIGURES DECLARATION CERTIFICATE ACKNOWLEDGEMENT ABSTRACT 1. INTRODUCTION 1.1 CHARACTERISTICS OF AN EMBEDDED SYSTEM 1.2 COMPONENTS REQUIRED 2. DESIGN AND DEVELOPMENT OF PASSWORD BASED SECURITY DOOR LOCK SYSTEM 2.1 WORK APPROACH. 3. DESCRIPTION OF COMPONENTS 3.1 MICROCONTROLLER AT89S52 3.1.1 FEATURES 3.1.2 DESCRIPTION 3.1.3 PIN CONFIGURATION 3.1.4 PIN DESCRIPTION TITLE PAGE NO. ii iii v vi vii viii 1 2

3 4

5 8

3.2 LIGHT EMITTING DIODE (LED) 3.2.1 WORKING 3.2.2 ADVANTAGES OF LED 3.2.3 DISADVANTAGES OF LED 3.3 PUSH BUTTON TACT SWITCH 3.3.1 WORKING 3.4 EEPROM 24C02 | AT24C02 3.4.1 PIN DIAGRAM 3.4.2 PIN DESCRIPTION 3.5 16x2 LIQUID CRYSTAL DISPLAY 3.5.1 PIN DIAGRAM 3.5.2 PIN DESCRIPTION 3.5.3 LCD COMMAND CODES 3.6 RESISTORS 3.6.1 TYPES OF RESISTORS 3.6.2 COLOUR CODING OF RESISTOR 3.7 CAPACITORS 3.7.1 TYPES OF CAPACITORS 3.8 TRANSFORMER 3.9 VOLTAGE REGULATOR 3.9.1 7805 VOLTAGE REGULATOR IC

3.9.2 ADVANTAGES OF 7805 IC 3.10 CENTER TAP FULL WAVE RECTIFIER 3.11 IN4007 DIODE 3.12 CRYSTAL OSCILLATOR 3.12.1 OPERATION 4 INTERFACING WITH MICROCONTROLLER 4.1 INTERFACING OF LCD. 4.2 INTERFACING OF SWITCHES 4.3 INTERFACING OF RESET SWITCH 4.4 INTERFACING OF CRYSTAL OSCILLATOR 4.5. INTERFACING OF OUTPUT LED 15

PROGRAMMING THE MICRO CONTROLLER 5.1 KEIL SOFTWARE 5.2 PROGRAMMING AT89S52 IN DIGITAL LOCK SYSTEM

61 65 65

6.

BIBLIOGRAPHY

89

10

CHAPTER 1 INTRODUCTION

11

An embedded system is a computer system designed for specific control functions within a larger system often with real-time computing constraints. It is a combination of software and hardware to perform a dedicated task. Basically an embedded system is a computer, designed for specific control functions within a large system like traffic lights, factory controllers, MP3 players etc. Embedded systems contain processing cores that are typically either microcontrollers or digital signal processors (DSP). The key characteristic, however, is being dedicated to handle a particular task. 1.1 CHARACTERISTICS OF AN EMBEDDED SYSTEM 1. Embedded systems are designed to do some specific task, rather than be a general-purpose computer for multiple tasks. Some also have real-time performance constraints that must be met, for reasons such as safety and usability; others may have low or no performance requirements, allowing the system hardware to be simplified to reduce costs. 2. Embedded systems are not always standalone devices. Many embedded systems consist of small, computerized parts within a larger device that serves a more general purpose. For example, an embedded system in an automobile provides a specific function as a subsystem of the car itself. 3. The program instructions written for embedded systems are referred to as firmware, and are stored in read-only memory or Flash memory chips. They run with limited computer hardware resources: little memory, small or non-existent keyboard and/or screen. In this project, an embedded system is designed to provide security to homes, offices by developing a digital door lock system. Some of the components used in this project given below which are described in detail in chapter 3.

12

1.2 COMPONENTS REQUIRED Microcontroller AT89S52 LCD 16X2 LED Capacitors Resistors Push button tact switches Transformer Crystal oscillator EEPROM Voltage regulator Diode PCB Soldering Iron Connecting Wires

13

CHAPTER 2 DESIGN AND DEVELOPMENT OF PASSWORD BASED SECURITY DOOR LOCK SYSTEM

14

2.1 Work Approach


Aim of this project is to develop a digital lock in which the security is provided by means of passwords. If the password is correct then the door will open otherwise it remains close. To implement this project the main component is microcontroller. Here we are using Microcontroller AT89s52 because of its specific features like 8 kilo bytes of in system programmable memory, three level program memory lock, 256 bytes of internal RAM, low cost etc. To enter the password push button tact switches are used. Nine switches are used for numeric digits from 0-9 and two for E and M buttons. M stands for Mode. It is use to switch between user mode and master mode. Whereas, E stands for Enter button. To display the result and the password a 16X2 LCD is used. It displays the password in the form of asterisk (*). It also displays the result whether the password entered is correct or not. These components need sufficient amount of power supply to work efficiently. Microcontroller AT89S52 and LCD need a power supply of 5v.Here the power supply section is consists of step down transformer which convert 220 v to 9v,rectifier to convert AC supply to DC, regulator to further step down the voltage to 5v and capacitor for smoothing of the output voltage If the password entered is correct LED glows for predefined amount of time already stored in the Microcontroller. The circuit diagram showing the interfacing between these components is shown in figure 2.1

15

Fig 2.1: Circuit diagram of PASSWORD BASED SECURITY DOOR LOCK SYSTEM

16

CHAPTER 3 IMPLEMENTATION AND SELECTION OF COMPONENTS

17

3.1 MICROCONTROLLER AT89S52 Microprocessors and microcontrollers are widely used in embedded systems products. Microcontroller is a programmable device. A microcontroller has a CPU in addition to a fixed amount of RAM, ROM, I/O ports and a timer embedded all on a single chip. The fixed amount of on-chip ROM, RAM and number of I/O ports in microcontrollers makes them ideal for many applications in which cost and space are critical. Microcontroller part can be found in all electronics devices. Microcontroller can be found in devices which are used in home like microwave oven, automatic brake systems, etc. Microcontroller helps in doing job easily and safely.

3.1.1 FEATURES
Compatible with MCS-51 Products 8K Bytes of In-System Programmable (ISP) Flash Memory 4.0V to 5.5V Operating Range Fully Static Operation: 0 Hz to 33 MHz Three-level Program Memory Lock 256 x 8-bit Internal RAM 32 Programmable I/O Lines Three 16-bit Timer/Counters Eight Interrupt Sources Full Duplex UART Serial Channel Low-power Idle and Power-down Modes Watchdog Timer Dual Data Pointer Fast Programming Time Flexible ISP Programming (Byte and Page Mode)

18

3.1.2 DESCRIPTION
The Microcontroller AT89S52 (shown in Fig 3.1.1) is a low-power, highperformance CMOS 8-bit microcontroller with 8K bytes of in-system programmable Flash memory. The device is manufactured using Atmels highdensity non-volatile memory technology and is compatible with the industrystandard 80C51 instruction set and pin out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional non-volatile memory programmer. By combining a versatile 8-bit CPU with in-system programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller which provides a highly-flexible and cost-effective solution to many embedded control applications. The AT89S52 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning. The Power-down mode saves the RAM con-tents but freezes the oscillator, disabling all other chip functions until the next interrupt or hardware reset.

Fig 3.1.1: MICROCONTROLLER AT89S52

19

3.1.3 PIN CONFIGURATION

Fig 3.1.2: Pin Configuration of AT89S52 3.1.4 PIN DESCRIPTION VCC: Supply voltage GND: Ground Port 0: Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high-impedance inputs. External pull-ups are required during program verification. Port 1: Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the internal pull-ups and can be used as inputs. Port 1 also receives the low-order address bytes during Flash programming and verification. Table shows the alternate functions performed by port 1 as timer/counter

20

Table 3.1.1: Alternate functions of Port 1 Port 2: Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the internal pull-ups and can be used as inputs. Port 2 also receives the high-order address bits and some control signals during Flash programming and verification. Port 3: Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the internal pull-ups and can be used as inputs. Port 3 also serves the functions of various special features of the AT89S52, as shown in the following table.

Table 3.1.2: Alternate functions of Port 3 RST: Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. This pin drives high for 98 oscillator periods after the Watchdog times out.

21

ALE/PROG: Address Latch Enable (ALE) is an output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming. PSEN: Program Store Enable (PSEN) is the read strobe to external program memory. When the AT89S52 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory. EA/VPP: External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming. XTAL1: Input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL2: Output from the inverting oscillator amplifier. 3.2 LIGHT EMITTING DIODE (LED) A light-emitting diode (LED) is a semiconductor light source. LEDs are used as indicator lamps in many devices and are increasingly used for other lighting. When a light-emitting diode is forward-biased (switched on), electrons are able to recombine with electron holes within the device, releasing energy in the form of photons Fig 3.2.1 shows symbol of an LED. This effect is called electroluminescence and the color of the light (corresponding to the energy of the photon) is determined by the energy gap of the semiconductor. LEDs are often small in area (less than 1 mm2), and integrated optical components may be used to shape its radiation pattern. LEDs present many advantages over incandescent
22

light sources including lower energy consumption, longer lifetime, improved robustness, smaller size, and faster switching. LEDs powerful enough for room lighting are relatively expensive and require more precise current and heat management than compact fluorescent lamp sources of comparable output. Fig 3.2.2 shows different parts of an LED. .

Fig 3.2.1: Symbol of an LED

Fig 3.2.2: Parts of an LED 3.2.1 WORKING The LED consists of a chip of semiconducting material doped with impurities to create a p-n junction. As in other diodes, current flows easily from the p-side, or anode, to the n-side, or cathode, but not in the reverse direction. Charge carriers, electrons and holes flow into the junction from electrodes with different voltages. When an electron meets a hole, it falls into a lower energy level, and releases energy in the form of a photon as shown in fig 3.2.3. The wavelength of the light emitted, and thus its color depends on the band gap energy of the materials forming the p-n junction. In silicon or germanium di23

odes, the electrons and holes recombine by a non-radioactive transition, which produces no optical emission, because these are indirect band gap materials.

Fig 3.2.3: Recombination in an LED 3.2.2 ADVANTAGES OF LED: Efficiency: LEDs produce more light per watt than incandescent bulbs; this is useful in battery powered or energy-saving devices. Colour: LEDs can emit light of an intended colour without the use of colour filters that traditional lighting methods require. This is more efficient and can lower initial costs. Size: LEDs can be very small (>2 mm2) and are easily populated onto printed circuit boards. 3.2.3 DISADVANTAGES OF LED: Temperature Dependence: LEDs performance largely depends on the ambient temperature of the operating environment. LEDs must be supplied with the correct current. 3.3 PUSH BUTTON TACT SWITCH A pushbutton tact switch is a simple switch mechanism which permits user generated changes in the state of a circuit. It is a type of switch that is only ON

24

when the button is pressed as shown in Fig 3.3.1. As soon the button is released, the circuit breaks. It can be thought as keys on a keyboard.

Fig 3.3.1: Variants of Push Button Tact Switch 3.3.1 WORKING As shown in fig 3.3.2, the switch has four pins which are linked in pairs by internal metal strips. Pressing the button bridges the contacts and closes the switch. The extra pins are useful in designing printed circuit boards for keyboard input and also stop the switch from being moved about or bent once soldered into position.

Fig 3.3.2: Working of Push Button Tact Switch 3.4 EEPROM 24C02 | AT24C02 AT24C02 is an electrically erasable and programmable ROM. It has a 2Kbits of memory size arranged in 32 pages of 8 byte each. There are 256 (32 x 8) words each of one byte.

25

3.4.1 PIN DIAGRAM Fig 3.4.1 shows the Pin Diagram of AT24C02. The data is transferred and received serially through serial data (SDA) pin. The SCL is clock input and is used to synchronize EEPROM with microcontroller for various operations. When data is to be read or write, first a start condition is created followed by device address, byte address and the data itself. Finally a stop condition is provided. The start condition occurs when SDA and SCL get high to low simultaneously. The stop condition is when SDA remains low while SCL goes from high to low. The data is read or written between the start and stop conditions on every transition of SCL from high to low.

Fig 3.4.1: Pin Diagram of AT24C02 3.4.2 PIN DESCRIPTION TABLE 3.4.1: Pin Description of AT24C02 Pin No 1 2 3 4 Function Address input pins; Provide addresses when more than one EEPROM is interfaced to a single microcontroller; Ground when only one EEPROM is used Ground (0V) Ground AD0 AD1 AD2 Name

26

5 6 7

Bi-directional pin for serial data transfer Provides clock signals Ground allows normal read/write functions; Vcc enables write protection

Serial Data Serial Clock Write protect

Supply voltage; 5V (up to 5.5V)

Vcc

3.5 16x2 LIQUID CRYSTAL DISPLAY


A liquid crystal display (LCD) is a flat panel display, electronic visual display, or video display that uses the light modulating properties of liquid crystals (LCs). LCs does not emit light directly. LCs are used in a wide range of applications, including computer monitors, television, instrument panels, aircraft cockpit displays, signage, etc. They are common in consumer devices such as video players, gaming devices, clocks, watches, calculators, and telephones. LCDs have replaced cathode ray tube (CRT) displays in most applications. They are available in a wider range of screen sizes than CRT and plasma displays, and since they do not use phosphors, they cannot suffer image burn-in. Fig 3.5.1 shows a 16 Character x 2 Line LCD. Each pixel of an LCD typically consists of a layer of molecules aligned between two transparent electrodes, and two polarizing filters, the axes of transmission of which are (in most of the cases) perpendicular to each other. With no actual liquid crystal between the polarizing filters, light passing through the first filter would be blocked by the second (crossed) polarizer.

Fig 3.5.1: 16X2 LCD

27

3.5.1 PIN DIAGRAM

Fig 3.5.2: Pin diagram of 16x2 LCD

3.5.2 PIN DESCRIPTION PIN 1 2 3 4 SYMBOL VSS VCC VEE RS I/O ---I DESCRIPTION Ground +5V power supply Power supply to control contrast RS=0 to select command register RS=1 to select data register 5 R/W I R/W=0 for write R/W=1 for read 6 7 8 9 10 11 12 13 EN DB0 DB1 DB2 DB3 DB4 DB5 DB6 I/O I/O I/O I/O I/O I/O I/O I/O Enable The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus

28

14

DB7

I/O

The 8-bit data bus

Table 3.5.1: Pin description of 16x2 VCC, VSS and VEE: While VCC and VSS provide with +5V and ground respectively, VEE is used for controlling LCD contrast. RS (REGISTER SELECT): There are two important registers inside the LCD. When RS is low (0), the data is to be treated as a command or special instruction (such as clear screen, position). When RS is high (1), the data that is sent is a text data which should be displayed on the screen. For example, to display the letter "T" on the screen RS should be set high. RW (READ/WRITE): The RW line is the "Read/Write" control line. When RW is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read command. All others are write commands, so RW will almost be low. EN (ENABLE): The EN line is called "Enable". This control line is used to tell the LCD that data is being sent. To send data to the LCD, first set this line high (1) and then set the other two control lines and/or put data on the data bus. D0-D7 (DATA LINES): The 8-bit data pins, D0-D7 are used to send information to the LCD or read the content of the LCDs internal registers. To display letters and numbers, ASCII codes for the letters A-Z, a-z and numbers 0-9 are sent to these pins while making RS=1. There are also instruction command codes that can be sent to the LCD to clear the display or force the cursor to the home position or blink the cursor.
29

3.5.3 LCD COMMAND CODES: CODE (HEX) 1 2 4 6 5 7 8 A C E F 10 14 18 1C 80 C0 38 COMMAND TO LCD INSTRUCTION REGISTER CLEAR DISPLAY SCREEN RETURN HOME DECREMENT CURSOR(SHIFT CURSOR TO LEFT) INCREMENT CURSOR(SHIFT CURSOR TO RIGHT) SHIFT DISPLAY RIGHT SHIFT DISPLAY LEFT DISPLAY OFF,CURSOR OFF DISPLAY OFF,CURSOR ON DISPLAY ON,CURSOR OFF DISPLAY ON CURSOR BLINKING DISPLAY ON CURSOR BLINKING SHIFT CURSOR POSITION TO LEFT SHIFT CURSOR POSITION TO RIGHT SHIFT THE ENTIRE DISPLAY TO THE LEFT SHIFT THE ENTIRE DISPLAY TO THE RIGHT FORCE CURSOR TO BEGINNING OF 1ST LINE FORCE CURSOR TO BEGINNING OF 2ND LINE 2 LINES AND 5x7 MATRIX Table 3.5.2: LCD command codes 3.6 RESISTORS A linear resistor is a linear, passive two terminal electrical component that implements electrical resistance as a circuit element. The current through a resistor is in direct proportion to the voltage across the resistor's terminals. Resistors are common elements of electrical networks and electronic circuits and are ubiqui-

30

tous in most electronic equipment. The electrical functionality of a resistor is specified by its resistance: common commercial resistors are manufactured over a range of more than nine orders of magnitude. When specifying that resistance in an electronic design, the required precision of the resistance may require attention to the manufacturing tolerance of the chosen resistor, according to its specific application. The temperature coefficient of the resistance may also be of concern in some precision applications. 3.6.1 TYPES OF RESISTORS There are various types of resistors available in the market according to the requirement. From operating conditions point of view, resistors can be classified into two. Fig 3.6.1 shows some of these resistors. 1) Fixed resistors 2) Adjustable/ variable resistors 1) Fixed resistors are further classified into: a) Carbon composition type resistors b) Metalized type resistors c) Wire wound type resistors a) Carbon composition type resistors: This is the most common type of low wattage resistor. The resistive material is of carbon-clay composition and the leads are made of tinned copper. These resistors are cheap and reliable and stability is high. b) Wire wound resistors: These resistors are a length of wire wound an insulating cylindrical core. Usually wires of material such as constantan (60% copper and 40% nickel) and man31

ganin which have high resistivity and low temperature coefficients are employed. The completed wire wound resistor is coated with an insulating material such as baked enamel. c) Metalized resistors It is constructed using film deposition techniques of depositing a thick film of resistive material onto an insulating substrate. Only approximate value of resistance can be had by this method. 2) Variable resistors For circuits requiring a resistance that can be adjusted while it remains connected in the circuit (for e.g.: volume control on radio), variable resistors are required. They usually have 3 lead two fixed and one movable. Variable resistors are often called potentiometers, or for short, because one very common use for them is adjustable voltage divider.

Fig 3.6.1: Types of resistors

32

3.6.2 COLOUR CODING OF RESISTOR

Fig 3.6.2: Colour coding of resistor 3.7 CAPACITORS A capacitor (formerly known as condenser) is a passive two-terminal electrical component used to store energy in an electric field. The forms of practical capacitors vary widely, but all contain at least two electrical conductors separated by a dielectric (insulator). When there is a potential difference (voltage) across the conductors, a static electric field develops across the dielectric, causing positive charge to collect on one plate and negative charge on the other plate. Energy is stored in the electrostatic field. An ideal capacitor is characterized by a single constant value, capacitance, measured in farads. Capacitors are widely used in electronic circuits for blocking direct current while allowing alternating current to pass, in filter networks, for smoothing the output of power supplies, in the resonant circuits that tune radios to particular frequencies and for many other purposes. 3.7.1 TYPES OF CAPACITORS
33

Although all capacitors work in essentially the same way, key difference in the construction of different capacitor types makes an enormous difference in their properties. The main element of the capacitor that gives rise to the different properties of the different types of capacitor is the dielectric - the material between the two plates. Its dielectric constant will alter the level of capacitance that can be achieved within a certain volume. Some of the major types are outlined below: Ceramic capacitor: The ceramic capacitor is a type of capacitor that is used in many applications from audio to RF. Values range from a few picofarads to around 0.1 microfarads. Ceramic capacitor is shown in the adjacent figure.

Fig 3.7.1: Ceramic Capacitor Electrolytic capacitor: Electrolytic capacitors are a type of capacitor that is polarised. They are able to offer high capacitance values typically above 1F, and are most widely used for low frequency applications are power supplies, decoupling and audio coupling applications as they have a frequency limit if around 100 kHz.

Fig 3.7.2: Electrolytic Capacitor


34

3.8 TRANSFORMER A transformer is a device that transfers electrical energy from one circuit to another through inductively coupled conductorsthe transformer's coils. A varying current in the first or primary winding creates a varying magnetic flux in the transformer's core and thus a varying magnetic field through the secondary winding. This varying magnetic field induces a varying electromotive force (EMF), or "voltage", in the secondary winding. This effect is called inductive coupling. If a load is connected to the secondary, current will flow in the secondary winding and electrical energy will be transferred from the primary circuit through the transformer to the load. In an ideal transformer, the induced voltage in the secondary winding (Vs) is in proportion to the primary voltage (Vp), and is given by the ratio of the number of turns in the secondary (Ns) to the number of turns in the primary (Np) as follows:

By appropriate selection of the ratio of turns, a transformer thus enables an alternating current (AC) voltage to be "stepped up" by making Ns greater than Np, or "stepped down" by making Ns less than Np. Fig 3.8.1 shows a step down transformer 9-0-9 which is used to step down from 220V to 9V.Its current rating is 750 ma.

35

Fig 3.8.1(a): Step Down Transformer 3.9 VOLTAGE REGULATOR

(b):9-0-9 Step Down Transformer

A voltage regulator is an electrical regulator designed to automatically maintain a constant voltage level. A voltage regulator may be a simple "feed-forward" design or may include negative feedback control loops. It may use an electromechanical mechanism, or electronic components. Depending on the design, it may be used to regulate one or more AC or DC voltages. Electronic voltage regulators are found in devices such as computer power supplies where they stabilize the DC voltages used by the processor and other elements. In automobile alternators and central power station generator plants, voltage regulators control the output of the plant. In an electric power distribution system, voltage regulators may be installed at a substation or along distribution lines so that all customers receive steady voltage independent of how much power is drawn from the line 3.9.1 7805 VOLTAGE REGULATOR IC The 7805 voltage regulator employs built-in current limiting, thermal shutdown, and safe-operating area protection which make it virtually immune to damage from output overloads. 7805 is a three-terminal positive voltage regulator as shown in fig 3.9.1.With adequate heat sinking, it can deliver in excess of 0.5A output current. Typical applications would include local (on-card) regula-

36

tors which can eliminate the noise and degraded performance associated with single-point regulation.

Fig 3.9.1: 7805 IC 3.9.2 ADVANTAGES OF 7805 IC The 7805 series has several key advantages over many other voltage regulator circuits which have resulted in its popularity: 7805 series ICs do not require any additional components to provide a constant, regulated source of power, making them easy to use, as well as economical, and also efficient uses of circuit board real estate. By contrast, most other voltage regulators require several additional components to set the output voltage level, or to assist in the regulation process. Some other designs (such as a switching power supply) can require not only a large number of components but also substantial engineering expertise to implement correctly as well. 7805 series ICs have built-in protection against a circuit drawing too much power. They also have protection against overheating and shortcircuits, making them quite robust in most applications. In some cases, the current-limiting features of the 7805 devices can provide protection not only for the 7805 itself, but also for other parts of the circuit it is used in, preventing other component from being damaged as well.

37

3.10 CENTER TAP FULL WAVE RECTIFIER A rectifier is an electrical device that converts alternating current (AC), which periodically reverses direction, to direct current (DC), which flows in only one direction. The process is known as rectification. A full-wave rectifier (as shown in fig 3.10.1) converts the whole of the input waveform to one of constant polarity (positive or negative) at its output. Fullwave rectification converts both polarities of the input waveform to DC (direct current), and is more efficient. For single-phase AC, if the transformer is center-tapped, then two diodes backto-back (i.e. anodes-to-anode or cathode-to-cathode) can form a full-wave rectifier. Twice as many windings are required on the transformer secondary to obtain the same output voltage compared to the bridge rectifier above. This rectifier circuit is called full-wave because it makes use of the entire waveform, both positive and negative half-cycles, of the AC source voltage in powering the DC load. As a result, there is less "ripple" voltage seen at the load. The RMS (RootMean-Square) value of the rectifier's output is also greater for this circuit than for the half-wave rectifier.

Fig 3.10.1: Full Wave Rectification 3.11 IN4007 DIODE Generally IN4007 diode is used in full wave rectifier because of following specification given below:

38

1)Low forward voltage drop 2)High surge current capacity 3)High stability 4)Comply with RoHS 5)High quality and competitive price These diodes are used to convert AC into DC. These are used as half wave rectifier or full wave rectifier. Three points must he kept in mind while using any type of diode. 1.) Maximum forward current capacity 2.) Maximum reverse voltage capacity 3.) Maximum forward voltage capacity awesome The number and voltage capacity of some of the important diodes available in the market are as follows: Diodes of number IN4001, IN4002, IN4003, IN4004, IN4005, IN4006 and IN4007 have maximum reverse bias voltage capacity of 50V and maximum forward current capacity of 1 Amp. Diode of same capacities can be used in place of one another. Besides this, diode of more capacity can be used in place of diode of low capacity but diode of low capacity cannot be used in place of diode of high capacity. For example, in place of IN4002; IN4001 or IN4007 can be used but IN4001 or IN4002 cannot be used in place of IN4007.The diode BY125made by company BEL is equivalent of diode from IN4001 to IN4003. BY 126 is equivalent to diodes IN4004 to 4006 and BY 127 is equivalent to diode IN4007. IN4007 diode is shown in the adjacent figure.

39

Fig 3.11.1: IN4007 DIODE One disadvantage of this full-wave rectifier design is the necessity of a transformer with a center-tapped secondary winding. If the circuit in question is one of high power, the size and expense of a suitable transformer is significant. Consequently, the center-tap rectifier design is seen only in low-power applications. 3.12 CRYSTAL OSCILLATOR A crystal oscillator is an electronic oscillator circuit that uses the mechanical resonance of a vibrating crystal of piezoelectric material to create an electrical signal with a very precise frequency. This frequency is commonly used to keep track of time (as in quartz wristwatches), to provide a stable clock signal for digital integrated circuits, and to stabilize frequencies for radio transmitters and receivers. The most common type of piezoelectric resonator used is the quartz crystal, so oscillator circuits designed around them became known as "crystal oscillators." 3.12.1 OPERATION A crystal is a solid in which the constituent atoms, molecules, or ions are packed in a regularly ordered, repeating pattern extending in all three spatial dimensions. Almost any object made of an elastic material could be used like a crystal, with appropriate transducers, since all objects have natural resonant frequencies of
40

vibration. For example, steel is very elastic and has a high speed of sound. It was often used in mechanical filters before quartz. The resonant frequency depends on size, shape, elasticity, and the speed of sound in the material. Highfrequency crystals are typically cut in the shape of a simple, rectangular plate. Low-frequency crystals, such as those used in digital watches, are typically cut in the shape of a tuning fork. For applications not needing very precise timing, a low-cost ceramic resonator is often used in place of a quartz crystal. When a crystal of quartz is properly cut and mounted, it can be made to distort in an electric field by applying a voltage to an electrode near or on the crystal. This property is known as piezoelectricity. When the field is removed, the quartz will generate an electric field as it returns to its previous shape, and this can generate a voltage. The result is that a quartz crystal behaves like a circuit composed of an inductor, capacitor and resistor, with a precise resonant frequency. Quartz has the further advantage that its elastic constants and its size change in such a way that the frequency dependence on temperature can be very low. The specific characteristics will depend on the mode of vibration and the angle at which the quartz is cut (relative to its crystallographic axes).Therefore, the resonant frequency of the plate, which depends on its size, will not change much, either. This means that a quartz clock, filter or oscillator will remain accurate. For critical applications the quartz oscillator is mounted in a temperature-controlled container, called a crystal oven, and can also be mounted on shock absorbers to prevent perturbation by external mechanical vibrations. The equivalent circuit for the quartz crystal shows an RLC series circuit, which represents the mechanical vibrations of the crystal, in parallel with a capacitance, Cp which represents the electrical connections to the crystal. Quartz crystal oscillators operate at "parallel resonance", and the equivalent impedance of
41

the crystal has a series resonance where Cs resonates with inductance, L and a parallel resonance where L resonates with the series combination of Cs and Cp as shown below in Fig 3.12.1.

Fig 3.12.1: Equivalent circuit of crystal oscillator

42

CHAPTER-4 INTERFACING WITH MICROCONTROLLER

43

Interfacing basically means connection of different component to form a complete system. In this project following components are interfaced with micro controller: 16X2 LCD Push button switches Reset switch of microcontroller Crystal oscillator An overall interfacing of microcontroller with different component is shown below

INPUT 12 PUSH BUTTON TACT SWITCHES

MICROCONTROLLER AT89S52

OUTPUT 16X2 LCD,LED

POWER SUPPLY 5V

Fig 4.1: Interfacing of Microcontroller 4.1 INTERFACING WITH LCD.

As described above 2X16 LCD display has been used, with 16 pins and each pin having a particular function. Fig. 4.1.1 shows the 16X2 LCD display with 16 pins.

LCD 16X2

Fig 4.1.1: 16X2 LCD display


44

For interfacing 16X2 LCD display with microcontroller, port 0 and port 2 of the microcontroller is used. Pin 0.0 to pin 0.7 is connected to data lines i.e. pin 7 to pin 14 of the LCD display with pull up registers. P2.7 is connected to the enable pin of the circuit. P2.5 is connected to the RS pin of the LCD.

P2.6 is connected to the R/w pin of the LCD. LCD interfacing with AT89s52 microcontroller is shown in Fig 4.1.2. Last two pins of the LCD are connected to the back light. Some time these are internally connected and some time these are connected by the power supply.

LCD 16X2

Fig 4.1.2: INTERFACING OF AT89s52 WITH 16X2 LCD DISPLAY.

45

4.2 INTERFACING OF SWITCHES As described above, 12 push button tact switches have been used, each having 2 legs. To interface it with microcontroller one leg of all the switches is connected to ground and the other leg is connected to microcontroller i.e. pins of port1 and port 3 as shown in the Fig 4.2.1. The 12 I/O pins of the microcontroller are made normally high,; when a switch is press a low appears at the pin. This makes the microcontroller to detect that a switch has been pressed.

Fig 4.2.1: Interfacing of switches 4.3 INTERFACING OF RESET SWITCH: Pin 9 of the microcontroller is connected to the reset circuit. Reset circuit consists of a resistor, switch and a capacitor as shown in Fig.4.3.1 When power supply is given to the AT89s52 microcontroller, it doesnt start. So to ON the microcontroller, it needs to be reset. Resetting of microcontroller requires giving logic 1 to the reset pin for at least 2 clock pulses.

46

When power supply is given to the circuit, it makes the capacitor to charge. On pressing the reset switch current follows through the alternative path via the switch and makes pin 9 high in addition to this capacitor also discharges with the help of resistor and help in making the pin 9 high.

P9

AT89s52

Fig 4.3.1. INTERFACING MICROCONTROLLER WITH RESET SWITCH.

4.4 INTERFACING OFCRYSTAL OSCILLATOR To interface crystal oscillator with the microcontroller Pin no 18 and 19 is connected to external crystal oscillator to provide a clock to the circuit. Two capacitors of 33 pf are also applied to the crystal oscillator circuit as shown in Fig 4.4.1. to make it free from noise.

18

19

Fig. 4.4.1. INTERFACING OF CRYSTAL OSCILLATOR WITH MICROCONTROLLER


47

4.5. INTERFACING OF OUTPUT LED As described above LED has been used for output. For interfacing it with AT89s52 microcontroller pin no.21 is used as shown in Fig. 4.5.1. The voltage across the LED is very insensitive to (i.e., very close to constant with) the current through the device. This means that to a good approximation, we can model the LED as a constant voltage drop. If we want to model the LED's V-I characteristics more accurately, then we could do that as a series combination of an ideal diode and a resistor. The ideal diode has an exponential V-I characteristic; that is what is responsible for the non-linear part of the curve near 1.6 V. There is also an ohmic (i.e., linear relationship between V and I) resistance associated with the LED; the voltage dropped by that resistance is negligible at small currents, because V = IR is small when I is small, but becomes significant at higher currents.

AT89s52

P21

Fig.4.5.1 INTERFACING OF MICROCONTROLLER WITH O/P LED.


48

CHAPTER 5 PROGRAMMING OF MICROCONTROLLER

49

5.1 KEIL SOFTWARE As described above, keil software has been used for coding. Keil development tools for the 8051 Microcontroller Architecture support every level of software developer from the professional applications engineer to the student just learning about embedded software development. Keil was founded in 1982 by Gnter und Reinhard Keil, initially as a German GBR. In April 1985 the company was converted to Keil Elektronik GMBH to market add-on products for the development tools provided by many of the silicon vendors. Keil implemented the first C compiler designed from the ground-up specifically for the 8051 microcontroller. The industry-standard Keil C Compilers, Macro Assemblers, Debuggers, Real-time Kernels, Single-board Computers, and Emulators support all 8051 derivatives. The Keil 8051 Development Tools are designed to solve the complex problems facing embedded software developers. When starting a new project, simply select the AT89s52 microcontroller from the Device Database and the Vision IDE sets all compiler, assembler, linker, and memory options. The Keil Vision Debugger accurately simulates on-chip peripherals of microcontroller. Simulation helps in understanding hardware configurations and avoids time wasted on setup problems. Additionally, with simu-

50

lation, one can write and test applications before target hardware is available. To begin testing your software application with target hardware, use the MON51, MON390, MONADI, or FlashMON51 Target Monitors, the ISD51 In-System Debugger, or the ULINK USB-JTAG Adapter to download and test program code on the target system. The snap shot of keil vision 2 is shown in Fig.5.1.1.

Fig. 5.1.1: Keil snapshot 5. 5.2 PROGRAMMING AT89s52 IN DIGITAL LOCK SYSTEM.

51

/*HEADER FILES*/ #include<reg51.h> #include<string.h>

/*LCD PIN CONNECTIONS*/ #define lcd P0 sbit rs=P0^1; sbit en=P0^3;

/*LCD FUNCTIONS DECLARATIONS*/ void init_lcd(void); void cmd_lcd(unsigned char); void data_lcd(unsigned char); void str_lcd(unsigned char *); void Delay_ms(unsigned int);

/*KEYPAD PIN CONNECTIONS*/ sbit row0=P2^3; sbit row1=P2^5; sbit row2=P2^6; sbit row3=P2^0; sbit col0=P2^4; sbit col1=P2^2; sbit col2=P2^1;

/*MOTOR PIN CONNECTIONS*/ sbit M1=P1^0; sbit M2=P1^5;

sbit BUZZER=P1^2;
52

/*VARIABLES DECLARATION*/ unsigned char i,j; unsigned char colval,rowval,pwdchange;

unsigned char pwd[15],str1[]="12345";

unsigned char keypad[4][3]={'1','2','3', '4','5','6', '7','8','9', '*','0','#',};

/*PASSWORD FUNCTION DECLARATION*/ void password(void);

/*KEYPAD FUNCTION DECLARATION*/ unsigned char key(void);

/*MAIN FUNCTION*/ main() { unsigned char k=0; BUZZER=0; M1=M2=0;

init_lcd();

//LCD INITIALIZATION FUNCTION CALLING //DISPLAY STRING ON LCD

str_lcd("ENTER PASSWORD:"); while(1) { cmd_lcd(0xc0); password();

//2ND LINE DISPLAY //PASSWORD FUNCTION CALLING


53

if(pwdchange) { pwdchange=0; continue; } if(!strcmp(str1,pwd)) WORD { BUZZER=0; cmd_lcd(0xc0); str_lcd("DOOR OPEN"); //COMPARING WITH 1ST PASS-

M1=0; M2=1; Delay_ms(30); LAY cmd_lcd(0xc0); str_lcd(" M1=0; M2=0; "); //30 MILLISECONDS DE-

Delay_ms(1500);

cmd_lcd(0xc0); str_lcd("DOOR CLOSE");

M1=1; M2=0; Delay_ms(30); cmd_lcd(0xc0); str_lcd(" ");


54

M1=0; k=0;

M2=0;

} else {

strcpy(temp,pwd); cmd_lcd(0x01); str_lcd("Confirm Password"); cmd_lcd(0xc0); password(); if(!strcmp(temp,pwd)) { strcpy(str1,temp); cmd_lcd(0x01); str_lcd("PasswordChanged"); } Delay_ms(1000); cmd_lcd(0x01); str_lcd("Enter Pass word"); cmd_lcd(0xc0); pwdchange=1; return; } else { cmd_lcd(0x01); str_lcd("Password Error"); Delay_ms(1000); cmd_lcd(0x01);
55

str_lcd("Enter Password"); cmd_lcd(0xc0); pwdchange=1; return; } } Else { cmd_lcd(0x01); str_lcd("Password Error"); Delay_ms(1000); cmd_lcd(0x01); str_lcd("Enter Password"); cmd_lcd(0xc0); pwdchange=1; return; } } else goto label; } else goto label; } else { label:pwd[i++]=j; data_lcd('*'); } } pwd[i]='\0'; }

56

CHAPTER 6 BIBLIOGRAPHY

57

BIBLIOGRAPHY Reference Books 1. The 8051microcontroller and embedded systems: MUHAMMAD ALI MAZIDI, JANICE GILLISPIE MAZIDI 2. The 8051 microcontroller: KENNETH J. AYALA Website 1. www.8051projects.info 2. www.datasheets4u.com 3. www.8051.com 4. http://www.atmel.com 5. http://www.semiconductors.philips.com

Anda mungkin juga menyukai