SlideShare a Scribd company logo
1 of 132
Download to read offline
PASSIVE INFRARED SENSOR (PIR)
BASED SECURITY SYSTEM
Project Report
Submitted in partial fulfilment of the requirements for the
award of the degree of Bachelor of Engineering
In
Electronics and Communication Engineering
By:
Ms. Pema Chodon Ms. Devi Maya Adhikari
Mr. Gopal Chandra Nepal Mr.Sangay Gyeltshen
Mr. Rajen Biswa
Under the Guidance of:
Mr. Chencho
DEPARTMENT OF ELECTRONICS AND COMMUNICATION
ENGINEERING
COLLEGE OF SCIENCE AND TECHNOLOGY
PHUENTSHOLING, BHUTAN
June 2013
ROYAL UNIVERSITY OF BHUTAN
COLLEGE OF SCIENCE AND TECHNOLOGY
DEPARTMENT OF ELECTRONICS AND COMMUNICATION
ENGINEERING
CERTIFICATE
This is to certify that the B.E. project titled “Passive Infrared Sensor (PIR) Based
Security System”, which is being submitted by Ms. Devi Maya Adhikari
(ECE2009019), Mr. Gopal Chandra Nepal (ECE2009023), Ms. Pema Chodon
(ECE2009059) , Mr. Rajen Biswa (ECE2009070) and Mr. Sangay Gyeltshen
(ECE2009078), the students of BE Final year Electronics and Communication
Engineering, during the academic year 2012-2013 in partial fulfilment of the requirement
for the award of “Bachelor of Engineering in Electronics and communication
Engineering” as a record of students work carried out at College of Science and
Technology, Phuentsholing under my supervision and guidance.
Mr. Chencho
Project Guide
Page | i
ACKNOWLEDGEMENT
This report is fruition of hard work undertaken during course of the Project which is
carried out in group of five, under the guidance of Mr. Chencho, dating from June 2012 to
June 2013. Indeed, it is a great opportunity for us to have hand-on experience and verify
the theoretical knowledge with experimental setups, which further nurtures our capability;
preparing us for greater challenges that are going to be faced in future.
Therefore, we would like to deeply thank College of Science and Technology under the
Royal University of Bhutan for incorporating such an effective learning program and
providing us with this opportunity.
Most importantly, our heartiest gratitude goes to Mr. Chencho for his unwavering guide
and support throughout the project without which the completion of the project would not
have been possible. We would also like to earnestly thank Mr. Subash Sharma; M.S.
Tshongkhang, Phuentsholing for providing and sponsoring us with all the materials
required for the project.
Also, we would to thank Dr. Kazuhiro Muramatsu (Lecturer, Electrical Department),
Mr.Sangay Dorji (Senior Instructor, ECE Department), Mr. Yeshi Wangchuck (Asst.
Lecturer, IT Department), Ms.Tshewang Lhamo (Lab Technician), Mr. Kinzang Dorji
(Lab Technician), other faculties and friends who were involved directly or indirectly in
this project.
Mr. Gopal Chandra Nepal
Mr. Sangay Gyaltshen
Ms. Devi Maya Adhikari
Ms. Pema Chodon
Mr. Rajen Biswa
Page | ii
ABSTRACT
In this project, PIR based security system which saves the power energy consumption and
saves the memory space of the recording system has been developed. The security
system consists of four parts namely power supply, PIR sensor, lighting and recording
system. A single phase of 230V, 50 Hz was used as the primary source to the circuit
designed. This input voltage was stepped down, rectified and regulated to give supply to
the PIR sensor other circuits.
Passive Infrared Radiation (PIR) sensor is the main component of our project. It will
detect the change in infrared radiation which is radiated by warm blooded moving object
provided that the object is in its detection range. When the device is exposed to infrared
radiation, it generates an electric charge. According to the change in the amount of
infrared striking the element, there will be a change in the voltages generated. This output
generated was amplified and used to turn ON the webcam and lighting system. Software
was developed to record the video captured by webcam when it gets turned ON. It is
installed in the computer and was made to run. It will keep checking if the webcam is
turned ON or connected to the system. When an object comes in the detection range of
the PIR sensor, an output is generated which actuates the lighting system and the
webcam. The software detects the webcam connection; it will start to record and save the
video. Once the object moves out of detection range of the sensor, the webcam and light
gets turn OFF. The software will again check for the webcam and stops recording
resulting in saving of power consumption and the memory space of the recording system.
Page | iii
TERMINOLOGY
1. A: The symbol for amps, or amperes, which is a unit of current flow.
2. AC: Alternating Current. This is electric current that periodically changes the
direction in which it flows.
3. Algorithm: is a detailed, step-by-step description of how to perform some task.
4. Amplifier: A device, either a single stage or a large scale circuit with multiple
stages for creating gain, i.e. making small signals larger.
5. C++: is a computer language that is used to create applications.
6. Capacitor: a device consisting of two parallel plates separated by an insulator.
7. Current: The term given to electron flow.
8. DC: Direct current. This is constant electric current with zero frequency.
9. Differential Amplifier: is a type of amplifier which can amplify the difference of
input signals.
10. Debug: check for errors in programming.
11. PIR Sensor: passive electronic devices which detect motion by sensing infrared
fluctuations.
12. Rectifier: is a device used for converting A.C into D.C
13. Resistor: a circuit element that presents a resistance to the flow of electric current.
14. Transformer: device which is used to change alternating current (A.C) from one
voltage to another voltage. It is of two types viz. Step up transformer and step
down transformer.
15. Transistor: The transistor is a three layer semiconductor device transfer signal
from a low resistance to a high resistance.
16. Voltage: the term for electric force. Voltage is the energy per unit charge
created when positive and negative charges are separated.
17. Voltage Regulator: regulation is the process of holding a voltage steady under
conditions of changing applied voltage and changing load current.
18. Window Comparator: it detects when the input is between two limits.
Page | iv
LIST OF ABBREVIATION
Sl. No. Terms Descriptions
1 A.C Alternating current
2 A Ampere
3 BSD Berkeley Software Distribution
4 C capacitor
5 CCTV Closed circuit Television
6 CRO Cathode Ray Oscilloscope
7 D Diode
8 D.C Direct current
9 E.M.F Electro motive force
10 FW Full wave
11 HTML Hyper Text Mark-up Language
12 HW Half wave
13 IC Integrated Circuit
14 PIR Passive Infrared
15 R Resistor
16 V Volt
17 LDR Light Dependent Resistor
18 OpenCV
Free Open Source Computer
Vision
19 XML Extensive Mark-up Language
Page | v
LIST OF TABLES
Table 3.2-1: Comparison of simulation and experimentation results 44
Table 3.3-1: Comparison of Simulation and Experimentation Result 47
Table 3.4-1: Comparison of Simulation and Experimentation Result of 12V regulator 57
Table 3.5-1: Comparison of experimentation and simulation results of 5V regulator 62
Table 3.6-1: When PIR sensor is activated 69
Table 3.6-2: When PIR sensor is idle 69
Page | vi
LIST OF FIGURES
Figure 1.2-1 Block diagram representation of the project 17
Figure 2.2-1 Basic construction of transformer 22
Figure 2.3-1 Full Wave Rectifier using Centre Tap Transformer 24
Figure 2.3-2 Output DC Voltage Waveform after Full-wave Rectification 24
Figure 2.4-1 Connection of filter circuit 28
Figure 2.4-2 Output waveform from filter circuit 28
Figure 2.5-1 Block Diagram of the Regulated Dual Voltage DC Power Supply 29
Figure 2.5-2 Symbol for three terminal IC regulator 29
Figure 2.5-3 IC regulator 30
Figure 2.5-4 LM7912 IC regulator 31
Figure 2.5-5 Configuration figure of LM7805 IC regulator 32
Figure 2.5-6 Two similar regulators connected as a plus-minus supply 33
Figure 2.6-1 PIR sensor 34
Figure 2.7-1 Differential Amplifier 35
Figure 2.8-1 Window Comparator used for the design 36
Figure 2.8-2 Output of window detector 36
Figure 2.9-1 Transistor used as a switch 37
Figure 2.9-2 SL100 transistor 37
Figure 2.10-1 Internal diagram of relay 39
Figure 3.2-1: Circuit diagram for transformer 42
Figure 3.2-2: Input supply from normal 230V ac supply 42
Figure 3.2-3: Output waveform from step-down 16 volt transformer 43
Figure 3.2-4: Output from CRO 43
Figure 3.3-1: Simulation circuit for Full Wave Rectifier 45
Figure 3.3-2: Input Waveform 45
Figure 3.3-3: Output Waveforms 46
Figure 3.3-4: CRO Output from positive Rectifier 46
Figure 3.3-5: CRO Output from negative Rectifier 47
Figure 3.4-1: Diagram from the complete simulation of 12V regulator 53
Figure 3.4-2: Input and output waveform of +12v Regulator 54
Figure 3.4-3: Input and Output waveform of -12V Regulator 54
Figure 3.4-4: Output waveform of the 12V regulator 55
Page | vii
Figure 3.4-5: Output waveform for 5V regulator 55
Figure 3.4-6: CRO input and output of +12V regulator 56
Figure 3.4-7: CRO input and output of -12V regulator 56
Figure 3.4-8: CRO output of 5V Regulator 57
Figure 3.5-1 Circuit diagram for differential amplifier 59
Figure 3.5-2: Input waveform to amplifier (output of PIR sensor) 60
Figure 3.5-3: Output waveform from the amplifier 60
Figure 3.5-4: Input to amplifier when PIR sensor is activated 61
Figure 3.5-5: Output from CRO 61
Figure 3.6-1: Design circuit for window detector 63
Figure 3.6-2: Circuit diagram for window comparator 64
Figure 3.6-3: Output from the window comparator when PIR senor is activated 65
Figure 3.6-4: Output Waveform when PIR sensor is activated 65
Figure 3.6-5: Input waveform 66
Figure 3.6-6: Output from PIR sensor when it is idle (does not detects any intruder) 66
Figure 3.6-7: Input to the window comparator when PIR sensor is activated 67
Figure 3.6-8: Output from the window comparator when PIR sensor is activated 68
Figure 3.6-9: Output from the window comparator when PIR sensor is idle 68
Figure 3.6-10: output from the window comparator when PIR sensor is idle 69
Figure 3.6-11 Complete circuit diagram 71
Figure 3.7-1: Transistor used as a switch 72
Figure 4.4-1 Environment variable setting to integrate OpenCV 2.4.4 in Microsoft Visual
C++ 2010 80
Figure 4.4-2 Creating new project in Microsoft Visual C++ 2010 81
Figure 4.4-3 Empty project 81
Figure 4.4-4 Property setting in Microsoft Visual C++ 2010 from integration of OpenCV
2.4.4 82
Figure 4.4-5 Including OpenCV 2.4.4 directories in Microsoft Visual C++ 2010 82
Figure 4.4-6 To include OpenCV library in Microsoft Visual C++ 2010 83
Figure 4.4-7 Integrating OpenCV 2.4.4 libraries in Microsoft Visual C++ 2010 84
Figure 4.4-8 Creating new C++ file 84
Figure 5.2-1 Flow chart for the program 89
Figure 5.2-2 When program is starting 94
Page | viii
Figure 5.2-3 When webcam is not detected 94
Figure 5.2-4 When webcam is found 95
Figure 5.3-1Step for creating .exe file 96
Figure 5.3-2 Configuration Property setting for creating .exe file 96
Figure 5.3-3 Creating executable .dll independent file 97
Figure 5.3-4 Build .exe file of PIR Sensor 98
Figure 5.3-5 Window for capturing the video 98
Page | ix
LIST OF PHOTOGRAPHS
Photograph 6.2-1 When there is no intruder in the range of PIR sensor 102
Photograph 6.2-2 Intruder has been detected 103
Photograph 6.2-3 The webcam continuously records the scene when there is intruder in its
range 103
Photograph 6.2-4 When intruder is out of the range Lights and Webcam turns OFF 104
Page | x
TABLE OF CONTENT
Acknowledgement i
Abstract ii
Terminology iii
List of Abbreviation iv
List of Tables v
List of Figures vi
List of Photographs ix
CHAPTER 1: BACKGROUND AND INTRODUCTION 14
1.1 Background 15
1.2 Introduction 16
1.3 Motivation 17
1.4 Aim 18
1.5 Objectives 18
1.6 Project framework 18
1.7 Structure of the Project Report 19
CHAPTER 2: HARDWARE COMPONENTS- THEORY 21
2.1 Introduction 22
2.2 Transformer 22
2.2.1 Types of Transformer 22
2.2.2 Working of Transformer 23
2.3 Rectifier 24
2.3.1 Centre Tapped Full Wave Rectifier 24
2.4 Filters 25
2.4.1 Capacitor Filter 26
Page | xi
2.4.2 Working of Capacitor Filter 27
2.5 Voltage Regulator 28
2.5.1 IC Voltage Regulator 29
2.5.2 Plus-Minus Supplies 33
2.6 PIR Sensor 33
2.6.1 Working or PIR Sensor 33
2.7 Differential Amplifier 34
2.8 Window Comparator 35
2.9 Transistor as a Switch 36
2.10 Relay 38
2.10.1 Working of Relay 38
2.11 Summary 39
CHAPTER 3: DESIGN, SIMULATION AND EXPERIMENT OF HARDWARE
COMPONENTS 40
3.1 Introduction 41
3.2 Transformer 41
3.2.1 Design Procedure 41
3.2.2 Simulation and Results 42
3.2.3 Experimentation result obtained from breadboard 43
3.2.4 Comparison of simulation result and the experimentation result 44
3.3 Rectifier 45
3.3.1 Simulation result of centre-tapped rectifier 45
3.3.2 Experimentation result of rectifier 46
3.3.3 Comparison of Simulation and Experimentation Result 47
3.4 Voltage Regulator 48
3.4.1 Design Procedure 48
3.4.2 Simulation and result of power supply 53
Page | xii
3.4.3 Experimentation Results of voltage regulators 56
3.4.4 Comparison of Simulation and Experimentation Result 57
3.5 Differential Amplifier 58
3.5.1 Design Procedure 58
3.5.2 Simulation and Result of differential amplifier 59
3.5.3 Experimentation 61
3.5.4 Comparison of simulation result and the experimentation result 62
3.6 Window Detector 62
3.6.1 Design Procedure 62
3.6.2 Simulation and Result of window comparator 64
3.6.3 Experimentation result of window comparator 67
3.6.4 Comparison of simulation result and the experimentation result of window
comparator 69
3.7 Transistor as switch 72
3.7.1 Design Procedures of transistor as a switch 72
3.1 Summary 73
CHAPTER 4: INTEGRATING OPENCV WITH MICROSOFT VISUAL C++ 2010
75
4.1 Introduction 76
4.2 Microsoft Visual C++ 2010 76
4.2.1 Introduction 76
4.3 OpenCV 77
4.3.1 Introduction 77
4.4 Integration of OpenCV 2.4.4 with Microsoft Visual C++ 2010 79
4.4.1 Environment Setting 79
4.4.2 Creating a new project and set up Visual C++ 80
4.5 Different libraries used from OpenCV 85
Page | xiii
4.6 Summary 86
CHAPTER 5: SOFTWARE PROGRAM 87
5.1 Introduction 88
5.2 General working of the program 88
5.2.1 Algorithm 88
5.2.2 Flow Chart 89
5.2.3 Program 90
5.2.4 Output of the Program 94
5.3 Creating Executable file (.exe) 95
5.4 Summary 98
CHAPTER 6: DEMONSTRATION 100
6.1 Introduction 101
6.2 Demonstrations 101
6.3 Summary 104
CHAPTER 7: CONCLUSION, CRITICAL ANALYSIS AND FUTURE WORKS106
7.1 Conclusion 107
7.2 Critical Analysis 107
7.3 Future works 109
Reference 111
Appendices 115
Appendix A: Diode 1N4007 115
Appendix B: LM7805 and LM7812 Positive IC Voltage Regulator 116
Appendix C: LM7912 Negative IC Voltage Regulator 119
Appendix D: uA741 Operational Amplifier (OPAMP) 121
Appendix E: LM324 Single Supply Quad Operational Amplifier 125
Appendix F: PCB Relay (JQC-3F(T73)) 129
Page | 14
SECTION A
CHAPTER 1: BACKGROUND AND INTRODUCTION
Objectives of the chapter
 Outlines the Background, Aim, Objectives, Motivations, Project
Framework and structure of the project.
Page | 15
1.1 Background
Due to increasing number of crime and burglary, the need of security system is very
essential. The security system that monitors the area throughout the time and reacts
effective to the treat is in need.
We have lots of security systems in the market for both indoor and outdoor applications
such as ultrasonic detectors, CCTV, microwave detectors, photoelectric detectors,
infrared detectors etc. ( Chowdhury, Imtiaz, Azam, Sumi, & Nur, 2013). However one or
the other systems have the following disadvantages:
 expensive (Lazko, 2013)
 keeps running even when there are no intruders, thereby consuming more
memory
 complex circuitry
 consumes large power
 operation can be effected in different temperatures (Anon, 2013)
A solution to overcome these problems could be by using a sensor of low cost which has
the ability to detect the intruders as they come within the sensor’s detection range and
generates an output. This output could be used for further signal processing or activating
other devices like alarms system, lighting system, recording system and similar devices.
This could at least save some power consumptions as some components get actuated only
when there are intruders. Passive Infrared Sensor is a low cost, low power and reliable
sensor (Zappi, Farella, & Benini, 2008). PIR sensors are manufactured with reduced form
factor too. It has the ability to detect infrared rays and gets activated resulting in
generation of electrical signal as the output. Therefore it was felt that a PIR sensor based
security system consisting of the sensor, lighting system and a recording system (webcam
and the software for saving the video) could overcome few or all of the above stated
problems. The sensor can detect the presence of anything that comes in its range and has
the ability to emit infrared rays. Upon detection, it generates the output in the form of
electrical signal. Although the output from the sensor is of few volts, it could be amplified
to required voltage using amplifier circuit and could be used for actuating lighting system
and the webcam. The lighting and webcam could be turned on when the PIR sensor is
activated and could remain off when the sensor is not activated. This way, the energy
activated and could remain off when the sensor is not activated. This way, the energy
Page | 16
consumed by the overall system could be minimised. Also the cost of system could be far
less than the security system available in the market. With this hypothesis, we have
carried out this project. It consists of designing of hardware components and software
development for the recording video on the computer upon activation of the webcam.
1.2 Introduction
Figure 1.2-1 shows the block diagram representation of our project. PIR sensors belong to
the class of thermal detectors. Thermal detectors can measure incident radiation by means
of a change in their temperature (Zappi, Farella, & Benini, 2008). PIR sensors are
designed to detect human bodies, thus the wavelengths of interest are mainly in the range
of the infrared window at 8-14μm, in which the IR emission of bodies at 370
C also peaks
(Zappi, Farella, & Benini, 2008).
A PIR sensor used in this project has some additional electronics circuitry for detecting
intruder in the area. When the sensor is exposed to infrared radiation from human passing
by the intended region, it generates an electric charge. A step down transformer is used to
step down the input voltage of 230V AC to 16V AC using a 16-0-16 centre-tapped
transformer. This 16V AC is rectified to get DC and regulated as per the requirement in
later circuitries (PIR sensor and Comparator) of the system. 12V and 5V regulated output
were obtained from two regulators and are used for the comparator/amplifier and PIR
sensor respectively. The PIR sensor works with 5V DC input and gives DC output of 3-5
volts. The output is then amplified for activating the relay and the webcam. More on
theory, design simulation and practical results of components of this project are discussed
in the later chapters of the report.
The system works in the following steps:
1. The software developed is kept running and it keep checking if the webcam is
ON.
2. When an intruder comes in the detection range of the sensor, the sensor
generates output of 3.3 volts.
3. This output is further amplified and is used for activating the relay of the
lighting system and webcam of the recording system.
4. Once the relay and webcam are turned on with the output from the amplifier,
the software finds the webcam is ON.
Page | 17
5. The software starts to save the video captured by the webcam on the computer.
6. After the intruder leaves the detection range of the sensor, there is no output
from the sensor. Therefore, it turns OFF the lamp and the webcam. The video
captured will be saved in the computer.
7. Every time when the intruders come in the detection range of the sensor, the
above steps from step 2- step 6 repeats.
Figure 1.2-1 Block diagram representation of the project
1.3 Motivation
With the increasing cases of theft in the college and around which generally took place at
night hours, it was felt a security system could prevent this. After studying few of the
security systems available in the market, it was found out these systems need to be turned
ON for whole night and the video captured by the system is recorded. The intruder’s face
cannot be figured out from the video recorded if the light is not turned ON during the
recording time and it is must that the lighting system should be kept ON along with the
recording system. These system remains turned ON even when there are no intruders
resulting in the consumption of the electric power and occupying more spaces of the
recording system.
Page | 18
Therefore, it was felt the need of system where in the lighting system and recording
system will get actuated when there is an intruder and gets turned OFF when the intruder
leaves. A security system with a sensor could be a solution to this. A PIR sensor is a
sensor which produces an electrical output upon detection of infrared. Human body can
generate infrared rays. So it was felt that using PIR sensor to detect the presence of
intruders and with its output to actuate the lighting system and recording system could be
a solution to prevent the theft cases. With this motivation, we have carried out our project.
1.4 Aim
The main aim of our project is to develop the PIR Sensor Based Security System which
consumes less electrical energy and saves memory space of the recording system.
1.5 Objectives
The following are the objectives set to achieve the main aim of the project.
 Find out and overcome limitations of the existing security system.
 Study about PIR sensor.
 To study about the process of recording by the webcam (both hardware and
software).
 Develop a suitable security system using PIR sensor which can capture and record
during the night hours or in the dark rooms consuming less electrical energy and
occupying less memory of the recording system (webcam and laptop).
1.6 Project framework
The proposed system started with in the following order:
 Literature review on PIR sensor based systems and performance of PIR sensor
was carried out.
 Find the methods to integrate the PIR sensor with hardware system (lighting
system, webcam and other electronic circuits).
 The study on software development for capturing and recording the video.
 Design PIR sensor based system.
Page | 19
1.7 Structure of the Project Report
The report is basically divided in to four sections viz. introduction & Background,
hardware, software and demonstration. Section A gives background and introduction of
the project. Section B gives the theoretical background, design, simulation, practical
testing and comparison of the simulation and experimentation in the lab of the circuit
designed. Section C gives introduction to the software used and the development of the
program to record video captured by the webcam. Section D talks about the practical
demonstration of our PIR sensor based Security System, conclusion, critical analysis and
future works.
Page | 20
SECTION B
HARDWARE COMPONENTS
Page | 21
CHAPTER 2: HARDWARE COMPONENTS- THEORY
Objective of the chapter
 Gives the brief theoretical background on different hardware components
