Académique Documents
Professionnel Documents
Culture Documents
Abstract
Wireless Sensor Network has become one of the hot topics nowadays. Indeed, it
has been already applied in the use of many different areas. Such as the Home
Automation, it is very common to find its use on the lighting control and security
alarming. It does improve a lot on the people’s living quality with a more
convenient environment.
the Wireless Sensor Network has been carried out in this project. And the Study
In this report, it is going to illustrate the results of the studies mentioned above
Automation.
1
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
Acknowledgement
Besides that, I would also like to thank the technician of Microwave Laboratory,
Mr. Leo Fung, for his help on ordering the RF kit for the project in the previous
semester.
Moreover, I would like to thank my fellow classmates Mr. Tang Kwok Kai and Mr.
Hui Cheung Ling for giving me advice and technical supports on building the
PCB Layouts. Finally, I would like to thank all the fellow classmates those who
work with me in the laboratory throughout the days and nights in these few
2
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
Contents
1. Introduction…………………………….…………………………………………. 6
3
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
4
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
7. References ……………………………..........…………………………….……. 63
5
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
1. Introduction
Have you ever dreamt of living in a Smart Environment, which it enhances your
living qualities with all kinds of intelligent automation devices or services? If “Yes”,
then your next question will surely be “How can we get it to be realized?” To
answer this question, very strict forward, I would say that the application of
In fact, like any responsive organism, the Smart Environment [1] relies first on
the sensory data from the actual world. Sensory data are obtained from
Network has exactly taken this sensing role to fulfill the needs of information for
this purpose. It acts as the first stage to realize the development of Smart
Environment. So, your following question will be “What the Wireless Sensor
6
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
Figure.1
Have you ever imagined thousands of sensors are installed in a specified area
and they are all well coordinated in a network without the data transmission jam?
Indeed, it is the exact case for Wireless Sensor Network. These sensors of
different modalities detect the physical changes, like temperature, humidity and
light intensity, and generate corresponding data signal. The data are then sent,
through the network, to the coordinator for processing. The coordinator manages
and controls the sensing data flow in the communication network. Therefore, the
7
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
Actually, Wireless Sensor Network has already been widely used in different
1 Habitat monitoring: such as the monitoring of water/ air pollution and the
2 Military use: like the monitoring the actual battle condition by installing the
3 Biomedical use: such as collecting the physiological data from human body
or medical diagnosis.
manufacturing production.
8
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
3. Coordinator processes the received data and identifies if matched with the
4. If the criteria are matched, for instance, a body presence in the area,
coordinator will send command to the lighting control unit to switch light on.
5. On the other hand, if nobody presence in the area for a period of time,
coordinator will send command to the lighting control unit to switch light off
Therefore, the system can perform a lighting control function where the light on
whenever anybody presence, while the light off if nobody presence for a period
9
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
There are three main components in the system to build the application of
which are:
sensing data ready for the coordinator to process and further application.
and monitor the data transmission in between devices of the system. It also
processes the received sensing data from the sensing unit and, regarding to
There should also be the lighting control unit, the application use, in the system.
However, it is not yet built up to the current development stage and may be built
10
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
2. Background Theory
Before going into any details of the system design, some background principles
section.
current market, such as Bluetooth, Wi-Fi, which are the most common ones.
However, are they suitable for building the communication network of Wireless
Sensor Network? There are indeed some specific requirements for the wireless
sensor network. Let’s consider the following factors first and see if the mentioned
11
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
2. Energy Consumption [3]: The battery of the sensor node (sensing units)
3. Simplicity[3]: As the sensor nodes (sensing units) are small and power
With the factors mentioned above, let’s consider the comparison of current
Figure.2
12
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
It is observed that neither the Bluetooth nor Wi-Fi would be suitable to be used in
Wireless Sensor Network. Comparing with the Zigbee standard in the above
simplicity, they are far worse than that of the Zigbee standard. Indeed, the
Occupancy sensor [4] is a device that responds to the presence and absence of
anybody in the sensor's field of view. The system consists of a motion detector,
an electronic control unit, and a controllable switch, where, in the system, there
switch. The motion detector senses motion and sends the appropriate signal to
the control unit. The control unit then processes the input signal and output a
13
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
In today’s markets, there are two commonly used methods / approaches for the
operation of Occupancy Sensor. They are the Passive Infrared sensing method
and the Ultrasonic wave detection method. This project will focus on the Passive
Passive infrared (PIR) sensors [6] react to the infrared heat energy emitted by
the human body. PIR sensors are passive devices in that they only detect
radiation and do not emit it. They are designed to be maximally sensitive to
objects which emit heat energy at a wavelength of around 10 microns (the peak
PIR sensors are strictly line-of-sight devices. They cannot "see" around corners
14
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
PIR sensors employ a pyroelectric transducer [6] to detect infrared radiation. The
device converts the IR energy into a voltage signal. (See the figure below)
Figure.3
1. An infrared filter window at the front most position of the transducer admits IR
which is grounded.
3 Meanwhile, the other end connects to the gate of a Field Effect Transistor
5 Output signal comes from FET source pin 2 usually connects through an
figure)
15
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
Figure.4
A Fresnel lens, a focusing device, surrounds the transducer and focuses heat
energy onto the detector. The lens views the area with a multitude of narrow and
discrete beams or cones. As such, it does not view the area in a continuous
fashion. As an occupant, moves a hand, arm, or the whole body from one cone
Figure.5
16
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
The detection pattern [5] of PIR sensors is fan shaped -- formed by the cones of
Figure.6
As shown in above figure, coverage gaps occur between the cones of vision of
alternate segments of the lens. These gaps widen with distance. At 40 feet from
the sensor, for instance, coverage gaps of up to 8 feet wide may be present.
Since the sensor is most sensitive to motion that moves from one sensing cone
to another, its sensitivity decreases with distance as the gaps between sensing
cones widen.
17
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
feet, arm and upper torso movement up to 20 feet, and full body movement up to
about 40 feet.
Regarding to the above data, it is surprising that the sensing range of that little
PIR sensor can be so large. Because of this reason, the PIR sensor is used to
area. Thus, a large area can be restricted to be our specified sensing region as
18
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
3. Paper Design
built up of basically the transmitting unit and receiving unit. Undoubtedly, it is the
same for the system in this project. For Simplicity, there will be two transmitters
(for sensor node) and one receiver (for coordinator node) in the Sensor Network
of this project.
communication network.
Combining with the circuitry of Sensing unit, it acts as the sensor node of the
Sensor Network. It is responsible to transmit data from the sensing unit (motion
detector) to the coordinator for process. The Unit is mainly composed of several
19
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
Figure.7
20
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
following descriptions:
The pin PIR_sense is connected to the output terminal of the circuitry of the
Motion Detector sensing unit. When this pin goes to “low”, it means that there is
an output, motion detected, from the sensing unit and vice versa.
21
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
The microprocessor then counts the time for how long the “motion detected”
state keeps continuously. The status is defined as valid if the time lasted for
more than at least 1 second and invalid if vice versa. This decision making aims
The pin RF_Control is connected to the above circuitry in order to control the
power on/off of the RF Transmitting module. When this pin goes “high”, the
transistor BC547 is turned on and current flow through the transistor. The
Thus, the potential at the point of RF_Power connected to the power supply of
the Transmitting unit will be low. It means to switch off the transmitting unit.
On the other hand, when this pin goes “low”, the transistor BC547 is turned off
and no current flow through the transistor. The collector voltage then equals to
22
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
that of VCC (+5V). Thus, the potential at the point of RF_Power connected to the
power supply of transmitting module is high and turn on the transmitting module.
Therefore, power can be saved for long running of the sensor node. As the
transmitter is turned on only when there is motion detected and is not always
kept as on. It builds the property of power conservation as the consideration for a
The pins RC0 – RC3 are connected to the data input pins RF13 – RF10 of
output when the state is changed to “motion detected” only. And this data will
microprocessor is thus the unit to give the according instruction data to the LCD
23
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
address pins and data from microprocessor into a serial coded waveform
tri-state address pins providing up to 531,441 (or 312) address codes; thereby,
largely reducing any code collision and unauthorized code scanning possibilities
Figure.8
24
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
Figure.9
“0” or “1”.
25
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
PT2262 encodes the code address and data set at A0 ~ A7 and D3 ~ D0 into a
special waveform and outputs it to the DOUT when /TE is pulled to “0” (Low
State). This waveform is fed to the RF modulator for transmission. Details of the
- 1. Code Bits
A Code Bit is the basic component of the encoded waveform, and can be
An AD Bit can be designated as Bit “0”, “1” or “f” if it is in low, high or floating
state respectively. One bit waveform consists of 2 pulse cycles. Each pulse cycle
Figure.10
26
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
The Synchronous Bit Waveform is 4 bits long with 1/8 bit width pulse.
Figure.11
- 2. Code Word
A group of Code Bits is called a Code Word. A Code Word consists of 12 AD bits
When Data Type of PT2262 is used, the address bits will decrease accordingly.
For example: In the 3 Data Type where the address has 9 bits, the transmitting
format is:
Figure.12
PT2262 has a maximum of twelve (12) Address Bits including the six (6)
Address/Data bits, the code bits with their corresponding pins are as shown in
27
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
Figure.13
The Code Bits A0 ~ A5 and A6/D5 ~ A11/D0 are determined by the states of A0
~ A5 and A6/D5 ~ A11/D0 pins. For example, when the A0 (Pin No. 1) is set to
“1” (Vcc), the Code Bit A0 is synthesized as “1” bit. In the same manner, when it
(A0 Pin) is set to “0” (Vss) or left floating, the Code Bit A0 is synthesized as a “0”
- 3. Code Frame
A Code Frame consists of four continuous Code Words. When PT2262 detects
“0” on the /TE (the /TE is active “low”), it outputs a Code Frame at DOUT.
Figure.14
If /TE is still active at the time the Code Frame transmission ends, PT2262
outputs another Code Frame. It should be noted that the Code Frame is
28
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
The unit is just used for displaying the current status of the motion detector after
the data processing by the microprocessor. Without the LCD Display, the main
function of data transmission can actually still be carried out. Thus, the LCD
data transmitted from the sensor node (transmitting unit), then processes the
acknowledgement and displays the result accordingly from the receiving data.
Receiving Module and a LCD display. (See the following Schematic Diagram)
29
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
Figure.15
30
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
descriptions:
messages. It gives a positive response if the checking is matched and does not
31
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
When there is positive response, the microprocessor displays the result on the
LCD by giving corresponding instruction data to the LCD module. For example, it
has 12 bits of tri-state address pins providing a maximum of 531,441 (or 312)
address codes; thereby, reducing any code collision and unauthorized code
decode the waveform and set the corresponding output pin(s). (See the internal
32
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
Figure.16
Figure.17
“0” or “1”.
33
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
VT O Valid Transmission. 17
PT2272 decodes the received waveform fed into the DIN pin. The Waveform is
decoded into code word which contains the address, data and sync bits. The
decoded address bits are compared with the address set at the address input
pins (A0 - A7). If both addresses match for 2 consecutive code words, PT2272
then drives – (1) the data output pin(s) whose corresponding data bit(s) is then
decoded to be a “1” & “0” bit, and (2) the VT output to high voltage (high state).
- 1. Code Bits
A Code Bit is the basic component of the encoded waveform, and can be
34
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
An AD Bit can be designated as Bit “0”, “1” or “f”, if it is in low, high or floating
state respectively. One bit waveform consists of 2 pulse cycles. Each pulse cycle
Figure.18
The Synchronous Bit Waveform is 4 bits long with 1/8 bit width pulse.
Figure.19
- 4. Code Word
A group of Code Bits is called a Code Word. A Code Word consists of 12 AD bits
35
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
When PT2272 receives a transmission code word, it initially checks whether this
Code Word, and (2) the Address Bits must match the Address Setting at the
Address Pins.
After two consecutive valid transmissions, PT2272 (1) drives the data pins
according to the data bits received, and (2) raises VT to high voltage (high state).
Figure.20
36
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
Regarding to the instruction data from the microprocessor, the LCD module
the ASCII chart. It means that all characters are displayed according to what
After all, whenever there are anybody present in a specified area, the motion
detector will be able to detect its motion. It gives out a sensing signal “motion
detected” (bit “0”) to the transmitting unit at its output terminal. The transmitting
unit then gets the signal from its PIR_sense pin and processes. It outputs the
37
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
PT2272 then validates and decodes the data if it is valid. As soon as the
decoded data arrives at the microprocessor, the corresponding output result will
be displayed on the LCD after processing. And the user current status of the
Sensor node (transmitting unit) can be viewed at the Coordinator (receiving unit)
finally.
3.1.4 Remarks
However, the lighting control unit has not yet been developed. And the
any control signal neither to the sensor node nor any control units yet. The
In the future development, apart from the construction of light control system, the
38
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
Sensor consists of three main components, which are the sensing unit, control
unit and the output unit. In the design of the PIR Movement Sensor of this
system, it is also the same case as that of the normal Occupancy Sensor. A PIR
sensor (RE200B) is chosen to be the sensing unit, a Master PIR Control Chip
MPCC (KC788B) is selected for control unit, while an output terminal will act as
It is in a package of T0-5 with dimension shown in the figure. There are two
sensitive elements with area of 2.0mm long, 1.0mm wide and are spaced in
Figure.21 Figure.22
39
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
around 2.5 Vp-p. For the field of view detected by the sensor, it is shown as
below:
Figure.23
The chip has been designed for easy implementation of AC control functions that
use a Passive Infra-Red (PIR) motion detector. Due to its high sensitivity and
Figure.24
With most of the necessary components integrated in the chip, it allows the
minimum external components. It has high sensitivity and an off delay timer.
40
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
Figure.25 The above diagram shows the internal block structure of the chip.
41
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
42
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
43
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
44
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
The heart of the circuit is the motion detection IC. Electrical signals from the PIR
sensor have a very low frequency (0.1 to 10Hz) and bandwidth. The IC is
optimized for this. The operating voltage of the KC778B itself is 4 - 15V. With the
78L05 regulator, voltage input should be in the 9V to 12V range. There are three
sensitivity controls built into the original circuit. (See the original schematic
When this pin equals the sensor drain potential at pin 7 (about 0.5V) sensitivity is
sensitivity is at maximum.
This is adopted when the sensor is designed to be inactive during the daytime
and only active at night. If this feature is not needed, the pin 12 should be
This adjusts the output pulse from between 1.5 seconds upwards. For the
minimum time delay, pins 18 & 19 are connected directly with no external
capacitor or resistor.
45
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
However, only two controls will be used after modification. They are the trimpot
P1 for Sensitivity adjustment and trimpot P3 for Pulse on-time adjustment. At the
meantime, the pin 12 is connected to Vcc and pin 11 is left unconnected. (See
Pin 17 is also connected to an LED, LED1. This IC output always goes on when
the sensor & IC detect movement. But this trigger may result in an Output signal.
For example, the Output from the unit is off during the Daytime. There is also an
inbuilt latency period of about 1.5 seconds in the Output pulse when triggered.
This latency period is essential to smooth out the multiple trigger pulses actually
sensed by the detector (as shown by LED1.) There is an internal 500R resistor
The output signal from IC pin16 goes “high” whenever movement is detected. It
switches on the BC547 and current flow through the transistor. Its collector is
Besides, it gives “low” to the OUTPUT in the modified circuit. And this signal will
46
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
Resistors: Quantity
1K brown black red R8 R9 R10 3
3K9 orange white red R3 1
10K brown black orange R2 R5 R7 1
47K yellow violet orange R1 R6 1
56K green blue orange R4 1
Potentiometers
200K Koa trimpot 204 P1 1
1M Koa trimpot 105 P3 1
Capacitors
10uF mini elcap C3 1
10uF Low leakage elcap C5 1
100uF mini elcap C1 1
100nF 104 C2 C4 C6 C8 4
220pF ceramic 221 C7 1
4n7 ceramic 472 C9 1
470nF C10
Control Unit IC
KC778B Movement IC1 1
Transistors
BC547 transistor Q1 1
Voltage Regulator
78L05 IC2 1
1N4004 diode D1
Output Units
LED 1
Sensors
RE200B PIR sensor 1
Light Dependent Resistor LDR
Fresnel Lens 1
47
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
4. Experimental Results
the receiving unit as what has been discussed in previous sections. Following
Without the RF Transmitting Module being placed, the Unit just consists of the
Figure 29
48
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
The unit then performs like a Detector with a Display showing its current status
Figure 30
Figure 31
Remarks: The display “I AM HERE” means that there are motions detected in
the specified area; the display “NOT HERE” means that there are any motions
49
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
With the RF Transmitting Module being installed, the Unit then consists of the RF
Transmitter, certainly, the PIR motion detector, the microprocessor and the LCD
Display Module
Figure 32
The unit is expected to perform as what has been stated in the “Paper Design”
section previously. It means that LCD displays the current status of whether any
motions are detected accordingly. At the mean time, the transmitter sends out an
acknowledgement signal.
kept showing on the LCD Display no matter there is motion nearby or not
50
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
As stated before in the previous description, the Receiving unit consists of the
Figure 33
At the same time, the transmitting unit is functioning in order to send out
the performance of transmitting unit is not as stable as expected, the tests can
still be regarded as valid. There are still acknowledgement data sent by the
transmitting unit depart its instability. Besides that, the receiving unit just displays
the result when there is acknowledgement received. The test can be carried out.
51
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
Figure 34
Figure 35
52
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
4. Experimental Results
The figure below shows the built PIR Movement Detector Circuit Board. It is built
Figure.36
The PIR detector will be undergone a testing with same approaches, but three
different environment. The aim of this testing is to observe how far the detector is
able to detect the motion, i.e. the detection range. After that, comparing the
testing result to the general detection range of the common PIR detector on
53
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
Testing Method: Moving away from sensor till the point where the movement
cannot be sensed
Hostel Corridor
PIR Sensor
Length
. Figure.37
Width
54
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
Testing Place: SHB 6th Floor Reading Area (Large Indoor Room)
Testing Method: Moving away from sensor till the point where the movement
cannot be sensed
PIR Sensor
Length
Width
Figure.38
55
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
Testing Place: Open Area at Hostel Ground Floor (Wild Open Area)
Testing Method: Moving away from sensor till the point where the movement
cannot be sensed
Figure.39
56
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
Measurement (60cm per square on the floor) (60cm per square on the floor)
21 x square 3 x square
Full body Movement
= 12.6 m = 1.8 m
Upper Half Body 12 x square 3 x square
Movement = 6.8 m = 1.8 m
48 x square 46 x square
Full body Movement
= 13.4 m = 12.88 m
Testing Result from case 3 at the Open area of Hostel Ground floor
57
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
5. Cost Summary
The estimated cost of the system for demonstration purpose is listed below
tables, where it is mainly separated into two parts; the hardware for Wireless
Microprocessor x 3 HK$60
Transmitting module x 2
HK$40
Receiving module x 1
58
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
6. Discussion
When testing the Wireless Communication and the PIR Movement Detector
module with the Movement Detector on a circuit board together with their original
Problem encounter
After merging the wireless communication modules and the PIR movement
detector, the performance should be as expected as what has been stated in the
previous “Paper Design” section. It means that the sensor node would give the
“motion detected” signal only if there are any body motions being sensed as in
the design. Unfortunately, the actual result is that the detector gives out such
sensing signals abnormally. It gives the “motion detected” signal even there are
The reason for this abnormal performance is actually because the ground
potential connected to the circuitry has become unstable after the wireless
59
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
communication module is merged with the motion detection circuit. And the
instability of overall ground potential is due to the long wired “ground” connection
between ports and the ground terminal. In the long connected wire, the RF signal
generated from the wireless module will impose some unwanted parasitic
potential along the wire connected. It then affects the original ground connection
on the ports in which the ground connection is no longer at ground potential (0V),
but an unknown potential imposed by the parasitic effect of the wired connection.
To solve the encounter problem, one possible solution is using a ground plane
for ground connection instead of using a wire connecting in between the port and
the ground terminal. It can greatly reduce the distance of connection in between
the ground terminal and the ports. The ground potential (0V) can then be kept
is also a usual practice of using ground plane for ground connection instead of
wiring between ports and the ground terminal for building any RF circuitry. As
shorter the ground connection it is, lesser the parasitic effect on ground potential
it imposes.
60
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
In the system, those two transmitting units are the only ones which are able to
talk/send out data to the other parties; but it cannot listen to/get the data from
others. Meanwhile, the receiving unit is the only one which is able to listen to/get
the data from other parties; but it cannot talk/send out data to others. It limits the
nodes and request for those their current status at any time. It can just wait till
the two-way communication between them, the network should no longer use
the pair of transmitting and receiving units. Instead, it should adopt the
can act both the functions of transmitting and receiving in a single module. The
coordinator can, thereby, be able to take control on the sensor nodes at any time
it requests. The current status update of sensor nodes can then be done more
61
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
After the testing in three different situations, it is observed that the detection
range of the built sensor is about 12m long which is about 40ft by calculation.
And this data does match to the previous mentioned range (40ft) for full body
However, there is a big drawback for our PIR Movement Detector. It is the
problem of line of view. Whenever there is obstacle in between, then the sensor
cannot sense the moving body. Beside that, it cannot sense the body at round
corner. To solve this problem, there can be a mixed use with ultrasonic wave
detection method. As this method is less dependent to the line of view, thus it is
62
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
7. References
[3] – Holger Karl and Andreas Willig. “A short survey of wireless sensor
October 2003.
63
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
#include <pic.h>
#include <stdio.h>
//////////////////////////////////////////////////////////////////////////////////////////////////
// File Name: LCD.h
// Description: It extern LCD Control functions in LCD.c
/////////////////////////////////////////////////////////////////////////////////////////////////
#include <pic.h>
#include <stdio.h>
65
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
/////////////////////////////////////////////////////////////////////////////////////////
// File Name: receive.c
// Description: It coordinates the whole process
/////////////////////////////////////////////////////////////////////////////////////////
#include "receive.h"
#include "LCD.h"
void main(void)
{
unsigned char result=0;
unsigned int stop_count;
InitPIC();
InitLCD();
clear();
pos_select(0);
lcd_puts("Node0:");
pos_select(2);
lcd_puts("Node1:");
ADR0 = 0;//Address0
while(1)
{
if (ADR0==0)
{
////////////////////////////////
//Node0 Process
////////////////////////////////
result=temp;
switch (result)
{
66
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
case 0:
pos_select(1);
lcd_puts("NOT HERE ");
count1=0;
//stop_count=10000;
while (count1<10000);
break;
case 10:
pos_select(1);
lcd_puts("I AM HERE");
count1=0;
//stop_count=50000;
while (count1<50000)
{
if (temp==10)
count1=0;
}
break;
default:
pos_select(1);
lcd_puts("I DUNNO ");
count1=0;
//stop_count=50000;
while (count1<10000);
break;
}
else if (ADR0==1)
{
///////////////////////////////////
//Node1 Process
////////////////////////////////////
result=temp1;
67
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
switch (result)
{
case 0:
pos_select(3);
lcd_puts("NOT HERE ");
count1=0;
while (count1<10000);
break;
case 10:
pos_select(3);
lcd_puts("I AM HERE");
count1=0;
while (count1<50000)
{
if (temp1==10)
count1=0;
}
break;
default:
pos_select(3);
lcd_puts("I DUNNO ");
count1=0; while (count1<10000);
break;
}
}
if ((Sel0==1)&&(Sel1==0))
ADR0=0;
else if ((Sel0==0)&&(Sel1==1))
ADR0=1;
else
ADR0=0;
}
}
68
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// File Name: LCD.c
// Description: It declares functions to control LCD display
////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "receive.h"
void clear(void)
{
///////////////////////////
//Clear Display
////////////////////////////
LCD_EN = 1;
LCD_RS = 0;
LCD_RW = 0;
PORTD = 0x01;
count=0;
while (count<100);//wait>=1.53ms for execution
LCD_EN = 0;
}
LCD_EN = 1;
LCD_RS = 0;
LCD_RW = 0;
PORTD = 0x80;//Upper Leftmost position
count=0;
while (count<50);//wait>=39us for execution
LCD_EN = 0;
break;
69
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
LCD_EN = 1;
LCD_RS = 0;
LCD_RW = 0;
PORTD = 0x87; //Lower Leftmost position
count = 0;
while (count<50);//wait>=39us for execution
LCD_EN = 0;
break;
LCD_EN = 1;
LCD_RS = 0;
LCD_RW = 0;
PORTD = 0xC0;//Lower Leftmost position
count=0;
while (count<50);//wait>=39us for execution
LCD_EN = 0;
break;
LCD_EN = 1;
LCD_RS = 0;
LCD_RW = 0;
PORTD = 0xC7;//Lower Leftmost position
count=0;
while (count<50);//wait>=39us for execution
LCD_EN = 0;
break;
}
70
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
LCD_RS = 1;
LCD_RW = 0;
LCD_EN = 1;
PORTD = *s;
count = 0;
while (count<10);//wait>=39us for execution
LCD_EN = 0;
*s++;//Jump to Next Character
}
}
void InitLCD(void)
{
while (count<1000);//wait>=30ms for power up
////////////////////////////
//Initialize Function Set
////////////////////////////
LCD_EN = 1;
LCD_RS = 0;
LCD_RW = 0;
PORTD = 0x38;
//PORTD = 0x38;
count = 0;
while (count<10);//wait>=39us for execution
LCD_EN = 0;
/////////////////////////////
//Display ON/OFF Control
/////////////////////////////
LCD_EN = 1;
LCD_RS = 0;
71
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
LCD_RW = 0;
//PORTB = 0x0C;//0x0F;
PORTD = 0x0C;
count = 0;
while (count<10);//wait>=39us for execution
LCD_EN = 0;
//////////////////////////////
//Display Clear
//////////////////////////////
LCD_EN = 1;
LCD_RS = 0;
LCD_RW = 0;
//PORTB = 0x01;
PORTD = 0x01;
count=0;
while (count<100);//wait>=1.53ms for execution
LCD_EN = 0;
///////////////////////////
//Entry Mode Set
///////////////////////////
LCD_EN = 1;
LCD_RS = 0;
LCD_RW = 0;
//PORTB = 0x07;
PORTD = 0x07;
count=0;
while (count<10);//wait>=39us for execution
LCD_EN = 0;
72
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// File Name: isr.c
// Description: It acts as timer counter and checks received data input
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "receive.h"
// TIMER0
if (T0IF)
{
if (ADR0==0)
temp = PORTC&0b00001111;
else if (ADR0==1)
temp1 = PORTC&0b00001111;
count++;
count1++;
TMR0=0x29;//interrupt at 50us
T0IF=0;
}
73
ERG4910B - Thesis II (2006-2007) Wireless Sensor Network
///////////////////////////////////////////////////////////////////////////////////////////////
// File Name: init.c
// Description: It initializes all the ports and registers
///////////////////////////////////////////////////////////////////////////////////////////////
#include "receive.h"
void InitPIC(void)
{
///////////////////////////////////
// A/D & I/O PIN SELECT
///////////////////////////////////
ADCON1 = 0b00001110; //ALL PINS are Digital pins
///////////////////////////////////
// PORTS
///////////////////////////////////
TRISA = 0b00000101;
TRISC = 0x1F;
TRISD = 0x00;
TRISE = 0x00;
///////////////////////////////////
// Interrupt Init
///////////////////////////////////
PIE1 = 0X00;
PIR1 = 0x00;
PEIE = 1; //enable PERI interrupt
GIE = 1; //enable ALL interrupt
///////////////////////////////////
// TMR0 Init
///////////////////////////////////
T0CS = 0; //follow CLK
T0IF = 0; //CLR TMR0 FLAG
T0IE = 1; //enable TMR0 interrupt
TMR0 = 0x29;//initial tmr0
74