Mini Project Report on PIR Sensor Based Intrusion Detection System CHAPTER-1 1.INTRODUCTION 1.1 Introduction to the Project This chapter is going to introduce about the physical devices those are microcontroller, embedded systems which are being used by the designers to mould the circuit for the desired output and those are illustrated below. We are implementing our project in Embedded systems. Embedded system means it is the combination of Software and Hardware that is designed with a small computer which performs a specific task. For this project we are writing the code in PIC COMPILER and dumping the program using PIC 2 kit software. We are implementing the circuit diagram using PCB WIZARD and this PCB board is designed using EXPRESS PCB. This project PIR SENSOR BASED INTRUSION DETECTION SYSTEM is an Embedded type project .We knows that embedded system is a fast emerging technology, It is a system which performs a single task using both software and hardware. VITS-Karimnagar 1 B.TECH(ECE)
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Mini Project Report on PIR Sensor Based Intrusion Detection System
CHAPTER-1
1. INTRODUCTION
1.1 Introduction to the Project
This chapter is going to introduce about the physical devices those are microcontroller,
embedded systems which are being used by the designers to mould the circuit for the
desired output and those are illustrated below.
We are implementing our project in Embedded systems. Embedded system
means it is the combination of Software and Hardware that is designed with a small
computer which performs a specific task.
For this project we are writing the code in PIC COMPILER and dumping the program
using PIC 2 kit software.
We are implementing the circuit diagram using PCB WIZARD and this PCB board is
designed using EXPRESS PCB.
This project PIR SENSOR BASED INTRUSION DETECTION SYSTEM is an
Embedded type project .We knows that embedded system is a fast emerging technology,
It is a system which performs a single task using both software and hardware.
The purpose of this project is to provide a home security system using PIR sensor. This
system facilitates the house owners to monitor their home. This system comprises of a
Microcontroller based monitoring system along with PIR (Passive Infrared) based
presence of human beings (thieves). Whenever an un-authorized entry is done, this
system gives Buzzer alerts to the house owner.
VITS-Karimnagar 1 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
1.2 Circuit diagram of the project
Figure 1: PIR Sensor Based Intrusion Detection System
VITS-Karimnagar 2 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
1.3. EMBEDDED SYSTEMS
An embedded system is a computer system designed to perform one or a few
dedicated functions often with real-time computing constraints. It is embedded as part of
a complete device often including hardware and mechanical parts. By contrast, a general-
purpose computer, such as a personal computer (PC), is designed to be flexible and to
meet a wide range of end-user needs. Embedded systems control many devices in
common use today.
Embedded systems are controlled by one or more main processing cores that are
typically either microcontrollers or digital signal processors (DSP). The key
characteristic, however, is being dedicated to handle a particular task, which may require
very powerful processors. For example, air traffic control systems may usefully be
viewed as embedded, even though they involve mainframe computers and dedicated
regional and national networks between airports and radar sites. (Each radar probably
includes one or more embedded systems of its own.)
Since the embedded system is dedicated to specific tasks, design engineers can optimize
it to reduce the size and cost of the product and increase the reliability and performance.
Some embedded systems are mass-produced, benefiting from economies of scale.
Physically embedded systems range from portable devices such as digital watches and
MP3 players, to large stationary installations like traffic lights, factory controllers, or the
systems controlling nuclear power plants. 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 a strictly definable term, as most systems have
some element of extensibility or programmability. For example, handheld computers
VITS-Karimnagar 3 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
share some elements with embedded systems such as the operating systems and
microprocessors which power them, but they allow different applications to be loaded
and peripherals to be connected. Moreover, even systems which don't expose
programmability as a primary feature generally need to support software updates. On a
continuum from "general purpose" to "embedded", large application systems will have
subcomponents at most points even if the system as a whole is "designed to perform one
or a few dedicated functions", and is thus appropriate to call "embedded".
Real Time Issues:
Embedded systems frequently control hardware, and must be able to respond to them in
real time. Failure to do so could cause inaccuracy in measurements, or even damage
hardware such as motors. This is made even more difficult by the lack of resources
available. Almost all embedded systems need to be able to prioritize some tasks over
others, and to be able to put off/skip low priority tasks such as UI in favor of high priority
tasks like hardware control.
Need For Embedded Systems:
The uses of embedded systems are virtually limitless, because every day new products
are introduced to the market that utilizes embedded computers in novel ways. In recent
years, hardware such as microprocessors, microcontrollers, and FPGA chips have
become much cheaper. So when implementing a new form of control, it's wiser to just
buy the generic chip and write your own custom software for it. Producing a custom-
made chip to handle a particular task or set of tasks costs far more time and money. Many
embedded computers even come with extensive libraries, so that "writing your own
software" becomes a very trivial task indeed. From an implementation viewpoint, there is
a major difference between a computer and an embedded system. Embedded systems are
often required to provide Real-Time response. The main elements that make embedded
systems unique are its reliability and ease in debugging.
Debugging:
VITS-Karimnagar 4 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
Embedded debugging may be performed at different levels, depending on the facilities
available. From simplest to most sophisticate they can be roughly grouped into the
following areas: Interactive resident debugging, using the simple shell provided by the
embedded operating system (e.g. Forth and Basic) External debugging using logging or
serial port output to trace operation using either a monitor in flash or using a debug server
like the Remedy Debugger which even works for heterogeneous multi core systems.
heterogeneous multi core systems.
An in-circuit debugger (ICD), a hardware device that connects to the microprocessor via
a JTAG or Nexus interface. This allows the operation of the microprocessor to be
controlled externally, but is typically restricted to specific debugging capabilities in the
processor.
An in-circuit emulator replaces the microprocessor with a simulated equivalent,
providing full control over all aspects of the microprocessor.
A complete emulator provides a simulation of all aspects of the hardware, allowing all of
it to be controlled and modified and allowing debugging on a normal PC.
Unless restricted to external debugging, the programmer can typically load and run
software through the tools, view the code running in the processor, and start or stop its
operation. The view of the code may be as assembly code or source-code.
Because an embedded system is often composed of a wide variety of elements, the
debugging strategy may vary. For instance, debugging a software(and microprocessor)
centric embedded system is different from debugging an embedded system where most of
the processing is performed by peripherals (DSP, FPGA, co-processor). An increasing
number of embedded systems today use more than one single processor core. In such a
case, the embedded system design may wish to check the data traffic on the busses
between the processor cores, which requires very low-level debugging, at signal/bus
level, with a logic analyzer, for instance.
Reliability:
VITS-Karimnagar 5 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
Embedded systems often reside in machines that are expected to run continuously for
years without errors and in some cases recover by them if an error occurs. Therefore the
software is usually developed and tested more carefully than that for personal computers,
and unreliable mechanical moving parts such as disk drives, switches or buttons are
avoided.
Specific reliability issues may include:
The system cannot safely be shut down for repair, or it is too inaccessible to repair.
Examples include space systems, undersea cables, navigational beacons, bore-hole
systems, and automobiles.
The system must be kept running for safety reasons. "Limp modes" are less tolerable.
Often backup s are selected by an operator. Examples include aircraft navigation, reactor
control systems, safety-critical chemical factory controls, train signals, engines on single-
engine aircraft.
The system will lose large amounts of money when shut down: Telephone switches,
factory controls, bridge and elevator controls, funds transfer and market making,
automated sales and service.
Watchdog timer that resets the computer unless the software periodically notifies the
watchdog
Designing with a Trusted Computing Base (TCB) architecture[6] ensures a highly secure
& reliable system environment
An Embedded Hypervisor is able to provide secure encapsulation for any subsystem
component, so that a compromised software component cannot interfere with other
subsystems, or privileged-level system software. This encapsulation keeps faults from
propagating from one subsystem to another, improving reliability. This may also allow a
subsystem to be automatically shut down and restarted on fault detection.
1.3.1. APPLICATIONS OF EMBEDDED SYSTEMS:
VITS-Karimnagar 6 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
Consumer applications:
At home we use a number of embedded systems which include microwave oven, remote
control, vcd players, DVD players, camera etc….
Office automation:
We use systems like fax machine, modem, printer etc…
Industrial automation:
Today a lot of industries are using embedded systems for process control. In industries
we design the embedded systems to perform a specific operation like monitoring
temperature, pressure, humidity ,voltage, current etc.., and basing on these monitored
levels we do control other devices, we can send information to a centralized monitoring
station.
Computer networking:
Embedded systems are used as bridges routers etc…
Tele communications:
Cell phones, web cameras etc.
1.3.2. CATEGORIES OF EMBEDDED SYSTEMS
Based on performance, functionality, requirement the embedded systems are divided into
three categories:
1. Stand Alone Embedded systems:
These systems takes the input in the form of electrical signals from transducers or
commands from human beings such as pressing of a button etc.., process them and
produces desired o/p.This entire process of taking input, processing it and giving output
is done in stand alone mode. Such embedded systems comes under stand alone embedded
systems
e.g.: microwave oven, air conditioner etc..,
VITS-Karimnagar 7 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
2. Real-time embedded systems:
Embedded systems which are used to perform a specific task or operation in a specific
time period those systems are called as real-time embedded systems.
There are two types of real-time embedded systems:
(i)Hard Real-time embedded systems:
These embedded systems follow an absolute dead line time period
i.e.., if the tasking is not done in a particular time period then there is a cause of damage
to the entire equipment
e.g.: consider a system in which we have to open a valve within 30 milliseconds. If this
valve is not opened in 30 ms this may cause damage to the entire equipment. So in such
cases we use embedded systems for doing automatic operations.
(ii)Soft Real Time embedded systems:
These embedded systems follow a relative dead line time period i.e.., if the task is not
done in a particular time that will not cause damage to the equipment.
e.g: Consider a TV remote control system ,if the remote control takes a few milliseconds
delay it will not cause damage either to the TV or to the remote control.
3. Network communication embedded systems:
A wide range network interfacing communication is provided by using embedded
systems.
e.g:
a) consider a web camera that is connected to the computer with internet can be used to
spread communication like sending pictures, images, videos etc.., to another computer
with internet connection through out anywhere in the world.
b)Consider a web camera that is connected at the door lock.Whenever a person comes
near the door, it captures the image of a person and sends to the desktop of your computer
which is connected to internet.
CHAPTER-2
2. DESIGN ANALYSIS
VITS-Karimnagar 8 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
2.1. Block Diagram
PIR Sensor based Intrusion Detection System
Micro controller
Regulated power supply
CrystalOscillator
Buzzerdriver
PIRsensor
Reset
Buzzer
LED indicator
Fig.2.1: Block Diagram
The main blocks of this project are:
Micro controller (16F72)
Reset button
Crystal oscillator
Regulated power supply
Led indicator
PIR sensor module
2,2. Schematic Diagram
VITS-Karimnagar 9 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
Fig.2.2: Schematic Diagram
Description:
The above schematic diagram of PIR based energy conservation system explains the
interfacing section of each component with micro controller and PIR sensor module. The
crystal oscillator connected to 9th and 10th pins of micro controller and regulated power
supply is also connected to micro controller and LED’s also connected to micro
controller through resistors
The detailed explanation of each module interfacing with microcontroller is as follows:
Interfacing crystal oscillator with micro controller:
VITS-Karimnagar 10 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
The crystal oscillator and reset button are connected to micro controller. The two pins of
oscillator are connected to the 9th and 10th pins of micro controller; the purpose of
external crystal oscillator is to speed up the execution part of instructions per cycle and
here the crystal oscillator having 20 MHz frequency. The 1st pin of the microcontroller is
referred as MCLR ie.., master clear pin or reset input pin is connected to reset button or
power-on-reset.
LED stands for Light Emitting Diode and these are connected to micro controller through
resistors.
CHAPTER-3
VITS-Karimnagar 11 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
3. HARDWARE DESCRIPTION
3.1. Regulated Power Supply
The basic circuit diagram of a regulated power supply (DC O/P) with led connected as load is shown in fig:
fig 3.1: Block Diagram of Regulated Power Supply
The components mainly used in above figure are
230V AC Mains
Transformer
Bridge Rectifier(diodes)
Capacitor
Voltage Regulator (IC 7805)
Resistor
LED(Light Emitting Diode)
From the above fig 3.1. TRANSFORMER is the first section of the regulated power
supply. The transformer step up or step down the input line voltage and isolates the
power supply from the power line. The RECTIFIER section converts the alternating
current input signal to a pulsating direct current. For this reason a FILTER section is used
3.2. Rectifiers
VITS-Karimnagar 12 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
A rectifier is an electrical device that converts alternating current (AC) to direct current
(DC), a process known as rectification. Rectifiers have many uses including as
components of power supplies and as detectors of radio signals. Rectifiers may be made
of solid-state diodes, vacuum tube diodes, mercury arc valves, and other components.
A device that it can perform the opposite function (converting DC to AC) is known
as an inverter. When only one diode is used to rectify AC (by blocking the negative or
positive portion of the waveform), the difference between the term diode and the term
rectifier is merely one of usage, i.e., the term rectifier describes a diode that is being used
to convert AC to DC. Almost all rectifiers comprise a number of diodes in a specific
arrangement for more efficiently converting AC to DC than is possible with only one
diode. Before the development of silicon semiconductor rectifiers, vacuum tube diodes
and copper (I) oxide or selenium rectifier stacks were used.
Half-wave rectification:
In half wave rectification, either the positive or negative half of the AC wave is passed,
while the other half is blocked. Because only one half of the input waveform reaches the
output, it is very inefficient if used for power transfer. Half-wave rectification can be
achieved with a single diode in a one-phase supply, or with three diodes in a three-phase
supply.
Input Out
fig.3.2: Half wave rectifier
VITS-Karimnagar 13 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
The output DC voltage of a half wave rectifier can be calculated with the following two
ideal equations.
Full wave rectifier:
Full wave rectifier is available in two ways like center-tapped full-wave rectifier and
bridge full-wave rectifier.
The Bridge rectifier is a circuit, which converts an ac voltage to dc voltage using both
half cycles of the input ac voltage. The Bridge rectifier circuit is shown in the figure. The
circuit has four diodes connected to form a bridge. The ac input voltage is applied to the
diagonally opposite ends of the bridge. The load resistance is connected between the
other two ends of the bridge.
For the positive half cycle of the input ac voltage, diodes D1 and D3 conduct, whereas
diodes D2 and D4 remain in the OFF state. The conducting diodes will be in series with
the load resistance RL and hence the load current flows through RL.
For the negative half cycle of the input ac voltage, diodes D2 and D4 conduct whereas,
D1 and D3 remain OFF. The conducting diodes D2 and D4 will be in series with the load
resistance RL and hence the current flows through RL in the same direction as in the
previous half cycle. Thus a bi-directional wave is converted into a unidirectional wave.
VITS-Karimnagar 14 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
Input Output
Fig 3.3: Bridge Rectifier- a full-wave rectifier using 4 diodes
Center Tapped Full wave rectifier:
For single-phase AC, if the transformer is center-tapped, then two diodes back-to-back
(i.e. anodes-to-anode or cathode-to-cathode) can form a full-wave rectifier. Twice as
many windings are required on the transformer secondary to obtain the same output
voltage compared to the bridge rectifier above.
For the positive half cycle of the input ac voltage, diodes D1 will conducts, whereas
diodes D2 is in the OFF state. The conducting diodes D1 will be in series with the load
resistance RL and hence the load current flows through RL.
For the negative half cycle of the input ac voltage, diodes D2 will conduct, whereas
diodes D1 is in the OFF state.
Input Output
Fig 3.4: Center tapped Full-wave rectifier using a transformer and 2 diodes.
VITS-Karimnagar 15 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
3.3 Battery:
Generally we use the transformer in power supply, but here for easy of
carrying we are using a 9 volts battery that is connect in series with input connection.
Battery is an electronic material which stores the current. so, here we ae using a 9 volts
battery as a input supply.
3.4. Filters
Filtration:
The process of converting a pulsating direct current to a pure direct current using filters
is called as filtration.
Capacitor Filter:
The simple capacitor filter is the most basic type of power supply filter. The application
of the simple capacitor filter is very limited. It is sometimes used on extremely high-
voltage, low-current power supplies for cathode-ray and similar electron tubes, which
require very little load current from the supply. The capacitor filter is also used where the
power-supply ripple frequency is not critical; this frequency can be relatively high. The
capacitor (C1) shown in figure 4-15 is a simple filter connected across the output of the
rectifier in parallel with the load.
VITS-Karimnagar 16 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
Figure 3.5: - Full-wave rectifier with a capacitor filter
When this filter is used, the RC charge time of the filter capacitor (C1) must be short and
the RC discharge time must be long to eliminate ripple action. In other words, the
capacitor must charge up fast, preferably with no discharge at all. Better filtering also
results when the input frequency is high; therefore, the full-wave rectifier output is easier
to filter than that of the half-wave rectifier because of its higher frequency.
For you to have a better understanding of the effect that filtering has on E avg, a
comparison of a rectifier circuit with a filter and one without a filter is illustrated in views
A and B of figure3.7. The output waveforms in figure 3.7 represent the unfiltered and
filtered outputs of the half-wave rectifier circuit. Current pulses flow through the load
resistance (RL) each time a diode conducts. The dashed line indicates the average value of
output voltage. For the half-wave rectifier, Eavg is less than half (or approximately 0.318)
of the peak output voltage. This value is still much less than that of the applied voltage.
With no capacitor connected across the output of the rectifier circuit, the waveform in
view A gas a large pulsating component (ripple) compared with the average or dc
component. When a capacitor is connected across the output (view B), the average value
of output voltage (Eavg) is increased due to the filtering action of capacitor C1.
UNFILTERED
VITS-Karimnagar 17 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
Figure3.6a. - Half-wave rectifier with and without filtering
FILTERED
Figure 3.6b- Half-wave rectifier with and with filtering
The value of the capacitor is fairly large (several microfarads), thus it presents a
relatively low reactance to the pulsating current and it stores a substantial charge. The
rate of charge for the capacitor is limited only by the resistance of the conducting diode
which is relatively low. Therefore, the RC charge time of the circuit is relatively short.
As a result, when the pulsating voltage is first applied to the circuit, the capacitor charges
rapidly and almost reaches the peak value of the rectified voltage within the first few
cycles. The capacitor attempts to charge to the peak value of the rectified voltage anytime
a diode is conducting, and tends to retain its charge when the rectifier output falls to zero.
(The capacitor cannot discharge immediately.) The capacitor slowly discharges through
the load resistance (RL) during the time the rectifier is no conducting.
The rate of discharge of the capacitor is determined by the value of capacitance and the
value of the load resistance. If the capacitance and load-resistance values are large, the
RC discharge time for the circuit is relatively long.
VITS-Karimnagar 18 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
A comparison of the waveforms shown in figure 3.7 (view A and view B) illustrates that
the addition of C1 to the circuit results in an increase in the average of the output voltage
(Eavg) and a reduction in the amplitude of the ripple component (Er) which is normally
present across the load resistance.
Now, let's consider a complete cycle of operation using a half-wave rectifier, a capacitive
filter (C1), and a load resistor (RL). As shown in view A of figure 3.8, the capacitive filter
(C1) is assumed to be large enough to ensure a small reactance to the pulsating rectified
current. The resistance of RL is assumed to be much greater than the reactance of C1 at
the input frequency. When the circuit is energized, the diode conducts on the positive half
cycle and current flows through the circuit, allowing C1 to charge. C1 will charge to
approximately the peak value of the input voltage. (The charge is less than the peak value
because of the voltage drop across the diode (D1)). In view A of the figure, the charge on
C1 is indicated by the heavy solid line on the waveform. As illustrated in view B, the
diode cannot conduct on the negative half cycle because the anode of D1 is negative with
respect to the cathode. During this interval, C1 discharges through the load resistor (RL).
The discharge of C1 produces the downward slope as indicated by the solid line on the
waveform in view B. In contrast to the abrupt fall of the applied ac voltage from peak
value to zero, the voltage across C1 (and thus across RL) during the discharge period
gradually decreases until the time of the next half cycle of rectifier operation. Keep in
mind that for good filtering, the filter capacitor should charge up as fast as possible and
discharge as little as possible.
POSITIVE HALF-CYCLE
VITS-Karimnagar 19 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
Mini Project Report on PIR Sensor Based Intrusion Detection System
CHAPTER-4
4. PIC MICROCONTROLLER
4.1. Introduction
The PIC16F72 CMOS FLASH-based 8-bit microcontroller is upward compatible with
PIC16C72/72A and PIC16F872devices. It features 200 ns instruction execution, self
programming, an ICD, 2 Comparators, 5 channels of 8-bit Analog-to-Digital (A/D)
converter, 2 capture/compare/PWM functions, a synchronous serial port that can be
configured as either 3-wire SPI or 2-wire I2C bus, a USART, and a Parallel Slave Port.
High-Performance RISC CPU
High performance RISC CPU
Only 35 single word instructions to learn
All single cycle instructions except for program branches which are two-cycle
Operating speed: DC - 20 MHz clock input DC - 200 ns instruction cycle
2K x 14 words of Program Memory
128 x 8 bytes of Data Memory (RAM)
Pin out compatible to the PIC16C72/72A and PIC16F872
Interrupt capability
Eight level deep hardware stack
Direct, Indirect and Relative Addressing modes
Peripheral Features
Timer0: 8-bit timer/counter with 8-bit prescaler Timer1: 16-bit timer/counter with prescaler, can be incremented during SLEEP
via external crystal/clock Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler Capture, Compare, PWM (CCP) module
VITS-Karimnagar 39 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
Capture is 16-bit, max resolution is 12.5 ns Compare is 16-bit, max resolution is 200 ns PWM max resolution is 10-bit 8-bit, 5-channel Analog-to-Digital converter Synchronous Serial Port (SSP) with SPI (Master mode) and I2C (Slave) Heat sink/Source Current:25 mA Brown-out detection circuitry for Brown-out Reset (BOR)
CMOS Technology:
Low power, high speed CMOS FLASH technology
Fully static design
Wide operating voltage range: 2.0V to 5.5V
industrial temperature range
Low power consumption:
- < 0.6 mA typical @ 3V, 4 MHz
- 20 μA typical @ 3V, 32 kHz
- < 1 μA typical standby current
Following are the major blocks of PIC Microcontroller.
Program memory (FLASH) is used to storing a written program. Since memory made
in FLASH technology can be programmed and cleared more than once, it makes this
microcontroller suitable for device development.
EEPROM- data memory that needs to be saved when there is no supply. It is usually
used for storing important data that must not be lost if power supply suddenly stops. For
instance, one such data is an assigned temperature in temperature regulators. If during a
loss of power supply this data was lost, we would have to make the adjustment once
again upon return of supply. Thus our device looses on self-reliance.
RAM - Data memory used by a program during its execution. In RAM are stored all
inter-results or temporary data during run-time.
PORTS are physical connections between the microcontroller and the outside world.
PIC16F72 has 22 I/O pins.
VITS-Karimnagar 40 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
FREE-RUN TIMER is an 8-bit register inside a microcontroller that works
independently of the program. On every fourth clock of the oscillator it increments its
value until it reaches the maximum (255), and then it starts counting over again from
zero. As we know the exact timing between each two increments of the timer contents,
timer can be used for measuring time which is very useful with some devices
4.2. Pin description
PIC16F72 has a total of 28 pins. It is most frequently found in a DIP28 type of case but
can also be found in SMD case which is smaller from a DIP. DIP is an abbreviation for
Dual In Package. SMD is an abbreviation for Surface Mount Devices suggesting that
holes for pins to go through when mounting aren't necessary in soldering this type of a
component.
Figure 4.1: PIC16F72 Microcontroller
Pins on PIC16F72 microcontroller have the following meaning:
There are 28 pins on PIC16F72. Most of them can be used as an IO pin. Others are
already for specific functions. These are the pin functions.
1. MCLR – to reset the PIC
2. RA0 – port A pin 0
VITS-Karimnagar 41 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
3. RA1 – port A pin 1
4. RA2 – port A pin 2
5. RA3 – port A pin 3
6. RA4 – port A pin 4
7. RA5 – port A pin 5
8. VSS – ground
9. OSC1 – connect to oscillator
10. OSC2 – connect to oscillator
11. RC0 – port C pin 0 VDD – power supply
12. RC1 – port C pin 1
13. RC2 – port C pin 2
14. RC3 – port C pin 3
15. RC4 - port C pin 4
16. RC5 - port C pin 5
17. RC6 - port C pin 6
18. RC7 - port C pin 7
19. VSS - ground
20. VDD – power supply
21. RB0 - port B pin 0
22. RB1 - port B pin 1
23. RB2 - port B pin 2
24. RB3 - port B pin 3
25. RB4 - port B pin 4
26. RB5 - port B pin 5
27. RB6 - port B pin 6
28. RB7 - port B pin 7
By utilizing all of this pin so many application can be done such as:
1. LCD – connect to Port B pin.
2. LED – connect to any pin declared as output.
3. Relay and Motor - connect to any pin declared as output.
VITS-Karimnagar 42 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
4. External EEPROM – connect to I2C interface pin – RC3 and RC4 (SCL and SDA)
5. LDR, Potentiometer and sensor – connect to analogue input pin such as RA0.
6. GSM modem dial up modem – connect to RC6 and RC7 – the serial communication
interface using RS232 protocol.
For more detail function for each specific pin please refer to the device datasheet from
Microchip.
Ports
Term "port" refers to a group of pins on a microcontroller which can be accessed
simultaneously, or on which we can set the desired combination of zeros and ones, or
read from them an existing status. Physically, port is a register inside a microcontroller
which is connected by wires to the pins of a microcontroller. Ports represent physical
connection of Central Processing Unit with an outside world. Microcontroller uses them
in order to monitor or control other components or devices. Due to functionality, some
pins have twofold roles like PA4/TOCKI for instance, which is in the same time the
fourth bit of port A and an external input for free-run counter. Selection of one of these
two pin functions is done in one of the configuration registers. An illustration of this is
the fifth bit T0CS in OPTION register. By selecting one of the functions the other one is
disabled.
All port pins can be designated as input or output, according to the needs of a device
that's being developed. In order to define a pin as input or output pin, the right
combination of zeros and ones must be written in TRIS register. If the appropriate bit of
TRIS register contains logical "1", then that pin is an input pin, and if the opposite is true,
it's an output pin. Every port has its proper TRIS register. Thus, port A has TRISA, and
port B has TRISB. Pin direction can be changed during the course of work which is
particularly fitting for one-line communication where data flow constantly changes
direction.
VITS-Karimnagar 43 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
PORTB and TRISB
PORTB has adjoined 8 pins. The appropriate register for data direction is TRISB. Setting
a bit in TRISB register defines the corresponding port pin as input, and resetting a bit in
TRISB register defines the corresponding port pin as output.
Figure 4.2.1: PORTSB And TRISB
VITS-Karimnagar 44 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
Each PORTB pin has a weak internal pull-up resistor (resistor which defines a line to
logic one) which can be activated by resetting the seventh bit RBPU in OPTION register.
These ‘pull-up’ resistors are automatically being turned off when port pin is configured
as an output. When a microcontroller is started, pull-ups are disabled.
Four pins PORTB, RB7:RB4 can cause an interrupt which occurs when their status
changes from logical one into logical zero and opposite. Only pins configured as input
can cause this interrupt to occur (if any RB7:RB4 pin is configured as an output, an
interrupt won't be generated at the change of status.) This interrupt option along with
internal pull-up resistors makes it easier to solve common problems we find in practice
like for instance that of matrix keyboard. If rows on the keyboard are connected to these
pins, each push on a key will then cause an interrupt. A microcontroller will determine
which key is at hand while processing an interrupt It is not recommended to refer to port
B at the same time that interrupt is being processed.
PORTA and TRISA
PORTA has 5 adjoining pins. The corresponding register for data direction is TRISA at
address 85h. Like with port B, setting a bit in TRISA register defines also the
corresponding port pin as input, and clearing a bit in TRISA register defines the
corresponding port pin as output.
It is important to note that PORTA pin RA4 can be input only. On that pin is also situated
an external input for timer TMR0. Whether RA4 will be a standard input or an input for a
counter depends on T0CS bit (TMR0 Clock Source Select bit). This pin enables the timer
TMR0 to increment either from internal oscillator or via external impulses on
RA4/T0CKI pin.
Example shows how pins 0, 1, 2, 3, and 4 are designated input, and pins 5, 6, and 7
output. After this, it is possible to read the pins RA2, RA3, RA4, and to set logical zero
or one to pins RA0 and RA1.
VITS-Karimnagar 45 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
Figure 4.2.2: PORTSA And TRISA
4.3. Central Processing Unit
CPU has a role of connective element between other blocks in the microcontroller. It
coordinates the work of other blocks and executes the user program.
VITS-Karimnagar 46 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
CISC, RISC
It has already been said that PIC16F72 has RISC architecture. This term is often found in
computer literature, and it needs to be explained here in more detail. Harvard architecture
is a newer concept than von-Neumann. It rose out of the need to speed up the work of a
microcontroller. In Harvard architecture, data bus and address bus are separate. Thus a
greater flow of data is possible through the central processing unit, and of course, a
greater speed of work. Separating a program from data memory makes it further possible
for instructions not to have to be 8-bit words. PIC16F72 uses 14 bits for instructions,
which allows for all instructions to be one-word instructions. It is also typical for Harvard
architecture to have fewer instructions than von-Neumann’s, and to have instructions
usually executed in one cycle.
Microcontrollers with Harvard architecture are also called "RISC microcontrollers".
RISC stands for Reduced Instruction Set Computer. Microcontrollers with von-
Neumann's architecture are called 'CISC microcontrollers'. Title CISC stands for
Complex Instruction Set Computer.
Since PIC16F72 is a RISC microcontroller, that means that it has a reduced set of
instructions, more precisely 35 instructions. (Ex. Intel's and Motorola's microcontrollers
have over hundred instructions) All of these instructions are executed in one cycle except
for jump and branch instructions. According to what its maker says, PIC16F72 usually
reaches results of 2:1 in code compression and 4:1 in speed in relation to other 8-bit
microcontrollers in its class.
VITS-Karimnagar 47 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
Applications
PIC16F72 perfectly fits many uses, from automotive industries and controlling home
appliances to industrial instruments, remote sensors, electrical door locks and safety
devices. It is also ideal for smart cards as well as for battery supplied devices because of
its low consumption.
EEPROM memory makes it easier to apply microcontrollers to devices where permanent
storage of various parameters is needed (codes for transmitters, motor speed, receiver
frequencies, etc.). Low cost, low consumption, easy handling and flexibility make
PIC16F72 applicable even in areas where microcontrollers had not previously been
considered (example: timer functions, interface replacement in larger systems,
coprocessor applications, etc.).
In System Programmability of this chip (along with using only two pins in data transfer)
makes possible the flexibility of a product, after assembling and testing have been
completed. This capability can be used to create assembly-line production, to store
calibration data available only after final testing, or it can be used to improve programs
on finished products.
Clock / instruction cycle
Clock is microcontroller's main starter, and is obtained from an external component
called an "oscillator". If we want to compare a microcontroller with a time clock, our
"clock" would then be a ticking sound we hear from the time clock. In that case,
oscillator could be compared to a spring that is wound so time clock can run. Also, force
used to wind the time clock can be compared to an electrical supply.
Clock from the oscillator enters a microcontroller via OSC1 pin where internal circuit of
a microcontroller divides the clock into four even clocks Q1, Q2, Q3, and Q4 which do
not overlap. These four clocks make up one instruction cycle (also called machine cycle)
during which one instruction is executed.
Execution of instruction starts by calling an instruction that is next in string. Instruction is
called from program memory on every Q1 and is written in instruction register on Q4.
Decoding and execution of instruction are done between the next Q1 and Q4 cycles. On
VITS-Karimnagar 48 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
the following diagram we can see the relationship between instruction cycle and clock of
the oscillator (OSC1) as well as that of internal clocks Q1-Q4. Program counter (PC)
holds information about the address of the next instruction.
.
Pipelining
Instruction cycle consists of cycles Q1, Q2, Q3 and Q4. Cycles of calling and executing
instructions are connected in such a way that in order to make a call, one instruction cycle
is needed, and one more is needed for decoding and execution. However, due to
pipelining, each instruction is effectively executed in one cycle. If instruction causes a
change on program counter, and PC doesn't point to the following but to some other
address (which can be the case with jumps or with calling subprograms), two cycles are
needed for executing an instruction. This is so because instruction must be processed
again, but this time from the right address. Cycle of calling begins with Q1 clock, by
writing into instruction register (IR). Decoding and executing begins with Q2, Q3 and Q4
clocks.
VITS-Karimnagar 49 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
4.4. Memory Organization
PIC16F72 has two separate memory blocks, one for data and the other for program.
EEPROM memory with GPR and SFR registers in RAM memory make up the data
block, while FLASH memory makes up the program block.
Program Memory:
Program memory has been carried out in FLASH technology which makes it possible to
program a microcontroller many times before it's installed into a dev9ice, and even after
its installment if eventual changes in program or process parameters should occur. The
size of program memory is 1024 locations with 14 bits width where locations zero and
four are reserved for reset and interrupt vector.
Data Memory:
Data memory consists of EEPROM and RAM memories. EEPROM memory
consists of 256 eight bit locations whose contents are not lost during loosing of power
supply. EEPROM is not directly addressable, but is accessed indirectly through EEADR
and EEDATA registers. As EEPROM memory usually serves for storing important
parameters (for example, of a given temperature in temperature regulators) , there is a
strict procedure for writing in EEPROM which must be followed in order to avoid
accidental writing. RAM memory for data occupies space on a memory map from
location 0x0C to 0x4F which comes to 68 locations. Locations of RAM memory are also
VITS-Karimnagar 50 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
called GPR registers which is an abbreviation for General Purpose Registers. GPR
registers can be accessed regardless of which bank is selected at the moment.
4.5. PIC C Compiler
PIC compiler is software used where the machine language code is written and
compiled. After compilation, the machine source code is converted into hex code which
is to be dumped into the microcontroller for further processing. PIC compiler also
supports C language code.
It’s important that you know C language for microcontroller which is commonly known
as Embedded C. As we are going to use PIC Compiler, hence we also call it PIC C. The
PCB, PCM, and PCH are separate compilers. PCB is for 12-bit opcodes, PCM is for 14-
bitopcodes, and PCH is for 16-bit opcode PIC microcontrollers. Due to many similarities,
all three compilers are covered in this reference manual. Features and limitations that
apply to only specific microcontrollers are indicated within. These compilers are
specifically designed to meet the unique needs of the PIC microcontroller. This allows
developers to quickly design applications software in a more readable, high-level
language. When compared to a more traditional C compiler, PCB, PCM, and PCH have
some limitations. As an example of the limitations, function recursion is not allowed.
This is due to the fact that the PIC has no stack to push variables onto, and also because
of the way the compilers optimize the code. The compilers can efficiently implement
normal C constructs, input/output operations, and bit twiddling operations. All normal C
data types are supported along with pointers to constant arrays, fixed point decimal, and
arrays of bits.
PIC C is not much different from a normal C program. If you know assembly, writing a C
program is not a crisis. In PIC, we will have a main function, in which all your
application specific work will be defined. In case of embedded C, you do not have any
operating system running in there. So you have to make sure that your program or main
file should never exit. This can be done with the help of simple while (1) or for (;;) loop
as they are going to run infinitely.
VITS-Karimnagar 51 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
. CHAPTER-5
5. PIR SENSOR
A Passive Infrared sensor (PIR sensor) is an electronic device which measures infrared
light radiating from objects in its field of view. Apparent motion is detected when an
infrared source with one temperature, such as a human, passes in front of an infrared
source with another temperature, such as a wall. All objects emit what is known as black
body radiation. This energy is invisible to the human eye but can be detected by
electronic devices designed for such a purpose. The term 'passive' in this instance means
the PIR does not emit energy of any type but merely accepts incoming infrared radiation.
The most frequent use of the PIR sensor is as an 'area' sensor. Whether it is to detect
'someone moving in the front yard', or 'someone moving in the bathroom', or 'someone
moving through a doorway', or even 'someone opened the beer cooler', it is all technically
the same sensor and logic.
There is a simple electronic device which is sensitive to 'heat', or rather the infrared light
that is emitted by warm or hot objects (like humans).
The 'logic' of the PIR sensor is that it must detect 'significant change' of the normal level
of heat within the 'field' of its view. The circuits that control it must be able to determine
what 'normal' is, and then close a switch when the normal field changes, as when a
human walks in front of it. It must also be able to 'tolerate' slow changes within the field,
and remember that as the new 'normal'. This is so that gradual changes like the sunlight
changes throughout the day don't cause a false alarm. This is a standard behavior of 'PIR'
type sensors. (There's a lot more electronics there than just the black window...)
VITS-Karimnagar 52 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
We'll notice in all three pictures of PIR type sensors on this page, that they all have some
sort of plastic 'lens' that covers the circuit board and the PIR sensor device. This is a
'Fresnel' lens. It 'pinches' light that passes thru it. If you hold it to your eye, you can see
that there are apparent distinct 'bars' of light as you move it across a scene. Some of these
bars may be vertical, and some may be horizontally oriented.
The lenses that are made for most PIR sensor tend to ‘pinch’ the light such that it is
horizontally sensitive.
This means that the Lens/PIR will be more sensitive to motion of a warm body,
horizontally 'across the field of view'. Please note that this means that these sensors are
most insensitive to warm bodies moving from a 'distance' and directly towards one of
these common devices...!
A motion sensor says:
- All motion sensors send ‘ON’ message when they first see motion.
- Most will also send ‘OFF’ message when motion has not been seen for a set period of
time.
- Some will continue to send ‘ON’ message periodically as long as motion continues.
- Others may only announce the first event, and say nothing again until the area has been
quiet for a set of period.
The PIR sensor itself:
The IR sensor itself is housed in a hermetically sealed metal can to improve
noise/ temperature / humidity immunity. There is a window made of IR-
transmissive material (typically coated silicon since that is very easy to come by) that
protects the sensing element.
Behind the window are the two balanced sensors.
VITS-Karimnagar 53 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
Figure 5.1:Working of PIR sensor
Lenses:
PIR sensors are rather generic and for the most part vary only in price and sensitivity.
Most of the real magic happens with optics. This is a pretty good idea for manufacturing
the PIR sensor and circuitry is fixed and costs a few dollars. The lens costs only a few
cents and can change the breadth, range, sensing pattern very easily.
In the diagram above the lens is just a piece of plastic but that means that the detection
area is just two rectangles. Usually we’d have a detection area that is much larger. To do
that we use a simple lens such as those found in camera: they condenses a large area
(such as a landscape) into a small one (on film or a CCD sensor). For reasons that will be
apparent soon, we would like to make the PIR lenses small and thin and moldable from
cheap plastic, even though it may add distortion. For this reason the sensors are actually
Key Specifications: Power requirements: 3.3 to 5 VDC Communication: single bit high/low output Dimensions: 1.27 x 0.96 x 1.0 in (32.2 x 24.3 x 25.4 mm) Operating temp range: +32 to +121 °F (0 to +50 °C).
5.2. PIR Motion Sensor Module
VITS-Karimnagar 57 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
Compact and complete, easy to use Passive Infrared (PIR) Sensor Module for human
body detection. Incorporating a Fresnel lens and motion detection circuit, suitable for a
wide range of supply voltages and with low current drain. High sensitivity and low noise.
Output is a standard 5V active high output signal.
Module provides an optimized circuit that will detect motion up to 6 meters away and can
be used in burglar alarms and access control systems. Inexpensive and easy to use, it's
ideal for alarm systems, motion-activated lighting, holiday props, and robotics
applications.
The Output can be connected to microcontroller pin directly to monitor signal or a
connected to transistor to drive DC loads like a bell, buzzer, siren, relay, opto-coupler
(e.g. PC817, MOC3021), etc. The PIR sensor and Fresnel lens are fitted onto the the
PCB. This enables the board to be mounted inside a case with the detecting lens
protruding outwards.
Fig5.3: PIR sensor
Theory 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, which are
measured by an on-board amplifier. The device contains a special filter called a Fresnel
lens, which focuses the infrared signals onto the element. As the ambient infrared signals
change rapidly, the on-board amplifier trips the output to indicate motion.
VITS-Karimnagar 58 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
The PIR (Passive Infra-Red) Sensor is a pyroelectric device that detects motion by
measuring changes in the infrared (heat) levels emitted by surrounding objects. This
motion can be detected by checking for a sudden change in the surrounding IR patterns.
When motion is detected the PIR sensor outputs a high signal on its output pin. This logic
signal can be read by a microcontroller or used to drive a transistor to switch a higher
current load.
Startup
The PIR Sensor requires a ‘warm-up’ time in order to function properly. This is due to
the settling time involved in ‘learning’ its environment. This could be anywhere from 10-
60 seconds. After this warm up time, sensor will be ready to use.
Range of Operation:
The PIR Sensor has a range of approximately 20 feet(6 meters). This can vary
with environmental conditions. The sensor is designed to adjust to slowly changing
conditions that would happen normally as the day progresses and the environmental
conditions change, but respond by making its output high when sudden changes occur,
such as when there is motion.
VITS-Karimnagar 59 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
Figure 5.4:PIR Sensor range operation
This device is designed for indoor use. Operation outside or in extreme temperatures may
affect stability negatively.
Due to the high sensitivity of PIR sensor device, it is not recommended to use the module
in the following or similar condition.
A) In rapid environmental changes & strong shock or vibration.
B) In a place where there are obstructing material (eg. glass) through which IR
Cannot pass within detection area.
VITS-Karimnagar 60 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
C) Exposed to direct sunlight or direct wind from a heater or air condition
VITS-Karimnagar 61 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
CHAPTER-6
6. Result: In this chapter we will be discuss about the accuracy of the all components
and. performance will be clearly understood.
VITS-Karimnagar 62 B.TECH(ECE)
INPUT
PARAMETER
FUNCTIONALITY OUTPUT INTERMEDIATE
COMPONENTS
1 POWER SUPPLY CONVERTS 230V
AC TO 5V DC BY
RECTIFICATION
AND FILTERING
+5V TRANSFORMER,REC
TIFIER,
CAPACITOR
FILTER,REGULATOR
2 PIR SENSOR CHECKS FOR
THE PRESENCE
OF IR RAYS
‘1’ IF
PIR
SENSOR
DETECTS
IR RAYS
ELSE ‘0’
3 MICROCONTROLL
ER
USED FOR
INTERFACING
ALL OTHER
COMPONENTS
GIVING SUPPLY
TO ALL OTHER
COMPONENTS
5V PORTS
4 BUZZER IT PRODUCES
BEEP SOUND
5V BUZZER DRIVER
5 CRYSTAL
OSCILLATOR
IT GIVES THE
CLOCK PULSES
0-20MHZ CRYSTAL
Mini Project Report on PIR Sensor Based Intrusion Detection System
Whenever a person comes nearer to PIR sensor, the sensor will detect PIR rays emitted
from a human body.The output of PIR sensor is digital ‘1’,which is given as input to the
PIC microcontroller. The microcontroller will then send an instruction to the buzzer to
alert. Thus the presence of human being can be detected by the buzzer alert.
Applications
It helps the owner of the house to monitor his home.
It can be used in banks, offices to know the entry of an unauthorized person.
We have a idea to develop this system in future by interfacing a GPS to the system so
that one can get a message to the mobile when a stranger enters into home.Also by
interfacing a cam we can also get a picture of the stranger when we are out of home.
6.1 Conclusion:
We can conclude that the project PIR sensor based intrusion detection system has been
successfully designed and tested. Integrating switches of all the hardware components
used have developed it. Presence of every module has been reasoned out and placed
carefully thus contributing to the best working of the unit. Secondly using highly
advanced IC’s and with the help of growing technology the project has been successfully
implemented.Enhancement in science and technology has made the world fully
atomized .This project provides cent percent security by giving a buzzer sound whenever
it detects IR rays from human beings.
6.2 Future Scope:
We have a idea to develop this system in future by interfacing a GPS to the system so
that one can get a message to the mobile when a stranger enters into home. Also by
interfacing a cam we can also get a picture of the stranger when we are out of home.
VITS-Karimnagar 63 B.TECH(ECE)
Mini Project Report on PIR Sensor Based Intrusion Detection System
CHAPTER-7
References/Bibliography:
Books referred:
1. Raj kamal –Microcontrollers Architecture, Programming, Interfacing and System
Design.
2. Mazidi and Mazidi –Embedded Systems.
3. PCB Design Tutorial –David.L.Jones.
4. PIC Microcontroller Manual – Microchip.
5. Pyroelectric Sensor Module- Murata.
6. Embedded C –Michael.J.Pont.
WEBSITES:
The sites which were used while doing this project: