Professional Documents
Culture Documents
Project Report On: Bi-Directional Visitor Counter & Home Automation
Project Report On: Bi-Directional Visitor Counter & Home Automation
Project Report on
Submitted to
Bachelor of Technology
In
Session: 2014-2015
BIKANER
Session 2014-2015
CERTIFICATE
This is to certify that the project entitled “BI-DIRECTIONAL VISITOR COUNTER &
HOME AUTOMATION” has been submitted to the Rajasthan Technical University, Kota
for fulfillment of the requirement for the award of the degree of Bachelor of Technology in
“Electronics & Communication Engineering” by following student of final year B.Tech.
(Electronics & Communication Engineering).
Roshan Mani(11ECTEC047)
Rahul Purohit(11ECTEC040)
Chhavi Sharma(11ECTEC12)
Harshita Gupta(11ECTEC020)
2
Roshan Mani-GCET Bikaner
ACKNOWLEDGEMENT
iii
Roshan Mani-GCET Bikaner
ABSTRACT
Materials & Method: The Project “Bi-directional Visitor Counter and Home
Automation” 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.
Results: This Project is a real-life model which have the ability to perform the task
of counting in both direction. Not only it will increase it’s counter when any person
will enter the house but also when any person leaves the house, counter’s value
reduce considerably.
iv
Roshan Mani-GCET Bikaner
TABLE OF CONTENTS
Certificate ii
Acknowledgement Iii
Abstract Iv
1. Project Overview 1
2. Circuit Components 2
2.1 Resistor 3
2.2 Diode 4
2.3 Potentiometer 4
2.7 AT89C51 7
2.7.1 Description
7
2.7.2 AT89S52 Pin Description 8-14
2.8 78XX IC 15
2.8.1 7805 IC 15
2.9 LED 16
2.10 Relay 17
v
Roshan Mani-GCET Bikaner
3. Circuit Design 23
4. Operation 23-24
5. Software 25-26
6. Applications 27
7. Limitations 27
8. Advantages 27
Conclusion 27
References 28
List of Figures
1. Block Diagram 1
2. Circuit Diagram 2
4. Diode 4
5. Potentiometer 4
6. Electrolytic Capacitor 5
7. Ceramic Capacitor 5
10. AT89C51 7
vi
Roshan Mani-GCET Bikaner
14. AT89S52 14
17. LED 16
19. Relay 17
22. LM324 IC 19
24. Transformer 21
27. Hex-Code of 0 to 9 22
29. Flow-Chart 24
vii
Roshan Mani-GCET Bikaner
1) PROJECT OVERVIEW:
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.
1
Roshan Mani-GCET Bikaner
2) Circuit Components:
2
Roshan Mani-GCET Bikaner
Reset Key
2 Relay
ULN2803 Relay Driver IC
LM324 IC
IR LED
IR Phototransistor
Transformer
7 segment Display
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.
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
Fig. 4 Diode
2.3)Potentiometer:
Fig. 5 Potentiometer
4
Roshan Mani-GCET Bikaner
2.4)Electrolytic Capacitor:
2.5)Ceramic Capacitor:
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.
6
Roshan Mani-GCET Bikaner
2.7)AT89C51:
Fig. 10 AT89C51
2.7.1)Description:
7
Roshan Mani-GCET Bikaner
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
8
Roshan Mani-GCET Bikaner
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
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 3 also receives some control signals for Flash programming and verification.
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
9
Roshan Mani-GCET Bikaner
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.
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.
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.
10
Roshan Mani-GCET Bikaner
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
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.
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
11
Roshan Mani-GCET Bikaner
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.
12
Roshan Mani-GCET Bikaner
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.
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
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
13
Roshan Mani-GCET Bikaner
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.
Fig.14 AT89S52
14
Roshan Mani-GCET Bikaner
15
Roshan Mani-GCET Bikaner
Pin Description:
Fig.17 LED
16
Roshan Mani-GCET Bikaner
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.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.
17
Roshan Mani-GCET Bikaner
Fig.20 ULN2803
The ULN 2803 IC consists of eight NPN Darlington connected transistors (often
called a Darlington pair). Darlington pair 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.
Q1 and Q2 both will not conduct as there is no base current provided to them. Thus,
nothing will appear at the output (OUT).
18
Roshan Mani-GCET Bikaner
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:
Fig.22 LM 324 IC
Pin Description:
Pin Function Name
No
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 2 nd comparator Input 2+
19
Roshan Mani-GCET Bikaner
20
Roshan Mani-GCET Bikaner
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.
Features:
• Common Anode
• 0.52 Inch Digit Height
• Continuous Uniform Segments
• Low power Requirement
• Excellent Characters Appearance
• High Brightness & High Contrast
• Wide Viewing Angle
21
Roshan Mani-GCET Bikaner
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.
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
23
Roshan Mani-GCET Bikaner
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 pin-
P1.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.
5) Flow Chart
24
Roshan Mani-GCET Bikaner
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};
25
Roshan Mani-GCET Bikaner
void main()
unsigned char z;
seg=a[0];
r1=r2=0;
while(1)
z--;
seg=a[z];
if(z<=5)
r1=1;r2=0;
else if(z<=9)
26
Roshan Mani-GCET Bikaner
6) Applications:
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.
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.
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 “Ms Neelam
Swami”. We will be highly obliged to you for this kind support.
27
Roshan Mani-GCET Bikaner
Bibliography
Reference Site:
1.www.google.co.in
2.www.wikipedia.com
3.www.cmcjaipur.com
4.www.electronicsforyou.com
5.www.encyclpedia.com
Reference Books:
1.E BALAGURUSAMY, “Programming in ANSI C”, Tata McGraw Hill, May 2010.
28