home automation & security

49
A PROJECT REPORT ON HOME AUTOMATION & SECURITY” Submitted in partial fulfillment for the Award of degree of Bachelor of Technology (RAJASTHAN TECHNICAL UNIVERSITY, KOTA) IN Electronics & Communication Engineering Session (2014-2015) Submitted By: Guided By: RAHUL PUROHIT (11ECTEC040) Mrs. NEELAM SWAMI ROSHAN MANI (11ECTEC047) Assistant Professor CHHAVI SHARMA (11ECTEC012) (Dept. of ECE) HARSHITA GUPTA (11ECTEC020) DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING GOVT. COLLEGE OF ENGINEERING & TECHNOLOGY, BIKANER (An Autonomous Institute of Govt. of Rajasthan)

Upload: roshan-mani

Post on 06-Aug-2015

108 views

Category:

Engineering


2 download

TRANSCRIPT

A

PROJECT REPORT

ON

“HOME AUTOMATION & SECURITY”

Submitted in partial fulfillment for the Award of degree of

Bachelor of Technology

(RAJASTHAN TECHNICAL UNIVERSITY, KOTA)

IN

Electronics & Communication Engineering

Session (2014-2015)

Submitted By: Guided By:

RAHUL PUROHIT (11ECTEC040) Mrs. NEELAM SWAMI

ROSHAN MANI (11ECTEC047) Assistant Professor

CHHAVI SHARMA (11ECTEC012) (Dept. of ECE)

HARSHITA GUPTA (11ECTEC020)

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

GOVT. COLLEGE OF ENGINEERING & TECHNOLOGY,

BIKANER

(An Autonomous Institute of Govt. of Rajasthan)

GOVT. COLLEGE OF ENGINEERING & TECHNOLOGY, BIKANER

Session 2014-2015

CERTIFICATE

This is to certify that the project entitled “HOME AUTOMATION & SECURITY” has

been submitted to the Rajasthan Technical University, Kota in fulfillment of requirement for

the award of the degree of Bachelor of Technology in “Electronics & Communication

Engineering” by following students of final year B.Tech. (Electronics & Communication

Engineering).

RAHUL PUROHIT (11ECTEC040)

ROSHAN MANI (11ECTEC047)

CHHAVI SHARMA (11ECTEC012)

HARSHITA GUPTA (11ECTEC020)

Guide

Mrs. Neelam Swami Mr. ARVIND SIRVEE

(Assistant Professor, E.C.E. Dept.) (H.O.D., E.C.E. Dept.)

ACKNOWLEDGEMENT

We are thankful to “Mr. ARVIND SIRVEE” (H.O.D., Dept. Of ECE) and “Mrs. NEELAM

SWAMI” Mam for giving use valuable time, guidance and support to gain insights in making

the project. We wish to express our deep sense of gratitude especially to “Mr. SAKET

JANGID” to supervise us in our project. It was his understanding and help that stimulated us

during the moments of difficulties.

Last but not the least we are thankful to all the staff members of Department of Electronics and

Communication Engineering, Government College of Engineering & Technology, Bikaner.

PLACE:BIKANER RAHUL PUROHIT (11ECTEC040)

DATE: 12/05/2015 ROSHAN MANI (11ECTEC047)

CHHAVI SHARMA (11ECTEC012)

HARSHITA GUPTA (11ECTEC020)

INDEX

S.No. Topic Page No.

Certificate ii

Acknowledgement iii

Abstract

List of Figures

1. Project Overview 1-2

2. Circuit Components 3

2.1 Resistor 4

2.2 Diode 5-6

2.3 Potentiometer 6

2.4 Electrolytic Capacitor 7

2.5 Ceramic Capacitor 7-8

2.6 11.0592 MHz Crystal Oscillator 8-9

2.7 AT89C51 9

2.7.1 Description 10

2.7.2 AT89S52 Pin Description 11-19

2.8 78XX IC 20

2.8.1 7805 IC 20

2.8.2 7812 IC Voltage Regulator Circuit 21

2.9 LED 21

2.10 Relay 22

2.11 ULN2803 Relay Driver IC 22-24

2.12 LM324 IC (OP-AMP) 24-25

2.13 IR LED Tx & Rx 26

2.14 Transformer 26-27

2.15 7-Segment Display 27-29

2.16 Liquid Crystal Display 29-30

2.17 Printed Circuit Board 30

3. Circuit Design 31

4. Operation 32-33

5. Software 34-35

6. Applications 36

7. Limitations 37

8. Advantages 38

Conclusion 39

References 40

LIST OF FIGURES

1. Block Diagram 1

2. Circuit Diagram of Counter 2

3. Circuit Diagram of Security System 3

3. Resistor Color Coding 5

4. Diode 6

5. Potentiometer 6

6. Electrolytic Capacitor 7

7. Ceramic Capacitor 8

8. 11.0592 MHz Crystal Oscillator 8

9. Crystal oscillator Schematic 9

10. AT89C51 9

11. Pin Diagram & Architecture of AT89C51 10

12. ROM & RAM in 8051 Microcontroller 15

13. Some 8-bit registers & some 16-bit registers 17

14. AT89S52 19

15. AT89S52 Pin Description 19

16. 12V regulated power supply using 7812 21

17. LED 21

18. Relay Description 22

19. Relay 22

20. ULN2 803 23

21. Darlington Pair 23

22. LM324 IC 25

23. Line of Sight Tx-Rx Circuit 26

24. Transformer 27

25. Common Anode & Common Cathode 7-Segment Display 28

26. 0 to 9 on 7-Segment Display 29

27. LCD 29

28. Layout of Bidirectional Visitor Counter 31

29. Flow-Chart 32

30. Working Model of Home Security & Automation 33

31. Sensor Circuit & Counter 33

ABSTRACT

HOME AUTOMATION & SECURITY

The objective of this project is to make a Microcontroller based model to count number

of persons visiting particular room and accordingly light up the room and for security purpose

we are using microcontroller based Safe which will be accessible only to genuine user who

knows the correct password. The Project is made using Microcontroller AT89S52 that takes over

the task of controlling the room lights as well as counting number of persons/ visitors in the

room very accurately. The model will receive the signals from the sensors, and this signal will be

operated under the control of software which is stored in ROM.

Traditional lock systems using mechanical lock and key mechanism are being replaced

by new advanced techniques of locking system. These techniques are an integration of

mechanical and electronic devices and highly intelligent. One of the prominent features of these

innovative lock systems is their simplicity and high efficiency. Such an automatic lock system

consists of electronic control assembly which controls the output load through a password. This

output load can be a motor or a lamp or any other mechanical/electrical load. This system

demonstrates a password based door lock system wherein once the correct code or password is

entered, the door is opened and the concerned person is allowed access to the secured area.

Again if another person arrives it will ask to enter the password. If the password is wrong then

door would remain closed, denying the access to the person. In today’s world, there is a

continuous need for automatic appliances with the increase in standard of living, there is a sense

of urgency for developing circuits that would ease the complexity of life. Also if at all one wants

to know the number of people present in room so as not to have congestion, this circuit prove to

be helpful.

1

CHAPTER 1

PROJECT OVERVIEW

This Project “HOME AUTOMATION & SECURITY” using Microcontroller is a reliable circuit that takes over the task of controlling the room lights as well as counting number of persons/ visitors in the room very accurately. When somebody enters into the room then the counter is incremented by one and the light in the room will be switched ON and when any one leaves the room then the counter is decremented by one. The light will be only switched OFF until all the persons in the room go out. The total number of persons inside the room is also displayed on the seven segment displays.

The microcontroller does the above job. It receives the signals from the sensors, and this signal is operated under the control of software which is stored in ROM. Microcontroller AT89S52 continuously monitor the Infrared Receivers, When any object pass through the IR Receiver’s then the IR Rays falling on the receiver are

obstructed , this obstruction is sensed by the Microcontroller.

Fig. 1 Block Diagram

2

Fig. 2 Circuit Diagram of Counter

Automated security systems play an important role of providing an extra layer

of security through user authentication to prevent break-ins at entry points and also to

track illegal intrusions or unsolicited activities within the vicinity of the home

(indoors and outdoors). There has been much research done in the design of various

types of automated security systems. Sensor-based systems that rely on contact or

movement sensors or contact-based systems such as fingerprint and palm print scan or

keypad activation that require substantial amount of contact with an input device.

Many security systems are based on only a single system. In an event of system

failure or intrusion of the user authentication, there is no backup system to monitor

the home continually. This shortcoming can be dealt with using multiple security

systems (or multi-layered security systems). However, multi-system implementations

will definitely be more demanding in terms of computational cost and organization.

This requires careful integration and sharing of resources. Thus, a feasible system

