Wireless Sensor Network

Author: Law Che Hang Anthony Student I.D.: 03645542 Supervisor: Professor K.K. Cheng Associate Examiner: Professor K.N. Leung

A project report presented to the Chinese University of Hong Kong in partial fulfillment of the Degree of Bachelor of Engineering

Department of Electronic Engineering The Chinese University of Hong Kong April 2007

ERG4910B - Thesis II (2006-2007)

Wireless Sensor Network

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.

In order to understand how this “Smart Innovative Technology” works, a study of the Wireless Sensor Network has been carried out in this project. And the Study is divided into two main parts, which are: 1. The Study on a Wireless Communication Network: To understand how a wireless communication network works. A communication method of using a pair of simple transmitter and receiver is to be studied and built. 2. The Study on Sensor: To understand how a sensor functions. An Occupancy Sensor (PIR Movement Sensor) is built and on studying in this project.

In this report, it is going to illustrate the results of the studies mentioned above and to suggest a simple application of the Wireless Sensor Networks on Home Automation.

1

ERG4910B - Thesis II (2006-2007)

Wireless Sensor Network

Acknowledgement
I would like to take this opportunity to sincerely show my gratitude to my supervisor, Prof. K.K. Cheng, Department of Electronic Engineering, for giving me guidance and support. He has given me valuable suggestions on the development of my system in this project.

Also, I would like to thank my project associate examiner, Prof K N Leung, Department of Electronic Engineering, for assessing my project.

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 months for their spiritual supports.

2

6 1.. 11 2..3.1 What is Wireless Sensor Network? ………………………………………......ERG4910B .........Thesis II (2006-2007) Wireless Sensor Network Contents 1.4 How passive infrared sensing works? …………………………………….1.……..2 Where Wireless Sensor Network can be found? …………………………….....8 1.11 2.7 1....1 Living in Smart Environment …………………………………………………..1.. Introduction……………………………...6 1......2.11 2. Background Theory …………………………………………………………...1.1 What should be considered?....9 1.....2 Method of Operation …………………………………………………………14 2.2..13 2..1......3 What is passive infrared sensing? …………………………………………14 2.2...10 2....1 What is Occupancy Sensor? …………………………………………………13 2..15 3 .1 Brief Introduction of the System ……………………………………………….6 1...2 What should be adopted? ………………………………………………….3 Specification of the System Design …………………………………………….1 Wireless Communication Network …………………………………………….…........2..9 1...2 Occupancy Sensor ………………………………………………………………13 2. 6 1.2 Realization of Smart Environment ……………………………………….1..…………………………………………..3 Wireless Sensor Network actually is ………………………………………......3.....2 Brief Descriptions of System Components ………………………………..

Thesis II (2006-2007) Wireless Sensor Network 3.2 Component 2 – RF Receiving module………………………………... Paper Design ………………….1 Component 1 – Microprocessor ….………………………………………… 21 3...1......1..2 Receiving Unit (Coordinator)………………………………………………… 29 3.1 Component 2 – RF Transmitting module …………………………...2.....…………………………………… 31 3..…..……… 37 3..... 37 3....ERG4910B ...1..1 Transmitting Unit (Sensor Node) ……….1.….………………………………….2 Component 3 – LCD Display module .1 Wireless Communication ………………....1..2 Component 1 – Microprocessor ….2.. 19 3.....….1... 47 4 ..2...40 3.4 Required Components for Modified Circuit……………………………...…………………………………….... 19 3..………… 39 3... 24 3. 38 3... 32 3....………………………………….45 3.. 29 3...2 PIR Movement Sensor……………………………………………….....1 Component 3 – LCD Display (optional)…………………………….2... ……………………………………..3 Whole Implementation ……………………………..... ……………….………...4 Remarks ………………………………....…….2 Control Unit (KC788B) ……………………………………………………….1 PIR sensor (RE200B)………………………………………………………… 39 3..1.……….....1.1.3 Control and Output Circuit Description …………………………………….1... 19 3...

.48 4.................………………………. 48 4...Thesis II (2006-2007) Wireless Sensor Network 4.... 54 4....... 62 7.…… 57 5..…..…………………….............2 Testing the PIR Movement Sensor …………………………………………… 53 4...... Cost Summary …. Discussion …………………. 59 6....2 Testing Case 2 with Daylight ..........1 Testing with Wireless Communication ……………….48 4.. 55 4.........1 Testing on Transmitting Unit ….. 59 6.........1...3 Testing Case 3 at Night ………………………….1.…......………………………… 56 4..........…………………………………………….……………….4 Testing Results form the previous 3 situation ………………………....2 PIR Movement Detector ……………………………………………………….1 Wireless Communication ....………………………………………...……………………………......2..2 Testing on Receiving Unit …………………………………………………...2..... 51 4.2... 63 8.. ……………………………....... Appendices – Software Coding ……………………………………………… 64 5 ......….............2.……...........1 Testing Case 1 with Daylight ………...ERG4910B ..………………………………………… 58 6. Experimental Results …………………………………………………………... References ……………………………..

So. your following question will be “What the Wireless Sensor Network actually is then?” 6 .1. Sensory data are obtained from numerous different sensors of distributed locations.2 Realization of Smart Environment In fact.1 What is Wireless Sensor Network? 1.1 Living in Smart Environment Have you ever dreamt of living in a Smart Environment. The Smart Environment does need information about its surroundings in order to generate the corresponding output regarding to respective changes. 1. very strict forward. then your next question will surely be “How can we get it to be realized?” To answer this question.Thesis II (2006-2007) Wireless Sensor Network 1.ERG4910B . which it enhances your living qualities with all kinds of intelligent automation devices or services? If “Yes”. Introduction 1. like any responsive organism. the Smart Environment [1] relies first on the sensory data from the actual world. The wireless Sensor 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. I would say that the application of Wireless Sensor Network is a solution to the realization of Smart Environment.1.

Thesis II (2006-2007) Wireless Sensor Network Figure. the data received at coordinator can then be used for further applications. 7 .ERG4910B . humidity and light intensity. The coordinator manages and controls the sensing data flow in the communication network. These sensors of different modalities detect the physical changes. to the coordinator for processing. Therefore.3 Wireless Sensor Network actually is 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.1 1. and generate corresponding data signal. like temperature. it is the exact case for Wireless Sensor Network. The data are then sent.1. through the network.

