Upload
adiseshumidde
View
13
Download
5
Embed Size (px)
Citation preview
PIR sensor based security system using 89C52 micro controller
1
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY KAKINADA
“PIR SENSOR BASED SECURITY SYSTEM USING 89C52 MICRO-
CONTROLLER”
Submitted to
Jawaharlal Nehru Technological University Kakinada
in partial fulfillment for the award of the degree of
Bachelor of Technology
In
ELECTRONICS AND COMMUNICATION ENGINEERING
Submitted by
G.NAGA SIRISHA (12H71A0487) K.MADHU BINDU (13H75A0406)
Y.ANIL KUMAR (12H71A0463) T.KATHIK (13H75A0422)
Under the Guidance of
Mrs. A.SARADA, ME
Associate Professor& ECE department
Of
ELECTRONICS AND COMMUNICATION ENGINEERING
Devineni Venkata Ramana & Dr. Hima Sekhar
MIC College of Technology
Kanchikacherla, Krishna Dist, PIN: 521180, A.P, India.
2015-2016
PIR sensor based security system using 89C52 micro controller
2
Devineni Venkata Ramana & Dr. Hima Sekhar
MIC College of Technology Kanchikacherla, Krishna Dist, PIN: 521180, A.P, India.
CERTIFICATE
This is to certify that the Main Project entitled “PIR SENSOR BASED SECURITY
SYSTEM USING 89C52 MICRO CONTROLLER” is a bonafide work done by
G.NAGA SIRISHA (12H71A0487), K.MADHU BINDU (13H75A0406), Y.ANIL
KUMAR(12H71A0463) and T.KARTHIK (13H75A0422)in partial fulfillment for the award of
Bachelor of Technology in ELECTRONICS AND COMMUNICATION
ENGINEERING of Jawaharlal Nehru Technological University Kakinada during the
year 2015-2016.
(Mrs. A.SARADA ) (Dr. A. GURUVA REDDY)
Associate Professor Professor,Dept of ECE
Project Guide Head of the Department
(Dr.K.B.K.RAO)
Principal
Examiner 1 Examiner 2
PIR sensor based security system using 89C52 micro controller
3
ACKNOWLEDGEMENT
I would like to take this opportunity to express our deep gratitude to the members who
assisted us directly and indirectly for the completion of this project work.
I would like to thank Mrs.A.SARADA, Associate Professor in the Department of
Electronics and Communication Engineering, department the project supervisor for her
esteemed guidance and support, especially the valuable ideas and thoughts provided during
this project work. She is expertise in the area of Communication systems, this makes us
very useful in solving the problems encountered during the project work.
I would like to express our immense pleasure in expressing immeasurable sense of
gratitude to, Dr.A.GURUVA REDDY, Professor& Head of the Department in
Electronics and Communication Engineering for his valuable suggestions in the
completion of the project.
I wholeheartedly acknowledge Dr. K. B. K. RAO, Principal, Prof. N. KRISHNA,
Director Academics and Prof. D. PANDURANGA RAO, CEO for giving opportunity to
make this project a successful one.
I also extend our thanks to all the faculty members of Electronics and Communication
Engineering Department for their valuable contributions in this project.
I would like to extend our warm appreciation to all my friends for sharing their
knowledge and valuable contributions in this project.
Finally I express our deep sense of gratitude to all our parents for their continuous
support throughout our academic carrier and their encouragement in completion of this
project work successfully.
G.NAGA SIRISHA
K.MADHUBINDU
Y.ANIL KUMAR
T.KARTHIK
PIR sensor based security system using 89C52 micro controller
4
DECLARATION
I “G.NAGA SIRISHA(12H71A0487),K.MADHU BINDU(13H75A0406),YANIL
KUMAR(12H71A0463) and T.KARTHIK(12H71A0422) ”of the main project “PIR
SENSOR BASED SECURITY SYSTEM USING 89C52 MICRO CONTROLLER”,
hereby declare that the matter embodied in this project is genuine work done by me and has
not been submitted either to this university or to any other university/institute for the
fulfillment of the requirement of any course of study.
G.NAGA SIRISHA(12H71A0487)
K.MADHUBINDU(135A0406)
Y.ANIL KUMAR(12H71A0463)
T.KARTHIK(13H75A0422)
PIR sensor based security system using 89C52 micro controller
5
ABSTRACT
The main aim of this project is to develop a low cost security system using small
Pyro-electric infrared (PIR) sensor built around a micro controller. The low-power PIR
detectors take advantage of pyro electricity to detect a human body that is constant source of
Passive Infrared and is usually not at thermal equilibrium with the surrounding environment.
Detecting the presence of any unauthorized person, the system sets up a voice message and
call to a predefined number. In addition to this the system also sets alarm when it detects
smoke particles.
PIR sensor based security system using 89C52 micro controller
6
CHAPTER-1
1.1 INTRODUCTION TO EMBEDDED SYSTEMS:
An embedded system can be defined as a computing device that does a specific
focused job. Appliances such as air conditioner, VCD Player, DVD Player, Printer, FAX
Machine, Mobile phone etc are some of examples of embedded system. Each of these
appliances will have a processor and special hardware to meet the specific requirement of
application along with embedded software that is executed by the processor for meeting that
specific requirement. The embedded software is also called “FIRM WARE”. In contrast, the
software in embedded systems is always fixed listed below.
Embedded systems do a very specific task; they cannot be programmed to do different
things. Embedded systems have very limited resources, particularly memory. Generally, they
do not have secondary storage devices such as CDROM or FLOPPY DISK. Embedded
systems have to work against some dead line. A specific job has to be completed within a
specific time. In some embedded systems, called real time systems, the deadlines are
stringent. Missing a dead line cause a catastrophe-loss of life or damage to property.
Embedded systems are constrained for power. As many embedded systems operate through a
battery, power consumption has to be very low. Some embedded systems have to operate in
extreme environmental conditions such as very high temperatures and humidity.
1.2 APPLICATION AREAS
Nearly 99% of processors manufactured end up in embedded systems. The embedded
system market is one of the highest growth areas as these systems are used in every market
segment-consumer electronics, office automation, industrial automation, biomedical
engineering wireless communication, data communication, telecommunication, transportation
and so on.
Consumer Appliances:
At home we use a number of embedded systems which include digital camera, digital
diary, DVD player, electronic toys, microwave oven, remote controls etc. Today’s high-tech
car has embedded systems for transmission control, engine sparkcontrol, air conditioning,
navigation etc.
PIR sensor based security system using 89C52 micro controller
7
Office Automation:
Products using embedded systems are copying machine, fax machine, key telephone,
modems etc.
Industrial Automation:
Today a lot of industries use embedded systems for process control. These include
pharmaceutical, cement, sugar, oil exploration, nuclear energy, electricity generation and
transmission. The embedded system for industrial use are designed to carry out specific tasks
such as monitoring temperature, pressure, humidity, voltage, current etc., and then take
appropriate action based on monitored levels to control other devices or to send information
to a centralized monitoring station. In hazardous industrial environment, where human
presence has to be avoided, robots are used, which are programmed to do specific jobs.
Medical electronics:
Almost all medical equipments in hospitals are embedded systems. These equipments
include diagnostic aids such as ECG, EEG, blood pressure measuring devices, X-ray
scanners, equipment used in blood analysis, radiation, colons copy, endoscopy etc.
Developments in medical electronics have paved way for more accurate diagnosis of
diseases.
Security:
Security of persons and information has always been a major issue. We need to
protect our homes and offices and also information we transmit and store. Developing
embedded systems for security applications is one of the most lucrative businesses nowadays.
Biometric systems using fingerprint and face recognition are now being extensively used for
user authentication in banking applications as well as for access control in high security
buildings.
Finance:
Financial dealing through cash and cheques are now slowly paving way for
transactions using smart cards and ATM machines. Smartcard, of the size of a credit card, has
a small microcontroller and memory and it interacts with smartcard reader! ATM machine
acts as an electronic wallet. Smartcard technology has capability of ushering in a cashless
PIR sensor based security system using 89C52 micro controller
8
society. Well, the list goes on. It is no exaggeration to say that eyes where ever you go, you
can see, the work of an embedded system.
1.3 EMBEDDED SYSTEM ARCHITECTURE
Every embedded system consists of custom-built hardware built around a Central
Processing Unit (CPU). This hardware also contains memory chips onto which the software
is loaded. The software residing on the memory chip is also called the ‘firm’. The embedded
system architecture can be represented as a layered architecture as shown in Fig.
Fig 1.3 Layered Architecture
The operating system runs above the hardware, and the application software runs
above the operating system. The same architecture is applicable to any computer including a
desktop computer. However, there are significant differences. It is not compulsory to have an
operating system in every embedded system. For small appliances such as remote control
units, air conditioners, toys etc., there is no need for an operating system and you can write
only the software specific to that application. For applications involving complex processing,
it is advisable to have an operating system. In such a case, you need to integrate the
application software with the operating system and then transfer the entire software on to the
memory chip. Once the software is transferred to the memory chip, the software will continue
to run for a long time you don’t need to reload new software.
Now, let us see the details of the various building blocks of the hardware of an
embedded system.
Hardware
Operating system
Application software
PIR sensor based security system using 89C52 micro controller
9
Fig1.3.1: The Building Blocks
Central Processing Unit (CPU)
Memory (Read-only Memory and Random Access Memory)
Input Devices
Central Processing Unit (CPU):
The Central Processing Unit (processor, in short) can be any of the following:
microcontroller, microprocessor or Digital Signal Processor (DSP). A micro-controller is a
low-cost processor. Its main attraction is that on the chip itself, there will be many other
components such as memory, serial communication interface, analog-to digital converter etc.,
so, for small applications, a micro-controller is the best choice as the number of external
components required will be very less. On the other hand, microprocessors are more
powerful, but you need to use many external components with them. DSP is used mainly for
applications in which signal processing is involved such as audio and video processing.
Memory:
The memory is categorized as Random Access Memory (RAM) and Read Only
Memory (ROM). The contents of the RAM will be erased if power is switched off to the
chip, whereas ROM retains the contents even if the power is switched off. So, the firmware is
PIR sensor based security system using 89C52 micro controller
10
stored in the ROM. When power is switched on, the processor reads the ROM; the program is
executed.
Input devices:
Unlike the desktops, the input devices to an embedded system have very limited
capability. There will be no keyboard or a mouse, and hence interacting with the embedded
system is no easy task. Many embedded systems will have a small keypad-you press one key
to give a specific command. A keypad may be used to input only the digits. Many embedded
systems used in process control do not have any input device for user interaction; they take
inputs from sensors or transducers, produce electrical signals that are in turn fed to other
systems.
Output devices:
The output devices of the embedded systems also have very limited capability. Some
embedded systems will have a few Light Emitting Diodes (LEDs) to indicate the health status
of the system modules, for visual indication of alarms. A small Liquid Crystal Display (LCD)
may also be used to display some important parameters.
Communication interfaces:
The embedded systems may need to interact with other embedded systems at they
may have to transmit data to a desktop. To facilitate this, the embedded systems are provided
with one or few communication interfaces such as RS232, RS422, RS485, Universal Serial
Bus (USB), and IEEE 1394, Ethernet etc.
Application-specific circuitry:
Sensors, transducers, special processing and control circuitry may be required for an
embedded system, depending on its application. This circuitry interacts with the processor to
carry out the necessary work. The entire hardware has to be given to power supply either
through the 230 volts main supply or through a battery. The hardware has to design in such a
way that the power consumption is minimized.
PIR sensor based security system using 89C52 micro controller
11
1.4 BLOCK DIAGRAM
Figure1.4:Block diagram
Nowadays life style has become very fast and busy and it is not possible to continuously track
the alarming events. Hence, the automation of capturing the events and communicating them
has become necessity. To achieve this we have developed the system named “PIR SENSOR
BASED SECURITY SYSTEM USINGMICRO CONTROLLER”.
If a sensor detectsany unauthorized situation then the system triggers an alarm and initiates
call to the configured mobile number. This system can be used in many applications such as offices,
companies and home. For this, a smoke sensor, a PIRsensoralong withGSM are used.
The Microcontroller interprets the received call from the SIM within GSM and
initiates the required action.The Microcontroller will continuously check the status of the
sensor. If any of the sensor’s condition breaks, then the Microcontroller detects that and sends
respective CALL through Mobile to the concerned person, so that the person can take further
action. Thus the system can secure the respective situation.
PIR sensor based security system using 89C52 micro controller
12
CHAPTER-2
SYSTEM DESIGN
This chapter clearly explainsthe Block Diagram and its description, its Hardware details and
Software details.
2.1 BLOCK DIAGRAM
Fig: 2.1 Block Diagram of Project
2.1.1.PIR Sensor:
This sensor continuously checks entry to the room.
Sensing element :dual type
Element Size: 2 1 mm
Spacing: 1 mm
Operating Voltage: 12 V
Operating Temperature -10~400centigrade
Storage Temperature -40~800centigrade
MICRO CONTROLLER
89C52
PIR
POWER SUPPLY 5V
GSM module GSM mobile Comparator
Threshold
level
Buzzer
Smoke
Sensor
Reset
ALPHA NUMERIC LCD
PIR sensor based security system using 89C52 micro controller
13
2.1.2. Micro Controller:(89C52)
The specifications for this are
-8051 Family – AT89C52
-Voltage - 5v
-Operating frequency - < 24 MHz
2.1.3 Smoke Sensor:
FEATURES:
Wide detecting scope
Fast response and High sensitivity
Stable and long life
Simple drive circuit
2.1.4. GSM Modem:(Model - SIM 900)
The specifications for this are
Voltage -+12 V
Current - 20mamp
Distance - Unlimited
2.1.5. Buzzer:
It is used to bring attention for any faulty operation detected.
2.1.6. LCD:
It is a 2*16 LCD which is mainly used for displaying any message. Data entering and
message acknowledgement can be displayed through this microcontroller.
2.2 Hardware Requirement:
1. Micro controller (8051)
2.GSM module
3.Buzzer
4.Alpha-numeric LCD display
5. Smoke sensor
6. PIR sensor
PIR sensor based security system using 89C52 micro controller
14
2.3 Software Requirement:
Programming on AT89C52 MC
- AT Commands
- Knowledge on GSM Modem
PIR sensor based security system using 89C52 micro controller
15
CHAPTER-3
Hardware Description
3.1 Introduction
This chapter clearly explains the details of Hardware components that are used in this project
i.e., circuit, Interfacings of various components
CIRCUIT DIAGRAM:
Figure:3.1.1 circuit diagram
PIR sensor based security system using 89C52 micro controller
16
3.2PIR SENSOR:
General Description:
The PIR (Passive Infra-Red) Sensor is a pyroelectric device that detects motion by measuring
changes inthe infrared levels emitted by surrounding objects. This motion can be detected by
checking for a high signal on a single I/O pin.
Figure3.2.1: PIRSensor (side view) and (top view)
Features Single bit output
Small size
Compatible with all Parallax microcontrollers
3.2.1Theory of Operation
Pyroelectric devices, such as the PIR sensor, have elements made of a crystalline material
that generates an electric charge when exposed to infrared radiation. The changes in the
amount of infrared striking the element change the voltages generated, the devicecontains a
special filter called a Fresnel lens, which focuses the infraredsignals onto the element. As
PIR sensor based security system using 89C52 micro controller
17
theambient infrared signals change rapidly, the on-board amplifier trips the output to indicate
motion.
Fig3.2.1.1:pir sensor
3.2.2Pin description and Ratings
Pin Name Function
- GND Connect To Ground Or Vss
+ V+ Connects To +VddOr VDC
Out OUTPUT Connects To I/O Pin Set To
INPUT Mode
3.2.3Principle of PIR sensor:
Every object that has a temperature above 0oC emits thermal energy (heat) in form of
radiation. Homo sapiens, radiate at wavelength of 9-10micrometers all time of the day. The
PIR sensors are tuned to detect this IR wavelength which only emanates when a human
being arrives in their proximity. The term “pyro electricity” means heat that generates
electricity (here, an electric signal of small amplitude). Since these sensors do not have an
infrared source of their own, they are also termed as passive.
PIR sensor based security system using 89C52 micro controller
18
Fig3.2.3.1: schematic diagram of PIR sensor
3.3 MICROCONTROLLER 89C52:
INRODUCTION TO MICRO CONTROLLER:
Definition:
Like most computers, microcontrollers are simply general-purpose Instruction executors. The
real star of a computer system is a program of instructions that is provided by a human
programmer. This program Instructs the computer to perform long sequences of very simple
actions to accomplish useful tasks as intended by the programmer like most computers,
microcontrollers are simply general-purpose Instruction executors. The real star of a
computer system is a program of instructions that is provided by a human programmer. This
program instructs the computer to perform long sequences of very simple actions to
accomplish useful tasks as intended by the programmer
PIR sensor based security system using 89C52 micro controller
19
3.3.1: FEATURES:
Compatible with MCS-51 Products.
8K Bytes of In-System Reprogrammable Flash Memory.
Endurance: 1,000 Write/Erase Cycles.
Fully Static Operation: 0 Hz to 24 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.
Programmable Serial Channel.
Low Power Idle and Power Down Mode
3.3.2: PIN DIAGRAM AND ITS DESCRIPTIONIPTION:
Fig 3.3.2: Pin Diagram
PIR sensor based security system using 89C52 micro controller
20
. 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 AT89C52 is a powerful microcomputer which
provides a highly flexible and cost effective solution to many embedded control
applications.
The AT89C52 provides the following standard features: 4 Kbytes of Flash, 256 bytes of
RAM, 32 I/O lines, two 16-bit timer/counters, a five vector two-level interrupt
architecture, a full duplex serial port, on-chip oscillator and clock circuitry. In addition,
the AT89C52 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 hardware reset.
3.3.3: ARCHITECTURE OF 89C52
PIR sensor based security system using 89C52 micro controller
21
Fig 3.3.3:Architecture of 89C52
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 bi-directional 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
PIR sensor based security system using 89C52 micro controller
22
also receives the low-order address bytes during Flash programming and program
verification.
Alternate functions of port 1
PORT PIN ALTERNATE FUNCTIONS
P1.0 T2(external count input to timer/counter2),clock-out
P1.1 T2EX(Timer /counter 2 capture/reload trigger and direction control)
P1.5 MOSI(used for In-System programming)
P1.6 MISO(used for In- System programming)
P1.7 SCK(used for In-System programming)
Table: 3.3.3.1
Port 2:
Port 2 is an 8-bit bidirectional I/O port with internal pullups. 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 pullups.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 A,@DPTR). In this application it
uses strong internal pull-ups when emitting 1s. During accesses to external data memory that
uses 8-bit addresses (MOVX A,@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 pullups. 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 pullups and can be used as inputs. As inputs, Port 3 pins that are externally being
pulled low will source current (IIL) because of the pullups. Port 3 also serves the functions of
various special features of the AT89C52 as listed below:
PIR sensor based security system using 89C52 micro controller
23
Alternate functions of port 3
PORT PIN ALTERNATE FUNCTIONS
P3.0 RXD (serial input port)
P3.1 TXD(serial output port)
P3.2 INT0(low external interrupt 0)
P3.3 INT1(low external interrupt 1)
P3.4 T0(timer 0 external input)
P3.5 T1(timer 1 external input)
P3.6 WR(low external data memory write
strobe)
P3.7 RD(low external data memory read strobe)
Table: 3.3.3.2
RST:
RST means RESET; 89C52 uses an active high reset pin. It must go high for two
machine cycles. The simple RC circuit used here will supply voltage (Vcc) to reset pin until
capacitance begins to charge. At a threshold of about 2.5V, reset input reaches a low level
and system begin to run.
Fig: 3.3.3.3: Reset Connection
PIR sensor based security system using 89C52 micro controller
24
ALE/PROG:
Address Latch Enable output pulse for latching the low byte of the address during
accesses to external memory. This pin is also the program pulse input (PROG) during Flash
programming. In normal operation ALE is emitted at a constant rate of 1/6 the oscillator
frequency, and may be used for external timing or clocking purposes. Note, however, that one
ALE pulse is skipped during each access to external Data Memory. If desired, ALE operation
can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only
during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the
ALE-disable bit has no effect if the microcontroller is in external execution mode.
PSEN:
Program Store Enable is the read strobe to external program memory. When the
AT89C52 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 OOOOH 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.
T2: External count input to Timer/Counter 2, Clock out.
PIR sensor based security system using 89C52 micro controller
25
T2EX: Counter 2 capture/reload trigger & direction control.
3.3.4: THE ON-CHIP OSCILLATORS
Pins XTAL1 and XTAL2 are provided for connecting a resonant network to form an
oscillator. The crystal frequency is basic internal clock frequency. The maximum and
minimum frequencies are specified from 1to 24MHZ.
Program instructions may require one, two or four machine cycles to be executed
depending on type of instructions. To calculate the time any particular instructions will take
to be executed, the number of cycles ‘C’,
T = C*12d / Crystal frequency
Here, we chose frequency as 11.0592MHZ. This is because,
baud= 2*clock frequency/(32d. 12d[256d-TH1]).The oscillator is chosen to help generate
both standard and nonstandard baud rates. If standard baud rates are desired, an 11.0592MHZ
crystal should be selected. From our desired standard rate, TH1 can be calculated. The
internally implemented value of capacitance is 33 pf.
Fig 3.3.4: On-Chip Oscillators
Program Memory Lock Bits:
On the chip there are three lock bits which can be left unprogrammed (U) or can be
programmed (P) to obtain the additional features .When lock bit 1 is programmed, the logic
PIR sensor based security system using 89C52 micro controller
26
level at the EA pin is sampled and latched during reset. If the device is powered up without a
reset, the latch initializes to a random value, and holds that value until reset is activated. It is
necessary that the latched value of EA be in agreement with the current logic level at that pin
in order for the device to function properly.
Program Counter and Data Pointer:
The 89C52 contains two 16-bit registers: the program counter (PC) and the data
pointer (DPTR), Each is used to hold the address of a byte in memory. The PC is the only
register that does not have an internal address. The DPTR is under the control of program
instructions and can be specified by its 16-bit name, DPTR, or by each individual byte name,
DPH and DPL. DPTR does not have a single internal address, DPH and DPL are each
assigned an address.
A & B Registers:
The 89C52 contains 34 general-purpose, working, registers. Two of these, registers A
and B, hold results of many instructions, particularly math and logical operations, of the
89C52 CPU. The other 32 are arranged as part of internal RAM in four banks, B0-B3, of
eight registers. The A register is also used for all data transfers between the 89C52 and any
external memory. The B register is used for with the A register for multiplication and division
operations.
Flags and the Program Status Word (PSW):
Flags may be conveniently addressed, they are grouped inside the program status
word (PSW) and the power control (PCON) registers.
The 89C52 has four math flags that respond automatically to the outcomes of math
operations and three general-purpose user flags that can be set to 1 or cleared to 0 by the
programmer as desired. The math flags include Carry (C), Auxiliary Carry (AC), Overflow
(OV), and Parity (P). User flags are named F0,GF0 and GF1, they are general-purpose flags
that may be used by the programmer to record some event in the program.
3.3.5: MEMORY ORGANISATION
PIR sensor based security system using 89C52 micro controller
27
Internal Memory:
The 89C52 has internal RAM and ROM memory for the functions. Additional
memory can be added externally using suitable circuits. This has a Hardware architecture,
which uses the same address, in different memories, for code and data.
Internal RAM:
The 256-byte internal RAM. The upper 128 bytes occupy a parallel address space to
the Special Function Registers. Instructions that use indirect addressing access the upper 128
bytes of RAM. Stack operations are examples of indirect addressing.
Internal Data Memory addresses are always one byte wide, which implies an address
space of only 256 bytes. However, the addressing modes for internal RAM can in fact
accommodate 384 bytes, using a simple trick. Direct addresses higher than 7FH access one
memory space, and indirect addresses higher than 7FH access a different memory space.
Thus Figure shows the Upper 128 and SFR space occupying the same block of addresses,
80H through FFH, although they are physically separate entities.
FFH
EDH
BOH
AOH
Figure:3.3.5.1:internal RAM memory
ACC
PORT 3
PORT2
PORT1
PORT0
PIR sensor based security system using 89C52 micro controller
28
The Lower 128 bytes of RAM are present in all 89C52 devices as mapped in Figure.
The lowest 32 bytes are grouped into 4 banks of 8 registers. Program instructions call out
these registers as R0 through R7.
Two bits in the Program Status Word (PSW) select which register bank is in use. This
allows more efficient use of code space, since register instructions are shorter than
instructions that use direct addressing. The next 16 bytes above the register banks form a
block of bit addressable memory space. The 89C52 instruction set includes a wide selection
of single-bit instructions, and the 128 bits in this area can be directly addressed by these
instructions. The bit addresses in this area are 00H through 7FH. All of the bytes in the
Lower 128 can be accessed by either direct or indirect addressing.
The Upper 128 can only be accessed by indirect addressing. SFRs include the Port
latches, timers, peripheral controls, etc. These registers can only be accessed by direct
addressing. Sixteen addresses in SFR space are both byte- and bit-addressable. The bit-
addressable SFRs are those whose address ends in OH or 80H.
Figure:3.3.5.2 UPPER 128 BYTES OF INTERNAL RAM
No bit –addressable
space
Su00465
Su00465 Su00465
FFH
80H
PIR sensor based security system using 89C52 micro controller
29
The Stack and Stack Pointer:
The stack refers to an area of internal RAM that is used in conjunction with certain
opcodes to store and retrieve data quickly. The 8-bit stack pointer register is used by the
89C52 to hold an internal RAM address that is called the top of the stack. The address held in
the SP register is the location in internal RAM where the last byte of data was stored by a
stack operation. When data is to be placed on the stack, the SP increments before storing data
on the stack so that the stack grows up as data is stored. As data is retrieved from the stack,
the byte is read from the stack, then the SP decrements to point to the next available byte of
stored data.
3.3.6: SPECIAL FUNCTION REGISTERS
The 89C52 operations that do not use the internal 128-byte RAM addresses from 00h
to 7Fh are done by a group of specific internal registers, each called a Special Function
register, which may be addressed much like internal RAM, using addresses from 80h to FFh.
PC is not part of the SFR and has no internal RAM address
T2CON Address=0C8H
Bit addressable Reset value=0000 000B
Bit
Table: 3.3.6.1
T2MOD Address=0C9H
Not bit addressable Reset value=XXXX XX00B
Bit
Table: 3.3.6.2
TF2 EXF2 RCLK TCLK EXEN2 TR2 C/T2(LOW) CP/RL2(LOW)
7 6 5 4 3 2 1 0
- - - - - - T20E DCEN
7 6 5 4 3 2 1 0
PIR sensor based security system using 89C52 micro controller
30
Name Function
A
B
DPH
DPL
IE
IP
P0
P1
P2
P3
PCON
PSW
SCON
SBUF
SP
TMOD
TCON
TL0
TH0
TL1
TH1
Accumulator
Arithmetic
Addressing external memory
Addressing external memory
Interrupt enable control
Interrupt priority
Input/output port latch
Input/output port latch
Input/output port latch
Input/output port latch
Power control
Program status word
Serial port control
Serial port data buffer
Stack pointer
Timer/counter mode control
Timer/counter control
Timer 0 low byte
Timer 0 high byte
Timer 1 low byte
Timer 1 highbyte
Figure:3.3.6.3 Special function registers
3.4 SMOKE SENSOR:
This alarm device that automatically detects the presence of smoke. It is also called
as smoke alarm.
3.4.1Features
Wide detecting scope
Fast response and High sensitivity
Stable and long life
Simple drive circuit
PIR sensor based security system using 89C52 micro controller
31
Fig: 3.4.1.1 Smoke Sensor
3.4.2 Photoelectric Smoke Detector Operation
Smoke produced by a fire affects the intensity of a light beam passing through air. The smoke
can block or obscure the beam. It can also cause the light to scatter due to reflectionfrom the
smoke particles. Photoelectric smoke detectors are designed to sense smoke by utilizing these
effects of smoke on light.
3.5 POWER SUPPLY
The supply given is the +5V D.C. The input a.c. supply is stepped down from 230V to
9-0-9V. The rectifier consists of diodes D1 and D2 makes the supply D.C. that is,
unidirectional waveform. The output from rectifier is a URDC, whose value is 12.726V peak
to peak. The voltage regulator makes this URDC to RDC of +5V. The capacitor C1 is used to
maintain constant voltage between two consecutive positive cycles where as C2 is used to
remove the fluctuations caused by regulator.
PIR sensor based security system using 89C52 micro controller
32
Figure 3.5. Block Diagram Of R.P.S
A regulated power supply maintains the output voltage constant irrespective of A.C.
mains fluctuations or load variations. The output voltage remains constant whether the load
current changes or there are fluctuations in the input A.C voltage.
The rectifier converts the transformer secondary A.C voltage into pulsating voltage. The
pulsating D.C. voltage is applied to the capacitor filter. This filter reduces the pulsationsin the
rectifier D.C. output voltage. Finally, it reduces the variations in the filtered output voltage.
3.5.1 Circuit diagram of R.P.S
Fig:3.5.1 Circuit diagram of power supply
1. There are considerable variations in A.C line voltage caused by outside factors
beyond our control. This changes the D.C. output voltage. Most of the electronic
PIR sensor based security system using 89C52 micro controller
33
circuits will refuse to work satisfactorily on such output voltage fluctuations. This
necessities to use regulated D.C. power supply.
2. The internal resistance of ordinary power supply in relatively large. Therefore, output
voltage is markedly affected by the amount of load current drawn from the supply.
3. These variations in D.C. voltage may cause erratic operation of electronic circuits.
4. Therefore, regulated D.C. power supply is the only solution in such situations.
3.6 BUZZER
A buzzer or beeper is a signaling device, usually electronic, typically used in
automobiles, household appliances such as a microwave oven, or game shows. It most
commonly consists of a number of switches or sensors connected to a control unit that
determines if and which button was pushed or a preset time has lapsed, and
usuallyIlluminates a light on the appropriate button or control panel, and sounds a warningin
the form of a continuous or intermittent buzzing or beeping sound. Initially this device was
based on an electromechanical system which was identical to an electric bell without the
metal gong (which makes the ringing noise). Often these units were anchored to a wall or
ceiling and used the ceiling or wall as a sounding board. Another implementation with some
AC-connected devices was to implement a circuit to make the AC current into a noise loud
enough to drive a loudspeaker and hook this circuit up to a cheap 8-ohm speaker. Now-a-
days, it is more popular to use a ceramic-based piezo-electric sounder like a Sonalert which
makes a high-pitched tone. Usually these were hooked up to driver” circuits which varied the
pitch of the sound or pulsed the sound on and off.
3.6.1 Buzzer Driver:
FIG: 3.6 .1CIRCUIT DIAGRAM
The circuit is designed to control the buzzer. The buzzer ON and OFF is controlled by the
pair of switching transistors (BC 547). The buzzer is connected in the Q2 transistor collector
VCC
Q?BC547
D?4007
+
12 V
-
Buz
µC PORT
PIR sensor based security system using 89C52 micro controller
34
terminal. When high pulse signal is given to base of the Q1 transistors, the transistor is
conducting and close the collector and emitter terminal so zero signals is given to base of the
Q2 transistor. Hence Q2 transistor and buzzer is turned OFF state.
When low pulse is given to base of transistor Q1, the transistor is turned OFF. Now 12V is
given to base of Q2 transistor so the transistor is conducting and buzzer is energized and
produces the sound signal.
Figure 3.6.2 Buzzer
3.7 MAX 232C
The TTL signals output by a USART are not suitable for transmission over long distances,
so these signals are converted to some other form to be transmitted. With a jumper between
the points numbered 7 and 8, a high on the TxD output of the 8251A produces a high on the
base of the transistor, which turns it off. With points numbered 9 and 10 jumped, the CR TX
line will then be pulled to -12V, which is a legal high or marking condition for RS-232C. A
low on the TxD output of the 8251A will turn on the transistor and pull the CR TX line to
+5V, which is legal low or space condition for RS- 232C.
PIR sensor based security system using 89C52 micro controller
35
TI IN 11 14 T1 OUT
T2 IN 10 7 T2 OUT
R1 OUT 12 13 R1 IN
R2 OUT 9 8 R2 IN
Figure: 3.7.1 Logic Diagram of MAX232
3.8 GSM MODEM
GSM (Global System for Mobile communications) is the technology that underpins
most of the world's mobile phone networks. The GSM platform is a hugely successful
wireless technology and an unprecedented story of global achievement and cooperation.
GSM has become the world's fastest growing communications technology of all time and the
leading global mobile standard, spanning 218 countries. GSM is an open, digital cellular
technology used for transmitting mobile voice and data services. GSM operates in the
900MHz and 1.8GHz bands GSM supports data transfer speeds of up to 9.6 kbps, allowing
the transmission of basic data services such as SMS.
PIR sensor based security system using 89C52 micro controller
36
Fig:3.8.1 GSM Module
3.8.1GSM SIM300/900
GSM/GPRS RS232 Modem is built with SIMCOM Make SIM900 Quad-band
GSM/GPRS engine, works on frequencies 850 MHz, 900 MHz, 1800MHz and 1900 MHz .It
is very compact in size and easy to use as plug in GSM Modem. The Modem is designed with
RS232 Level converter circuitry, which allows you to directly interface PC Serial port .
3.8.2 Features:
• High Quality Product (Not hobby grade)
• Quad-Band GSM/GPRS
• 850/ 900/ 1800/ 1900 MHz
• Built in RS232 Level Converter (MAX3232)
• Configurable baud rate
• SMA connector with GSM L Type Antenna.
• Built in SIM Card holder.
• Built in Network Status LED
• Inbuilt Powerful TCP/IP protocol stack for internet data transfer over GPRS
• Audio interface Connector
• Most Status & Controlling Pins are available at Connector
• Normal operation temperature: -20 °C to +55 °C
• Input Voltage: 5V-12V DC
PIR sensor based security system using 89C52 micro controller
37
3.8.3 Specifications:
• Quad-Band 850/ 900/ 1800/ 1900 MHz
• GPRS multi-slot class 10/8
• GPRS mobile station class B
• Compliant to GSM phase 2/2+
Class 4 (2 W @850/ 900 MHz)
Class 1 (1 W @ 1800/1900MHz)
• Dimensions: 24*24*3mm
• Weight: 3.4g
• Control via AT commands (GSM 07.07,07.05 and SIMCOM enhanced AT Commands)
• Low power consumption: 1.0mA(sleep mode)
• Operation temperature: -40°C to +85 °C\
3.8.4Special firmware
• MMS
• Java (cooperate with isolation)
• Embedded AT
Figure 3.8.4.1 SIM900
PIR sensor based security system using 89C52 micro controller
38
3.9 LIQUID CRYSTAL DISPLAY
To understand the operation of an LCD, it is easiest to trace the path of a light
ray from the backlight to the user. The light source is usually located directly behind the
LCD, and can use either LED or conventional fluorescent technology. From this source, the
light ray will pass through a light polarizer to uniformly polarize the light so it can be acted
upon by the liquid crystal (LC) matrix. The light beam will then pass through the LC matrix,
which will determine whether this pixel should be “on” or “off”. If the pixel is “on”, the
liquid crystal cell is electrically activated, and the molecules in the liquid will align in a
single direction. This will allow the light to pass through unchanged. If the pixel is “off”, the
electric field is removed from the liquid, and the molecules with in scatter. This dramatically
reduces the light that will pass through the display at that pixel.
INTERFACING LCD TO THE MICROCONTROLLER:
This is the first interfacing example for the parallel port. We will star with
something simple. This example does not use the Bi-directional feature found on newer ports,
thus it should work with most, ifnot all Parallel Ports. It however does not show the use of the
status port as an input. So what are we interfacing? A 16 Character X 2 Line LCD Module to
the Parallel Port. These LCD Modules are very common these days, and are quite simple to
work with, as all the logic required running them is on board.
3.9.1 Features:
Interface with either 4-bit or 8-bit microprocessor.
Display data RAM
Character generator ROM
-matrix character patterns.
Character generator RAM
-matrix patterns.
Display data RAM and character generator RAM may be
Accessed by the microprocessor.
PIR sensor based security system using 89C52 micro controller
39
Numerous instructions
Clear Display, Cursor Home, Display ON/OFF, Cursor
ON/OFF, Blink Character, Cursor Shift, Display Shift.
Built-in reset circuit is triggered at power ON.
Figure3.9.2A general purpose alphanumeric LCD with two lines of 16 characters.
Pin diagram:
Figure: 3.9.3 pin diagram
Pin symbol Function
1 Vss Power Supply (Gnd)
2 Vdd Power Supply (+5v)
PIR sensor based security system using 89C52 micro controller
40
3 V0 Contrast Adjust
4 Rs Instruction /Data Register
Select
5 R/W Data Bus Line
6 E Enable Signal
7-14 Db0-Db7 Data Bus Line
15 A Power Supply For Led B/L
(+)
16 K Power Supply For Led B/L(-)
Figure:3.9.4 pin description
PIR sensor based security system using 89C52 micro controller
41
CHAPTER-4
4.FLOWCHART AND SOFTWARES
Serial port initialization
LCD Initialization
PIR Sensor SMOKE sensor
IF motion detected
If smoke Detected
Initialize GSM
Default Message transfers to GSM
GSM transfer Voice message to owner
Buzzer activated
stop
Buzzer on
start
PIR sensor based security system using 89C52 micro controller
42
4.1Soft wares Used:
1. Assembly language for 8052
2. 8052 Cross compiler
3. Universal Programmer soft ware
4. ORCAD for PCB designing and layout.
Universal Programmer soft ware
PIR sensor based security system using 89C52 micro controller
43
4.2Programming language for 8052
Programming languages share properties with natural languages related to their purpose as
vehicles for communication, having a syntactic form separate from its semantics, and
showing languages families of related languages branching one form another. But as artificial
constructs they also differ in fundamental ways from languages that have evolved through
usage.
A significant difference is that programming language can be fully described and studied in
its entirety, since it has a precise and finite definition. By contrast, natural languages have
changing meanings given by their users in different communities.
While constructed languages are also artificial languages designed from the ground up with a
specific purpose, they lack the precise and complete semantic definition that a programming
language has.
Many programming languages have been designed from scratch, altered to meet new needs
and combined with other languages. Many have eventually fallen into disuse. Although there
PIR sensor based security system using 89C52 micro controller
44
have been attempts to design one “universal” programming language that servers all
purposes all of them have failed to be generally accepted as filling this role. The need for
reverse programming languages arises from the diversity of contest in which language are
used.
Programs range from tiny scripts written by individual hobbyists to huge systems written by
hundreds of programmers.
Programmers ranging expertise from novices who need simplicity above all else, to experts
who may be comfortable with considerable complexity.
Programs must balance speed, size, and simplicity on systems ranging from microcontroller
to super computers.
Programs may be written once and not change for generations, or they may undergo continual
modification.
Programmers may simply differ in their tastes: they may be accustomed to discussing
problems and expressing them in a particular language
One common trend in the development of programming languages has been to add more
ability to solve problems using a higher level abstraction. The abstraction. The earliest
programming languages were tied very closely to the underlying hardware of the computer.
As new programming languages have developed, features have been added that let
programmers express ideas that are more remote from simple translation into underlying
hardware instructions. Because programmers are less tied to the complexity of the computer,
their programmers can do more computing with less effort from the programmer. This lets
them write more functionality per time unit.
4.3 8052 Cross compiler
A cross compiler is a compiler capable of creating executable code for a platform other than
the one on which the compiler is running. For example, a compiler that runs on a Windows 7
PC but generates code that runs on Android smartphone is a cross compiler.
PIR sensor based security system using 89C52 micro controller
45
A cross compiler is necessary to compile for multiple platforms from one machine. A
platform could be infeasible for a compiler to run on, such as for the microcontroller of an
embedded system because those systems contain no operating system. In par virtualization
one machine runs many operating systems, and a cross compiler could generate an executable
for each of them from one main source.
Cross compilers are not to be confused with source to source compilers. A cross compiler is
for cross platform software development of binary code, while a source to source "compiler"
just translates from one programming language to another in text code. Both are programming
tools.
4.4 ORCAD for PCB designing and layout
Steps to PCB design using Orcad.
1. Design circuit using schematic entry package (Capture).
2. Generate net list for PCB package.
3. Import net list into PCB package (Layout Plus).
4. Place components, route signals.
5. Generate machining (Gerber) files for PCB plant.
This document is a 'quick start', describing some of the most commonly used operations for
PCB design using Orcad. For more details see on-line help and also the pdf manuals which
are usually in Program Files\Orcad\Document. These pdf files seem generally much more
comprehensive than the on-line help.
Schematic Design
• Use Capture to enter your design. Multiple schematic pages for same design can be used.
• Tip: label nets you may want to locate at the PCB stage – net names are carried through to
the PCB design process.
• Select project in project window (as opposed to schematic window), select
Design Rule Check for Tools menu. Correct any errors in design.
• Select project in project window, select Create Net list from Tools menu.
Choose Layout tab (to generate Layout compatible net list), generate net list.
Choose units (English or metric) compatible with what you will use in your
PIR sensor based security system using 89C52 micro controller
46
PCB design.
PCB Layout
• Run Layout Plus. Choose File/New.
• Select a “technology file” appropriate for your design. These are in Program
Files\Orcad\Layout Plus\data and set defaults for things like track spacing, hole sizes etc.
Some examples:
1BET_ANY.TCH – allows single track between pins on standard DIP;
2BET_SMT.TCH – for surface mount and mixed smt/through hole designs, 2 tracks
between pins of standard DIP;
3BET_THR.TCH – through hole boards, up to 3 tracks between pins.
You're best using 1bet_any.tch if at all possible, since this is the least demanding pcb
technology.
• Choose your net list file (.mnl extension). If the units (English/metric) are not the same you
won't be able to load it. Just go back to Capture and generate the net list again with the right
units.
• If some of your components chosen from the Orcad Capture libraries did not
School of Engineering Orcad PCB Quick Start have PCB footprints associated with them you
will get “Cannot find footprint for...” messages. If this happens, choose “link existing
footprint to component”. Browse footprint libraries to find the required footprint
(Preview of footprint shown on screen). You can often guess footprints from names.
Examples:
TM = through hole mounted (as opposed to surface mount)
BCON100T = block connector, 0.1” pitch, through hole
BLKCON.100/VH/TM1SQ/W.100/3 = block connector, 0.1” pitch, vertical (as opposed to
right angle), through hole, pin 1 square pad, width 0.1”, 3 pins.
Library DIP100T = dual in line packages, through hole, 0.1” between pins.
If you can't find the right footprint then you'll need to make your own. See
“Creating a new Footprint” at the end of this document.
Draw Board Outline
• Click obstacle toolbar button.
PIR sensor based security system using 89C52 micro controller
47
• Somewhere in design, right click, select new.
• Right click again, select properties.
• Select: board outline, width = 50 (or as required), layer = global layer, OK.
• Left click to place one corner of board, then right click on successive corners. Draw a board
the required size. Right click, select finish when done
(Only need to do 3 corners, finish will complete the outline). Notice that the dimensions are
shown on status bar at bottom of screen as you draw the board – can be helpful for creating
particular board size. (You can do all this later, after you've placed and routed everything if
you prefer.)
Choose Layers
• Use spreadsheet toolbar button to see the Layers spreadsheet.
• Enable only the layers you want for routing, set other layers to unused
(Double click on the spreadsheet entry, select unused routing). For a single sided board you
probably want only the “bottom” layer, for double sided you
Probably want “top” and “bottom”, for a 4 layer board you probably want these plus power
and ground plane layers. Tip: you can select multiple layers using click with ctrl key, then
right click, select properties, then set/clear unused routing to simultaneously enable or disable
several layers.
Place Components
• Select “component” tool from toolbar, click on required component and drag it where you
want. Right click to see some options, including rotate.
• Auto/place board will attempt to place components automatically for you within board
outline. You may want to move components manually as well.
School of Engineering Orcad PCB Quick Start
Track Thickness
PIR sensor based security system using 89C52 micro controller
48
• To change, select “nets” spreadsheet, double click on required net to set its properties. Net
names are inherited from your schematic diagram – explicitly naming nets helps you identify
them in the PCB design. For a simple through hole board you probably want about 20mil
tracks. For surface mount boards you probably want 10 or 12 mil tracks. Our PCB plant will
make 5 mil tracks if you really need them, but there's an increased risk of part of the track
being lost in the etching process. 10 or 12 mil can be reliably made. You may want to make
power and ground tracks thicker.
Routing
• Automatic routing is ok, but you can manually route as well (use toolbar buttons).
• Make sure you've set the track thicknesses as you want before routing (see above).
• You may want to route power and ground first, especially if it's a 1 or 2 layer board. Use the
nets spreadsheet to enable/disable those nets you want to route at any one time. Tip: select
Routing Enabled column, right click, disable to disable all nets, then enable the ones you
want.
• You may want to give priority to critical nets (those that need shortest paths), to optimally
route those. Priority can be selected from the “nets” spreadsheet for each net.
• To automatically route, select Tools, auto, route board. To put everything back to the rat's
nest net, tools/auto/unroute board.
• You can auto route just one component by selecting auto route/component then click on a
pin on that component.
• After an auto route/board is completed, orcad thinks it's finished, and if you run it again
(e.g. to route some more signals that were disabled the first time) it says all sweeps done or
disabled and won't run again. To run auto route again you have to remove "done" from all
auto route passes. Click the spreadsheet toolbar button and select strategy/route pass. Select
the whole "enable" column, right click, and select properties. Remove the "done" tick and
click OK. Close the spreadsheet and you can now run the auto router again.
PIR sensor based security system using 89C52 micro controller
49
Copper Pour
• Copper pour fills selected unused board area with copper. This allows creation of large
ground (and/or power) areas which improves noise properties. Also reduces amount of
copper that needs to be etched off the board by manufacturing process.
• Tip: don't do this until you've finished placement and routing.
• Select required layer (e.g. TOP or BOTTOM).
• Select obstacle tool (toolbar button), right click in design, select new.
School of Engineering Orcad PCB Quick Start
• Right click again, select properties
• Select copper pour, net = GND (or as required), OK. (This example would connect copper
pour to the GND net.)
• Draw (by left click and drag) the outline for the copper fill.
• Repeat as required for other copper pour areas and/or layers.
• If you want to delete it, select it by using obstacle tool then ctrl left click on the pour. Then
press the delete key.
Set Datum (origin)
• From Tool menu select dimension/move datum.
• Left click at the bottom LH corner of your board to set the origin. (Exact placing doesn't
matter.)
Generate Machining Files (Gerber files)
• The machining files required to manufacture the PCB are generated by the “post processor”.
From options menu choose “Post Processing”. In the Spreadsheet, select the layers you need
to manufacture. You need at least the routing layers you have used (eg top, bottom) and the
drill information.
• Choose Auto/Post Process to generate the files. The files generated by the post processor
are the only ones needed for the PCB plant to make the board.
Tips
PIR sensor based security system using 89C52 micro controller
50
Use the color toolbar button, click on a colour box and press the – key to toggle its visibility.
With copper pour in place it can be hard to see what you've got.
Silk Screen - to see it, you need to add it to the colours table. Use Colours tool, right click,
new. Select layer SST (silk screen top), rule = default, OK.
Use manual place (auto place doesn't optimize placement for noise considerations).
When placing, set critical nets (e.g. op amp inputs) to a distinctive colour (via nets
spreadsheet) so you can easily see them to optimize placement. Place connectors first – they
need to be in a convenient place (e.g. near the edge).
Some components have multiple parts within one package. Place an additional part in the
schematic, choosing, for example, the B part. The “annotate design” tool will combine them
into one package (same component identifier). Don't forget to connect unused inputs to
appropriate places (e.g. power, ground) in the schematic, particularly for digital circuits.
You can go back and change your schematic. Then, when you generate the net list again, be
sure to select the box “Run ECO to Layout” (Engineering
Change Order). The PCB will be appropriately changed (you may need to then tidy things
up).
To select an obstacle (e.g. board outline or copper pour) select the obstacle tool
(Toolbar button). Hold ctrl key down and left click on obstacle to select it
(Becomes highlighted – usually white). Or, click on corner of obstacle and drag as required.
Or, select obstacle by drawing a box (with obstacle tool selected) which includes some part of
the object.
Make sure you do a save fairly often. You can save to a different file name if you want, then
you have a partial PCB design you can go back to if you change your mind how to do things.
Do a save before trying anything daring. Then if it doesn't work out you can just exit without
saving and start again with your previously saved design. Beware: the "undo" option is only
occasionally helpful.
The on-line manuals are ok, but more detailed information is in the pdf files contained in the
Orcad Family folder (eg information on technology files, strategy files and many more
complex operations than those mentioned here).
Creating a New Footprint
An easy way to create a new footprint is to find an existing one that's similar, edit it and save
it with a new name.
PIR sensor based security system using 89C52 micro controller
51
• Start Layout+ and choose tools/library manager.
• The list of libraries is displayed in the top part of the window. Click on one you think may
be useful.
• The list of footprints in that library is now shown in the bottom window. If you click on a
footprint it is displayed in the window on the right.
• Browse to a footprint that's close to what you want. (eg Right number of pins but wrong
width, or vice versa.)
• To move a pin, choose pin tool, click on pin, and move cursor to where you want it. (You
can also use the arrow keys.) The coordinates and distance moved are shown in the status bar
at the bottom.
• Another, possibly easier way to move a pin to the right place is to edit its properties in the
footprints spreadsheet. You can just type in the required
x,y coordinate of the pin here. You can also take a copy of a pin (ctrl C) if you need to add
pins.
• To move text use the text tool, click on the text and drag it to where you want.
• To change the place outline and detail, select them using the obstacle tool and either delete
(delete key) or drag to where you want. If you delete and redraw, make sure it's the right
obstacle type (right click, properties). The place outline shows the board space taken – other
footprints can't be placed within this outline.
• When you want to save, do a “save as” (don't overwrite the original library
School of Engineering Orcad PCB Quick Start object). Then you have the option to create a
new library. I'd recommend this – make a library in your own design folder and keep this
with the rest of your design files.
Software Dumping Procedure
1. The assembly language Instructions typed in dos editor or notepad with an
extension of .ASM.
2. Compile the above .asm file with 8052 cross assembler.
3. The assembler converts the .ASM file into .HEX file (Contains all op codes).
4. Copy the converted Hex file into internal flash Rom of Micro Controller with the
help of Universal Programmer or Micro Controller Programmer.
PIR sensor based security system using 89C52 micro controller
52
CHAPTER-5
RESULTS
1.When power supply is given, the kit will be on and the LED will be displayed as above
PIR sensor based security system using 89C52 micro controller
53
2.After 5 seconds, LED will display as above indicating that, it is ready for the signal of
sensor.
3.PIR sensor has detected the presence of the object
5.First we will be intimated with a message, then LED will display like this.
PIR sensor based security system using 89C52 micro controller
54
6.We will get a message first.
7.After message sending, LED will show this message, which indicates getting phone call.
PIR sensor based security system using 89C52 micro controller
55
8.Like this we will get a call
9. Smoke detection is done and again a message is sent to the predefined numbers after
buzzer sound.
PIR sensor based security system using 89C52 micro controller
56
CHAPTER 6
FUTURE WORK AND CONCLUSION
In this security system PIR sensor has been used which is low power, and low cost, pretty
rugged, have a wide lens range, and are easy to interface with. This security system can be
implemented in places like home, office, shop etc. The sensitivity range for detecting motion
of the system is about 3 to 4 feet. It can be raised up to 20 feet through careful use of
concentrating optical lenses as future development. In addition to this, this system can be
equipped with glass break detectors to enhance the level of protection. Use of multi-sensor
data fusion and complex algorithm can be used to increase the effective FOV for larger
spaces. In order to enhance the location accuracy and to enhance the method of processing
the PIR sensor signal, use of more advanced techniques such as probabilistic theories and soft
computing is left open for the future.
PIR sensor based security system using 89C52 micro controller
57
REFERENCES
[I] Z. Zhi - hui, L. Hui, L. Yin, C. Jia - jia, "Design of the intelligent firep
roof and theft - proof alann system for home", JOURNAL OF HENAN
POLYTECHNIC UNIVERSITY, vol. 28,no. I, pp. 207-210, Feb. 2009.
[2] Q. Qu, Z. Guohao, W. Baohua, "Design of Home Safeguard System
Based on GSM Technique", Electronic Engineer, vol. 32, no. I I, pp. 76-
78, Nov. 2006.
[3] M. Shankar, 1. Burchett, Q. Hao, B. Guenther, "Human-tracking systems
using pyroelectric infrared detectors", Optical Engineering, vol. 10, no.
45, pp. 106401 (01-10), Oct. 2006.
[4] M. Moghavvemi and C.S. Lu, "Pyroelectric infrared sensor for intruder
detection," in Proc. TENCON 2004 Conf., pp. 656-659.
[5] Renewable Energy UK. (2010, Aug.). Find out how to integrate PIR
(passiveinfra red) sensors into renewable energy applications. [Online].
Available: http://www.reuk.co.uklPIR-Sensors.htm
PIR sensor based security system using 89C52 micro controller
58
ANNEXURE
;THIS IS ELECTRONIC SECURITY SYSTEM
;WITH FEED BACK.+ VOICE+SMS+DTMF
;P2.0 =BUZZER
;P2.1 =
;P2.3 =
;P2.4 =
;P1.0=DTMF0
;P1.1=DTMF1
;P1.2=DTMF2
;P1.3=DTMF3
;P1.4=DTMF4
;P0 = DISP DATA
;P2.7 = RS
;P2.6 = R/W
;P2.5 = EN
TXD MACRO
JNB TI,$
CLR TI
MOV SBUF,R6
PIR sensor based security system using 89C52 micro controller
59
MACEND
ORG 0
LJMP START
ORG 0050H
;--------------------
START: MOV P2,#00H
MOV P1,#FFH
LCALL SPINI
LCALL LCDINI
LCALL DEL
XX2:
MOV DPTR,#0900H
LCALL TLINE
MOV DPTR,#0910H
LCALL BLINE
LCALL SSEC
SETB P1.2
SETB P1.3
PIR sensor based security system using 89C52 micro controller
60
SETB P2.4
CLR P2.0
SETB P2.1
SETB P2.2
MOV DPTR,#0920H
LCALL TLINE
MOV DPTR,#0930H
LCALL BLINE
XX1: JB P1.0,YY1
LCALL DEL
JB P1.0,XX1
MOV 19H,#01H
LJMP CCVV
YY1: JNB P1.1,XX1
LCALL DEL
JNB P1.1,YY1
MOV 19H,#02H
LJMP CCVV
PIR sensor based security system using 89C52 micro controller
61
CCVV: MOV DPTR,#0940H
LCALL TLINE
MOV DPTR,#0950H
LCALL BLINE
SETB P2.0
CLR P2.1
LCALL SEC3
LCALL SEC3
LCALL SEC3
JNB P2.4,START
LJMP SMSX
RETSMTX:
;*****************************
DIAL1:
MOV DPTR,#09A0H
LCALL TLINE
MOV DPTR,#09B0H
LCALL BLINE
PIR sensor based security system using 89C52 micro controller
62
MOV DPTR,#AT_D ;DIAL MODE
MOV R2,#0EH
LCALL CMD1
LCALL ENTER
LCALL VSEL
LCALL SSEC
LCALL SSEC
LCALL SSEC
LCALL SSEC
LCALL SSEC
MOV DPTR,#AT_H ;DIAL MODE
MOV R2,#03H
LCALL CMD1
LCALL ENTER
LCALL SSEC
LCALL SEC
SETB P2.0
LCALL SEC
CLR P2.0
PIR sensor based security system using 89C52 micro controller
63
;-----------------
DIAL2: MOV DPTR,#AT_D2 ;DIAL MODE
MOV R2,#0EH
LCALL CMD1
LCALL ENTER
LCALL VSEL
LCALL SSEC
LCALL SSEC
LCALL SSEC
LCALL SSEC
LCALL SSEC
MOV DPTR,#AT_H ;DIAL MODE
MOV R2,#03H
LCALL CMD1
LCALL ENTER
LCALL SSEC
LCALL SEC
SETB P2.0
LCALL SEC
CLR P2.0
;--------------
DIAL3: MOV DPTR,#AT_D3 ;DIAL MODE
PIR sensor based security system using 89C52 micro controller
64
MOV R2,#0EH
LCALL CMD1
LCALL ENTER
LCALL VSEL
LCALL SSEC
LCALL SSEC
LCALL SSEC
LCALL SSEC
LCALL SSEC
MOV DPTR,#AT_H ;DIAL MODE
MOV R2,#03H
LCALL CMD1
LCALL ENTER
LCALL SSEC
LCALL SEC
SETB P2.0
LCALL SEC
CLR P2.0
LJMP START
VSEL: MOV A,19H
CJNE A,#01H,VOI2
PIR sensor based security system using 89C52 micro controller
65
CLR P1.2
LCALL SEC
;SETB P1.2
RET
VOI2: CJNE A,#02H,VOI3
CLR P1.3
LCALL SEC
;SETB P1.3
VOI3: RET
;*********** SMS TXD ********
SMSX: MOV DPTR,#0960H
LCALL TLINE
MOV DPTR,#0970H
LCALL BLINE
;-------------------
MOV 3EH,#03H
;------------------------
SMSXX: MOV DPTR,#AT_CMGF ;SMS MODE PDU=0/TEXT=1
MOV R2,#09H
LCALL CMD1
LCALL ENTER
PIR sensor based security system using 89C52 micro controller
66
LCALL SEC
MOV DPTR,#AT_ERS ;ERASE OF 1 ST LOCATION
MOV R2,#09H
LCALL CMD1
LCALL ENTER
LCALL SEC
LCALL SEC
MOV DPTR,#AT_CPMS ;SIMM MEMORY SELECTION
MOV R2,#0CH
LCALL CMD1
LCALL ENTER
LCALL SEC ;BETTER TO PUT ERASE
;---------3 NUMBERS -----------
MOV A,3EH
CJNE A,#03H,NP2
MOV DPTR,#AT_CMGW
LJMP NP4
PIR sensor based security system using 89C52 micro controller
67
NP2: CJNE A,#02H,NP3
MOV DPTR,#AT_CMGW2
LJMP NP4
NP3: CJNE A,#01H,NP4
MOV DPTR,#AT_CMGW3 ;WRITE MES.IN SIMM MEMORY
LOCATION
NP4: MOV R2,#14H
LCALL CMD1
LCALL ENTER
;-----------------------------------
LCALL SEC3
; MOV DPTR,#AT_CMD ;WRITE MES.IN SIMM MEMORY
LOCATION
; MOV R2,#0BH
; LCALL CMD1
LCALL CMDRAM
LCALL SEC3
MOV DPTR,#AT_CMSS ;SEND COMMAND TO MODEM
MOV R2,#09H
LCALL CMD1
PIR sensor based security system using 89C52 micro controller
68
LCALL ENTER
SETB P2.0
LCALL SEC
CLR P2.0
LCALL SEC3
DEC 3EH
MOV A,3EH
CJNE A,#00H,SMSXX
;LJMP XX1
LJMP RETSMTX
;*******************************************
SMSRX: SETB P2.0
MOV DPTR,#0980H
LCALL TLINE
MOV DPTR,#0990H
LCALL BLINE
LCALL SEC3
MOV DPTR,#AT_ERS ;ERASE OF 1 ST LOCATION
MOV R2,#09H
PIR sensor based security system using 89C52 micro controller
69
LCALL CMD1
LCALL ENTER
MOV DPTR,#AT_ERS2 ;ERASE OF 2 ST LOCATION
MOV R2,#09H
LCALL CMD1
LCALL ENTER
MOV DPTR,#AT_ERS3 ;ERASE OF 3 ST LOCATION
MOV R2,#09H
LCALL CMD1
LCALL ENTER
MOV DPTR,#AT_ERS4 ;ERASE OF 4 ST LOCATION
MOV R2,#09H
LCALL CMD1
LCALL ENTER
MOV DPTR,#AT_ERS5 ;ERASE OF 5 ST LOCATION
MOV R2,#09H
LCALL CMD1
LCALL ENTER
;---------------------
PIR sensor based security system using 89C52 micro controller
70
MOV DPTR,#AT_CMGF ;SMS MODE PDU=0/TEXT=1
MOV R2,#09H
LCALL CMD1
LCALL ENTER
LCALL SEC
MOV DPTR,#AT_CNMI ;REQ. FOR RECEIVE
MOV R2,#11H
LCALL CMD1
LCALL ENTER
LCALL SEC
MOV DPTR,#AT_CNMA ;READY TO RECEIVE
MOV R2,#07H
LCALL CMD1
LCALL ENTER
LCALL SEC3
LCALL SEC
CLR P2.0
;********************************
MAIN: MOV R0,#20H
NXTB: LCALL RXD
PIR sensor based security system using 89C52 micro controller
71
CJNE R4,#01H,NXTB
MOV A,R1
MOV @R0,A
INC R0
CJNE R0,#55H,NXTB
LCALL DISP
LCALL MOTON
LCALL MOTOF
LJMP MAIN
HHHH: LJMP HHHH
;************************************
MOTON:
MOV A,52H
CJNE A,#4FH,MRET
MOV A,53H
CJNE A,#4EH,MRET
MOV A,54H
CJNE A,#4DH,MRET
SETB P2.1
SETB P1.3
CLR P1.4
PIR sensor based security system using 89C52 micro controller
72
LCALL SEC3
CLR P1.3
CLR P1.4
MRET: RET
MOTOF:
MOV A,52H
CJNE A,#4FH,NRET
MOV A,53H
CJNE A,#46H,NRET
MOV A,54H
CJNE A,#4DH,NRET
CLR P2.1
CLR P1.3
SETB P1.4
LCALL SEC3
CLR P1.3
CLR P1.4
NRET: RET
;************************************
RXD: MOV R4,#00H
MOV R7,#1FH
PIR sensor based security system using 89C52 micro controller
73
AE: MOV R6,#FFH
AD: MOV R5,#FFH
AB: JNB RI,AC
CLR RI
MOV R1,SBUF
MOV R4,#01H ;STATUS CHK #01 OK,#02 NOT OK
;MOV R6,SBUF
;TXD
RET
AC: DJNZ R5,AB
DJNZ R6,AD
DJNZ R7,AE
MOV R4,#02H
RET
;*************LOCATION SENSING***********
LSEN:
LDISP:
RET
;****************************************
DISP:
PIR sensor based security system using 89C52 micro controller
74
CLR p2.7
CLR p2.6
MOV P0,#C0H
LCALL WRI
MOV R1,#50H
XTKL:
CLR A
MOV A,@R1
MOV P0,A
LCALL WRD
INC R1
CJNE R1,#55H,XTKL
;-----------------------
RET
;********** LCD INI *************************
LCDINI:
CLR P2.5
CLR p2.7
CLR p2.6
PIR sensor based security system using 89C52 micro controller
75
MOV P0,#30H
LCALL WRI
CLR p2.7
CLR p2.6
MOV P0,#30H
LCALL WRI
CLR p2.7
CLR p2.6
MOV P0,#30H
LCALL WRI
CLR p2.7
CLR p2.6
MOV P0,#38H
LCALL WRI
CLR p2.7
CLR p2.6
MOV P0,#01H
LCALL WRI
PIR sensor based security system using 89C52 micro controller
76
CLR p2.7
CLR p2.6
MOV P0,#01H
LCALL WRI
CLR p2.7
CLR p2.6
MOV P0,#01H
LCALL WRI
CLR p2.7
CLR p2.6
MOV P0,#02H
LCALL WRI
CLR p2.7
CLR p2.6
MOV P0,#0CH
LCALL WRI
CLR p2.7
CLR p2.6
PIR sensor based security system using 89C52 micro controller
77
MOV P0,#1CH
LCALL WRI
CLR p2.7
CLR p2.6
MOV P0,#38H
LCALL WRI
CLR p2.7
CLR p2.6
MOV P0,#06H
LCALL WRI
CLR p2.7
CLR p2.6
MOV P0,#01H
LCALL WRI
RET
;----------------------------
TLINE: CLR p2.7
CLR p2.6
MOV P0,#80H
LCALL WRI
PIR sensor based security system using 89C52 micro controller
78
MOV R7,#00H
TKL:
CLR A
MOVC A,@A+DPTR
MOV P0,A
LCALL WRD
INC DPTR
INC R7
CJNE R7,#10H,TKL
RET
BLINE: CLR p2.7
CLR p2.6
MOV P0,#C0H
LCALL WRI
MOV R7,#00H
BKL:
CLR A
MOVC A,@A+DPTR
MOV P0,A
LCALL WRD
INC DPTR
INC R7
CJNE R7,#10H,BKL
PIR sensor based security system using 89C52 micro controller
79
RET
;******** INSTRUCTION /DATA WRITE *********
WRI: SETB P2.5
MOV R0,#FFH
DJNZ R0,$
CLR P2.5
MOV R0,#FFH
DJNZ R0,$
RET
WRD: SETB p2.7 ; REGISTER
CLR p2.6 ;READ WRITE
SETB P2.5 ;ENABLE
MOV R0,#FFH
DJNZ R0,$
CLR P2.5
CLR p2.6
CLR p2.7
RET
;******************************
PIR sensor based security system using 89C52 micro controller
80
DEL: MOV R7,#FFH
DJNZ R7,$
RET
DEL1: MOV R7,#FFH
DJNZ R7,$
RET
SEC: MOV R5,#03H
M1: MOV R6,#FFH
M2: MOV R7,#FFH
M3: DJNZ R7,M3
DJNZ R6,M2
DJNZ R5,M1
RET
SEC3: MOV R5,#0FH
M13: MOV R6,#FFH
M23: MOV R7,#FFH
M33: DJNZ R7,M33
DJNZ R6,M23
DJNZ R5,M13
RET
PIR sensor based security system using 89C52 micro controller
81
SSEC: MOV R5,#3FH
SM1: MOV R6,#FFH
SM2: MOV R7,#FFH
SM3: DJNZ R7,SM3
DJNZ R6,SM2
DJNZ R5,SM1
RET
;********************************************
XDEL:
mov r4,#0FH
djnz r4,$
RET
XDEL1: mov r4,#0FH
djnz r4,$
RET
XDEL2: MOV R5,#5FH
GB: mov r4,#FFH
djnz r4,$
DJNZ R5,GB
RET
PIR sensor based security system using 89C52 micro controller
82
;*********** DISPLAY *************
;**********************************************
ENTER: MOV R6,#0DH
TXD
RET
CMD1: CLR A
MOVC A,@A+DPTR
MOV R6,A
TXD
INC DPTR
DJNZ R2,CMD1
RET
;----------SENDING MES.-----------
CMDRAM: MOV A,19H
CJNE A,#01H,MES2
LCALL SEC3
MOV DPTR,#AT_CMD ;WRITE MES.IN SIMM MEMORY
LOCATION
MOV R2,#32H
LCALL CMD1
RET
MES2: CJNE A,#02H,BBBM
PIR sensor based security system using 89C52 micro controller
83
LCALL SEC3
MOV DPTR,#AT_CMD1 ;WRITE MES.IN SIMM MEMORY
LOCATION
MOV R2,#32H
LCALL CMD1
BBBM: RET
;************** UART PORT INT *************
SPINI:
MOV A,#00H
MOV TCON,#40H
MOV TMOD,#20H
MOV SCON,#52H
MOV IE,#9AH
MOV TH1,#FDH
MOV TL1,#FDH
RET
;##############################
ORG 0900H
;************ 1 LINE
PIR sensor based security system using 89C52 micro controller
84
DB 'IVRS BASED ESEC '
DB ' '
DB 'WAITIN FOR '
DB 'SENSOR SIGNAL.. '
DB ' SENSOR '
DB ' ACTIVATED '
DB ' SMS SENDING.. '
DB ' '
DB 'SMS RECEIVING.. '
DB ' '
DB 'VOICE CALL... '
DB ' '
;*********************************
ORG 1B00H
AT_CMGF: DB "AT+CMGF=1"
PIR sensor based security system using 89C52 micro controller
85
ORG 1B20H
AT_CPMS: DB "AT+CPMS="
DB 22H
DB "SM"
DB 22H
ORG 1B40H
AT_CMGW: DB "AT+CMGS="
DB 22H
DB "8885463472"
DB 22H
ORG 1B60H
AT_CMD: DB "SOMEBODY ENTERED INTO YOUR HOUSE "
DB 1AH
ORG 1BA0H
AT_CMSS: DB "AT+CMSS=1"
ORG 1BC0H
AT_D: DB "ATD8885463472;"
ORG 1C00H
PIR sensor based security system using 89C52 micro controller
86
AT_ERS: DB "AT+CMGD=1"
ORG 1C10H
AT_ERS2: DB "AT+CMGD=2"
ORG 1C20H
AT_ERS3: DB "AT+CMGD=3"
ORG 1C30H
AT_ERS4: DB "AT+CMGD=4"
ORG 1C40H
AT_ERS5: DB "AT+CMGD=5"
ORG 1C50H
AT_CNMI: DB "AT+CNMI=2,2,0,0,0"
ORG 1C70H
AT_CNMA: DB "AT+CNMA"
ORG 1C80H ;2ND SMS
AT_CMGW2:DB "AT+CMGS="
DB 22H
DB "9177965408"
DB 22H
PIR sensor based security system using 89C52 micro controller
87
ORG 1CA0H ;3RD SMS
AT_CMGW3:DB "AT+CMGS="
DB 22H
DB "8187017099"
DB 22H
ORG 1CD0H
AT_D2: DB "ATD9177965408;"
ORG 1CF0H
AT_D3: DB "ATD8187017099;"
ORG 1E10H
AT_H: DB "ATH"
ORG 1E20H
AT_CMD1: DB "FIRE ACCIDENT IN YOUR HOUSE AT HOME "
DB 1AH
END;
;AAAAAAAAAAAAA#############################################
#####
PIR sensor based security system using 89C52 micro controller
88