used in the project
Page | 22
2.1 Introduction
This chapter gives brief theory on the hardware components used in our PIR Sensor
Based Security System. The working principles, types, expected output etc. of the
components were discussed in an order of the components used in the project.
2.2 Transformer
The transformer is a static device which works on principle of electromagnetic induction
to step up or step down the voltage. It consists of two side, the primary side and
secondary side which are separated by iron core (Sachdeva, 2012).
Figure 2.2-1 Basic construction of transformer
(Courtesy: http://www.physicstutorials.org/home/magnetism/transformers)
2.2.1 Types of Transformer
Generally transformers can be classified into two types:
i. Step Up transformer
ii. Step Down Transformer
 Step Up transformer
Step Up transformers are used to step up the input A.C voltage by making more number
of winding in secondary side than that of primary side.
 Step Down Transformer
Step Down transformers are used to step down the input A.C voltage by making more
number of winding in primary side than that of secondary side.
Page | 23
2.2.2 Working of Transformer
When we apply an A.C source to the primary side of the transformer (V1), due to the
phenomenon of electromagnetic induction the current in primary coil will produce
magnetic flux which is linked to the secondary coil. When there is change in current in
the primary side the flux in the secondary side also changes thus producing EMF (Electro
Motive Force) V2 as shown in Figure 2.2-1 (Anon, Transformer, August).
With reference to Figure 2.2-1, we can calculate the relation between the voltages,
currents and number of turns of the primary side/coil and secondary side of the
transformer (Anon, Rectifier, 2012).
2
1
2
1
N
N
V
V
 (2.2-1)
2
1
1
2
N
N
I
I
 (2.2-2)
Equating (2.2-1) and (2.2-2) we get:
1
2
2
1
I
I
V
V
 (2.2-3)
Where
1V = Voltage in primary side/coil
2V = Voltage in Secondary side/coil
1I = Current in primary
2I = Current in secondary
1N = Number of turns in Primary coil
2N = Number of turns in secondary coil
We are using centre tap transformer for the step down purpose in the project because in
centre tap transformer there is equal amount of voltage transfer in opposite polarity (that
is +V and –V).
Page | 24
2.3 Rectifier
Rectifier is a device used for converting A.C into D.C (Anon, Rectifier, 2012). The
process of converting Alternating Current (AC) into Direct Current (DC) is known as
rectification. Thus rectifiers can also be defined as electrical devices used to perform
rectification (Anon, Diode Lab).
The rectifiers are basically classified into three types according to their configuration
i. Half Wave Rectifier
ii. Full Wave Rectifier
iii. Bridge rectifier
2.3.1 Centre Tapped Full Wave Rectifier
In Full Wave Rectifier both the halves of the A.C signal are used to cause output current
to flow in the same direction. This type of rectifier usually uses Centre Tap transformer.
The figure of full wave rectifier is as shown in Figure 2.3-1 and its wave form is as shown
in Figure 2.3-2 (Bigelow, 1996)
Figure 2.3-1 Full Wave Rectifier using Centre Tap Transformer
Figure 2.3-2 Output DC Voltage Waveform after Full-wave Rectification
Page | 25
 Working of full wave rectifier
The full wave rectifier circuit consists of two diodes connected to a single load resistance
(RL) with each diode taking it in turn to supply current to the load. When point A of the
transformer is positive with respect to point C, diode D1 conducts in the forward direction
as indicated by the arrows. When point B is positive (in the negative half of the cycle)
with respect to point C, diode D2 conducts in the forward direction and the current
flowing through resistor R is in the same direction as that of positive half cycle. As the
output voltage across the resistor R is the phasor sum of the two waveforms combined,
this type of full wave rectifier circuit is also known as a "bi-phase" circuit (Storr,
Electronics-Tutorials.ws, 1999).
This project has used two full wave rectifiers to convert the AC input into DC output.
Why we have used centre tapped rectifier?
Though bridge rectifier is more advantage than Centre tapped full wave rectifier, the
centre tapped full wave rectifier as per the following reason:
 Requirement to generate plus-minus voltage to supply Op-Amps
If two bridge rectifiers are used, number of diode used in circuit increases (eight
diode), thereby increasing losses due to diode and size of circuit. Therefore, in
order to have clean circuit with reduced component, two centre tapped full wave
rectifier is (use only four diode) to generate plus-minus voltage.
2.4 Filters
While the output of a rectifier is a pulsating dc, most electronic circuits require a
substantially pure dc for proper operation. This type of output is provided by single or
multi-section filter circuits placed between the output of the rectifier and the load. An
electric filter is often a frequency-selective circuit that passes a specified band of
frequencies and blocks or attenuates signals of frequencies outside this band (Gayakwad).
A filter is an electrical network that alters the amplitude and/or phase characteristics of a
signal with respect to frequency. Ideally a filter will not add new frequencies to the input
signal nor will it change the component frequencies of that signal, but it will change the
relative amplitudes of the various frequency components and/or their phase relationships.
Page | 26
Filters are often used in electronic systems to emphasize signals in certain frequency
ranges and reject signals in other frequency ranges (Lacanette, 2012).
There are four basic types of filter circuits:
 Simple capacitor filter
 LC choke-input filter
 LC capacitor-input filter(pi-type)
 RC capacitor-input filter(pi-type)
2.4.1 Capacitor Filter
In our project we have used simple capacitor filter. A capacitor opposes any change in
voltage. The opposition to a change in current is called capacitive reactance (XC) and is
measured in ohms. The capacitive reactance is determined by the frequency (f) of the
applied voltage and the capacitance (C) of the capacitor.
FCXC
2
1
 (2.4-1)
Where
XC is capacitive reactance,
F is frequency,
C is capacitance
From the Equation 2.4-1, we can see that if frequency or capacitance is increased, the XC
decreases. Since filter capacitors are placed in parallel with the load, a low XC will
provide better filtering than a high XC. For this to be accomplished, a better shunting
effect of the ac around the load is provided. To obtain a steady dc output, the capacitor
must charge almost instantaneously to the value of applied voltage. Once charged, the
capacitor must retain the charge as long as possible. The capacitor must have a short
charge time constant. This can be accomplished by keeping the internal resistance of the
power supply as small as possible (fast charge time) and the resistance of the load as large
as possible.
As we know one time constant is defined as the time it takes a capacitor to charge to 63.2
% of the applied voltage or to discharge to 36.8 per cent of its total charge.
Page | 27
This action can be expressed by the following equation:
RCt  (2.4-2)
Where:
R represents the resistance of the charge or discharge path
C represents the capacitance of the capacitor.
A capacitor is considered fully charged after five RC time constants. A steady dc output
voltage is obtained when the capacitor charges rapidly and discharges as slowly as
possible.
In filter circuits the capacitor is the common element to both the charge and the discharge
paths. Therefore, to obtain the longest possible discharge time, capacitor value should be
as large as possible. Another way to look at it is: The capacitor acts as a short circuit
around the load (as far as the ac component is concerned) since the larger the value of the
capacitor (C), the smaller the opposition (XC) or reactance to ac.
This (passive) type of filter consists of large value of capacitor connected across the load
resistor. This capacitor offers a low reactance to the A.C components and very high
impedance to D.C, so that the A.C components in the rectifier output find low reactance
path through capacitor and only a small part flows through R, producing small ripple at
the output.
2.4.2 Working of Capacitor Filter
The value of CX should be smaller than R because, current should pass through C and C
should get charged. If C value is very small, CX will be large and hence current flows
through R only and no filtering action takes place. The capacitor C gets charged when the
diode (in the rectifier) is conducting and gets discharged (when the diode is not
conducting) through R. When the input voltage tVv sin is greater than the capacitor
voltage, C gets charged. When the input voltage is less than that of the capacitor voltage,
C will discharge through R (Ramesh, 2012). The stored energy in the capacitor maintains
the load voltage at a high value for a long period. The diode conducts only for a short
interval of high current. The connection of filter circuit and waveforms are as shown in
Figure 2.4-1 and 2.4-2 (Ramesh, 2012). Capacitor opposes sudden fluctuations in voltage
across it. So the ripple voltage is minimized.
Page | 28
For this project we are using shunt capacitor (C) passive filter.
Figure 2.4-1 Connection of filter circuit
Figure 2.4-2 Output waveform from filter circuit
The capacitor filter are used in our project since it provide us with the following
advantages
 Low cost
 Small size and weight
 Good characteristics
 Can be connected for both HW and FW rectifiers
 Improved D.C output
However the drawback is capacitor filter draws more current (Ramesh, 2012).
2.5 Voltage Regulator
Voltage regulation is the process of holding a voltage steady under conditions of
changing applied voltage and changing load current. The regulated power supply is to
provide the necessary dc voltage and current, with low level of ac ripple and with stability
and regulation. A device which is responsible for obtaining constant DC voltage is called
voltage regulator (Kuhn, 2009).
Many electronic systems require a stable power supply voltage and use voltage regulators
to accomplish that. The following block diagram shown in Figure 2.5-1 (Dev, Khan, &
Page | 29
K., 2009) below, shows how the voltage regulator is employed in the process of voltage
regulation.
TRANSFORMER
STEP-DOWN
RECTIFIER
FILTER
POSITIVE
REGULATOR
O
P
I
P
FILTER
NEGATIVE
REGULATOR
+V
-V
Figure 2.5-1 Block Diagram of the Regulated Dual Voltage DC Power Supply
2.5.1 IC Voltage Regulator
With the advent of the integrated technology now it has become technically and
economically feasible to incorporate all discrete components of regulator circuits in
monolithic form, giving all benefit if ICs, such as, excellent performance, small size, ease
of use, low cost, and above all high reliability. As the result three- terminal voltage
regulator are now available.
Figure 2.5-2 Symbol for three terminal IC regulator
The general circuit symbol of IC voltage regulators are shown in the Figure 2.5-2 (Dev,
Khan, & K., 2009). There are three terminals as labelled Vin, Vout and COM. The device
accepts the unregulated DC voltage across the Vin and COM terminal and yields a DC
regulated voltage across the Vout and COM terminals (Dev, Khan, & K., 2009).
 Classification of IC voltage regulator
The three terminal voltage with a variety of regulate output voltage rating are available
from different manufacturer. The well-known types of voltage regulator ICs are (Dev,
Khan, & K., 2009);
1. Three-terminal fixed voltage regulators (positive) : 78XX series
2. Three-terminal fixed voltage regulators (negative) : 79XX series
Page | 30
3. Three-terminal adjustable voltage regulators (positive) : LM 317
4. Three-terminal adjustable voltage regulators (negative) : LM 337
National Semiconductor offers 78XX/79XX series regulator with its standard LM prefix.
The last two digits ‘XX’ of the series give the rated nominal output voltage. For example
LM7805 regulator is +5V regulator and LM7905 is -5V regulator.
LM7812: A Positive Voltage Regulator (12V)
Figure 2.5-3 IC regulator
The LM7812 as shown in Figure 2.5-3 (Dev, Khan, & K., 2009) of three terminal positive
regulators are available in the TO-220 package and with several fixed output voltages,
making them useful in a wide range of applications. Each type employs internal current
limiting, thermal shut down and safe operating area protection, making it essentially
indestructible. If adequate heat sinking is provided, they can deliver over 1A output
current. Although designed primarily as fixed voltage regulators, these devices can be
used with external components to obtain adjustable voltages and currents.
Features:
1. Output Current up to 1A
2. Output Voltages of 12 volt
3. Thermal Overload Protection
4. Short Circuit Protection
5. Output Transistor Safe Operating Area Protection
Page | 31
LM7912: A Negative Voltage Regulator (-12V)
Figure 2.5-4 LM7912 IC regulator
The LM7912 regulator as shown in Figure 2.5-4 (Dev, Khan, & K., 2009) comes from
79xx family of self-contained fixed linear voltage regulator integrated circuits, where it
would give fixed output of -12V DC in ideal cases.
The LM79XX series of 3-terminal regulators is available with fixed output voltages of -
5V,-8V, -12V, and -15V. These devices need only one external component -a
compensation capacitor at the output. The LM79XX series is packaged in the TO-220
power package and is capable of supplying 1.5A of output current (Dev, Khan, & K.,
2009).
These regulators employ internal current limiting safe area protection and thermal
shutdown for protection against virtually all overload conditions. Low ground pin current
of the LM79XX series allows output voltage to be easily boosted above the pre-set value
with a resistor divider. The low quiescent current drain of these devices with a specified
maximum change with line and load ensures good regulation in the voltage boosted
mode.
Features:
1. Thermal, short circuit and safe area protection
2. High ripple rejection
3. 1.5A output current
4. 4% tolerance on pre-set output voltage
5V regulator (LM7805)
The standard configuration of IC voltage regulator LM7805 is as given in Figure 2.5-5.
However the simple configuration is also given below with certain value of capacitor with
Page | 32
intended fixed output 5 V. Such configuration can withstand short circuits and also
overheating. The only way the damage occurs is by the application of reverse voltage to
its input. Reverse polarity destroys regulator instantly (Khan & Dey, 2009).
Figure 2.5-5 Configuration of LM7805 IC regulator
Advantage of LM7805 series over other
The 7805 series has several key advantages over many other voltage regulator circuits
which have resulted in its popularity (Anon, National Semiconductor Cooperation ,
2000):
i. 7805 series ICs do not require any additional components to provide a constant,
regulated source of power, making them easy to use, as well as economical, and
also efficient uses of circuit board real estate. By contrast, most other voltage
regulators require several additional components to set the output voltage level
ii. 7805 series ICs have built-in protection against a circuit drawing too much
power. They also have protection against overheating and short-circuits, making
them quite robust in most applications. In some cases, the current-limiting
features of the 7805 devices can provide protection not only for the 7805 itself,
but also for other parts of the circuit it is used in, preventing other components
from being damaged as well.
Page | 33
2.5.2 Plus-Minus Supplies
Figure 2.5-6 Two similar regulators connected as a plus-minus supply
In this project IC regulator LM7812 and LM7912 as shown in Figure 2.5-6 (Bell, 2004) is
used in order to obtain plus-minus supplies. The negative output terminal of a voltage
regulator is grounded to give an output voltage which is positive with respect to ground.
So long as there are no grounded terminals in the unregulated supply, the positive output
of the regulator can be grounded to produce an output which is negative with respect to
ground. Using two dc voltage regulators, one positive and one negative terminal can be
connected together and grounded, as illustrated in Figure 2.5-6. This produces the type of
plus-minus voltage often used as supply for operational amplifier (Bell, 2004).
2.6 PIR Sensor
2.6.1 Working or PIR Sensor
PIR sensors are passive electronic devices which detect motion by sensing infrared
fluctuations. Once a motion is detected, a high signal is sent to the signal pin. Because of
the biological characteristic of organisms to emit heat; these sensors work well in
detecting human motion and therefore are commonly implemented in security
applications (Anon, National Semiconductor Cooperation , 2000).
The human body radiates infrared waves with wavelengths of 8 to 12 micrometres. Any
movement by a person leads to a change in the amount of infrared energy which a sensor
can detect within its range (Anon, Parallax)
Pyro-electric 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,
Page | 34
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
(Anon, Tech Note, 2010).
Figure 2.6-1 PIR sensor
Also PIR sensors work best when there is a large difference between the air temperature
and the animal. In warm temperatures, say above 80 degrees Fahrenheit, the detection
range will be reduced. In cold temperatures, below 40 degrees, the detection distance will
increase (Anon, Tech Note, 2010).
Typically, the PIR sensor that we have used has the detection range of 6 meters (20 feet),
and is designed to adjust to slowly to changing conditions environment as shown in
Figure 2.6-1 such as gradual change in the thermal profile of the surroundings as the day
passes
2.7 Differential Amplifier
Differential Amplifier is a special type of amplifier, which can amplify the difference of
input signals. It is used in another special type of amplifier circuit called Operational
Amplifier (OPAMP). The differential amplifier has two inputs: inverting input (input–1)
and non-inverting input (input–2). Its output signal is 180° out of phase with inverting
input signal and in phase with non-inverting input signal. For example, when negative
voltage is connected to inverting terminal we get positive voltage at output. Similarly,
when negative voltage is connected to non-inverting terminal, we get negative voltage at
output. The Figure 2.7-1 shows circuit of differential amplifier. It is symmetrical circuit,
Page | 35
i.e. it has same components on both sides. If all resistors are equal it becomes a straight
difference amplifier (Nave, 2011). The output of differential amplifier is given by:
1
3
1
113
413
2
)(
)(
R
R
V
RRR
RRR
VVout 


 (2.7-1)
If
12
;
44
RRRR 
Then, it gives an amplified difference (Nave, 2011).
2.7-1 Differential Amplifier
2.8 Window Comparator
The window comparator compares an input signal fed from the PIR sensor which is
amplified to a 'low' and a 'high' reference voltage level (VRef Low and VRef High,
respectively) which is a window. A window comparator is also called double-ended limit
detector as it detects when the input is between two limits. It uses two op-amps as
comparators and two reference voltages. If the input is between the windows (between
two reference levels) it outputs a logic low level. If the input is higher than VRef High or
lower than VRef Low, the output goes to logic high or the positive saturation. One of the
op amps is used for comparing the input to VRef High while the other op amp is used for
comparison with VRef Low (Paul, Industrial Electronics And Control, 2004).
The diodes (D1 and D2) are used to isolate the outputs of the two op amps from each other
(Anon, ECE lab, 2006). If the signal is in the window, the upper comparator will be at
negative saturation since its non-inverting input is negative. The lower comparator will
also be at negative saturation because its inverting input is positive. Both diodes are
Page | 36
reverse biased and the voltage across the load is zero. If the input becomes above the
upper limit, the upper comparator goes to a positive saturation. If the input turns less than
lower limit the lower comparator goes to positive saturation as its inverting inputs will be
negative to its non-inverting input. This will forward bias D2 and the combined output
becomes positive saturation (Anon, ECE lab, 2006).
Figure 2.8-1 Window Comparator used for the design
Figure 2.8-2 Output of window detector
2.9 Transistor as a Switch
When a transistor is used as a switch it must be either OFF or fully ON. In the fully ON
state the voltage VCE across the transistor is almost zero and the transistor is said to be
saturated because it cannot pass any more collector current IC. The output device switched
by the transistor is usually called the 'load'.
The power developed in a switching transistor is very small:
 In the OFF state: power = Ic × VCE, but Ic = 0, so the power is zero.
Page | 37
 In the full ON state: power = Ic × VCE, but VCE = 0 (almost), so the power is very
small.
Figure 2.9-1 Transistor used as a switch
This means that the transistor should not become hot in use and you do not need to
consider its maximum power rating. The important ratings in switching circuits are the
maximum collector current Ic (max) and the minimum current gain hFE (min). The
transistor's voltage ratings may be ignored unless you are using a supply voltage of more
than about 15V. There is a table showing technical data for some popular transistors on
the transistors page (Storr, Transistor as a switch, 2013).
In our project we are using SL100 transistor. SL100 is a general purpose, medium power
NPN transistor. It is mostly used as switch in common emitter configuration. The
transistor terminals require a fixed DC voltage to operate in the desired region of its
characteristic curves. This is known as the biasing. For switching applications, SL100 is
biased in such a way that it remains fully on if there is a signal at its base. In the absence
of base signal, it gets turned off completely.
Figure 2.9-2 SL100 transistor
Page | 38
The emitter leg of SL100 is indicated by a protruding edge in the transistor case. The base
is nearest to the emitter while collector lies at other extreme of the casing (Anon,
Transistor SL100, 2012).
2.10 Relay
A relay is an electrically operated switch. Many relays use an electromagnet to operate a
switching mechanism mechanically. Relays are simple switches which are operated both
electrically and mechanically. Relays consist of an n electromagnet and also a set of
contacts. The switching mechanism is carried out with the help of the electromagnet.
There are also other operating principles for its working. But they differ according to their
applications. Most of the devices have the application of relays. A relay is said to switch
one or more poles. Each pole has contacts that can be thrown in mainly three ways. They
are (Anon, Relay-construction-and-operation).
 Normally Open Contact (NO) – NO contact is also called a make contact. It
closes the circuit when the relay is activated. It disconnects the circuit when the
relay is inactive.
 Normally Closed Contact (NC) – NC contact is also known as break contact.
This is opposite to the NO contact. When the relay is activated, the circuit
disconnects. When the relay is deactivated, the circuit connects.
 Change-over (CO) / Double-throw (DT) Contacts – This type of contacts are
used to control two types of circuits. They are used to control a NO contact and
also a NC contact with a common terminal. According to their type they are called
by the names break before make and make before break contacts.
2.10.1 Working of Relay
The working of a relay can be better understood by explaining Figure 2.10-1 (Anon,
Relay-construction-and-operation). The diagram shows an inner section diagram of a
relay. An iron core is surrounded by a control coil. As shown Figure 2.10-1, the power
source is given to the electromagnet through a control switch and through contacts to the
load. When current starts flowing through the control coil, the electromagnet starts
energizing and thus intensifies the magnetic field. Thus the upper contact arm starts to be
attracted to the lower fixed arm and thus closes the contacts causing a short circuit for the
Page | 39
power to the load. On the other hand, if the relay was already de-energized when the
contacts were closed, then the contact move oppositely and make an open circuit.
Figure 2.10-1 Internal diagram of relay
As soon as the coil current is off, the movable armature will be returned by a force back
to its initial position. This force will be almost equal to half the strength of the magnetic
force. This force is mainly provided by two factors. They are the spring and also gravity.
Relays are mainly made for two basic operations. One is low voltage application and the
other is high voltage. For low voltage applications, more preference will be given to
reduce the noise of the whole circuit. For high voltage applications, they are mainly
designed to reduce a phenomenon called arcing (Anon, Relay-construction-and-
operation).
2.11 Summary
This chapter briefly discussed the theory of the hardware components used in PIR Sensor
Based Security System. The working principles, types of some components, circuit
analysis, some components advantages and disadvantages were discussed.
Page | 40
CHAPTER 3: DESIGN, SIMULATION AND EXPERIMENT OF
HARDWARE COMPONENTS
Objectives of the chapter:
 Outline the design procedure of different hardware parts
 Simulate the different hardware parts used in the system
 Test the hardware parts in breadboard
 Compare the experimental and simulation result
Page | 41
3.1 Introduction
This chapter encompasses design, simulation and experimentation of each component
used in PIR Sensor Based Security System. The design, simulation and experimentation
of hardware parts include the power supply circuit, amplifier circuit, comparator circuit
and transistor as a switch.
The design of the components will be explained and simulations results for the same are
shown in this chapter. The simulation was carried out in PSpice software. The validation
for the simulation results are shown by experimenting in the lab using breadboards. The
results of both simulation and experimentation are shown in this chapter.
3.2 Transformer
3.2.1 Design Procedure
In the simulation of the power supply, firstly centre tap transformer is designed the as
follows:
2
1
2
1
N
N
V
V
 (3.2.1)
Where we assumed that N1= 4500 turns and calculated the value for N2 as V1= 230V and
V2=32V.
230
324500
2
x
N 
The value of N2 =626.09 turns.
Then using the following formula we calculated the value for inductor.
2
1
2
2
1
L
L
N
N






(3.2.2)
Where we assumed that L2= 10µΩ and calculated the value for L1 as N1= 4500turns and
N2=626.09turns.
10
09.626
4500
2
1 xL 






The value of L1 was found as 516.75µH.
Page | 42
These values of inductor thus obtained were used in simulation for proper step down of
the input voltage.
3.2.2 Simulation and Results
 Simulation Result of 16-0-16 Step-down Transformer
Figure 3.2-1: Circuit diagram for transformer
 Input supply
Figure 3.2-2: Input supply from normal 230V ac supply
The input given to the step down transformer is 50 Hz, 230V. Figure 3.2-2 shows the
simulation result of the input given to the transformer.
Note: In taking out the output we have taken separately due to the large difference of the
voltage output is very small to be visible enough.
V2
FREQ = 50
VAMPL = 230V
VOFF = 0V
R4
0.000005
0
0
Lp
Ls1
Ls2
TX6
XFRM_LIN/CT-SEC
R5
1k
V
V
Page | 43
 Output from the step-down transformer
Figure 3.2-3: Output waveform from step-down 16 volt transformer
The output obtained is 16V after the 230 V is stepped down using the transformer.
3.2.3 Experimentation result obtained from breadboard
 Output
Figure 3.2-4: Output from CRO
From the Figure 3.2-4, volts/div is given as 5V and the peak of output waveform is 3.1
divisions. The 230V AC supply has been stepped down to 15.5V by 16-0-16 centred-
tapped step down transformer.
Page | 44
3.2.4 Comparison of simulation result and the experimentation result
Table 3.2-1: Comparison of simulation and experimentation results
Simulation Result
Experimentation Result
CRO reading Multi-meter reading
Input 230V 230V 230V
Output 16V 15.5V 16V
Thus from the Table 3.2-1, we conclude that the output voltage obtained from simulation
and experimentation is almost equal. Therefore an input of 230V is stepped down to 16V.
Page | 45
3.3 Rectifier
3.3.1 Simulation result of centre-tapped rectifier
 Circuit Diagram
Figure 3.2-5: Simulation circuit for Full Wave Rectifier
 Input supply to the rectifier
Figure 3.2-6: Input Waveform
D1
D1N4004
D2
D1N4004
D3 D1N4004
D4
D1N4004
R3
625
0
0
V2
FREQ = 50
VAMPL = 230V
VOFF = 0V
R4
0.000005
0
R10
1k
0
Lp
Ls1
Ls2
TX6
XFRM_LIN/CT-SEC
V
V
V
Page | 46
 Output from the rectifier
Figure 3.2-7: Output Waveforms
The input AC voltage of 15V (blue waveform) is rectified to DC voltage (as
shown by red and green waveform) by two full wave rectifier circuit. We have used two
rectifiers circuit to get both positive and negative supply for the elements like Op-amps in
later parts.
3.3.2 Experimentation result of rectifier
 Output from positive Rectifier
Figure 3.2-8: CRO Output from positive Rectifier
Page | 47
This is CRO output waveform from full wave rectifier (D1 and D2) which gives positive
dc output voltage of 15V as follows:
Volt/division = 5v
Number of division =3
 Output voltage = 3×5 = 15volts
 Output from negative Rectifier
Figure 3.2-9: CRO Output from negative Rectifier
This is CRO output waveform from full wave rectifier (D1 and D2) which gives positive
dc output voltage of 15V as follows:
Volt/division = 10v (it is shown in Figure 3.3.-5, beside CH1)
Number of division = -1.5
 Output voltage = -10×1.5 = -15volts
3.3.3 Comparison of Simulation and Experimentation Result
Table 3.2-2: Comparison of Simulation and Experimentation Result
Simulation Result
Experimentation Result
CRO reading Multi-meter reading
Input (AC) 16V 16V 16V
Output (DC) 15V 15V 15V
Page | 48
From this result we can conclude that simulation and experimentation output are same.
Thus, this rectifier can be effectively used as the supply for the voltage regulator that we
are using in later sections.
3.4 Voltage Regulator
3.4.1 Design Procedure
 Design Procedure of 12V Voltage Regulator
As discussed above in section 2.5 about the voltage regulator, this is the device to get the
fixed constant voltage. In our project we use have used two regulators:  12V regulator
and 5V regulator.
 The Steps for designing the input to Regulator
Following are the steps used for designing the power supply to the regulator (Dev, Khan,
& K., 2009)
1. Select ⁄ step down transformer capable of giving around 1A current in
the secondary. 16V here represents the centre-tapped step down transformer that
we are using.
2. We find out the dc voltage at the output of regulator when the ac input voltage
varies from 180V-250V under the condition that the capacitor filter C1 loaded.
Here we are assuming that the AC fluctuation to be between this window
(180V-250V).
3. When the input ac voltage is 230V and output is 16V,the transformer turns ratio
is calculated by:
2
1
2
1
N
N
V
V
 (3.4-1)
4. When the input ac voltage is 180V and 250V (assuming the minimum
fluctuating limits as 180V and maximum fluctuating limit as 250V in order to
obtain maximum possible input for 12V regulator) using Np: Ns data, we
calculate an output at the secondary of the transformer by the below equation.
sp
s
NN
geInputVolta
rmsV
:
)(  (3.4-2)
Page | 49
Take the lowest secondary voltage from above calculation.
)(2)( rmsVpeakV ss  (3.4-3)
5. The we calculate the peak value of the voltage Vs (peak) at secondary of the
transformer
6. Find the peak value of the voltage Vc1 (peak) at the input to the regulator.
2V-(peak)V=(peak)V sC1
(3.4-4)
Taking 7.0V ( V is cut-in voltage of the diode used in bridge
rectifier)
7. Calculate the maximum peak to peak ripple voltage that can be tolerated at the
input to the regulator.
(Note: the ripple voltage must not cause the input to fall below the minimum required to
maintain regulation which is 15.5V for LM7812)
]5.15)([2)( 1  peakVPPV cv (3.4-5)
8. Find the value of filter capacitor C1 using equation
)(
2 1
PPV
fc
I
v
dc


32.102
1


f
I
C dc
Idc= 1A when the filter is heavily loaded.
9. LM7812 show that the ripple rejection under the given operating condition is a
minimum of 62dB
Thus, 20 log [ ] = 62 dB ( is peak to peak ripple voltage)
10. Connect the resistor 620 across the output of the regulator (to maintain the
quiescent current) and capacitor C2 = 0.1 F to eliminate any high frequency
pulses.
Page | 50
 Calculation
The Calculation of the values of different components for this project is (Dev, Khan, &
K., 2009):
1. The transformer turns ratio as we are using the transformer as 230V/16V:
16
230

s
p
N
N
= 14.375
2. Output voltage of secondary transformer
a) At AC input voltage of 180V
sp
s
NN
geInputVolta
rmsV
:
)( 
375:3.14
180
)( rmsVs
= 12.521V
b) At AC input voltage of 250V
375:3.14
250
)( rmsVs
=17.51V
Here we can take the lowest secondary voltage 12.521V when input line supply is
180V. As per the datasheet the minimum requirement for the regulator is 12V.
3. Peak value of voltage at secondary transformer
(rms)Vs2=Vs(peak) 
= 17.70V12.5212 
4. Peak value of voltage at the input to the regulator
2V-(peak)V=(peak)V sC1
0.72-17.70= 
Page | 51
V6.301=
5. Maximum peak-to-peak ripple voltage
15.5]-(peak)2[V=(PP)V c1v
15.5]-2[16.30=
1.6V=
6. Filter capacitor C1
≤ Vv (PP)
≤ 1.6V
C1 ≥
When
C1 ≥
= 1.990 x 10-3
F
C1 ≥ 1990μF
Thus, the filter capacitor of value1990μF or preferably more should be selected.
But the lower value can also be used.
7. Change in output dc voltage, ΔVout
dB
V
V
ou
in
55]log[20 


VVin 6.1
mV
anti
V
V in
out 84.2
20
55
log









Therefore, mVVout 84.2
Page | 52
Thus, the change in the output dc voltage about the regulated voltage of +12V shall
be around mV84.2
 Design Procedure of 5V regulator (LM7805)
Since the input to this regulator is already regulated 12 V DC. The initial process is not
required. The 12V DC can be feed directly to the input terminal of the LM7805 IC. The
bypass capacitor C1 and C2 are used for optimum stability and transient response.
Page | 53
3.4.2 Simulation and result of power supply
 12 V Regulators: Circuit Diagram
Figure 3.4-1: Diagram from the complete simulation of 12V regulator
C3
0.1u
0
C7
0.1u
0
C8
33u
0
0
D13
D1N4004
D14
D1N4004
D15
D1N4004
D16
D1N4004
C5
470u
U1
LM7812C
IN
1
OUT
2
GND
3
U2
LM7912C
IN
3
OUT
2
GND
1
C4
1u 1k
D17
D1N4004
D18
D1N4004
D10
D1N4004
D11
C2
470u
V4
FREQ = 50
VAMPL = 230V
VOFF = 0V
R8
0.000005
Lp
Ls1
Ls2
TX6
XFRM_LIN/CT-SEC
U3
LM7805C
IN
1
OUT
2
GND
3
D19
D1N4004
D20
D1N4004
R7
1k
V
V
V
Page | 54
For the clear vision of the output we have taken out the result separately for different
position as indicated in the Figure 3.4-1.
 Input and output of +12v Regulator
Figure 3.4-2: Input and output waveform of +12v Regulator
Figure 3.4-2 shows the simulation result of +12V regulator with the rectifier input. From
the output figure the input to the regulator circuit is not exactly 16Vas expected, this may
be due to the drop across the elements. It is the regulated +12V that’s the output which is
our focus. Therefore, we see the output is exactly 12V as expected.
 Input and Output of -12V Regulator
Figure 3.4-3: Input and Output waveform of -12V Regulator
Page | 55
Figure 3.4-3 shows the simulation result of -12V regulator with the rectifier input. From
the output figure the input to the regulator circuit is not exactly 16V as expected, this may
be due to the drop across the elements. It is the regulated -12V that’s the output which is
our focus. Therefore, we see the output is exactly -12V as expected.
Figure 3.4-4: Output waveform of the 12V regulator
Figure 3.4-4 shows the V12 regulator output. With the input from the rectifier we were
able to obtain V12 for the Opamps that we are using in later circuits.
 5V regulator: Output
Figure 3.4-5: Output waveform for 5V regulator
Page | 56
3.4.3 Experimentation Results of voltage regulators
 CRO input and output of +12V regulator
Figure 3.4-6: CRO input and output of +12V regulator
From the Figure 3.4-6 we see that volts/div is 10.0V and divisions of output is 1.15 div,
thus the output result is 11.5V.
It was found that the result on the multi-meter was 12V with 15.64V ( V16 ) input
 CRO input and output of -12V regulator
Figure 3.4-7: CRO input and output of -12V regulator
From the Figure 3.4-7 volts/div of the output voltage is 10.0V and the division of output
is -1.2 div, thus output voltage is -12V.
Page | 57
 CRO output of 5V Regulator
Figure 3.4-8: CRO output of 5V Regulator
From the Figure 3.4-8, the volts/div is 2V/div and the output mark divisions is 2.4 div.
therefore, output voltage is 4.8V ( V5 )
3.4.4 Comparison of Simulation and Experimentation Result
 For 12V regulator
Table 3.4-1: Comparison of Simulation and Experimentation Result of 12V regulator
Simulation Result
Experimentation Result
CRO reading Multi-meter reading
Input (AC) 16V 15.64V 15.64
Output (DC) 15V  12V 12V
It was found that the result on the multi-meter was -12V with 15.64V ( V16 ) input.
This confirms the DC output of  12V to be the supplied to Opamps and 5V regulator.
Page | 58
3.5 Differential Amplifier
3.5.1 Design Procedure
The output of differential amplifier is given by
1
3
1
124
413
2out
R
R
V-
R)R+(R
R)R+(R
V=V (3.5-1)
We have,
Vout=5V (this is the required input that need to be given to comparator)
V1=0V
V2=3.3
NOTE: The value on V1 and V2 are the output from PIR sensor when it is activated and
idle respectively. We have used the PIR sensor which gives the output of 3.3V when
activated and 0V when idle.
Thus to get the amplified output,
R4=R3 and R2=R1
Let us take the value of R1=R2=3.3 K
Hence the equation (3.4.1) becomes
0-
3.33.3)+(R
R3.3)+(R
3.3=5
4
43
3.33.3)+(R
R3.3)+(R
3.3=5
4
33
Solving the above equation, we get the value of R3=5 and -3.3.
Therefore ignoring the negative value, we take R3=R4=5 K
Page | 59
3.5.2 Simulation and Result of differential amplifier
 Circuit Diagram of differential amplifier
Figure 3.5-1 Circuit diagram for differential amplifier
Here 3.3V DC supply represents the output of PIR sensor. Since the PIR sensor is not
build in PSpice software, we have measured the PIR sensor output when activated and it
was found to be 3.3V. Therefore, we have used as external 3.3 V DC supply for the
simulation purpose. In reality, this 3.3V will be replaced by the PIR sensor output. This
3.3V output of PIR sensor is amplified to 5V DC by using differential amplifier. The
amplified voltage will be given to window comparator in later circuit.
 Input to amplifier from the PIR sensor
The input voltage given to the Op-amp is 3.3V. This voltage is obtained when the PIR
sensor is activated. In case the PIR sensor is not activated, the input voltage remains zero.
R9
5K
V7
12Vdc
V8
12Vdc
R3
3.3k
R4
5K
U1
uA741
+
3
-
2
V+
7
V-
4
OUT
6
OS1
1
OS2
5
0
V10
3.3Vdc V
V
Page | 60
Figure 3.5-2: Input waveform to amplifier (output of PIR sensor)
 Amplified output of the PIR sensor output voltage when activated
Figure 3.5-3: Output waveform from the amplifier
The input voltage of 3.3V given from the PIR sensor is amplified to 5V by differential
amplifier.
Page | 61
3.5.3 Experimentation
 Output of PIR sensor when activated
Figure 3.5-4: Input to amplifier when PIR sensor is activated
Volt/div = 1
Div = 3.2
 Voltage = 3.2 V ( V3.3 )
The input voltage to amplifier obtained from the CRO is 3.3V which has been amplified
to 5V.
 Output from CRO
Figure 3.5-5: Output from CRO
Page | 62
Volt/division = 2v
Division = 2.4
 Voltage = 4.8 V ( V5 )
Thus the amplified output obtained at CRO is 5V.
3.5.4 Comparison of simulation result and the experimentation result
Table 3.5-1: Comparison of experimentation and simulation results of 5V regulator
Simulation Result
Experimentation Result
CRO reading Multi-meter reading
Input 3.3V 3.2V 3.3V
Output 5V 4.8 V 4.9V
The input and output voltage obtained in simulation and experimentation is almost equal.
Thus the input voltage of 3.3V obtained from PIR sensor is amplified to 5V.
3.6 Window Detector
3.6.1 Design Procedure
We have,
V×
R3)+R2+(R1
R3
=VREF1 (3.6-1)
V×
R3)+R2+(R1
RR3
=V 2
REF2

(3.6-2)
In the Figure 3.6-1,
V=12V
R1= R8=1K
R2=R7=22K
R3=R6= 10K
Note: The values of R6, R7 and R8 are as given in simulation circuit diagram.
Page | 63
Therefore,
3.67V12×
10)+22+(1
10
=VREF1 
11.6V12×
10)+22+(1
2210
=VREF2 

Figure 3.6-1: Design circuit for window detector
Page | 64
3.6.2 Simulation and Result of window comparator
 Circuit Diagram
Figure 3.6-2: Circuit diagram for window comparator
R15
1.082k
V6
5Vdc
R9
5K
V7
12Vdc
V8
12Vdc
V9
12Vdc
R13
4k
R3
3.3k
R4
5K
Q2
2N2222A/ZTX
R14
10k
U1
uA741
+
3
-
2 V+
7
V-
4
OUT
6
OS1
1
OS2
5
0
0
0
R7
22k
R8
1k
0
U2B
LM324
+
5
-
6
V+
4
V-
11
OUT
7
U3B
LM324
+
5
-
6
V+
4
V-
11
OUT
7
R6
10k
D1
D1N4148
D2
D1N4148
0
V10
3.3Vdc
V
V
Page | 65
 Case 1: When PIR sensor is activated
Input to window comparator from the amplifier
Figure 3.6-3: Output from the window comparator when PIR senor is activated
When PIR sensor is activated, the input given to the window comparator is 5V, which is
output from the amplifier. This 5V input is compared with the two reference voltages:
lower limit (3.67V) and upper limit (11.6V).
Output from the window comparator when PIR sensor is activated
Figure 3.6-4: Output Waveform when PIR sensor is activated
The input voltage to the comparator when PIR sensor is activated is 5V, which is an
amplified result of 3.3V of PIR sensor output. This input voltage is compared with the
upper and lower limits (Paul, Industrial Electronics And Control, 2009). As the input
Page | 66
voltage is within the window, the upper comparator will be at negative saturation since its
non-inverting input is negative (<11.6V). The lower comparator will also be at negative
saturation and both the diodes become reverse biased and the output voltage is zero.
As seen from Figure 3.6-4, the output is -131uV ( V0 )
 Case 2: When PIR sensor is not activated
Input to window comparator from the amplifier when PIR sensor is not activated
Figure 3.6-5: Input waveform
When the PIR sensor is idle that it does not detect any intruder, output then goes to zero.
Therefore, the amplified output is also zero.
Output from the window comparator when PIR sensor is idle
Figure 3.6-6: Output from PIR sensor when it is idle (does not detects any intruder)
Page | 67
When PIR sensor is idle, its output is zero. Since output of amplifier is zero, the lower
comparator goes to positive saturation as its inverting input will be negative w.r.t. to its
non-inverting input. This forward biases the diode D2, and the combined output will be
positive saturation of nearby 3V.
3.6.3 Experimentation result of window comparator
 Case 1: When PIR sensor is activated
Input to window comparator when PIR sensor is activated
Figure 3.6-7: Input to the window comparator when PIR sensor is activated
When the PIR sensors activated, the input given to window comparator is found to be
V5 . From the Figure 3.6-7,
Volts/division = 2.00 V/div
division = 2.3 div
 Volts = 22.3 = 4.6 V V5
As discussed under case 1 of section 3.6-2, the output from the window comparator was
found to be 0V.
Page | 68
 Output from the window comparator when PIR sensor is activated
Figure 3.6-8: Output from the window comparator when PIR sensor is activated
 Case 2: When PIR sensor is idle
 Input to window comparator when PIR sensor is idle
Figure 3.6-9: Output from the window comparator when PIR sensor is idle
 Output from window comparator when PIR sensor is idle
As discussed under case 2 of section 3.5-2, the output from the window comparator was
found to be 3V.
Page | 69
Figure 3.6-10: output from the window comparator when PIR sensor is idle
3.6.4 Comparison of simulation result and the experimentation result of window
comparator
 Case 1: When PIR is activated
Table 3.6-1: When PIR sensor is activated
Simulation Result
Breadboard Result
CRO reading Multi-meter reading
Input 5V 4.7V 4.7V
Output 131uV 0V 0V
 Case 2: When PIR is idle
Table 3.6-2: When PIR sensor is idle
Simulation Result
Breadboard Result
CRO reading Multi-meter reading
Input 0V 0V 0V
Output 3V 3V 3V
Page | 70
Thus we see that the result so obtained is in line with the expected results as discussed in
section 3.6-2.
Page | 71
Figure 3.6-11 Complete circuit diagram
Here voltage supply is supplied directly from the voltage source and 3.3V represents the PIR sensor output. The regulators are designed
in the previous sections and in real circuit we have used the regulators instead of the direct voltage source
V6
5Vdc
R9
5K
V7
12Vdc
V8
12Vdc
U4
Relay _SPDT_b
COM
A
B
NC
NO
V9
12Vdc
U5
LAMP
HL
R13
4k
R3
3.3k
Q2
2N2222A/ZTX
R4
5K
R14
10k
U1
uA741
+
3
-
2
V+
7
V-
4
OUT
6
OS1
1
OS2
5
V10
3.3 Vdc U6
Relay _SPDT_b
COM
A
B
NC
NO
0
0
CAMERA
0
R7
22k
R8
1k
0
U2B
LM324
+
5
-
6
V+
4
V-
11
OUT
7
U3B
LM324
+
5
-
6
V+
4
V-
11
OUT
7
R6
10k
D1
D1N4148
D2
D1N4148
0
Page | 72
3.7 Transistor as switch
3.7.1 Design Procedures of transistor as a switch
Figure 3.7-1: Transistor used as a switch
 Our relay uses 12V and will draw 11.7mA. Clearly this transistor will easily handle this.
 The next step is to ensure to drive the transistor into saturation. We will do this by
selecting the proper value for R1. The collector current will be the base current multiplied
by the DC gain, hFE. The data sheet for a SL100 shows the hFE as a minimum of 25 under
one set of circumstances, and a minimum of 40 and a maximum of 300 under other
circumstances. The reality is that transistor parameters run all over the place. The
simplest thing to do here is use the worst case value, or 25 in this case.
 Changing the transistor gain equation around and using the 11.7mA relay coil current and
SL100 hFE gives us:
Ib = Ic/hFE = 11.7/25 = .468 mA
For simplicity we will round up Ib to 0.5mA. Actually we will probably want to double
it. Running Ib at 1mA or 2mA will not cause any damage and will give an extra margin to
ensure the transistor is driven hard into saturation.
 The voltage from comparator will supply 5V. There will be a voltage drop between the
base and emitter VBE (sat). The data sheet shows this as 2V maximum with much higher
base and collector currents that we will be using. In our circuit it will probably be in the
0.6V to 1.3V range. For simplicity we will use 1.3V. Since the voltages across the circuit
loop must be 0V we have the following:
Vs = VR1 + VBE (3.7-1)
Solving for the voltage across R1, we get the following
Page | 73
VR1 = Vs – VBE = 5V – 1.3V = 3.7V
So, R1 will drop 3.7V with a current of 1mA. Ohm’s Law says
R = V/I = 3.7/.001 = 3.7kΩ (approximately . 4kΩ)
We will use a 4K resistor for R1, but we can use resistor between 1KΩ to 5KΩ.
 The remaining component is R2, and may not be needed in some applications. When
power is first applied to the circuit, you might get some current glitch through the
transistor, turning it and the relay on momentarily. This might not be tolerable. Putting
R2 in will help prevent the transistor from turning on by draining any charge out of the
base of the transistor. 10K resistors are a typical value for this component.
 We know we will have 12V from the supply to relay, and Vce (sat) is going to be around 1
volt. We know that the voltage across the transistor plus the voltage across the relay must
be 12V. That means that the voltage across the relay must be
Vc = Vrelay + Vce (sat) (3.7-2)
Vrelay = Vc – Vce (sat) = 12 – 1.3 = 10.7V
3.1 Summary
The hardware components to be used in the PIR Sensor Based Security System has been
firstly studied theoretically and then designed, simulated in PSpice software and tested in
breadboard to confirm the result before fabricating it in the prototype.
It was found that the results from theoretical design, simulation and experimentation
result were all in same range. Thus the designed was confirmed to proceed further with
the design of prototype.
Page | 74
SECTION C
SOFTWARE
Page | 75
CHAPTER 4: INTEGRATING OPENCV WITH MICROSOFT
VISUAL C++ 2010
Objectives of chapter:
 Introduce Microsoft Visual C++ 2010
 Introduce OpenCV 2.4.4
 Introduce different settings involved in integrating OpenCV 2.4.4 with
Microsoft Visual C++ 2010
 Introduce the coding techniques in Microsoft Visual C++ 2010
Page | 76
4.1 Introduction
We have developed a software program using Microsoft Visual C++ 2010 and OpenCV
2.4.4. OpenCV library files allows generic image/video loading, saving, and acquisition
(team., 2013) which is the backbone of our program. C++ is regarded as a middle-level
language, as it comprises a combination of both high-level and low-level language
features. We have integrated the OpenCV library files in Microsoft Visual C++ 2010 for
capturing, recording and video acquisition.
This chapter gives brief introduction to Microsoft Visual C++ 2010 and OpenCV. We
have illustrated the integration of OpenCV 2.4.4 in Microsoft Visual C++ 2010 and
different OpenCV libraries we have used.
4.2 Microsoft Visual C++ 2010
4.2.1 Introduction
Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft.
It is used to develop console and graphical applications along with Windows Forms
applications, web sites, web applications, and web services for all platforms supported
by Microsoft Windows, Windows Mobile, .NET Framework and .NET Compact
Framework (Anonymous, Tutorials Point).
Visual Studio supports different programming languages by means of language services,
which allow the code editor and debugger to support (to varying degrees) nearly any
programming language, provided a language-specific service exists. Built-in languages
include C/C++ (via Visual C++), VB.NET (via Visual Basic .NET), C# (via Visual C#),
and F# (as of Visual Studio 201). Support for other languages such as M, Python,
and Ruby among others is available via language services installed separately (Anon,
Mathematics and Computer Science, South Dakota School of Mines and Technology,
2012).
It also supports XML/XSLT, HTML/XHTML, JavaScript and CSS. Individual language-
specific versions of Visual Studio also exist which provide more limited language
services to the user: Microsoft Visual Basic, Visual J#, Visual C#, and Visual
C++.Microsoft provides Express editions of its Visual Studio 2010 components Visual
Page | 77
Basic, Visual C#, Visual C++, and Visual Web Developer at no cost (Anon, Mathematics
and Computer Science, South Dakota School of Mines and Technology, 2012).
The following operations using Microsoft Visual C++ 2010 Express Edition can be
performed (Inc, 2010):
 Starting a new project and entering code
 Saving a project to disk
 Compiling and executing a project
 Closing a project
 Opening an existing project
 Creating a multi-file project
 Removing files from a project
 Adding example source files to a project
 Determining where data files created by a program are located
