Sunteți pe pagina 1din 54

STUDY ORIENTED PROJECT

SMART WIRELESS TEMPERATURE DATA LOGGER USING IEEE 802.15.4/ZIGBEE PROTOCOL

BY : I.D.L.NARYANA SWAMY 2009AAPS068H

UNDER THE GUIDENCE OF MR.U.MADHAVA RAO BITS-PILANI HYDERABAD CAMPUS

ACKNOWLEDGEMENT
Mere thanks in few words would be highly inadequate to express my gratitude to Mr.U.MADHAVA RAO SIR who gave me invaluable suggestions and guidance during the course of this project. He helped me not only with the theoretical aspects relating to the project but also provided me with the knowledge of how to come up with real time and industrial application embedded systems. I acknowledge with thanks the support rendered by my friend I.Sriram Vamsi who helped me to understand few concepts.

ABSTRACT
This project deals with a portable wireless data acquisition system for temperature in real time process dynamics. Process variables (like temperature, pressure, flow, level) vary with time in certain applications and this variation should be recorded so that a control action can take place at a defined set point. This project uses an 8- bit embedded platform for a sensor having a network interface using the 802.15.4, ZigBee protocol, that is specially designed for the sensors network. The ZigBee protocol is a wireless technology developed as an open global standard to address the unique needs of low-cost, low power, wireless sensors network .This wireless data logger senses and monitors the variations in the local temperature there by transmits the data within the range to an assigned embedded processor based server. Received temperature is displayed on a local liquid crystal display (LCD) on assigned server and simultaneously on a computer.

TABLE OF CONTENTS
Topic Introduction Tasks to be accomplished Block Diagram LM35 ADC Microcontroller Peripheral Interfacing MAX232 LCD Programming ZIGBEE Problem statement Transmitting unit Receiving unit Other configuring aspects Conclusion Appendix List of illustrations References Page no. 5 6 7 8 10 13 15 16 17 18 22 34 35 38 43 46 47 53 54
4

INTRODUCTION

This project has many real time applications like the constant temperature regulation and the necessary alarm signal during the extreme conditions.The temperature can be sensed at a place and transmitted with in a radius 10 m. The smart logger is the convergence of the sensing features of a sensor with the intelligence and decision making abilities of a micro system. They have been successfully deployed in many industrial applications such as maintenance, monitoring, control, security, etc. Free from the hassles of any ordinary sensor system, it has its advantages in terms of portability, reliability, flexibility and robustness. Temperature is recorded using a temperature tag at user defined time intervals. The temperature tag can be programmed so that when the memory is full it either stops further recording or continues recording by overwriting the earliest of the previously recorded data. During the course of my project I want to apply this principle to develop a constant regulatory system of motors in a laboratory. We can use many transmitting units, each sending information to the receiver at regular intervals without any clash. This enables us to plot graphs of different motors and their temperature variations which gives us an idea about their mean temperature variation with time.

TASKS TO BE ACCOMPLISHED

To understand and analyse the smart wireless temperature data logger using IEEE 802.15.4/zigbee protocol

Study and understand the functioning of LM35-DZ temperature sensor Function of ADC convertor Analysis of the ZIGBEE/IEEE 8021.15.4 modules Software implementation for the microcontroller LCD display module Serial poet communication between microcontroller and pc Function of MAX 232 (interfacing unit) Hardware implementation and schematic description Study of the transmitter and receiver Pin configuration of the microcontroller and its interfacing units

BLOCK DIAGRAM

A TEMPERATURE SENSOR D C MICROCONTROLLER TRANSMITTER

TRANSMITTING UNIT

LCD MICROCONTROLLER PC RECEIVER

BUZZER

RECEIVING UNIT

Fig.1

TEMPERATURE SENSOR (LM35)


FEATURES: Calibrated directly in Celsius (Centigrade) Linear + 10.0 mV/C scale factor 0.5C accuracy guaranteeable (at +25C) Rated for full -55 to +150C range Suitable for remote applications Low cost due to wafer-level trimming Operates from 4 to 30 volts Less than 60 A current drain Low self-heating, 0.08C in still air Nonlinearity only C typical Low impedance output, 0.1 Ohm for 1 mA load

General Description: The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage over linear temperature sensors calibrated in Kelvin, as the user is not required to subtract a large constant voltage from its output to obtain convenient Centigrade scaling. The LM35 does not require any external calibration or trimming to provide typical accuracies of 14C at room temperature and 34C over a full 55 to +150C temperature range. Low cost is assured by trimming and calibration at the wafer level. The LM35s low output impedance, linear output, and precise inherent calibration interfacing to readout or control circuitry especially easy. It can be used with single power supplies, or with plus and minus supplies. As it draws only 60 A from its supply, it has very low self-heating, less than 0.1C in still air. The LM35 is rated to operate over a 55 to +150C temperature range, while the LM35C is rated for a 40 to +110C range (10 with improved
8

accuracy). The LM35 series is available packaged in hermetic TO-46 transistor packages, while the LM35C, LM35CA, and LM35D are also available in the plastic TO-92 transistor package. The LM35D is also available in an 8-lead surface mount small outline package and a plastic TO-220 package. Applications: The LM35 can be applied easily in the same way as other integrated-circuit temperature sensors. It can be glued or cemented to a surface and its temperature will be within about 0.01C of the surface temperature. This presumes that the ambient air temperature is almost the same as the surface temperature; if the air temperature were much higher or lower than the surface temperature, the actual temperature of the LM35 die would be at an intermediate temperature between the surface temperature and the air temperature. This is especially true for the TO-92 plastic package, where the copper leads are the principal thermal path to carry heat into the device, so its temperature might be closer to the air temperature than to the surface temperature. To minimize this problem, be sure that the wiring to the LM35, as it leaves the device, is held at the same temperature as the surface of interest. The easiest way to do this is to cover up these wires with a bead of epoxy which will insure that the leads and wires are all at the same temperature as the surface, and that the LM35 dies temperature will not be affected by the air temperature. Alternatively, the LM35 can be mounted inside a sealed-end metal tube, and can then be dipped into a bath or screwed into a threaded hole in a tank. As with any IC, the LM35 and accompanying wiring and circuits must be kept insulated and dry, to avoid leakage and corrosion. This is especially true if the circuit may operate at cold temperatures where condensation can occur. These devices are sometimes soldered to a small light-weight heat fin, to decrease the thermal time constant and speed up the response in slowly-moving air. On the other hand, a small thermal mass may be added to the sensor, to give the steadiest reading despite small deviations in the air temperature.