2 Where Wireless Sensor Network can be found? Actually. 4 Home automation: for example. Applications [2] include: 1 Habitat monitoring: such as the monitoring of water/ air pollution and the temperature/ humidity measurement. lighting control and security alarming 5 Other Commercial applications: like product quality control on the manufacturing production. 8 .ERG4910B . Wireless Sensor Network has already been widely used in different areas for current development.Thesis II (2006-2007) Wireless Sensor Network 1. 3 Biomedical use: such as collecting the physiological data from human body or medical diagnosis. 2 Military use: like the monitoring the actual battle condition by installing the sensor on the army and weapons.

Coordinator processes the received data and identifies if matched with the predefined criteria according to the needs of user. 4. 3. 5.1 Brief Introduction of the System In this project. coordinator will send command to the lighting control unit to switch light on. a body presence in the area.Thesis II (2006-2007) Wireless Sensor Network 1. the system can perform a lighting control function where the light on whenever anybody presence.3. 9 . Among the applications in this area. coordinator will send command to the lighting control unit to switch light off Therefore. it is aimed to demonstrate the application in the area of Home Automation.3 Specification of the System Design 1. To transmit the sensing data back to the coordinator through a network. if nobody presence in the area for a period of time.ERG4910B . To sense if there are anybody presence or absence in a specified area. while the light off if nobody presence for a period of time so as to save the power consumption. The system work flow is as following: 1. On the other hand. a simple function of lighting control is going to be implemented. for instance. 2. If the criteria are matched.

It is responsible to transmit the sensing data or the commands to and from different devices in the system.2 Brief Descriptions of System Components There are three main components in the system to build the application of wireless sensor network up to the current development stage of the project.ERG4910B . which are: 1. 3. Occupancy Sensor: The sensor unit of the system. regarding to the processed result. Wireless Communication Network: The communication channel between devices of the system. outputs correspondingly. 2. like light on/ off. It also processes the received sensing data from the sensing unit and. 10 . However. It is responsible to control and monitor the data transmission in between devices of the system. the application use.Thesis II (2006-2007) Wireless Sensor Network 1. It is responsible to sense if there are anybody presence or absence in a specified area and generate sensing data ready for the coordinator to process and further application. There should also be the lighting control unit. Coordinator: The headquarter unit of the system. it is not yet built up to the current development stage and may be built in future development if possible. in the system.3.

However. such as Bluetooth. Therefore. there are plenty of wireless communication standards available in the current market. Scalability [3]: The network has to be scalable. are they suitable for building the communication network of Wireless Sensor Network? There are indeed some specific requirements for the wireless sensor network.Thesis II (2006-2007) Wireless Sensor Network 2. hundreds of thousands) of entities.1. which are the most common ones. Wi-Fi.1 What should be considered? Obviously.ERG4910B . numerous sensors can be installed in the network and be able to monitor the region more efficiently. some background principles and consideration of the components of the system will be discussed in this section. 1. which means it can support up to as much larger number (thousands. Let’s consider the following factors first and see if the mentioned standards are suitable or not.1 Wireless Communication Network 2. 11 . 2. Background Theory Before going into any details of the system design.

With the factors mentioned above. 3. Simplicity[3]: As the sensor nodes (sensing units) are small and power supply is so limited.Thesis II (2006-2007) Wireless Sensor Network 2.ERG4910B . Energy Consumption [3]: The battery of the sensor node (sensing units) is usually not rechargeable.2 12 . the operating and networking software must be kept orders of magnitude simpler as compare to today’s desktop computers. Thus it is important to minimize the power consumption and prolong the sensor lifetime as the system cannot function properly without the sensing units. let’s consider the comparison of current available wireless communication standards as listed below: Figure.

power consumption and simplicity. there is a wireless communication network in between the control unit and controllable switch. 2. they are far worse than that of the Zigbee standard. regarding to their performance on scalability. The control unit then processes the input signal and output a corresponding signal to either switch the responsive device on/ off.1 What is Occupancy Sensor? Occupancy sensor [4] is a device that responds to the presence and absence of anybody in the sensor's field of view.2. Comparing with the Zigbee standard in the above table.Thesis II (2006-2007) Wireless Sensor Network 2. in the system. it establishes a system with similar property of power conservation as what it is in the standard. 13 . However.2 Occupancy Sensor 2.ERG4910B . this project is not implementing the Zigbee. an electronic control unit. Indeed.1. and a controllable switch.2 What should be adopted? It is observed that neither the Bluetooth nor Wi-Fi would be suitable to be used in Wireless Sensor Network. Instead. The system consists of a motion detector. the Zigbee has become the most commonly adopted network communication standard in the wireless sensor system on the current development or research. The motion detector senses motion and sends the appropriate signal to the control unit. where.

2 Method of Operation[5] In today’s markets. 14 .ERG4910B . such as a partition.2. They cannot "see" around corners and a person will not be detected if there is an obstruction. They are the Passive Infrared sensing method and the Ultrasonic wave detection method. there are two commonly used methods / approaches for the operation of Occupancy Sensor.2.Thesis II (2006-2007) Wireless Sensor Network 2.3 What is passive infrared sensing? Passive infrared (PIR) sensors [6] react to the infrared heat energy emitted by the human body. This project will focus on the Passive Infrared sensing method. PIR sensors are strictly line-of-sight devices. 2. between the person and the detector. 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 wavelength of the heat energy emitted by humans).

An infrared filter window at the front most position of the transducer admits IR within the 5 to 15 microns wavelength range 2.ERG4910B .2. the other end connects to the gate of a Field Effect Transistor and to a very high value pull-down resistor 4 5 Power is applied to the FET thus to the drain pin 1 Output signal comes from FET source pin 2 usually connects through an external pull-down resistor to ground and to an amplifier (See the following figure) 15 .3 1. The device converts the IR energy into a voltage signal. 3 Meanwhile. (See the figure below) Figure.4 How passive infrared sensing works? PIR sensors employ a pyroelectric transducer [6] to detect infrared radiation.Thesis II (2006-2007) Wireless Sensor Network 2. One end of the two series-connected sensing elements connected to pin 3 which is grounded.

or the whole body from one cone of vision to another. moves a hand. a positive signal is generated and sent to the controller.Thesis II (2006-2007) Wireless Sensor Network Figure. (See the figure below) Figure. surrounds the transducer and focuses heat energy onto the detector.4 A Fresnel lens. As such. As an occupant.ERG4910B . a focusing device.5 16 . it does not view the area in a continuous fashion. arm. The lens views the area with a multitude of narrow and discrete beams or cones.

its sensitivity decreases with distance as the gaps between sensing cones widen.Thesis II (2006-2007) Wireless Sensor Network The detection pattern [5] of PIR sensors is fan shaped -.6 As shown in above figure. for instance. coverage gaps occur between the cones of vision of alternate segments of the lens. 17 .ERG4910B . Figure. coverage gaps of up to 8 feet wide may be present. At 40 feet from the sensor. Since the sensor is most sensitive to motion that moves from one sensing cone to another. These gaps widen with distance.formed by the cones of vision seen by each segment of the faceted lens.

Thesis II (2006-2007) Wireless Sensor Network Most PIR sensors are sensitive to hand movement up to a distance of about 10 feet. a large area can be restricted to be our specified sensing region as soon as the PIR sensor is able to detect the movement. Because of this reason. and full body movement up to about 40 feet. arm and upper torso movement up to 20 feet. Thus. Regarding to the above data. the PIR sensor is used to act as the sensing unit to detect anybody presence or absence in a specified area. 18 . it is surprising that the sensing range of that little PIR sensor can be so large.ERG4910B .

ERG4910B . the Network is also built up of basically the transmitting unit and receiving unit. the adopted Communication Network for Sensor network has to be power conserving. so as to be long-lasted functioning. there will be two transmitters (for sensor node) and one receiver (for coordinator node) in the Sensor Network of this project. Paper Design 3.1 Transmitting Unit (Sensor Node) Combining with the circuitry of Sensing unit. Thus. For Simplicity.1. 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 components: a Microprocessor. this concept is also included in the design of communication network. a RF Transmitting Module and a LCD display (optional). it is the same for the system in this project. however large it is. (See the following Schematic Diagram) 19 . Undoubtedly.Thesis II (2006-2007) Wireless Sensor Network 3. 3. And as mentioned in the previous “Background Theory” section.1 Wireless Communication In a Wireless Communication Network.

ERG4910B .Thesis II (2006-2007) Wireless Sensor Network Schematic Diagram of Transmitting Unit Figure.7 20 .

it means that there is an output. from the sensing unit and vice versa.1. Process data from the sensing unit.Thesis II (2006-2007) Wireless Sensor Network 3. When this pin goes to “low”.1. 21 . motion detected.1 Component 1 .Microprocessor (PIC16F877A) The Microprocessor (PIC16F877A) is adopted for several main purposes as the following descriptions: .ERG4910B . motion detector The pin PIR_sense is connected to the output terminal of the circuitry of the Motion Detector sensing unit.

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 to avoid any fake-sensing from the surrounding environment.

- 2. Control power on/off of the RF Transmitting unit 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 collector voltage then equals to that of emitter which is connected to ground. 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 sensor network mentioned in the “Background Theory” section previously.

- 3. Output acknowledgement to RF transmitting module The pins RC0 – RC3 are connected to the data input pins RF13 – RF10 of transmitting unit respectively. The 4-bit acknowledgement data, 0b1010, is output when the state is changed to “motion detected” only. And this data will then be encoded by the transmitting module and transmitted out afterward.

- 4. Control character display on the LCD module (coding) In order to configure and display the characters on the LCD correctly, it is necessary to input corresponding instruction data to the LCD module. The microprocessor is thus the unit to give the according instruction data to the LCD module for displaying the status of the sensor node

23

ERG4910B - Thesis II (2006-2007)

Wireless Sensor Network

3.1.1 Component 2 - RF Transmitting module (Operating at 315MHz) [7]

The unit mainly consists of an encoding IC PT2262. PT2262 is a remote control encoder utilizing CMOS Technology. It encodes the preset address on its address pins and data from microprocessor into a serial coded waveform suitable for RF modulation before transmission. It has a maximum of 12 bits of tri-state address pins providing up to 531,441 (or 312) address codes; thereby, largely reducing any code collision and unauthorized code scanning possibilities (See the internal structure and pin assignment as followings)

Figure.8
24

Thesis II (2006-2007) Wireless Sensor Network Figure. Active Low Signal 14 OSC1 OSC2 DOUT O I O A resistor connected in between to 15 determine fundamental frequency 16 Encoded waveform output to this pin 17 serially. Each pin can be 1 . VCC VSS - + 5V Power Supply GND Ground Connection 18 9 25 .8 set to “0”. /TE I Transmission Enable. D3 – D0 I Data pins. “1” or “f” (floating). Each can only be set to 10 . Code Address Pin.ERG4910B .13 “0” or “1”.9 Pin Name A0 – A7 I/O I Description Pin No. Data Output pin.

1. and can be classified as either an AD (Address/Data) Bit or a SYNC (Synchronous) Bit. Each pulse cycle has 16 oscillating time periods.1.Thesis II (2006-2007) Wireless Sensor Network 3. This waveform is fed to the RF modulator for transmission. high or floating state respectively.1 Component 2 . Code Bits A Code Bit is the basic component of the encoded waveform.Function Description 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).Address/Data (AD) Bit Waveform An AD Bit can be designated as Bit “0”. Details of the operation are as followings: . .10 26 . “1” or “f” if it is in low. One bit waveform consists of 2 pulse cycles.ERG4910B . (See the diagram below) Figure.

Code Word A group of Code Bits is called a Code Word.) Bit Waveform The Synchronous Bit Waveform is 4 bits long with 1/8 bit width pulse. the transmitting format is: Figure.ERG4910B .11 . For example: In the 3 Data Type where the address has 9 bits. Figure. the code bits with their corresponding pins are as shown in 27 .2. The 12 AD bits are determined by corresponding states of A0 ~ A7 and D3 ~ D0 pins at the time of transmission.Thesis II (2006-2007) Wireless Sensor Network . A Code Word consists of 12 AD bits followed by one Sync Bit.12 PT2262 has a maximum of twelve (12) Address Bits including the six (6) Address/Data bits. When Data Type of PT2262 is used.Synchronous (Sync. the address bits will decrease accordingly.

Figure. PT2262 outputs another Code Frame. 28 .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. when it (A0 Pin) is set to “0” (Vss) or left floating. For example.Thesis II (2006-2007) Wireless Sensor Network the following diagram:.ERG4910B . It should be noted that the Code Frame is synthesized at the time of transmission. When PT2262 detects “0” on the /TE (the /TE is active “low”). when the A0 (Pin No. Figure. In the same manner. the Code Bit A0 is synthesized as a “0” or “f” bit respectively. Code Frame A Code Frame consists of four continuous Code Words.14 If /TE is still active at the time the Code Frame transmission ends. 1) is set to “1” (Vcc). . it outputs a Code Frame at DOUT. the Code Bit A0 is synthesized as “1” bit.3.

1 Component 3 . (See the following Schematic Diagram) 29 .ERG4910B . the main function of data transmission can actually still be carried out.1. a RF Receiving Module and a LCD display. Without the LCD Display. Thus.1.Thesis II (2006-2007) Wireless Sensor Network 3.2 Receiving Unit (Coordinator) The unit acts as the coordinator of the system. 3. then processes the acknowledgement and displays the result accordingly from the receiving data. It receives acknowledgement data transmitted from the sensor node (transmitting unit).LCD Display (optional) The unit is just used for displaying the current status of the motion detector after the data processing by the microprocessor. the LCD Display can be optional. This unit is mainly composed of several components: a Microprocessor.

Thesis II (2006-2007) Wireless Sensor Network Schematic diagram of Receiving Unit Figure.ERG4910B .15 30 .

Process Acknowledgement from receiving data As the received data at the RF receiving module arrive at the microprocessor.ERG4910B . the microprocessor checks if it matches with the predefined acknowledgement messages.Thesis II (2006-2007) Wireless Sensor Network 3.2 Component 1 .Microprocessor (PIC16F877A) The processor PIC16F877A is adopted for several purposes as the following descriptions: . It gives a positive response if the checking is matched and does not give any responses at vice versa.1. 31 .1.

ERG4910B . It has 12 bits of tri-state address pins providing a maximum of 531. 3. thereby.1.Thesis II (2006-2007) Wireless Sensor Network -2.441 (or 312) address codes.2 Component 2 . For example. the microprocessor displays the result on the LCD by giving corresponding instruction data to the LCD module. Control character display on the LCD module (coding) When there is positive response. it displays “I AM HERE” when there is somebody present in the area. The transmitted radio frequency is received by the RF demodulator and reshaped to the special waveform. (See the internal structure and pin assignment as followings) 32 .RF Receiving Module (Operating at 315MHz) [7] The unit mainly consists of an encoder PT2272 utilizing CMOS Technology. reducing any code collision and unauthorized code scanning possibilities. PT2272 is then used to decode the waveform and set the corresponding output pin(s).

17 Pin Name A0 – A7 I/O I Description Pin No.ERG4910B .13 “0” or “1”. Code Address Pin.Thesis II (2006-2007) Wireless Sensor Network Figure. 33 . Each can only be set to 10 . Each pin can be 1 . “1” or “f” (floating).8 set to “0”.16 Figure. D3 – D0 O Data pins.

and (2) the VT output to high voltage (high state). PT2272 then drives – (1) the data output pin(s) whose corresponding data bit(s) is then decoded to be a “1” & “0” bit.A7). Active High Signal 16 17 VCC VSS - + 5V Power Supply GND Ground Connection 18 9 3.Thesis II (2006-2007) Wireless Sensor Network Pin Name OSC1 OSC2 VT I/O I O O Description Pin No. A resistor connected in between to 15 determine fundamental frequency Valid Transmission. and can be classified as either an AD (Address/Data) Bit or a SYNC (Synchronous) Bit.Function Description PT2272 decodes the received waveform fed into the DIN pin.2 Component 2 . The Waveform is decoded into code word which contains the address. The decoded address bits are compared with the address set at the address input pins (A0 . If both addresses match for 2 consecutive code words.ERG4910B .1. 34 . Code Bits A Code Bit is the basic component of the encoded waveform. Details of Operation are as followings.1. data and sync bits. .

19 . Code Word A group of Code Bits is called a Code Word.18 .4. See the following diagram: Figure.Thesis II (2006-2007) Wireless Sensor Network . Each pulse cycle has 16 oscillating time periods. “1” or “f”. if it is in low. One bit waveform consists of 2 pulse cycles.ERG4910B . See the diagram below: 35 . Address/Data (AD) Bit Waveform An AD Bit can be designated as Bit “0”. Synchronous (Sync. high or floating state respectively. Figure.3. A Code Word consists of 12 AD bits followed by one Sync Bit.) Bit Waveform The Synchronous Bit Waveform is 4 bits long with 1/8 bit width pulse.2.

After two consecutive valid transmissions. PT2272 (1) drives the data pins according to the data bits received.Valid Transmission When PT2272 receives a transmission code word.ERG4910B .2 Component 2 . (1) it must be a Complete Code Word. and (2) the Address Bits must match the Address Setting at the Address Pins.Thesis II (2006-2007) Wireless Sensor Network 3. For a transmission to be valid.1. and (2) raises VT to high voltage (high state).20 36 . Figure. The timings are shown in the following diagram. it initially checks whether this is a valid transmission.

the LCD module displays the characters correspondingly. And RF module transmits the waveforms at 315MHz over a distance. It gives out a sensing signal “motion detected” (bit “0”) to the transmitting unit at its output terminal. 37 .3 Whole Implementation After all.LCD Display Module Regarding to the instruction data from the microprocessor. Indeed. the characters are arranged in the ASCII chart.ERG4910B . 3. The transmitting unit then gets the signal from its PIR_sense pin and processes.2 Component 3 . PT2262 then encodes the data into predefined waveforms.Thesis II (2006-2007) Wireless Sensor Network 3. the motion detector will be able to detect its motion.1. It means that all characters are displayed according to what ASCII code is keyed into the module.1. whenever there are anybody present in a specified area. It outputs the acknowledgement data to the RF transmitting module.

the lighting control unit has not yet been developed.4 Remarks However. apart from the construction of light control system. In the future development.1. the decoder PT2272 then validates and decodes the data if it is valid. therefore. 38 . As soon as the decoded data arrives at the microprocessor.ERG4910B . And the coordinator is just consisting of receiver unit. where it is not allowed to transmit any control signal neither to the sensor node nor any control units yet. the transceivers should also be implemented in the design if possible. be developed to be more functional and efficient.Thesis II (2006-2007) Wireless Sensor Network As the receiving module received the transmitted waveforms. And the user current status of the Sensor node (transmitting unit) can be viewed at the Coordinator (receiving unit) finally. 3. The coordinator cannot control the lighting control system at the moment. the corresponding output result will be displayed on the LCD after processing. The system can.

the Occupancy Sensor consists of three main components.0mm wide and are spaced in 1. As shown in the figure below Figure. which are the sensing unit.0mm long.0mm apart.21 Figure. In the design of the PIR Movement Sensor of this system. while an output terminal will act as the Output unit of the whole sensor system.2 PIR Movement Sensor As mentioned in the previous “Background Theory” section. a Master PIR Control Chip MPCC (KC788B) is selected for control unit. A PIR sensor (RE200B) is chosen to be the sensing unit.1 PIR sensor (RE200B) It is in a package of T0-5 with dimension shown in the figure.ERG4910B . 1.22 39 . There are two sensitive elements with area of 2.2. control unit and the output unit.Thesis II (2006-2007) Wireless Sensor Network 3. it is also the same case as that of the normal Occupancy Sensor. 3.

it allows the minimum external components.2 Control Unit (KC778B) The chip has been designed for easy implementation of AC control functions that use a Passive Infra-Red (PIR) motion detector.5 Vp-p.2.23 3. it is shown as below: Figure.24 With most of the necessary components integrated in the chip. it is also widely used in security product. 40 . Due to its high sensitivity and reliability. For the field of view detected by the sensor.Thesis II (2006-2007) Wireless Sensor Network It can be operated at 3 to 10 V DC with its minimal signal output voltage at around 2. Figure. It has high sensitivity and an off delay timer.ERG4910B .

25 The above diagram shows the internal block structure of the chip.ERG4910B . 41 .Thesis II (2006-2007) Wireless Sensor Network Figure.

Thesis II (2006-2007) Wireless Sensor Network Figure.26. Pin assignment of the Chip: 42 .ERG4910B .

27 Original Schematics 43 .ERG4910B .Thesis II (2006-2007) Wireless Sensor Network Figure.

Thesis II (2006-2007) Wireless Sensor Network Figure.28 Modified Schematics 44 .ERG4910B .

If this feature is not needed. voltage input should be in the 9V to 12V range. With the 78L05 regulator.15V. (See the original schematic diagram in the previous page) 1. This adjusts the output pulse from between 1.Thesis II (2006-2007) Wireless Sensor Network 3. When this pin equals the sensor drain potential at pin 7 (about 0. pins 18 & 19 are connected directly with no external capacitor or resistor. The operating voltage of the KC778B itself is 4 .ERG4910B . There are three sensitivity controls built into the original circuit. Electrical signals from the PIR sensor have a very low frequency (0. 45 . Pulse on-time trimpot P3. For the minimum time delay. the pin 12 should be connected to Vcc and pin 11 should be left unconnected 3.2. the sensitivity is at maximum.3 Control and Output Circuit Description The heart of the circuit is the motion detection IC.1 to 10Hz) and bandwidth.5V) sensitivity is at a minimum. The IC is optimized for this. When the pin 2 is connected to ground (about 0. Sensitivity is controlled at pin 2 by trimpot P1. Daylight sensitivity using trimpot P2 and the LDR.5 seconds upwards.125V). This is adopted when the sensor is designed to be inactive during the daytime and only active at night. 2.

At the meantime.) (See Pin 17 is also connected to an LED. LED1. only two controls will be used after modification. They are the trimpot P1 for Sensitivity adjustment and trimpot P3 for Pulse on-time adjustment.Thesis II (2006-2007) Wireless Sensor Network However.5 seconds in the Output pulse when triggered. the modified schematic diagram in the previous page. There is also an inbuilt latency period of about 1. It switches on the BC547 and current flow through the transistor. But this trigger may result in an Output signal.) There is an internal 500R resistor on pin 17 so a current limiting resistor is not required. And this signal will be passed to the coordinator for processing. the Output from the unit is off during the Daytime. Its collector is then becomes grounded as the emitter is connected to ground. the pin 12 is connected to Vcc and pin 11 is left unconnected. This latency period is essential to smooth out the multiple trigger pulses actually sensed by the detector (as shown by LED1. 46 . it turns on LED2 in original design as there is now potential difference across LED2. For example. Thus.ERG4910B . The output signal from IC pin16 goes “high” whenever movement is detected. Besides. it gives “low” to the OUTPUT in the modified circuit. This IC output always goes on when the sensor & IC detect movement.

ERG4910B .4 Required Components for building the Modified Circuit Resistors: 1K brown black red R8 R9 R10 3K9 orange white red R3 10K brown black orange R2 R5 R7 47K yellow violet orange R1 R6 56K green blue orange R4 Potentiometers 200K Koa trimpot 204 P1 1M Koa trimpot 105 P3 Capacitors 10uF mini elcap C3 10uF Low leakage elcap C5 100uF mini elcap C1 100nF 104 C2 C4 C6 C8 220pF ceramic 221 C7 4n7 ceramic 472 C9 470nF C10 Control Unit IC KC778B Movement IC1 Transistors BC547 transistor Q1 Voltage Regulator 78L05 IC2 1N4004 diode D1 Output Units LED Sensors RE200B PIR sensor Light Dependent Resistor LDR Fresnel Lens Quantity 3 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 1 47 .Thesis II (2006-2007) Wireless Sensor Network 3.2.

the microprocessor and LCD Display Module Figure 29 48 . the Unit just consists of the PIR motion detector. Experimental Results 4.Thesis II (2006-2007) Wireless Sensor Network 4.1.ERG4910B .1 Testing on the Transmitting Units (Sensor Node) Test Case 1 .1 Testing with Wireless Communication The Wireless Communication is mainly composed of the transmitting unit and the receiving unit as what has been discussed in previous sections. Following tests are carried out on investigating the individual performances of the transmitting and receiving units 4.No RF Transmitting Module installed Without the RF Transmitting Module being placed.

Figure 31 .Thesis II (2006-2007) Wireless Sensor Network The unit then performs like a Detector with a Display showing its current status Figure 30 . the display “NOT HERE” means that there are any motions detected in the area monitoring.ERG4910B . 49 . the LCD displays as the above figure. Remarks: The display “I AM HERE” means that there are motions detected in the specified area. the LCD displays as the above figure.When motion detected.When no motion detected.

ERG4910B . State of “motion detected” is kept showing on the LCD Display no matter there is motion nearby or not 50 .RF Transmitting Module installed With the RF Transmitting Module being installed. certainly. the performance is not as expected. the transmitter sends out an acknowledgement signal. 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 Unit then consists of the RF Transmitter.Thesis II (2006-2007) Wireless Sensor Network Test Case 2 . Unfortunately. the PIR motion detector.

The test can be carried out. the transmitting unit is functioning in order to send out acknowledgement signal to the receiving unit in the testing process. 51 .Thesis II (2006-2007) Wireless Sensor Network 4. the Receiving unit consists of the RF receiving module. There are still acknowledgement data sent by the transmitting unit depart its instability. Besides that. the tests can still be regarded as valid.2 Testing of the Receiving Unit (Coordinator) As stated before in the previous description. a microprocessor and a LCD display. Although the performance of transmitting unit is not as stable as expected.1.ERG4910B . Figure 33 At the same time. the receiving unit just displays the result when there is acknowledgement received.

When there is “motion detected” acknowledgement received Figure 34 The Display shows the “motion detected” status Case 2 .ERG4910B .When no there is no “motion detected” acknowledgement received Figure 35 The Display shows no motion detected status The performance of the Receiving unit is stable and as expected 52 .Thesis II (2006-2007) Wireless Sensor Network Case 1 .

comparing the testing result to the general detection range of the common PIR detector on market and see if the performance is satisfied or not.ERG4910B .2 Testing the PIR Movement Sensor The figure below shows the built PIR Movement Detector Circuit Board.Thesis II (2006-2007) Wireless Sensor Network 4. i. Figure. The aim of this testing is to observe how far the detector is able to detect the motion. the detection range. but three different environment.e. After that. It is built according to the schematic shown in the section of “Background Theory”.36 The PIR detector will be undergone a testing with same approaches. Experimental Results 4. 53 .

Figure.ERG4910B .Thesis II (2006-2007) Wireless Sensor Network 4.2.37 Width 54 .1 Testing Case 1 with Daylight Testing Place: Hostel Corridor (Rectangular Closed Area) Testing Object: Human Body (Full Body / Upper Body Movement) Testing Method: Moving away from sensor till the point where the movement cannot be sensed Hostel Corridor PIR Sensor Length .

ERG4910B .2 Testing Case 2 with Daylight Testing Place: SHB 6th Floor Reading Area (Large Indoor Room) Testing Object: Human Body (Full Body Movement) Testing Method: Moving away from sensor till the point where the movement cannot be sensed SHB 6th Floor Reading Area PIR Sensor Length Width Figure.Thesis II (2006-2007) Wireless Sensor Network 4.38 55 .2.

Thesis II (2006-2007) Wireless Sensor Network 4.2.ERG4910B .39 56 .3 Testing Case 3 at Night Testing Place: Open Area at Hostel Ground Floor (Wild Open Area) Testing Object: Human Body (Full Body Movement) Testing Method: Moving away from sensor till the point where the movement cannot be sensed Open Area at Hostel Ground Figure.

2.8 m Body 12 x square = 6.96 m 140 deg when getting close to the sensor 57 .ERG4910B .4 m 46 x square = 12.88 m Testing Result from case 3 at the Open area of Hostel Ground floor Body Measurement Movement Measured Length (26cm per shoes) View Angle (Rough Observation only) Full body Movement 46 x square = 11.Thesis II (2006-2007) Wireless Sensor Network 4.6 m 3 x square = 1.8 m Testing Result from case 2 at SHB 6th floor Reading Area: Body Measurement Movement Measured Length (28cm per shoes) Measured Width (28cm per shoes) Full body Movement 48 x square = 13.4 Testing Results from the previous 3 situation are as following Testing Result from case 1 at Hostel Corridor: Body Measurement Movement Measured Length (60cm per square on the floor) Measured Width (60cm per square on the floor) Full body Movement Upper Half Movement 21 x square = 12.8 m 3 x square = 1.

where it is mainly separated into two parts. the hardware for Wireless Communication Network and the necessary components for PIR Movement Detector circuit building. PIR Sensor. Table 1: Hardware for Wireless Communication Network Item Description Microprocessor x 3 Transmitting module x 2 Receiving module x 1 All Necessary components + LCD Total Cost Item Cost HK$60 HK$40 HK$25 HK$125 Table 2: PIR Movement Detector Circuit Item Descriptions All Necessary components Item Cost HK$5 Fresnel lens.Thesis II (2006-2007) Wireless Sensor Network 5. Controller IC (KC778B) HK$75 Total Cost HK$80 58 .ERG4910B . Cost Summary The estimated cost of the system for demonstration purpose is listed below tables.

Unfortunately. It gives the “motion detected” signal even there are not any body motions in the sensing area.1 Wireless Communication When testing the Wireless Communication and the PIR Movement Detector individually.ERG4910B .Thesis II (2006-2007) Wireless Sensor Network 6. Reason for the abnormal performance The reason for this abnormal performance is actually because the ground potential connected to the circuitry has become unstable after the wireless 59 . becomes very unstable. their performance is perfectly stable. the overall performance. Discussion 6. Problem encounter After merging the wireless communication modules and the PIR movement detector. the actual result is that the detector gives out such sensing signals abnormally. however. the performance should be as expected as what has been stated in the previous “Paper Design” section. After combining the Wireless module with the Movement Detector on a circuit board together with their original arrangements. 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.

60 .ERG4910B . lesser the parasitic effect on ground potential it imposes. The ground potential (0V) can then be kept constantly as there is no longer the parasitic effect of connection wire. It can greatly reduce the distance of connection in between the ground terminal and the ports. the RF signal generated from the wireless module will impose some unwanted parasitic potential along the wire connected. 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. Possible solution to the Problem To solve the encounter problem. In the long connected wire. And the instability of overall ground potential is due to the long wired “ground” connection between ports and the ground terminal. It then affects the original ground connection on the ports in which the ground connection is no longer at ground potential (0V).Thesis II (2006-2007) Wireless Sensor Network communication module is merged with the motion detection circuit. As shorter the ground connection it is. it 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. Indeed. but an unknown potential imposed by the parasitic effect of the wired connection.

To implement the two-way communication between them. but it cannot listen to/get the data from others. Meanwhile. thereby. A better suggestion on the communication method is to implement a two-way communication between the coordinator and the sensor nodes.ERG4910B . the network should no longer use the pair of transmitting and receiving units.Thesis II (2006-2007) Wireless Sensor Network Further Possible Improvement In the system. but it cannot talk/send out data to others. It limits the communication between the sensor nodes and the coordinator to be a kind of single-way communication. The current status update of sensor nodes can then be done more efficiently and effectively. it should adopt the transceiver as the communication module in between them. those two transmitting units are the only ones which are able to talk/send out data to the other parties. It can just wait till those sensor nodes send out the acknowledgement data only. As the transceiver can act both the functions of transmitting and receiving in a single module. the receiving unit is the only one which is able to listen to/get the data from other parties. The coordinator can. 61 . be able to take control on the sensor nodes at any time it requests. Instead. The coordinator cannot take control on the sensor nodes and request for those their current status at any time.

it is observed that the detection range of the built sensor is about 12m long which is about 40ft by calculation. there can be a mixed use with ultrasonic wave detection method. It is the problem of line of view. there is a big drawback for our PIR Movement Detector. 62 . And this data does match to the previous mentioned range (40ft) for full body movement in the section of “Background Theory”.ERG4910B . As this method is less dependent to the line of view.Thesis II (2006-2007) Wireless Sensor Network 6. it cannot sense the body at round corner. However. then the sensor cannot sense the moving body. thus it is able to help enlarge the detection range afterward. Beside that. To solve this problem. Whenever there is obstacle in between.2 PIR Movement Detector After the testing in three different situations.

lightingdesignlab. “Wireless sensor networks: a survey. Cook and S. [4] – Lighting design lab http://www. Das.Thesis II (2006-2007) Wireless Sensor Network 7. Sankarasubramaniam. L. April 2002 [3] – Holger Karl and Andreas Willig. Y.html [7] – Application notes of PT2262/2272 http://www. John Wiley.glolab. and E. Technical University Berlin. and Applications. [2] – Akyildiz. J. editors. “ Computer Networks. Su.com/articles/occ_sensor/method_oper. In D.lightsearch. New York.com.com/resources/lightguides/sensors. K. 38(4):393–422. Smart Environments: Technologies.htm [5] – light guide: occupant sensors http://www. October 2003.princeton.ERG4910B . Protocols. W. References [1] – F. “Wireless sensor networks”.tw 63 . 2004. Lewis. “A short survey of wireless sensor networks” TKN Technical Report TKN-03-018. Cayirci.html [6] – How Infrared Motion Detector Components work http://www.com/pirparts/infrared.

count1. Appendices – Software Coding ////////////////////////////////////////////////////////////////////////////////////////////////// // File Name: receive. extern unsigned char temp. 64 .h> #define Sel0 RA0 #define NIL RA1 #define Sel1 RA2 #define ADR0 RA3 #define ADR1 RA4 #define ADR2 RA5 #define RX0 RC0 #define RX1 RC1 #define RX2 RC2 #define RX3 RC3 #define RX_ACK RC4 #define #define #define #define #define #define #define #define LCD0 LCD1 LCD2 LCD3 LCD4 LCD5 LCD6 LCD7 RD0 RD1 RD2 RD3 RD4 RD5 RD6 RD7 #define LCD_RS RE2 #define LCD_RW RE1 #define LCD_EN RE0 extern void InitPIC(void).h // Description: It declares all pins and externs functions /////////////////////////////////////////////////////////////////////////////////////////////////// #include <pic.h> #include <stdio.ERG4910B . extern unsigned int count.temp1.Thesis II (2006-2007) Wireless Sensor Network 8.

extern void clear(void).Thesis II (2006-2007) Wireless Sensor Network ////////////////////////////////////////////////////////////////////////////////////////////////// // File Name: LCD. extern void InitLCD(void). 65 .h> #include <stdio. extern void pos_select(unsigned char pos).h> extern void lcd_puts(const char *s).ERG4910B .c ///////////////////////////////////////////////////////////////////////////////////////////////// #include <pic.h // Description: It extern LCD Control functions in LCD.

//Address0 while(1) { if (ADR0==0) { //////////////////////////////// //Node0 Process //////////////////////////////// result=temp.c // Description: It coordinates the whole process ///////////////////////////////////////////////////////////////////////////////////////// #include "receive. InitLCD(). InitPIC().h" #include "LCD. pos_select(2). lcd_puts("Node1:"). unsigned int stop_count.Thesis II (2006-2007) Wireless Sensor Network ///////////////////////////////////////////////////////////////////////////////////////// // File Name: receive. clear().h" void main(void) { unsigned char result=0. switch (result) { 66 . ADR0 = 0. pos_select(0).ERG4910B . lcd_puts("Node0:").

//stop_count=10000. count1=0. } break. //stop_count=50000.ERG4910B . break. while (count1<10000). case 10: pos_select(1). lcd_puts("I AM HERE").Thesis II (2006-2007) Wireless Sensor Network case 0: pos_select(1). count1=0. break. while (count1<50000) { if (temp==10) count1=0. lcd_puts("I DUNNO "). } } else if (ADR0==1) { /////////////////////////////////// //Node1 Process //////////////////////////////////// result=temp1. 67 . while (count1<10000). lcd_puts("NOT HERE "). count1=0. default: pos_select(1). //stop_count=50000.

} } if ((Sel0==1)&&(Sel1==0)) ADR0=0.Thesis II (2006-2007) Wireless Sensor Network switch (result) { case 0: pos_select(3). } } 68 . while (count1<50000) { if (temp1==10) count1=0.ERG4910B . else ADR0=0. else if ((Sel0==0)&&(Sel1==1)) ADR0=1. break. count1=0. } break. default: pos_select(3). while (count1<10000). break. lcd_puts("I AM HERE"). case 10: pos_select(3). lcd_puts("I DUNNO "). while (count1<10000). count1=0. count1=0. lcd_puts("NOT HERE ").

break. PORTD = 0x80.h" void clear(void) { /////////////////////////// //Clear Display //////////////////////////// LCD_EN = 1. LCD_RS = 0. LCD_RS = 0. LCD_RW = 0.Thesis II (2006-2007) Wireless Sensor Network //////////////////////////////////////////////////////////////////////////////////////////////////////////// // File Name: LCD. 69 .//Upper Leftmost position count=0.//wait>=1.c // Description: It declares functions to control LCD display //////////////////////////////////////////////////////////////////////////////////////////////////////////// #include "receive. LCD_RW = 0. count=0. while (count<50).53ms for execution LCD_EN = 0.//wait>=39us for execution LCD_EN = 0. } void pos_select(unsigned char pos) { ///////////////////////////////////////////// // Select Display Position ///////////////////////////////////////////// switch (pos) { case 0://Node0 Display LCD_EN = 1. PORTD = 0x01. while (count<100).ERG4910B .

LCD_RS = 0. LCD_RS = 0. LCD_RS = 0. case 3://Node1 Status LCD_EN = 1. LCD_RW = 0.//wait>=39us for execution LCD_EN = 0.ERG4910B . while (count<50).//wait>=39us for execution LCD_EN = 0. PORTD = 0x87. break. } } 70 . while (count<50). //Lower Leftmost position count = 0. LCD_RW = 0.Thesis II (2006-2007) Wireless Sensor Network case 1://Node0 Status LCD_EN = 1. break. PORTD = 0xC7. break. LCD_RW = 0.//Lower Leftmost position count=0. while (count<50).//wait>=39us for execution LCD_EN = 0. case 2://Node1 Display LCD_EN = 1.//Lower Leftmost position count=0. PORTD = 0xC0.

LCD_RS = 0. PORTD = 0x38. count = 0.//wait>=30ms for power up //////////////////////////// //Initialize Function Set //////////////////////////// LCD_EN = 1. ///////////////////////////// //Display ON/OFF Control ///////////////////////////// LCD_EN = 1. while (count<10).//wait>=39us for execution LCD_EN = 0. LCD_RW = 0. LCD_RS = 0. //PORTD = 0x38. PORTD = *s. LCD_RW = 0. 71 .//wait>=39us for execution LCD_EN = 0.//Jump to Next Character } } void InitLCD(void) { while (count<1000).Thesis II (2006-2007) Wireless Sensor Network void lcd_puts(const char *s) { while(*s) { /////////////////////////// // Write Characters /////////////////////////// LCD_RS = 1. count = 0.ERG4910B . LCD_EN = 1. while (count<10). *s++.

count=0. while (count<10).53ms for execution LCD_EN = 0.//wait>=39us for execution LCD_EN = 0.ERG4910B . LCD_RW = 0. //PORTB = 0x01. while (count<100).//wait>=1. LCD_RS = 0. count=0. //PORTB = 0x07. PORTD = 0x07. LCD_RS = 0. /////////////////////////// //Entry Mode Set /////////////////////////// LCD_EN = 1. PORTD = 0x01. ////////////////////////////// //Display Clear ////////////////////////////// LCD_EN = 1.//0x0F. PORTD = 0x0C.//wait>=39us for execution LCD_EN = 0. } 72 . LCD_RW = 0. while (count<10).Thesis II (2006-2007) Wireless Sensor Network LCD_RW = 0. //PORTB = 0x0C. count = 0.

h" unsigned int count.temp1.count1. TMR0=0x29. // TIMER0 if (T0IF) { if (ADR0==0) temp = PORTC&0b00001111. count1++. unsigned char temp.//interrupt at 50us T0IF=0.c // Description: It acts as timer counter and checks received data input ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include "receive. else if (ADR0==1) temp1 = PORTC&0b00001111.Thesis II (2006-2007) Wireless Sensor Network /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // File Name: isr. } } 73 . count++.ERG4910B . void interrupt ISR(void) { flag=RX_ACK. bit flag.

PIR1 = 0x00.//clear variable temp } 74 . PEIE = 1. /////////////////////////////////// // Interrupt Init /////////////////////////////////// PIE1 = 0X00. TRISC = 0x1F. //CLR TMR0 FLAG T0IE = 1. //enable PERI interrupt GIE = 1. //ALL PINS are Digital pins /////////////////////////////////// // PORTS /////////////////////////////////// TRISA = 0b00000101. //enable ALL interrupt /////////////////////////////////// // TMR0 Init /////////////////////////////////// T0CS = 0. //follow CLK T0IF = 0.h" void InitPIC(void) { /////////////////////////////////// // A/D & I/O PIN SELECT /////////////////////////////////// ADCON1 = 0b00001110.Thesis II (2006-2007) Wireless Sensor Network /////////////////////////////////////////////////////////////////////////////////////////////// // File Name: init.//initial tmr0 temp = 0.ERG4910B . TRISE = 0x00.c // Description: It initializes all the ports and registers /////////////////////////////////////////////////////////////////////////////////////////////// #include "receive. TRISD = 0x00. //enable TMR0 interrupt TMR0 = 0x29.

Sign up to vote on this title
UsefulNot useful