This project uses a C++ program. C++ is a computer language that is used to create
applications. C++ is a statically typed, compiled, general purpose, case-sensitive, free-
form programming language that supports procedural, object-oriented, and generic
programming. C++ is regarded as a middle-level language, as it comprises a combination
of both high-level and low-level language features.
C++ was developed by Bjarne Stroustrup starting in 1979 at Bell Labs in Murray Hill,
New Jersey as an enhancement to the C language and originally named C with Classes
but later it was renamed C++ in 1983. C++ is a superset of C and that virtually any legal
C program is a legal C++ program (Anonymous, Cplusplus.com- Instructions for use,
2000).
4.3 OpenCV
4.3.1 Introduction
OpenCV (Free Open Source Computer Vision) is a library of programming functions
mainly aimed at real time computer vision. It has a BSD license (free for commercial or
research use). OpenCV was originally written in C but now has a full C++ interface and
all new development is in C++. There is also a full Python interface to the library (Agam,
2007).
Page | 78
 General description
 Open source computer vision library in C/C++.
 Optimized and intended for real-time applications.
 OS/hardware/window-manager independent.
 Generic image/video loading, saving, and acquisition.
 Both low and high level API.
 Provides interface to Intel's Integrated Performance Primitives (IPP) with
processor specific optimization (Intel processors).
 Features:
 Image data manipulation (allocation, release, copying, setting, conversion).
 Image and video I/O (file and camera based input, image/video file
output).
 Matrix and vector manipulation and linear algebra routines (products,
solvers, eigenvalues, SVD).
 Various dynamic data structures (lists, queues, sets, trees, graphs).
 Basic image processing (filtering, edge detection, corner detection,
sampling and interpolation, colour conversion, morphological operations,
histograms, image pyramids).
 Structural analysis (connected components, contour processing, distance
transform, various moments, template matching, Hough transform,
polygonal approximation, line fitting, ellipse fitting, and Delaunay
triangulation).
 Camera calibration (finding and tracking calibration patterns, calibration,
fundamental matrix estimation, homographic estimation, stereo
correspondence).
 Motion analysis (optical flow, motion segmentation, tracking).
 Object recognition (Eigen-methods, HMM).
 Basic GUI (display image/video, keyboard and mouse handling, scroll-
bars).
 Image labelling (line, conic, polygon, text drawing)
 OpenCV modules:
Page | 79
i. Core - a compact module defining basic data structures, including the dense
multi-dimensional array Mat and basic functions used by all other modules.
ii. Imgproc - an image processing module that includes linear and non-linear
image filtering, geometrical image transformations (resize, affine and
perspective warping, generic table-based remapping), colour space conversion,
histograms, and so on.
iii. Video - a video analysis module that includes motion estimation, background
subtraction, and object tracking algorithms.
iv. Calib3d - basic multiple-view geometry algorithms, single and stereo camera
calibration, and object pose estimation, stereo correspondence algorithms, and
elements of 3D reconstruction.
v. Features2d - salient feature detectors, descriptors, and descriptor matchers.
vi. Objdetect - detection of objects and instances of the predefined classes (for
example, faces, eyes, mugs, people, cars, and so on).
vii. Highgui - an easy-to-use interface to video capturing, image and video codecs,
as well as simple UI capabilities
viii. GPU- GPU-accelerated algorithms from different OpenCV modules.
ix. Some other helper modules, such as FLANN and Google test wrappers,
Python bindings, and others.
4.4 Integration of OpenCV 2.4.4 with Microsoft Visual C++ 2010
4.4.1 Environment Setting
Integration of OpenCV 2.4.4 in Microsoft Visual C++ 2010 is performed in the following
steps (Phillip, 2011).
i. Open Control Panel → System → Advanced System Settings → Advanced
Tab → Environment Variables.
ii. On the System Variables section, select Path (1 as shown in Figure 4.4-1), Edit (2
as shown in Figure 4.4-1), and type C:opencvbuildx86vc10bin; (3 as shown in
Figure 4.4-1), then click Ok.
Page | 80
Figure 4.4-1 Environment variable setting to integrate OpenCV 2.4.4 in Microsoft Visual
C++ 2010
iii. On some computers, it may need to restart computer for the system to recognize
the environment path variables.
This will complete the OpenCV 2.4.4 installation on computer.
4.4.2 Creating a new project and set up Visual C++
i. Open Visual C++ and select File → New → Project → Visual C++ → Empty
Project. Give a name for your project (e.g.: webcam) and set the project location
(e.g.: c:usersuserdocumentsvisual studio
2010Projects).
ii. Click Ok. Visual C++ will create an empty project.
Page | 81
Figure 4.4-2 Creating new project in Microsoft Visual C++ 2010
Figure 4.4-3 Empty project
iii. Make sure that "Debug" is selected in the tool bar. Right click the “webcam”
(your project that you have created, here we have created project as “webcam”)
and select Properties → VC++ Directories.
iv. Select Include Directories to add a new entry and type C:opencvbuildinclude.
Page | 82
Figure 4.4-4 Property setting in Microsoft Visual C++ 2010 from integration of OpenCV
2.4.4
Figure 4.4-5 Including OpenCV 2.4.4 directories in Microsoft Visual C++ 2010
v. Click Ok to close the dialog.
vi. Back to the Property dialog; select Library Directories to add a new entry and
type C:opencvbuildx86vc10lib.
Page | 83
Figure 4.4-6 To include OpenCV library in Microsoft Visual C++ 2010
vii. Click Ok to close the dialog.
viii. Back to the property dialog, select Linker → Input → Additional
Dependencies to add new entries. On the popup dialog box, type the files listed
below. Each of these libraries is explained in later topic.
opencv_core244.lib
opencv_imgproc244.lib
opencv_highgui244.lib
opencv_ml244.lib
opencv_video244.lib
opencv_features2d244.lib
opencv_calib3d244.lib
opencv_objdetect244.lib
opencv_contrib244.lib
opencv_legacy244.lib
opencv_flann244.lib
Click Ok to close the dialog. Click Ok on the project properties dialog to save all
settings.
Page | 84
Figure 4.4-7 Integrating OpenCV 2.4.4 libraries in Microsoft Visual C++ 2010
These was the steps of setting up Visual C++, now is the time for coding. Right click your
project and select Add → New Item → Visual C++ → C++ File.
Figure 4.4-8 Creating new C++ file
Name your file (e.g.: loadimg.cpp) and click Ok. Type the code in the editor
Page | 85
4.5 Different libraries used from OpenCV
A library is a collection of implementations of behaviour, written in terms of a language
that has a well-defined interface by which the behaviour is invoked. Library code is
organized in such a way that it can be used by multiple programs that have no connection
to each other, while code that is part of a program is organized to only be used within that
one program (Team O. , OpenCV Documentation, 2011).
The distinguishing feature is that a library is organized for the purposes of being reused
by independent programs or sub-programs, and the user only needs to know the interface.
The following libraries are used in the program (Team O. , highgui. High-level GUI and
Media I/O, 2011).
 opencv_core244.lib: This is the basic building block of the library for
understanding how to manipulate the images on a pixel level.
 To store images in the memory and how to print out their content to the
console.
 How to scan images (go through each of the image pixels) with OpenCV.
 To scan images with neighbour access and use the filter2D function to
apply kernel filters on images.
 to blend two images
 Changing the contrast and brightness of an image
 to draw simple geometry with OpenCV
 draw some fancy-looking stuff
 use the Discrete Fourier transformation
 To use the File Storage data structure of OpenCV to write and read data to
XML or YAML file format.
 Interoperability with old versions of OpenCV
 opencv_imgproc244.lib: This is for the image processing (manipulation)
functions inside OpenCV
 opencv_highgui244.lib: how to read/save your image/video files and how to use
the built-in graphical user interface of the library.
 opencv_ml244.lib: Use the powerful machine learning classes for statistical
classification, regression and clustering of data.
Page | 86
 pencv_video244.lib: use on your video stream algorithms like: motion extraction,
feature tracking and foreground extractions.
 opencv_features2d244.lib: This is to use the feature point’s detectors, descriptors
and matching framework found inside OpenCV.
 opencv_calib3d244.lib: Although most of our images are in a 2D format they do
come from a 3D world. This is use to find out from the 2D images information
about the 3D world.
 opencv_objdetect244.lib:detects peoples and faces
 opencv_contrib244.lib: How to process images and video streams with a model
of retina filter for details enhancement, spatio-temporal noise removal, luminance
correction and spatio-temporal events detection.
 opencv_legacy244.lib
 Motion Analysis
 Expectation Maximization
 Histogram
 Planar Subdivisions (C API)
 Feature Detection and Description
 Common Interfaces of Descriptor Extractors
 Common Interfaces of Generic Descriptor Matchers
 opencv_flann244.lib: It is used for Clustering and Search in Multi-Dimensional
Spaces. This section documents OpenCV interface to the FLANN library. FLANN
(Fast Library for Approximate Nearest Neighbours) is a library that contains a
collection of algorithms optimized for fast nearest neighbour search in large
datasets and for high dimensional features.
4.6 Summary
In this chapter, step by step integration of OpenCV 2.4.4 with Microsoft Visual C++ 2010
has been discussed. The integration of OpenCV in Microsoft Visual Studio enables us to
use all of its library files for different purposes. In development of the software for
capturing and recording the video, we have used above mentioned libraries.
Page | 87
CHAPTER 5: SOFTWARE PROGRAM
Objectives of the chapter:
 Outline the algorithm and flow chart of the core program
 Introduce to the program used in designing the software
 Present output of the program
 Discuss the steps involved in creating executable file
Page | 88
5.1 Introduction
This chapter gives the coding techniques we have used to create the software. The
program is based in Microsoft Visual C++ 2010 using different library file from OpenCV
2.4.4. The program will be able to capture and record the video when the webcam is ON.
To keep the software machine independent, executable file will be created. The code will
be tested as per the requirement.
5.2 General working of the program
Our system is mainly for security purpose. So, when it detects human, the sensor turns on
the webcam. The program should be able to detect that the webcam is turned ON and
starts recording the video. When the sensor does not detect human, it turns OFF the
webcam. When the webcam is turned OFF, program saves the recorded video. The
program continuously checks whether the webcam is ON or not. If it is ON the above
process is repeated.
5.2.1 Algorithm
i. Start the program
ii. Check whether the webcam is ON or not
iii. If the webcam is ON, start recording the video until the webcam turns OFF
iv. Save the video
v. Continue to check if the webcam is ON
vi. Then loop the process from iii to iv
Page | 89
5.2.2 Flow Chart
Figure 5.2-1 Flow chart for the program
Page | 90
5.2.3 Program
// PIRSensor.cpp : Defines the entry point for the console application.
// DatenTime.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <time.h>
#include <string>
using namespace std;
int main( int argc, char** argv ) {
startcam:
time_t now = time(0); // First Getting Current System Time
struct tm tstruct;
char buf[80];
tstruct = *localtime(&now); //Gets current local time
strftime(buf, sizeof(buf), "PIR %d_%m_%Y %H_%M", &tstruct); //Copies the time in the format we want
(PIR 30_03_2013 15_30)
string GetTime=buf; // Character is given to string
string TimeinString= GetTime.append(".avi"); //".avi" is appended to the date name (PIR 30_03_2013 15_30.avi)
char* p = new char[TimeinString.length() + 1]; //String is converted back to character
strcpy(p, TimeinString.c_str()); //Copies the character we want in the clipboard
//Next Turning ON the camera and capturing the video in .avi format
Page | 91
//The structure CvCapture does not have public interface and is used only as a parameter for video capturing functions.
CvCapture* capture;
//The function cvCreateCameraCapture allocates and initialized the CvCapture structure for reading a video stream from
the camera. Currently two camera interfaces can be used on Windows: Video for Windows (VFW) and Matrox Imaging Library
(MIL); and two on Linux: V4L and FireWire (IEEE1394).
capture = cvCreateCameraCapture(0);
//Checks whether the camera is turned ON or not and does job accordingly
cout<<"n Checking Webcam.....n";
if (capture==NULL)
{
cout<<"nCamera Not Connectedn";
goto startcam; //If Camera is NOT turned ON the program goes to startcam point and checks again
}
else
cout<<"nCamera Foundn";
assert( capture != NULL );
//The function cvQueryFrame grabs a frame from camera or video file, decompresses and returns it. This function is just
a combination of cvGrabFrame and cvRetrieveFrame in one call. The returned image should not be released or modified by
user.
IplImage* bgr_frame = cvQueryFrame( capture );
//The function cvGetCaptureProperty retrieves the specified property of camera or video file.
CvSize size = cvSize((int)cvGetCaptureProperty( capture,CV_CAP_PROP_FRAME_WIDTH),(int)cvGetCaptureProperty(
capture,CV_CAP_PROP_FRAME_HEIGHT));
Page | 92
//The function cvNamedWindow creates a window which can be used as a placeholder for images and trackbars. Created
windows are reffered by their names.
//If the window with such a name already exists, the function does nothing.
cvNamedWindow( "Webcam", CV_WINDOW_AUTOSIZE );
cout<<"n Starting Webcam Window n";
//writes or saves the video/frames
CvVideoWriter *writer = cvCreateVideoWriter(p,CV_FOURCC('D','I','V','X'),12,size);
cout<<"n Saving the Video Frames n";
//loops the multiple frames
while( (bgr_frame = cvQueryFrame( capture )) != NULL )
{
cvWriteFrame(writer, bgr_frame ); //The function cvWriteFrame writes/appends one frame to video file.
cvShowImage( "Webcam", bgr_frame );
//The function cvWaitKey waits for key event infinitely (delay<=0) or for "delay" milliseconds. Returns the code of the
pressed key or -1 if no key were pressed until the specified timeout has elapsed.
//Note: This function is the only method in HighGUI to fetch and handle events so it needs to be called periodically for
normal event processing, unless HighGUI is used within some environment that takes care of event processing.
char c = cvWaitKey(3);
if( cvCreateCameraCapture(0)==NULL || c==27){ break;}
}
//The function cvReleaseVideoWriter finishes writing to video file and releases the structure
cvReleaseVideoWriter( &writer );
Page | 93
//The function cvReleaseCapture releases the CvCapture structure allocated by cvCreateFileCapture or
cvCreateCameraCapture
cvReleaseCapture( &capture );
//The function cvDestroyWindow destroys the window with a given name.
cout<<"n Finishd Saving Video n";
cvDestroyWindow("Webcam");
goto startcam;
return( 0 );
}
Page | 94
5.2.4 Output of the Program
1. When program runs, it starts Checking for webcam, if webcam is found it start
recording and saving videos.
Figure 5.2-2 When program is starting
2. When webcam is disconnected, recording gets stopped and saves the records,
while program continues to check for webcam.
Figure 5.2-3 When webcam is not detected
3. When webcam is ON, it detects and continues to record and save the videos.
Page | 95
Figure 5.2-4 When webcam is found
5.3 Creating Executable file (.exe)
The executable file creation is required for the program to run independent of the
Microsoft visual C++ and other dependent library files. Using the software (Microsoft
Visual C++) and library files from OpenCV have following drawbacks (Team X. , 2007):
1. These software may not be available to all users
2. Requires lot of space and probably slows down the computer
3. All may not have enough knowledge to use these software or for easy use of
program
4. Requires time for configurations and settings of software.
Thus the use of executable file overcomes the above drawbacks.
The steps of creating the executable file as follows:
1. First of all we need to create the project of the program we want. It is because we
must run program in VC++ before creating the .exe file.
2. After successfully running the program now we have to create executable file.
Firstly we go to Project >> (Your Project Name) Properties or you can press alt +
F7, as shown in Figure 5.3-1:
Page | 96
Figure 5.3-1Step for creating .exe file
3. There are two build configurations for C++ projects: Debug and Release. The
procedure for creating an executable will depend on the configuration, which
is Debug by default. Since it is the default, we have discussed how to create an
executable file using the Debug configuration with the understanding that
the Release configuration can be done similarly.
Figure 5.3-2 Configuration Property setting for creating .exe file
Page | 97
4. To see your current build configuration, left-click "Project" in the menu bar and
left-click "Properties" in the submenu to open the "Properties Pages" dialog
shown above.
5. Left-click "Configuration Properties" and you should see "Active (Debug)" in
the box next to "Configuration:" in the upper-left corner of the dialog. This tells us
that the active or current configuration is Debug
6. Next we want to eliminate our executable .dll file dependency so that we can run
it on any other Windows machine, even if it does not have the .dll file that we are
currently using.
7. To do above task, left-click the arrow next to "Configuration Properties" and
then left-click the arrow next to "C/C++" to expand the lists below them. Then
left-click "Code Generation" below this and left-click "Multi-threaded Debug
DLL" next to "Runtime Library".
8. A drop-down arrow is found next to "Multi-threaded Debug DLL". Left-click
the arrow to expand the list, and left-click "Multi-threaded Debug" in the list.
Finally, commit the changes by left-clicking the "Apply" button and then the
"OK" button
9. The executable can be created by left-clicking "Debug" in the menu-bar and
"Build Solution" in the submenu or press F7.
Figure 5.3-3 Creating executable .dll independent file
Page | 98
Figure 5.3-4 Build .exe file of PIR Sensor
10. Now navigate to the solution folder for the current project. This is where
the .sln file is found. There is "Debug" folder. Double-click the "Debug" folder to
enter it and we see the executable file with the .exe extension. Double-click this
file to run the program and we see window frame opened.
Figure 5.3-5 Window for capturing the video
5.4 Summary
The program was build based on Microsoft Visual C++ 2010 integrating OpenCV 2.4.4
libraries. OpenCV contains a stack of libraries that can be integrated with other
programming languages.
Page | 99
We have created the program as executable file, so that the program contains the package
that can be interfaced with the hardware part of the PIR Sensor Based Security System.
The executable file enables program to run independent of the Microsoft visual C++ and
other dependent library files. It also enables user friendly software with conserved space
and time unlike other software which requires large space and user with adequate
knowledge for configurations and settings of software.
Page | 100
SECTION D
CHAPTER 6: DEMONSTRATION
Objectives of the section:
 To do the demonstration and testing of the PIR Sensor Based Security
System that we have designed
 Recording output shown.
Page | 101
6.1 Introduction
This chapter gives the practical demonstration of the PIR Sensor Based Security System.
Practical testing was carried out in Electronics and Communication Lab with the project
guide. Results of the demonstration will be reflected in the following pages.
6.2 Demonstrations
As explained in the first chapter of the hardware components, the software will be kept
running in the laptop or the computer checking if the webcam is connected or not. When
an intruder comes in the detection range of the PIR sensor, an output of 3.3 volts will be
generated and amplified using differential amplifier circuit. This output voltage is used
for actuating the lighting system and the webcam. Once the software finds the webcam is
connected, it will start recording the video captured by the webcam.
When the intruder leaves the detection range of PIR sensor, the lighting system and
webcam are turned OFF since there is no output from the PIR sensor. The software will
stop recording and it will again start checking if the webcam is connected or not. If the
intruder comes in the detection range of the PIR sensor process of recording and saving of
video repeats
Following Photograph show the actual working of the PIR sensor based system. When we
start the program the program immediately starts to check for the webcam. As in the
beginning the webcam won’t be ON so the program loops and checks for the webcam till
the camera is ON as in Photograph 6.2-1.
Page | 102
Photograph 6.2-1 When there is no intruder in the range of PIR sensor
The lighting system will also be OFF. This shows that there is no intruder in the range.
Page | 103
Photograph 6.2-2 Intruder has been detected
As shown in the Photograph 6.2-2, the PIR sensor gets activated when it detects
the intruder in its range and then turns ON the lighting system and webcam.
Photograph 6.2-3 The webcam continuously records the scene when there is intruder in its
range
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system
PIR based security system

More Related Content

What's hot

Smart street lighting control system project PPT
Smart street lighting control system project PPT Smart street lighting control system project PPT
Smart street lighting control system project PPT PetchiMuthu26
 
electric relay
electric relayelectric relay
electric relayaditya das
 
Home automation using blynk app with fan direction control and displaying sta...
Home automation using blynk app with fan direction control and displaying sta...Home automation using blynk app with fan direction control and displaying sta...
Home automation using blynk app with fan direction control and displaying sta...Diwash Kapil Chettri
 
Over Head Line Insulators : Presentation Topic in Electrical Engineering Seminar
Over Head Line Insulators : Presentation Topic in Electrical Engineering SeminarOver Head Line Insulators : Presentation Topic in Electrical Engineering Seminar
Over Head Line Insulators : Presentation Topic in Electrical Engineering SeminarSandip Kumar Sahoo
 
Relay Setting Calculation For REF615/ REJ601
Relay Setting Calculation For REF615/ REJ601Relay Setting Calculation For REF615/ REJ601
Relay Setting Calculation For REF615/ REJ601SARAVANAN A
 
Home automation using_pc
Home automation using_pcHome automation using_pc
Home automation using_pcSumit Sonawane
 
IRJET - IoT based Anti Theft Detection and Alerting System using Raspberry Pi
IRJET - IoT based Anti Theft Detection and Alerting System using Raspberry PiIRJET - IoT based Anti Theft Detection and Alerting System using Raspberry Pi
IRJET - IoT based Anti Theft Detection and Alerting System using Raspberry PiIRJET Journal
 
MAJOR PROJECT REPORT ON "RENEWABLE ENERGY (SOLAR) BASED HOME -AUTOMATION
MAJOR PROJECT REPORT ON "RENEWABLE ENERGY (SOLAR) BASED HOME -AUTOMATION MAJOR PROJECT REPORT ON "RENEWABLE ENERGY (SOLAR) BASED HOME -AUTOMATION
MAJOR PROJECT REPORT ON "RENEWABLE ENERGY (SOLAR) BASED HOME -AUTOMATION Prasant Kumar
 
Presentation on Over-/under-voltage protection of electrical appliance
Presentation on Over-/under-voltage protection of electrical appliancePresentation on Over-/under-voltage protection of electrical appliance
Presentation on Over-/under-voltage protection of electrical applianceNishant Kumar
 
Substation Automation
Substation AutomationSubstation Automation
Substation Automationskullbreaker
 
automatic street light
automatic street lightautomatic street light
automatic street lightAnish Anand
 
Home automation under wi fi through android apps from any smart phone
Home automation under wi fi through android apps from any smart phoneHome automation under wi fi through android apps from any smart phone
Home automation under wi fi through android apps from any smart phoneEdgefxkits & Solutions
 
switches manufacturing by jigar.pptx
switches manufacturing by jigar.pptxswitches manufacturing by jigar.pptx
switches manufacturing by jigar.pptxJigar Prajapati
 
33016052 electric-traction-system
33016052 electric-traction-system33016052 electric-traction-system
33016052 electric-traction-systembabu yadav
 
33-11-kv-substation-training-report (1) (1).pdf
33-11-kv-substation-training-report (1) (1).pdf33-11-kv-substation-training-report (1) (1).pdf
33-11-kv-substation-training-report (1) (1).pdfSagarRana91
 
Substation protection devices
Substation protection devicesSubstation protection devices
Substation protection devicesRahul Aman
 

What's hot (20)

Laser security system
Laser security systemLaser security system
Laser security system
 
Smart street lighting control system project PPT
Smart street lighting control system project PPT Smart street lighting control system project PPT
Smart street lighting control system project PPT
 
electric relay
electric relayelectric relay
electric relay
 
Home automation using blynk app with fan direction control and displaying sta...
Home automation using blynk app with fan direction control and displaying sta...Home automation using blynk app with fan direction control and displaying sta...
Home automation using blynk app with fan direction control and displaying sta...
 
Over Head Line Insulators : Presentation Topic in Electrical Engineering Seminar
Over Head Line Insulators : Presentation Topic in Electrical Engineering SeminarOver Head Line Insulators : Presentation Topic in Electrical Engineering Seminar
Over Head Line Insulators : Presentation Topic in Electrical Engineering Seminar
 
Relay Setting Calculation For REF615/ REJ601
Relay Setting Calculation For REF615/ REJ601Relay Setting Calculation For REF615/ REJ601
Relay Setting Calculation For REF615/ REJ601
 
Home automation using_pc
Home automation using_pcHome automation using_pc
Home automation using_pc
 
IRJET - IoT based Anti Theft Detection and Alerting System using Raspberry Pi
IRJET - IoT based Anti Theft Detection and Alerting System using Raspberry PiIRJET - IoT based Anti Theft Detection and Alerting System using Raspberry Pi
IRJET - IoT based Anti Theft Detection and Alerting System using Raspberry Pi
 
Home security alarm system
 Home security alarm  system  Home security alarm  system
Home security alarm system
 
MAJOR PROJECT REPORT ON "RENEWABLE ENERGY (SOLAR) BASED HOME -AUTOMATION
MAJOR PROJECT REPORT ON "RENEWABLE ENERGY (SOLAR) BASED HOME -AUTOMATION MAJOR PROJECT REPORT ON "RENEWABLE ENERGY (SOLAR) BASED HOME -AUTOMATION
MAJOR PROJECT REPORT ON "RENEWABLE ENERGY (SOLAR) BASED HOME -AUTOMATION
 
Presentation on Over-/under-voltage protection of electrical appliance
Presentation on Over-/under-voltage protection of electrical appliancePresentation on Over-/under-voltage protection of electrical appliance
Presentation on Over-/under-voltage protection of electrical appliance
 
Substation Automation
Substation AutomationSubstation Automation
Substation Automation
 
automatic street light
automatic street lightautomatic street light
automatic street light
 
Home automation under wi fi through android apps from any smart phone
Home automation under wi fi through android apps from any smart phoneHome automation under wi fi through android apps from any smart phone
Home automation under wi fi through android apps from any smart phone
 
switches manufacturing by jigar.pptx
switches manufacturing by jigar.pptxswitches manufacturing by jigar.pptx
switches manufacturing by jigar.pptx
 
Power quality
Power qualityPower quality
Power quality
 
33016052 electric-traction-system
33016052 electric-traction-system33016052 electric-traction-system
33016052 electric-traction-system
 
33-11-kv-substation-training-report (1) (1).pdf
33-11-kv-substation-training-report (1) (1).pdf33-11-kv-substation-training-report (1) (1).pdf
33-11-kv-substation-training-report (1) (1).pdf
 
Smart grid presentation
Smart grid presentationSmart grid presentation
Smart grid presentation
 
Substation protection devices
Substation protection devicesSubstation protection devices
Substation protection devices
 

Similar to PIR based security system

Variable power supply with digital control with seven segments display
Variable power supply with digital control with seven segments displayVariable power supply with digital control with seven segments display
Variable power supply with digital control with seven segments displaypoornima college of engg. jaipur
 
Audio amplification System
Audio amplification SystemAudio amplification System
Audio amplification SystemShivam Sharma
 
Major_project_b.tech_sem8_may_2018
Major_project_b.tech_sem8_may_2018Major_project_b.tech_sem8_may_2018
Major_project_b.tech_sem8_may_2018Dipen Kantariya
 
sample project report (2).docx
sample project report (2).docxsample project report (2).docx
sample project report (2).docxDrFROSTFIRExR
 
RAJPRASAD PAPER NO-127
RAJPRASAD PAPER NO-127RAJPRASAD PAPER NO-127
RAJPRASAD PAPER NO-127RAJPRASAD RS
 
Doc a.7-tlc report
Doc a.7-tlc reportDoc a.7-tlc report
Doc a.7-tlc report9951081577
 
IRJET- Simulation and Analysis of Five Level SPWM Inverter
IRJET- Simulation and Analysis of Five Level SPWM InverterIRJET- Simulation and Analysis of Five Level SPWM Inverter
IRJET- Simulation and Analysis of Five Level SPWM InverterIRJET Journal
 
IJARCCE4J s govinda Public Transport Assistant for Visually Impaired (PuTAVI)
IJARCCE4J s govinda Public Transport Assistant for Visually Impaired (PuTAVI)IJARCCE4J s govinda Public Transport Assistant for Visually Impaired (PuTAVI)
IJARCCE4J s govinda Public Transport Assistant for Visually Impaired (PuTAVI)SreekarV
 
Voltage Mode Control of Buck Converter
Voltage Mode Control of Buck ConverterVoltage Mode Control of Buck Converter
Voltage Mode Control of Buck ConverterManish Kumar
 
56211728 automatic-room-light-controller-with-bidirectional-visitor-counter
56211728 automatic-room-light-controller-with-bidirectional-visitor-counter56211728 automatic-room-light-controller-with-bidirectional-visitor-counter
56211728 automatic-room-light-controller-with-bidirectional-visitor-counterAnn Francis Olita
 
AUTOMATIC LIGHT & DARK SENSING SYSTEM WITH MOSQUITO REPELLENT CIRCUIT
AUTOMATIC LIGHT & DARK SENSING SYSTEM WITH MOSQUITO REPELLENT CIRCUITAUTOMATIC LIGHT & DARK SENSING SYSTEM WITH MOSQUITO REPELLENT CIRCUIT
AUTOMATIC LIGHT & DARK SENSING SYSTEM WITH MOSQUITO REPELLENT CIRCUITShahrukh Javed
 
Automatic power factor_improvement_and_monitoring_by_using_plc[1]
Automatic power factor_improvement_and_monitoring_by_using_plc[1]Automatic power factor_improvement_and_monitoring_by_using_plc[1]
Automatic power factor_improvement_and_monitoring_by_using_plc[1]ferozpatowary
 
DFIG control of WECS using indirect matrix converter
DFIG control of WECS using indirect matrix converter DFIG control of WECS using indirect matrix converter
DFIG control of WECS using indirect matrix converter Kuldeep Behera
 
Low-Cost Sensor Network for Contamination Detection in Drinking Water
Low-Cost Sensor Network for Contamination Detection in Drinking WaterLow-Cost Sensor Network for Contamination Detection in Drinking Water
Low-Cost Sensor Network for Contamination Detection in Drinking WaterIJERA Editor
 

Similar to PIR based security system (20)

Variable power supply with digital control with seven segments display
Variable power supply with digital control with seven segments displayVariable power supply with digital control with seven segments display
Variable power supply with digital control with seven segments display
 
Audio amplification System
Audio amplification SystemAudio amplification System
Audio amplification System
 
Major_project_b.tech_sem8_may_2018
Major_project_b.tech_sem8_may_2018Major_project_b.tech_sem8_may_2018
Major_project_b.tech_sem8_may_2018
 
sample project report (2).docx
sample project report (2).docxsample project report (2).docx
sample project report (2).docx
 
RAJPRASAD PAPER NO-127
RAJPRASAD PAPER NO-127RAJPRASAD PAPER NO-127
RAJPRASAD PAPER NO-127
 
final project
final projectfinal project
final project
 
Doc a.7-tlc report
Doc a.7-tlc reportDoc a.7-tlc report
Doc a.7-tlc report
 
Final Report Content
Final Report ContentFinal Report Content
Final Report Content
 
Photovoltaic array fed inverter
Photovoltaic array fed inverterPhotovoltaic array fed inverter
Photovoltaic array fed inverter
 
Gopi 1 lab manual
Gopi 1 lab manualGopi 1 lab manual
Gopi 1 lab manual
 
IRJET- Simulation and Analysis of Five Level SPWM Inverter
IRJET- Simulation and Analysis of Five Level SPWM InverterIRJET- Simulation and Analysis of Five Level SPWM Inverter
IRJET- Simulation and Analysis of Five Level SPWM Inverter
 
Report
ReportReport
Report
 
IJARCCE4J s govinda Public Transport Assistant for Visually Impaired (PuTAVI)
IJARCCE4J s govinda Public Transport Assistant for Visually Impaired (PuTAVI)IJARCCE4J s govinda Public Transport Assistant for Visually Impaired (PuTAVI)
IJARCCE4J s govinda Public Transport Assistant for Visually Impaired (PuTAVI)
 
Voltage Mode Control of Buck Converter
Voltage Mode Control of Buck ConverterVoltage Mode Control of Buck Converter
Voltage Mode Control of Buck Converter
 
20
2020
20
 
56211728 automatic-room-light-controller-with-bidirectional-visitor-counter
56211728 automatic-room-light-controller-with-bidirectional-visitor-counter56211728 automatic-room-light-controller-with-bidirectional-visitor-counter
56211728 automatic-room-light-controller-with-bidirectional-visitor-counter
 
AUTOMATIC LIGHT & DARK SENSING SYSTEM WITH MOSQUITO REPELLENT CIRCUIT
AUTOMATIC LIGHT & DARK SENSING SYSTEM WITH MOSQUITO REPELLENT CIRCUITAUTOMATIC LIGHT & DARK SENSING SYSTEM WITH MOSQUITO REPELLENT CIRCUIT
AUTOMATIC LIGHT & DARK SENSING SYSTEM WITH MOSQUITO REPELLENT CIRCUIT
 
Automatic power factor_improvement_and_monitoring_by_using_plc[1]
Automatic power factor_improvement_and_monitoring_by_using_plc[1]Automatic power factor_improvement_and_monitoring_by_using_plc[1]
Automatic power factor_improvement_and_monitoring_by_using_plc[1]
 
DFIG control of WECS using indirect matrix converter
DFIG control of WECS using indirect matrix converter DFIG control of WECS using indirect matrix converter
DFIG control of WECS using indirect matrix converter
 
Low-Cost Sensor Network for Contamination Detection in Drinking Water
Low-Cost Sensor Network for Contamination Detection in Drinking WaterLow-Cost Sensor Network for Contamination Detection in Drinking Water
Low-Cost Sensor Network for Contamination Detection in Drinking Water
 

Recently uploaded

Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxPurva Nikam
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitterShivangiSharma879191
 

Recently uploaded (20)

Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptx
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter
 

PIR based security system

  • 1. PASSIVE INFRARED SENSOR (PIR) BASED SECURITY SYSTEM Project Report Submitted in partial fulfilment of the requirements for the award of the degree of Bachelor of Engineering In Electronics and Communication Engineering By: Ms. Pema Chodon Ms. Devi Maya Adhikari Mr. Gopal Chandra Nepal Mr.Sangay Gyeltshen Mr. Rajen Biswa Under the Guidance of: Mr. Chencho DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING COLLEGE OF SCIENCE AND TECHNOLOGY PHUENTSHOLING, BHUTAN June 2013
  • 2. ROYAL UNIVERSITY OF BHUTAN COLLEGE OF SCIENCE AND TECHNOLOGY DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING CERTIFICATE This is to certify that the B.E. project titled “Passive Infrared Sensor (PIR) Based Security System”, which is being submitted by Ms. Devi Maya Adhikari (ECE2009019), Mr. Gopal Chandra Nepal (ECE2009023), Ms. Pema Chodon (ECE2009059) , Mr. Rajen Biswa (ECE2009070) and Mr. Sangay Gyeltshen (ECE2009078), the students of BE Final year Electronics and Communication Engineering, during the academic year 2012-2013 in partial fulfilment of the requirement for the award of “Bachelor of Engineering in Electronics and communication Engineering” as a record of students work carried out at College of Science and Technology, Phuentsholing under my supervision and guidance. Mr. Chencho Project Guide
  • 3. Page | i ACKNOWLEDGEMENT This report is fruition of hard work undertaken during course of the Project which is carried out in group of five, under the guidance of Mr. Chencho, dating from June 2012 to June 2013. Indeed, it is a great opportunity for us to have hand-on experience and verify the theoretical knowledge with experimental setups, which further nurtures our capability; preparing us for greater challenges that are going to be faced in future. Therefore, we would like to deeply thank College of Science and Technology under the Royal University of Bhutan for incorporating such an effective learning program and providing us with this opportunity. Most importantly, our heartiest gratitude goes to Mr. Chencho for his unwavering guide and support throughout the project without which the completion of the project would not have been possible. We would also like to earnestly thank Mr. Subash Sharma; M.S. Tshongkhang, Phuentsholing for providing and sponsoring us with all the materials required for the project. Also, we would to thank Dr. Kazuhiro Muramatsu (Lecturer, Electrical Department), Mr.Sangay Dorji (Senior Instructor, ECE Department), Mr. Yeshi Wangchuck (Asst. Lecturer, IT Department), Ms.Tshewang Lhamo (Lab Technician), Mr. Kinzang Dorji (Lab Technician), other faculties and friends who were involved directly or indirectly in this project. Mr. Gopal Chandra Nepal Mr. Sangay Gyaltshen Ms. Devi Maya Adhikari Ms. Pema Chodon Mr. Rajen Biswa
  • 4. Page | ii ABSTRACT In this project, PIR based security system which saves the power energy consumption and saves the memory space of the recording system has been developed. The security system consists of four parts namely power supply, PIR sensor, lighting and recording system. A single phase of 230V, 50 Hz was used as the primary source to the circuit designed. This input voltage was stepped down, rectified and regulated to give supply to the PIR sensor other circuits. Passive Infrared Radiation (PIR) sensor is the main component of our project. It will detect the change in infrared radiation which is radiated by warm blooded moving object provided that the object is in its detection range. When the device is exposed to infrared radiation, it generates an electric charge. According to the change in the amount of infrared striking the element, there will be a change in the voltages generated. This output generated was amplified and used to turn ON the webcam and lighting system. Software was developed to record the video captured by webcam when it gets turned ON. It is installed in the computer and was made to run. It will keep checking if the webcam is turned ON or connected to the system. When an object comes in the detection range of the PIR sensor, an output is generated which actuates the lighting system and the webcam. The software detects the webcam connection; it will start to record and save the video. Once the object moves out of detection range of the sensor, the webcam and light gets turn OFF. The software will again check for the webcam and stops recording resulting in saving of power consumption and the memory space of the recording system.
  • 5. Page | iii TERMINOLOGY 1. A: The symbol for amps, or amperes, which is a unit of current flow. 2. AC: Alternating Current. This is electric current that periodically changes the direction in which it flows. 3. Algorithm: is a detailed, step-by-step description of how to perform some task. 4. Amplifier: A device, either a single stage or a large scale circuit with multiple stages for creating gain, i.e. making small signals larger. 5. C++: is a computer language that is used to create applications. 6. Capacitor: a device consisting of two parallel plates separated by an insulator. 7. Current: The term given to electron flow. 8. DC: Direct current. This is constant electric current with zero frequency. 9. Differential Amplifier: is a type of amplifier which can amplify the difference of input signals. 10. Debug: check for errors in programming. 11. PIR Sensor: passive electronic devices which detect motion by sensing infrared fluctuations. 12. Rectifier: is a device used for converting A.C into D.C 13. Resistor: a circuit element that presents a resistance to the flow of electric current. 14. Transformer: device which is used to change alternating current (A.C) from one voltage to another voltage. It is of two types viz. Step up transformer and step down transformer. 15. Transistor: The transistor is a three layer semiconductor device transfer signal from a low resistance to a high resistance. 16. Voltage: the term for electric force. Voltage is the energy per unit charge created when positive and negative charges are separated. 17. Voltage Regulator: regulation is the process of holding a voltage steady under conditions of changing applied voltage and changing load current. 18. Window Comparator: it detects when the input is between two limits.
  • 6. Page | iv LIST OF ABBREVIATION Sl. No. Terms Descriptions 1 A.C Alternating current 2 A Ampere 3 BSD Berkeley Software Distribution 4 C capacitor 5 CCTV Closed circuit Television 6 CRO Cathode Ray Oscilloscope 7 D Diode 8 D.C Direct current 9 E.M.F Electro motive force 10 FW Full wave 11 HTML Hyper Text Mark-up Language 12 HW Half wave 13 IC Integrated Circuit 14 PIR Passive Infrared 15 R Resistor 16 V Volt 17 LDR Light Dependent Resistor 18 OpenCV Free Open Source Computer Vision 19 XML Extensive Mark-up Language
  • 7. Page | v LIST OF TABLES Table 3.2-1: Comparison of simulation and experimentation results 44 Table 3.3-1: Comparison of Simulation and Experimentation Result 47 Table 3.4-1: Comparison of Simulation and Experimentation Result of 12V regulator 57 Table 3.5-1: Comparison of experimentation and simulation results of 5V regulator 62 Table 3.6-1: When PIR sensor is activated 69 Table 3.6-2: When PIR sensor is idle 69
  • 8. Page | vi LIST OF FIGURES Figure 1.2-1 Block diagram representation of the project 17 Figure 2.2-1 Basic construction of transformer 22 Figure 2.3-1 Full Wave Rectifier using Centre Tap Transformer 24 Figure 2.3-2 Output DC Voltage Waveform after Full-wave Rectification 24 Figure 2.4-1 Connection of filter circuit 28 Figure 2.4-2 Output waveform from filter circuit 28 Figure 2.5-1 Block Diagram of the Regulated Dual Voltage DC Power Supply 29 Figure 2.5-2 Symbol for three terminal IC regulator 29 Figure 2.5-3 IC regulator 30 Figure 2.5-4 LM7912 IC regulator 31 Figure 2.5-5 Configuration figure of LM7805 IC regulator 32 Figure 2.5-6 Two similar regulators connected as a plus-minus supply 33 Figure 2.6-1 PIR sensor 34 Figure 2.7-1 Differential Amplifier 35 Figure 2.8-1 Window Comparator used for the design 36 Figure 2.8-2 Output of window detector 36 Figure 2.9-1 Transistor used as a switch 37 Figure 2.9-2 SL100 transistor 37 Figure 2.10-1 Internal diagram of relay 39 Figure 3.2-1: Circuit diagram for transformer 42 Figure 3.2-2: Input supply from normal 230V ac supply 42 Figure 3.2-3: Output waveform from step-down 16 volt transformer 43 Figure 3.2-4: Output from CRO 43 Figure 3.3-1: Simulation circuit for Full Wave Rectifier 45 Figure 3.3-2: Input Waveform 45 Figure 3.3-3: Output Waveforms 46 Figure 3.3-4: CRO Output from positive Rectifier 46 Figure 3.3-5: CRO Output from negative Rectifier 47 Figure 3.4-1: Diagram from the complete simulation of 12V regulator 53 Figure 3.4-2: Input and output waveform of +12v Regulator 54 Figure 3.4-3: Input and Output waveform of -12V Regulator 54 Figure 3.4-4: Output waveform of the 12V regulator 55
  • 9. Page | vii Figure 3.4-5: Output waveform for 5V regulator 55 Figure 3.4-6: CRO input and output of +12V regulator 56 Figure 3.4-7: CRO input and output of -12V regulator 56 Figure 3.4-8: CRO output of 5V Regulator 57 Figure 3.5-1 Circuit diagram for differential amplifier 59 Figure 3.5-2: Input waveform to amplifier (output of PIR sensor) 60 Figure 3.5-3: Output waveform from the amplifier 60 Figure 3.5-4: Input to amplifier when PIR sensor is activated 61 Figure 3.5-5: Output from CRO 61 Figure 3.6-1: Design circuit for window detector 63 Figure 3.6-2: Circuit diagram for window comparator 64 Figure 3.6-3: Output from the window comparator when PIR senor is activated 65 Figure 3.6-4: Output Waveform when PIR sensor is activated 65 Figure 3.6-5: Input waveform 66 Figure 3.6-6: Output from PIR sensor when it is idle (does not detects any intruder) 66 Figure 3.6-7: Input to the window comparator when PIR sensor is activated 67 Figure 3.6-8: Output from the window comparator when PIR sensor is activated 68 Figure 3.6-9: Output from the window comparator when PIR sensor is idle 68 Figure 3.6-10: output from the window comparator when PIR sensor is idle 69 Figure 3.6-11 Complete circuit diagram 71 Figure 3.7-1: Transistor used as a switch 72 Figure 4.4-1 Environment variable setting to integrate OpenCV 2.4.4 in Microsoft Visual C++ 2010 80 Figure 4.4-2 Creating new project in Microsoft Visual C++ 2010 81 Figure 4.4-3 Empty project 81 Figure 4.4-4 Property setting in Microsoft Visual C++ 2010 from integration of OpenCV 2.4.4 82 Figure 4.4-5 Including OpenCV 2.4.4 directories in Microsoft Visual C++ 2010 82 Figure 4.4-6 To include OpenCV library in Microsoft Visual C++ 2010 83 Figure 4.4-7 Integrating OpenCV 2.4.4 libraries in Microsoft Visual C++ 2010 84 Figure 4.4-8 Creating new C++ file 84 Figure 5.2-1 Flow chart for the program 89 Figure 5.2-2 When program is starting 94
  • 10. Page | viii Figure 5.2-3 When webcam is not detected 94 Figure 5.2-4 When webcam is found 95 Figure 5.3-1Step for creating .exe file 96 Figure 5.3-2 Configuration Property setting for creating .exe file 96 Figure 5.3-3 Creating executable .dll independent file 97 Figure 5.3-4 Build .exe file of PIR Sensor 98 Figure 5.3-5 Window for capturing the video 98
  • 11. Page | ix LIST OF PHOTOGRAPHS Photograph 6.2-1 When there is no intruder in the range of PIR sensor 102 Photograph 6.2-2 Intruder has been detected 103 Photograph 6.2-3 The webcam continuously records the scene when there is intruder in its range 103 Photograph 6.2-4 When intruder is out of the range Lights and Webcam turns OFF 104
  • 12. Page | x TABLE OF CONTENT Acknowledgement i Abstract ii Terminology iii List of Abbreviation iv List of Tables v List of Figures vi List of Photographs ix CHAPTER 1: BACKGROUND AND INTRODUCTION 14 1.1 Background 15 1.2 Introduction 16 1.3 Motivation 17 1.4 Aim 18 1.5 Objectives 18 1.6 Project framework 18 1.7 Structure of the Project Report 19 CHAPTER 2: HARDWARE COMPONENTS- THEORY 21 2.1 Introduction 22 2.2 Transformer 22 2.2.1 Types of Transformer 22 2.2.2 Working of Transformer 23 2.3 Rectifier 24 2.3.1 Centre Tapped Full Wave Rectifier 24 2.4 Filters 25 2.4.1 Capacitor Filter 26
  • 13. Page | xi 2.4.2 Working of Capacitor Filter 27 2.5 Voltage Regulator 28 2.5.1 IC Voltage Regulator 29 2.5.2 Plus-Minus Supplies 33 2.6 PIR Sensor 33 2.6.1 Working or PIR Sensor 33 2.7 Differential Amplifier 34 2.8 Window Comparator 35 2.9 Transistor as a Switch 36 2.10 Relay 38 2.10.1 Working of Relay 38 2.11 Summary 39 CHAPTER 3: DESIGN, SIMULATION AND EXPERIMENT OF HARDWARE COMPONENTS 40 3.1 Introduction 41 3.2 Transformer 41 3.2.1 Design Procedure 41 3.2.2 Simulation and Results 42 3.2.3 Experimentation result obtained from breadboard 43 3.2.4 Comparison of simulation result and the experimentation result 44 3.3 Rectifier 45 3.3.1 Simulation result of centre-tapped rectifier 45 3.3.2 Experimentation result of rectifier 46 3.3.3 Comparison of Simulation and Experimentation Result 47 3.4 Voltage Regulator 48 3.4.1 Design Procedure 48 3.4.2 Simulation and result of power supply 53
  • 14. Page | xii 3.4.3 Experimentation Results of voltage regulators 56 3.4.4 Comparison of Simulation and Experimentation Result 57 3.5 Differential Amplifier 58 3.5.1 Design Procedure 58 3.5.2 Simulation and Result of differential amplifier 59 3.5.3 Experimentation 61 3.5.4 Comparison of simulation result and the experimentation result 62 3.6 Window Detector 62 3.6.1 Design Procedure 62 3.6.2 Simulation and Result of window comparator 64 3.6.3 Experimentation result of window comparator 67 3.6.4 Comparison of simulation result and the experimentation result of window comparator 69 3.7 Transistor as switch 72 3.7.1 Design Procedures of transistor as a switch 72 3.1 Summary 73 CHAPTER 4: INTEGRATING OPENCV WITH MICROSOFT VISUAL C++ 2010 75 4.1 Introduction 76 4.2 Microsoft Visual C++ 2010 76 4.2.1 Introduction 76 4.3 OpenCV 77 4.3.1 Introduction 77 4.4 Integration of OpenCV 2.4.4 with Microsoft Visual C++ 2010 79 4.4.1 Environment Setting 79 4.4.2 Creating a new project and set up Visual C++ 80 4.5 Different libraries used from OpenCV 85
  • 15. Page | xiii 4.6 Summary 86 CHAPTER 5: SOFTWARE PROGRAM 87 5.1 Introduction 88 5.2 General working of the program 88 5.2.1 Algorithm 88 5.2.2 Flow Chart 89 5.2.3 Program 90 5.2.4 Output of the Program 94 5.3 Creating Executable file (.exe) 95 5.4 Summary 98 CHAPTER 6: DEMONSTRATION 100 6.1 Introduction 101 6.2 Demonstrations 101 6.3 Summary 104 CHAPTER 7: CONCLUSION, CRITICAL ANALYSIS AND FUTURE WORKS106 7.1 Conclusion 107 7.2 Critical Analysis 107 7.3 Future works 109 Reference 111 Appendices 115 Appendix A: Diode 1N4007 115 Appendix B: LM7805 and LM7812 Positive IC Voltage Regulator 116 Appendix C: LM7912 Negative IC Voltage Regulator 119 Appendix D: uA741 Operational Amplifier (OPAMP) 121 Appendix E: LM324 Single Supply Quad Operational Amplifier 125 Appendix F: PCB Relay (JQC-3F(T73)) 129
  • 16. Page | 14 SECTION A CHAPTER 1: BACKGROUND AND INTRODUCTION Objectives of the chapter  Outlines the Background, Aim, Objectives, Motivations, Project Framework and structure of the project.
  • 17. Page | 15 1.1 Background Due to increasing number of crime and burglary, the need of security system is very essential. The security system that monitors the area throughout the time and reacts effective to the treat is in need. We have lots of security systems in the market for both indoor and outdoor applications such as ultrasonic detectors, CCTV, microwave detectors, photoelectric detectors, infrared detectors etc. ( Chowdhury, Imtiaz, Azam, Sumi, & Nur, 2013). However one or the other systems have the following disadvantages:  expensive (Lazko, 2013)  keeps running even when there are no intruders, thereby consuming more memory  complex circuitry  consumes large power  operation can be effected in different temperatures (Anon, 2013) A solution to overcome these problems could be by using a sensor of low cost which has the ability to detect the intruders as they come within the sensor’s detection range and generates an output. This output could be used for further signal processing or activating other devices like alarms system, lighting system, recording system and similar devices. This could at least save some power consumptions as some components get actuated only when there are intruders. Passive Infrared Sensor is a low cost, low power and reliable sensor (Zappi, Farella, & Benini, 2008). PIR sensors are manufactured with reduced form factor too. It has the ability to detect infrared rays and gets activated resulting in generation of electrical signal as the output. Therefore it was felt that a PIR sensor based security system consisting of the sensor, lighting system and a recording system (webcam and the software for saving the video) could overcome few or all of the above stated problems. The sensor can detect the presence of anything that comes in its range and has the ability to emit infrared rays. Upon detection, it generates the output in the form of electrical signal. Although the output from the sensor is of few volts, it could be amplified to required voltage using amplifier circuit and could be used for actuating lighting system and the webcam. The lighting and webcam could be turned on when the PIR sensor is activated and could remain off when the sensor is not activated. This way, the energy activated and could remain off when the sensor is not activated. This way, the energy
  • 18. Page | 16 consumed by the overall system could be minimised. Also the cost of system could be far less than the security system available in the market. With this hypothesis, we have carried out this project. It consists of designing of hardware components and software development for the recording video on the computer upon activation of the webcam. 1.2 Introduction Figure 1.2-1 shows the block diagram representation of our project. PIR sensors belong to the class of thermal detectors. Thermal detectors can measure incident radiation by means of a change in their temperature (Zappi, Farella, & Benini, 2008). PIR sensors are designed to detect human bodies, thus the wavelengths of interest are mainly in the range of the infrared window at 8-14μm, in which the IR emission of bodies at 370 C also peaks (Zappi, Farella, & Benini, 2008). A PIR sensor used in this project has some additional electronics circuitry for detecting intruder in the area. When the sensor is exposed to infrared radiation from human passing by the intended region, it generates an electric charge. A step down transformer is used to step down the input voltage of 230V AC to 16V AC using a 16-0-16 centre-tapped transformer. This 16V AC is rectified to get DC and regulated as per the requirement in later circuitries (PIR sensor and Comparator) of the system. 12V and 5V regulated output were obtained from two regulators and are used for the comparator/amplifier and PIR sensor respectively. The PIR sensor works with 5V DC input and gives DC output of 3-5 volts. The output is then amplified for activating the relay and the webcam. More on theory, design simulation and practical results of components of this project are discussed in the later chapters of the report. The system works in the following steps: 1. The software developed is kept running and it keep checking if the webcam is ON. 2. When an intruder comes in the detection range of the sensor, the sensor generates output of 3.3 volts. 3. This output is further amplified and is used for activating the relay of the lighting system and webcam of the recording system. 4. Once the relay and webcam are turned on with the output from the amplifier, the software finds the webcam is ON.
  • 19. Page | 17 5. The software starts to save the video captured by the webcam on the computer. 6. After the intruder leaves the detection range of the sensor, there is no output from the sensor. Therefore, it turns OFF the lamp and the webcam. The video captured will be saved in the computer. 7. Every time when the intruders come in the detection range of the sensor, the above steps from step 2- step 6 repeats. Figure 1.2-1 Block diagram representation of the project 1.3 Motivation With the increasing cases of theft in the college and around which generally took place at night hours, it was felt a security system could prevent this. After studying few of the security systems available in the market, it was found out these systems need to be turned ON for whole night and the video captured by the system is recorded. The intruder’s face cannot be figured out from the video recorded if the light is not turned ON during the recording time and it is must that the lighting system should be kept ON along with the recording system. These system remains turned ON even when there are no intruders resulting in the consumption of the electric power and occupying more spaces of the recording system.
  • 20. Page | 18 Therefore, it was felt the need of system where in the lighting system and recording system will get actuated when there is an intruder and gets turned OFF when the intruder leaves. A security system with a sensor could be a solution to this. A PIR sensor is a sensor which produces an electrical output upon detection of infrared. Human body can generate infrared rays. So it was felt that using PIR sensor to detect the presence of intruders and with its output to actuate the lighting system and recording system could be a solution to prevent the theft cases. With this motivation, we have carried out our project. 1.4 Aim The main aim of our project is to develop the PIR Sensor Based Security System which consumes less electrical energy and saves memory space of the recording system. 1.5 Objectives The following are the objectives set to achieve the main aim of the project.  Find out and overcome limitations of the existing security system.  Study about PIR sensor.  To study about the process of recording by the webcam (both hardware and software).  Develop a suitable security system using PIR sensor which can capture and record during the night hours or in the dark rooms consuming less electrical energy and occupying less memory of the recording system (webcam and laptop). 1.6 Project framework The proposed system started with in the following order:  Literature review on PIR sensor based systems and performance of PIR sensor was carried out.  Find the methods to integrate the PIR sensor with hardware system (lighting system, webcam and other electronic circuits).  The study on software development for capturing and recording the video.  Design PIR sensor based system.
  • 21. Page | 19 1.7 Structure of the Project Report The report is basically divided in to four sections viz. introduction & Background, hardware, software and demonstration. Section A gives background and introduction of the project. Section B gives the theoretical background, design, simulation, practical testing and comparison of the simulation and experimentation in the lab of the circuit designed. Section C gives introduction to the software used and the development of the program to record video captured by the webcam. Section D talks about the practical demonstration of our PIR sensor based Security System, conclusion, critical analysis and future works.
  • 22. Page | 20 SECTION B HARDWARE COMPONENTS
  • 23. Page | 21 CHAPTER 2: HARDWARE COMPONENTS- THEORY Objective of the chapter  Gives the brief theoretical background on different hardware components used in the project
  • 24. Page | 22 2.1 Introduction This chapter gives brief theory on the hardware components used in our PIR Sensor Based Security System. The working principles, types, expected output etc. of the components were discussed in an order of the components used in the project. 2.2 Transformer The transformer is a static device which works on principle of electromagnetic induction to step up or step down the voltage. It consists of two side, the primary side and secondary side which are separated by iron core (Sachdeva, 2012). Figure 2.2-1 Basic construction of transformer (Courtesy: http://www.physicstutorials.org/home/magnetism/transformers) 2.2.1 Types of Transformer Generally transformers can be classified into two types: i. Step Up transformer ii. Step Down Transformer  Step Up transformer Step Up transformers are used to step up the input A.C voltage by making more number of winding in secondary side than that of primary side.  Step Down Transformer Step Down transformers are used to step down the input A.C voltage by making more number of winding in primary side than that of secondary side.
  • 25. Page | 23 2.2.2 Working of Transformer When we apply an A.C source to the primary side of the transformer (V1), due to the phenomenon of electromagnetic induction the current in primary coil will produce magnetic flux which is linked to the secondary coil. When there is change in current in the primary side the flux in the secondary side also changes thus producing EMF (Electro Motive Force) V2 as shown in Figure 2.2-1 (Anon, Transformer, August). With reference to Figure 2.2-1, we can calculate the relation between the voltages, currents and number of turns of the primary side/coil and secondary side of the transformer (Anon, Rectifier, 2012). 2 1 2 1 N N V V  (2.2-1) 2 1 1 2 N N I I  (2.2-2) Equating (2.2-1) and (2.2-2) we get: 1 2 2 1 I I V V  (2.2-3) Where 1V = Voltage in primary side/coil 2V = Voltage in Secondary side/coil 1I = Current in primary 2I = Current in secondary 1N = Number of turns in Primary coil 2N = Number of turns in secondary coil We are using centre tap transformer for the step down purpose in the project because in centre tap transformer there is equal amount of voltage transfer in opposite polarity (that is +V and –V).
  • 26. Page | 24 2.3 Rectifier Rectifier is a device used for converting A.C into D.C (Anon, Rectifier, 2012). The process of converting Alternating Current (AC) into Direct Current (DC) is known as rectification. Thus rectifiers can also be defined as electrical devices used to perform rectification (Anon, Diode Lab). The rectifiers are basically classified into three types according to their configuration i. Half Wave Rectifier ii. Full Wave Rectifier iii. Bridge rectifier 2.3.1 Centre Tapped Full Wave Rectifier In Full Wave Rectifier both the halves of the A.C signal are used to cause output current to flow in the same direction. This type of rectifier usually uses Centre Tap transformer. The figure of full wave rectifier is as shown in Figure 2.3-1 and its wave form is as shown in Figure 2.3-2 (Bigelow, 1996) Figure 2.3-1 Full Wave Rectifier using Centre Tap Transformer Figure 2.3-2 Output DC Voltage Waveform after Full-wave Rectification
  • 27. Page | 25  Working of full wave rectifier The full wave rectifier circuit consists of two diodes connected to a single load resistance (RL) with each diode taking it in turn to supply current to the load. When point A of the transformer is positive with respect to point C, diode D1 conducts in the forward direction as indicated by the arrows. When point B is positive (in the negative half of the cycle) with respect to point C, diode D2 conducts in the forward direction and the current flowing through resistor R is in the same direction as that of positive half cycle. As the output voltage across the resistor R is the phasor sum of the two waveforms combined, this type of full wave rectifier circuit is also known as a "bi-phase" circuit (Storr, Electronics-Tutorials.ws, 1999). This project has used two full wave rectifiers to convert the AC input into DC output. Why we have used centre tapped rectifier? Though bridge rectifier is more advantage than Centre tapped full wave rectifier, the centre tapped full wave rectifier as per the following reason:  Requirement to generate plus-minus voltage to supply Op-Amps If two bridge rectifiers are used, number of diode used in circuit increases (eight diode), thereby increasing losses due to diode and size of circuit. Therefore, in order to have clean circuit with reduced component, two centre tapped full wave rectifier is (use only four diode) to generate plus-minus voltage. 2.4 Filters While the output of a rectifier is a pulsating dc, most electronic circuits require a substantially pure dc for proper operation. This type of output is provided by single or multi-section filter circuits placed between the output of the rectifier and the load. An electric filter is often a frequency-selective circuit that passes a specified band of frequencies and blocks or attenuates signals of frequencies outside this band (Gayakwad). A filter is an electrical network that alters the amplitude and/or phase characteristics of a signal with respect to frequency. Ideally a filter will not add new frequencies to the input signal nor will it change the component frequencies of that signal, but it will change the relative amplitudes of the various frequency components and/or their phase relationships.
  • 28. Page | 26 Filters are often used in electronic systems to emphasize signals in certain frequency ranges and reject signals in other frequency ranges (Lacanette, 2012). There are four basic types of filter circuits:  Simple capacitor filter  LC choke-input filter  LC capacitor-input filter(pi-type)  RC capacitor-input filter(pi-type) 2.4.1 Capacitor Filter In our project we have used simple capacitor filter. A capacitor opposes any change in voltage. The opposition to a change in current is called capacitive reactance (XC) and is measured in ohms. The capacitive reactance is determined by the frequency (f) of the applied voltage and the capacitance (C) of the capacitor. FCXC 2 1  (2.4-1) Where XC is capacitive reactance, F is frequency, C is capacitance From the Equation 2.4-1, we can see that if frequency or capacitance is increased, the XC decreases. Since filter capacitors are placed in parallel with the load, a low XC will provide better filtering than a high XC. For this to be accomplished, a better shunting effect of the ac around the load is provided. To obtain a steady dc output, the capacitor must charge almost instantaneously to the value of applied voltage. Once charged, the capacitor must retain the charge as long as possible. The capacitor must have a short charge time constant. This can be accomplished by keeping the internal resistance of the power supply as small as possible (fast charge time) and the resistance of the load as large as possible. As we know one time constant is defined as the time it takes a capacitor to charge to 63.2 % of the applied voltage or to discharge to 36.8 per cent of its total charge.
  • 29. Page | 27 This action can be expressed by the following equation: RCt  (2.4-2) Where: R represents the resistance of the charge or discharge path C represents the capacitance of the capacitor. A capacitor is considered fully charged after five RC time constants. A steady dc output voltage is obtained when the capacitor charges rapidly and discharges as slowly as possible. In filter circuits the capacitor is the common element to both the charge and the discharge paths. Therefore, to obtain the longest possible discharge time, capacitor value should be as large as possible. Another way to look at it is: The capacitor acts as a short circuit around the load (as far as the ac component is concerned) since the larger the value of the capacitor (C), the smaller the opposition (XC) or reactance to ac. This (passive) type of filter consists of large value of capacitor connected across the load resistor. This capacitor offers a low reactance to the A.C components and very high impedance to D.C, so that the A.C components in the rectifier output find low reactance path through capacitor and only a small part flows through R, producing small ripple at the output. 2.4.2 Working of Capacitor Filter The value of CX should be smaller than R because, current should pass through C and C should get charged. If C value is very small, CX will be large and hence current flows through R only and no filtering action takes place. The capacitor C gets charged when the diode (in the rectifier) is conducting and gets discharged (when the diode is not conducting) through R. When the input voltage tVv sin is greater than the capacitor voltage, C gets charged. When the input voltage is less than that of the capacitor voltage, C will discharge through R (Ramesh, 2012). The stored energy in the capacitor maintains the load voltage at a high value for a long period. The diode conducts only for a short interval of high current. The connection of filter circuit and waveforms are as shown in Figure 2.4-1 and 2.4-2 (Ramesh, 2012). Capacitor opposes sudden fluctuations in voltage across it. So the ripple voltage is minimized.
  • 30. Page | 28 For this project we are using shunt capacitor (C) passive filter. Figure 2.4-1 Connection of filter circuit Figure 2.4-2 Output waveform from filter circuit The capacitor filter are used in our project since it provide us with the following advantages  Low cost  Small size and weight  Good characteristics  Can be connected for both HW and FW rectifiers  Improved D.C output However the drawback is capacitor filter draws more current (Ramesh, 2012). 2.5 Voltage Regulator Voltage regulation is the process of holding a voltage steady under conditions of changing applied voltage and changing load current. The regulated power supply is to provide the necessary dc voltage and current, with low level of ac ripple and with stability and regulation. A device which is responsible for obtaining constant DC voltage is called voltage regulator (Kuhn, 2009). Many electronic systems require a stable power supply voltage and use voltage regulators to accomplish that. The following block diagram shown in Figure 2.5-1 (Dev, Khan, &
  • 31. Page | 29 K., 2009) below, shows how the voltage regulator is employed in the process of voltage regulation. TRANSFORMER STEP-DOWN RECTIFIER FILTER POSITIVE REGULATOR O P I P FILTER NEGATIVE REGULATOR +V -V Figure 2.5-1 Block Diagram of the Regulated Dual Voltage DC Power Supply 2.5.1 IC Voltage Regulator With the advent of the integrated technology now it has become technically and economically feasible to incorporate all discrete components of regulator circuits in monolithic form, giving all benefit if ICs, such as, excellent performance, small size, ease of use, low cost, and above all high reliability. As the result three- terminal voltage regulator are now available. Figure 2.5-2 Symbol for three terminal IC regulator The general circuit symbol of IC voltage regulators are shown in the Figure 2.5-2 (Dev, Khan, & K., 2009). There are three terminals as labelled Vin, Vout and COM. The device accepts the unregulated DC voltage across the Vin and COM terminal and yields a DC regulated voltage across the Vout and COM terminals (Dev, Khan, & K., 2009).  Classification of IC voltage regulator The three terminal voltage with a variety of regulate output voltage rating are available from different manufacturer. The well-known types of voltage regulator ICs are (Dev, Khan, & K., 2009); 1. Three-terminal fixed voltage regulators (positive) : 78XX series 2. Three-terminal fixed voltage regulators (negative) : 79XX series
  • 32. Page | 30 3. Three-terminal adjustable voltage regulators (positive) : LM 317 4. Three-terminal adjustable voltage regulators (negative) : LM 337 National Semiconductor offers 78XX/79XX series regulator with its standard LM prefix. The last two digits ‘XX’ of the series give the rated nominal output voltage. For example LM7805 regulator is +5V regulator and LM7905 is -5V regulator. LM7812: A Positive Voltage Regulator (12V) Figure 2.5-3 IC regulator The LM7812 as shown in Figure 2.5-3 (Dev, Khan, & K., 2009) of three terminal positive regulators are available in the TO-220 package and with several fixed output voltages, making them useful in a wide range of applications. Each type employs internal current limiting, thermal shut down and safe operating area protection, making it essentially indestructible. If adequate heat sinking is provided, they can deliver over 1A output current. Although designed primarily as fixed voltage regulators, these devices can be used with external components to obtain adjustable voltages and currents. Features: 1. Output Current up to 1A 2. Output Voltages of 12 volt 3. Thermal Overload Protection 4. Short Circuit Protection 5. Output Transistor Safe Operating Area Protection
  • 33. Page | 31 LM7912: A Negative Voltage Regulator (-12V) Figure 2.5-4 LM7912 IC regulator The LM7912 regulator as shown in Figure 2.5-4 (Dev, Khan, & K., 2009) comes from 79xx family of self-contained fixed linear voltage regulator integrated circuits, where it would give fixed output of -12V DC in ideal cases. The LM79XX series of 3-terminal regulators is available with fixed output voltages of - 5V,-8V, -12V, and -15V. These devices need only one external component -a compensation capacitor at the output. The LM79XX series is packaged in the TO-220 power package and is capable of supplying 1.5A of output current (Dev, Khan, & K., 2009). These regulators employ internal current limiting safe area protection and thermal shutdown for protection against virtually all overload conditions. Low ground pin current of the LM79XX series allows output voltage to be easily boosted above the pre-set value with a resistor divider. The low quiescent current drain of these devices with a specified maximum change with line and load ensures good regulation in the voltage boosted mode. Features: 1. Thermal, short circuit and safe area protection 2. High ripple rejection 3. 1.5A output current 4. 4% tolerance on pre-set output voltage 5V regulator (LM7805) The standard configuration of IC voltage regulator LM7805 is as given in Figure 2.5-5. However the simple configuration is also given below with certain value of capacitor with
  • 34. Page | 32 intended fixed output 5 V. Such configuration can withstand short circuits and also overheating. The only way the damage occurs is by the application of reverse voltage to its input. Reverse polarity destroys regulator instantly (Khan & Dey, 2009). Figure 2.5-5 Configuration of LM7805 IC regulator Advantage of LM7805 series over other The 7805 series has several key advantages over many other voltage regulator circuits which have resulted in its popularity (Anon, National Semiconductor Cooperation , 2000): i. 7805 series ICs do not require any additional components to provide a constant, regulated source of power, making them easy to use, as well as economical, and also efficient uses of circuit board real estate. By contrast, most other voltage regulators require several additional components to set the output voltage level ii. 7805 series ICs have built-in protection against a circuit drawing too much power. They also have protection against overheating and short-circuits, making them quite robust in most applications. In some cases, the current-limiting features of the 7805 devices can provide protection not only for the 7805 itself, but also for other parts of the circuit it is used in, preventing other components from being damaged as well.
  • 35. Page | 33 2.5.2 Plus-Minus Supplies Figure 2.5-6 Two similar regulators connected as a plus-minus supply In this project IC regulator LM7812 and LM7912 as shown in Figure 2.5-6 (Bell, 2004) is used in order to obtain plus-minus supplies. The negative output terminal of a voltage regulator is grounded to give an output voltage which is positive with respect to ground. So long as there are no grounded terminals in the unregulated supply, the positive output of the regulator can be grounded to produce an output which is negative with respect to ground. Using two dc voltage regulators, one positive and one negative terminal can be connected together and grounded, as illustrated in Figure 2.5-6. This produces the type of plus-minus voltage often used as supply for operational amplifier (Bell, 2004). 2.6 PIR Sensor 2.6.1 Working or PIR Sensor PIR sensors are passive electronic devices which detect motion by sensing infrared fluctuations. Once a motion is detected, a high signal is sent to the signal pin. Because of the biological characteristic of organisms to emit heat; these sensors work well in detecting human motion and therefore are commonly implemented in security applications (Anon, National Semiconductor Cooperation , 2000). The human body radiates infrared waves with wavelengths of 8 to 12 micrometres. Any movement by a person leads to a change in the amount of infrared energy which a sensor can detect within its range (Anon, Parallax) Pyro-electric 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,
  • 36. Page | 34 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 (Anon, Tech Note, 2010). Figure 2.6-1 PIR sensor Also PIR sensors work best when there is a large difference between the air temperature and the animal. In warm temperatures, say above 80 degrees Fahrenheit, the detection range will be reduced. In cold temperatures, below 40 degrees, the detection distance will increase (Anon, Tech Note, 2010). Typically, the PIR sensor that we have used has the detection range of 6 meters (20 feet), and is designed to adjust to slowly to changing conditions environment as shown in Figure 2.6-1 such as gradual change in the thermal profile of the surroundings as the day passes 2.7 Differential Amplifier Differential Amplifier is a special type of amplifier, which can amplify the difference of input signals. It is used in another special type of amplifier circuit called Operational Amplifier (OPAMP). The differential amplifier has two inputs: inverting input (input–1) and non-inverting input (input–2). Its output signal is 180° out of phase with inverting input signal and in phase with non-inverting input signal. For example, when negative voltage is connected to inverting terminal we get positive voltage at output. Similarly, when negative voltage is connected to non-inverting terminal, we get negative voltage at output. The Figure 2.7-1 shows circuit of differential amplifier. It is symmetrical circuit,
  • 37. Page | 35 i.e. it has same components on both sides. If all resistors are equal it becomes a straight difference amplifier (Nave, 2011). The output of differential amplifier is given by: 1 3 1 113 413 2 )( )( R R V RRR RRR VVout     (2.7-1) If 12 ; 44 RRRR  Then, it gives an amplified difference (Nave, 2011). 2.7-1 Differential Amplifier 2.8 Window Comparator The window comparator compares an input signal fed from the PIR sensor which is amplified to a 'low' and a 'high' reference voltage level (VRef Low and VRef High, respectively) which is a window. A window comparator is also called double-ended limit detector as it detects when the input is between two limits. It uses two op-amps as comparators and two reference voltages. If the input is between the windows (between two reference levels) it outputs a logic low level. If the input is higher than VRef High or lower than VRef Low, the output goes to logic high or the positive saturation. One of the op amps is used for comparing the input to VRef High while the other op amp is used for comparison with VRef Low (Paul, Industrial Electronics And Control, 2004). The diodes (D1 and D2) are used to isolate the outputs of the two op amps from each other (Anon, ECE lab, 2006). If the signal is in the window, the upper comparator will be at negative saturation since its non-inverting input is negative. The lower comparator will also be at negative saturation because its inverting input is positive. Both diodes are
  • 38. Page | 36 reverse biased and the voltage across the load is zero. If the input becomes above the upper limit, the upper comparator goes to a positive saturation. If the input turns less than lower limit the lower comparator goes to positive saturation as its inverting inputs will be negative to its non-inverting input. This will forward bias D2 and the combined output becomes positive saturation (Anon, ECE lab, 2006). Figure 2.8-1 Window Comparator used for the design Figure 2.8-2 Output of window detector 2.9 Transistor as a Switch When a transistor is used as a switch it must be either OFF or fully ON. In the fully ON state the voltage VCE across the transistor is almost zero and the transistor is said to be saturated because it cannot pass any more collector current IC. The output device switched by the transistor is usually called the 'load'. The power developed in a switching transistor is very small:  In the OFF state: power = Ic × VCE, but Ic = 0, so the power is zero.
  • 39. Page | 37  In the full ON state: power = Ic × VCE, but VCE = 0 (almost), so the power is very small. Figure 2.9-1 Transistor used as a switch This means that the transistor should not become hot in use and you do not need to consider its maximum power rating. The important ratings in switching circuits are the maximum collector current Ic (max) and the minimum current gain hFE (min). The transistor's voltage ratings may be ignored unless you are using a supply voltage of more than about 15V. There is a table showing technical data for some popular transistors on the transistors page (Storr, Transistor as a switch, 2013). In our project we are using SL100 transistor. SL100 is a general purpose, medium power NPN transistor. It is mostly used as switch in common emitter configuration. The transistor terminals require a fixed DC voltage to operate in the desired region of its characteristic curves. This is known as the biasing. For switching applications, SL100 is biased in such a way that it remains fully on if there is a signal at its base. In the absence of base signal, it gets turned off completely. Figure 2.9-2 SL100 transistor
  • 40. Page | 38 The emitter leg of SL100 is indicated by a protruding edge in the transistor case. The base is nearest to the emitter while collector lies at other extreme of the casing (Anon, Transistor SL100, 2012). 2.10 Relay A relay is an electrically operated switch. Many relays use an electromagnet to operate a switching mechanism mechanically. Relays are simple switches which are operated both electrically and mechanically. Relays consist of an n electromagnet and also a set of contacts. The switching mechanism is carried out with the help of the electromagnet. There are also other operating principles for its working. But they differ according to their applications. Most of the devices have the application of relays. A relay is said to switch one or more poles. Each pole has contacts that can be thrown in mainly three ways. They are (Anon, Relay-construction-and-operation).  Normally Open Contact (NO) – NO contact is also called a make contact. It closes the circuit when the relay is activated. It disconnects the circuit when the relay is inactive.  Normally Closed Contact (NC) – NC contact is also known as break contact. This is opposite to the NO contact. When the relay is activated, the circuit disconnects. When the relay is deactivated, the circuit connects.  Change-over (CO) / Double-throw (DT) Contacts – This type of contacts are used to control two types of circuits. They are used to control a NO contact and also a NC contact with a common terminal. According to their type they are called by the names break before make and make before break contacts. 2.10.1 Working of Relay The working of a relay can be better understood by explaining Figure 2.10-1 (Anon, Relay-construction-and-operation). The diagram shows an inner section diagram of a relay. An iron core is surrounded by a control coil. As shown Figure 2.10-1, the power source is given to the electromagnet through a control switch and through contacts to the load. When current starts flowing through the control coil, the electromagnet starts energizing and thus intensifies the magnetic field. Thus the upper contact arm starts to be attracted to the lower fixed arm and thus closes the contacts causing a short circuit for the
  • 41. Page | 39 power to the load. On the other hand, if the relay was already de-energized when the contacts were closed, then the contact move oppositely and make an open circuit. Figure 2.10-1 Internal diagram of relay As soon as the coil current is off, the movable armature will be returned by a force back to its initial position. This force will be almost equal to half the strength of the magnetic force. This force is mainly provided by two factors. They are the spring and also gravity. Relays are mainly made for two basic operations. One is low voltage application and the other is high voltage. For low voltage applications, more preference will be given to reduce the noise of the whole circuit. For high voltage applications, they are mainly designed to reduce a phenomenon called arcing (Anon, Relay-construction-and- operation). 2.11 Summary This chapter briefly discussed the theory of the hardware components used in PIR Sensor Based Security System. The working principles, types of some components, circuit analysis, some components advantages and disadvantages were discussed.
  • 42. Page | 40 CHAPTER 3: DESIGN, SIMULATION AND EXPERIMENT OF HARDWARE COMPONENTS Objectives of the chapter:  Outline the design procedure of different hardware parts  Simulate the different hardware parts used in the system  Test the hardware parts in breadboard  Compare the experimental and simulation result
  • 43. Page | 41 3.1 Introduction This chapter encompasses design, simulation and experimentation of each component used in PIR Sensor Based Security System. The design, simulation and experimentation of hardware parts include the power supply circuit, amplifier circuit, comparator circuit and transistor as a switch. The design of the components will be explained and simulations results for the same are shown in this chapter. The simulation was carried out in PSpice software. The validation for the simulation results are shown by experimenting in the lab using breadboards. The results of both simulation and experimentation are shown in this chapter. 3.2 Transformer 3.2.1 Design Procedure In the simulation of the power supply, firstly centre tap transformer is designed the as follows: 2 1 2 1 N N V V  (3.2.1) Where we assumed that N1= 4500 turns and calculated the value for N2 as V1= 230V and V2=32V. 230 324500 2 x N  The value of N2 =626.09 turns. Then using the following formula we calculated the value for inductor. 2 1 2 2 1 L L N N       (3.2.2) Where we assumed that L2= 10µΩ and calculated the value for L1 as N1= 4500turns and N2=626.09turns. 10 09.626 4500 2 1 xL        The value of L1 was found as 516.75µH.
  • 44. Page | 42 These values of inductor thus obtained were used in simulation for proper step down of the input voltage. 3.2.2 Simulation and Results  Simulation Result of 16-0-16 Step-down Transformer Figure 3.2-1: Circuit diagram for transformer  Input supply Figure 3.2-2: Input supply from normal 230V ac supply The input given to the step down transformer is 50 Hz, 230V. Figure 3.2-2 shows the simulation result of the input given to the transformer. Note: In taking out the output we have taken separately due to the large difference of the voltage output is very small to be visible enough. V2 FREQ = 50 VAMPL = 230V VOFF = 0V R4 0.000005 0 0 Lp Ls1 Ls2 TX6 XFRM_LIN/CT-SEC R5 1k V V
  • 45. Page | 43  Output from the step-down transformer Figure 3.2-3: Output waveform from step-down 16 volt transformer The output obtained is 16V after the 230 V is stepped down using the transformer. 3.2.3 Experimentation result obtained from breadboard  Output Figure 3.2-4: Output from CRO From the Figure 3.2-4, volts/div is given as 5V and the peak of output waveform is 3.1 divisions. The 230V AC supply has been stepped down to 15.5V by 16-0-16 centred- tapped step down transformer.
  • 46. Page | 44 3.2.4 Comparison of simulation result and the experimentation result Table 3.2-1: Comparison of simulation and experimentation results Simulation Result Experimentation Result CRO reading Multi-meter reading Input 230V 230V 230V Output 16V 15.5V 16V Thus from the Table 3.2-1, we conclude that the output voltage obtained from simulation and experimentation is almost equal. Therefore an input of 230V is stepped down to 16V.
  • 47. Page | 45 3.3 Rectifier 3.3.1 Simulation result of centre-tapped rectifier  Circuit Diagram Figure 3.2-5: Simulation circuit for Full Wave Rectifier  Input supply to the rectifier Figure 3.2-6: Input Waveform D1 D1N4004 D2 D1N4004 D3 D1N4004 D4 D1N4004 R3 625 0 0 V2 FREQ = 50 VAMPL = 230V VOFF = 0V R4 0.000005 0 R10 1k 0 Lp Ls1 Ls2 TX6 XFRM_LIN/CT-SEC V V V
  • 48. Page | 46  Output from the rectifier Figure 3.2-7: Output Waveforms The input AC voltage of 15V (blue waveform) is rectified to DC voltage (as shown by red and green waveform) by two full wave rectifier circuit. We have used two rectifiers circuit to get both positive and negative supply for the elements like Op-amps in later parts. 3.3.2 Experimentation result of rectifier  Output from positive Rectifier Figure 3.2-8: CRO Output from positive Rectifier
  • 49. Page | 47 This is CRO output waveform from full wave rectifier (D1 and D2) which gives positive dc output voltage of 15V as follows: Volt/division = 5v Number of division =3  Output voltage = 3×5 = 15volts  Output from negative Rectifier Figure 3.2-9: CRO Output from negative Rectifier This is CRO output waveform from full wave rectifier (D1 and D2) which gives positive dc output voltage of 15V as follows: Volt/division = 10v (it is shown in Figure 3.3.-5, beside CH1) Number of division = -1.5  Output voltage = -10×1.5 = -15volts 3.3.3 Comparison of Simulation and Experimentation Result Table 3.2-2: Comparison of Simulation and Experimentation Result Simulation Result Experimentation Result CRO reading Multi-meter reading Input (AC) 16V 16V 16V Output (DC) 15V 15V 15V
  • 50. Page | 48 From this result we can conclude that simulation and experimentation output are same. Thus, this rectifier can be effectively used as the supply for the voltage regulator that we are using in later sections. 3.4 Voltage Regulator 3.4.1 Design Procedure  Design Procedure of 12V Voltage Regulator As discussed above in section 2.5 about the voltage regulator, this is the device to get the fixed constant voltage. In our project we use have used two regulators:  12V regulator and 5V regulator.  The Steps for designing the input to Regulator Following are the steps used for designing the power supply to the regulator (Dev, Khan, & K., 2009) 1. Select ⁄ step down transformer capable of giving around 1A current in the secondary. 16V here represents the centre-tapped step down transformer that we are using. 2. We find out the dc voltage at the output of regulator when the ac input voltage varies from 180V-250V under the condition that the capacitor filter C1 loaded. Here we are assuming that the AC fluctuation to be between this window (180V-250V). 3. When the input ac voltage is 230V and output is 16V,the transformer turns ratio is calculated by: 2 1 2 1 N N V V  (3.4-1) 4. When the input ac voltage is 180V and 250V (assuming the minimum fluctuating limits as 180V and maximum fluctuating limit as 250V in order to obtain maximum possible input for 12V regulator) using Np: Ns data, we calculate an output at the secondary of the transformer by the below equation. sp s NN geInputVolta rmsV : )(  (3.4-2)
  • 51. Page | 49 Take the lowest secondary voltage from above calculation. )(2)( rmsVpeakV ss  (3.4-3) 5. The we calculate the peak value of the voltage Vs (peak) at secondary of the transformer 6. Find the peak value of the voltage Vc1 (peak) at the input to the regulator. 2V-(peak)V=(peak)V sC1 (3.4-4) Taking 7.0V ( V is cut-in voltage of the diode used in bridge rectifier) 7. Calculate the maximum peak to peak ripple voltage that can be tolerated at the input to the regulator. (Note: the ripple voltage must not cause the input to fall below the minimum required to maintain regulation which is 15.5V for LM7812) ]5.15)([2)( 1  peakVPPV cv (3.4-5) 8. Find the value of filter capacitor C1 using equation )( 2 1 PPV fc I v dc   32.102 1   f I C dc Idc= 1A when the filter is heavily loaded. 9. LM7812 show that the ripple rejection under the given operating condition is a minimum of 62dB Thus, 20 log [ ] = 62 dB ( is peak to peak ripple voltage) 10. Connect the resistor 620 across the output of the regulator (to maintain the quiescent current) and capacitor C2 = 0.1 F to eliminate any high frequency pulses.
  • 52. Page | 50  Calculation The Calculation of the values of different components for this project is (Dev, Khan, & K., 2009): 1. The transformer turns ratio as we are using the transformer as 230V/16V: 16 230  s p N N = 14.375 2. Output voltage of secondary transformer a) At AC input voltage of 180V sp s NN geInputVolta rmsV : )(  375:3.14 180 )( rmsVs = 12.521V b) At AC input voltage of 250V 375:3.14 250 )( rmsVs =17.51V Here we can take the lowest secondary voltage 12.521V when input line supply is 180V. As per the datasheet the minimum requirement for the regulator is 12V. 3. Peak value of voltage at secondary transformer (rms)Vs2=Vs(peak)  = 17.70V12.5212  4. Peak value of voltage at the input to the regulator 2V-(peak)V=(peak)V sC1 0.72-17.70= 
  • 53. Page | 51 V6.301= 5. Maximum peak-to-peak ripple voltage 15.5]-(peak)2[V=(PP)V c1v 15.5]-2[16.30= 1.6V= 6. Filter capacitor C1 ≤ Vv (PP) ≤ 1.6V C1 ≥ When C1 ≥ = 1.990 x 10-3 F C1 ≥ 1990μF Thus, the filter capacitor of value1990μF or preferably more should be selected. But the lower value can also be used. 7. Change in output dc voltage, ΔVout dB V V ou in 55]log[20    VVin 6.1 mV anti V V in out 84.2 20 55 log          Therefore, mVVout 84.2
  • 54. Page | 52 Thus, the change in the output dc voltage about the regulated voltage of +12V shall be around mV84.2  Design Procedure of 5V regulator (LM7805) Since the input to this regulator is already regulated 12 V DC. The initial process is not required. The 12V DC can be feed directly to the input terminal of the LM7805 IC. The bypass capacitor C1 and C2 are used for optimum stability and transient response.
  • 55. Page | 53 3.4.2 Simulation and result of power supply  12 V Regulators: Circuit Diagram Figure 3.4-1: Diagram from the complete simulation of 12V regulator C3 0.1u 0 C7 0.1u 0 C8 33u 0 0 D13 D1N4004 D14 D1N4004 D15 D1N4004 D16 D1N4004 C5 470u U1 LM7812C IN 1 OUT 2 GND 3 U2 LM7912C IN 3 OUT 2 GND 1 C4 1u 1k D17 D1N4004 D18 D1N4004 D10 D1N4004 D11 C2 470u V4 FREQ = 50 VAMPL = 230V VOFF = 0V R8 0.000005 Lp Ls1 Ls2 TX6 XFRM_LIN/CT-SEC U3 LM7805C IN 1 OUT 2 GND 3 D19 D1N4004 D20 D1N4004 R7 1k V V V
  • 56. Page | 54 For the clear vision of the output we have taken out the result separately for different position as indicated in the Figure 3.4-1.  Input and output of +12v Regulator Figure 3.4-2: Input and output waveform of +12v Regulator Figure 3.4-2 shows the simulation result of +12V regulator with the rectifier input. From the output figure the input to the regulator circuit is not exactly 16Vas expected, this may be due to the drop across the elements. It is the regulated +12V that’s the output which is our focus. Therefore, we see the output is exactly 12V as expected.  Input and Output of -12V Regulator Figure 3.4-3: Input and Output waveform of -12V Regulator
  • 57. Page | 55 Figure 3.4-3 shows the simulation result of -12V regulator with the rectifier input. From the output figure the input to the regulator circuit is not exactly 16V as expected, this may be due to the drop across the elements. It is the regulated -12V that’s the output which is our focus. Therefore, we see the output is exactly -12V as expected. Figure 3.4-4: Output waveform of the 12V regulator Figure 3.4-4 shows the V12 regulator output. With the input from the rectifier we were able to obtain V12 for the Opamps that we are using in later circuits.  5V regulator: Output Figure 3.4-5: Output waveform for 5V regulator
  • 58. Page | 56 3.4.3 Experimentation Results of voltage regulators  CRO input and output of +12V regulator Figure 3.4-6: CRO input and output of +12V regulator From the Figure 3.4-6 we see that volts/div is 10.0V and divisions of output is 1.15 div, thus the output result is 11.5V. It was found that the result on the multi-meter was 12V with 15.64V ( V16 ) input  CRO input and output of -12V regulator Figure 3.4-7: CRO input and output of -12V regulator From the Figure 3.4-7 volts/div of the output voltage is 10.0V and the division of output is -1.2 div, thus output voltage is -12V.
  • 59. Page | 57  CRO output of 5V Regulator Figure 3.4-8: CRO output of 5V Regulator From the Figure 3.4-8, the volts/div is 2V/div and the output mark divisions is 2.4 div. therefore, output voltage is 4.8V ( V5 ) 3.4.4 Comparison of Simulation and Experimentation Result  For 12V regulator Table 3.4-1: Comparison of Simulation and Experimentation Result of 12V regulator Simulation Result Experimentation Result CRO reading Multi-meter reading Input (AC) 16V 15.64V 15.64 Output (DC) 15V  12V 12V It was found that the result on the multi-meter was -12V with 15.64V ( V16 ) input. This confirms the DC output of  12V to be the supplied to Opamps and 5V regulator.
  • 60. Page | 58 3.5 Differential Amplifier 3.5.1 Design Procedure The output of differential amplifier is given by 1 3 1 124 413 2out R R V- R)R+(R R)R+(R V=V (3.5-1) We have, Vout=5V (this is the required input that need to be given to comparator) V1=0V V2=3.3 NOTE: The value on V1 and V2 are the output from PIR sensor when it is activated and idle respectively. We have used the PIR sensor which gives the output of 3.3V when activated and 0V when idle. Thus to get the amplified output, R4=R3 and R2=R1 Let us take the value of R1=R2=3.3 K Hence the equation (3.4.1) becomes 0- 3.33.3)+(R R3.3)+(R 3.3=5 4 43 3.33.3)+(R R3.3)+(R 3.3=5 4 33 Solving the above equation, we get the value of R3=5 and -3.3. Therefore ignoring the negative value, we take R3=R4=5 K
  • 61. Page | 59 3.5.2 Simulation and Result of differential amplifier  Circuit Diagram of differential amplifier Figure 3.5-1 Circuit diagram for differential amplifier Here 3.3V DC supply represents the output of PIR sensor. Since the PIR sensor is not build in PSpice software, we have measured the PIR sensor output when activated and it was found to be 3.3V. Therefore, we have used as external 3.3 V DC supply for the simulation purpose. In reality, this 3.3V will be replaced by the PIR sensor output. This 3.3V output of PIR sensor is amplified to 5V DC by using differential amplifier. The amplified voltage will be given to window comparator in later circuit.  Input to amplifier from the PIR sensor The input voltage given to the Op-amp is 3.3V. This voltage is obtained when the PIR sensor is activated. In case the PIR sensor is not activated, the input voltage remains zero. R9 5K V7 12Vdc V8 12Vdc R3 3.3k R4 5K U1 uA741 + 3 - 2 V+ 7 V- 4 OUT 6 OS1 1 OS2 5 0 V10 3.3Vdc V V
  • 62. Page | 60 Figure 3.5-2: Input waveform to amplifier (output of PIR sensor)  Amplified output of the PIR sensor output voltage when activated Figure 3.5-3: Output waveform from the amplifier The input voltage of 3.3V given from the PIR sensor is amplified to 5V by differential amplifier.
  • 63. Page | 61 3.5.3 Experimentation  Output of PIR sensor when activated Figure 3.5-4: Input to amplifier when PIR sensor is activated Volt/div = 1 Div = 3.2  Voltage = 3.2 V ( V3.3 ) The input voltage to amplifier obtained from the CRO is 3.3V which has been amplified to 5V.  Output from CRO Figure 3.5-5: Output from CRO
  • 64. Page | 62 Volt/division = 2v Division = 2.4  Voltage = 4.8 V ( V5 ) Thus the amplified output obtained at CRO is 5V. 3.5.4 Comparison of simulation result and the experimentation result Table 3.5-1: Comparison of experimentation and simulation results of 5V regulator Simulation Result Experimentation Result CRO reading Multi-meter reading Input 3.3V 3.2V 3.3V Output 5V 4.8 V 4.9V The input and output voltage obtained in simulation and experimentation is almost equal. Thus the input voltage of 3.3V obtained from PIR sensor is amplified to 5V. 3.6 Window Detector 3.6.1 Design Procedure We have, V× R3)+R2+(R1 R3 =VREF1 (3.6-1) V× R3)+R2+(R1 RR3 =V 2 REF2  (3.6-2) In the Figure 3.6-1, V=12V R1= R8=1K R2=R7=22K R3=R6= 10K Note: The values of R6, R7 and R8 are as given in simulation circuit diagram.
  • 65. Page | 63 Therefore, 3.67V12× 10)+22+(1 10 =VREF1  11.6V12× 10)+22+(1 2210 =VREF2   Figure 3.6-1: Design circuit for window detector
  • 66. Page | 64 3.6.2 Simulation and Result of window comparator  Circuit Diagram Figure 3.6-2: Circuit diagram for window comparator R15 1.082k V6 5Vdc R9 5K V7 12Vdc V8 12Vdc V9 12Vdc R13 4k R3 3.3k R4 5K Q2 2N2222A/ZTX R14 10k U1 uA741 + 3 - 2 V+ 7 V- 4 OUT 6 OS1 1 OS2 5 0 0 0 R7 22k R8 1k 0 U2B LM324 + 5 - 6 V+ 4 V- 11 OUT 7 U3B LM324 + 5 - 6 V+ 4 V- 11 OUT 7 R6 10k D1 D1N4148 D2 D1N4148 0 V10 3.3Vdc V V
  • 67. Page | 65  Case 1: When PIR sensor is activated Input to window comparator from the amplifier Figure 3.6-3: Output from the window comparator when PIR senor is activated When PIR sensor is activated, the input given to the window comparator is 5V, which is output from the amplifier. This 5V input is compared with the two reference voltages: lower limit (3.67V) and upper limit (11.6V). Output from the window comparator when PIR sensor is activated Figure 3.6-4: Output Waveform when PIR sensor is activated The input voltage to the comparator when PIR sensor is activated is 5V, which is an amplified result of 3.3V of PIR sensor output. This input voltage is compared with the upper and lower limits (Paul, Industrial Electronics And Control, 2009). As the input
  • 68. Page | 66 voltage is within the window, the upper comparator will be at negative saturation since its non-inverting input is negative (<11.6V). The lower comparator will also be at negative saturation and both the diodes become reverse biased and the output voltage is zero. As seen from Figure 3.6-4, the output is -131uV ( V0 )  Case 2: When PIR sensor is not activated Input to window comparator from the amplifier when PIR sensor is not activated Figure 3.6-5: Input waveform When the PIR sensor is idle that it does not detect any intruder, output then goes to zero. Therefore, the amplified output is also zero. Output from the window comparator when PIR sensor is idle Figure 3.6-6: Output from PIR sensor when it is idle (does not detects any intruder)
  • 69. Page | 67 When PIR sensor is idle, its output is zero. Since output of amplifier is zero, the lower comparator goes to positive saturation as its inverting input will be negative w.r.t. to its non-inverting input. This forward biases the diode D2, and the combined output will be positive saturation of nearby 3V. 3.6.3 Experimentation result of window comparator  Case 1: When PIR sensor is activated Input to window comparator when PIR sensor is activated Figure 3.6-7: Input to the window comparator when PIR sensor is activated When the PIR sensors activated, the input given to window comparator is found to be V5 . From the Figure 3.6-7, Volts/division = 2.00 V/div division = 2.3 div  Volts = 22.3 = 4.6 V V5 As discussed under case 1 of section 3.6-2, the output from the window comparator was found to be 0V.
  • 70. Page | 68  Output from the window comparator when PIR sensor is activated Figure 3.6-8: Output from the window comparator when PIR sensor is activated  Case 2: When PIR sensor is idle  Input to window comparator when PIR sensor is idle Figure 3.6-9: Output from the window comparator when PIR sensor is idle  Output from window comparator when PIR sensor is idle As discussed under case 2 of section 3.5-2, the output from the window comparator was found to be 3V.
  • 71. Page | 69 Figure 3.6-10: output from the window comparator when PIR sensor is idle 3.6.4 Comparison of simulation result and the experimentation result of window comparator  Case 1: When PIR is activated Table 3.6-1: When PIR sensor is activated Simulation Result Breadboard Result CRO reading Multi-meter reading Input 5V 4.7V 4.7V Output 131uV 0V 0V  Case 2: When PIR is idle Table 3.6-2: When PIR sensor is idle Simulation Result Breadboard Result CRO reading Multi-meter reading Input 0V 0V 0V Output 3V 3V 3V
  • 72. Page | 70 Thus we see that the result so obtained is in line with the expected results as discussed in section 3.6-2.
  • 73. Page | 71 Figure 3.6-11 Complete circuit diagram Here voltage supply is supplied directly from the voltage source and 3.3V represents the PIR sensor output. The regulators are designed in the previous sections and in real circuit we have used the regulators instead of the direct voltage source V6 5Vdc R9 5K V7 12Vdc V8 12Vdc U4 Relay _SPDT_b COM A B NC NO V9 12Vdc U5 LAMP HL R13 4k R3 3.3k Q2 2N2222A/ZTX R4 5K R14 10k U1 uA741 + 3 - 2 V+ 7 V- 4 OUT 6 OS1 1 OS2 5 V10 3.3 Vdc U6 Relay _SPDT_b COM A B NC NO 0 0 CAMERA 0 R7 22k R8 1k 0 U2B LM324 + 5 - 6 V+ 4 V- 11 OUT 7 U3B LM324 + 5 - 6 V+ 4 V- 11 OUT 7 R6 10k D1 D1N4148 D2 D1N4148 0
  • 74. Page | 72 3.7 Transistor as switch 3.7.1 Design Procedures of transistor as a switch Figure 3.7-1: Transistor used as a switch  Our relay uses 12V and will draw 11.7mA. Clearly this transistor will easily handle this.  The next step is to ensure to drive the transistor into saturation. We will do this by selecting the proper value for R1. The collector current will be the base current multiplied by the DC gain, hFE. The data sheet for a SL100 shows the hFE as a minimum of 25 under one set of circumstances, and a minimum of 40 and a maximum of 300 under other circumstances. The reality is that transistor parameters run all over the place. The simplest thing to do here is use the worst case value, or 25 in this case.  Changing the transistor gain equation around and using the 11.7mA relay coil current and SL100 hFE gives us: Ib = Ic/hFE = 11.7/25 = .468 mA For simplicity we will round up Ib to 0.5mA. Actually we will probably want to double it. Running Ib at 1mA or 2mA will not cause any damage and will give an extra margin to ensure the transistor is driven hard into saturation.  The voltage from comparator will supply 5V. There will be a voltage drop between the base and emitter VBE (sat). The data sheet shows this as 2V maximum with much higher base and collector currents that we will be using. In our circuit it will probably be in the 0.6V to 1.3V range. For simplicity we will use 1.3V. Since the voltages across the circuit loop must be 0V we have the following: Vs = VR1 + VBE (3.7-1) Solving for the voltage across R1, we get the following
  • 75. Page | 73 VR1 = Vs – VBE = 5V – 1.3V = 3.7V So, R1 will drop 3.7V with a current of 1mA. Ohm’s Law says R = V/I = 3.7/.001 = 3.7kΩ (approximately . 4kΩ) We will use a 4K resistor for R1, but we can use resistor between 1KΩ to 5KΩ.  The remaining component is R2, and may not be needed in some applications. When power is first applied to the circuit, you might get some current glitch through the transistor, turning it and the relay on momentarily. This might not be tolerable. Putting R2 in will help prevent the transistor from turning on by draining any charge out of the base of the transistor. 10K resistors are a typical value for this component.  We know we will have 12V from the supply to relay, and Vce (sat) is going to be around 1 volt. We know that the voltage across the transistor plus the voltage across the relay must be 12V. That means that the voltage across the relay must be Vc = Vrelay + Vce (sat) (3.7-2) Vrelay = Vc – Vce (sat) = 12 – 1.3 = 10.7V 3.1 Summary The hardware components to be used in the PIR Sensor Based Security System has been firstly studied theoretically and then designed, simulated in PSpice software and tested in breadboard to confirm the result before fabricating it in the prototype. It was found that the results from theoretical design, simulation and experimentation result were all in same range. Thus the designed was confirmed to proceed further with the design of prototype.
  • 76. Page | 74 SECTION C SOFTWARE
  • 77. Page | 75 CHAPTER 4: INTEGRATING OPENCV WITH MICROSOFT VISUAL C++ 2010 Objectives of chapter:  Introduce Microsoft Visual C++ 2010  Introduce OpenCV 2.4.4  Introduce different settings involved in integrating OpenCV 2.4.4 with Microsoft Visual C++ 2010  Introduce the coding techniques in Microsoft Visual C++ 2010
  • 78. Page | 76 4.1 Introduction We have developed a software program using Microsoft Visual C++ 2010 and OpenCV 2.4.4. OpenCV library files allows generic image/video loading, saving, and acquisition (team., 2013) which is the backbone of our program. C++ is regarded as a middle-level language, as it comprises a combination of both high-level and low-level language features. We have integrated the OpenCV library files in Microsoft Visual C++ 2010 for capturing, recording and video acquisition. This chapter gives brief introduction to Microsoft Visual C++ 2010 and OpenCV. We have illustrated the integration of OpenCV 2.4.4 in Microsoft Visual C++ 2010 and different OpenCV libraries we have used. 4.2 Microsoft Visual C++ 2010 4.2.1 Introduction Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft. It is used to develop console and graphical applications along with Windows Forms applications, web sites, web applications, and web services for all platforms supported by Microsoft Windows, Windows Mobile, .NET Framework and .NET Compact Framework (Anonymous, Tutorials Point). Visual Studio supports different programming languages by means of language services, which allow the code editor and debugger to support (to varying degrees) nearly any programming language, provided a language-specific service exists. Built-in languages include C/C++ (via Visual C++), VB.NET (via Visual Basic .NET), C# (via Visual C#), and F# (as of Visual Studio 201). Support for other languages such as M, Python, and Ruby among others is available via language services installed separately (Anon, Mathematics and Computer Science, South Dakota School of Mines and Technology, 2012). It also supports XML/XSLT, HTML/XHTML, JavaScript and CSS. Individual language- specific versions of Visual Studio also exist which provide more limited language services to the user: Microsoft Visual Basic, Visual J#, Visual C#, and Visual C++.Microsoft provides Express editions of its Visual Studio 2010 components Visual
  • 79. Page | 77 Basic, Visual C#, Visual C++, and Visual Web Developer at no cost (Anon, Mathematics and Computer Science, South Dakota School of Mines and Technology, 2012). The following operations using Microsoft Visual C++ 2010 Express Edition can be performed (Inc, 2010):  Starting a new project and entering code  Saving a project to disk  Compiling and executing a project  Closing a project  Opening an existing project  Creating a multi-file project  Removing files from a project  Adding example source files to a project  Determining where data files created by a program are located This project uses a C++ program. C++ is a computer language that is used to create applications. C++ is a statically typed, compiled, general purpose, case-sensitive, free- form programming language that supports procedural, object-oriented, and generic programming. C++ is regarded as a middle-level language, as it comprises a combination of both high-level and low-level language features. C++ was developed by Bjarne Stroustrup starting in 1979 at Bell Labs in Murray Hill, New Jersey as an enhancement to the C language and originally named C with Classes but later it was renamed C++ in 1983. C++ is a superset of C and that virtually any legal C program is a legal C++ program (Anonymous, Cplusplus.com- Instructions for use, 2000). 4.3 OpenCV 4.3.1 Introduction OpenCV (Free Open Source Computer Vision) is a library of programming functions mainly aimed at real time computer vision. It has a BSD license (free for commercial or research use). OpenCV was originally written in C but now has a full C++ interface and all new development is in C++. There is also a full Python interface to the library (Agam, 2007).
  • 80. Page | 78  General description  Open source computer vision library in C/C++.  Optimized and intended for real-time applications.  OS/hardware/window-manager independent.  Generic image/video loading, saving, and acquisition.  Both low and high level API.  Provides interface to Intel's Integrated Performance Primitives (IPP) with processor specific optimization (Intel processors).  Features:  Image data manipulation (allocation, release, copying, setting, conversion).  Image and video I/O (file and camera based input, image/video file output).  Matrix and vector manipulation and linear algebra routines (products, solvers, eigenvalues, SVD).  Various dynamic data structures (lists, queues, sets, trees, graphs).  Basic image processing (filtering, edge detection, corner detection, sampling and interpolation, colour conversion, morphological operations, histograms, image pyramids).  Structural analysis (connected components, contour processing, distance transform, various moments, template matching, Hough transform, polygonal approximation, line fitting, ellipse fitting, and Delaunay triangulation).  Camera calibration (finding and tracking calibration patterns, calibration, fundamental matrix estimation, homographic estimation, stereo correspondence).  Motion analysis (optical flow, motion segmentation, tracking).  Object recognition (Eigen-methods, HMM).  Basic GUI (display image/video, keyboard and mouse handling, scroll- bars).  Image labelling (line, conic, polygon, text drawing)  OpenCV modules:
  • 81. Page | 79 i. Core - a compact module defining basic data structures, including the dense multi-dimensional array Mat and basic functions used by all other modules. ii. Imgproc - an image processing module that includes linear and non-linear image filtering, geometrical image transformations (resize, affine and perspective warping, generic table-based remapping), colour space conversion, histograms, and so on. iii. Video - a video analysis module that includes motion estimation, background subtraction, and object tracking algorithms. iv. Calib3d - basic multiple-view geometry algorithms, single and stereo camera calibration, and object pose estimation, stereo correspondence algorithms, and elements of 3D reconstruction. v. Features2d - salient feature detectors, descriptors, and descriptor matchers. vi. Objdetect - detection of objects and instances of the predefined classes (for example, faces, eyes, mugs, people, cars, and so on). vii. Highgui - an easy-to-use interface to video capturing, image and video codecs, as well as simple UI capabilities viii. GPU- GPU-accelerated algorithms from different OpenCV modules. ix. Some other helper modules, such as FLANN and Google test wrappers, Python bindings, and others. 4.4 Integration of OpenCV 2.4.4 with Microsoft Visual C++ 2010 4.4.1 Environment Setting Integration of OpenCV 2.4.4 in Microsoft Visual C++ 2010 is performed in the following steps (Phillip, 2011). i. Open Control Panel → System → Advanced System Settings → Advanced Tab → Environment Variables. ii. On the System Variables section, select Path (1 as shown in Figure 4.4-1), Edit (2 as shown in Figure 4.4-1), and type C:opencvbuildx86vc10bin; (3 as shown in Figure 4.4-1), then click Ok.
  • 82. Page | 80 Figure 4.4-1 Environment variable setting to integrate OpenCV 2.4.4 in Microsoft Visual C++ 2010 iii. On some computers, it may need to restart computer for the system to recognize the environment path variables. This will complete the OpenCV 2.4.4 installation on computer. 4.4.2 Creating a new project and set up Visual C++ i. Open Visual C++ and select File → New → Project → Visual C++ → Empty Project. Give a name for your project (e.g.: webcam) and set the project location (e.g.: c:usersuserdocumentsvisual studio 2010Projects). ii. Click Ok. Visual C++ will create an empty project.
  • 83. Page | 81 Figure 4.4-2 Creating new project in Microsoft Visual C++ 2010 Figure 4.4-3 Empty project iii. Make sure that "Debug" is selected in the tool bar. Right click the “webcam” (your project that you have created, here we have created project as “webcam”) and select Properties → VC++ Directories. iv. Select Include Directories to add a new entry and type C:opencvbuildinclude.
  • 84. Page | 82 Figure 4.4-4 Property setting in Microsoft Visual C++ 2010 from integration of OpenCV 2.4.4 Figure 4.4-5 Including OpenCV 2.4.4 directories in Microsoft Visual C++ 2010 v. Click Ok to close the dialog. vi. Back to the Property dialog; select Library Directories to add a new entry and type C:opencvbuildx86vc10lib.
  • 85. Page | 83 Figure 4.4-6 To include OpenCV library in Microsoft Visual C++ 2010 vii. Click Ok to close the dialog. viii. Back to the property dialog, select Linker → Input → Additional Dependencies to add new entries. On the popup dialog box, type the files listed below. Each of these libraries is explained in later topic. opencv_core244.lib opencv_imgproc244.lib opencv_highgui244.lib opencv_ml244.lib opencv_video244.lib opencv_features2d244.lib opencv_calib3d244.lib opencv_objdetect244.lib opencv_contrib244.lib opencv_legacy244.lib opencv_flann244.lib Click Ok to close the dialog. Click Ok on the project properties dialog to save all settings.
  • 86. Page | 84 Figure 4.4-7 Integrating OpenCV 2.4.4 libraries in Microsoft Visual C++ 2010 These was the steps of setting up Visual C++, now is the time for coding. Right click your project and select Add → New Item → Visual C++ → C++ File. Figure 4.4-8 Creating new C++ file Name your file (e.g.: loadimg.cpp) and click Ok. Type the code in the editor
  • 87. Page | 85 4.5 Different libraries used from OpenCV A library is a collection of implementations of behaviour, written in terms of a language that has a well-defined interface by which the behaviour is invoked. Library code is organized in such a way that it can be used by multiple programs that have no connection to each other, while code that is part of a program is organized to only be used within that one program (Team O. , OpenCV Documentation, 2011). The distinguishing feature is that a library is organized for the purposes of being reused by independent programs or sub-programs, and the user only needs to know the interface. The following libraries are used in the program (Team O. , highgui. High-level GUI and Media I/O, 2011).  opencv_core244.lib: This is the basic building block of the library for understanding how to manipulate the images on a pixel level.  To store images in the memory and how to print out their content to the console.  How to scan images (go through each of the image pixels) with OpenCV.  To scan images with neighbour access and use the filter2D function to apply kernel filters on images.  to blend two images  Changing the contrast and brightness of an image  to draw simple geometry with OpenCV  draw some fancy-looking stuff  use the Discrete Fourier transformation  To use the File Storage data structure of OpenCV to write and read data to XML or YAML file format.  Interoperability with old versions of OpenCV  opencv_imgproc244.lib: This is for the image processing (manipulation) functions inside OpenCV  opencv_highgui244.lib: how to read/save your image/video files and how to use the built-in graphical user interface of the library.  opencv_ml244.lib: Use the powerful machine learning classes for statistical classification, regression and clustering of data.
  • 88. Page | 86  pencv_video244.lib: use on your video stream algorithms like: motion extraction, feature tracking and foreground extractions.  opencv_features2d244.lib: This is to use the feature point’s detectors, descriptors and matching framework found inside OpenCV.  opencv_calib3d244.lib: Although most of our images are in a 2D format they do come from a 3D world. This is use to find out from the 2D images information about the 3D world.  opencv_objdetect244.lib:detects peoples and faces  opencv_contrib244.lib: How to process images and video streams with a model of retina filter for details enhancement, spatio-temporal noise removal, luminance correction and spatio-temporal events detection.  opencv_legacy244.lib  Motion Analysis  Expectation Maximization  Histogram  Planar Subdivisions (C API)  Feature Detection and Description  Common Interfaces of Descriptor Extractors  Common Interfaces of Generic Descriptor Matchers  opencv_flann244.lib: It is used for Clustering and Search in Multi-Dimensional Spaces. This section documents OpenCV interface to the FLANN library. FLANN (Fast Library for Approximate Nearest Neighbours) is a library that contains a collection of algorithms optimized for fast nearest neighbour search in large datasets and for high dimensional features. 4.6 Summary In this chapter, step by step integration of OpenCV 2.4.4 with Microsoft Visual C++ 2010 has been discussed. The integration of OpenCV in Microsoft Visual Studio enables us to use all of its library files for different purposes. In development of the software for capturing and recording the video, we have used above mentioned libraries.
  • 89. Page | 87 CHAPTER 5: SOFTWARE PROGRAM Objectives of the chapter:  Outline the algorithm and flow chart of the core program  Introduce to the program used in designing the software  Present output of the program  Discuss the steps involved in creating executable file
  • 90. Page | 88 5.1 Introduction This chapter gives the coding techniques we have used to create the software. The program is based in Microsoft Visual C++ 2010 using different library file from OpenCV 2.4.4. The program will be able to capture and record the video when the webcam is ON. To keep the software machine independent, executable file will be created. The code will be tested as per the requirement. 5.2 General working of the program Our system is mainly for security purpose. So, when it detects human, the sensor turns on the webcam. The program should be able to detect that the webcam is turned ON and starts recording the video. When the sensor does not detect human, it turns OFF the webcam. When the webcam is turned OFF, program saves the recorded video. The program continuously checks whether the webcam is ON or not. If it is ON the above process is repeated. 5.2.1 Algorithm i. Start the program ii. Check whether the webcam is ON or not iii. If the webcam is ON, start recording the video until the webcam turns OFF iv. Save the video v. Continue to check if the webcam is ON vi. Then loop the process from iii to iv
  • 91. Page | 89 5.2.2 Flow Chart Figure 5.2-1 Flow chart for the program
  • 92. Page | 90 5.2.3 Program // PIRSensor.cpp : Defines the entry point for the console application. // DatenTime.cpp : Defines the entry point for the console application. #include "stdafx.h" #include <iostream> #include <opencv2/opencv.hpp> #include <opencv2/highgui/highgui.hpp> #include <time.h> #include <string> using namespace std; int main( int argc, char** argv ) { startcam: time_t now = time(0); // First Getting Current System Time struct tm tstruct; char buf[80]; tstruct = *localtime(&now); //Gets current local time strftime(buf, sizeof(buf), "PIR %d_%m_%Y %H_%M", &tstruct); //Copies the time in the format we want (PIR 30_03_2013 15_30) string GetTime=buf; // Character is given to string string TimeinString= GetTime.append(".avi"); //".avi" is appended to the date name (PIR 30_03_2013 15_30.avi) char* p = new char[TimeinString.length() + 1]; //String is converted back to character strcpy(p, TimeinString.c_str()); //Copies the character we want in the clipboard //Next Turning ON the camera and capturing the video in .avi format
  • 93. Page | 91 //The structure CvCapture does not have public interface and is used only as a parameter for video capturing functions. CvCapture* capture; //The function cvCreateCameraCapture allocates and initialized the CvCapture structure for reading a video stream from the camera. Currently two camera interfaces can be used on Windows: Video for Windows (VFW) and Matrox Imaging Library (MIL); and two on Linux: V4L and FireWire (IEEE1394). capture = cvCreateCameraCapture(0); //Checks whether the camera is turned ON or not and does job accordingly cout<<"n Checking Webcam.....n"; if (capture==NULL) { cout<<"nCamera Not Connectedn"; goto startcam; //If Camera is NOT turned ON the program goes to startcam point and checks again } else cout<<"nCamera Foundn"; assert( capture != NULL ); //The function cvQueryFrame grabs a frame from camera or video file, decompresses and returns it. This function is just a combination of cvGrabFrame and cvRetrieveFrame in one call. The returned image should not be released or modified by user. IplImage* bgr_frame = cvQueryFrame( capture ); //The function cvGetCaptureProperty retrieves the specified property of camera or video file. CvSize size = cvSize((int)cvGetCaptureProperty( capture,CV_CAP_PROP_FRAME_WIDTH),(int)cvGetCaptureProperty( capture,CV_CAP_PROP_FRAME_HEIGHT));
  • 94. Page | 92 //The function cvNamedWindow creates a window which can be used as a placeholder for images and trackbars. Created windows are reffered by their names. //If the window with such a name already exists, the function does nothing. cvNamedWindow( "Webcam", CV_WINDOW_AUTOSIZE ); cout<<"n Starting Webcam Window n"; //writes or saves the video/frames CvVideoWriter *writer = cvCreateVideoWriter(p,CV_FOURCC('D','I','V','X'),12,size); cout<<"n Saving the Video Frames n"; //loops the multiple frames while( (bgr_frame = cvQueryFrame( capture )) != NULL ) { cvWriteFrame(writer, bgr_frame ); //The function cvWriteFrame writes/appends one frame to video file. cvShowImage( "Webcam", bgr_frame ); //The function cvWaitKey waits for key event infinitely (delay<=0) or for "delay" milliseconds. Returns the code of the pressed key or -1 if no key were pressed until the specified timeout has elapsed. //Note: This function is the only method in HighGUI to fetch and handle events so it needs to be called periodically for normal event processing, unless HighGUI is used within some environment that takes care of event processing. char c = cvWaitKey(3); if( cvCreateCameraCapture(0)==NULL || c==27){ break;} } //The function cvReleaseVideoWriter finishes writing to video file and releases the structure cvReleaseVideoWriter( &writer );
  • 95. Page | 93 //The function cvReleaseCapture releases the CvCapture structure allocated by cvCreateFileCapture or cvCreateCameraCapture cvReleaseCapture( &capture ); //The function cvDestroyWindow destroys the window with a given name. cout<<"n Finishd Saving Video n"; cvDestroyWindow("Webcam"); goto startcam; return( 0 ); }
  • 96. Page | 94 5.2.4 Output of the Program 1. When program runs, it starts Checking for webcam, if webcam is found it start recording and saving videos. Figure 5.2-2 When program is starting 2. When webcam is disconnected, recording gets stopped and saves the records, while program continues to check for webcam. Figure 5.2-3 When webcam is not detected 3. When webcam is ON, it detects and continues to record and save the videos.
  • 97. Page | 95 Figure 5.2-4 When webcam is found 5.3 Creating Executable file (.exe) The executable file creation is required for the program to run independent of the Microsoft visual C++ and other dependent library files. Using the software (Microsoft Visual C++) and library files from OpenCV have following drawbacks (Team X. , 2007): 1. These software may not be available to all users 2. Requires lot of space and probably slows down the computer 3. All may not have enough knowledge to use these software or for easy use of program 4. Requires time for configurations and settings of software. Thus the use of executable file overcomes the above drawbacks. The steps of creating the executable file as follows: 1. First of all we need to create the project of the program we want. It is because we must run program in VC++ before creating the .exe file. 2. After successfully running the program now we have to create executable file. Firstly we go to Project >> (Your Project Name) Properties or you can press alt + F7, as shown in Figure 5.3-1:
  • 98. Page | 96 Figure 5.3-1Step for creating .exe file 3. There are two build configurations for C++ projects: Debug and Release. The procedure for creating an executable will depend on the configuration, which is Debug by default. Since it is the default, we have discussed how to create an executable file using the Debug configuration with the understanding that the Release configuration can be done similarly. Figure 5.3-2 Configuration Property setting for creating .exe file
  • 99. Page | 97 4. To see your current build configuration, left-click "Project" in the menu bar and left-click "Properties" in the submenu to open the "Properties Pages" dialog shown above. 5. Left-click "Configuration Properties" and you should see "Active (Debug)" in the box next to "Configuration:" in the upper-left corner of the dialog. This tells us that the active or current configuration is Debug 6. Next we want to eliminate our executable .dll file dependency so that we can run it on any other Windows machine, even if it does not have the .dll file that we are currently using. 7. To do above task, left-click the arrow next to "Configuration Properties" and then left-click the arrow next to "C/C++" to expand the lists below them. Then left-click "Code Generation" below this and left-click "Multi-threaded Debug DLL" next to "Runtime Library". 8. A drop-down arrow is found next to "Multi-threaded Debug DLL". Left-click the arrow to expand the list, and left-click "Multi-threaded Debug" in the list. Finally, commit the changes by left-clicking the "Apply" button and then the "OK" button 9. The executable can be created by left-clicking "Debug" in the menu-bar and "Build Solution" in the submenu or press F7. Figure 5.3-3 Creating executable .dll independent file
  • 100. Page | 98 Figure 5.3-4 Build .exe file of PIR Sensor 10. Now navigate to the solution folder for the current project. This is where the .sln file is found. There is "Debug" folder. Double-click the "Debug" folder to enter it and we see the executable file with the .exe extension. Double-click this file to run the program and we see window frame opened. Figure 5.3-5 Window for capturing the video 5.4 Summary The program was build based on Microsoft Visual C++ 2010 integrating OpenCV 2.4.4 libraries. OpenCV contains a stack of libraries that can be integrated with other programming languages.
  • 101. Page | 99 We have created the program as executable file, so that the program contains the package that can be interfaced with the hardware part of the PIR Sensor Based Security System. The executable file enables program to run independent of the Microsoft visual C++ and other dependent library files. It also enables user friendly software with conserved space and time unlike other software which requires large space and user with adequate knowledge for configurations and settings of software.
  • 102. Page | 100 SECTION D CHAPTER 6: DEMONSTRATION Objectives of the section:  To do the demonstration and testing of the PIR Sensor Based Security System that we have designed  Recording output shown.
  • 103. Page | 101 6.1 Introduction This chapter gives the practical demonstration of the PIR Sensor Based Security System. Practical testing was carried out in Electronics and Communication Lab with the project guide. Results of the demonstration will be reflected in the following pages. 6.2 Demonstrations As explained in the first chapter of the hardware components, the software will be kept running in the laptop or the computer checking if the webcam is connected or not. When an intruder comes in the detection range of the PIR sensor, an output of 3.3 volts will be generated and amplified using differential amplifier circuit. This output voltage is used for actuating the lighting system and the webcam. Once the software finds the webcam is connected, it will start recording the video captured by the webcam. When the intruder leaves the detection range of PIR sensor, the lighting system and webcam are turned OFF since there is no output from the PIR sensor. The software will stop recording and it will again start checking if the webcam is connected or not. If the intruder comes in the detection range of the PIR sensor process of recording and saving of video repeats Following Photograph show the actual working of the PIR sensor based system. When we start the program the program immediately starts to check for the webcam. As in the beginning the webcam won’t be ON so the program loops and checks for the webcam till the camera is ON as in Photograph 6.2-1.
  • 104. Page | 102 Photograph 6.2-1 When there is no intruder in the range of PIR sensor The lighting system will also be OFF. This shows that there is no intruder in the range.
  • 105. Page | 103 Photograph 6.2-2 Intruder has been detected As shown in the Photograph 6.2-2, the PIR sensor gets activated when it detects the intruder in its range and then turns ON the lighting system and webcam. Photograph 6.2-3 The webcam continuously records the scene when there is intruder in its range