ADC CONVERTER
General Description: The ADC0808, ADC0809 data acquisition component is a monolithic CMOS device with an 8-bit analog-to-digital converter, 8-channel multiplexer and microprocessor compatible control logic. The 8-bit A/D converter uses successive approximation as the conversion technique. The converter features a high impedance chopper stabilized comparator, a 256R voltage divider with analog switch tree and a successive approximation register. The 8-channel multiplexer can directly access any of 8-single-ended analog signals. The device eliminates the need for external zero and full-scale adjustments. Easy interfacing to microprocessors is provided by the latched and decoded multiplexer address inputs and latched TTL TRI-STATE outputs. The design of the ADC0808, ADC0809 has been optimized by incorporating the most desirable aspects of several A/D conversion techniques. The ADC0808, ADC0809 offers high speed, high accuracy, minimal temperature dependence, excellent long-term accuracy and repeatability, and consumes minimal power. These features this device ideally suited to applications from process and machine control to consumer and automotive applications. For 16-channel multiplexer with common output (sample/hold port) see ADC0816 data sheet. (See AN-247 for more information.) Features: Easy interface to all microprocessors Operates ratiometrically or with 5 VDC or analog span adjusted voltage reference No zero or full-scale adjust required 8-channel multiplexer with address logic 0V to 5V input range with single 5V power supply Outputs meet TTL voltage level specifications Standard hermetic or molded 28-pin DIP package 28-pin molded chip carrier package ADC0808 equivalent to MM74C949ADC0809
10

CONVERTER CHARACTERISTICS
The Converter: The heart of this single chip data acquisition system is its 8-bit analog-to-digital converter. The converter is designed to give fast, accurate, and repeatable conversions over a wide range of temperatures. The converter is partitioned into 3 major sections: the 256R ladder network, the successive approximation register, and the comparator. The converters digital outputs are positive true. The 256R ladder network approach (Figure 1) was chosen over the conventional R/2R ladder because of its inherent monotonicity, which guarantees no missing digital codes. Monotonicity is particularly important in closed loop feedback control systems. A non-monotonic relationship can cause oscillations that will be catastrophic for the system. Additionally, the 256R network does not cause load variations on the reference voltage. The bottom resistor and the top resistor of the ladder network are not the same value as the remainder of the network. The difference in these resistors causes the output characteristic to be symmetrical with the zero and full-scale points of the transfer curve. The first output transition occurs when the analog signal has reached +12 LSB and succeeding output transitions occur every 1 LSB later up to full-scale. The successive approximation register (SAR) performs 8 iterations to approximate the input voltage. For any SAR type converter, n-iterations are required for an nbit converter. In the ADC0808, ADC0809, the approximation technique is extended to 8 bits using the 256R network. The A/D converters successive approximation register (SAR) is reset on the positive edge of the start conversion (SC) pulse. The conversion is begun on the falling edge of the start conversion pulse. A conversion in process will be interrupted by receipt of a new start conversion pulse. Continuous conversion may be accomplished by tying the end-of-conversion (EOC) output to the SC
11

input. If used in this mode, an external start conversion pulse should be applied after power up. End-of-conversion will go low between 0 and 8 clock pulses after the rising edge of start conversion. The most important section of the A/D converter is the comparator. It is this section which is responsible for the ultimate accuracy of the entire converter. It is also the comparator drift which has the greatest influence on the repeatability of the device. A chopper-stabilized comparator provides the most effective method of satisfying all the converter requirements. The chopper-stabilized comparator converts the DC input signal into an AC signal. This signal is then fed through a high gain AC amplifier and has the DC level restored. This technique limits the drift component of the amplifier since the drift is a DC component which is not passed by the AC amplifier. This s the entire A/D converter extremely insensitive to temperature, long term drift and input offset

12

MICROCONTROLLER(AT89C51)
The Microcontroller AT89C51 is derived from Intel 8051 architecture. Intel refers to 8051 as MCS-51 family. It has the same SFRs as of the 8051 microcontroller. The various features of this microcontroller are described below. Features: 80C51 Central Processing Unit 5 V Operating voltage from 0 to 40 MHz 64 kB of on-chip Flash program memory with ISP (In-System Programming) and IAP (In-Application Programming) Supports 12-clock (default) or 6-clock mode selection via software or ISP SPI (Serial Peripheral Interface) and enhanced UART PCA (Programmable Counter Array) with PWM and Capture/Compare functions Eight 8-bit registers (R0 - R7) Four 8-bit I/O ports with three high-current Port 1 pins (16 mA each) Three 16-bit timers/counters Programmable Watchdog timer (WDT) Eight interrupt sources with four priority levels Second DPTR register Low EMI mode (ALE inhibit) TTL- and CMOS-compatible logic levels The Flash program memory supports both parallel programming and in serial InSystem Programming (ISP). Parallel programming mode offers gang-programming at high speed, reducing programming costs and time to market. ISP allows a device to be reprogrammed in the end product under software control. The capability to field/update the application firmware s a wide range of applications possible. The P89LV51RD2 is also In-Application Programmable (IAP), allowing the Flash program memory to be reconfigured even while the application is running.
13

The Block diagram showing various internal peripherals of the microcontroller NXP P89LV51RD2 is as follows.

Fig.2 The block diagram showing internal architecture of NXP P89LV51RD2.

14

SERIAL PERIPHERAL INTERFACE (MAX232)