should be effective, practical and reasonable in cost. In this paper, we proposed an

integrated dual-level sensor based home security system, consisting of two

subsystems – a IR sensors, burglar alarm module and fire alarm module. Both

subsystems work independently but are incorporated into a single automated system

for practical implementation.

3

Fig. 3 Circuit Diagram of Security System

4

CHAPTER 2

Circuit Components

• 5 Resistor of 330 ohms

• Diode

• 2 Variable Resistor of 20 Kohms

• 2 Variable Resistor of 50Kohms

• 2 Electrolytic Capacitor

• 4 Ceramic Capacitor 104

• 2 Ceramic Capacitor 33 pF

• 11.0592 MHz crystal Oscillator

• AT89S52

• 7805 7812

• 3 LED

• Reset Key

• 2 Relay

• ULN2803 Relay Driver IC

• LM324 IC

• IR LED

• IR Phototransistor

• Transformer

• 7 segment Display

5

2.1 RESISTOR

Resisitors restrict the flow of electric current, for example a resistor is placed

in series with a light emitting diode (LED) to limit the current passing through the

LED.

Fig. 3 Resistor Color Coding

2.2 Diode

A diode is a specialized electronic component with two electrodes called the

anode and the cathode. Most diodes are made with semiconductor materials such as

silicon, germanium, or selenium

6

Fig. 4 Diode

2.3 Potentiometer

A potentiometer informally a pot, is a three-terminal resistor with a sliding or rotating

contact that forms an adjustable voltage divider. If only two terminals are used, one

end and the wiper, it acts as a variable resistor or rheostat.

Fig. 5 Potentiometer

7

2.4 Electrolytic Capacitor

An electrolytic capacitor is a capacitor in which one electrode is made of a

special metal on which an oxide layer is formed. This thin oxide layer acts as the

dielectric of the capacitor. An electrolyte covers the surface of the oxide layer and

serves as the second electrode of the capacitor.

Fig. 6 Electrolytic Capacitors

2.5 Ceramic Capacitor

A ceramic capacitor is a fixed value capacitor in which ceramic material acts

as the dielectric. It is constructed of two or more alternating layers of ceramic and a

metal layer acting as the electrodes. The composition of the ceramic material defines

the electrical behavior and therefore applications.

8

Fig.7 Ceramic Capacitor

2.6 Crystal Oscillator of frequency 11.0592MHz

It provide clock pulses of 11.0592 Mhz frequency. It is a common clock for

Intel 8051 microprocessors It 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, 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 incorporating them became known as crystal oscillators. The

crystal oscillator circuit sustains oscillation by taking a voltage signal from the quartz

resonator, amplifying it, and feeding it back to the resonator. The rate of expansion

and contraction of the quartz is the resonant frequency, and is determined by the cut

and size of the crystal. When the energy of the generated output frequencies matches

the losses in the circuit, an oscillation can be sustained.

Fig.8 11.592 MHZ Oscillator

9

Fig.9 Crystal Oscillator Schematic

2. 7 AT89C51

Fig. 10 AT89C51

10

2.7. 1 Description

The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer

with 4K bytes of Flash Programmable and Erasable Read Only Memory (PEROM).

The device is manufactured using Atmel’s high density non-volatile memory

technology and is compatible with the industry standard MCS-51™ 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 Flash on a monolithic chip, the Atmel AT89C51 is a

powerful microcomputer which provides a highly flexible and cost effective solution

to many embedded control applications.

Fig. 11 Pin Diagram and Architecture of AT89C51

11

2.7.2 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.

Port 0 may also be configured to be the multiplexed low order address/data

bus during accesses to external program and data memory. In this mode P0 has

internal pull ups. Port 0 also receives the code bytes during Flash programming, and

outputs the code bytes during program verification. 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. As inputs, Port

1 pins that are externally being pulled low will source current (IIL) because of the

internal pull ups. Port 1 also receives the low-order address bytes low-order address

bytes during Flash programming and verification.

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. As inputs, Port

2 pins that are externally being pulled low will source current (IIL) because of the

internal pull ups. Port 2 emits the high-order address byte during fetches from external

program memory and during accesses to external data memory that use 16-bit

12

addresses (MOVX @DPTR). In this application it uses strong internal pull ups when

emitting 1s. During accesses to external data memory that use 8-bit addresses

(MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register. 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. As inputs, Port

3 pins that are externally being pulled low will source current (IIL) because of the pull

ups. Port 3 also serves the functions of various special features of the AT89C51 as

listed below:

Port Pin Alternate Functions

P3.0 RXD (serial input port)

P3.1 TXD (serial output port)

P3.2 INT0 (external interrupt 0)

P3.3 INT1 (external interrupt 1)

P3.4 T0 (timer 0 external input)

P3.5 T1 (timer 1 external input)

P3.6 WR (external data memory write

strobe)

P3.7 RD (external data memory read

strobe)

Port 3 also receives some control signals for Flash programming and

verification.

13

RST

Reset input. A high on this pin for two machine cycles while the oscillator is

running resets the device.

ALE/PROG

Address Latch Enable 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.

In normal operation ALE is emitted at a constant rate of 1/6 the oscillator

frequency, and may be used for external timing or clocking purposes. Note, however,

that one ALE pulse is skipped during each access to external Data Memory. If

desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With

the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the

pin is weakly pulled high. Setting the ALE-disable bit has no effect if the

microcontroller is in external execution mode.

PSEN

Program Store Enable is the read strobe to external program memory.

When the AT89C51 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.

14

EA should be strapped to VCC for internal program executions. This pin also

receives the 12-volt programming enable voltage (VPP) during Flash programming,

for parts that require 12-volt VPP.

XTAL1

Input to the inverting oscillator amplifier and input to the internal clock

operating circuit.

XTAL2

Output from the inverting oscillator amplifier.

MEMORY SPACE ALLOCATION

The 8051 has three very general types of memory. To effectively program the

8051 it is necessary to have a basic understanding of these memory types. The

memory types are illustrated in the following graphic. They are: On-Chip Memory,

External Code Memory, and External RAM.

Onchip ROM

The 89C51 has a 4K bytes of on-chip ROM. This 4K bytes ROM memory has

memory addresses of 0000 to 0FFFh. Program addresses higher than 0FFFh, which

exceed the internal ROM capacity will cause the microcontroller to automatically

fetch code bytes from external memory. Code bytes can also be fetched exclusively

from an external memory, addresses 0000h to FFFFh, by connecting the external

access pin to ground. The program counter doesn’t care where the code is: the circuit

designer decides whether the code is found totally in internal ROM, totally in external

ROM or in a combination of internal and external ROM.

Onchip RAM

The 1289 bytes of RAM inside the 8051 are assigned addresses 00 to 7Fh. These

128 bytes can be divided into three different groups as follows:

A total of 32 bytes from locations 00 to 1Fh are set aside for register banks and the

stack.

A total of 16 bytes from locations 20h to 2Fh are set aside for bit addressable

read/write memory and instructions. A total of 80 bytes from locations 30h to 7Fh are

15

used for read and write storage, or what is normally called a scratch pad. These 80

locations of RAM are widely used for the purpose of storing data and parameters by

8051 programmers.

Fig. 12 ROM & RAM in 8051 Microcontroller

External Code Memory

External Code Memory is code (or program) memory that resides off-chip. This is

often in the form of an external EPROM.

External RAM

External RAM is RAM memory that resides off-chip. This is often in the form of

standard static RAM or flash refers to any memory (Code, RAM, or other) that

physically exists on the microcontroller itself. On-chip memory can be of several

types, but we'll get into that shortly.

16

External RAM As an obvious opposite of Internal RAM, the 8051 also supports

what is called External RAM. As the name suggests, External RAM is any random

access memory which is found off-chip. Since the memory is off-chip it is not as

flexible in terms of accessing, and is also slower. For example, to increment an

Internal RAM location by 1 requires only 1 instruction and 1 instruction cycle. To

increment a 1-byte value stored in External RAM requires 4 instructions and 7

instruction cycles. In this case, external memory is 7 times slower

Code Memory

Code memory is the memory that holds the actual 8051 program that is to be run.

This memory is limited to 64K and comes in many shapes and sizes: Code memory

may be found on-chip, either burned into the microcontroller as ROM or EPROM.

Code may also be stored completely off-chip in an external ROM or, more

commonly, an external EPROM. Flash RAM is also another popular method of

storing a program. Various combinations of these memory types may also be used-

that is to say, it is possible to have 4K of code memory on-chip and 64k of code

memory off-chip in an EPROM.

Registers

In the CPU, registers are used to store information temporarily. That information

could be a byte of data to be processed, or an address pointing to the data to be

fetched. In the 8051 there us only one data type: 8 bits. With an 8- bit data type, any

data larger than 8 bits has to be broken into 8-bit chunks before it is processed.

The most commonly used registers of the 8051 are A(accumulator), B, R0, R1,

R2, R3, R4, R5, R6, R7, DPTR (data pointer) and PC (program counter). All the

above registers are 8-bit registers except DPTR and the program counter. The

accumulator A is used for all arithmetic and logic instructions.

17

Fig. 13 Some 8-bit registers & some 16-bit register

Program Counter and Data Pointer

The program counter is a 16- bit register and it points to the address of the next

instruction to be executed. As the CPU fetches op-code from the program ROM, the

program counter is incremented to point to the next instruction. Since the PC is 16 bit

wide, it can access program addresses 0000 to FFFFH, a total of 64K bytes of code.

However, not all the members of the 8051 have the entire 64K bytes of on-chip ROM

installed. The DPTR register is made up of two 8-bit registers, DPH and DPL, which

are used to furnish memory addresses for internal and external data access. The DPTR

is under the control of program instructions and can be specified by its name, DPTR.

DPTR does not have a single internal address, DPH and DPL are assigned an address

each.

Flag bits and the PSW Register

Like any other microprocessor, the 8051 have a flag register to indicate

arithmetic conditions such as the carry bit. The flag register in the 8051 is called the

program status word (PSW) register. The program status word (PSW) register is an

8-bit register. It is also referred as the flag register. Although the PSW register is 8-bit

wide, only 6 bits of it are used by the microcontroller. The two unused bits are user

definable flags. Four of the flags are conditional flags, meaning they indicate some

conditions that resulted after an instruction was executed. These four are CY (carry),

AC (auxiliary carry), P (parity), and OV (overflow). The bits of the PSW register are

shown below:

CY PSW.7 Carry flag

18

AC PSW.6 Auxiliary carry flag

-- PSW.5 Available to the user for general purpose

RS1 PSW.6 Register bank selector bit 1

RS0 PSW.3 Register bank selector bit 0

OV PSW.2 Overflow flag

F0 PSW.1 User definable bit

P PSW.0 Parity flag

CY, the carry flag

This flag is set whenever there is a carry out from the d7 bit. This flag bit is

affected after an 8-bit addition or subtraction. It can also be set to 1 or 0 directly by an

instruction such as “SETB C” and “CLR C” where “SETB C” stands for set bit carry

and “CLR C” for clear carry.

AC, the auxiliary carry flag

If there is carry from D3 to D4 during an ADD or SUB operation, this bit is

set,

otherwise cleared. This flag is used by instructions that perform BCD arithmetic.

P, the parity flag

The parity flag reflects the number of 1s in the accumulator register only. If the

register A contains an odd number of 1s, then P=1. Therefore, P=0 if A has an even

number of 1s.

OV, the overflow flag

This flag is set whenever the result of a signed number operation is too large,

causing the high order bit to overflow into the sign bit. In general the carry flags is

used to detect errors in unsigned arithmetic operations

19

Fig.14 AT89S52

Fig.15 AT89S52 Pin Description

20

2.8 78XX

The 78xx (sometimes L78xx, LM78xx, MC78xx...) is a family of self-

contained fixed linear voltage regulator integrated circuits. The 78xx family is

commonly used in electronic circuits requiring a regulated power supply due to their

ease-of use and low cost. For ICs within the family, the xx is replaced with two digits,

indicating the output voltage (for example, the 7805 has a 5 volt output, while the

7812 produces 12 volts). The 78xx line are positive voltage regulators: they produce a

voltage that is positive relative to a common ground. There is a related line of 79xx

devices which are complementary negative voltage regulators. 78xx and 79xx ICs can

be used in combination to provide positive and negative supply voltages in the same

circuit.

IC 7805 (Voltage Regulator IC)

7805 is a voltage regulator integrated circuit. It is a member of 78xx series of

fixed linear voltage regulator ICs. The voltage source in a circuit may have

fluctuations and would not give the fixed voltage output. The voltage regulator IC

maintains the output voltage at a constant value. The xx in 78xx indicates the fixed

output voltage it is designed to provide. 7805 provides +5V regulated power supply.

Capacitors of suitable values can be connected at input and output pins depending

upon the respective voltage levels.

Pin Description:

Pin No Function Name

1 Input voltage (5V-18V) Input

2 Ground (0V) Ground

3

Regulated output; 5V (4.8V-5.2V)

Output

21

Fig.16 12V Regulated Power Supply Using 7812

2.9 LED

A light-emitting diode (LED) is a two-lead semiconductor light source. It is a

basic pn-junction diode, which emits light when activated. When a suitable voltage is

applied to the leads, electrons are able to recombine with electron holes within the

device, releasing energy in the form of photons. This effect is called

electroluminescence, and the color of the light (corresponding to the energy of the

photon) is determined by the energy band gap of the semiconductor.

Fig.17 LED

22

2.10 Relay

A relay is an electrically operated switch. Many relays use an electromagnet to

mechanically operate a switch, but other operating principles are also used, such as

solid-state relays. Relays are used where it is necessary to control a circuit by a low-

power signal (with complete electrical isolation between control and controlled

circuits), or where several circuits must be controlled by one signal.

Fig.18 Relay description

Fig. 19 Relay

2.11 ULN2803

IC ULN2803 consists of octal high voltage, high current darlington transistor

arrays. The eight NPN Darlington connected transistors in this family of arrays are

ideally suited for interfacing between low logic level digital circuitry (such as TTL,

CMOS or PMOS/NMOS) and the higher current/voltage requirements of lamps,

relays, printer hammers or other similar loads for a broad range of computer,

industrial, and consumer applications. The ULN 2803 IC consists of eight NPN

Darlington connected transistors (often called a Darlington pair). Darlington pair

23

consists of two bipolar transistors such that the current amplified by the first is

amplified further by the second to get a high current gain β or hFE. The figure shown

below is one of the eight Darlington pairs of ULN 2803 IC.

Fig. 20 ULN2803

. Fig. 21 Darlington Pair

Now 2 cases arise:-

Case 1: When IN is 0 volts.

24

Q1 and Q2 both will not conduct as there is no base current provided to them.

Thus, nothing will appear at the output (OUT).

Case 2: When IN is 5 volts.

Input current will increase and both transistors Q1 and Q2 will begin to

conduct. Now, input current of Q2 is combination of input current and emitter current

of Q1, so Q2 will conduct more than Q1 resulting in higher current gain which is very

much required to meet the higher current requirements of devices like motors, relays

etc. Output current flows through Q2 providing a path (sink) to ground for the

external circuit that the output is applied to. Thus, when a 5V input is applied to any

of the input pins (1 to 8), output voltage at corresponding output pin (11 to 18) drops

down to zero providing GND for the external circuit. Thus, the external circuit gets

grounded at one end while it is provided +Vcc at its other end. So, the circuit gets

completed and starts operating.

2.12 LM324 IC

It is a 14pin IC consisting of four independent operational amplifiers (op-

amps) compensated in a single package. Op-amps are high gain electronic voltage

amplifier with differential input and, usually, a single-ended output. The output

voltage is many times higher than the voltage difference between input terminals of

an op-amp.

These op-amps are operated by a single power supply LM324 and need for a

dual supply is eliminated. They can be used as amplifiers, comparators, oscillators,

rectifiers etc. The conventional op-amp applications can be more easily implemented

with LM324.

25

Fig.22 LM 324 IC Pin Description:

Pin

No

Function Name

1 Output of 1st comparator Output 1

2 Inverting input of 1st comparator Input 1-

3 Non-inverting input of 1st comparator Input 1+

4 Supply voltage; 5V (up to 32V) Vcc

5 Non-inverting input of 2nd comparator Input 2+

6 Inverting input of 2nd comparator Input 2-

7 Output of 2nd comparator Output 2

8 Output of 3rd comparator Output 3

9 Inverting input of 3rd comparator Input 3-

10 Non-inverting input of 3rd comparator Input 3+

11 Ground (0V) Ground

12 Non-inverting input of 4th comparator Input 4+

13 Inverting input of 4th comparator Input 4-

14 Output of 4th comparator Output 4

26

Pin Description of LM 324 IC

2.13 IR LED TRANSMITTER & RECEIVER

An IR LED, also known as IR transmitter, is a special purpose LED that

transmits infrared rays in the range of 760 nm wavelength. Such LEDs are usually

made of gallium arsenide or aluminium gallium arsenide. They, along with IR

receivers, are commonly used as sensors. The appearance is same as a common LED.

Since the human eye cannot see the infrared radiations, it is not possible for a person

to identify whether the IR LED is working or not, unlike a common LED. To

overcome this problem, the camera on a cellphone can be used. The camera can show

us the IR rays being emanated from the IR LED in a circuit.

Fig. 23 Line of Sight Tx & Rx

2.14 Transformer

Transformers convert AC electricity from one voltage to another with little loss of

power. Transformers work only with AC and this is one of the reasons why mains

electricity is AC. The two types of transformers

Step-up transformers increase voltage, Step-down transformers reduce voltage.

Most power supplies use a step-down transformer to reduce the dangerously high

mains voltage (230V in UK) to a safer low voltage. The input coil is called the

primary and the output coil is called the secondary. There is no electrical connection

between the two coils, instead they are linked by an alternating magnetic field created

in the soft-iron core of the transformer. The two lines in the middle of the circuit

symbol represent the core.

27

Transformers waste very little power so the power out is (almost) equal to the

power in. Note that as voltage is stepped down current is stepped up. The ratio of the

number of turns on each coil, called the turns ratio, determines the ratio of the

voltages. A step-down transformer has a large number of turns on its primary (input)

coil which is connected to the high voltage mains supply, and a small number of turns

on its secondary (output) coil to give a low output voltage.

Fig. 24 Transformer

2.15 7-Segment Display

The LTS 542 is a 0.52 inch digit height single digit seven-segment display.

This device utilizes Hi-eff. Red LED chips, which are made from GaAsP on GaP

substrate, and has a red face.

28

Features:

• Common Anode

• 0.52 Inch Digit Height

• Continuous Uniform Segments

• Low power Requirement

• Excellent Characters Appearance

• High Brightness & High Contrast

• Wide Viewing Angle

Fig. 25 Common Cathode & Common Anode 7-Segment Display

29

2.16 LIQUID CRYSTAL DISPLAY (LCD)

Fig. 27 LCD

30

A liquid crystal display (LCD) is a thin, flat electronic visual display that

uses the light modulating properties of liquid crystals (LCs). LCs do not emit light

directly. They 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 displaced cathode ray tube (CRT) displays in

most applications. They are usually more compact, lightweight, portable, less

expensive, more reliable, and easier on the eyes. 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. LCDs are more energy efficient and offer safer

disposal than CRTs. Its low electrical power consumption enables it to be used in

battery-powered electronic equipment.

2.17 PRINTED CIRCUIT BOARD (PCB)

It is used to mechanically support and electrically connect Electrical

components using conductive pathways, tracks or signal traces etched from copper

sheets laminated onto a non-conductive substrate. It is also referred to as printed

wiring board (PWB) or etched wiring board. A PCB populated with electronic

components is a printed circuit assembly (PCA), also known as a printed circuit

board assembly (PCBA). Printed circuit boards are used in virtually all but the

simplest commercially-produced electronic devices. PCBs are inexpensive, and can

be highly reliable. They require much more layout effort and higher initial cost than

either wire wrap or point-to-point construction, but are much cheaper and faster for

high-volume production; the production and soldering of PCBs can be done by totally

automated equipment. Much of the electronics industry's PCB design, assembly, and

quality control needs are set by standards that are published by the IPC organization.

31

CHAPTER 3

CIRCUIT DESIGN

The heart of the circuit design lies in designing the microcontroller interface.

Here we use the microcontroller AT89S52. The microcontroller AT89S52 is

interfaced to the IR sensor pairs at two ports pins – P1.0 and P1.1 respectively. The 7

segment display is interfaced to the microcontroller at port P2.Another important

aspect of the design involves designing the oscillator circuit and the reset circuit. The

oscillator circuit is designed by selecting a 11.0592MHz quartz crystal and two

ceramic capacitors-each 33pF. The reset circuit is designed by selecting an electrolyte

capacitor of 10uF to ensure a reset pulse width of 100ms and reset pin voltage drop of

1.2V.The sensor circuit is designed by selecting appropriate value of resistors for both

the LED and the phototransistor.

Fig. 28 Layout of Bidirectional Visitor Counter & Home

Automation

32

CHAPTER 4

OPERATION

When the system is powered, the compiler initially initializes the stack pointer and all

other variables. It then scans the input ports (PortP1.0 first). In the meantime, when

there is no interruption between the IR LED and the phototransistor of the first sensor

pair, the output of the phototransistor is always at low voltage. In other words port

P1.0 is at logic low level. Now when a transition takes place, i.e. a logic high level is

received at port P1.0, the compiler sees this as an interruption to sense the passage of

a person or an object between the IR LED and the phototransistor. As per the

program, the count value is increased and this value is displayed on the Counter. Now

the compiler starts scanning the other input pinP1.1. Similar to the first sensor pair,

for this sensor pair also the phototransistor conducts in absence of any interruption

and P1.1 is at logic low level. In case of an interruption, the pin P1.1 goes high and

this interruption is perceived by decreasing the value of count.The program ensures

that the scanning of both the port pins is done at certain delays so as to avoid

confusion of reading. For instance port P1.0 is scanned for two or three interruptions

so as to ensure the count value is above 1 or 2.

4.1 FLOW CHART

Fig. 29 Flow Chart

33

Fig. 30 Working Model of Home Automation & Security

Fig. 31 Sensor Circuit & Counter

34

CHAPTER 5

SOFTWARE

#include<reg51.h>

#define seg P2

sbit s1=P1^0;

sbit s2=P1^1;

sbit r1=P1^2;

sbit r2=P1^3;

unsigned char a[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};

void main()

{

unsigned char z;

seg=a[0];

r1=r2=0;

while(1)

{

while(s1==1 && s2==1);

if(s1==0 && s2==1)

{

while(s1==0 && s2==1);

while(s1==1 && s2==1);

while(s1==1 && s2==0);

z++;

35

}

else if(s1==1 && s2==0)

{

while(s1==1 && s2==0);

while(s1==1 && s2==1);

while(s1==0 && s2==1);

z--;

}

seg=a[z];

if(z<=5)

{

r1=1;r2=0;

}

else if(z<=9)

{

r1=1;r2=1;

}

else

{

z=0;

seg=a[z];

}

}

}

36

CHAPTER 6

APPLICATIONS

1. This circuit can be used domestically to get an indication of number of persons

entering a party.

2. It can be used at official meetings.

3. It can be used at homes and other places to keep a check on the number of persons

entering a secured place.

4. It can also be used as home automation system to ensure energy saving by switching

on the loads and fans only when needed.

37

CHAPTER 7

LIMITATIONS

1. It is a theoretical circuit and may require few changes in practical implementation

2. It is a low range circuit and cannot be implemented at large areas.

3. More than one candidate should not enter or exit the room. If it happens it will count

it as a single person.

4. With frequent change in the count value, after a certain time the output may look

confusing

5. In this Module we are using a room having capacity of 9 candidates. So we are using

only one segment that can show from 0 to 9 only. For a large room we will use a no.

of segments. For example for 9999 candidate we will use 4 segments.

38

CHAPTER 8

ADVANTAGES

1. The Most advantage is that it will help to save electricity. When no one is there in

room the appliances will be off.

2. For School/colleges/companies it will help to check if somebody is there in the

zone or not. If the data on display unit is zero the peons or security guards can shut

the gate easily.

3. Whole system will work automatically so it reduces the human work.

39

CONCLUSION

In our project We have designed and implemented a Bi-Directional Counter &

Home Automation using the concept of Embedded System. The target users of the project

can be any one right from a common man to any organization. Lets say if any one uses

our project for Seminar Purpose then the track record of the persons attending the seminar

will give the exact idea about the no. of candidate attending and leaving the seminar and

accordingly the Project Model will control the Electronics Gadget of the Seminar Hall. In

making this project We all team mates have to really give our best and it was all possible

due to unmatched guidelines of our mentor “Mrs Neelam Swami”. We will be highly

obliged to you for this kind support.

40

BIBLIOGRAPHY

Reference Site:

[1] http://www.electronicshub.org/bidirectional-visitor-counter-using-8051-

microcontroller/

[2] http://en.wikipedia.org/wiki/Operational_amplifier

[3] http://www.ti.com/product/lm324

[4] http://www.instructables.com/id/8051-Microcontroller-based-Bidirectional-

Visitor-C/

[5] http://www.ti.com/lsds/ti/apps/automation/applications.page

[6] http://www.projectsof8051.com/password-based-door-locking-system/

[7] http://store.circuitstoday.com/password-based-security-system-using-8051

Reference Books:

1.E BALAGURUSAMY, “Programming in ANSI C”, Tata McGraw Hill, May 2010.

2.MUHAMMAD ALI, MAZID JANICE, GILLISPIE MAZIDI, “The

8051microcontroller and embedded systems”, Pearson Education, April 2009.