You are on page 1of 38

Home Security System

1. INTRODUCTION
1.1 OVERVIEW

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.

2. EMBEDDED SYSTEMS
1

Home Security System

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; 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 2

Home Security System

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

Home Security System

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

Home Security System

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.

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 5

Home Security System

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.

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

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 Atmels 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 sixvector 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.

Home Security System

Fig2: pin configurations of micro controller

Home Security System

Fig3: Block diagram of Micro controller

5.2.1 Pin Description:


10

Home Security System

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

Home Security System

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

12

Home Security System

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.

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.

13

Home Security System

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

Home Security System

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 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
15

Home Security System

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


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

16

Home Security System

fig4: Oscillator circuit

Note: C1, C2 = 30 pF 10 pF for Crystals = 40 pF 10 pF for Ceramic Resonators External Clock Drive Configuration

fig5: Oscillator connections Idle Mode 17

Home Security System

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.

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.

18

Home Security System

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

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:

19

Home Security System

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.

I/D 1 = Increment (by 1) 0 = Decrement (by 1)

R/L 1 = Shift right 0 = Shift left

S 1 = Display shift on 0 = Display shift off

DL 1 = 8-bit interface 0 = 4-bit interface

D 1 = Display on 0 = Display off

N 1 = Display in two lines 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 20

Home Security System

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.

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

21

Home Security System

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

22

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

23

Home Security System

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.

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

24

Home Security System

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

25

Home Security System

measured in X-ray, UV, visible, or IR. X-ray photodiodes are optimized for X-ray, gamma ray, and beta radiation detection.

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:

26

Home Security System

8.1.1 Schematic

J 3 L C V C C R C C U C P 2 5 9 4 8 3 7 2 6 1 C O N N E C T 4 2 6 C A P 1 4 1 3 7 8 V V A 7 3 + C C C C 1 2 1 +3 1 4 +5 2 C C A 6 P J 3 1 2 3 4 5 6 7 8 N 8 J 4 1 2 3 4 5 6 7 8 O P Y C 4 C 2 1 C D D 1 I O D DE 2 I O D D 4 I O D 6 DE I O U D E 1 V 5 G N D I N V O U 2 T C 8 R 1 0 4 R 5 A P 2 9 0 X T G N A D L 1 1 R C Y S T A L O N 8 N 8 R X D T X D 1 1 1 1 1 1 1 1 1 0 1 2 3 4 5 6 7 8 P P P P P P P P X T 3 3 3 3 3 3 3 3 . . . . . . . . A 0 1 2 3 4 5 6 7 / / / / / / / / L 2 R T I I T T W R A 1 2 3 4 5 6 7 8 9 P P P P P P P P R 1 1 1 1 1 1 1 1 S . . . . . . . . 0 1 2 3 4 5 6 7 T E A / V 3 1 P P 3 0 R 9O 2 N 2 A2 A2 A2 A2 A2 A2 8 71 61 51 41 31 21 5 4 3 2 1 0 G J 1 2 3 4 5 6 7 8 2 C O N 8 U 1 V P P P P P P P P 0 0 0 0 0 0 0 0 . . . . . . . . 0 1 2 3 4 5 6 7 C / / / / / / / / C 4 0 9 D 8 D 7 D 6 D 5 D 4 D 3 D 2 D 0 1 2 3 4 5 6 7 1 2 3 4 5 6 7 8 J 2 P C 5 V C P C 6 O T D

gnd vcc 3 R S W EN P 0 .0 P 0 .1 P 0 .2 P 0 .3 P 0 .4 P 0 .5 P 0 .6 P 0 .7 V C C G N D

V 1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 1 0 1 2 3 4 5 6

1 1 T 1 O U T T 1 I N1 2 R 1 I NR 1 O U T 1 0 T 2 O U T T 2 I N9 R 2 I NR 2 O U T

T X D R X D

1 C C C R R 4

M O R J 7 C O D N

A B 2

X 9

2 3 2

3 A3 A3 A3 A3 A3 A3 A3 A

C 1 2

3 C

t / f

i n )

6 ( 4 p

L E / P X P S E D X D N T 0 N P T2 1. 7 / 0P 2 . 6 / 1P 2 . 5 / P R2 . 4 / PD 2 . 3 / P 2 . 2 / P 2 . 1 P 2 . 0

1 2

/2A 1 9 / A 8

5 V A T 8 9 S 5 2

C = C

9 1 0 0 0 U F / 2 5 V

L M

7 8 0

5 / T O 3

T L E D D 5 S

i t l e i z e A

<

T i t l e

> e d a n t y , N u m J u l y b e r 1S 5 h , e 2e 0t 1 1 0 o f 1 R < e R v e v C o d e >

D o c < D o h u

u m c > r s

a t e : T

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

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 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: 28

Home Security System

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 18th & 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 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

29

Home Security System

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 *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. 30

Home Security System

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(); } //=============================================== void lcd_init() { Delay(1); //only for avoiding warning Delay_30ms(); lcd_cmd(0x38); Delay_30ms(); lcd_cmd(0x01); Delay_30ms(); 31

Home Security System

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 void lcdmessage(unsigned char *str) { while(*str!='\0') { LCD =*str; RS =1; RW =0; EN =1; Delay_30ms(); EN =0; str++; } } 32

Home Security System

#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); 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); 33

Home Security System

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('*'); 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); 34

Home Security System

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() { 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); 35

Home Security System

lcdcmd(0x80); msgdisplay("ACCESS OK"); lcdcmd(0xC0); msgdisplay("DOOR OPENED"); for(i=0;i<100;i++) { P2=0x11; } } void bwd() { int i; lcdcmd(0xC0); msgdisplay("DOOR CLOSED"); for(i=0;i<100;i++) { P2=0x11; delay(5); }

36

Home Security System

10. CONCLUSION
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.

37

Home Security System

11. BIBLIOGRAPHY
S.NO. Title of the Text books 1 8051 Micro Controller and Embedded systems(2nd edition) 2 8051 Micro Controller(3rd edition) 3 Embedded controller hardware design Author Publications MAZIDI&MAZIDI Prentice hall publications KENNETH J.AYALA KEN ARNOLD Thomson publications Newnes publications Year 2009 2004 2007

11.1 WEB REFERENCES


www.beyondlogic.org/serial/serial/html www.intersil.com www.atmel.com www.microcontroller.com www.wikipedia.com

38

You might also like