Beruflich Dokumente
Kultur Dokumente
Project Report submitted in partial fulfillment of the requirements for the award of the degree of Bachelor of Technology in
DEPARTMENT OF ELECTRONICS & INSTRUMENTATION ENGINEERING GITAM INSTITUTE OF TECHNOLOGY GITAM UNIVERSITY VISAKHAPATNAM-530045 ANDHRA PRADESH
DEPARTMENT OF ELECTRONICS & INSTRUMENTATION ENGINEERING GITAM INSTITUTE OF TECHNOLOGY GITAM UNIVERSITY VISAKHAPATNAM-530045 ANDHRA PRADESH
DEPARTMENT OF ELECTRONICS & INSTRUMENTATION ENGINEERING GITAM INSTITUTE OF TECHNOLOGY GITAM UNIVERISTY VISAKHAPATNAM-530045
CERTIFICATE
This is to certify that project work entitled SECURITY MANAGEMENT SYSTEM FOR OILFIELD BASED ON ZIGBEE has been carried out by the following students under my guidance in the partial fulfillment of the requirements for the award of degree of Bachelor of Technology in Electronics & Instrumentation Engineering submitted to the Department of Electronics & Instrumentation Engineering, GITAM INSTITUTE of TECHNOLOGY, GITAM UNIVERSITY, Visakhapatnam, during the year 2011-2012.
Signature of Guide
ACKNOWLEDGEMENT
We express our profound sense of gratitude to our guide Sri L Srinivas Rao, Assistant Professor, Dept. of Electronics & Instrumentation Engineering, GITAM University for the brilliant and gracious and unstinted cooperation through out our work. He spared his valuable time and spared project report with keen interest. This project report would not have been shaped to this form without his encouragement and cooperation.
We also express our thanks to Dr. D. Elizabeth Rani, Head of the Department of Electronics & Instrumentation engineering for the encouragement and support given to us.
We are thankful to other staff members of the college for their encouragement and valuable suggestions during the project work.
Abstract
With rapid development of national economic construction, there is a great demand and dependent on petroleum in various industries. The international price of petroleum has been kept at a high level in recent years, so production efficiency on domestic oilfield is urgently needed to be improved, new requirements for oilfield information construction is raised, construction of information and digitalization become development direction for oilfield. The first level consists of some remote controllers and a launcher, which include wireless fire alarm and burglar alarm; and some water sprinkling mechanism. The second level consists of a wireless receiver and a wireless alarm controller in the system. The core of a wireless receiver and some launchers adopt advanced embedded technology. The wireless communication system which we are going to use is zigbee. ZigBee is a low-cost, low-power, wireless mesh network standard. The low cost allows the technology to be widely deployed in wireless control and monitoring applications. Low power-usage allows longer life with smaller batteries. Mesh networking provides high reliability and more extensive range.
CONTENTS
1. 2.
Introduction
Embedded System 2.1 Embedded System 2.2 Real Time System 2.3 Categories of Embedded System 2.4 Gartner Corporation Categories 2.5 Applications of Embedded System 2.6 Microcontrollers 2.6.1 Introduction 2.6.2 Microcontroller vs Microprocessor 2.6.3 Advantages of Microcontroller 2.6.4 Types of 8051 Microcontroller 2.6.5 Features 2.7 Microcontroller 8051 2.7.1 Introduction 2.7.2 Description 2.7.3 Features 2.7.4 Microcontroller Architecture 2.7.5 Features of 89C51 2.7.6 Pin Description 2.7.7 Input-Output Ports 2.7.8 Memory in Microcontroller 2.7.9 Using Timers to Measure Time
3.
ZigBee Wireless Communication 3.1 Introduction 3.2 ZigBee Characteristics 3.3 Frame Structure
4.
Hardware Design 4.1 Block Diagram 4.1.1 Transmitter Side 4.1.2 Receiver Side
4.2 Power supply 4.3 Serial Communication 4.4 Synchronous And Synchronous Communication 4.5 Drivers for Serial Communication 4.5.1 RS 232 4.5.2 MAX 232 4.6 Drivers for Relay 4.7 Zigbee module: Tarang 4.8 Buzzer 4.9 LCD Display 5. Software 5.1 Keil Software 5.2 Getting Started and Creating Application 5.2.1 Evaluation Kits and Development Kits. 5.2.2 Types of users 5.3 Vision IDE 5.3.1 About the Environment 5.3.2 Menu, Commands, Toolbars and Shortcuts 5.3.4 Vision Features 5.4 Advantages 5.5 Using Keil 5.6 Programming the Chip 5.6.1 Intelligent Universal Programmer 6. Source Code 6.1 Transmitter Side 6.2 Receiver Side 7. Conclusion
1. INTRODUCTION
With rapid development of national economic construction, there is a great demand and dependent on petroleum in various industries. The international price of petroleum has been kept at a high level in recent years, so production efficiency on domestic oilfield is urgently needed to be improved, new requirements for oilfield information construction is raised, construction of information and digitalization become development direction for oilfield. The Distribution State of working environment in oilfield is very special, the site of oilwell is distributed dispersedly, but distribution area is widely, oil exhauster continuous working for 24h, regional of Perambulation for the site of oil-well is very vast, meanwhile, as for the problem of petroleum' being stolen, transmission line' being stolen, transformer' being stolen, which has been one of the important management works. With Consideration of the objective condition restriction of geographical environment, the implementation of safe management for oilfield is very difficult. We overcome these difficulties, which comes from geographical environment. the cost is not only high if the fiber cable would be lay between working station in the several tens of square kilometers, but also need to put into a lot of human and material resources with line maintenance and guard against theft. It is a perfect scheme that remote wireless monitoring and control system is established. This system can improve the level of oilfields security; enhance the security checking management of digitization and information. The method could solve problems with highly efficient and rapid, also could reduce the loss of country with effective. So it has the important significance and social and economic benefits for the dependability and controllability of remote communication.
2. EMBEDDED SYSTEM
A system of priority inheritance must exist And it should be: Scalable Configurable Small footprint CPU support Device drivers
estimated that 7% of these will have transient Year 2000 problems; 2% may have Persistent problems. Large-scale systems: Computer with a hard disc drive is connected to equipment that may incorporate Microprocessors. The failure rate for these systems is estimated at 35%.
Satellites Mobile telephones Banking, finance and commercial: Automated teller systems Credit card systems Medical and life support: Heart defibrillators Pacemaker monitors X-ray equipment Testing, monitoring and diagnostic systems: Energy metering Environmental-monitoring equipment
This system is designed around a soft microcontroller AT89C51. This system basically consists of a) Power Supply b) Max 232 c) ULN 2003 d) Oscillatory Circuit e) Stepper Motors - For generating the required power to the circuit setup - For serial communication - For Interfacing with the stepper motors - For providing the delay - For open the door
2.6 Microcontrollers:
2.6.1 Introduction:
A microcontroller is an integrated chip that is often part of an embedded system. The microcontroller includes a CPU, RAM, ROM, I/O ports, and timers like a standard Computer, but because they are designed to execute only a single specific task to control a single system, they are much smaller and simplified so that they can include all the functions required on a single chip. A microcontroller differs from a microprocessor, which is a general-purpose chip that is used to create a multi-function computer or device and requires multiple chips to handle various tasks. A microcontroller is meant to be more self-contained and independent, and functions as a tiny, dedicated computer. The great advantage of microcontrollers, as opposed to using larger microprocessors, is that the parts-count and design costs of the item being controlled can be kept to a minimum. They are typically designed using CMOS (complementary metal oxide semiconductor) technology, an efficient fabrication technique that uses less power and is more immune to power spikes than other techniques.
There are also multiple architectures used, but the predominant architecture is CISC (Complex Instruction Set Computer), which allows the microcontroller to contain multiple control instructions that can be executed with a single macro instruction. Some use a RISC (Reduced Instruction Set Computer), architecture, which implements fewer instructions, but delivers greater simplicity and lower power consumption.
80C154, low voltage static variants 80C154, mask parts 87C748 through 89C588, mostly old legacy 8051 parts from Signetics 80C501 through 80C517A, and a wide variety of CAN devices. COM20051 with ARCNET token bus network engine 80x52, 2 x HDLC variant for MODEM use
2.6.5 Features:
Compatible with MCS-51 Products 4K Bytes of In-System Reprogrammable Flash Memory Endurance: 1,000 Write/Erase Cycles Fully Static Operation: 0 Hz to 24 MHz Three-level Program Memory Lock 128 x 8-bit Internal RAM 32 Programmable I/O Lines Two 16-bit Timer/Counters Six Interrupt Sources Programmable Serial Channel
In Addition to NV RAM, Dallas semiconductors offer a number of peripherals that simply reduce the cost of embedded systems. Although the specific features of each chip or module vary, all devices offer the following basic features set: 100% code-compatible with 8051 Directly addresses 64 KB program/64KB data memory. Non volatile memory control circuitry. 10-years data retention in the absence of power In-system reprogramming via serial port. 128 bytes fast access scratchpad RAM Two 16 bit general-purpose timer/counters One UART Five interrupts with two external Dedicated memory bus, preserving four 8-bit ports for general purpose I/O Power-fail reset Early warning power-fail interrupts. Watchdog timer.
TIMER/COUNTER
INTERNAL ROM
PROGRAM COUNTER
2.1 Functional Block Diagram of Microcontroller
Most microcontrollers will also combine other devices such as: A Timer module to allow the microcontroller to perform tasks for certain time periods. A serial I/O port to allow data to flow between the microcontroller and other devices such as a PC or another microcontroller. An ADC to allow the microcontroller to accept analogue input data for processing.
2.7.2 Description:
The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 and 80C52 instruction set and pin out.
The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer, which provides a highly flexible and cost-effective solution to many embedded control applications. The AT89C51 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM, 32 I/O lines, two 16-bit timer/counters, a six-vector two-level interrupt architecture, a full-duplex serial
port(UART) which operates at 11.0592 MHz, on-chip oscillator, and clock circuitry. In addition, the AT89C51 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM; timer/counters, serial port, and interrupt system to continue functioning. The Powerdown mode saves the RAM contents but freezes the oscillator, disabling all other chip functions until the next hardware reset.
2.7.3 Features:
8 bit 8051-compatible microcontroller adapts to task at hand. 8 or 32 k bytes of nonvolatile RAM for program and /or data memory storage. Initial downloading software in end system via on chip serial port. Capable of modifying its own program and/or date memory in end use. Crash proof operation: Maintains all nonvolatile resources for 10 years in the absence of VCC. Power-Fail Reset. Early Warning power-Fail Interrupt. Watchdog Timer. Software security feature: Executes encrypted software to prevent unauthorized disclosure. On-chip, full-duplex serial I/O ports. Two on-chip timer/events counter 32 parallel I/O lines. Compatible with industry standard 8051 instruction set and pin out. Optional permanently powered real timer clock.
Bus Organization
There are four major buses in the secure microprocessor: the internal data bus, the internal address bus, the byte wide memory bus, and the expanded bus. All addresses and data that are transferred during program execution are passed on the internal address and data buses. User program and data memory is always accessed from either the byte wide program/data RAM or from external memory located on the expanded bus. The byte wide memory bus allows access memory located on the expanded bus. The byte wide memory bus allows access to program/data RAM in the sane way as an 8051 family device would access internal ROM or EPROM memory.
This bus can be used in place of the expanded bus, freeing Port2 and Port0 pins for general I/O use. CPU Registers: The CPU registers are mapped as special function registers (SFRs). They are identical in number and function to those prevents within the 8051. These registers are described briefly. Accumulator: The accumulator (A or ACC) is used as either a source and/or destination register in all arithmetic instructions. It may also be sued in most other types of instructions. Stack Pointer: The stack pointer (SP) is an 8 bit register that marks the location of the last byte of data stored in the stack. The stack itself can be located anywhere in the on-chip 128 byte scratchpad register area. The stack pointer pre-increments during a stack push and post-decrements during a stack pop. Program Status Word: The Program status word (PSW) contains status flags that are set according to the results of a previously executed instruction. In addition, the PSW contains register bank select bits. Data Pointer: The Data pointer (DPTR) is used to access data memory that can be mapped into byte wide data RAM or onto external memory devices on the expanded bus. The DPTR is accessed by the users program as either two 8 bit SFRs or as a 16-bit register with certain instructions. Programmable Timers: Two 16 bit programmable timers are included that can perform various timing and counting functions. Four registers (TH1, TL1, TH0 and TL0) access the upper and lower halves of each of the two timer/counters. A single control register (TCON) is used to select the various operating modes of the two timers. Two external I/O pins (P3.4, P3.5) can be programmed to serve as external counter inputs, one pin for each of the two timer/counters. Parallel I/O: Four SFRs provide access for the four parallel I/O port latches. These I/O ports are denoted as P0, P1, P2 and P3. 32 bits of parallel I/O is available through these I/O ports. However, up to 16 bits are sacrificed when the expanded bus mode is used to interface to
external memory and up to 6 bits can be sacrificed if any external interrupt inputs, timer counter inputs, or serial I/O functions are used. When using the byte wide bus, ports are not affected. Atmel At89c51 Pin out and Description: The smallest current device is the ATMEL 89c51, a 40 Pin FLASH variant with 2 timers, UART, 500mA. ATMEL was the first with standard FLASH, and with more program cycles than other custom FLASH. These parts compete with OTP and MASK product on price, but eliminate inventory problems and the hidden costs of OTP development. Why we go for AT89C51? The AT89C51 is a low power, high performance CMOS 8-bit microcontroller with 4Kbytes of Flash programmable and erasable read only memory (PEROM). This device is compatible with the industry standard 8051 instruction set and pin out. The on-chip Flash allows the program memory to be quickly reprogrammed using a nonvolatile memory programmer such as the PG302 (with the ADT87 adapter). By combining an industry standard 8-bit CPU with Flash on a monolithic chip, the 8951 is a powerful microcomputer which provides a highly flexible and cost effective solution to many embedded control applications.
-Timer 1 7. It has full duplex asynchronous serial port. 8. It can support up to 64KB of external memory with the help of PC and DPTR. 9. It has 16-bit address bus. 10. Six interrupts with two priority levels -2 general purpose interrupts (INT0, INT1). -4 preprogrammed interrupt (Timer0, Timer1, Serial interrupt, Reset interrupt). 11. Wide range of frequency of operation (0 to 24 MHz). 12. It will operate on 5V dc supply. 13. It can support maximum of 500mA of current.
In addition, the 89C51 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial Port and interrupt system to continue functioning. The Power Down Mode saves the RAM contents but freezes the oscillator disabling all other chip functions until the next hardware reset.
10-17: Port 3: As with Port 1, each of these pins can be used as universal input or output. However, each pin of Port 3 has an alternative function Pin 10: RXD - Serial input for asynchronous communication or serial output for synchronous communication.
Pin 11: TXD - Serial output for asynchronous communication or clock output for synchronous communication Pin 12: INT0 - Input for interrupt 0 Pin 13: INT1 - Input for interrupt 1 Pin 14: T0 - Clock input of counter 0 Pin 15: T1 - Clock input of counter 1 Pin 16: WR - Signal for writing to external (add-on) RAM memory Pin 17: RD - Signal for reading from external RAM memory 18-19: X2 and X1: Input and output of internal oscillator. Quartz crystal controlling the frequency commonly connects to these pins. Capacitances within the oscillator mechanism (see the image) are not critical and are normally about 30pF. New MCUs work at frequencies from 0Hz to 50MHz+.
20: GND: Ground 21- 28: Port 2: If external memory is not present, pins of Port 2 act as universal input/output. If external memory is present, then these pins serve as the location of the higher address byte, i.e. addresses A8 A15. It is important to note that in cases when not all the 8 bits are used for addressing the memory (i.e. memory is smaller than 64kB), the rest of the unused bits are not available as input/output. 29: PSEN: MCU activates this bit (brings to low state) upon each reading of byte (instruction) from program memory. If external ROM is used for storing the program, PSEN is directly connected to its control pins. 30: ALE: Before each reading of the external memory, MCU sends the lower byte of the address register (addresses A0 A7) to port P0 and activates the output ALE. External register (74HCT373 or 74HCT375 circuits are common), memorizes the state of port P0 upon receiving a signal from ALE pin, and uses it as part of the address for memory chip. During the second part of the mechanical MCU cycle, signal on ALE is off, and port P0 is used as Data Bus. In this way, by adding only one cheap integrated circuit, data from port can be multiplexed and the port simultaneously used for transferring both addresses and data. 31: EA: Bringing this pin to the logical state zero designates the ports P2 and P3 for transferring addresses regardless of the presence of the internal memory. This means that even if there is a program loaded in the MCU it will not be executed, but the one from the external ROM will be used instead. Conversely, bringing the pin to the high logical state causes the controller to use both memories, first the internal, and then the external (if present). 32-39: Port 0: Similar to Port 2, pins of Port 0 can be used as universal input/output, if external memory is not used. If external memory is used, P0 behaves as address output
(A0 A7) when ALE pin is at high logical level, or as data output (Data Bus) when ALE pin is at low logical level. 40: VCC: Power +5V
Port 3 Beside its role as universal I/O port, each pin of Port 3 has an alternate function. In order to use one of these functions, the pin in question has to be designated as input, i.e. the appropriate bit of register P3 needs to be set. From a hardware standpoint, Port 3 is similar to Port 0.
On-Chip Memory refers to any memory (Code, RAM, or other) that physically exists on the microcontroller itself. External Code Memory is code (or program) memory that resides off-chip. This is often in the form of an external EPROM. External RAM is RAM memory that resides off-chip. This is often in the form of standard static RAM or flash RAM. During the runtime, microcontroller uses two different types of memory: one for holding the program being executed (ROM memory), and the other for temporary storage of data and auxiliary variables (RAM memory). ROM memory In this MCU contain 4 kilobytes of the flash memory on the chip. It is of EEPROM. We can use 12v to program MCU. This option is cost-effective only for large series. The main purpose of ROM is to store the programs to be executed.
RAM memory
RAM is used for storing temporary data and auxiliary results generated during the runtime. Apart from that, RAM comprises a number of registers: hardware counters and timers, I/O ports, buffer for serial connection, etc. With older versions, RAM spanned 256 locations, while new models feature additional 128 registers. First 256 memory locations form the basis of RAM (addresses 0 FFh) of every 8051 MCU. Locations that are available to the user span
addresses from 0 to 7Fh, i.e. first 128 registers, and this part of RAM is split into several blocks as can be seen in the following figure.
The main purpose of RAM is to provide synchronization between ROM and CPU so as to increase the speed of microcontroller. Bit Memory The 8051, being a communications-oriented microcontroller, gives the user the ability to access a number of bit variables. These variables may be either 1 or 0. There are 128 bit variables available to the user, numbered 00h through 7Fh. Special Function Register (SFR) Memory Special Function Registers (SFRs) are areas of memory that control specific functionality of the 8051 processor. It may appear that SFR is part of Internal Memory. However, when using this method of memory access (its called direct address), any instruction that has an address of 00h through 7Fh refers to an Internal RAM memory address; any instruction with an address of 80h through FFh refers to an SFR control register. Register Banks General Purpose registers:
The 8051 uses 8 "R" registers which are used in many of its instructions. These "R" registers are numbered from 0 through 7 (R0, R1, R2, R3, R4, R5, R6, and R7). These registers are generally used to assist in manipulating values and moving data from one memory location to another. SFR Registers (Special Function Registers) SFR registers can be seen as a sort of control panel for managing and monitoring the microcontroller.
Timers: The 8051 comes equipped with two timers, both of which may be controlled, set, read, and configured individually. The 8051 timers have three general functions:
1) Keeping time and/or calculating the amount of time between events, 2) Counting the events themselves, or 3) Generating baud rates for the serial port.
When this bit is set the timer will count events on T1 6 C/T1 (P3.5). When this bit is clear the timer will be 1 incremented every machine cycle. 5 4 T1M1 T1M0 Timer mode bit (see below) Timer mode bit (see below) When this bit is set the timer will only run when INT0 3 GATE0 (P3.2) is high. When this bit is clear the timer will run 0 regardless of the state of INT0. When this bit is set the timer will count events on T0 2 C/T0 (P3.4). When this bit is clear the timer will be 0 incremented every machine cycle. 1 0 T0M1 T0M0 Timer mode bit (see below) Timer mode bit (see below) 0 0 1 1
Four bits (two for each timer) are used to specify a mode of operation. The modes of operation are: TxM1 0 0 1 TxM0 0 1 0 Timer Mode 0 1 2 Description of Mode 13-bit Timer. 16-bit Timer 8-bit auto-reload
The TCON SFR There is one more SFR that controls the two timers and provides valuable information about them. The TCON SFR has the following structure: TCON (88h) SFR Bit Address
Bit Name
Explanation of Function
Timer
TF1
8Fh
Timer 1 Overflow. This bit is set by the microcontroller when Timer 1 overflows. Timer 1 Run. When this bit is set Timer 1 is turned on. When this bit is clear Timer 1 is off. Timer 0 Overflow. This bit is set by the microcontroller when Timer 0 overflows.
TR1 8Eh
TF0
8Dh
TR0 8Ch
Timer 0 Run. When this bit is set Timer 0 is turned on. When this bit is clear Timer 0 is off.
Only four bits of SFR are used for timers, the remaining four are used for interrupts.
Interfaces: The digital I/O ports are the means by which the microcontroller interfaces to the environment. Digital I/O tends to be grouped into byte wide ports (8 digital bits) that can be configured as either input bits or output bits.
3.1 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 makes possible completely networked homes where all devices are able to communicate and be controlled by a single unit. The ZigBee Alliance, the standards body which defines ZigBee, also publishes application profiles that allow multiple OEM vendors to create interoperable products. The current list of application profiles either published or in the works are: Home Automation ZigBee Smart Energy Telecommunication Applications Personal Home The relationship between IEEE 802.15.4 and ZigBee is similar to that between IEEE 802.11 and the Wi-Fi Alliance. For non-commercial purposes, the ZigBee specification is available free to the general public. An entry level membership in the ZigBee Alliance, called Adopter, costs US$ 3500 annually and provides access to the as-yet unpublished specifications and permission to create products for market using the specifications. 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. ZigBee devices are actively limited to a throughrate of 250Kbps, compared to Bluetooth's much larger pipeline of 1Mbps, operating on the 2.4 GHz 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-and-forget 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 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 enrolls 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.
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
PAN Coordinator
Star Topology
Communications Flow
1
2 The data frame is illustrated below:
The Physical Protocol Data Unit is the total information sent over the air. As shown in the illustration above the Physical layer adds the following overhead: Preamble Sequence Start of Frame Delimiter Frame Length 4 Octets 1 Octet 1 Octet
In summary the total overhead for a single packet is therefore 15 -31 octets (120 bits); depending upon the addressing scheme used (short or 64 bit addresses). Please note that these numbers do not include any security overhead.
For low latency applications or applications requiring specific data bandwidth, the PAN coordinator may dedicate portions of the active superframe to that application. These portions are called guaranteed time slots (GTSs). The guaranteed time slots comprise the contention free period (CFP), which always appears at the end of the active superframe starting at a slot boundary immediately following the CAP, as shown in Figure 5. The PAN coordinator may allocate up to seven of these GTSs and a GTS may occupy more than one slot period. However, a sufficient portion of the CAP shall remain for contention based access of other networked devices or new devices wishing to join the network. All contention based transactions shall be complete before the CFP begins. Also each device transmitting in a GTS shall ensure that its transaction is complete before the time of the next GTS or the end of the CFP.
4. HARDWARE DESIGN
BLOCK DIAGRAM
MOTOR MOTOR
OSCILLATORY CIRCUIT
M AX 23 2 circ uit
ZIGBEE
BLOCK DIAGRAM
RESET CIRCUIT
BUZZER ATMEL 89C51 CONTROLLER
LCD
OSCILLATORY CIRCUIT
M AX 23 2 circ uit
ZIGBEE
Transformer
A bridge rectifier coupled with a step down transformer is used for our design. The voltage rating of transformer used is 0-12V and the current rating is 500mA. When AC voltage of 230V is applied across the primary winding an output AC voltage of 12V is obtained. One alteration of input causes the top of transformer to be positive and the bottom negative. The next alteration will temporarily cause the reverse.
Rectifier
In the power supply unit, rectification is normally achieved using a solid state diode. Diode has the property that will let the electron flow easily at one direction at proper biasing condition. Bridge rectifiers of 4 diodes are used to achieve full wave rectification. Two diodes will conduct during the negative cycle and the other two will conduct during the positive half cycle.
Filtering unit
Filter circuit which is usually a capacitor acts as a surge arrester always follows the rectifier unit. This capacitor is also called as a decoupling capacitor or a bypass capacitor, is used not only to short the ripple with frequency to ground but also leave the frequency of the DC to appear at the output.
Regulators
The voltage regulators play an important role in any power supply unit. The primary purpose of a regulator is to aid the rectifier and filter circuit in providing a constant DC voltage to the device. Power supplies without regulators have an inherent problem of changing DC voltage values due to variations in the load or due to fluctuations in the AC line voltage. With a regulator connected to DC output, the voltage can be maintained within a close tolerant region of the desired output. IC 7805 and 7812 regulators are used in this project for providing a DC voltage of +5V and +12V respectively.
Some types of serial devices support only one-way communications and therefore use only two wires in the cable - the transmit line and the signal ground.
Communication by Bits
Once the start bit has been sent, the transmitter sends the actual data bits. There may either be 5, 6, 7, or 8 data bits, depending on the number selected. Both receiver and the transmitter must agree on the number of data bits, as well as the baud rate. Almost all devices transmit data using either 7 or 8 data bits.
Pin Number
Direction of signal:
1 2 3 4 5 6 7 8 9
Carrier Detect (CD) (from DCE) Incoming signal from a modem Received Data (RD) Incoming Data from a DCE Transmitted Data (TD) Outgoing Data to a DCE Data Terminal Ready (DTR) Outgoing handshaking signal Signal Ground Common reference voltage Data Set Ready (DSR) Incoming handshaking signal Request To Send (RTS) Outgoing flow control signal Clear To Send (CTS) Incoming flow control signal Ring Indicator (RI) (from DCE) Incoming signal from a modem
The TD (transmit data) wire is the one through which data from a DTE device is transmitted to a DCE device. The TD line is kept in a mark condition by the DTE device when it is idle. The RD (receive data) wire is the one on which data is received by a DTE device, and the DCE device keeps this line in a mark condition when idle .RTS stands for Request To Send. This line and the CTS line are used when "hardware flow control" is enabled in both the DTE and DCE devices. The DTE device puts this line in a mark condition to tell the remote device that it is ready and able to receive data. If the DTE device is not able to receive data (typically because its receive buffer is almost full), it will put this line in the space condition as a signal to the DCE to stop sending data. The complement of the RTS wire is CTS, which stands for Clear To Send. The DCE device puts this line in a mark condition to tell the DTE device that it is ready to receive the data. Likewise, if the DCE device is unable to receive data, it will place this line in the space condition. Together, these two lines make up what is called RTS/CTS or "hardware" flow control.
DTR stands for Data Terminal Ready. Its intended function is very similar to the RTS line. DSR (Data Set Ready) is the companion to DTR in the same way that CTS is to RTS. Some serial
devices use DTR and DSR as signals to simply confirm that a device is connected and is turned on. CD stands for Carrier Detect. Carrier Detect is used by a modem to signal that it has a made a connection with another modem, or has detected a carrier tone.
RI or Ring Indicator. A modem toggles the state of this line when an incoming call rings your phone. The Carrier Detect (CD) and the Ring Indicator (RI) lines are only available in connections to a modem.
4.5.1 RS 232
RS-232 stands for Recommend Standard number 232. The full RS-232C standard specifies a 25pin "D" connector of which 22 pins are used. Most of these pins are not needed for normal PC communications, and indeed, most new PCs are equipped with male D type connectors having only 9 pins.
Almost all digital devices required either TTL or CMOS logic levels. Therefore the first step to connecting a device to the RS-232 port is to transform the RS-232 levels back into 0 and 5 Volts, this is done by RS-232 Level Converters.
It includes a Charge Pump, which generates +10V and -10V from a single 5v supply. This I.C. also includes two receivers and two transmitters in the same package. This is handy in many cases when you only want to use the Transmit and Receive data Lines. You don't need to use two chips, one for the receive line and one for the transmit. However all this convenience comes at a price, but compared with the price of designing a new power supply it is very cheap.
Features of ULN2003:
1. 2. 3. 4. ULN2003 is a 16 bit IC It is of Darlington pair amplifier (1 to 1000) 1.2 Amps current is supported. It gives inverted output.
Description The ULN2001A,ULN2002A,ULN2003A,ULN2004A are monolithic high-voltage, high-current Darlington transmitter, each consist of seven Darlington pairs that feature high-voltage output with common-cathode clamp diodes for switching inductive load. The collector-current rating of a single Darlington pair is 500mA. The Darlington pair may be paralleled for higher current capability applications include relay drivers, hammer driver, lamp drivers, display drivers (LED & gas discharge), line driver & logic buffers. For 100-V (otherwise inter chargeable) versions, see the SN75465 through SN75469. The ULN2001A is a general-purpose array and can be used with TTL and CMOS techniques. The ULN2002A is specifically designed for use with 14 to 25v PMOS devices. Each input of this device has a Zener diode and resistor in series to control the input current to a safe limit. The ULN2003A has a 2.7kohms series based resistor for each Darlington pair for operation directly with TTL or 5v CMOS devices. The ULN2004A has a 10.5k ohms series based resistor to allow its operation directly from CMOS devices they use supply voltages of 6 to 15 volts. The required input current of the ULN2004A is below that of the ULN2003A, and the required voltage is less than that required by the ULN2002A.
Relay The relay is an electromagnetic device which energies when the supply is given. Relay circuit is used to activate the relay through microcontroller. The relay is an electromagnetic device which energies when the supply is given. Relay circuit is used to activate the relay through microcontroller. That means when the microcontroller gives high to the relay circuit the switched on and also the relay is ON. Darlington transistor is
When the microcontroller gives low to the relay circuit the Darlington transistor is switched off and also the relay is OFF. In this circuit we have to use a Darlington transistor (Tip122) for switch on the relay.
Relay Circuit
Features
Range - Outdoor line of sight: up to 50kms with directional antenna. Transmit Power: up to 1 watt / 30 dBm nominal. Receiver Sensitivity: up to 107 dBm. AT Command Modes for configuring Module Parameters Direct sequence spread spectrum technology. Analog to digital conversion and digital I/O line support.
TarangNet Features
Acknowledgement
Each direct sequence channel has 64K unique network addresses. Source / destination addressing. Unicast and broadcast communication. Point to point, point to multi point and peer-to-peer topologies are possible.
4.8 Buzzer:
Buzzer is a transducer, which produces sound signal to the corresponding electric signal. The switching operation of the buzzer is controlled by using microcontroller. the buzzer draws more current while it is operating so by using 2N2222 fast switching transistor we directly operate the buzzer by using microcontroller. The connection of the buzzer is as shown below,
When output pin of the microcontroller is high, then 2N2222 goes to saturation, then buzzer gets operated. Whenever output pin of the microcontroller is low the buzzer stops operating.
5. SOFTWARE
The Keil Software 8051 development tools listed below are the programs used to compile your C code, assemble your assembler source files, link your program together, create HEX files, and debug your target program.
Vision2 for Windows Integrated Development Environment: combines project Management, Source Code Editing, and Program Debugging in one powerful environment. C51 ANSI Optimizing C Cross Compiler: creates relocatable object modules from your C source code, A51 Macro Assembler: creates re locatable object modules from your 8051 assembler source code, BL51 Linker/Locator: combines relocatable object modules created by the compiler and assembler into the final absolute object module, LIB51 Library Manager: combines object modules into a library which may be used by the linker, OH51 Object-HEX Converter: creates Intel HEX files from absolute object modules, RTX-51 real-time operating system: simplifies the design of complex, time critical software projects.
They are designed for the professional software developer, but any level of programmer can use them to get the most out of the 8051 hardware.
Keil Software provides two types of kits in which our tools are delivered. The EK51 Evaluation Kit includes evaluation versions of our 8051 tools along with this users guide. The tools in the evaluation kit let you generate these applications up to 2 Kbytes in size. You may use this kit to evaluate for the effectiveness of our 8051 tools and to generate small target applications. The 8051 Production Kits discussed in Product Overview topic section, include the unlimited versions of our 8051 tools along with this users guide and the full manual set. The production kits also include 1 year of free technical support and product updates.
Evaluation Users:
Evaluation users are those users who have not yet purchased the software but have requested the evaluation package to get a better feel for what the tools do and how they perform. The evaluation package includes evaluation tools that are limited to 2 Kbytes along with several sample programs that provide real-world applications created for the 8051 microcontroller family. Even if you are only an evaluation user, take the time to read this manual. It explains how to install the software, provides you with an overview of the development tools, and introduces the sample programs.
New Users:
New users are those users who are purchasing 8051 development tools for the first time. The included software provides you with the latest development tool technology, manuals, and sample programs. If you are new to the 8051 or the tools, take the time to review the sample programs described in this manual.
Experienced Users:
Experienced users are those users who have previously used the Keil 8051 development tools and is now upgrading to the latest version. The software included with a product upgrade contains the latest development tools and sample programs.
Full-featured source code editor, Device Database for pre-configuring the development tool setting, Project manager for creating and maintaining your projects, Integrated make facility for assembling, compiling, and linking your embedded applications, Dialogs for all development tool settings, True integrated source-level Debugger with high-speed CPU and peripheral simulator. Advanced GDI interface for software debugging in the target hardware and for connection to Monitor-51. Links to development tools manuals, device datasheets & users guides. The Vision2 debugging features are only available in the PK51 and DK51 tool kits.
The Vision2 screen provides you with a menu bar for command entry, a tool bar where you can rapidly select command buttons, and windows for source files, dialog boxes, and information displays. Vision2 lets you simultaneously open and view multiple source files.
The menu bar provides you with menus for editor operations, project maintenance, development tool option settings, program debugging, window selection and manipulation, and on-line help. With the toolbar buttons you can rapidly execute operations. The commands can be reached also with configurable keyboard shortcuts. The following tables give you an overview of the Vision2 commands and the default shortcuts.
The Device Database which automatically sets the assembler, compiler, and linker options for the chip you select. This prevents you from wasting your time configuring the tools and helps you get started writing code faster. A robust Project manager which lets you create several different configurations of your target from a single project file. Only the Keil Vision IDE allows you to create an output file for simulating, an output file for debugging with an emulator, and an output file for programming an EPROM--all from the same Project file. An integrated make facility with automatic dependency generation. You don't have to figure out which header files and include files are used by which source files. The Keil compilers and assemblers do that automatically.
Interactive error correction. As you project compiles, errors and warnings appear in an output window. You may make corrections to the files in your project while Vision continues to compile in the background. Line numbers associated with each error or warning are automatically resynchronized when you make changes to the source.
The Keil 8051 Development Tools are designed to solve the complex problems facing embedded software developers. When starting a new project, simply select the microcontroller you use from the Device Database and the Vision IDE sets all compiler, assembler, linker, and memory options for you. Numerous example programs are included to help you get started with the most popular embedded 8051 devices. The Keil Vision Debugger accurately simulates on-chip peripherals (IC, CAN, UART, SPI, Interrupts, I/O Ports, A/D Converter, D/A Converter, and PWM Modules) of your 8051 device. Simulation helps you understand hardware configurations and avoids time wasted on setup problems. Additionally, with simulation, you can write and test applications before target hardware is available. When you are ready to begin testing your software application with target hardware, use the MON51, MON390, MONADI, or FlashMON51 Target Monitors, the ISD51 In-System Debugger, or the ULINK USB-JTAG Adapter to download and test program code on your target system.
5.4 Advantages:
Knowledge of the processor instruction set is not required, rudimentary knowledge of the memory structure of the 8051 CPU is desirable (but not Necessary). Details like register allocation and addressing of the various memory types and data types are managed by the compiler. Programs get a formal structure and can be divided into separate functions. This leads to better program structure. The ability to combine variable selection with specific operations improves program readability. Keywords and operational functions can be used that more nearly resemble the human thought process. Programming and program test time is drastically reduced which increases your efficiency. The C run-time library contains many standard routines such as: formatted output, numeric conversions and floating point arithmetic.
Existing program parts can be more easily included into new programs, because of the comfortable modular program construction techniques. The language C is a very portable language (based on the ANSI standard) that enjoys wide popular support, and can be easily obtained for most systems. This means that existing program investments can be quickly adapted to other processors as needed.
Step1: Open the keil window and go to project in the menu and create new project
Step2: Enter a file name for the project and save it in the required location.
Step5: Save the text file in the required location with .asm extension
step6: Browse the required asm file and add the asm file to the target
Step8: Compile the code and check for any errors occurred or warnings encountered.
Step11: Now run the code either in step-by-step mode or single step mode and check the Ports and other peripherals used in the code.
Features of IUP:
High Speed USB port interface. Supports 5V, 3.3V & 1.8V Devices Less that 2 seconds per M bit Programming speed No adapter required for DIL devices up to 48-pin. 48-pin universal pin driver and current limit Device insertion / continuity check Supports Windows 95/98, Windows 2000, Windows XP & NT 3 years hardware warranty. FREE software updates via the web. Serialization for Memory and Micro's Memory buffer H / L byte swap Project file save and load function User Selectable verify VCC with one or two-pass verify voltage Automatic file format detection and conversion Pin swapping table provided for all adapters
6. SOURCE CODE.
setb tr1 ret send: call delay mov sbuf,a jnb TI,$ clr TI ret
delay: mov r4,#25 h: setb tr0 jnb tf0,$ clr tr0 clr tf0 djnz r4,h ret end
ALARM=1; SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */ TMOD = 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */ TH1 = -3; /* TH1: reload value for 9600 baud @ 11.0592MHz */ TR1 = 1; /* TR1: timer 1 run */ init_lcd(); delay_ms(10); display_lcd("OILFIELD SECURITY "); cmd_lcd(0xc0); display_lcd(" USING ZIGBEE"); delay_ms(50); while(1); } void serial_int(void)interrupt 4 { unsigned char k; if(RI) { k=SBUF; if(k=='1') { cmd_lcd(0x01); ALARM=0; display_lcd("WELL OPENED"); delay_ms(200); ALARM=1; } else if(k=='2') { cmd_lcd(0x01); ALARM=0; display_lcd("WARNING"); delay_ms(10); cmd_lcd(0xc0);
RI = 0; } }
void init_lcd(void) { cmd_lcd(0x28); cmd_lcd(0x0c); cmd_lcd(0x06); cmd_lcd(0x01); delay_ms(10); } void cmd_lcd(unsigned char c) { lcd = ((c & 0xf0) | 0x08); lcd = 0; lcd = ((c<<4)|0x08); lcd = 0; delay_ms(20); }
void lcd_data(unsigned char c) { lcd = ((c&0xf0)|0x0a); lcd = 0; lcd = ((c<<4)|0x0a); lcd = 0; delay_ms(20); } void display_lcd(unsigned char *s) { while(*s) lcd_data(*s++); }
7. CONCLUSION