Serial communication is used for transferring and receiving data between the microcontroller and the PC. Serial data communication uses two methods, asynchronous and synchronous. The synchronous method transfers a block of data at a time, while the asynchronous method transfers a single byte at a time. These chips are commonly referred to as UART and USART. There are three modes of transmission Simplex, Half Duplex, Full Duplex. In data transmission, if the data can be transmitted and received, it is a duplex transmission. This is in contrast to simplex transmissions such as with printers, in which the computer only sends data. Duplex transmissions can be half or full duplex depending on whether or not the data transfer can be simultaneous. If data is transmitted one way at a time, it is referred to as half duplex. If the data can go both ways at the same time, it is full duplex. Of course, full duplex requires two wire conductors for the data lines, one for transmission and one for reception, in order to transfer and receive data simultaneously. P89LV51RD2 microcontroller has built-in UART (Universal Asynchronous Receiver-Transmitter). RS232 standards are followed for serial communication. In RS232, a logical 1 is represented by -3V to -25V, while a logical 0 by +3V to +25V, making -3V to +3V undefined. So the IC MAX232 is used to convert the TTL logic levels of microcontroller to RS232 voltage levels, and vice versa. MAX232 chip is commonly referred to as line driver.

15

MAX232 IC: It consists of 16 pins. The pin connections are as follows. Four 1uF/25V capacitors are connected between pins 1&3, 4&5, 6&GND, 2&GND. R1 IN (Pin 13) is connected to third pin of DB9 connector. T1 IN (Pin 11) is connected to P3.1 (Pin 13/TXD) of microcontroller. R1 OUT (Pin 12) is connected to P3.0 (Pin 11/RXD) of microcontroller. T1 OUT (Pin 14) is connected to second pin of DB9 connector. R2 IN, T2 IN, R2 OUT and T2 OUT are unused. Data sent by microcontroller is received at T1 IN (Pin 11) and transmitted out to PC by T1 OUT (Pin 14). Data sent by PC is received at R1 IN (Pin 13) and transmitted out to micro-controller by R1 OUT (Pin 12). Baud Rate is one of the characteristics of the serial communication. It is the speed at which the serial port transmits or receives data. Baud rate is mentioned in bps (bits per second). This baud rate is set using the Timer 1 of microcontroller running in mode 2 (8-bit auto reload mode). The baud rate which we use here is 2400bps. The SFRs associated with serial port are SBUF and SCON. SBUF register holds the data that is received by RxD line or the data that is to be transferred serially through TxD line. The SCON register is used to program the start bit, stop bit and data bits of data framing.

16

LCD DISPLAY MODULE (20 X 4)

LCD Display Module is a dot matrix liquid crystal display that displays alphanumeric characters, graphics and symbols. It has a display of four lines and 20 characters in each line. Each character has a dot matrix of 5x7 dots. The characters displayed on the LCD screen are controlled by microcontroller using either 8-bit or 4-bit interface. In this microcontroller unit the LCD is controlled through 4-bit interface. The LCD module has 2 registers, instruction command code register and data registers. These registers are selected using the RS pin of LCD. If RS is low, instruction command code register is selected. If RS is high, data register is selected. R/W pin allows us to read or write information from the LCD module. In this case R/W pin is always low, allowing us only to write information into registers. Enable pin (E) is used by LCD to latch the information present in the data pins. When data is supplied to the data pins, a High-to-Low pulse must be applied to this pin in order for the LCD to latch in the data present at the data pins. This pulse must be a minimum of 450ns wide. It has 16 pins. The pin configuration is as follows. Pin 1, 16 are grounded. Pin 2 is connected to Vcc. Pin 3 is connected to 5K potentiometer for controlling LCD contrast. Pin 4 (RS pin) is connected to P2.4 of microcontroller. Pin 5 (R/W pin) is grounded for write mode. Pin 6 (E Pin) is connected to P2.5 of microcontroller. Pin 7-10 (DB0-DB3) are unused. Pin 11-14 (DB4-DB7) are connected to P2.0 to P2.3 of microcontroller. Pin 15 is connected to P2.7 of microcontroller via BC557 Transistor.
17

In 4-bit data transfer mode, first higher nibble of data is sent followed by lower nibble. In order to set the LCD display to work in 4-bit mode the command 0x22 has to be sent first to the instruction command code register of LCD. Command words are used to clear display, set the cursor position, cursor shift direction, blinking of cursor, switching LCD on/off, etc.

PROGRAMMING THE MICROCONTROLLER

In this we programmed microcontroller using assembly and embedded C. In assembly language, the code is written as .asm file in text editor. This asm file is converted to HEX file using ASM51 software and the generated HEX file is simulated in JISM software. In C programming we have used Keil Vision3 for writing, compiling and simulating the generated HEX file. The HEX file generated in above cases is programmed on to the microcontroller using Flash Magic. We have programmed the microcontroller unit in the following order. 1) Serial port 2) LCD Display 3) Panel LEDs 4) Keypad

Serial port programming:


Initialization of the serial port involves the following steps: 1. Set the mode of serial port operation. 2. Depending on the serial mode set the baud rate using Timer 1. 3. Start the timer. Now serial port is ready to receive or transfer the data. The flow charts describing the various operations performed using the serial port are as follows:
18

Transmitting a string
Start

Receiving a string

Start

Initialize serial port

Initialize serial port

Load string, STR = string pointer

STR = string pointer

Send character onto SBUF

Is RI one

No

Increment STR

Is TI zero No TI = 0

Increment STR
Yes

Yes
Copy SBUF to STR RI = 0 No

End of

End of Yes Sto

No

Yes RI = 0

Sto

19

LCD programming: LCD has to be initialized by using various control words to get required display output. The various control words and their functions are specified in the following table. Control word 0x22 0x14 0x0F 0x06 0x01 0x0C 0x28 Function 4-bit mode Cursor shift towards right Display on, blinking cursor Increment the cursor Clear LCD Display on, cursor off Function set

Here we are using 20x4 LCD display module. Here are the control words for selecting various lines of the display screen. Control word/address 0x80 0xC0 0x94 0xD4 Selected line Line1 Line2 Line3 Line4

The LCD module consists of data, control registers to receive the respective data, commands from the microcontroller. So, by configuring them we can get the desired result. First the command mode is selected and various control words are set so that the LCD is ready for receiving the data and displaying it. The flowcharts describing them are as follows.
20

For sending a command:


Start

For sending the data:


Start

Set LCD in read mode

Set LCD in read mode

Set RS = 0 to receive commands

Set RS = 1 to receive Data

Copy the Command into TEMP

Copy the Data into TEMP

Select Upper 4 bits of TEMP

Select Upper 4 bits of TEMP

Send the 4 bits to LCD

Send the 4 bits to LCD

Latch it by H-to-L signal at E pin

Latch it by H-to-L signal at E pin

Select Lower 4 bits of TEMP

Select Lower 4 bits of TEMP

Send the 4 bits to LCD

Send the 4 bits to LCD

Latch it by H-to-L signal at E pin

Latch it by H-to-L signal at E pin

Sto

Sto 21

ZIGBEE PROTOCOL ABSTRACT


ZigBee is an IEEE 802.15.4 standard for data communications with business and consumer devices. It is designed around low-power consumption allowing batteries to essentially last forever. The ZigBee standard provides network, security, and application support services operating on top of the IEEE 802.15.4 Medium Access Control (MAC) and Physical Layer (PHY) wireless standard. It employs a suite of technologies to enable scalable, self-organizing, self-healing networks that can manage various data traffic patterns. ZigBee is a low-cost, lowpower, wireless mesh networking standard. The low cost allows the technology to be widely deployed in wireless control and monitoring applications, the low power-usage allows longer life with smaller batteries, and the mesh networking provides high reliability and larger range. ZigBee has been developed to meet the growing demand for capable wireless networking between numerous low power devices. In industry ZigBee is being used for next generation automated manufacturing, with small transmitters in every device on the floor, allowing for communication between devices to a central computer. This new level of communication permits finely-tuned remote monitoring and manipulation.

22

INTRODUCTION

ZigBee is an established set of specifications for wireless personal area networking (WPAN), i.e. digital radio connections between computers and related devices. WPAN Low Rate or ZigBee provides specifications for devices that have low data rates, consume very low power and are thus characterized by long battery life. ZigBee s possible completely networked homes where all devices are able to communicate and be controlled by a single unit. ZigBee is one of the global standards of communication protocol formulated by the relevant task force under the IEEE 802.15 working group. The fourth in the series, WPAN Low Rate/ZigBee is the newest and provides specifications for devices that have low data rates, consume very low power and are thus characterized by long battery life. Other standards like Bluetooth and IrDA address high data rate applications such as voice, video and LAN communications. ISM band, which is available throughout most of the world. In the consumer market ZigBee is being explored for everything from linking low-power household devices such as smoke alarms to a central housing control unit, to centralized light controls. The specified maximum range of operation for ZigBee devices is 250 feet (76m), substantially further than that used by Bluetooth capable devices, although security concerns raised over "sniping" Bluetooth devices remotely, may prove to hold true for ZigBee devices as well. Due to its low power output, ZigBee devices can sustain themselves on a small battery for many months, or even years, making them ideal for install-andforget purposes, such as most small household systems. Predictions of ZigBee installation for the future, most based on the explosive use of ZigBee in automated household tasks in China, look to a near future when upwards of sixty
23

ZigBee devices may be found in an average American home, all communicating with one another freely and regulating common tasks seamlessly. The ZigBee Alliance has been set up as an association of companies working together to enable reliable, cost-effective, low-power, wirelessly networked, monitoring and control products based on an open global standard. Once a manufacturer enrols in this Alliance for a fee, he can have access to the standard and implement it in his products in the form of ZigBee chipsets that would be built into the end devices. Philips, Motorola, Intel, HP are all members of the Alliance. The goal is to provide the consumer with ultimate flexibility, mobility, and ease of use by building wireless intelligence and capabilities into every day devices. ZigBee technology will be embedded in a wide range of products and applications across consumer, commercial, industrial and government markets worldwide. For the first time, companies will have a standards based wireless platform optimized for the unique needs of remote monitoring and control applications, including simplicity, reliability, low cost and low-power The target networks encompass a wide range of devices with low data rates in the Industrial, Scientific and Medical (ISM) radio bands, with building-automation controls like intruder/fire alarms, thermostats and remote (wireless) switches, video/audio remote controls likely to be the most popular applications. So far sensor and control devices have been marketed as proprietary items for want of a standard. With acceptance and implementation of ZigBee, interoperability will be enabled in multi-purpose, self-organizing mesh networks

24

CHARACTERSTICS OF ZIGBEE
The focus of network applications under the IEEE 802.15.4 / ZigBee standard include the features of low power consumption, needed for only two major modes (Tx/Rx or Sleep), high density of nodes per network, low costs and simple implementation. These features are enabled by the following characteristics, Low power consumption, with battery life ranging from months to years. Considering the number of devices with remotes in use at present, it is easy to see that more numbers of batteries need to be provisioned every so often, entailing regular (as well as timely), recurring expenditure. In the ZigBee standard, longer battery life is achievable by either of two means: continuous network connection and slow but sure battery drain, or intermittent connection and even slower battery drain. Maximum data rates allowed for each of these\ frequency bands are fixed as 250 kbps @2.4 GHz, 40 kbps @ 915 MHz, and 20 kbps @868 MHz. High throughput and low latency for low duty cycle applications (<0.1%) Channel access using Carrier Sense Multiple Access with Collision Avoidance (CSMA - CA) Addressing space of up to 64 bit IEEE address devices, 65,535 networks 50m typical range Fully reliable hand-shaked data transfer protocol. Different topologies as illustrated below: star, peer-to-peer, mesh

25

TRAFFIC TYPES
ZigBee/IEEE 802.15.4 addresses three typical traffic types. IEEE 802.15.4 MAC can accommodate all the types. 1. Data is periodic. The application dictates the rate, and the sensor activates, checks for data and deactivates. 2. Data is intermittent. The application, or other stimulus, determines the rate, as in the case of say smoke detectors. The device needs to connect to the network only when communication is necessitated. This type enables optimum saving on energy. 3. Data is repetitive, and the rate is fixed a priori. Depending on allotted time slots, called GTS (guaranteed time slot), devices operate for fixed durations. ZigBee employs either of two modes, beacon or non-beacon to enable the to-andfro data traffic. Beacon mode is used when the coordinator runs on batteries and thus offers maximum power savings, whereas the non-beacon mode finds favour when the coordinator is mains-powered. In the beacon mode, a device watches out for the coordinator's beacon that gets transmitted at periodically, locks on and looks for messages addressed to it. If message transmission is complete, the coordinator dictates a schedule for the next beacon so that the device goes to sleep'; in fact, the coordinator itself switches to sleep mode. While using the beacon mode, all the devices in a mesh network know when to communicate with each other. In this mode, necessarily, the timing circuits have to be quite accurate, or wake up sooner to be sure not to miss the beacon. This in turn means an increase in power consumption by the coordinator's receiver, entailing an optimal increase in costs. The non-beacon mode will be included in a system where devices are asleep' nearly always, as in smoke detectors and burglar alarms. The devices wake up and confirm their continued presence in the network at random intervals. On detection of activity, the sensors spring to attention', as it were, and transmit to the ever waiting coordinator's receiver (since it is mains powered). However,there

26

is the remotest of chances that a sensor finds the channel busy, in which case the receiver unfortunately would miss a call'.

ARCHITETURE
ZigBee is a home-area network designed specifically to replace the proliferation of individual remote controls. ZigBee was created to satisfy the market's need for a cost-effective, standards-based wireless network that supports low data rates, low power consumption, security, and reliability. To address this need, the ZigBee Alliance, an industry working group is developing standardized application software on top of the IEEE 802.15.4 wireless standard. The alliance is working closely with the IEEE to ensure an integrated, complete, and interoperable network for the market. For example, the working group will provide interoperability certification testing of 802.15.4 systems that include the ZigBee software layer. The ZigBee Alliance will also serve as the official test and certification group for ZigBee devices. ZigBee is the only standards-based technology that addresses the needs of most remote monitoring and control and sensory network applications. It may be helpful to think of IEEE 802.15.4 as the physical radio and ZigBee as the logical network and application software. Following the standard Open Systems Interconnection (OSI) reference model, ZigBee's protocol stack is structured in layers. The first two layers, physical (PHY) and media access (MAC), are defined by the IEEE 802.15.4 standard. The layers above them are defined by the ZigBee Alliance. The IEEE working group passed the first draft of PHY and MAC in 2003. ZigBee-compliant products operate in unlicensed bands worldwide, including 2.4GHz (global), 902 to 928MHz (Americas), and 868MHz (Europe). Raw data throughput rates of 250Kbps can be achieved at 2.4GHz (16 channels), 40Kbps at 915MHz (10 channels), and 20Kbps at 868MHz (1 channel). The transmission distance is expected to range from 10 to 75m, depending on power output and environmental characteristics. Like Wi-Fi, Zigbee uses direct-sequence spread spectrum in the 2.4GHz band, with offset-quadrature phase-shift keying modulation.
27

FRAME STRUCTURE

The four basic frame types are: Data ACK MAC Command Beacon

The data frame provides a payload of up to 104 bytes. The frame is numbered to ensure that all packets are tracked. A frame-check sequence ensures that packets are received without error. This frame structure improves reliability in difficult conditions. Another important structure for 802.15.4 is the acknowledgment (ACK) frame. It provides feedback from the receiver to the sender confirming that the packet was received without error. The device takes advantage of specified "quiet time" between frames to send a short packet immediately after the data packet transmission. A MAC command frame provides the mechanism for remote control and configuration of client nodes. A centralized network manager uses MAC to configure individual clients' command frames no matter how large the network. Finally, the beacon frame wakes up client devices, which listen for their address and go back to sleep if they don't receive it. Beacons are important for mesh and cluster-tree networks to keep all the nodes synchronized without requiring those nodes to consume precious battery energy by listening for long periods of time.

28

CHANNEL ACCESS, ADDRESSING

Two channel-access mechanisms are implemented in 802.15.4. For a non beacon network, a standard ALOHA CSMA-CA (carrier-sense medium-access with collision avoidance) communicates with positive acknowledgement for successfully received packets. In a beacon-enabled network, a super frame structure is used to control channel access. The super frame is set up by the network coordinator to transmit beacons at predetermined intervals (multiples of 15.38ms, up to 252s) and provides 16 equal-width time slots between beacons for contention-free channel access in each time slot. The structure guarantees dedicated bandwidth and low latency. Channel access in each time slot is contention-based. However, the network coordinator can dedicate up to seven guaranteed time slots per beacon interval for quality of service. Device addresses employ 64-bit IEEE and optional 16-bit short addressing. The address field within the MAC can contain both source and destination address information (needed for peer-to-peer operation). This dual address information is used in mesh networks to prevent a single point of failure with in the network.

29

DEVICE TYPES
These devices have 64-bit IEEE addresses, with option to enable shorter addresses to reduce packet size, and work in either of two addressing modes star and peer-to-peer. ZigBee networks use three device types: The network coordinator maintains overall network knowledge. It's the most sophisticated of the three types and requires the most memory and computing power. The full function device (FFD) supports all 802.15.4 functions and features specified by the standard. It can function as a network coordinator. Additional memory and computing power it ideal for network router functions or it could be used in network-edge devices (where the network touches the real world). The reduced function device (RFD) carries limited (as specified by the standard) functionality to lower cost and complexity. It's generally found in network-edge devices.

30

SECURITY
Security and data integrity are key benefits of the ZigBee technology. ZigBee leverages the security model of the IEEE 802.15.4 MAC sub layer which specifies four security services: Access controlthe device maintains a list of trusted devices within the network Data encryption, which uses symmetric key 128-bit advanced encryption standard Frame integrity to protect data from being modified by parties without cryptographic keys. Sequential freshness to reject data frames that have been replayedthe network controller compares the freshness value with the last known value from the device and rejects it if the freshness value has not been updated to a new value. The actual security implementation is specified by the implementer using a standardized toolbox of ZigBee security software.

31

THE INEVITABLE QUESTION IS WHETHER ZIGBEE AND BLUETOOTH ARE COMPETITORS OR COMPLEMENTS Bluetooth seems best suited for:

Synchronization of cell phone to PDA Hands-free audio PDA to printer

While ZigBee is better suited for:


Controls Sensors Lots of devices Low duty cycle Small data packets Long battery life is critical

Air Interface comparison: ZigBee


DSSS 11 chips/ symbol 62.5 K symbols/s 4 Bits/ symbol Peak Information Rate ~128 Kbit/second

Peak Information Rate ~108-723 kbit/second

Bluetooth
FHSS 1600 hops / second 1 M Symbol / second 1 bit/symbol
32

COMPARISON SUMMARY ZigBee and Bluetooth are two solutions for two different application areas.
The differences are from their approach to their desired application. Bluetooth has addressed a voice application by embodying a fast frequency hopping system with a master slave protocol. ZigBee has addressed sensors, controls, and other short message applications by embodying a direct sequence system with a star or peer to peer protocols. Minor changes to Bluetooth or ZigBee wont change their inherent behavior or characteristics. The different behaviors come from architectural differences.

33

PROBLEM STATEMENT
TO DESIGN A CENTRALISED TEMPERATURE MONITORING SYSTEM FOR INDUSTRIAL APPLICATIONS USING THE SPECAIL FEATURES OF ZIGBEE.

T1 T2 T3 RECEIVER

T4 T5

T6

CONTROLLER

Control Room

T7

LCD DISPLAY

BUZZER

Block diagram (Fig.3) Now we will discuss about the individual modules of the block diagram
34

TRANSMITTING UNITS: The transmitting unit basically consists of temperature sensor, ADC convertor and a zigbee transmitter. But the zigbee module itself has inbuilt ADC convertor, so we need not use an external one. Temperature sensor was dealt earlier .

Fig.4

CONFIGURE THE TRANSMITTING MODULES


35

For each of the remote modules, we'll want to: Set their address, so we can tell them apart Configure which inputs they should be reading Set how often they should read the inputs

To configure an XBee module it must be connected to the Controller's serial port, as shown in the Plugging In section. Then, remember that we need all our boards to be in packet mode - otherwise, it won't respond properly to any of our other messages. To do that, send the message /xbeeconfig/packet-mode 1

Set the address The specific address you choose doesn't matter too much, but you should remember which address you've given to which board, so you know which messages are coming back from it. I always like to put a little sticker on the module itself with the address I gave it, just so I don't get confused later. We'll set the address of our first module to 12 - so, send the message /xbeeconfig/address 12

Configure the inputs On our first module, we're just connecting a single sensor to analog in 0. So, we need to set the XBee module to read In0 as an analog in. To do this, send the message /xbeeconfig/io0 2 Note that along the right side of the XBee board, all the inputs are there, labelled AD0 - DI8. The input's number corresponds to the io property that
36

we'll use to configure it. The value that comes after that specifies whether that input is an analogin (2), a digital in (3), or disabled (0). So, to set input 8 to disabled, we'd send the message /xbeeconfig/io8 0

Set the sample rate Now we need to set how often the module should read In0. We'll set it to read every 50 milliseconds. To do that, send the message /xbeeconfig/samplerate 50 If you ever want your board to stop sending messages altogether, just set the sample rate to 0. Lastly, and very importantly, we need to remember to save all the configuration changes we've made to the module. Otherwise, it will revert to its defaults when it reboots. To save the changes, send the message /xbeeconfig/write 1 If something doesn't seem to be working quite right, you can always read back any of these settings to be sure. Now, repeat these steps for any additional modules you have, but sure to give them different addresses.

37

RECEIVING UNIT: The receiving are includes a zigbee receiver, a microcontroller, LCD display module, buzzer, serial port. As we discussed about the others early in this report now we will look at the zigbee receiver and how to configure it. Fig.5

38

Configure the Receiver Module There's not too much to do with the receiver module. But, sure it's in packet mode. Again, once you plug it in, send the messages /xbeeconfig/packet-mode 1 /xbeeconfig/write 1

Start Listening and Reading the Data The last step is to start reading in the XBee messages. To do this, the easiest thing is to use autosend. This way whenever a message from an XBee module arrives, the Controller will an OSC message out of it and send it back to us. To do this, first choose whether you want the Controller to send messages to you over USB or Ethernet. If you want Ethernet, send it the message /system/autosend-udp 1 or if you want USB, send the message /system/autosend-usb 1 Next, decide how often you want the Controller Kit to check for new messages. We'll have it look every 10 milliseconds, or 100 times a second. To do this, send the message /system/autosend-interval 10 Lastly, turn the XBee autosend on. /xbee/autosend 1 Now, you should have the sensors plugged into the remote XBee modules and the receiver module plugged into the Controller. If you've done everything successfully, you should see a bunch of messages streaming into mchelper that

39

look like /xbee/io16 12 31 1023 0 0 0 0 0 0 0 This is a message back from one of the remote modules. As is explained in the OSC reference, the first two numbers are: 1. the address of the module that sent the message (12 in the example above) 2. signal strength (31 above) The next 9 numbers are the values from the 9 IO pins on the XBee module. So, this is a message back from the board that we gave address 12, and 1023 is the value from the sensor that we have plugged into In0 on that module. Admittedly, seeing all that data streaming into mchelper is not all that helpful. But, it is a good way to confirm that we're getting messages back from the modules. Now you're ready to head into your environment of choice and start reading all sorts of XBee goodness.

40

MODES OF COMMUNICATION
Some concepts going over how the XBee modules communicate with the Controller. The XBee modules have two modes of operation: 1. Transparent serial port mode. This mode is the simplest - you send data over a Controller's serial port to an XBee module which sends that data wirelessly to another XBee module, also presumably connected to a Controller, which can then read the data from the serial port. So, it's like a big, wireless serial connection between the two Controllers, hence the name.

2. Packet mode. If you want to actually send messages to the XBee module itself, however, you need a way to distinguish that from data that should be sent transparently. There are a few different kinds of packets, but we'll most concern ourselves here with IO packets and command packets. IO packets are what an XBee module sends when it has sampled its inputs. Command packets are used to set some configuration option for the module itself. Packet mode is nice because then we get to see a bunch of important information about each packet who it came from, the signal strength, and things like that. We'll be using the modules pretty much exclusively in packet mode.

41

RECEIVING PACKETS
For the most part, incoming packets aren't too interesting if they just show up at your XBee module - unless they're directly controlling its output pins, for example. Otherwise, you'll want to get the info in the incoming packet to the Make Controller and/or up to your computer. If you're doing this in firmware, all you need is the XBee_GetPacket( ) function. Over OSC, however, you have a couple options: 1. You can periodically send the Make Controller a request for new packets. If any have arrived, since you last asked they'll be sent back to you. Unfortunately, the problem with this is that the Make Controller only has room to hang onto a couple of packets at a time - any packets that arrive after it's full will be lost. To get around this,

2. You can use the autosend capability. The Make Controller itself will constantly be checking for new packets and when one arrives, it will send it out automatically. To do this, turn autosend on by sending the message

/xbee/autosend 1 Then, you need to set how often you want the Make Controller to check for new messages, and whether to send it over Ethernet (Udp) or USB. /system/autosend-interval 10 /system/autosend-usb 1 So we just set it to check for new messages every 10 milliseconds (100 times a second) and to send those messages over USB. If we wanted them to be sent over Ethernet, we would send the message /system/autosend-udp 1

42

OTHER CONFIGURING ASPECTS


IO Configuration Configure the input/output capabilities of an XBee module. There are 9 IO pins on the XBee module, abeled AD0-AD6, DIO7 and DI8. AD0 - AD6 can be set as digital or analog inputs, DIO7 can be a digital in or out, and DI8 can only act as a digital in. Pins can be set to one of 5 values:

0 - Disabled 2 - Analog Input 3 - Digital Input 4 - Digital Out High/On 5 - Digital Out Low/Off

In OSC, use the /xbeeconfig/io properties to do this - just append the number of the input pin onto the io part of the message. For example, to configure AD4 as an analog in, we'd send the message /xbeeconfig/io4 2 Note that we added the 4 on the end of io and used 2 to specify that it should be an analog in. To do this in firmware check the XBeeConfig_SetIO( ) function. Sample Rate If an XBee module's sample rate is set to anything greater than 0, it will read all its input pins at that rate and send a message with the values. Once you turn the sample rate on, properly addressed modules will receive IO packets from that module. To set the sample rate to once every 10 milliseconds via OSC, send the message /xbeeconfig/samplerate 10 To do this in firmware check the XBeeConfig_SetSampleRate( ) function.
43

Once you've set some values, try reading them back to make sure you can communicate successfully with the module. If this doesn't even work, go back and check your work - bad connections are always a likely suspect. As was previously mentioned, there are all sorts of additional configuration options for the XBee modules. It's not practical to reproduce the entire manual in this tutorial, but you can download it from our datasheets section. Addressing How to make sure your messages go where you want. There are 3 values that allow you to organize your XBee module address space: 1. Individual module addresses 2. PAN (Presonal Area Network) IDs 3. Channels For two modules to communicate, they must be on the same channel, have the same PAN ID and the destination address of the sender must match the address of the receiver. Each XBee module has its own unique address, as well as a destination address that it sends its messages to. The destination address can specify a single destination or it can be a broadcast address, which will be received by all XBee modules within range. The broadcast address is 65535 (0xFFFF in hex). If you only have a couple modules, you'll probably never need to change the PAN ID or channel. But if you're in an evironment with a bit more traffic, you might want to be sure that nobody else's messages are getting mixed up with yours, so this offers a nice option for that.

Unique and Broadcast Addresses XBee modules can be used with 16-bit addresses or 64-bit addresses. 16 bits already gives you 65536 possible unique values, but hey you never know when you might need number 65537, right? Any time a module's address is less than 0xFFFE, it will use 16-bit addresses. When the module's address is set to 0xFFFF or 0xFFFE, it will use a 64-bit address derived from its internal serial
44

number. There are 2 values that configure the destination address - DH (Destination High) and DL (Destination Low). If DH is set to 0, as it is by default, the board will send to a 16-bit address. To send broadcast messages, which will be received by all modules on that channel and PAN, set DH 0x0000FFFF to and DL to 0x00000000 (default value). The above mentioned functions are included in the appendix. So, after configuring the microcontroller we all our requirements with above mentioned modes and communication types it serves our purpose.

45

CONCLUSION

With the idea of temperature control system described in this report we can develop a low cost, highly efficient, reliable and inbuilt security model for real time applications and successfully implement it on a large scale. This is model is differentiated with other models of this kind by its unique usage of zigbee protocol. It is likely that ZigBee will increasingly play an important role in the future of computer and communication technology. In terms of protocol stack size, ZigBee's 32 KB is about one-third of the stack size necessary in other wireless technologies (for limited capability end devices, the stack size is as low as 4 KB). The IEEE 802.15.4based ZigBee is designed for remote controls and sensors, which are very many in number, but need only small data packets and, mainly, extremely low power consumption for (long) life. Therefore they are naturally different in their approach to their respective application arenas. The ZigBee Alliance targets applications "across consumer, commercial, industrial and government markets worldwide". Unwired applications are highly sought after in many networks that are characterized by numerous nodes consuming minimum power and enjoying long battery lives. ZigBee technology is designed to best suit these applications, for the reason that it enables reduced costs of development and very fast market adoption.

46

APPENDIX
lcd.h #define TRANSTIME 10 #define PORT P2 sbit RS = P2^4; sbit EN = P2^5; void lcd_init(void); void lcd_write(unsigned char); void lcd_cmd(unsigned char); void lcd_data(unsigned char); void lcd_string(unsigned char *); lcd.c #include <reg51.h> #include "lcd.h" #include "serial.h" #include "delay.h" void lcd_init(void) { lcd_cmd(0x22); lcd_cmd(0x28); lcd_cmd(0x14); lcd_cmd(0x0f); lcd_cmd(0x06); lcd_cmd(0x01); } void lcd_write(unsigned char write) {
47

PORT=(PORT&0xF0)|write; EN=1; msdelay(TRANSTIME); EN=0; } void lcd_cmd(unsigned char cmd) { RS=0; lcd_write((cmd&0xf0)>>4); lcd_write(cmd&0x0f); } void lcd_data(unsigned char dat) { RS=1; lcd_write((dat&0xf0)>>4); lcd_write(dat&0x0f); } void lcd_string(unsigned char * str) { unsigned char ch=0; while(*str != '\0'&&(ch<20)) { lcd_data(*str); str++; ch++; } } Serial.h void serial_init(void); void send_char(unsigned char);
48

unsigned char rec_char(void); void send_string(unsigned char *); void rec_string(unsigned char *); serial.c #include <reg51.h> #include <string.h> #include "serial.h" #include "delay.h" #define SEC 1001 void serial_init(void) { TMOD=0X20; TH1=0XF3; //2400 BAUD RATE(FOR 12MHZ CRYSTAL) SCON=0X50; TR1=1; } void send_char(unsigned char send) { SBUF=send; while(TI==0); TI=0; } unsigned char rec_char(void) { unsigned char rec; while(RI==0); rec=SBUF; RI=0; return rec;
49

} void send_string(unsigned char *str) { unsigned char loop; unsigned char len; len=strlen(str); for(loop=0;loop<len;loop++) { SBUF=str[loop]; while(TI==0); TI=0; } } void rec_string(unsigned char *rec) { unsigned int n=0; unsigned char c; while(1) { c=rec_char(); if(c!=0x0D) { rec[n]=c; n++; } else { rec[n]='\0'; break; } } }

50

ZIGBEE:
bool XBee_CreateTX16Packet ( XBeePacket * xbp, uint8 uint16 uint8 uint8 * uint8 ) Create a packet to be transmitted with a 16-bit address. If the frameID is 0, you won't receive a TX Status message in response. Parameters: xbp frameID The XBeePacket to create. The frame ID for this packet that subsequent response/status messages can refer to. Set to 0 for no response. destination The destination address for this packet. Broadcast Address: 0xFFFF. options The XBee options for this packet (0 if none). data A pointer to the data to be sent in this packet. Up to 100 bytes. datalength The number of bytes of data to be sent. Maximum 100 bytes. Returns: True on success, false on failure. Example
XBeePacket txPacket; uint8 data[] = "ABC"; XBee_CreateTX16Packet( &txPacket, 0x52, 0, 0, data, 3 ); XBee_SendPacket( &txPacket, 3 );

frameID, destination , options, data, datalength

bool XBee_ReadIO16Packet ( XBeePacket * xbp, uint16 * uint8 * uint8 * int * ) Unpack the info from an incoming IO packet with a 16-bit address. When an XBee module has been given a sample rate, it will sample its IO pins according to their current configuration and send an IO packet with the sample data. This function will extract the sample info into an array of ints for you. There are 9 IO pins on the XBee modules, so be sure that the array you pass in has room for 9 ints. Pass NULL into any of the parameters you don't care about. Parameters: xbp The XBeePacket to read from. srcAddress A pointer to a uint16 that will be filled up with the 16-bit address of this packet. sigstrength A pointer to a uint8 that will be filled up with the signal strength of this packet. srcAddress, sigstrength , options, samples

51

options samples

A pointer to a uint8 that will be filled up with the XBee options for this packet. A pointer to an array of ints that will be filled up with the sample values from this packet.

Returns: True on success, false on failure. See also: XBeeConfig_SetSampleRate( ), XBeeConfig_SetIOs( ) Example
XBeePacket rxPacket; if( XBee_GetPacket( &rxPacket, 0 ) ) { uint16 src; uint8 sigstrength; int samples[9]; if( XBee_ReadIO16Packet( &rxPacket, &src, &sigstrength, NULL, samples ) ) { // then process the new packet here XBee_ResetPacket( &rxPacket ); // and clear it out before reading again } }

52

LIST OF ILLUSTRATIONS

Fig.1 Block diagram showing single transmitter and single receiver Fig.2 The block diagram showing internal architecture of NXP P89LV51RD2. Fig.3The block diagram of problem statement. Fig.4 The pin diagram of XBEE module. Fig.5 The pin diagram of receiving unit

Page 7

Page 14

Page 34 Page 35 Page 38

53

REFERENCES
1.Smart Wireless Temperature Data Logger Using IEEE 802.15.4/ZigBee
Protocol Vivek Kumar Sehgal*1, Nitin2, Durg Singh Chauhan3 , Rohit Sharma4 ,1,2,3,4Member, IEEE and ACM 1,3,4, Department of ECE, 2Department of CSE and IT, Jaypee University of Information Technology Waknaghat, Solan (HP) INDIA 2.ZigBee Technology: Wireless Control that Simply Works Patrick Kinney Kinney consulting LLC chair of IEEE 802.15.4 task group secretary of Zigbee BoD chair building automation profile WG 3. The role of zigbee technology in future data communication system Dr.S.S.Riaz Ahamed. Professor & Head, Dept of Computer Applications, Mohamed Sathak Engg College,Kilakarai & Principal, Sathak Institute of Technology, Ramanathapuram,TamilNadu, India-623501. 4. XBee%20Wireless%20Interface%20%20MakingThings.htm 5. Make%20Controller%20Kit%20-%20Firmware%20API%20%20XBee.htm

54

S-ar putea să vă placă și