Home Security System
1. INTRODUCTION
1.1OVERVIEW
The overview of this project is to implement home security system using IR technology and 89S52 controller. 89S52 is very efficient architecture which can be used for low end security systems and IR is widely adapted technology for communication.
1.2PURPOSE
Purpose of the current work is to study and analyze the security system by using 8051 controller.
1.3 SCOPE
Current work focuses on how to use effectively IR and 8051 controllers for security systems.
1
Home Security System
2. EMBEDDED SYSTEMS
2.1 INTRODUCTION
An embedded system is a special-purpose computer system designed to perform one or a
few dedicated functions, often with real-time computing constraints. It is usually
embedded as part of a complete device including hardware and mechanical parts. In
contrast, a general-purpose computer, such as a personal computer, can do many different
tasks depending on programming. Embedded systems control many of the common
devices in use today.
Since the embedded system is dedicated to specific tasks, design engineers can optimize
it, reducing the size and cost of the product, or increasing the reliability and performance.
Physically, embedded systems range from portable devices such as digital watches and
mp4 players, to large stationary installations like traffic lights, factory controllers, or the
systems controlling nuclear power stations. Complexity varies from low, with a single
microcontroller chip, to very high with multiple units, peripherals and networks mounted
inside a large chassis or enclosure.
In general, "embedded system" is not an exactly defined term, as many systems have
some element of programmability. For example, handheld computers share some
elements with embedded systems — such as the operating systems and microprocessors
which power them — but are not truly embedded systems, because they allow different
applications to be loaded and peripherals to be connected
2.2 CHARACTERISTICS
1. Embedded systems are designed to do some specific task, rather than be a
general-purpose computer for multiple tasks. Some also have real-time
performance constraints that must be met, for reasons such as safety and usability;
2
Home Security System
others may have low or no performance requirements, allowing the system
hardware to be simplified to reduce costs.
2. Embedded systems are not always standalone devices. Many embedded systems
consist of small, computerized parts within a larger device that serves a more
general purpose. For example, the features an embedded system for tuning the
strings, but the overall purpose of the Robot Guitar is, of course, to play music.
Similarly, an embedded system in automobiles provides a specific function as a
subsystem of the car itself.
3. The program instructions written for embedded systems are referred to as
firmware, and are stored in read-only memory or flash memory chips. They run
with limited computer hardware resources: little memory, small or non-existent
keyboard and/or screen.
Fig1: Embedded system block diagram
3
Home Security System
3.MICRO CONTROLLER
A bye product of microprocessor development was the micro controller. The same
fabrication techniques and programming concepts that make possible general-purpose
microprocessor also yielded the micro controller.
Among the applications of a micro controller we can mention industrial automation,
mobile telephones, radios, microwave ovens and VCRs. Besides, the present trend in
digital electronics is toward restricting to micro controllers and chips that concentrate a
great quantity of logical circuits, like PLDs (Programmable Logic Devices) and GALs
(Gate Array Logic). In dedicated systems, the micro controller is the best solution,
because it is cheap and easy to manage.
3.1 8051 Micro Controller
Despite it’s relatively old age, the 8051 is one of the most popular micro controllers in
use today. Many derivative micro controllers have since been developed that are based
on--and compatible with--the 8051. Thus, the ability to program an 8051 is an important
skill for anyone who plans to develop products that will take advantage of micro
controllers. In 8051 architecture there are so many controllers developed by different
semiconductor companies. Here we are going to use the controller manufactured by
Atmel semiconductors which is AT89S52.All the controllers belongs to 8051 architecture
follow harward architecture and CISC design.
.
4
Home Security System
4. IR REMOTE THEORY
The cheapest way to remotely control a device within a visible range is via Infra-Red
light. Almost all audio and video equipment can be controlled this way nowadays. Due to
this wide spread use the required components are quite cheap, thus making it ideal for us
hobbyists to use IR control for our own projects.
IR sensor is the combination of IR LED with PHOTO DIODE. After this combination
we are connecting the DARLINGTON PAIR TRANSISTOR. End of the IR sensor we
have to connect a NOT gate for the inverting purpose means low input have
corresponding low output. At last this entire connector is connected to any one external
interrupt to generating the interruption of the main program.
Infra-Red actually is normal light with a particular color. We humans can't see this color
because its wave length of 950nm is below the visible spectrum. That's one of the reasons why
IR is chosen for remote control purposes, we want to use it but we're not interested in seeing it.
Another reason is because IR LEDs are quite easy to make, and therefore can be very cheap.
IR LED wave length range 1.6m to 2.4m. Materials used for IR LED are InSB, Ge,Si,
GaAs, CdSe . These IR s are not visible range for observation purpose we have to
connect LED s are not.
4.1 SECURITY SYSTEMS
Nowadays security became very serious issue at anywhere. To get security at any time
we need a system which can work at any circumstances. In this project we are going to
use IR technology which is widely accepted technology for small distance
communications. With the use of 89s52 controller and IR technology we are going to
implement security system for home with door opening and closing when intruder is
detected.
5
Home Security System
4.2 PROBLEM FORMULATION
The problem with the security systems is access to the specific person and at the same
time if any person trying to access the system it should intimate without any fail.IR
technology we are using to pass information to the specific person with the help of 8051
controller. To detect intruder we are using IR transmitter and Receiver circuit or we can
go with photo diode and photo transmitters. In this system a person can access only if the
password is correct and if not correct door is will not open. With the use of 89s52
controller and IR technology we are going to implement security system for home with
door opening and closing when intruder is detected.
6
Home Security System
5. SYSTEM SPECIFICATIONS
89S52 Micro Controller
5.1 FEATURES:
• Compatible with MCS-51® Products
• 8K Bytes of In-System Programmable (ISP) Flash Memory
– Endurance: 1000 Write/Erase Cycles
• 4.0V to 5.5V Operating Range
• Fully Static Operation: 0 Hz to 33 MHz
• Three-level Program Memory Lock
• 256 x 8-bit Internal RAM
• 32 Programmable I/O Lines
• Three 16-bit Timer/Counters
• Eight Interrupt Sources
• Full Duplex UART Serial Channel
• Low-power Idle and Power-down Modes
• Interrupt Recovery from Power-down Mode
• Watchdog Timer
• Dual Data Pointer
• Power-off Flag
7
Home Security System
5.2 DESCRIPTION:
The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K
bytes of in-system programmable Flash memory. The device is manufactured using
Atmel’s high-density nonvolatile memory technology and is compatible with the
industry- standard 80C51 instruction set and pin out. 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 in-system programmable
Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller which
provides a highly-flexible and cost-effective solution to many embedded control
applications.
The AT89S52 provides the following standard features: 8K bytes of Flash, 256 bytes of
RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters, a six-
vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and
clock circuitry. In addition, the AT89S52 is designed with static logic for operation down
to zero frequency and supports two software selectable power saving modes. The Idle
Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt
system to continue functioning. The Power-down mode saves the RAM contents but
freezes the oscillator, disabling all other chip functions until the next interrupt or
hardware reset.
8
Home Security System
Fig2: pin configurations of micro controller
9
Home Security System
Fig3: Block diagram of Micro controller
10
Home Security System
5.2.1 Pin Description:
VCC: Pin 40 provides supply voltage to the chip. The voltage source is + 5V.
GND: Pin 20 provides 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 can 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.
In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count
input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown
in the following table.
Port 1 also receives the 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.
11
Home Security System
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 AT89S52, as shown in
the following table.
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. This pin drives High for 96 oscillator periods after the
Watchdog times out.
ALE/PROG: Address Latch Enable (ALE) is an output pulse for latching the low byte of
the address during accesses to external memory. This pin is also the program pulse input
(PROG) during flash programming.
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 (PSEN) is the read strobe to external program memory.
When the AT89S52 is executing code from external program memory, PSEN is activated
twice each machine cycle, except that two PSEN activations are skipped during each
access to external data memory.
12
Home Security System
EA/VPP: External access enable. EA must be strapped to GND in order to enable the
device to fetch code from external program memory locations starting at 0000H up to
FFFFH.
Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset.
EA should be strapped to VCC for internal program executions. This pin also receives the
12-volt programming enable voltage (VPP) during Flash programming.
XTAL1: Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.
XTAL2: Output from the inverting oscillator amplifier.
5.2.2 Special Function Registers
Timer 2 Registers: Control and status bits are contained in registers T2CON (shown in
Table 2) and T2MOD (shown in Table 3) for Timer 2. The register pair (RCAP2H,
RCAP2L) is the Capture/Reload registers for Timer 2 in 16-bit capture mode or 16-bit
auto-reload mode.
Interrupt Registers: The individual interrupt enable bits are in the IE register. Two
priorities can be set for each of the six interrupt sources in the IP register.
Dual Data Pointer Registers: To facilitate accessing both internal and external data
memory, two banks of 16-bit Data Pointer Registers are provided: DP0 at SFR address
locations 82H-83H and DP1 at 84H-85H. Bit DPS = 0 in SFR AUXR1 selects DP0 and
DPS = 1 selects DP1. The user should always initialize the DPS bit to the appropriate
value before accessing the respective Data Pointer Register.
Power Off Flag: The Power Off Flag (POF) is located at bit 4 (PCON.4) in the PCON
SFR. POF is set to “1” during power up. It can be set and rest under software control and
is not affected by reset.
13
Home Security System
5.2.3 Memory Organization
MCS-51 devices have a separate address space for Program and Data Memory. Up to
64K bytes each of external Program and Data Memory can be addressed.
Program Memory: If the EA pin is connected to GND, all program fetches are directed
to external memory. On the AT89S52, if EA is connected to VCC, program fetches to
addresses 0000H through 1FFFH are directed to internal memory and fetches to
addresses 2000H through FFFFH are to external memory.
Data Memory: The AT89S52 implements 256 bytes of on-chip RAM. The upper 128
bytes occupy a parallel address space to the Special Function Registers. This means that
the upper 128 bytes have the same addresses as the SFR space but are physically separate
from SFR space.
When an instruction accesses an internal location above address 7FH, the address mode
used in the instruction specifies whether the CPU accesses the upper 128 bytes of RAM
or the SFR space. Instructions which use direct addressing access of the SFR space.
5.3 WATCHDOG TIMER
(One-time Enabled with Reset-out)
The WDT is intended as a recovery method in situations where the CPU may be
subjected to software upsets. The WDT consists of a 13-bit counter and the Watchdog
Timer Reset (WDTRST) SFR. The WDT is defaulted to disable from exiting reset. To
enable the WDT, a user must write 01EH and 0E1H in sequence to the WDTRST register
(SFR location 0A6H). When the WDT is enabled, it will increment every machine cycle
while the oscillator is running. The WDT timeout period is dependent on the external
clock frequency. There is no way to disable the WDT except through reset (either
hardware reset or WDT overflow (reset). When WDT overflows, it will drive an output
RESET HIGH pulse at the RST pin.
14
Home Security System
Using the WDT
To enable the WDT, a user must write 01EH and 0E1H in sequence to the WDTRST
register (SFR location 0A6H). When the WDT is enabled, the user needs to service it by
writing 01EH and 0E1H to WDTRST to avoid a WDT overflow. The 13-bit counter
overflows when it reaches 8191 (1FFFH), and this will reset the device. When the WDT
is enabled, it will increment every machine cycle while the oscillator is running. This
means the user must reset the WDT at least every 8191 machine cycles. To reset the
WDT the user must write 01EH and 0E1H to WDTRST. DTRST is a write-only register.
The WDT counter cannot be read or written. When WDT overflows, it will generate an
output RESET pulse at the RST pin. The RESET pulse duration is 96xTOSC, where
TOSC=1/FOSC. To make the best use of the WDT, it should be serviced in those
sections of code that will periodically be executed within the time required to prevent a
WDT reset.
UART
Serial data communication uses two methods, asynchronous and synchronous. The
synchronous method transfers a block of data (characters) at a time, while the
asynchronous method transfers a single byte at a time. It is possible to write software to
use either of these methods, but programs can be tedious and long. For this reason, there
are special IC chips made by the manufacturers for the serial data communications. These
chips are commonly referred to as UART (universal asynchronous receiver-transmitter)
and USART ( universal synchronous receiver-transmitter). The 8052 has built-in UART.
Timer 0
The 16-bit register of timer 0 is accessed as low byte and high byte. The low byte register
is called TL0 (Timer 0 low byte) and the high byte register is referred to as TH0 (Timer 0
high byte). These registers can be accessed like any other registers.
Timer1
15
Home Security System
Timer 1 is also 16 bits and its 16-bit register is split into two bytes, referred to as TL1
(Timer 1 low byte ) and TH1 ( Timer 1 high byte). These registers are accessible in the
same way as the registers of Timer 0.
Timer 2
Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event counter.
The type of operation is selected by bit C/T2 in the SFR T2CON (shown in Table 2).
Timer 2 has three operating modes: capture, auto-reload (up or down counting), and baud
rate generator. The modes are selected by bits in T2CON.
5.4 INTERRUPTS
The AT89S52 has a total of six interrupt vectors: two external interrupts (INT0 and
INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt. These
interrupts are all shown in Figure 10. Each of these interrupt sources can be individually
enabled or disabled by setting or clearing a bit in Special Function Register IE. IE also
contains a global disable bit, EA, which disables all interrupts at once. Note that Table 5
shows that bit position IE.6 is unimplemented. In the AT89S52, bit position IE.5 is also
unimplemented. User software should not write 1s to these bit positions, since they may
be used in future AT89 products. Timer 2 interrupt is generated by the logical OR of bits
TF2 and EXF2 in register T2CON. Neither of these flags is cleared by hardware when the
service routine is vectored to. In fact, the service routine may have to determine whether
it was TF2 or EXF2 that generated the interrupt, and that bit will have to be cleared in
software. The Timer 0 and Timer 1 flags, TF0 and TF1, are set at S5P2 of the cycle in
which the timers overflow. The values are then polled by the circuitry in the next cycle.
However, the Timer 2 flag, TF2, is set at S2P2 and is polled in the same cycle in which
the timer overflows.
5.5 OSCILLATOR CHARACTERISTICS
16
Home Security System
XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier that
can be configured for use as an on-chip oscillator, as shown in Figure 11. Either a quartz
crystal or ceramic resonator may be used. To drive the device from an external clock
source, XTAL2 should be left unconnected while XTAL1 is driven, as shown in Figure
12. There are no requirements on the duty cycle of the external clock signal, since the
input to the internal clocking circuitry is through a divide-by-two flip-flop, but minimum
and maximum voltage high and low time specifications must be observed.
Oscillator connections
fig4: Oscillator circuit
Note: C1, C2 = 30 pF ± 10 pF for Crystals
= 40 pF ± 10 pF for Ceramic Resonators
External Clock Drive Configuration
17
Home Security System
fig5: Oscillator connections
Idle Mode
In idle mode, the CPU puts itself to sleep while all the on chip peripherals remain active.
The mode is invoked by software.
Power-down Mode
In the Power-down mode, the oscillator is stopped, and the instruction that invokes
Power-down is the last instruction executed. The on-chip RAM and Special Function
Registers retain their values until the Power-down mode is terminated.
18
Home Security System
6. LIQUID CRYSTAL DISPLAY
LCD stands for Liquid Crystal Display. LCD is finding wide spread use replacing LEDs
(seven segment LEDs or other multi segment LEDs) because of the following reasons:
1. The declining prices of LCDs.
2. The ability to display numbers, characters and graphics. This is in contrast to
LEDs, which are limited to numbers and a few characters.
3. Incorporation of a refreshing controller into the LCD, thereby relieving the CPU
of the task of refreshing the LCD. In contrast, the LED must be refreshed by the
CPU to keep displaying the data.
4. Ease of programming for characters and graphics.
These components are “specialized” for being used with the microcontrollers, which
means that they cannot be activated by standard IC circuits. They are used for writing
different messages on a miniature LCD.
Fig6: LCD Display
19
Home Security System
A model described here is for its low price and great possibilities most frequently used in
practice. It is based on the HD44780 microcontroller (Hitachi) and can display messages
in two lines with 16 characters each.
LCD SCREEN: LCD screen consists of two lines with 16 characters each. Each character
consists of 5x7 dot matrix. Contrast on display depends on the power supply voltage and
whether messages are displayed in one or two lines. For that reason, variable voltage 0-Vdd is
applied on pin marked as Vee. Trimmer potentiometer is usually used for that purpose. Some
versions of displays have built in backlight (blue or green diodes). When used during operating, a
resistor for current limitation should be used (like with any LE diode).
6.1 LCD BASIC COMMANDS:
All data transferred to LCD through outputs D0-D7 will be interpreted as commands or
as data, which depends on logic state on pin RS:
RS = 1 - Bits D0 - D7 are addresses of characters that should be displayed. Built in
processor addresses built in “map of characters” and displays corresponding symbols.
Displaying position is determined by DDRAM address. This address is either previously
defined or the address of previously transferred character is automatically incremented.
RS = 0 - Bits D0 - D7 are commands which determine display mode.
20
Home Security System
I/D 1 = Increment (by 1) R/L 1 = Shift right
0 = Decrement (by 1) 0 = Shift left
S 1 = Display shift on DL 1 = 8-bit interface
0 = Display shift off 0 = 4-bit interface
D 1 = Display on N 1 = Display in two lines
0 = Display off 0 = Display in one line
6.2 LCD CONNECTION: Depending on how many lines are used for connection
to the microcontroller, there are 8-bit and 4-bit LCD modes. The appropriate mode is
determined at the beginning of the process in a phase called “initialization”. In the first
case, the data are transferred through outputs D0-D7 as it has been already explained. In
case of 4-bit LED mode, for the sake of saving valuable I/O pins of the microcontroller,
there are only 4 higher bits (D4-D7) used for communication, while other may be left
unconnected.
Consequently, each data is sent to LCD in two steps: four higher bits are sent first (that
normally would be sent through lines D4-D7), four lower bits are sent afterwards. With
the help of initialization, LCD will correctly connect and interpret each data received.
Besides, with regards to the fact that data are rarely read from LCD (data mainly are
transferred from microcontroller to LCD) one more I/O pin may be saved by simple
connecting R/W pin to the Ground. Such saving has its price. Even though message
displaying will be normally performed, it will not be possible to read from busy flag since
it is not possible to read from display.
21
Home Security System
6.3 LCD INITIALIZATION:
Once the power supply is turned on, LCD is automatically cleared. This process lasts for
approximately 15mS. After that, display is ready to operate. The mode of operating is set
by default. This means that:
1. Display is cleared
2. Mode
DL = 1 Communication through 8-bit interface
N = 0 Messages are displayed in one line
F = 0 Character font 5 x 8 dots
5. Display/Cursor on/off
D = 0 Display off
U = 0 Cursor off
B = 0 Cursor blink off
6. Character entry
ID = 1 Addresses on display are automatically incremented by 1
22
Home Security System
S = 0 Display shift off
Automatic reset is mainly performed without any problems. Mainly but not always! If for
any reason power supply voltage does not reach full value in the course of 10mS, display
will start perform completely unpredictably. If voltage supply unit cannot meet this
condition or if it is needed to provide completely safe operating, the process of
initialization by which a new reset enabling display to operate normally must be applied.
Algorithm according to the initialization is being performed depends on whether
connection to the microcontroller is through 4- or 8-bit interface. All left over to be done
after that is to give basic commands and of course- to display messages.
23
Home Security System
7. INFRARED LED (IR LED)
IR sensor is the combination of IR LED with PHOTO DIODE. After this combination we
are connecting the DARLINGTON PAIR TRANSISTOR. End of the IR sensor we have
to connect a NOT gate for the inverting purpose means low input have corresponding low
output Infra-Red actually is normal light with a particular color. We humans can't see
this color because its wave length of 950nm is below the visible spectrum. That's one of
the reasons why IR is chosen for remote control purposes, we want to use it but we're not
interested in seeing it. Another reason is because IR LEDs are quite easy to make, and
therefore can be very cheap.
Although we humans can't see the Infra-Red light emitted from a remote control doesn't
mean we can't make it visible. A video camera or digital photo camera can "see" the
Infra-Red
7.1 TRANSMITTER:
In the picture below we can see a modulated signal driving the IR LED of the transmitter
on the left side. The detected signal is coming out of the receiver at the other side.
:
24
Home Security System
FIG7: IR TRANSMITTER
The transmitter usually is a battery powered handset. It should consume as little power as
possible, and the IR signal should also be as strong as possible to achieve an acceptable
control distance. Preferably it should be shock proof as well.
FIG8: TRANSISTOR CIRCUIT USED TO DRIVE IR LED
Quartz crystals are seldom used in such handsets. They are very fragile and tend to break
easily when the handset is dropped. Ceramic resonators are much more suitable here,
because they can withstand larger physical shocks. The fact that they are a little less
accurate is not important.
The current through the LED (or LEDs) can vary from 100mA to well over 1A! In order
to get an acceptable control distance the LED currents have to be as high as possible. A
trade-off should be made between LED parameters, battery lifetime and maximum
control distance. LED currents can be that high because the pulses driving the LEDs are
very short. Average power dissipation of the LED should not exceed the maximum value
though. You should also see to it that the maximum peek current for the LED is not
exceeded. All these parameters can be found in the LED's data sheet.
25
Home Security System
A simple transistor circuit can be used to drive the LED. A transistor with a suitable hfe
and switching speed should be selected for this purpose. The resistor values can simply
be calculated using Ohm's law. Remember that the nominal voltage drop over an IR LED
is approximately 1.1V. The normal driver, described above, has one disadvantage. As the
battery voltage drops, the current through the LED will decrease as well. This will result
in a shorter control distance that can be covered.
An emitter follower circuit can avoid this. The 2 diodes in series will limit the pulses on
the base of the transistor to 1.2V. The base-emitter voltage of the transistor subtracts
0.6V from that, resulting in constant amplitude of 0.6V at the emitter. This constant
amplitude across a constant resistor results in current pulses of a constant magnitude.
Calculating the current through the LED is simply applying ohm’ law.
7.2 PHOTODIODES:
Unfortunately for us there are many more sources of Infrared light. The sun is the
brightest source of all, but there are many others, like: light bulbs, candles, central
heating system, and even our body radiate Infrared light. In fact everything that radiates
heat also radiates Infrared light. Therefore we have to take some precautions to guarantee
that our IR message gets across to the receiver without errors.
Photodiodes are used for the detection of optical power (UV, Visible, and IR) and for the
conversion of optical power to electrical power. The photodiode spectral response can be
measured in X-ray, UV, visible, or IR. X-ray photodiodes are optimized for X-ray,
gamma ray, and beta radiation detection.
26
Home Security System
8. SYSTEM DESIGN
Designing of this system is possible when you select the specific controller to suite. For this we selected 89S52 controller. With the help of this controller home security can be implemented successfully with the help IR technology. To the controller we connected IR transmitter and receiver circuit. Instead of IR transmitter and receiver we can go with photo diode and photo transmitters also. Whenever person enters into home, then IR detects the person by sending signal to controller and the controller will gives alarm and display message on the LCD and it rotates stepper motor
8.1 HARDWARE DESIGN:
27
Home Security System
8.1.1 Schematic
V C C
R 5R
J 3
C O N 8
12345678
U 5
L M 7 8 0 5 / TO
1
3
2V I N
GN
D V O U T
C 2
C A P
D 4D I O D E
U 1
A T8 9 S 5 2
5678
9
1 01 11 21 31 41 51 61 7
1 8
1 9
2 0
4 0
3 93 83 73 63 53 43 33 2
3 1
3 02 9
2 82 72 62 52 42 32 22 1
1234
P 1 . 4P 1 . 5P 1 . 6P 1 . 7
R S T
P 3 . 0 / R XDP 3 . 1 / TXDP 3 . 2 / I N T0P 3 . 3 / I N T1P 3 . 4 / T0P 3 . 5 / T1P 3 . 6 / W RP 3 . 7 / R D
XTA L 2
XTA L 1
G N D
V C C
P 0 . 0 / A D 0P 0 . 1 / A D 1P 0 . 2 / A D 2P 0 . 3 / A D 3P 0 . 4 / A D 4P 0 . 5 / A D 5P 0 . 6 / A D 6P 0 . 7 / A D 7
E A / V P P
A L E / P R O GP S E N
P 2 . 7 / A 1 5P 2 . 6 / A 1 4P 2 . 5 / A 1 3P 2 . 4 / A 1 2P 2 . 3 / A 1 1P 2 . 2 / A 1 0
P 2 . 1 / A 9P 2 . 0 / A 8
P 1 . 0P 1 . 1P 1 . 2P 1 . 3
S W 1
J 2
C O N 8
12345678
C 5
C A P
V C C
J 4
C O N 8
12345678
D 1D I O D E
R 4R
J 3
L C D
1 2 3 4 5 6 7 8 9 10
11
12
13
14
15
16
gn
dv
cc
3 RS
W EN
P0
.0P
0.1
P0
.2P
0.3
P0
.4P
0.5
P0
.6P
0.7
VC
CG
ND
C 4
C A P
C 1C
P 2
C O N N E C TO R D B 9
594837261
C 6
C A P
V C C
R XD
R 6
P O T
J 2
C O N 8
12345678
D 6D I O D E
TXD
TXD
C 7C A P
U 6t / f (4 p in )
1 2
3 4
1 2
3 4
C 3
C A P
D 2D I O D E
<D o c > <R e v C o d e >
<Tit le >
A
1 1Th u rs d a y , J u ly 1 5 , 2 0 1 0
Tit le
S ize D o c u m e n t N u m b e r R e v
D a t e : S h e e t o f
Y 1C R Y S TA L
D 5L E D
R XD
J 7C O N 2
1 2
+5 V
C 9
C
= 1 0 0 0 U F / 2 5 V
U 3
M A X2 3 2
13
45
2
6
1 2
9
1 1
1 0
1 3
8
1 4
7
C 1 +C 1 -
C 2 +C 2 -
V +
V -
R 1 O U T
R 2 O U T
T1 I N
T2 I N
R 1 I N
R 2 I N
T1 O U T
T2 O U T
C 81 0 4
Fig9: Circuit diagram
8.1.2. Schematic Description
The main aim of this power supply is to convert the 230V AC into 5V DC in order to
give supply for the TTL. This schematic explanation includes the detailed pin
connections of every device with the microcontroller.
This schematic explanation includes the detailed pin connections of every device with the
microcontroller.
Let us see the pin connections of each and every device with the microcontroller in detail.
28
Home Security System
Power Supply: The power supplies are designed to convert high voltage AC mains
electricity to a suitable low voltage supply for electronic circuits and other devices. A
RPS (Regulated Power Supply) is the Power Supply with Rectification, Filtering and
Regulation being done on the AC mains to get a Regulated power supply for
Microcontroller and for the other devices being interfaced to it.
A power supply can by broken down into a series of blocks, each of which performs a
particular function. A d.c power supply which maintains the output voltage constant
irrespective of a.c mains fluctuations or load variations is known as “Regulated D.C
Power Supply”
Regulator:
Voltage regulator ICs is available with fixed (typically 5, 12 and 15V) or variable output
voltages. The maximum current they can pass also rates them. Negative voltage
regulators are available, mainly for use in dual supplies. Most regulators include some
automatic protection from excessive current ('overload protection') and overheating
('thermal protection'). Many of the fixed voltage regulators ICs have 3 leads and look
like power transistors, such as the 7805 +5V 1A regulator shown on the right. The
LM7805 is simple to use. You simply connect the positive lead of your unregulated DC
power supply (anything from 9VDC to 24VDC) to the Input pin, connect the negative
lead to the Common pin and then when you turn on the power, you get a 5 volt supply
from the output pin.
Transformer: At the primary of the transformer we are giving the 230V AC supply. The
secondary is connected to the opposite terminals of the Bridge rectifier as the input. From
other set of opposite terminals we are taking the output to the rectifier.
Rectifier: The bridge rectifier converts the AC coming from the secondary of the
transformer into pulsating DC. The output of this rectifier is further given to the smoother
circuit which is capacitor in our project. The smoothing circuit eliminates the ripples
29
Home Security System
from the pulsating DC and gives the pure DC to the RPS to get a constant output DC
voltage. The RPS regulates the voltage as per our requirement.
Microcontroller:
The microcontroller AT89S52 with Pull up resistors at Port0 and crystal oscillator of
11.0592 MHz crystal in conjunction with couple of capacitors of is placed at 18 th & 19th
pins of 89S51 to make it work (execute) properly.
IR Module:
The IR module is input device. This is connected to the port P2 of the Microcontroller
through the decoder and encoder for transmitter and receiver circuit respectively
LCD:
The LCD data lines are connected to port 0 of the microcontroller in the schematic and
the control signals like RS, EN are connected to pin2,3 of port 1.
PC Connection :
Here the PC is connected to microcontroller by using serial port of 89S52. i.e., Tx and Rx
signals (pin 10, 11)
8.2 SYSTEM TESTING
Home security is a somewhat dated term used to describe an opto-electronic means of
sensing something, most commonly a photo detector of some type. An example is the
door safety system used on garage door openers that use a light transmitter and receiver
at the bottom of the door to prevent closing if there is any obstruction in the way that
breaks the light beam. The system can be tested with the use of KEIL compiler. This one
30
Home Security System
we are using to write programs for 8051 controller. After writing programs using 8051
programmer we can dump code in to the controller. Now develop intruder detection
system by using IR transmitter and receiver with the help of 555 timer or we can use
photo diode and photo transistors. To test the board, First of all write a program in terms
of like first enable LCD. To activate LCD send proper commands to it and after that
configure baud rate, parity and number of bits for the serial port. After initializing all the
devices connected to the controller,
While testing keep the transmitter & receiver aligned in a straight position facing each
other about a distance more than 2 meter but not less than that. If the transmitter and
receiver are not in a aligned position data communication is not possible. Connect the
output of IR receiver to the controller port pin. If there is no intruder the output pin will
show low value. If there is any introduce it will show high value. In program monitor for
high value and when you the value is high sense a message to a number indicating that
intruder detected.
9. SOFTWARE COMPONENTS
Software used is:
*Keil software for C programming
*Express PCB for lay out design
31
Home Security System
*Express SCH for schematic design
KEIL µVision3
µVision3 is an IDE (Integrated Development Environment) that helps you write, compile,
and debug embedded programs. It encapsulates the following components:
A project manager.
A make facility.
Tool configuration.
Editor.
A powerful debugger.
Express PCB Express PCB is a Circuit Design Software and PCB manufacturing
service. One can learn almost everything you need to know about Express PCB from the
help topics included with the programs given.
Details: Express PCB, Version 5.6.0
Express SCH The Express SCH schematic design program is very easy to use. This
software enables the user to draw the Schematics with drag and drop options. A Quick
Start Guide is provided by which the user can learn how to use it.
Details: Express SCH, Version 5.6.0
The programming Language used here in this project is an Embedded C Language
9.1 PROGRAM CODING
void Delay(unsigned int v) //Here we are generating ms delay{
unsigned int t;for(t=0;t<v;t++)Delay_1ms();
32
Home Security System
}//===============================================void lcd_init() { Delay(1); //only for avoiding warning
Delay_30ms(); lcd_cmd(0x38); Delay_30ms(); lcd_cmd(0x01); Delay_30ms(); lcd_cmd(0x0C); Delay_30ms(); lcd_cmd(0x06); Delay_30ms(); lcd_cmd(0x80); Delay_30ms();
} void lcdcmd(unsigned char cmd) {
LCD =cmd;RS =0;RW =0;EN =1;for(i=0;i<50;i++);EN =0;for(i=0;i<50;i++);
}//===============================================void lcddata(unsigned char dat) //display_data {
LCD =dat;RS =1;RW =0;EN =1;for(i=0;i<50;i++);EN =0;for(i=0;i<50;i++);
}//===============================================//DISPLAY STRING IN of data in LCD
33
Home Security System
void lcdmessage(unsigned char *str){
while(*str!='\0') {
LCD =*str;RS =1;RW =0;EN =1;Delay_30ms();EN =0;str++;
}}
#include<lcd.h>#include<string.h>
sbit rled = P0^5;sbit gled =P0^6;sbit buzzer = P0^7;sbit IR = P3^7;
void Buzzer_OFF();void Buzzer_ON(); void fwd(); void bwd();
//***************************************************************************//**************************** MAIN PROGRAM**********************************//*************************************************************************** void main() {
unsigned char ch[5],i; lcd_init(); lcdcmd(0x01);
34
Home Security System
lcdcmd(0x85); msgdisplay("WELCOME");
delay(100);lcdcmd(0xC0);msgdisplay("SRTIST College"); delay(200);
lcdcmd(0x01);lcdcmd(0x82);
while(1) {
lcdcmd(0x01);msgdisplay("Home Security ");delay(100);lcdcmd(0xC0);msgdisplay(" System with IR "); delay(200);
delay(200);delay(200);delay(200); if(IR==0) { lcdcmd(0x01);
delay(50); lcdcmd(0x80);
msgdisplay("Itruder Detected"); Buzzer_ON();
delay(1000);delay(200);delay(200);delay(200);
Buzzer_OFF();
lcdcmd(0x01);
msgdisplay("enter password");delay(100);delay(200);delay(200);lcdcmd(0x01); for(i=0;i<4;i++){ch[i]=keypad();lcddata('*');
35
Home Security System
delay(100);delay(200);delay(200);}
if(!strcmp(ch,"1234")){
fwd();delay(100);delay(100);delay(200);delay(200);delay(100);bwd();
}
else{
delay(200); lcdcmd(0x01);
msgdisplay("Access Denied");delay(200);delay(200);delay(200);}
delay(200); } else {
lcdcmd(0x01); delay(50);
lcdcmd(0x80); msgdisplay("NO Itruder");
delay(200);}
} }//***********************// LCD CONVERSION //************************** void Buzzer_ON()
36
Home Security System
{ delay(50); lcdcmd(0xC0); msgdisplay("Alarm ON"); buzzer = 0;
delay(1000); }
void Buzzer_OFF() { delay(50); lcdcmd(0xC0); msgdisplay("Alarm OFF"); buzzer = 1;
delay(1000); }
void fwd(){int i;lcdcmd(0X01);lcdcmd(0x80);msgdisplay("ACCESS OK");lcdcmd(0xC0);msgdisplay("DOOR OPENED");
for(i=0;i<100;i++)
{P2=0x11;
}}
void bwd(){int i;lcdcmd(0xC0);
37
Home Security System
msgdisplay("DOOR CLOSED");
for(i=0;i<100;i++)
{P2=0x11;delay(5);
}
10. CONCLUSION
38
Home Security System
The controller we used having the following features like 8 bit 8051 architecture in a tiny
40 pin DIP package,128B RAM and 4kB on-chip Flash Program Memory. For low end
applications this controller is very easy to use.
In real time electronic eyes are used for a long-range straight line of site security
protection. With a photo detection range of up to hundreds of feet, a Photoelectric Beam
Sensor is the ideal infrared (IR) light beam detector.
It can also be used for “present” detection in automated manufacturing processes, garage
door security, entry detection, as a parking position sensor, or an intrusion alarm.
A focused infrared (IR) light beam is projected from the emitter and detected by the
receiver that is placed at the other side of the detection area. The photoelectric beam
sensor detects when the infrared beam is broken due to the passing of a person, or the
presence of an object, in the path of the infrared beam. A relay built into the receiver
alerts you that a breech of the beam has occurred, or that an object has entered or passed
through the photoelectric infrared beam.
The flexibility of a home security and access control system can allow you to be in many
places at one time. This is critical for a large, multi-faceted operation, like a hospital,
where a watchful eye is paramount.
11. BIBLIOGRAPHY
S.NO. Title of the Text books Author Publications Year1 8051 Micro Controller MAZIDI&MAZIDI Prentice hall 2009
39
Home Security System
and Embedded systems(2nd edition)
publications
2 8051 Micro Controller(3rd edition)
KENNETHJ.AYALA
Thomson publications
2004
3 Embedded controller hardware design
KEN ARNOLD Newnes publications
2007
11.1 WEB REFERENCES
www.beyondlogic.org/serial/serial/html
www.intersil.com
www.atmel.com
www.microcontroller.com
www.wikipedia.com
40