Bi-Directional Visitor Counter & Home Automation revised strictly to pattern of RTU
1. A
Project Report for
Phase-I
on
“BI-DIRECTIONAL VISITOR COUNTER & HOME
AUTOMATION”
Submitted to
Rajasthan Technical University, Kota
In Partial Fulfillment of the requirement for the award of the degree of
Bachelor of Technology
In
“Electronics & Communication Engineering”
Session: 2014-2015
SUBMITTED BY: GUIDED BY:
Roshan Mani(11ECTEC047) Mrs. Neelam Swami
Rahul Purohit(11ECTEC040) Assistant Professor
Chhavi Sharma(11ECTEC012) E.C.E. Deptt.
Harshita Gupta(11ECTEC020)
GOVERNMENT COLLEGE OF ENGINEERING & TECHNOLOGY,BIKANER
Karni Industrial Area, Pughal Road, Bikaner, Rajasthan-334003
2. i
GOVERNMENT COLLEGE OF ENGINEERING & TECHNOLOGY
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 students of final year B.Tech.
(Electronics & Communication Engineering).
Roshan Mani(11ECTEC047)
Rahul Purohit(11ECTEC040)
Chhavi Sharma(11ECTEC12)
Harshita Gupta(11ECTEC020)
Guide:
Mrs. Neelam Swami
Assistant Professor
E.C.E. Deptt.
3. ii
ACKNOWLEDGEMENT
We are deeply thankful to “CMC Academy” as it has given us golden opportunities to
go through remarkable training on “Embedded System”. Here we have got valuable
and detailed knowledge on real time Projects.
We owe our gratitude to our Faculty cum Trainer “Mr. Vishwesh Kumar Sharma” for
his unmatched support, guidance and inspiration without which we would not have
learned so many new & innovative things in such a short span of time.
We would also like to thank our Department i.e., Department of Electronics &
Communication Engineering of our College especially our H.O.D. “Mr. Arvind
Sirvee” and all our teachers who have suggested us to join this beneficial summer
training. Our special thanks goes to “Mrs. Neelam Swami” without whose support we
would not have completed this Project Report on time in such a good way. We are
highly obliged that we have received all of yours support whenever we needed.
Place:Bikaner Submitted by:
Date: 9th
of January, 2015 Roshan Mani(11ECTEC047)
Rahul Purohit(11ECTEC040)
Chhavi Sharma(11ECTEC012)
Harshita Gupta(11ECTEC020)
4. iii
ABSTRACT
The objective of the project Bi-Directional Visitor Counter & Home Automation is to
make a Microcontroller based model to count number of person visiting particular
room and accordingly light up the room. 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 receives the signals from the sensors, and this
signal is operated under the control of software which is stored in ROM. This Project
is a real life model which has the ability to perform the task of counting in both
directions. Not only it will increase the counter value when any person enter the house
but also when any person leaves the house, counter’s value reduces considerably. 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 proves to be helpful.
The main benefit of this Project is Power Saving. Suppose when we are not in room
then what is the need of appliances being in ON position. It is wastage of Electricity. So to
reduce this wastage and to preserve our resources we need to implement our knowledge of
science and this is our small tribute to mankind.
5. iv
CONTENTS
S. No. Topic Page No.
Certificate i
Acknowledgement ii
Abstract iii
List of Figures v
1. Introduction 1-2
2. Circuit Components 3
2.1 Resistor 3-4
2.2 Diode 4
2.3 Potentiometer 5
2.4 Electrolytic Capacitor 5
2.5 Ceramic Capacitor 6
2.6 11.0592 MHz Crystal Oscillator 6-7
2.7 AT89C51 Microcontroller 7
2.7.1 AT89C51 Pin Description 8-13
2.7.2 AT89S52 Pin Description 13-14
2.8 78XX IC Voltage Regulator IC 15
2.9 LED 16
2.10 Relay 16-17
2.11 ULN2803 Relay Driver IC 17-18
2.12 LM324 IC (OP-AMP) 19
2.13 IR LED Transmitter & Receiver 20
2.14 Transformer 20-21
2.15 7-Segment Display 21-22
3. Circuit Design 23
4. Operation 24-25
5. Flowchart 26
6. Applications 27
7. Limitations 27
8. Advantages 27
Result 28
Conclusion 29
Future Work 30
References 31
Coding 32-33
6. v
LIST OF FIGURES
S. No. Figure Page No.
1.1 Circuit Diagram 1
1.2 Block Diagram 2
1.3 Actual View of Project Model 3
2.1 Resistor Color Coding 4
2.2 Diode 4
2.3 Potentiometer 5
2.4 Electrolytic Capacitors 5
2.5 Ceramic Capacitors 6
2.6 11.0592 MHz Crystal Oscillator 7
2.7 Crystal oscillator Schematic 7
2.8 Pin Diagram & Architecture of AT89C51 8
2.9 ROM & RAM in 8051 Microcontroller 11
2.10 Some 8-bit registers & some 16-bit registers 12
2.11 AT89S52 Pin Diagram 14
2.12 AT89S52 Pin Description 14
2.13 12V regulated power supply using 7812 15
2.14 LED 16
2.15 Relay Description 16
2.16 Relay 17
2.17 ULN2 803 17
2.18 Darlington Pair 18
2.19 LM324 IC 19
2.20 Transmitter & Receiver in Proximity Configuration 20
2.21 Transformer 21
2.22 Common Anode & Common Cathode 7-Segment
Display
22
2.23 0 to 9 on 7-Segment Display 22
2.24 Hex-Code of 0 to 9 22
3.1 Layout of Bi-Directional Visitor Counter & Home
Automation
23
4.1 Working Model 24
5.1 Flow Chart 25
7. 1
1. INTRODUCTION:
This Project “Bi-directional Visitor Counter and Home Automation” 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.1 Circuit Diagram of BDVC
8. 2
Fig. 1.1 Block Diagram of BDVC
Fig. 1.3 Actual View of Project Model
9. 3
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
2.1RESISTOR:
Resistors 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. A resistor is a passive two-terminal electrical component that implements
electrical resistance as a circuit element. Resistors act to reduce current flow,
and, at the same time, act to lower voltage levels within circuits. In electronic
circuits resistors are used to limit current flow, to adjust signal levels, bias active
elements, terminate transmission lines among other uses. High-power resistors
that can dissipate many watts of electrical power as heat may be used as part of
motor controls, in power distribution systems, or as test loads for generators.
Resistors can have fixed resistances that only change slightly with temperature,
time or operating voltage. Variable resistors can be used to adjust circuit
elements (such as a volume control or a lamp dimmer), or as sensing devices for
heat, light, humidity, force, or chemical activity.
10. 4
Fig. 2.1 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. In electronics, a diode is a two-terminal
electronic component with asymmetric conductance; it has low (ideally zero)
resistance to current in one direction, and high (ideally infinite) resistance in the
other. A semiconductor diode, the most common type today, is a crystalline piece
of semiconductor material with a p–n junction connected to two electrical
terminals. A vacuum tube diode has two electrodes, a plate (anode) and a heated
cathode. Semiconductor diodes were the first semiconductor electronic devices.
Fig. 2.2 Diode
11. 5
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. 2.3 Potentiometer
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. 2.4 Electrolytic Capacitors
12. 6
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.
Fig. 2.5 Ceramic Capacitors
2.6 11.0592MHz Crystal Oscillator:
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.
13. 7
Fig. 2.6 11.592 MHz Crystal Oscillator
Fig.2.7 Crystal Oscillator Schematic
2.7 AT89C51 Microcontroller:
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 nonvolatile memory technology
and is compatible with the industry standard MCS-51™ instruction set and pinout.
The on-chip Flash allows the program memory to be reprogrammed in-system or by a
conventional nonvolatile 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.
14. 8
Fig. 2.8 Pin Diagram and Architecture of AT89C51
2.7.1 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.
15. 9
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 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.
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.
16. 10
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.
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.
On-chip 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.
On-chip 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.
17. 11
Fig. 2.9 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.
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.
18. 12
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 is 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.
Fig. 2.10 Some 8-bit registers & some 16-bit registers
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.
19. 13
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
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 flag is used to detect errors in unsigned arithmetic operations.
2.7.2 AT89S52 Microcontroller:
Low-power, high-performance CMOS 8-bit microcontroller with 8KB of ISP
flash memory. The device uses Atmel high-density, nonvolatile memory
technology and is compatible with the industry-standard 80C51 instruction set
and pinout. On-chip flash allows the program memory to be reprogrammed in-
system or by a conventional nonvolatile memory programmer. This powerful
microcontroller is suitable for many embedded control applications.
21. 15
2.8 78XX IC
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 is 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:
Fig. 2.13 12V Regulated Power Supply Using 7812
Pin No Function Name
1 Input voltage (5V-18V) Input
2 Ground (0V) Ground
3 Regulated output; 5V (4.8V-5.2V) Output
22. 16
2.9 LED
A light-emitting diode (LED) is a two-lead semiconductor light source. It is a
basic p-n 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. 2.14 LED
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. 2.15 Relay description
23. 17
Fig. 2.16 Relay
2.11 ULN2803 Relay Driver IC
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.
Fig. 2.17 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 β. The figure shown below is one of the eight Darlington pairs of ULN
2803 IC.
24. 18
Fig. 2.18 Darlington Pair
Now 2 cases arise:
Case 1: When IN is 0 volts.
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. 19
Fig. 2.19 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
Pin Description of LM 324 IC
26. 20
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. 2.20 Transmitter & Receiver in Proximity Configuration
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.
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 turn 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.
27. 21
Fig. 2.21 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
28. 22
Fig.2.22 Common Cathode & Common Anode 7-Segment Display
Fig. 2.23 0 to 9 on 7-Segment Display
Fig. 2.24 Hex Code of 0 to 9
29. 23
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. 3.1 Layout of Bidirectional Visitor Counter & Home
Automation
30. 24
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 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.
Fig. 4.1 Working Model
31. 25
We are having three different Circuits in our project. Firstly we have voltage regulator
circuit where we are using Step-Down Transformer for converting 240V AC mains
supply to 12 V AC. Then we are using Bridge Rectifier Circuit consisting of 4 diodes
for converting AC to DC. This process is called rectification. Then we are using one
electrolytic capacitor which helps us in reducing ripples present. Next we have one
diode which lets further circuit perform it’s task when it is forward biased. Then we
have 7812 IC whose basic task is to regulate the voltage coming from transformer to
exactly 12 V. Here we have 2 Ceramic Capacitor. Next we have another electrolytic
capacitor which works as power saver capacitor. After that we are having one LED in
series with a resistor which acts as indicator. So we get 12 V DC power supply from
this first part of our project.
In the second part of our project we are having Sensor Circuit. Here we have two
Transmitter & Receiver pairs which are connected in line of sight configuration or
through beam configuration. Transmitter IR LED is connected in reverse biased mode
along with it’s respective fixed resistor. The receiver IR LED is connected to variable
resistor so that it can be tuned according to requirement. When any person passes
through the Transmitter Receiver pair the IR ray between them is inhibited of which
information is send to third part of our project.
In the third part of our project initially the signal of hinderance coming from Sensor
Circuit goes to LM324 IC which is an OpAmp (Operational Amplifier). It gives it’s
output to P1.0 and P1.1 port of AT89S52 Microcontroller. The Microcontroller is
coded in such a way that if any person bypasses the sensor circuit then counter is
intialised and 7-Segment display start showing the no. of persons. Simultaneously the
relay start functioning as the output from P1.2 & P1.3 port of AT89S52 is connected
to I0 & I1 port of ULN2803 Relay driver IC which controls the relay. In this part of
our project we have 7805 IC as well as 7812 IC. 7805 IC controls the microcontroller
where as 7812 IC controls the relay. Thus the result is that we are able to count the
visitor using our Project Bi-Directional Visitor Counter & Home Automation.
32. 26
5. Flow Chart
Fig. 5.1 Flow Chart
If the sensor 1 is interrupted first then the microcontroller will look for the sensor
2. And if it is interrupted then the microcontroller will increment the count and
switch on the relay, if it is first time interrupted.
If the sensor 2 is interrupted first then the microcontroller will look for the sensor
1. And if it is interrupted then the microcontroller will decrement the count.
This process will continue and when no. of person entering the room exceed 5
then second relay is switched on.
When the last person leaves the room then counter goes to 0 and that time the
relay will turn off. And light will be turn off.
33. 27
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.
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.
3. Whole system will work automatically so it reduces the human work.
34. 28
RESULT
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. Let us 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.
35. 29
CONCLUSION
With the knowledge of new techniques in “Electronics”, we are able to make our life
more comfortable. One such application of Electronics is “Bi-Directional Visitor
Counter & Home Automation”.
Bi-Directional Visitor Counter & Home Automation is one of the applications of
electronics to increase the facilities of life. The use of new electronic theories has
been put down by us to increase the facilities given by the existing appliance. Here the
facility of ordinary room light is increased by the making it controlled automatically
through sensors.
This circuit is simple to use and efficient. It can be assembled with ease. It is cheap
and hence very economic. It is small in size and can be fixing inside our house, in our
office, in seminar hall, in theatre or where ever we want.
It saves around 60% of electricity from per room. So throughout the world if we use
this concept then it will eliminate the energy crisis to a larger extent.
36. 30
Future Work
Bi-Directional Visitor Counter & Home Automation has very good future. It can be
used by anybody right from a common man to an industrialist. It can be used for
counting the no. of persons present in any room at particular time. If any person enters
the room then the value of counter increases and the light is automatically switched.
In the similar way when any one leaves the place then the value of counter is reduced
hence it works in both case. The relay are connected in such a way that it has capacity
of controlling upto 2 appliances. In future with simple change in circuit more
appliances can be controlled. The data of no. of person present can also be increased
using more 7-Segment Display. Later in this project we can also add security features
using Password Based Home Security System. This technology will safeguard the
home from unknown intruders. It will give access to only genuine person. So, we can
say that this Project has good future scope.
37. 31
REFERENCES
Reference Site:
[1] http://www.atmel.com/devices/at89s52.aspx
[2] http://www.keil.com/dd/chip/3411.htm
[3] http://www.electronics-tutorials.ws/counter/count_1.html
[4] http://www.electronics-tutorials.ws/resistor/res_1.html
[5] http://en.wikipedia.org/wiki/Light-emitting_diode
[6] http://en.wikipedia.org/wiki/Transformer
[7] http://www.answers.com/Q/What_is_Relay_driver_ULN2803
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.