Sie sind auf Seite 1von 185

A PROJECT REPORT ON

WIRELESS DATA ACQUISITION SYSTEM


SUBMITTED BY MINALI JADHAV RUCHA GAJARE VAIBHAV MEHTA UNDER THE GUIDANCE OF Mrs. SHRAVANI SHAHAPURE

DEPARTMENT OF ELECTRONICS & TELECOMMUNICATION ENGINEERING PILLAIS INSTITUTE OF INFORMATION TECHNOLOGY, ENGINEERING, MEDIA STUDIES & RESEARCH NEW PANVEL 410206 UNIVERSITY OF MUMBAI Academic Year 2011-12

DEPARTMENT OF ELECTRONICS AND TELECOMMUNICATION Pillais Institute of Information Technology, Engineering, Media Studies and Research New Panvel-410206 CERTIFICATE This is to certify that the requirements for the project synopsis entitled WIRELESS DATA ACQUISITION SYSTEM have been successfully completed by the following students: Name Minali P Jadhav Rucha H Gajare Vaibhav D Mehta Roll No 822 816 834

In partial fulfillment of Bachelor of Engineering University of Mumbai, in the department of Electronics and Telecommunication, Pillais Institute of Information Technology, Engineering, Media Studies & Research, New Panvel during the academic year 2011-12.

Internal Guide: _____________________ (Mrs. Shravani Shahapure) Internal Examiner: _________________

External Guide: _________________ External Examiner: _____________

Head of Department: _______________

Principal: _____________________

Acknowledgement

Apart from the efforts of us, the success of any project depends largely on the encouragement and guidelines of many others. We take this opportunity to express our gratitude to the people who have been instrumental in the successful completion of this project. We would like to show greatest appreciation to our project guide Mrs. Shravani Shahapure. We cant say thank you enough for her tremendous support and help. We feel motivated and encouraged every time we attend her meeting. Without her encouragement and guidance this project would not have materialized. We would like to tender our sincere thanks to Prof. Sanjeev Kumar Shrivastava the H.O.D of the branch of Electronics & Telecommunication Engineering. and the entire teaching staff of Pillis Institute of Information Technology for their support and encouragement in all aspects. We also express our deep regards and gratitude to our Principal Dr. R.I.K Moorthy. We would wish to thank the non-teaching staff and our friends who have helped us in all the time in one way or other. The guidance and support received from all the members who contributed and who are contributing to this project, was vital for the success of the project. We are grateful for their constant support and help.

PREFACE

We take an opportunity to present this project report on "WIRELESS DATA ACQUISITION SYSTEM" and put before readers some useful information regarding our project. The completion of the project work is a millstone in student life and its execution is inevitable in the hands of guide. We have made sincere attempts and taken every care to present this matter in precise and compact form, the language being as simple as possible. We are sure that the information contained in this volume would certainly prove useful for better insight in the scope and dimension of this project in its true perspective. The task of completion of the project though being difficulty was made quite simple, interesting and successful due to deep involvement and complete dedication of our group members.

Table of Contents
Table of Contents..................................................................................................................................5 List of Figures...................................................................................................................................9 ........................................................................................................................................................11 1. INTRODUCTION..........................................................................................................................11 1.1 DAS: Then and Now................................................................................................................12 1.2 Typical Data Acquisition System.............................................................................................13 1.3 Problems in DAS......................................................................................................................15 2. REVIEW OF LITERATURE.........................................................................................................16 3. WIRELESS DATA ACQUISITION SYSTEM............................................................................18 3.1 Structure of WDAS in brief......................................................................................................18 3.2 Wireless Technology................................................................................................................19 3.3 Why only Wi-Fi?.....................................................................................................................20 3.4 Block Diagram of Wireless Data Acquisition System.............................................................20 3.4.1 PIC18F4550 Microcontroller.............................................................................................23 3.4.1.1 PIC18F4550 Microchip High-Performance, Enhanced Flash, USB Microcontrollers with nanoWatt Technology Features......................................................................................24 3.4.1.2 PIN diagram and Architecture....................................................................................26 3.4.2. Ultrasonic Distance Measurement Sensor........................................................................27 3.4.2.1 Construction and Working..........................................................................................28 3.4.2.2 Selection of transducer................................................................................................29 3.4.2.3 Ultrasonic Echo Ranging............................................................................................29 3.4.2.4 Calculation to measure distance of obstacle...............................................................31 3.4.2.5 Specifications..............................................................................................................31

3.4.3 Passive Infrared Sensor......................................................................................................32 3.4.3.1 Design..........................................................................................................................33 3.4.3.3 PIR Based motion detector.........................................................................................34 3.4.3.4 Construction and Working of PIR..............................................................................35 3.4.3.5 Specifications..............................................................................................................36 3.4.4 IR Based Obstacle Sensor..................................................................................................38 3.4.4.1 Working.......................................................................................................................39 3.4.4.2 Circuit description & working for oscillator..............................................................48 3.4.4.3 IR transmitter LED......................................................................................................49 3.4.4.4 TSOP1738 IR receiver................................................................................................50 3.4.5 Global Positioning System................................................................................................51 3.4.5.1 How it works...............................................................................................................52 3.4.5.2. Navigation equations..................................................................................................52 3.4.5.3 Trilateration.................................................................................................................53 3.4.5.4 The GPS satellite system............................................................................................54 3.4.5.5 Signals in GPS.............................................................................................................54 3.4.5.6 Sources of GPS signal errors......................................................................................55 3.4.5.7 GPS Module in our Project.........................................................................................56 3.4.5.8 Specifications..............................................................................................................56 3.4.6 LM35 Temperature Sensor................................................................................................57 3.4.7 Data Sharing Methods.......................................................................................................59 3.4.7.1 Selection of sharing techniques..................................................................................61 3.4.7.2 Opera Units.................................................................................................................62 3.4.7.3 Remote Desktop..........................................................................................................66 3.4.7.3.3 Configure for a Remote Desktop Connection in windows 7..................................70

3.4.7.3.4 Connecting to a Remote Desktop in windows 7.....................................................73 3.4.8 Software Development For WDAS...................................................................................74 3.4.8.1 Software developing for microcontroller PIC18F4550..............................................77 3.4.8.2 Software developing for PC........................................................................................93 3.4.9 PCB Layout......................................................................................................................102 COMPONENTS LIST......................................................................................................................109 TESTING OF WDAS.......................................................................................................................110 5.1 Recorded data when WDAS system was in ideal state..........................................................111 5.2 Recorded data when WDAS system when feted on Robot...................................................116 8. Reference......................................................................................................................................126 Appendix...........................................................................................................................................128 9.1 Program for developing software for PC...............................................................................128 Program for microcontroller for collecting data from sensors, processing data, master slave communication and communication with PC..............................................................................144 9.2.1 Program for master PIC.......................................................................................................144 9.2.2 Program for slave PIC......................................................................................................161

List of Figures
Figure 1.1 Block diagram of DAS.....................................................................................................13 Figure 3.1 Structure of WDAS...........................................................................................................19 Figure 3.2 Block diagram WDAS......................................................................................................21 Figure 3.3 Pin configuration of PIC...................................................................................................26 Figure 3.4 PIC block diagram...........................................................................................................27 Figure 3.5 Ultrasonic sensor.....................................................................................................28 Figure 3.6 Construction of ultrasonic sensor.....................................................................................28 Figure 3.6 Radiation pattern of Ultrasonic.........................................................................................29 Figure 3.7 Ultrasonic transmitter receiver.........................................................................................29 Figure 3.8 Ultrasonic block diagram..................................................................................................30 Figure 3.9 Simplified model of pyroelectric effect............................................................................33 Figure 3.10 Construction of PIR35 Figure 3.11 Working principle of PIR...............................................................................................36 Figure 3.12 PIR...................................................................................................................................36 Figure 3.13 IR spectrum.....................................................................................................................38 Figure 3.14 IR Obstacle detection.....................................................................................................38 Figure 3.15 IR obstacle detector circuit.............................................................................................48 Figure 3.16 Oscillator circuit for IR transmission....................................................................49 Figure 3.17 Waveforms......................................................................................................................49 Figure 3.18 IR Transmitter LED........................................................................................................49 Figure 3.19 TSOP1738 IR receiver....................................................................................................50 Figure 3.20 Block Diagram of TSOP1738.........................................................................................50 Figure 3.21 GPS satellite system........................................................................................................54 9|Page

Figure 3.23 GPS MT3318 USB Module............................................................................................56 Figure 3.24 Opera data sharing unit...................................................................................................62 Figure 3.25 Downloading opera web page - Step1............................................................................63 Figure 3.26 Opera Unite Installation and setting - Step2..................................................................64 Figure 3.27 Opera Unite Installation and setting - Step3..................................................................65 Figure 3.28 Opera Unite Installation and setting - step4...................................................................66 Figure 3.29-Configuring Remote desktop - step1..............................................................................71 Figure 3.30 Configure for a Remote Desktop - Step2.......................................................................71 Figure 3.31 Configure for a Remote Desktop - Step3.......................................................................73 Figure 3.32 Connecting to remote desktop - step1 .............................................................................................................................................................74 Figure 3.33 Connecting to remote desktop - Step2............................................................................74 Figure 3.34 Simple I/O.......................................................................................................................79 Figure 3.35 Port A and TRISA Register............................................................................................79 Figure 3.36 PORTB and TRISB Register..........................................................................................81 Figure 3.37 ADCON0 control register...............................................................................................82 Figure 3.38 ADCON1 register...........................................................................................................83 Figure 3.39 PCFG register..................................................................................................................84 Figure 3.40 ADCON2 Register..........................................................................................................85 Figure 3.41 A/D conversions TAD cycles (ACQT <2:0> = 000, TAQ=1)......................................88 Figure 3.42 A/D conversions TAD cycles (ACQT <2:0> = 010, TAQ=4TAD)..............................88 Figure 3.43 Software developing for PC flowchart...........................................................................93 Figure 3.44 WDAS software screen shot...........................................................................................96 Figure 3.45 Selecting Port to which motherboard is connected........................................................97 Figure 3.46 Motherboard connected..................................................................................................97 10 | P a g e

Figure 3.47 Data log started...............................................................................................................98 Figure 3.48 Selecting port where GPS is connected..........................................................................99 Figure 3.49 GPS data display...........................................................................................................102 Figure 3.50 PCB design stages.........................................................................................................103 Figure 3.51 Schematic of circuit......................................................................................................106 Figure 3.52 PCB layout....................................................................................................................107

1. INTRODUCTION
In industry with having huge span, Agricultural area, security system and other practical application process, it often needs to test the site equipments video of particular area with audio 11 | P a g e

and environmental. To control or observe such sites it is necessary to check conditions over sites time to time. This is what actually data acquisition means. Data acquisition is the process of sampling signals that measures real world physical conditions and converts the resulting samples into digital numeric values that can be manipulated. Data acquisition systems can take many forms from very simple manual systems to high complicated computer controlled ones. The simplest form may be a technician manually logging information such as the temperature of an oven. However this form of data acquisition has its limitations. Not only is it expensive because of the fact that someone has to be available to take the measurements, but being manual it can be subject to errors. Readings may not be taken at the prescribed times, and also there can be errors resulting from the manual fashion in which the readings are taken. As can be imagined the problems become worse if a large number of readings need to be taken, as timing may become more of an issue, along with the volume of work required. To overcome this, the simple answer is to use computer control to perform the data acquisition. As a result a definition of what is normally taken to be data acquisition is gathering information in an automated fashion from analog and digital measurement sources, i.e. sensors and devices under test. Data acquisition is widely used in many areas of industry. Data acquisition is used to acquire data from sensors and other sources under computer control and bring the data together and store and manipulate it. In view of the wide variety of signals and parameters that can be sampled and stored, data acquisition involves many techniques and skills. Data acquisition systems incorporate signals, sensors, actuators, signal conditioning, data acquisition devices, and application software. So summing up, Data Acquisition is the process of: Acquiring signals from real-world phenomena Digitizing the signals Analyzing, presenting and saving the data

1.1 DAS: Then and Now


12 | P a g e

It was not that long ago the stereotype of an engineer was someone in a white lab coat watching one or more meters and writing results on a clipboard. The advent of extremely low cost computers, combined with the development of a wide variety of powerful data acquisition interfaces has driven this stereotype farther back in history than black and white movies. Also, most college graduates in science and engineering disciplines have enough programming training and experience to make the programming required for DAQ applications quite straightforward. In the early 1980's, when the PC-based DAQ market was in its infancy, most analog input and output devices offered 12-bit resolution. There were also some lower speed products with greater than 12-bit resolution and a number of high speed products offering resolution in the 8 to 10-bit range. Today, the technology has changed and the standard resolution is 16-bit, with DAQ products offering resolutions up to 24-bit while some of the higher speed, lower resolution products are even challenging the performance of low end digital oscilloscopes.

1.2 Typical Data Acquisition System

Figure 1.1 Block diagram of DAS

The

figure depicts the two important features of a data acquisition system:

Signals are input to a sensor, conditioned, converted into bits that a computer can read, and analyzed to extract meaningful information. Data from a computer is converted into an analog signal and output to an actuator. 13 | P a g e

The ideal solution for a data acquisition system is often to use a central computer to control the system and to collect the data, store and process it. This can be done by collecting data through microcontroller and save that data in personal computer. Further on connecting that personal computer to Wi-Fi we can share the recorded data. There are some free utilities such as opera through which its possible to share data over Internet. Not only sharing, but even we can control the equipments by remote desktop the particular computer.

The standard data acquisition system (DAS) contains three elements, acquisition hardware, storage unit and data transmission method. Acquisition hardware plays a key role in the system which decides the performance of DAS. Most of the research is using personal computer as acquisition hardware. Further on with new technique the standard personal computer to high speed personal computer for better performance of data processing and transferring to storage unit. But the microcontroller based DAS is more popular platform since its low in cost and suitable for simple and small application. Now days there are no serial ports in net books or laptops. Instead of that there are USB ports. Also data transmission speed is more as compared with serial ports. So to collect the data form acquisition hardware and store it in net book, the communication between them can only be done by USB. USB advantages for data acquisition: Not only has USB proved itself an ideal platform for many mainstream computer applications, but it also offers many advantages for data acquisition systems. The advantages include aspects including: USB allows much faster speeds than RS232 The power for the "sensor" or data acquisition module can be obtained from the computer, simplifying many systems, and especially any portable USB data acquisition systems. USB data acquisition modules can be connected and disconnected without the need to power down the computer USB ports are standard on most PCs these days making it an almost universally available method of connection. It is possible to use USB as well as other data acquisition communication standards together It is possible to expand the connectivity using a USB hub so that several USB data acquisition devices can be connected So we should use the Microcontroller which has USB communication or else serial to USB converter should be used. But for higher data transmission direct USB connection is preferred. Considering the microcontroller with USB communication available in market at a cheaper rate for basic requirement is from the Microchip which is PIC18F4550. Its cost is approximate 350 INR. It has 35 I/O ports, 13 internal ADC converter ports with resolution of 10 bits and lots of other features. If more ports are require then the PICs can be cascaded in master and slave configuration to work together. From this microcontroller data at the ports can be stored in memory card and can also be stored in net book for further operation. 14 | P a g e

1.3 Problems in DAS


It is difficult to define a typical data acquisition system as the requirements, and hence the implementations vary so considerably. Although simple solutions may utilize a data logger, these data loggers may not be suitable for data acquisition systems requiring data from a large variety of different sensors to be made and collected and analyzed. The ideal solution for a data acquisition system is often to use a central computer to control the system and to collect the data, store and process it. This can be done by collecting data through microcontroller and save that data in personal computer. In certain case, when area to be monitored is very large then, wired DAS has certain drawbacks which are noted below. System becomes more complex Cost of overall DAS increases More man power is required More time is required for installation Maintenance is difficult If any problem arises it cant be detected easily Hence time is wasted in finding the problem

The best way of solving this problem is going for WIRELESS DATA ACQUISITION SYSTEM which is cost effective choice. So to solve this problem we can transmit the signals from various sensors to central unit using wireless transmission.

15 | P a g e

2. REVIEW OF LITERATURE
There are a number of test equipment choices in the data acquisition market, ranging from PC plug-in cards to standalone data acquisition units. To select the optimal equipment for our application, it is important for us to evaluate our measurement performance needs, including resolution, accuracy, functionality and throughput speeds. With so many choices available today, we will want to choose a flexible solution that can grow in tandem with our application, so we can protect our investment in the future [12]. Different types of Data Acquisition systems are: 1 PC Plug-In Cards PC plug-in cards are typically positioned as a low-cost data acquisition solution. These cards are designed to communicate with a PC over its internal bus and have direct access to the PCs internal memory. Manufacturers currently offer PC plug-in cards with a wide range of capabilities, including signal conditioning, stepper motor control, analog input/output, and digital input/output. Typically, the channel count is low with PC plug-in cards due to the physical space available inside the PC. Data acquisition systems that use PC plug-in cards are normally less accurate than stand-alone instruments due to the electrical noise generated by the PC. In addition, PC plug-in cards are generally not very robust and cannot typically handle voltages greater than 10 volts. With PC plug-in data acquisition, you will need signal conditioning components to make ac voltage and temperature measurements. If an application requires signal conditioning, be aware that this will greatly affect the overall cost of the data acquisition system. In fact, the cost of the signal conditioning components could potentially equal the cost of the PC plug-in card. It is also important to note that integrating a PC plug-in card into a PC may not be a straightforward task. Since the card is installed directly into the PC, it is crucial to select interrupt lines or memory addresses that are not reserved for other devices in the PC. 2 Switch Boxes 16 | P a g e

For many design verification and product testing applications, switch boxes are included as a type of data acquisition system. A switch box is typically used to route test signals between the device-under-test and other instrumentation such as oscilloscopes, counters, power supplies, and digital multimeter. Switch boxes are available that can switch signal levels from a few microvolt to several hundred volts, and from dc to several gigahertz. In addition to basic switching, some switch boxes add simple control capabilities. For example, some manufacturers have added digital input/output capabilities, analog output control, and isolated actuators for controlling high-power devices.

3. Stand-Alone Data Loggers Data loggers are used primarily to monitor signals over a period of time in order to identify irregularities that may require attention. Most data loggers also provide a way to graph and analyze the data, which is collected through a PC connection. Although used primarily in the up-front design verification stage of product development, data loggers also are used in-house for environmental-chamber monitoring, component inspection, bench top testing, and process troubleshooting. Since they typically are used in single-instrument applications, data loggers also make great portable field-testing instruments. Some data loggers have the ability to perform mathematical operations on the measured data, compare the measured data against user-defined limits, and output signals for control operations. For example, when measuring temperature, signal conditioning or linearization must be applied before the measured data is useful. If the data logger has these built-in capabilities, a computer may not be at all necessary. Most data loggers also have a communications interface (GPIB, USB or LAN) to allow measurement data to be down-loaded to a PC in real-time or after a specific test is completed. If the application requires real-time downloading of the measurement data, the PC must continuously monitor the data logger, resulting in the loss of the data loggers stand-alone benefits. If the data logger has its own internal data storage capability, or access to an external storage device such as a disk drive, then you can download the measurements for analysis at a later time. Note that a low-cost data logger with fewer than 20 channels and a relatively low scan rate is adequate for many data logging applications. For greater flexibility and functionality, select a data logger that can operate as a standalone instrument, can be easily upgraded, and can be connected to a PC. A data logger should also have plug-in slots and the ability to measure different types of input signals without external signal conditioning. All the above mentioned types available in market are quite costly and are complex. Their installation and maintenance require expertise of the system. In our project we have designed a DAS which include all the above advantages as well as it easy to install and maintain. Due to wireless connection, its cost is much less and it does not require any additional network setup because of Wi-Fi. All the industries already have Wi-Fi 17 | P a g e

connection, so we just need to add our system in that network, which not a difficult job. If any problem arises it is very easy to detect and solve the problem.

3. WIRELESS DATA ACQUISITION SYSTEM


Wireless data acquisition system is based on wireless sensors network principal. A wireless sensor network (WSN) consists of spatially distributed autonomous sensors to monitor physical or environmental conditions, such as temperature, sound, vibration, pressure, humidity, motion or pollutants and to cooperatively pass their data through the network to a main location[1]. The more modern networks are bi-directional, also enabling control of sensor activity. The development of wireless sensor networks was motivated by military applications such as battlefield surveillance; today such networks are used in many industrial and consumer applications, such as industrial process monitoring and control, machine health monitoring, and so on. The WSN is built of "nodes" from a few to several hundreds or even thousands, where each node is connected to one (or sometimes several) sensors. Each such sensor network node has typically several parts: a radio transceiver with an internal antenna or connection to an external antenna, a microcontroller, an electronic circuit for interfacing with the sensors and an energy source, usually a battery or an embedded form of energy harvesting. In this project we have replaced transmission of every sensor into group of sensors with single transmitter [3].

3.1 Structure of WDAS in brief


The wireless data acquisition system is outlined in fig

18 | P a g e

Figure 3.1 Structure of WDAS

The processor board collects status of various sensors and updates all measurements and sends that data to host PC with USB communication. PC logs this data and stores it with time and date. PCs in the network communicate with host PC through wireless communication. Data log on host PC is shared using file transfer protocol (FTP), opera unit and web hosting. For real time viewing the data log on internet, PHP web page hosting can be done. The work of collecting data, monitoring and processing is done by host PC.

3.2 Wireless

Technology
Wireless technology and wireless networks are widely used today, but its quite new in industrial automation systems. There are different technologies and wireless standards available[13], [14]: Infrared Wireless USB Bluetooth ZigBee (IEEE 802.15.4) 19 | P a g e

Wi-Fi (IEEE 802.11)

The Figure below compares the different wireless technologies: Table 1 Out of these technologies the cheapest and effective way of wireless communication is through Wi-Fi. We just need to collect the data and share it over network. Wi-Fi data acquisition is an extension of PC-based data acquisition to measurement applications where cables are inconvenient or uneconomical.

3.3 Why only Wi-Fi?


Wide bandwidth Ease of installation No line of sight required. In industrial areas Wi-Fi network is already installed, so no any additional installation is required to create a network. Error detection and correction is easy. Secured

3.4 Block Diagram of Wireless Data Acquisition System


20 | P a g e

WDAS can be used for various applications such as in industry for automation or for monitoring process, medical for observing the patient under test, security system, robotics etc. In our project we have developed system for robotics having some basic sensors such as Ultrasonic sensor, PIR sensor, GPS, temperature sensor, IR based obstacle sensors, batteries. So considering these sensors the block diagram of our project wireless data acquisition system is shown bellow.

Figure 3.2 Block diagram WDAS

In the figure above the most important part is microcontroller and the host pc. All the sensors in the network are connected to the 21 | P a g e

microcontroller PIC 18F4550.this microcontroller has built in 13 channel ADC with 10 bit of resolution, so external ADC is not required resulting in less complexity circuit and reduces overall cost of the system. Also this microcontroller provides boot uploder. Using this we can reprogram microcontroller without removing it from circuitry using USB communication. This microcontroller collects the data from its ports and processed it for transmitting to host PC using USB communication. PC logs this data and stores it with date and time. The data stored in PC can be share with other computers in the network using Wi-Fi. All the PCs in the network are communicated through Wi-Fi. Files can be transferred by file transfer protocol (FTP), web hosting and opera unit. This data can be viewed in real time due to the use of PHP. PHP is a scripting language for creating dynamic web pages. As all PCs are communicated wirelessly, the data can be viewed remotely. In industrial area where the span of area is more, we can install WDAS at different unite and can monitor all the WDAS system seating at masters computer/central computer or any other computer in network or the PC having internet connectivity. This can be done by creating a star network. The system to cover larger area by dividing area in units is shown below [19].

22 | P a g e

3.4.1 PIC18F4550 Microcontroller

The better way of selecting microcontroller is first to list out the sensors which are to be interface and there nature of output and input of the signal required. In case if analog signal is produced at sensors output, we require analog to digital converter to convert the data in digital form for logging purpose. We can use analog to digital converter externally or else we can select the microcontroller having inbuilt ADC. The best solution is to select microcontroller which has internal ADC. This will reduce complexity of the circuit and will reduce the overall circuit structure. Second thing is the interfacing required. In our project we required a microcontroller to interface it with PC for data logging and sharing over a network and on internet. Now days there are no laptops and notebooks having RS232. This is due to popularity of USB communication. As a result RS232 communication has become outdated. So we require a microcontroller which could support USB communication. The third think is the number of ports required. The microcontroller should provide require number of ports. If not it should support master and slave configuration so that the slave microcontroller can be use for interfacing the other sensors. Also we should consider the memory requirement of microcontroller speed and power consumption [5]. Considering all these things the best option found out is PIC18F4550 microcontroller. PIC is a family of modified Harvard architecture microcontrollers made by Microchip Technology. The name PIC initially referred to "Peripheral Interface Controller". PICs are popular with both industrial developers and hobbyists alike due to their low cost, wide availability, large user base, extensive collection of application notes, availability of low cost or free development tools, and serial programming (and re-programming with flash memory) capability. Microchip produces microcontroller supporting 12, 13, 14, 16 and 32 bit data processing. PIC18F4550 is from PIC18 family supporting 8bit processing. PIC18F4550 is ideal for low power (nanoWatt) and connectivity applications that benefit from the availability of three serial ports: FS-USB (12Mbit/s), IC and SPI (up to 10Mbit/s) and an asynchronous (LIN capable) serial port (EUSART). It has large amounts of RAM memory for buffering and Enhanced Flash program memory make it ideal for embedded control and monitoring applications that require periodic connection with a (legacy free) personal computer via USB for data upload/download and/or firmware updates. It supports boot uploader. Through which PIC 23 | P a g e

microcontroller can be reprogrammed without removing it from circuit via USB communication. Once boot uploader is loaded in microcontroller, we dont require any external programming kit to reprogram it. The cost of microcontroller in Indian market is around 350. While seeing to its features and application is cheaper. It can be programmed in C Compiler Optimized Architecture with optional Extended Instruction Set. The program memory can be erase/Write cycle up to 100,000 of time. While data EEPROM can be Erase/Write cycle up to 1,000,000 times.

3.4.1.1 PIC18F4550 Microchip High-Performance, Enhanced Flash, USB Microcontrollers with nanoWatt Technology Features
Two-Speed Oscillator Start-up Universal Serial Bus Features: USB V2.0 Compliant Low Speed (1.5Mb/s) and Full Speed (12 Mb/s) Supports Control, Interrupt, Isochronous and Bulk Transfers Supports up to 32 Endpoints (16 bidirectional) 1-Kbyte Dual Access RAM for USB On-Chip USB Transceiver with On-Chip Voltage Regulator Interface for Off-Chip USB Transceiver Streaming Parallel Port (SPP) for USB streaming transfers (40/44-pin devices only) Power-Managed Modes: Run: CPU on, peripherals on Idle: CPU off, peripherals on Sleep: CPU off, peripherals off Idle mode currents down to 5.8A typical Sleep mode currents down to 0.1A typical Timer1 Oscillator: 1.1A typical, 32 kHz, 2V Watchdog Timer: 2.1A typical Flexible Oscillator Structure: Four Crystal modes, including High Precision PLL for USB Two External Clock modes, up to 48 MHz Internal Oscillator Block: - 8 user-selectable frequencies, from 31 kHz to 8 MHz - User-tunable to compensate for frequency drift

Secondary Oscillator using Timer1 @ 32 kHz Dual Oscillator options allow microcontroller and USB module to run at different clock speeds Fail-Safe Clock Monitor: - Allows for safe shutdown if any clock stops Peripheral Highlights: High-Current Sink/Source: 25 mA/25 mA Three External Interrupts 24 | P a g e

Four Timer modules (Timer0 to Timer3) Up to 2 Capture/Compare/PWM (CCP) modules: - Capture is 16-bit, max. resolution 5.2 ns (TCY/16) - Compare is 16-bit, max. resolution 83.3 ns (TCY) - PWM output: PWM resolution is 1 to 10-bit Enhanced Capture/Compare/PWM (ECCP) module: - Multiple output modes - Selectable polarity Special Microcontroller Features: C Compiler Optimized Architecture with optional Extended Instruction Set 1,000,000 Erase/Write Cycle Data EEPROM Program Memory typical Memory typical 100,000 Erase/Write Cycle Enhanced Flash Flash/Data EEPROM Retention: > 40 years Self-Programmable under Software Control Priority Levels for Interrupts 8 x 8 Single-Cycle Hardware Multiplier Extended Watchdog Timer (WDT): - Programmable period from 41 ms to 131s Programmable Code Protection Single-Supply 5V In-Circuit Serial Programming (ICSP) via two pins In-Circuit Debug (ICD) via two pins

- Programmable dead time - Auto-shutdown and auto-restart Enhanced USART module: - LIN bus support Master Synchronous Serial Port (MSSP) module supporting 3-wire SPI (all 4 modes) and I2C Master and Slave modes 10-bit, up to 13-channel Analogto-Digital Converter module (A/D) with Programmable Acquisition Time Dual Analog Comparators with Input Multiplexing

Optional dedicated ICD/ICSP port (44-pin devices only) Wide Operating Voltage Range (2.0V to 5.5V) 100,000 Erase/Write Cycle Enhanced Flash

25 | P a g e

3.4.1.2 PIN diagram and Architecture


Figure 3.3 Pin configuration of PIC

26 | P a g e

Figure 3.4 PIC block diagram

3.4.2. Ultrasonic Distance Measurement Sensor 27 | P a g e

Ultrasound is cyclic sound pressure with a frequency greater than the upper limit of human hearing. Ultrasound is thus not separated from "normal" (audible) sound based on differences in physical properties, only the fact that humans cannot hear it. So this range of frequency is used for obstacle detection purpose based on radar or sonar which evaluates attributes of a target by interpreting the echoes from radio or sound waves respectively. Ultrasonic sensors generate high frequency Ultrasound waves and evaluate the echo which is received back by the sensor. Sensors calculate the time interval between sending the signal and receiving the echo to determine the distance to an object. Systems typically use a transducer which generates sound waves in the ultrasonic range, above 18,000 hertz, by turning electrical energy into sound, then upon receiving the echo turn the sound waves into electrical energy which can be measured and displayed.

Figure 3.5 Ultrasonic sensor

3.4.2.1 Construction and Working


Ultrasonic sensor consists of two units, namely the transmitter unit and receiver unit. Transmitter and receiver unit structure is simple a piezoelectric crystal is connected with mechanical anchors and only connected with the diaphragm vibrator, alternating voltage with a frequency of 40 kHz 400 kHz are given on the metal plate. The atomic structure of the piezoelectric crystal will contract (binding), expanded or shrunk to the polarity of applied voltage, and is called the piezoelectric effect. Contractions that occur forwarded to the diaphragm resulting in an ultrasonic vibrator emitted into the air (the surroundings), and the reflection of ultrasonic waves will occur when there is a particular object, and the reflection of ultrasonic waves to be received back by the receiver sensor units. Furthermore, the sensor unit will cause the diaphragm vibrator receiver will vibrate and the piezoelectric effect produces an 28 | P a g e
Figure 3.6 Construction of ultrasonic sensor

alternating voltage with the same frequency. Large amplitude signals generated by receiver sensor units depend on the distant object detected nearby and the quality of the sensor transmitter and receiver sensors [8].

3.4.2.2 Selection of transducer


While selecting transducer for a given application, it is important to be aware of the principles of sound propagation. Since sound is a wave phenomenon, its propagation and directivity are related to its wavelength (). A typical radiation power pattern for either a Generator or receiver of waves is shown in Figure 3.7. Due to the reciprocity of transmission and reception, the graph portrays both power radiated along a given direction (in case of wave production), and the sensitivity along a given direction (in case of wave reception). The angular, half-width (/2) of the main beam is given by: /2 = sin-1 (0.51/D ) for -3dB /2 = sin-1 (0.7/ D ) for -6dB = c / f
Figure 3.6 Radiation pattern of Ultrasonic

Where D is the effective diameter of the flexure diaphragm, is the wavelength, c the velocity of sound (344 meter/second in air at 20 C), and f is the operating frequency. The above relationship applies if < D. For D, the power pattern tends to become spherical in form. Thus, narrow beams and high directivity are achieved by selecting D large in relation to . So for covering angle of 60 with a main beam (-6dB) Figure 3.7 Ultrasonic we have to select a pair of ultrasonic working at transmitter receiver 40KHz frequency and having effective diameter of 23mm (1mm wall thickness).

3.4.2.3 Ultrasonic Echo Ranging


Ultrasonic ranging systems are used to determine the distance to an object by measuring the time required for an ultrasonic wave to travel to the object and return to the source. This technique is frequently referred to as echo ranging. The distance to the object may be related to the time it will take for an ultrasonic pulse to propagate the 29 | P a g e

distance to the object and return to the source by dividing the total distance by the speed of sound which is 344 meters/second or 13.54 inches/millisecond. Below is a block diagram that illustrates the basic design concept and functional elements in a typical ranging system. With increasing in distance between obstacle and Ultrasonic sensor, the accuracy gets decreases. Ideally it can work for detecting obstacle at a distance up to 4m. It can detect obstacle which are more than 4m distance, but its accuracy get decreases.

Figure 3.8 Ultrasonic block diagram

30 | P a g e

The driving signal can be either a tone burst of suitable burst number, which depends on the rising time of transceiver, or a pulse that will result in the transmission of a few cycles of Ultrasonic energy. MCU starts a counter when tone burst starting, which is stopped by the detected returning echo. The count is thus directly proportional to the propagation time of the ultrasonic wave. The matching circuit tunes out the imaginary part of transceiver and also plays as an impedance matching bridge for maximizing energy transfer. The returning ultrasonic echo is usually very weak and the key to designing a good ranging system is to utilize a high Q tuned frequency amplifier stage that will significantly amplify any signal at the frequency of the ultrasonic echo while rejecting all other higher or lower frequencies. Another useful technique is to make the gain of the echo amplifier increase with time such that the amplifier gain compensates for the proportional decrease in the signal strength with distance or time. This amplifier is called as TGC (Time Controlled Gain) Amplifier.

3.4.2.4 Calculation to measure distance of obstacle


The distance of the obstacle can be measured by calculating time required for travelling of sound signal using simple formula as below. Distance = (Echo pulse width high time * Sound Velocity (340M/S)/2) or Distance in cm = (Echo pulse width high time (in uS)*0.017)

3.4.2.5 Specifications
o Working 5V(DC) o Working 15mA o Working frequency : 40 KHZ 31 | P a g e Current : Voltage : o Output: 0-5V (Output high when obstacle

detected in range) o Beam Angle : Max 60 degree

o Distance 400cm

2cm

o Echo signal : PWM signal (time required for sound signal to travel twice between source and obstacle) o Size 45mm*20mm*15 mm :

o Accuracy : 0.3cm o Input trigger signal : 10us impulse TTL

3.4.3 Passive Infrared Sensor A Passive Infrared sensor (PIR sensor) is an electronic device that measures infrared (IR) light radiating from objects in its field of view. All objects above absolute zero emit energy in the form of radiation. Usually infrared radiation is invisible to the human eye but can be detected by 32 | P a g e

electronic devices designed for such a purpose. The term passive in this instance means that the PIR device does not emit an infrared beam but merely passively accepts incoming infrared radiation. Infra meaning below our ability to detect it visually, and Red because this color represents the lowest energy level that our eyes can sense before it becomes invisible. Thus, infrared means below the energy level of the color red and applies to many sources of invisible energy [4].

3.4.3.1 Design
Infrared radiation enters through the front of the sensor, known as the sensor face. At the core of a PIR sensor is a solid state sensor or set of sensors, made from an approximately 1/4 inch square of natural or artificial pyroelectric materials, usually in the form of a thin film, out of gallium nitride (GaN), cesium nitrate (CsNO3), polyvinyl fluorides, derivatives of phenylpyrazine, and cobalt phthalocyanine. (See pyroelectric crystals.) Lithium tantalate (LiTaO3) is a crystal exhibiting both piezoelectric and pyroelectric properties [9]. *Pyroelectricity: Pyroelectricity (from the Greek pyr, fire, and electricity) is the ability of certain materials to generate a temporary voltage when they are heated or cooled. A pyroelectric material generates an electric charge in response to a thermal energy flow through its body. Since all pyroelectrics are also piezoelectrics, the absorbed heat causes the front side of the sensing element to expand. The resulting thermally induced stress leads to a development of piezoelectric charge on the element electrodes. This charge is manifested as voltage across the electrodes deposited on opposite side of the material. Fig: Simplified model of a pyroelecric effect as a secondary effect of piezoelectricity. Initially, the element has a uniform temperature (a); upon exposure to thermal radiation its front side warms up and expands, causing a stress induced charge (b)
Figure 3.9 Simplified model of pyroelectric effect

33 | P a g e

3.4.3.2 Lenses Besides sensing element, a PIR detector needs a


focusing device. Some detectors employ parabolic mirrors while the Fresnel plastic lenses become more and more popular because they are inexpensive, may be molded in any desirable shape and in addition to focusing, act as windows to protect the interior of the sensor from outside moisture and pollutants.

3.4.3.3 PIR Based motion detector


In a PIR-based motion detector, the PIR sensor is typically mounted on a printed circuit board containing the necessary electronics required to interpret the signals from the pyroelectric sensor chip. The complete assembly is contained within a housing mounted in a location where the sensor can view the area to be monitored. Infrared energy is able to reach the pyroelectric sensor through the window because the plastic used is transparent to infrared radiation (but only translucent to visible light). This plastic sheet also prevents the intrusion of dust and/or insects from obscuring the sensor's field of view, and in the case of insects, from generating false alarms. The window may have multiple Fresnel lenses molded into it. Alternatively, some PIDs are manufactured with internal plastic, segmented parabolic mirrors to focus the infrared energy. Where mirrors are used, the plastic window cover has no Fresnel lenses molded into it. The PID can be thought of as a kind of infrared camera that remembers the amount of infrared energy focused on its surface. Once power is applied to the PID, the electronics in the PID shortly settle into a quiescent state and energize a small relay. This relay controls a burglar alarm control panel. If the amount of infrared energy focused on the pyroelectric sensor changes within a configured time period, the device will switch the state of the alarm relay.

34 | P a g e

3.4.3.4 Construction and Working of PIR


All living objects emit energy. This is infrared radiation with wavelengths ~10um (micrometers). This radiation is invisible to the human eye but can be detected by the Passive infrared sensor (PIR). The PIR sensor is a electronic device with two sensitive areas allocated under infrared filter window. This arrangement cancels signals caused by the sunlight, vibration and changes in ambient temperature. A man crosses the horizontal plane in front of the mounted sensors activates the first and then the second detector sensitive area. All other sources of infrared radiation do not act on the behavior of the sensor because they affect on both sensitive elements simultaneously.
Figure 3.10 Construction of PIR

Human motion leads to a change of emitted infrared energy which is detected by the PIR sensor. The sensor reacts to this change and provides a low-frequency (~10Hz) small amplitude signal. This signal amplified by the Operational Amplifier and digitized by the Analog to Digital Converter embedded into the MCU. Passive infrared sensor can sense the changes of the infrared energy within small distances till 1m. For reliable detection of human movement at the long distance it is necessary to use a Fresnel lens. Fresnel lens allows focusing infrared radiation on the sensor surface and reveals the presence of a human at a 7m distance. The lens divides the entire territory covered by a sensor on the sectors. Any movement between the sectors leads to a change in infrared energy, registered by two sensitive zones of the PIR sensor. When a person passes in front of a motion sensor, the signal from its output will initially be positive (when a person crosses the first sensor element) and then negative (when a person crosses the second sensor element). This is indicated on the Picture 3 with two zones 1 and 2. During the passage of these areas by 35 | P a g e

human in the opposite direction, the output signal from the sensor is inverted.
Figure 3.11 Working principle of PIR

3.4.3.5 Specifications
o Supply: 5V Dc to 9V DC o Detection range: 6meters o Output: 5V TTL o Static current: 50uA o Sensitivity: Presettable o Settling time: 60 seconds o Trigger:H-Yes, L-No o Block time: 2.5 S(default) o Delay time: 5 S(default) o Sentry Angle:< 110 degree o Size: Length32mm, Width 24mm, Thickness 26mm
Figure 3.12 PIR

36 | P a g e

Calibration The PIR Sensor requires a warm-up time in order to function properly. This is due to the settling time involved in learning its environment. This could be anywhere from 10-60 seconds. During this time there should be as little motion as possible in the sensors field of view. Sensitivity The PIR Sensor has a range of approximately 20 feet. This can vary with environmental conditions. The sensor is designed to adjust to slowly changing conditions that would happen normally as the day progresses and the environmental conditions change, but responds by making its output high when sudden changes occur, such as when there is motion. Applications: PIR sensors are used in many applications. They are used on television sets and television accessory devices, such as VCRs and DVD players, to detect infrared light coming from a television remote. PIR sensors are also used as motion detectors at most public doorways in grocery stores, hospitals, and libraries. PIR sensors can also be used for military purposes such as laser range-finding, night vision, and heat-seeking missiles. Advantages PIR sensors have several important advantages. They detect infrared light from several feet/yards away, depending on how the device is calibrated. PIR sensors are generally compact and can be fitted into virtually any electronic device. Also, they do not need an external power source because they generate electricity as they absorb infrared light. Disadvantages Although PIR sensors can be advantageous, they also have several disadvantages. PIR sensors can only receive infrared light and cannot emit it like other types of infrared sensors. They can be expensive to purchase, install, and calibrate as well.

3.4.4 IR Based Obstacle Sensor sInfrared (IR) light is electromagnetic radiation with a wavelength longer than that of visible light, measured from the nominal edge of visible red light at 0.74 micrometers (m), and extending conventionally to 300 m. These wavelengths correspond to a frequency range of approximately 1 to 400 THz, and include most of the thermal radiation emitted by objects near room temperature. Much of the energy from the Sun arrives on Earth in the form of infrared radiation .

Figure 3.13 IR spectrum

There are certain transducers, which emits and sense IR rays. The principal is just to transmit IR rays and sense the reflect signal if there is any obstacle. Similarly if there is any other IR signal transmitting at one end can be can be decoded at other end. For transmitting Infrared we use IR LDR and sensing we use IR receiver. Inexpensive infrared receiver chips are available. The receivers are sensitive to oscillations several kilohertz to either side, although reception distance improves with a better signal to start with. If used for object detection, the signal needs to travel the distance to the object, bounce off the object, and then travel the distance back to the receiver. So, distance becomes a factor.
Figure 3.14 IR Obstacle detection

3.4.4.1 Working

When IR LED is given a supply it emits IR light. This light when strikes a target it gets reflected, whose proportional depends on distance of obstacle and color of obstacle. For white color reflection is more and for black surface its less. There it is picked up with phototransistor. This phototransistor can be used to measure proportional of reflected IR light. Initially resistance of photo transistor is very high. Depending on the proportion of IR light incident on its resistance gets reduce. To Figure 3.15 IR obstacle detector circuit measure change in resistance, phototransistor is given a VCC supply. According to ohms law, change in resistance results change in voltage drop across it. This Voltage in measured which is proportional to picked up light intensity. Comparator or ADC is used to convert it to digital form and decide, if there is an obstacle in front of us. For example if 5 Volts supply is used: 4.5 Volts mean obstacle is far, and 1 Volt means obstacle is close. Since infrared spectrum lies between visible and microwave portion of electromagnetic spectrum, all the signals received by normal IR receiver are detected as obstacle. This will create a problem. To solve this problem we can select a receiver which will allow a range of frequency as that of transmitter. This can be done by selecting TSOP1738 IR receiver that will allow only 38 KHz frequency and filter out all other frequencies. So to generate a frequency of 38 KHz at transmitter we need an oscillator which will drive it. For feeding 38 KHz oscillation to IR LED, 555 timer IC is used.

3.4.4.2 Circuit description & working for oscillator


In the circuit, 555 IC works as oscillator. This circuit provides oscillation of 38KHZfrequency. This type of relaxation oscillator for generating stabilized square wave output

waveforms of either a fixed frequency of up to 500 KHz or of varying duty cycles from 50 to 100%. Here 555 IC is working as Astable Oscillator [18]. In astable mode, the 555 timer puts out a continuous stream of rectangular pulses having a specified frequency. Resistor R1 is connected between VCC and the discharge pin (pin 7) and another resistor (R2) is connected between the discharge pin (pin 7), and the trigger (pin 2) and threshold (pin 6) pins that share a common node. Hence the capacitor is charged through R1 and R2, and discharged only through R2, since pin 7 has low impedance to ground during output low intervals of the cycle, therefore discharging the capacitor. In the astable mode, the frequency of the pulse stream depends on the values of R1, R2 and C:
[7]

Figure 3.16 Oscillator circuit for IR transmission

The high time from each pulse is given by (t1): and the low time from each pulse is given by (t2): where R1 and R2 are the values of the resistors in ohms and C is the value of the capacitor in farads. The power capability of R1 must be greater than V2cc /R1 Particularly with bipolar 555s, low values of R1 must be avoided so that the output stays saturated near zero volts during discharge, as assumed by the above equation. Otherwise the output low time will be greater than calculated above. After calculation for 38 KHz oscillation using 555IC we get R1= 1K, R2= 10K pot, C1=0.01F, C2= 0.01F, C3=0.1F

Figure 3.17 Waveforms

3.4.4.3 IR transmitter LED


IR transmitter is a transducer which emits the light in form of infra red rays. In our project we are modulating signal in 38 KHz and emit that modulated signal by infra red transducer.
Figure 3.18 IR Transmitter LED

Figure 3.19 TSOP1738 IR receiver

3.4.4.4 TSOP1738 IR receiver


The TSOP17: series are miniaturized receivers for infrared remote control systems. PIN diode and preamplifier are assembled on lead frame, the epoxy package is designed as IR filter. The demodulated output signal can directly be decoded by a microprocessor. TSOP17.. is the standard IR remote control receiver series, supporting all major transmission codes. In the device number, end 2 numbers indicates the frequency range. In our project we are using TSOP1738, which means that it can operate in range of 38 KHz.

Features of TSOP1738 Photo detector and preamplifier in one package Internal filter for PCM frequency Improved shielding against electrical field disturbance TTL and CMOS compatibility Output active low Low power consumption High immunity against ambient light Continuous data transmission possible (1200 bit/s) Suitable burst length 10 cycles/burst

Features of obstacle sensor


Figure 3.20 Block Diagram of TSOP1738

Very cheap Quite reliable Can be used for detection of obstacle for a range up to 12 cm.

Need of IR based obstacle sensor Obstacle sensor is used in industries, automated systems, robots etc. These sensors are available at very cheap rate. So it is widely used. We had used this to detect and measure the distance. This method is quite reliable and at a best rate.

3.4.5 Global Positioning System Introduction to GPS The Global Positioning System (GPS) is a satellite-based navigation system that consists of 24 orbiting satellites, each of which makes two circuits around the Earth every 24 hours. These satellites transmit three bits of information the satellite's number, its position in space, and the time the information is sent. These signals are picked up by the GPS receiver, which uses this information to calculate the distance between it and the GPS satellites. With signals from three or more satellites, a GPS receiver can triangulate its location on the ground (i.e., longitude and latitude) from the known position of the satellites. With four or more satellites, a GPS receiver can determine a 3D position (i.e., latitude, longitude, and elevation). In addition, a GPS receiver can provide data on your speed and direction of

travel. Anyone with a GPS receiver can access the system. Because GPS provides real-time, three-dimensional positioning, navigation, and timing 24 hours a day, 7 days a week, all over the world, it is used in numerous applications, including GIS data collection, surveying, and mapping. What attracts us to GPS is

The relatively high positioning accuracies, from tens of meters down to the millimeter level. The capability of determining velocity and time, to an accuracy commensurate with position. The signals are available to users anywhere on the globe: in the air, on the ground, or at sea. It is a positioning system with no user charges that simply requires the use of relatively low cost hardware. It is an all-weather system, available 24 hours a day. The position information is in three dimensions, that is, vertical as well as horizontal information is provided.

3.4.5.1 How it works


GPS satellites circle the earth twice a day in a very precise orbit and transmit signal information to earth. GPS receivers take this information and use triangulation to calculate the user's exact location. Essentially, the GPS receiver compares the time a signal was transmitted by a satellite with the time it was received. The time difference tells the GPS receiver how far away the satellite is A GPS receiver must be locked on to the signal of at least three satellites to calculate a 2D position (latitude and longitude) and track movement. With four or more satellites in view, the receiver can determine the user's 3D position (latitude, longitude and altitude).

3.4.5.2. Navigation equations


The x, y, and z components of satellite position and the time sent are designated as [xi, yi, zi, ti] where the subscript i denotes the satellite and has the value 1, 2, ..., n, where Knowing when the message was received , the receiver computes the message's transit time as . Note that the receiver indeed knows the reception time indicated by its on-board clock, rather than . Assuming the message traveled at the speed of light (c) the

distance traveled is (tr ti)c. Knowing the distance from receiver to satellite and the satellite's position implies that the receiver is on the surface of a sphere centered at the satellite's position. Thus the receiver is at or near the intersection of the surfaces of the spheres. In the ideal case of no errors, the receiver is at the intersection of the surfaces of the spheres. Let b denote the clock error or bias, the amount that the receiver's clock is off. The receiver has four unknowns, the three components of GPS receiver position and the clock bias [x, y, z, b]. The equations of the sphere surfaces are given by:

or in terms of pseudoranges,

, as

.
These equations can be solved by algebraic or numerical methods .

3.4.5.3 Trilateration
Trilateration is used to determine the position based on three satellite's pseudoranges. In the usual case of two intersections, the point nearest the surface of the sphere corresponding to the fourth satellite is chosen. Let d denote the signed distance from the receiver position to the sphere around the fourth satellite. The notation, d(correction) shows this as a function of the correction, because it changes the pseudoranges. The problem is to determine the correction such that d(correction) = 0. This is the familiar problem of finding the zeroes of a one dimensional non-linear function of a scalar variable.

Certain atmospheric factors and other sources of error can affect the accuracy of GPS receivers. Users can also get better accuracy with Differential GPS (DGPS), which corrects GPS signals to within an average of three to five meters. The U.S. Coast Guard operates the most common DGPS correction service. This system consists of a network of towers that

receive GPS signals and transmit a corrected signal by beacon transmitters. In order to get the corrected signal, users must have a differential beacon receiver and beacon antenna in addition to their GPS.

3.4.5.4 The GPS satellite system


The 24 satellites that make up the GPS space segment are orbiting the earth about 12,000 miles above us. They are constantly moving, making two complete orbits in less than 24 hours. These satellites are travelling at speeds of roughly 7,000 miles an hour. GPS satellites are powered by solar energy. They have backup batteries onboard to keep them running in the event of a solar eclipse, when there's no solar power. Small rocket boosters on each satellite keep them flying in the correct path.

Figure 3.21 GPS satellite system

3.4.5.5 Signals in GPS


GPS satellites transmit two low power radio signals, designated L1 and L2. Civilian GPS uses the L1 frequency of 1575.42 MHz in the UHF band. The signals travel by line of sight, meaning they will pass through clouds, glass and plastic but will not go through most solid objects such as buildings and mountains. A GPS signal contains three different bits of information - a pseudorandom code, ephemeris data and almanac data. The pseudorandom code is simply an I.D. code that identifies which satellite is transmitting information. You can view this number on your Garmin GPS unit's satellite page, as it identifies which satellites it's receiving. Ephemeris data, which is constantly transmitted by each satellite, contains important information about the status of the satellite (healthy or unhealthy), current date and time. This part of the signal is essential for determining a position. The almanac data tells the GPS receiver where each GPS satellite should be at any time throughout the day. Each satellite transmits almanac data showing the orbital information for that satellite and for every other satellite in the system.

3.4.5.6 Sources of GPS signal errors


Factors that can degrade the GPS signal and thus affect accuracy include the following:

Ionosphere and troposphere delays - The satellite signal slows as it passes through the atmosphere. The GPS system uses a built-in model that calculates an average amount of delay to partially correct for this type of error. Signal multipath - This occurs when the GPS signal is reflected off objects such as tall buildings or large rock surfaces before it reaches the receiver. This increases the travel time of the signal, thereby causing errors. Receiver clock errors - A receiver's built-in clock is not as accurate as the atomic clocks onboard the GPS satellites. Therefore, it may have very slight timing errors. Orbital errors - Also known as ephemeris errors, these are inaccuracies of the satellite's reported location. Number of satellites visible - The more satellites a GPS receiver can "see," the better the accuracy. Buildings, terrain, electronic interference, or sometimes even dense foliage can block signal reception, causing position errors or possibly no position reading at all. GPS units typically will not work indoors, underwater or underground. Satellite geometry/shading - This refers to the relative position of the satellites at any given time. Ideal satellite geometry exists when the satellites are located at wide angles relative to each other. Poor geometry results when the satellites are located in a line or in a tight grouping. Intentional degradation of the satellite signal - Selective Availability (SA) is an intentional degradation of the signal once imposed by the U.S. Department of Defense. SA was intended to prevent military adversaries from using the highly accurate GPS signals. The government turned off SA in May 2000, which significantly improved the accuracy of civilian GPS receivers.

3.4.5.7 GPS Module in our Project


In our project we have used GPS Receiver MT3318 USB Module. GPS Receiver MT3318 USB Module is based on the MediaTek MTK MT3318 chipset. It has active patch antenna from Cirocomm. It can track 51 satellites simultaneously. It can be directly connected to the PC via USB port. It has onboard FT232 USB to serial converter of interfacing GPS with the PCs USB port. GPS receiver is mounted on the PCB along with the 3.3V low drop voltage regulator, Figure 3.23 GPS MT3318 USB Module transmit, receive and power indication LEDs, Schmitt triggers based buffer for 5V to 3.3V logic level conversion and FT232 USB to serial converter. GPS receiver gives data output in standard NMEA format with update rate of 1 second at 9600 bps. Receiver has onboard battery for memory backup for quicker acquisition of GPS satellites. GPS module is powered by USB port of the PC.

3.4.5.8 Specifications
Supply: 5V, 40mA, Built in RTC power battery (3V) for location data retention Chipset: MTK MT3318 Antenna: High gain GPS patch antenna from Cirocomm Data output: CMOS UART interface at 3.3V Protocol: NMEA-0183@9600bps (Default) at update rate of 1 second. Protocol message support: GGA, GSA, GSV,RMC, VTG No. of Satellite simultaneously tracked: 51 Tracking Sensitivity: On-module antenna : -157dBm Position Accuracy : <3 m Max. Update Rate5Hz (Default: 1 Hz) Obscuration recovery: 0.1 second average Hot start: <1 seconds average Warm start: <34 seconds average

Cold start: <36 seconds average GPS Receiver Size: 30mm x 70mm Onboard FT232 USB to serial converter Onboard 3.3V low drop voltage regulator 3.4.6 LM35 Temperature Sensor

Introduction: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 0Kelvin, 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 +_ 1/40C at room temperature and +_3/40C over a full -55 to a1500C temperature range. Low cost is assured by trimming and calibration at the wafer level. The LM35's low output impedance, linear output, and precise inherent calibration make 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 mA from its supply, it has very low self-heating, less than 0.1 0C in still air. The LM35 is rated to operate over a -550 to 150C temperature range, while the LM35C is rated for a -400 to a1100C range (-100 with improved 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-202 package [10].

Features:o Calibrated directly in 0 Celsius


(Centigrade) o Low cost due to wafer-level trimming o o Operates from 4 to 30 volts Less than 60 mA current drain

o Linear a 10.0 mV/0C scale


factor

o 0.50C accuracy guarantee able


(at a250C)

o Low self-heating, 0.080C in


still air

o Rated for full -550 to a1500C


range o Suitable for remote applications

o Nonlinearity only +-1/40C


typical

o Low impedance output, 0.1


ohm for 1 mA load

Need of temperature sensor in our project Temperature sensor is used to measure temperature so as to control the overall temperature.

3.4.7 Data Sharing Methods Up till now we have seen how data is collected from various sensors using PIC18F4550 microcontroller in PC. The aim of this project is to make wireless using Wi-Fi. So we have to share the collected data in local network and on internet. This can be done by various ways. Some of them are described below [11]. File sharing: One of the most common network systems for sharing files, printers, and other resources is the Server Message Block (SMB) protocol. This protocol is at the core of Microsoft Windows networking, and it also works with Macintosh OS X and Linux/Unix systems. Therefore, exchanging files among computers that run different operating systems is not a problem, even though the files themselves might not always be compatible (for example, you probably cant run a program written for Windows on a Linux system). Many operating systems support more than one networking protocol, but when you run a mixed network, or if its remotely possible that a visitor with a different kind of computer (such as a Mac or Linux laptop) might want to connect to your network, its best to use the most common protocols. Control of file sharing rests with the computer that holds each file, so other people cant open and read your files without your permissioneven if they have a login account (or theyre using a guest account) on the same computer. In order to share files with other users, you must turn on your operating systems filesharing service and then assign an access level (universal, limited, or none) to each folder or directory. Creating a PHP webpage and sharing it over a network: PHP is a general-purpose server-side scripting language originally designed for Web development to produce dynamic Web pages. PHP was originally created by Rasmus Lerdorf in 1995. The main implementation of PHP is now produced by The PHP Group and serves as the formal reference to the PHP language. PHP is free software released under the PHP License. It is one of the first developed server-side scripting languages to be embedded into an HTML source document, rather than calling an external file to process data. Ultimately, the code is interpreted by a Web server with a PHP processor module which generates the resulting Web page. It also has evolved to include a command-line interface capability and can be used in standalone graphical applications.PHP can be deployed on most Web servers and also as a

standalone shell on almost every operating system and platform free of charge. Any PHP code in a requested file is executed by the PHP runtime, usually to create dynamic web page content or dynamic images used on Web sites or elsewhere. HTML is used only to display the scripted page. So it cant be used for real-time data where the value changes from time to time. Here PHP plays important role. It can be used for real time data by updating the values according the data entry in MySQL [2].

Using Opera Unite Opera Unite is an extensible framework that allows for several web services (referred to as "Applications") to be hosted from the user's computer, including a web server for hosting a site, file and photo sharing, a chat room, and streaming media. Opera Software has released an API to create new or improved applications for the Opera Unite Platform, and many have already done so. An Opera Unite user's applications run on a domain associated with their My Opera Community account, and are accessible from any web browser. For these applications to be accessed, the computer and the Opera Browser hosting the applications must both be running. The included API uses HTML, CSS, client-side ECMAScript and a new server-side JavaScript technology with local file access and persistent storage. Unite Applications are packaged according to the W3C Widgets 1.0 specification. Opera also provides a vetted facility for developers to upload these user-created applications. Unite has been included standard since version 10.10.

Sharing using FTP File Transfer Protocol (FTP) is a standard network protocol used to transfer files from one host to another host over a TCP-based network, such as the Internet. It is often used to upload web pages and other documents from a private development machine to a public web-hosting server. FTP is built on client-server architecture and uses separate control and data connections between the client and the server. FTP users may authenticate themselves using a clear-text sign-in protocol, normally in the form of a username and password, but can connect anonymously if the server is configured to allow it. For secure transmission that hides (encrypts) our username and password, as well as encrypts the content, we can try using a client that uses SSH File Transfer Protocol.

Remote Desktop Remote desktop is an application allows the user to control the desktop and indeed, the entire contents of one computer from second machine. This application gives the "master" computer access to all of the contents on the remote computer, and often provides features like file transfer and text chat. One version of the remote desktop application comes standard with all new Windows computers, but other versions are available for that operating system (OS) as well as for Mac and Linux as well as between systems, such as Linux and Windows. This remote control can be established in number of ways, including over wide area network (WAN), Local area network (LAN), Wireless Local area network (WLA) or over the Internet. There are various professional first-party, third-party, open source, and freeware remote desktop applications.

3.4.7.1 Selection of sharing techniques


So we have seen that there are various ways of sharing the data in network. For project purpose we are implementing 2 techniques seeing to its advantages and simplicity. We have implemented sharing using Opera Unite and Remote desktop. Its advantages are described below. Advantages of Opera Units Its User friendly Available free of cost Sharing can be done over local network as well as on internet. Has a password protection. No additional hardware or any installation is required except Opera software. Web Proxy provides fully-functional remote access to local Web Server, allows executing PHP/Perl/Python/etc scripts.

Advantages of Remote desktop It is secure connection due to encrypted data.

Its password protected User friendly Fast and Flexible Allows us to set and control applications and softwares at remote location

3.4.7.2 Opera Units


Opera Unite aims to be a collaborative program that allows you to share files with loved ones or colleagues without having to go through a central, third-party server (as illustrated below).

Figure 3.24 Opera data sharing unit

3.4.7.2.1 How does it work?


In Opera Unite our are in control. We can dictate which files and folders are shared on the server and which ones are not. You are given a unique URL which provides a link to the files you choose to share. Whoever you choose to share with can use that link to access photos, videos, or anything else on their own web-connected computer. Its shocking how easy it is to set up and implement. I have never come across a file sharing program that was so user-friendly.

3.4.7.2.1 Steps for Installation and setting up for sharing

1. Install the latest version of the Opera Browser (11.00 or later).

Figure 3.25 Downloading opera web page - Step1

2. Install Opera Browser

3. After installing, open the opera browser form installed location. After opening click on Opera > Opera Unite > Enable Opera Unit

Figure 3.26 Opera Unite Installation and setting - Step2

4. After clicking you will be asked for login. If u dont have account click on I dont have an account and create new one.

5. After creating account it will get automatically. After log in the configuring page will appear. Here you have to set u a name for computer. Set the name and click on finish.

Figure 3.27 Opera Unite Installation and setting - Step3

6. Now pc is ready for sharing. Next step is so select the file location which is to be shared. This can be done by clicking on Opera unit symbol > file sharing configuration present left side of 7. Opera browser. After opening the configuration window, select the location.

Figure 3.28 Opera Unite Installation and setting - step4

Now the system is ready to share the log data files on internet as well as on local area network.

3.4.7.3 Remote Desktop


We have seen the advantages of remote desktop. Also in future development of this project, we can control the device seating at remote location. It will help in manually controlling of various devises in industry seating at remote location. If ISP provides static IP address, then we can control the devices seating at any part of the world by using internet connection. So further on we will see how Remote Desktop works and how to setup the system for remote desktop using Microsoft Windows 7.

3.4.7.3.1 Working of Remote Desktop


Remote desktop requires that the client, or "master," and remote, also called the "slave" or host, computers be connected to the same network.

This remote desktop network can be wired or wireless. Wired networks can use direct connections or connections through routers, while wireless networks can be formed using routers or the Internet. It is quite common for a remote desktop application to be used to control a host computer that is far from the client, connected only via the Internet.

Advanced security protocols are standard practice in remote desktop software, especially when the network is a wireless and/or Internet one. The nature of this application, allowing another computer to control the host machine, makes security extremely important. Anyone running remote desktop software, even if the connection is direct wired, should make sure that the connection is secure and password protected to reduce the possibility that an unauthorized user could access the remote computer. Certain safety features may be built into the remote desktop software protocols such that the client computer is not able to delete or otherwise alter files without the remote user's permission. Once the administrator has entered the correct password, the remote desktop software enables that administrator to access the remote computer. After establishing the connection, the master computer displays a copy of the image received from the controlled slave display screen. The copy is updated on a timed interval, or when a change on screen is noticed by the remote control software. The software on the master computer transmits its own keyboard and mouse activity to the slave computer, where the remote control software implements these actions. The slave computer then behaves as if the actions were performed directly at that computer. In many cases the local display and input devices can be disabled so that the remote session cannot be viewed or interfered with. The quality, speed and functions of any remote desktop protocol are based on the system layer where the graphical desktop is redirected. Software such as VNC and others use the top software layer to extract and compress the graphic interface images for transmission. Other products such as Microsoft RDP use a kernel driver level to construct the remote desktop for transmission of data. The person using the client computer can use any software on the remote machine, and access any files. Software maintenance is one of the most common uses of remote desktop software, allowing an administrator to shut down a malfunctioning software application or install a software upgrade. This saves the time that it would take the administrator to physically insert a CD or other storage device into the host computer or to do a manual software upgrade download. In most cases, the host computer is still able to access all of its core functions; it may be possible to lock or disable the peripheral devices on the host computer, however, so that a user cannot interfere with the client actions. With some software, many of these functions, including the main

clipboard, can also be shared between the remote computer and the client. This software may even allow the client administrator to run an audio or video application on a remote computer and have the sights and/or sounds redirected to the client machine. When windows remote option is used, the application works using Remote Desktop Protocol. Remote Desktop Protocol is a proprietary protocol developed by Microsoft, which provides a user with a graphical interface to another computer. The protocol is an extension of the ITU-T T.128 application sharing protocol. Clients exist for most versions of Microsoft Windows (including Windows Mobile), Linux, Unix, Mac OS X, Android, and other modern operating systems. By default the server listens on TCP port 3389. Every Windows version beginning with Windows XP (excluding 'Home' edition) includes an installed Remote Desktop Connection (RDC) ("Terminal Services") client (mstsc.exe) whose version is determined by that of the operating system or last applied Windows Service Pack. The Terminal Services server is supported as an official feature on Windows NT 4.0 Terminal Server Edition, Windows 2000 Server, all editions of Windows XP except Windows XP Home Edition, Windows Server 2003, Windows Home Server, on Windows Fundamentals for Legacy PCs, in Windows Vista Ultimate, Enterprise and Business editions, Windows Server 2008 and Windows Server 2008 R2 and on Windows 7 Professional and above. Microsoft provides the client required for connecting to newer RDP versions for down level operating systems. Since the server improvements are not available down level, the features introduced with each newer RDP version only work on down level operating systems when connecting to a higher version RDP server from these older operating systems, and not when using the RDP server in the older operating system. Up till now Microsoft has release 8 Version. The newest of is Version7.1 which is appeared in Windows 7 SP1 and Server 2008 R2 SP1.

3.4.7.3.2 Features offered


32-bit color support. 8-, 15-, 16-, and 24-bit color are also supported.

128-bit encryption, using the RC4 encryption algorithm, as of Version 6. Audio Redirection allows users to run an audio program on the remote desktop and have the sound redirected to their local computer. File System Redirection allows users to use their local files on a remote desktop within the terminal session. Printer Redirection allows users to use their local printer within the terminal session as they would with a locally or network shared printer. Port Redirection allows applications running within the terminal session to access local serial and parallel ports directly. The clipboard can be shared between the remote computer and the local computer. Seamless Windows: Remote applications can run on a client machine that is served by a Remote Desktop connection. It uses virtual channel method, and available since RDP 5. RemoteFX: RemoteFX provides virtualized GPU support and host side encoding and is being shipped as part of Windows Server 2008 R2 SP1.

The following features were introduced with the release of RDP 6.0 in 2006: Remote Programs: Application publishing with client-side file type associations. Terminal Services Gateway: Enables the ability to use a front-end IIS server to accept connections (over port 443) for back-end Terminal Services servers via an https connection, similar to how RPC over https allows Outlook clients to connect to a back-end Exchange 2003 server. Requires Windows Server 2008 Network Level Authentication Support for remoting the Aero Glass Theme (or Composed Desktop), including ClearType font smoothing technology.

Support for remoting of Windows Presentation Foundation applications: Compatible clients that have .NET Framework 3.0 support will be able to display full Windows Presentation Foundation effects on a local machine. Rewrite of device redirection to be more general-purpose, allowing a greater variety of devices to be accessed. Fully configurable and scriptable via Windows Management Instrumentation. Improved bandwidth tuning for RDP clients. Support for Transport Layer Security (TLS) 1.0 on both server and client ends (can be negotiated if both parties agree, but is not mandatory in a default configuration of any version of Windows). Multiple monitor support for allowing one session to use multiple monitors on the client (disables desktop composition)

3.4.7.3.3 Configure for a Remote Desktop Connection in windows 7


First we need is to allow to pass the Remote Desktop application if there is any Firewall blocking it. 1. Click the Computer icon and choose properties, or you can type in system into the start menu search box, and then find the entry for System.

Figure 3.29-Configuring Remote desktop - step1

2.

Click Remote settings in the Tasks list on the left side of the System window.

Figure 3.30 Configure for a Remote Desktop - Step2

3. Now you can finally turn it on:

Figure 3.31 Configure for a Remote Desktop - Step3

Select Allow Remote Assistance connection to this computer to allow for remote connection. To connect from another Vista / Win7 PC on the same network, click the bottom radio button. If you need to connect from an XP/2k machine, click the Allow connections from computers running any version of Remote Desktop radio button. Now the system is ready for remote desktop connection.

3.4.7.3.4 Connecting to a Remote Desktop in windows 7


1. Go to Start (the Orb) > All Programs > Accessories > Remote Desktop Connection

Figure 3.32 Connecting to remote desktop - step1

2. In the Remote Desktop Connection window, Type the address of the remote computer in the Computer: text box and then click Connect.

Figure 3.33 Connecting to remote desktop - Step2

3. After clicking on connect you will be asked for User name and password. Just enter it and get connected to remote computer. 3.4.8 Software Development For WDAS Software design is a process of problem solving and planning for a software solution. After the purpose and specifications of software are

determined, software developers will develop a plan for a solution. It includes low-level component and algorithm implementation issues as well as the architectural view. Design considerations while programming: There are many aspects to consider in the design of a piece of software. The importance of each should reflect the goals the software is trying to achieve. Some of these aspects are

Compatibility - The software is able to operate with other products that are designed for interoperability with another product. For example, a piece of software may be backward-compatible with an older version of itself. Extensibility - New capabilities can be added to the software without major changes to the underlying architecture. Fault-tolerance - The software is resistant to and able to recover from component failure. Maintainability - The software can be restored to a specified condition within a specified period of time. For example, antivirus software may include the ability to periodically receive virus definition updates in order to maintain the software's effectiveness. Modularity - the resulting software comprises well defined, independent components. That leads to better maintainability. The components could be then implemented and tested in isolation before being integrated to form a desired software system. This allows division of work in a software development project. Packaging - Printed material such as the box and manuals should match the style designated for the target market and should enhance usability. All compatibility information should be visible on the outside of the package. All components required for use should be included in the package or specified as a requirement on the outside of the package. Reliability - The software is able to perform a required function under stated conditions for a specified period of time. Reusability - the software is able to add further features and modification with slight or no modification. Robustness - The software is able to operate under stress or tolerate unpredictable or invalid input. For example, it can be designed with a resilience to low memory conditions.

Security - The software is able to withstand hostile acts and influences. Usability - The software user interface must be usable for its target user/audience. Default values for the parameters must be chosen so that they are a good choice for the majority of the users.

Software development for WDAS is divided in two parts. One is developing software for PC to communicate with microcontroller and log the data, where as the other is for the microcontroller for configuring the controller and send the data to PC. The important thing before beginning of programming is to collect all the data for configuring the ports. After that, we need to study the steps in which way communication should be done; data should be fetched and logged in PC.

3.4.8.1 Software developing for microcontroller PIC18F4550


Simplicity and ease which higher programming languages bring in, as well as broad application of microcontrollers today, were reasons to incite some companies to adjust and upgrade BASIC programming language to better suit needs of microcontroller programming. This change is for developing applications is faster and easier with all the predefined routines which BASIC brings in, whose programming in assembly would take the largest amount of time. Before going further lets see the basic definitions used in programming Programming language: It is a set of commands and rules according to which we write the program. There are various programming languages such as BASIC, C, Pascal, etc. There are plenty of resources on BASIC programming language out there, so we will focus our attention particularly to programming of microcontrollers. Program: It consists of a sequence of commands written in programming language that microcontroller executes one after another. Compiler is a program run on computer and its task is to translate the original BASIC, C, Pascal code into language of zeros and ones that can be fed to microcontroller. The process of translation of program written in MPLab IDE C language into executive HEX code is shown in the figure below in fig. The program written in C and saved as file program. C is converted by compiler into assembly code (program.asm). The generated assembly code is further translated into executive HEX code which can be written to microcontroller memory. Programmer is a device which we use to transfer our HEX files from computer to microcontroller memory.

Before beginning for writing program for microcontroller we list out the sensors that are to be connected, its format of output, its in digital or analog output. After listing we allocated the ports for sensors. We studied the registers which are to me initializing. For initializing port as simple I/O, A/D converter communications are as follow:

3.4.8.1.1 Simple I/O


Depending on the device selected and features enabled, there are up to five ports available. Some pins of the I/O ports are multiplexed with an alternate function from the peripheral features on the device. In be used as a general purpose I/O pin. Each port has three registers for its operation [7]. These TRIS register (data direction register) PORT register (reads the levels on the pins of the device) LAT register (output latch) The Data Latch register (LATA) is useful for read-modify- write operations on the value driven by the I/O pins. By clearing some bit of the TRIS register (bit=0), the corresponding port pin is configured as output. Similarly, by setting some bit of the TRIS register (bit=1), the corresponding port pin is configured as input. This rule is easy to remember 0 = Output, 1 = Input.

Figure 3.34 Simple I/O

Port A and TRISA Register: PORTA is an 8-bit wide, bidirectional port. The corresponding data direction register is TRISA. Reading the PORTA register reads the status of the pins; writing to it will write to the port latch.

Figure 3.35 Port A and TRISA Register

The Data Latch register (LATA) is also memory mapped. Readmodify-write operations on the LATA register read and write the latched output value for PORTA. The RA4 pin is multiplexed with the Timer0 module clock input to become the RA4/T0CKI pin. The RA6 pin is multiplexed with the main

oscillator pin; it is enabled as an oscillator or I/O pin by the selection of the main oscillator in Configuration Register 1H. When not used as a port pin, RA6 and its associated TRIS and LAT bits are read as 0. RA4 is also multiplexed with the USB module; it serves as a receiver input from an external USB transceiver. Several PORTA pins are multiplexed with analog inputs, the analog VREF+ and VREF- inputs and the comparator voltage reference output. The operation of pins RA5 and RA3:RA0 as A/D converter inputs is selected by clearing/setting the control bits in the ADCON1 register (A/D Control Register 1). All other PORTA pins have TTL input levels and full CMOS output drivers. The TRISA register controls the direction of the RA pins, even when they are being used as analog inputs. The user must ensure the bits in the TRISA register are maintained set when using them as analog inputs.

Port B and TRISB Register Each of the PORTB pins has a weak internal pull-up. A single control bit can turn on all the pull-ups. This is performed by clearing bit, RBPU (INTCON2<7>). The weak pull-up is automatically turned off when the port pin is configured as an output. The pull-ups are disabled on a Power-on Reset.

Figure 3.36 PORTB and TRISB Register

Four of the PORTB pins (RB7:RB4) have an interrupt-on- change feature. Only pins configured as inputs can cause this interrupt to occur. Any RB7:RB4 pin configured as an output is excluded from the interrupt-onchange comparison. Pins, RB2 and RB3, are multiplexed with the USB peripheral and serve as the differential signal outputs for an external USB transceiver (TRIS configuration). RB4 is multiplexed with CSSPP, the chip select function for the Streaming Parallel Port (SPP) TRIS setting. Similarly we can configure ports C, D and E and their corresponding TRISC, TRISD and TRISE registers respectively.

3.4.8.1.2 A/D converter


Many electrical signals around us are Analog in nature. That means a quantity varies directly with some other quantity. The first quantity is mostly voltage while that second quantity can be anything like temperature,

pressure, light, force or acceleration. For example in LM35 temperature sensor the output voltage varies according to the temperature, so if we could measure voltage, we can measure temperature [6], [20]. But most of our computer (or Microcontrollers) are digital in nature. They can only differentiate between HIGH or LOW level on input pins. For example if input is more than 2.5v it will be read as 1 and if it is below 2.5 then it will be read as 0 (in case of 5v systems). So we cannot measure voltage directly from MCUs. To solve this problem most modern MCUs have an ADC unit. ADC stands for analog to digital converter. It will convert a voltage to a number so that it can be processed by a digital system like MCU. The ADC takes a VSS-VDD (0-5V on my PIC MCU) DC signal as its input and then converts the voltage to a digital value.PPIC18F4550 has 10 bit ADC module. Using the 10-bit ADC, this means that a voltage level of 0V should be read as 0, and 5V as 1023 (2^10 - 1). The ADC module on the PIC18F4550 has five registers associated with it (page 267 in the datasheet):

Result High Register (ADRESH) Result Low Register (ADRESL) Control Register 0 (ADCON0) Control Register 1 (ADCON1) Control Register 2 (ADCON2)

We will start by configuring the ADCON0 control register. bit 7-6 Unimplemented: Read as 0

Figure 3.37 ADCON0 control register

bit 5-2 CHS3:CHS0: Analog Channel Select bits 0000 = Channel 0 (AN0) 0100 = Channel 4 (AN4) 0001 = Channel 1 (AN1) 0101 = Channel 5 (AN5)(1,2) 0010 = Channel 2 (AN2) 0110 = Channel 6 (AN6)(1,2) 0011 = Channel 3 (AN3) 0111 = Channel 7 (AN7)(1,2)

1000 = Channel 8 (AN8) 1100 = Channel 12 (AN12) 1001 = Channel 9 (AN9) 1101 = Unimplemented(2) 1010 = Channel 10 (AN10) 1110 = Unimplemented(2) 1011 = Channel 11 (AN11) 1111 = Unimplemented(2) bit 1 GO/DONE: A/D Conversion Status bit When ADON = 1: 1 = A/D conversion in progress 0 = A/D Idle bit 0 ADON: A/D On bit 1/0 = A/D converter module is enabled disable Configuring ADCON0 control register ADCON0bits.ADON = 0; // Disable A/D module ADCON0bits.CHS0 = 0; // Select channel 0 (AN0) ADCON0bits.CHS1 = 0; ADCON0bits.CHS2 = 0; ADCON0bits.CHS3 = 0; Only one channel (I/O pin) may be sampled at one time. ADCON0 (page 261 in 18F4550 datasheet) can be used to select the channel. It can also be used to enable the A/D converter module (something that needs to be done before any A/D conversions will take place) and to check whether an A/D conversion has completed. The CHS3:CHS0 (Channel Select) bits are used to select the channel that will be sampled when the GO_DONE bit is set. I'm only using one analog input and so I decided to use channel 0 (AN0), as this will leave the rest of the I/O pins available as digital inputs or outputs. I choose channel 0 by clearing bits CHS3:CHS0 and, since I'm not using any other channels, I will always leave them cleared. If you use multiple channels, just change the CHS3:CHS0 bits to select the channel you want to sample then set the GO_DONE bit to start the sample/conversion process. Next is the ADCON1 register.

Figure 3.38 ADCON1 register

bit 7-6 Unimplemented: Read as 0 bit 5 VCFG0: Voltage Reference Configuration bit (VREF- source) 1 = VREF- (AN2) 0 = VSS bit 4 VCFG0: Voltage Reference Configuration bit (VREF+ source) 1 = VREF+ (AN3) 0 = VDD bit 3-0 PCFG3:PCFG0: A/D Port Configuration Control bits:

Figure 3.39 PCFG register

This register controls which I/O pins are analog and which are digital. As previously mentioned, I chose to use channel 0 so that the rest of the pins would be available as digital I/O. Two bits in the register also determine what the voltage reference source is. ADCON1 configuration:
ADCON1bits.VCFG1 ADCON1bits.VCFG0 ADCON1bits.PCFG0 digital ADCON1bits.PCFG1 ADCON1bits.PCFG2 ADCON1bits.PCFG3 = 0; // Use VSS for Vref- source = 0; // Use VDD for Vref+ source = 0; // Make AN0 pin analog and all others = 1; = 1; = 1;

The last configuration register is ADCON2.

Figure 3.40 ADCON2 Register

bit 7 ADFM: A/D Result Format Select bit 1 = Right justified 0 = Left justified bit 6 Unimplemented: Read as 0 bit 5-3 ACQT2:ACQT0: A/D Acquisition Time Select bits 111 = 20 TAD 011 = 6 TAD 110 = 16 TAD 010 = 4 TAD 101 = 12 TAD 001 = 2 TAD 100 = 8 TAD 000 = 0 TAD(1) bit 2-0 ADCS2:ADCS0: A/D Conversion Clock Select bits 111 = FRC (clock derived from 011 = FRC (clock derived from A/D RC oscillator)(1) A/D RC oscillator)(1) 110 = FOSC/64 010 = FOSC/32 101 = FOSC/16 001 = FOSC/8 100 = FOSC/4 000 = FOSC/2

The acquisition time and A/D conversion clock need to be set in ADCON2. The A/D conversion clock (Tad) is the amount of time it
takes the A/D module to convert one bit. It takes 11 Tad to perform the 10bit A/D conversion. According to the datasheet, Tad must be selected to be as short as possible but greater than the minimum Tad (.7us for the 18F4550 p400, parameter 130). TAD can be configured to equal:

2 TOSC 4 TOSC 8 TOSC

16 TOSC 32 TOSC 64 TOSC

TOSC = 1/FOSC, where FOSC is the frequency of your crystal or oscillator. We are running at 20MHz in our PIC Development board so we set prescaler of 32 TOSC. Our FOSC = 20MHz

Therefore our FOSC = 1/20MHz = 50nS 32 TOSC = 32 x 50nS = 1600nS = 1.6uS 1.6uS is more than the minimum requirement. The three bits selecting the acquisition time need to be configured. You can find the formula to calculate the acquisition time in the datasheet, but it's probably sufficient to say that it needs to be about 2.5s. The acquisition time determines how long the channel is sampled before starting the conversion. The acquisition time can be one of the following options:

0 TAD 2 TAD 4 TAD 6 TAD

8 TAD 12 TAD 16 TAD 20 TA

Since my TAD is 32*Tosc =1.6s so we select 2 x TAD as acquisition time. TACQ=2 x TAD =2 x 1.6uS (Replacing TAD= 1.6uS) =3.2uS The acquisition time parameter, used to reduce software overhead, is the amount of Tad cycles to delay before the actual A/D conversion starts. Last, but not least, bit 7 (ADFM bit) of ADCON2 selects whether the 10 bit A/D result will be left-justified or right-justified. Since the microcontroller registers are only 8 bits, two registers are dedicated to hold the result (ADRESH:ADRESL):
. 7 X . . 6 X . . 5 X . ADRESH. 4 3 2 1 X X X X . . . X . 0 X X : : . . . 7 X X . 6 X X ADRESL. 5 4 3 2 . . . . X X X X . 1 . X . 0 . <-Left Justified X <-Right Justified

ADCON2 configuration: ADCON2bits.ADFM = 1; // A/D result is right justified ADCON2bits.ACQT0 = 1; // Acquisition time ADCON2bits.ACQT1 = 0; ADCON2bits.ACQT2 = 0; ADCON2bits.ADCS0 = 0; // A/D conversion clock ADCON2bits.ADCS1 = 1; ADCON2bits.ADCS2 = 1;

The configuration is complete. To enable the A/D converter module, we will set bit 0 in ADCON0 register to 1 Selecting and Configuring Acquisition Time The ADCON2 register allows the user to select an acquisition time that occurs each time the GO/DONE bit is set. It also gives users the option to use an automatically determined acquisition time. Acquisition time may be set with the ACQT2:ACQT0 bits (ADCON2<5:3>) which provide a range of 2 to 20 TAD. When the GO/DONE bit is set, the A/D module continues to sample the input for the selected acquisition time, then automatically begins a conversion. Since the acquisition time is programmed, there may be no need to wait for an acquisition time between selecting a channel and setting the GO/DONE bit. Manual acquisition is selected when ACQT2:ACQT0 = 000. When the GO/DONE bit is set, sampling is stopped and a conversion begins. The user is responsible for ensuring the required acquisition time has passed between selecting the desired input channel and setting the GO/DONE bit. This option is also the default Reset state of the ACQT2:ACQT0 bits and is compatible with devices that do not offer programmable acquisition times. In either case, when the conversion is completed, the GO/DONE bit is cleared, the ADIF flag is set and the A/D begins sampling the currently selected channel again. If an acquisition time is programmed, there is nothing to indicate if the acquisition time has ended or if the conversion has begun [15]. Configuring Analog Port Pins The ADCON1, TRISA, TRISB and TRISE registers all configure the A/D port pins. The port pins needed as analog inputs must have their corresponding TRIS bits set (input). If the TRIS bit is cleared (output), the digital output level (VOH or VOL) will be converted. The A/D operation is independent of the state of the CHS3:CHS0 bits and the TRIS bits. A/D Conversions Figure 3.41 shows the operation of the A/D converter after the GO/DONE bit has been set and the ACQT2:ACQT0 bits are cleared. A conversion is started after the following instruction to allow entry into Sleep mode before the conversion begins. Figure 3.42 shows the operation of the A/D converter after the GO/DONE bit has been set, the ACQT2:ACQT0 bits are set to 010 and selecting a 4 TAD acquisition time before the conversion starts. Clearing the GO/DONE bit during a conversion will abort the current conversion. The A/D Result register pair will NOT be updated with the partially completed A/D conversion sample. This means the

ADRESH:ADRESL registers will continue to contain the value of the last

completed conversion (or the last value written to the ADRESH:ADRESL registers). After the A/D conversion is completed or aborted, a 2 TAD wait is required before the next acquisition can be started. After this wait, acquisition on the selected channel is automatically started. Accordingly we have written the program and created a HEX file for writing it microcontroller. The PIC18F4550 which we received, war pre uploaded by boot loader. So we directly program using it using USB cable.

Figure 3.41 A/D conversions TAD cycles (ACQT <2:0> = 000, TAQ=1)

Figure 3.42 A/D conversions TAD cycles (ACQT <2:0> = 010, TAQ=4TAD)

3.4.8.1.3 Loading program to microcontroller

After successful compiling of our code in Mplab IDE, it generate following files: program.map - contains detailed information on the allocation of data and code. Program. mcs - file contains the build-state information required by MPLAB IDE's Make function such as file dependencies Program. hex - executable file which is written into the programming memory

For loading program in microcontroller, we need to load the .HEX file created by Mplab IDE in microcontroller ROM. This can be done by programming kit. But as discussed above, the microcontroller using in our project war pre uploaded by boot uploader. So we directly burn this .HEX file in microcontroller.

3.4.8.1.4 Communication between host PC and PIC18F4550 Microcontroller


Now The PIC18FX4550 device family contains a full-speed of 12Mbps and low-speed of 1.5Mbps compatible USB Serial Interface Engine (SIE) that allows fast communication between any USB host and the PIC microcontroller. The SIE can be interfaced directly to the USB, utilizing the internal transceiver, or it can be connected through an external transceiver. An internal 3.3V regulator is also available to power the internal transceiver in 5V applications. Some special hardware features have been included in PIC18F4550 to improve performance. Dual port memory in the devices data memory space (USB RAM) has been supplied to share direct memory access between the microcontroller core and the SIE. Buffer descriptors are also provided, allowing users to freely program endpoint memory usage within the USB RAM space. A Streaming Parallel Port has been provided to support the uninterrupted transfer of large volumes of data, such as isochronous data, to external memory buffers. Impact of number of features there are some disadvantages of USB. The comparison of traditionally used serial port USB and are given below.

Serial Port
Advantages: i. Very easy to use from a software standpoint ii. More widely used than USB for hobby projects Disadvantages: i. Newer computers do not have serial ports i. A USB-to-serial adapter must be used (I recommend this one, or this one) ii. A MAX232 level shifter must be used to convert the signals from 0V through 5V (microcontroller) to -12V through 12V (PC).

USB
Advantages: All computers have several USB ports, so USB is much more convenient for users ii. Data transfer speeds can be much higher iii. Serial is becoming more obsolete as time goes on, but USB continues to be developed i.

Disadvantages: Much harder to use than serial from a software point of view - A USB stack must be used on the microcontroller, and this is very complicated if being written from scratch (only a few people have done it) ii. Depending on the data transfer type you choose, a device driver may be required for the PC, and drivers are not easy to write i. As mentioned above, serial is much easier to use from a software point of view, but requires additional hardware (the level shifter and USB to serial adaptor). USB is much more convenient to use, but the software is extremely difficult to write from scratch. This problem can be solved by selecting right choice of free USB stacks available for PIC18 microcontrollers. One of these USB stacks is the Microchip USB Framework for PIC18, PIC24 & PIC32 microcontrollers. Microchip USB Framework is a distribution package containing a variety of USB related PIC18, PIC24F, PIC32 firmware projects, along with other USB related drivers and resources intended for use on the PC. Microchip USB Framework provides Demos which include Device CDC demo, Printer demo, bar code scanner demo, CDC serial emulator, device composite HID and mass storage, generic driver demo, HID mouse demo, HID keyboard demo, SD card reader, SD data logger, thumb drive data logger (host) and much more. It is an open source library provided by Microchip. For our project purpose i.e. WDAS we are using CDC. USB communications device class (or USB CDC) is a composite Universal Serial Bus device class. It provides a single device class. The class may include more than one interface, such as a custom control interface, data interface, audio or mass storage related interfaces. Microchip PIC18 USB CDC (Communication Device Class) Framework which essentially makes the PIC18, connected to the pc using USB cord to the USB port of pc, appear as a virtual COM port on the PC. It's also worth noting that although the microcontroller software is much more complex when using USB, if we use the USB Communications Device Class (USB CDC) then the PC will interact with the microcontroller as if it was connected over a serial port. This means that we don't have to write a driver for our device, or learn how to communicate with a USB device from the PC; all we have to do is read and write data to the virtual COM port. The Firmware for PIC18F4550 can be found in Microchip USB Framework. So this makes use easy for communication to USB.

3.4.8.2 Software developing for PC


Before moving on further for software development we will first draw the flowchart and understand the processes for which the suitable program should be developed. Flowchart is a schematic representation of an algorithm or a stepwise process. The flowchart for WDAS is shown below.

Figure 3.43 Software developing for PC flowchart

For wireless data transmission we are using host PC where all the data is logged. After logging this Host PC shares data over the network and internet. A network host is a computer connected to a computer network. A network host may offer information resources, services, and applications to users or other nodes on the network. So we develop software which is to be installed at Host PC.

So considering the requirement of data logging at Host PC the processing should be carried out as per the flowchart shown above. Initially when the software is started, it should tell user to connect the WDAS mother board and select the particular port number to which motherboard is connected. After selecting the port number, it should verify the connection. After verification, it checks the communication between motherboard and host PC. After this process actual processing should be started. Once the communication started, motherboard should continuously send the encoded data from various sensors to the Host PC. Host PC should decode these commands from WDAS motherboard and accordingly logs the data with time and date into its data base. This data log should be shared in the network to make it available to remote places and at the processing unit. Using this data the Host PC should display the values by graphical representation, current value using progressing bar, etc Considering all this things we have used C#. C# (pronounced see sharp) is a multi-paradigm programming language encompassing strong typing, imperative, declarative, functional, generic, object-oriented (classbased), and component-oriented programming disciplines. It was developed by Microsoft within its .NET initiative and later approved as a standard by Ecma (ECMA-334) and ISO (ISO/IEC 23270:2006). C# is one of the programming languages designed for the Common Language Infrastructure. Also C# provides library for image processing, voice processing and many more tools, which will help for future development of WDAS [17]. Using C# we have developed a simple program for decoding data coming from microcontroller. As seen before, we are using USB communication for communicating with mother board consisting of PIC18F4550 microcontroller. For introducing WDAS technique we have implemented basic things in our project. This can be further more developed for giving the best outcome as per needs. We have developed our project while seeing the basic sensors present in Robot. So we have designed our system to achieve the aim, which is collecting the data for various sensors and processing it as per needs and send that data through wireless communication to other locations.

Following figure shows the snapshot of our developed software for Host PC for logging data and displaying the values in graph form which can be seen in network using remote desktop.

So in this snapshot we can see the indicators which shows the current values of the Sensors i.e. temperature sensor, Ultrasonic sensor, PIR sensor, IR based obstacle sensors, charging left in battery unit, Location using data received from GPS system. Using these values we can display in graphical format to see the previous values. One of such example is of temperature sensor.

Figure 3.44 WDAS software screen shot

Steps for connecting and logging the data

Step one- as seen in above figure initially when we open the application it welcomes the user and tells his to connect the motherboard to PC and select the respective Port number.

Figure 3.45 Selecting Port to which motherboard is connected

Step two- After selecting the port number, click on power symbol. After clicking, the color of symbol changes from green to red and the communication between PC and motherboard is established. The communication between the processors and PC are displayed in Log section.

Figure 3.46 Motherboard connected

After establishment of successful communication, i.e. after receiving acknowledgement from microcontroller, the color of microcontroller symbol which is white transparency changes to green. Once the communication is establishment, microcontroller starts fetching data from its ports. If the data is in analog form, it converts it into digital with 10 bit resolution. After all this process, microcontroller sends this data to PC with USB communication. PC receives this data and processes it. While processing it shows all process in logging area. We can find the log which consist communication between PC and motherboard. It comprises of the sensors

data send by the microcontroller testing the communication between microcontrollers. Depending on data received we can see changes in symbol, graphs, current value in software.
Figure 3.47 Data log started

In this figure we can see the readings of Temperature sensor with its graph, obstacle distance measured by Ultrasonic sensor, battery charge available. In first step, when we open an application, automatically a log text file is created. With every new update in Log area, the log text file is also updated. This log file is then shared in network and over internet by Wireless sharing methods. Here the programmer has set a threshold value for alarm system. When any sensor crosses this threshold value, the alarm is triggered. In our

project we have pre-assigned this value, but according to needs as per the user, entry text box can be created in program itself through which the threshold value can be set.

Step three- If we want to track the location, we can do this by using Global Positioning System (GPS). For this we need to first connect GPS receiver to host PC. After connecting, select the port number to which GPS is connected and click on connect connected and click on connect
Figure 3.48 Selecting port where GPS is connected

After connection we can see latitude longitude of the location and Indian standard time by adding 5:30 to GMT time. The snapshot of software after connecting GPS is shown below. 3.4.9 PCB Layout A Printed Circuit Boards (PCB) is a rugged, copper and non-conductive substrate based structure to connect electrical components. The PCB is the backbone of electrical devices, allowing you to connect passive (resistor, inductor, capacitors etc), active (operational amplifiers etc) and embedded devices together, into specific form factors to fit the design need. Connections between the components are made through copper connections (routes) which become passageways for electrical signals. PCB Design Flow:

Figure 3.49 GPS data display

The PCB design flow consists of four distinct stages. There is the part research and selection stage, schematic capture and simulation, board layout, and finally board verification 1. Part Research and Selection: The most fundamental building part of a design is the physical component (such as resistors, operational amplifiers, transistors and digital components). Part research and selection requires the evaluation of components to investigate how each will work as a part of a design topology. 2. Schematic capture and Simulation: To design accurate PCB layout it is necessary to first draw the complete and accurate schematic diagram. A PCB design is a manufactured version of your schematic, so it is natural for the PCB design to be influenced by the original

Figure 3.50 PCB design stages

schematic. If your schematic is neat, and clearly laid out, then it really does make your PCB design job a lot easier. In modern day schematic capture tool is used to draw a schematic diagram. A schematic capture tool allows you to place symbols for electronic components and wire them together. Each of these symbols (for the amplifier, resistor etc) are linked to a symbol that represents the dimensions and shape of an actual device used on a PCB. In our project we have used Eagle software to create schematic diagram. The EAGLE Layout Editor is an easy to use, yet powerful tool for designing printed circuit boards (PCBs). The name EAGLE is an acronym, which stands for Easily Applicable Graphical Layout Editor.

3. Board layout: Now this schematic must be transfer to a board layout application. The easiest technique this for this purpose is Toner Transfer Method. There are certain basic requirements for this process: Laser PrinterA4 photo paper An ironing tool (iron) Etching powder (Ferric chloride powder)

The very first thing to do is to make the Layout of the given schematic. Layout is basically a graphical representation of the tracks, pads and drill holes etc. Now print the schematic on the shining part of the Photo paper, using laser printer. The second step is to get the copper board. Cut one piece of copper board with size approximately equal to that of the layout. Clean the copper board with steel wool to remove Any traces of copper oxide. After cleaning the copper board, place it over a plane wooden surface with copper facing up. Put the printed piece of paper over and tape it like the picture. Now turn the iron on. Set the iron to half of its maximum temperature setting. After the iron is heated up, apply iron over the paper and keep it pressed for at least 30 seconds, without moving it. Heat passes through the paper and board will absorb good part of it and dissipate it. While this happens, the printing Toner and a thin photo layer are transferred to the PCB. After ironing, wait until the board is completely cooled. After the board is cooled, carefully remove the paper off it. The paper comes off the board without leaving almost any toner on the sheet. The board is almost ready to be etched. Correct any tracks if needed. Now put the board in plastic container for etching. Boil one glass of water and pour it in the plastic container just enough to cover the board. Add around 1 to 2 teaspoon of etching powder. Etching takes something between 15 to 30 minutes. If the container is gently shaken, it can accelerate the etching a great deal. Your PCB should be completely etched by now. Take it off the solution and flush with water. The remaining solution can be poured into a non-metal sink with tap open. Wash everything that got in contact with the solution.

It is better to drill the board before removing the toner. Toner helps to center the drilling. Drilling is usually done using a simple hand drill. To be able to use the board, u can remove the toner with thinner or even with steel wool. The PCB is thus implemented using the above method.

Figure 3.51 Schematic of circuit

Figure 3.52 PCB layout

COMPONENTS LIST
COMPONENT 1.Resistor 65 1K 10K 2.Capacitors: 1uF 22uF 40uF 1000uF Crystal-20MHz Switch USB Connecter LEDs Diodes IC-78405 Microcontroller: PIC 18F4550 Ultrasonic distance sensor IR transmitter IR receiver- TSOP1738 Passive infrared sensor GPS receiver MT3318 12 4 2 2 2 8 2 2 8 2 2 1 4 4 1 1 1 4 4 QUANTITY

TESTING OF WDAS
For testing purpose we have connected our WDAS motherboard to one of the laptop having windows vista. We have installed WDAS.exe file which was created by programming in that laptop. For startup environment of this software it requires .NET v4. So we have downloaded it from net which is available freely. The next we install is Opera unit for sharing log files over a network and on internet. We just login in Opera and initialized the location form where the file and .PHP web paged is to be shared so that any user in having a local network connectivity or internet can view the logged data. After creating environment for data logging and sharing we connected the sensors to WDAS motherboard. After completing these steps we supplied the motherboard. After some time the new device was detected on laptop. This WDAS motherboard required MCHPUSB drivers for working properly with laptop which is available at Microchip website. We just downloaded this driver and installed it. We found out the port number to which the motherboard was connected from the device manager. Next we started the WDAS software and entered the port number where motherboard was connected on the supply button. Immediately after clicking the communication between the WDAS motherboard and laptop was established and WDAS motherboard started transmitting the respective data of the sensors to laptop. Laptop identified the motherboard communication and started decoding the data which was been send by WDAS motherboard. We found the log of the communication between WDAS motherboard and laptop on the screen. Also me found a new text file which was nothing but the logged data values with the date and time when it was been logged. This file was updated with every update received from motherboard. Accordingly we found the changes in symbol and progressing bar in GUI software. The user in the network on or on the internet could fount the log data on the allocated IP address by the network and on the website which was created while registration in Opera unite which is www.recordof.wdasproject.operaunite.com which is created for testing purpose. We tested our designed project in two cases. One is ideal case when the WDAS system is in steady case and the other one with WDAS connected on robot. In ideal case we just kept in room with some of the obstacle near it. In second case we tested with robot when it was in outfield in moving position. We logged the data in both the cases to test its accuracy and stability. While testing in both the cases the recorded data is shown below.

The basic system requirement for testing and implementing WDAS is Windows XP, Microsoft .NET V4 frame work, any size HDD and Ram available in the system, Wi-Fi and internet connectivity.

5.1 Recorded data when WDAS system was in ideal state


[11-04-2012 13:13:02] Welcome to WDAS [11-04-2012 13:13:02] Please connect WDAS motherboard [11-04-2012 13:13:02] Please select the com port to which the USB Master is connected and click on power symbol [11-04-2012 13:13:52] Connected via COM40 [11-04-2012 13:13:52] sending(3): M00 [11-04-2012 13:13:52] sending(2): S [11-04-2012 13:13:52] sending(3): L00 [11-04-2012 13:13:52] sending(1): R [11-04-2012 13:13:53] rcvd: O <7> [11-04-2012 13:13:53] rcvd: V <0> [11-04-2012 13:13:53] PIR 0 [11-04-2012 13:13:54] rcvd: O <0> [11-04-2012 13:13:54] rcvd: B <0> <210> [11-04-2012 13:13:55] BAT 11.881333974367 [11-04-2012 13:13:55] rcvd: O <7> [11-04-2012 13:13:55] rcvd: T <0> <106> [11-04-2012 13:13:55] TEMP 27.1453924956633 C [11-04-2012 13:13:56] rcvd: O <7> [11-04-2012 13:13:56] rcvd: U <1> <175> [11-04-2012 13:13:56] ULT 431 [11-04-2012 13:13:56] ULT 89.2170009762049 [11-04-2012 13:13:57] rcvd: O <7> [11-04-2012 13:13:57] rcvd: V <0> [11-04-2012 13:13:57] PIR 0 [11-04-2012 13:13:58] rcvd: O <0> [11-04-2012 13:13:58] rcvd: B <0> <194> [11-04-2012 13:13:58] BAT 11.6722323964443 [11-04-2012 13:13:58] rcvd: O <7> [11-04-2012 13:13:59] rcvd: T <0> <105> [11-04-2012 13:13:59] TEMP 26.6522284035138 C [11-04-2012 13:14:00] rcvd: O <7> [11-04-2012 13:14:00] rcvd: U <1> <159> [11-04-2012 13:13:00] ULT 415 [11-04-2012 13:14:01] ULT 85.9050009399652

[11-04-2012 13:14:01] rcvd: O <7> [11-04-2012 13:14:02] rcvd: V <0> [11-04-2012 13:14:02] PIR 0 [11-04-2012 13:14:02] rcvd: O <0> [11-04-2012 13:14:02] rcvd: B <0> <194> [11-04-2012 13:14:03] BAT 11.6722323964443 [11-04-2012 13:14:03] rcvd: O <7> [11-04-2012 13:14:04] rcvd: T <0> <105> [11-04-2012 13:14:04] TEMP 26.6522284035138 C [11-04-2012 13:14:04] rcvd: O <7> [11-04-2012 13:14:04] rcvd: U <1> <159> [11-04-2012 13:14:04] ULT 415 [11-04-2012 13:14:05] ULT 85.9050009399652 [11-04-2012 13:14:05] rcvd: O <7> [11-04-2012 13:14:05] rcvd: V <0> [11-04-2012 13:14:05] PIR 0 [11-04-2012 13:14:06] rcvd: O <0> [11-04-2012 13:14:06] rcvd: B <0> <192> [11-04-2012 13:14:06] BAT 11.646094699204 [11-04-2012 13:14:07] rcvd: O <7> [11-04-2012 13:14:07] rcvd: T <0> <106> [11-04-2012 13:14:07] TEMP 27.1453924956633 C [11-04-2012 13:14:07] rcvd: O <7> [11-04-2012 13:14:07] rcvd: U <1> <131> [11-04-2012 13:14:08] ULT 387

[11-04-2012 13:14:08] ULT 80.1090008765459 [11-04-2012 13:14:08] sending(1): Q [11-04-2012 13:14:09] error: Problem while writing to serial port [11-04-2012 13:14:09] Please connect WDAS motherboard [11-04-2012 13:14:09] Please select the com port to which the USB Master is connected and click on power symbol [11-04-2012 13:17:57] Connected via COM40 [11-04-2012 13:17:59] rcvd: O <7> [11-04-2012 13:17:59] rcvd: V <1> [11-04-2012 13:17:59] PIR 1 [11-04-2012 13:18:01] rcvd: O <7> [11-04-2012 13:18:01] rcvd: B <0> <192> [11-04-2012 13:18:01] BAT 11.646094699204 [11-04-2012 13:18:03] rcvd: O <7> [11-04-2012 13:18:03] rcvd: T <0> <105> [11-04-2012 13:18:03] TEMP 26.6522284035138 C [11-04-2012 13:18:05] rcvd: O <7> [11-04-2012 13:18:06] rcvd: U <1> <159> [11-04-2012 13:18:06] ULT 415 [11-04-2012 13:18:06] ULT 85.9050009399652 [11-04-2012 13:18:08] rcvd: O <7> [11-04-2012 13:18:08] rcvd: V <1> [11-04-2012 13:18:08] PIR 1 [11-04-2012 13:18:10] rcvd: O <7>

[11-04-2012 13:18:10] rcvd: B <0> <192> [11-04-2012 13:18:10] BAT 11.646094699204 [11-04-2012 13:18:12] rcvd: O <7> [11-04-2012 13:18:12] rcvd: T <0> <106> [11-04-2012 13:18:12] TEMP 26.1590643113642 C [11-04-2012 13:18:14] rcvd: O <7> [11-04-2012 13:18:14] rcvd: U <1> <174> [11-04-2012 13:18:14] ULT 430 [11-04-2012 13:18:14] ULT 89.0100009739399 [11-04-2012 13:18:16] rcvd: O <7> [11-04-2012 13:18:17] rcvd: V <1> [11-04-2012 13:18:17] PIR 1 [11-04-2012 13:18:18] rcvd: O <7> [11-04-2012 13:18:19] rcvd: B <0> <192> [11-04-2012 13:18:19] BAT 11.646094699204 [11-04-2012 13:18:21] rcvd: O <7> [11-04-2012 13:18:21] rcvd: T <0> <106> [11-04-2012 13:18:21] TEMP 27.1453924956633 C [11-04-2012 13:18:23] rcvd: O <7> [11-04-2012 13:18:23] rcvd: U <1> <161> [11-04-2012 13:18:23] ULT 417 [11-04-2012 13:18:23] ULT 86.3190009444952 [11-04-2012 13:18:25] rcvd: O <7> [11-04-2012 13:18:25] rcvd: V <0> [11-04-2012 13:18:25] PIR 0

[11-04-2012 13:18:27] rcvd: O <7> [11-04-2012 13:18:27] rcvd: B <0> <192> [11-04-2012 13:18:27] BAT 11.646094699204 [11-04-2012 13:18:29] rcvd: O <7> [11-04-2012 13:18:30] rcvd: T <0> <106> [11-04-2012 13:18:30] TEMP 27.1453924956633 C [11-04-2012 13:18:32] rcvd: O <7> [11-04-2012 13:18:32] rcvd: U <1> <159> [11-04-2012 13:18:32] ULT 415 [11-04-2012 13:18:32] ULT 85.9050009399652 [11-04-2012 13:18:34] rcvd: O <7> [11-04-2012 13:18:34] rcvd: V <0> [11-04-2012 13:18:34] PIR 0 [11-04-2012 13:18:36] rcvd: O <7> [11-04-2012 13:18:36] rcvd: B <0> <192> [11-04-2012 13:18:36] BAT 11.646094699204 [11-04-2012 13:18:38] rcvd: O <7> [11-04-2012 13:18:38] rcvd: T <0> <105> [11-04-2012 13:18:38] TEMP 26.6522284035138 C [11-04-2012 13:18:40] rcvd: O <7> [11-04-2012 13:18:41] rcvd: U <1> <194> [11-04-2012 13:18:41] ULT 450 [11-04-2012 13:18:41] ULT 93.1500010192394 [11-04-2012 13:18:43] rcvd: O <7>

[11-04-2012 13:18:43] rcvd: V <0> [11-04-2012 13:18:43] PIR 0 [11-04-2012 13:18:45] rcvd: O <7> [11-04-2012 13:18:45] rcvd: B <0> <192> [11-04-2012 13:18:45] BAT 11.646094699204 [11-04-2012 13:18:47] rcvd: O <7> [11-04-2012 13:18:47] rcvd: T <0> <106> [11-04-2012 13:18:47] TEMP 27.1453924956633 C [11-04-2012 13:18:49] rcvd: O <7> [11-04-2012 13:18:49] rcvd: U <1> <159> [11-04-2012 13:18:49] ULT 415 [11-04-2012 13:18:49] ULT 85.9050009399652 [11-04-2012 13:18:51] rcvd: O <7> [11-04-2012 13:18:52] rcvd: V <1> [11-04-2012 13:18:52] PIR 1 [11-04-2012 13:18:53] rcvd: O <7> [11-04-2012 13:18:54] rcvd: B <0> <192> [11-04-2012 13:18:54] BAT 11.646094699204 [11-04-2012 13:18:56] rcvd: O <7> [11-04-2012 13:18:56] rcvd: T <0> <109> [11-04-2012 13:18:56] TEMP 28.6248847721119 C [11-04-2012 13:18:58] rcvd: O <7> [11-04-2012 13:18:58] rcvd: U <1> <216> [11-04-2012 13:18:58] ULT 472 [11-04-2012 13:18:58] ULT 97.7040010690689

[11-04-2012 13:19:00] rcvd: O <7> [11-04-2012 13:19:00] rcvd: V <0> [11-04-2012 13:19:00] PIR 0 [11-04-2012 13:19:02] rcvd: O <7> [11-04-2012 13:19:02] rcvd: B <0> <192> [11-04-2012 13:19:02] BAT 11.646094699204 [11-04-2012 13:19:04] rcvd: O <7> [11-04-2012 13:19:05] rcvd: T <0> <107> [11-04-2012 13:19:05] TEMP 27.6385565878128 C [11-04-2012 13:19:07] rcvd: O <7> [11-04-2012 13:19:07] rcvd: U <1> <159> [11-04-2012 13:19:07] ULT 415 [11-04-2012 13:19:07] ULT 85.9050009399652 [11-04-2012 13:19:09] rcvd: O <7> [11-04-2012 13:19:09] rcvd: V <0> [11-04-2012 13:19:09] PIR 0 [11-04-2012 13:19:11] rcvd: O <7> [11-04-2012 13:19:11] rcvd: B <0> <192> [11-04-2012 13:19:11] BAT 11.646094699204 [11-04-2012 13:19:13] rcvd: O <7> [11-04-2012 13:19:13] rcvd: T <0> <106> [11-04-2012 13:19:13] TEMP 26.6522284035138 C C [11-04-2012 13:19:15] rcvd: O <7> [11-04-2012 13:19:16] rcvd: U <1> <159> [11-04-2012 13:19:16] ULT 415

[11-04-2012 13:19:16] ULT 85.9050009399652 [11-04-2012 13:19:18] rcvd: O <7> [11-04-2012 13:19:18] rcvd: V <0> [11-04-2012 13:19:18] PIR 0 [11-04-2012 13:19:20] rcvd: O <7> [11-04-2012 13:19:20] rcvd: B <0> <192> [11-04-2012 13:19:20] BAT 11.646094699204 [11-04-2012 13:19:22] rcvd: O <7> [11-04-2012 13:19:22] rcvd: T <0> <105> [11-04-2012 13:19:22] TEMP 26.6522284035138 C [11-04-2012 13:19:24] rcvd: O <7> [11-04-2012 13:19:24] rcvd: U <1> <159> [11-04-2012 13:19:24] ULT 415 [11-04-2012 13:19:24] ULT 85.9050009399652 [11-04-2012 13:19:26] rcvd: O <7> [11-04-2012 13:19:27] rcvd: V <0> [11-04-2012 13:19:27] PIR 0 [11-04-2012 13:19:28] rcvd: O <7> [11-04-2012 13:19:29] rcvd: B <0> <192> [11-04-2012 13:19:29] BAT 6.35321100803559 [11-04-2012 13:19:31] rcvd: O <7> [11-04-2012 13:19:31] rcvd: T <0> <105> [11-04-2012 13:19:31] TEMP 26.6522284035138 C [11-04-2012 13:19:33] rcvd: O <7>

[11-04-2012 13:19:33] rcvd: U <1> <131> [11-04-2012 13:19:33] ULT 387 [11-04-2012 13:19:33] ULT 80.1090008765459 [11-04-2012 13:19:35] rcvd: O <7> [11-04-2012 13:19:35] rcvd: V <0> [11-04-2012 13:19:35] PIR 0 [11-04-2012 13:19:37] rcvd: O <7> [11-04-2012 13:19:37] rcvd: B <0> <192> [11-04-2012 13:19:37] BAT 11.646094699204 [11-04-2012 13:19:39] rcvd: O <7> [11-04-2012 13:19:40] rcvd: T <0> <108> [11-04-2012 13:19:40] TEMP 28.1317206799624 C [11-04-2012 13:19:42] rcvd: O <7> [11-04-2012 13:19:42] rcvd: U <1> <131> [11-04-2012 13:19:42] ULT 387 [11-04-2012 13:19:42] ULT 80.1090008765459 [11-04-2012 13:19:44] rcvd: O <7> [11-04-2012 13:19:44] rcvd: V <0> [11-04-2012 13:19:44] PIR 0 [11-04-2012 13:19:46] rcvd: O <7> [11-04-2012 13:19:46] rcvd: B <0> <192> [11-04-2012 13:19:46] BAT 11.646094699204 [11-04-2012 13:19:48] rcvd: O <7> [11-04-2012 13:19:48] rcvd: T <0> <107> [11-04-2012 13:19:48] TEMP 27.6385565878128 C

[11-04-2012 13:19:50] rcvd: O <7> [11-04-2012 13:19:51] rcvd: U <1> <131> [11-04-2012 13:19:51] ULT 387 [11-04-2012 13:19:51] ULT 80.1090008765459

[11-04-2012 13:19:53] rcvd: O <7> [11-04-2012 13:19:53] rcvd: V <1>

GPS log: For tracking the location minimum 3 satellite signals should be available. As we in this case we are testing inside the room at ideal position there are no satellite signals. As a result no data log is obtained of GPS signals.

5.2 Recorded data when WDAS system when feted on Robot


[17-04-2012 11:43:02] Welcome to WDAS [17-04-2012 11:43:02] Please connect WDAS motherboard [17-04-2012 11:43:02] Please select the com port to which the USB Master is connected and click on power symbol [17-04-2012 11:43:52] Connected via COM40 [17-04-2012 11:43:52] sending(3): M00 [17-04-2012 11:43:52] sending(2): S [17-04-2012 11:43:52] sending(3): L00

[17-04-2012 11:43:52] sending(1): R [17-04-2012 11:43:53] rcvd: O <7> [17-04-2012 11:43:53] rcvd: V <0> [17-04-2012 11:43:53] PIR 0 [17-04-2012 11:43:54] rcvd: O <0> [17-04-2012 11:43:54] rcvd: B <3> <86> [17-04-2012 11:43:55] BAT 10.26079674546617 [17-04-2012 11:43:55] rcvd: O <7> [17-04-2012 11:43:55] rcvd: T <0> <117> [17-04-2012 11:43:55] TEMP 34.5428538779062 C [17-04-2012 11:43:56] rcvd: O <7> [17-04-2012 11:43:56] rcvd: U <1> <175> [17-04-2012 11:43:56] ULT 431 [17-04-2012 11:43:56] ULT 89.2170009762049 [17-04-2012 11:43:57] rcvd: O <7> [17-04-2012 11:43:57] rcvd: V <0> [17-04-2012 11:43:57] PIR 0 [17-04-2012 11:43:58] rcvd: O <0> [17-04-2012 11:43:58] rcvd: B <3> <113> [17-04-2012 11:43:58] BAT 10.6136556582106 [17-04-2012 11:43:58] rcvd: O <7> [17-04-2012 11:43:59] rcvd: T <0> <118> [17-04-2012 11:43:59] TEMP 33.0633616014576 C [17-04-2012 13:43:00] rcvd: O <7>

[17-04-2012 13:43:00] rcvd: U <1> <159> [17-04-2012 11:43:00] ULT 415 [17-04-2012 11:44:01] ULT 85.9050009399652 [17-04-2012 11:44:01] rcvd: O <7> [17-04-2012 11:44:02] rcvd: V <0> [17-04-2012 11:44:02] PIR 0 [17-04-2012 11:44:02] rcvd: O <0> [17-04-2012 11:44:02] rcvd: B <3> <113> [17-04-2012 11:44:03] BAT 10.6136556582106 [17-04-2012 11:44:03] rcvd: O <7> [17-04-2012 11:44:04] rcvd: T <0> <118> [17-04-2012 11:44:04] TEMP 33.0633616014576 C [17-04-2012 11:44:04] rcvd: O <7> [17-04-2012 11:44:04] rcvd: U <1> <159> [17-04-2012 11:44:04] ULT 415 [17-04-2012 11:44:05] ULT 85.9050009399652 [17-04-2012 11:44:05] rcvd: O <7> [17-04-2012 11:44:05] rcvd: V <0> [17-04-2012 11:44:06] PIR 0 [17-04-2012 11:44:06] rcvd: O <0> [17-04-2012 11:44:06] rcvd: B <3> <70> [17-04-2012 11:44:06] BAT 10.0516951675434 [17-04-2012 11:44:07] rcvd: O <7> [17-04-2012 11:44:07] rcvd: T <0> <117> [17-04-2012 11:44:07] TEMP 34.5428538779062 C

[17-04-2012 11:44:07] rcvd: O <7> [17-04-2012 11:44:08] rcvd: U <1> <131> [17-04-2012 11:44:08] ULT 387 [17-04-2012 11:44:08] ULT 80.1090008765459 [17-04-2012 11:44:09] Connected via COM40 [17-04-2012 11:44:09] rcvd: O <7> [17-04-2012 11:44:09] rcvd: V <1> [17-04-2012 11:44:09] PIR 1 [17-04-2012 11:44:09] rcvd: O <7> [17-04-2012 11:44:10] rcvd: B <3> <70> [17-04-2012 11:44:10] BAT 10.0516951675434 [17-04-2012 11:44:10] rcvd: O <7> [17-04-2012 11:44:10] rcvd: T <0> <118> [17-04-2012 11:44:11] TEMP 33.0633616014576 C [17-04-2012 11:44:11] rcvd: O <7> [17-04-2012 11:44:11] rcvd: U <1> <159> [17-04-2012 11:44:11] ULT 415 [17-04-2012 11:44:11] ULT 85.9050009399652 [17-04-2012 11:44:11] rcvd: O <7> [17-04-2012 11:44:11] rcvd: V <1> [17-04-2012 11:44:11] PIR 1 [17-04-2012 11:44:10] rcvd: O <7> [17-04-2012 11:44:10] rcvd: B <3> <70> [17-04-2012 11:44:10] BAT 10.0516951675434 [17-04-2012 11:44:12] rcvd: O <7>

[17-04-2012 11:44:12] rcvd: T <0> <117> [17-04-2012 11:44:12] TEMP 32.5701975093081 C [17-04-2012 11:44:14] rcvd: O <7> [17-04-2012 11:44:14] rcvd: U <1> <174> [17-04-2012 11:44:14] ULT 430 [17-04-2012 11:44:14] ULT 89.0100009739399 [17-04-2012 11:44:16] rcvd: O <7> [17-04-2012 11:44:17] rcvd: V <1> [17-04-2012 11:44:17] PIR 1 [17-04-2012 11:44:18] rcvd: O <7> [17-04-2012 11:44:19] rcvd: B <3> <70> [17-04-2012 11:44:19] BAT 10.0516951675434 [17-04-2012 11:44:21] rcvd: O <7> [17-04-2012 11:44:21] rcvd: T <0> <117> [17-04-2012 11:44:21] TEMP 34.5428538779062 C [17-04-2012 11:44:23] rcvd: O <7> [17-04-2012 11:44:23] rcvd: U <1> <161> [17-04-2012 11:44:23] ULT 417 [17-04-2012 11:44:23] ULT 86.3190009444952 [17-04-2012 11:44:25] rcvd: O <7> [17-04-2012 11:44:25] rcvd: V <0> [17-04-2012 11:44:25] PIR 0 [17-04-2012 11:44:27] rcvd: O <7> [17-04-2012 11:44:27] rcvd: B <3> <70> [17-04-2012 11:44:27] BAT 10.0516951675434

[17-04-2012 11:44:29] rcvd: O <7> [17-04-2012 11:44:30] rcvd: T <0> <117> [17-04-2012 11:44:30] TEMP 34.5428538779062 C [17-04-2012 11:44:32] rcvd: O <7> [17-04-2012 11:44:32] rcvd: U <1> <159> [17-04-2012 11:44:32] ULT 415 [17-04-2012 11:44:32] ULT 85.9050009399652 [17-04-2012 11:44:34] rcvd: O <7> [17-04-2012 11:44:34] rcvd: V <0> [17-04-2012 11:44:34] PIR 0 [17-04-2012 11:44:36] rcvd: O <7> [17-04-2012 11:44:36] rcvd: B <3> <70> [17-04-2012 11:44:36] BAT 10.0516951675434 [17-04-2012 11:44:38] rcvd: O <7> [17-04-2012 11:44:38] rcvd: T <0> <118> [17-04-2012 11:44:38] TEMP 33.0633616014576 C [17-04-2012 11:44:40] rcvd: O <7> [17-04-2012 11:44:41] rcvd: U <1> <194> [17-04-2012 11:44:41] ULT 450 [17-04-2012 11:44:41] ULT 93.1500010192394 [17-04-2012 11:44:43] rcvd: O <7> [17-04-2012 11:44:43] rcvd: V <0> [17-04-2012 11:44:43] PIR 0 [17-04-2012 11:44:45] rcvd: O <7> [17-04-2012 11:44:45] rcvd: B <3> <70>

[17-04-2012 11:44:45] BAT 10.0516951675434 [17-04-2012 11:44:47] rcvd: O <7> [17-04-2012 11:44:47] rcvd: T <0> <117> [17-04-2012 11:44:47] TEMP 34.5428538779062 C [17-04-2012 11:44:49] rcvd: O <7> [17-04-2012 11:44:49] rcvd: U <1> <159> [17-04-2012 11:44:49] ULT 415 [17-04-2012 11:44:49] ULT 85.9050009399652 [17-04-2012 11:44:51] rcvd: O <7> [17-04-2012 11:44:52] rcvd: V <1> [17-04-2012 11:44:52] PIR 1 [17-04-2012 11:44:53] rcvd: O <7> [17-04-2012 11:44:54] rcvd: B <3> <70> [17-04-2012 11:44:54] BAT 10.0516951675434 [17-04-2012 11:44:56] rcvd: O <7> [17-04-2012 11:44:56] rcvd: T <0> <112> [17-04-2012 11:44:56] TEMP 30.1043770485605 C [17-04-2012 11:44:58] rcvd: O <7> [17-04-2012 11:44:58] rcvd: U <1> <216> [17-04-2012 11:44:58] ULT 472 [17-04-2012 11:44:58] ULT 97.7040010690689 [17-04-2012 11:45:00] rcvd: O <7> [17-04-2012 11:45:00] rcvd: V <0> [17-04-2012 11:45:00] PIR 0 [17-04-2012 11:45:02] rcvd: O <7>

[17-04-2012 11:45:02] rcvd: B <3> <70> [17-04-2012 11:45:02] BAT 10.0516951675434 [17-04-2012 11:45:04] rcvd: O <7> [17-04-2012 11:45:05] rcvd: T <0> <107> [17-04-2012 11:45:05] TEMP 29.6112129564109 C [17-04-2012 11:45:07] rcvd: O <7> [17-04-2012 11:45:07] rcvd: U <1> <159> [17-04-2012 11:45:07] ULT 415 [17-04-2012 11:45:07] ULT 85.9050009399652 [17-04-2012 11:45:09] rcvd: O <7> [17-04-2012 11:45:09] rcvd: V <0> [17-04-2012 11:45:09] PIR 0 [17-04-2012 11:45:11] rcvd: O <7> [17-04-2012 11:45:11] rcvd: B <3> <70> [17-04-2012 11:45:11] BAT 10.0516951675434 [17-04-2012 11:45:13] rcvd: O <7> [17-04-2012 11:45:13] rcvd: T <0> <117> [17-04-2012 11:45:13] TEMP 33.0633616014576 C C [17-04-2012 11:45:15] rcvd: O <7> [17-04-2012 11:45:16] rcvd: U <1> <159> [17-04-2012 11:45:16] ULT 415 [17-04-2012 11:45:16] ULT 85.9050009399652 [17-04-2012 11:45:18] rcvd: O <7> [17-04-2012 11:45:18] rcvd: V <0> [17-04-2012 11:45:18] PIR 0

[17-04-2012 11:45:20] rcvd: O <7> [17-04-2012 11:45:20] rcvd: B <3> <70> [17-04-2012 11:45:20] BAT 10.0516951675434 [17-04-2012 11:45:22] rcvd: O <7> [17-04-2012 11:45:22] rcvd: T <0> <118> [17-04-2012 11:45:22] TEMP 33.0633616014576 C [17-04-2012 11:45:24] rcvd: O <7> [17-04-2012 11:45:24] rcvd: U <1> <159> [17-04-2012 11:45:24] ULT 415 [17-04-2012 11:45:24] ULT 85.9050009399652 [17-04-2012 11:45:26] rcvd: O <7> [17-04-2012 11:45:27] rcvd: V <0> [17-04-2012 11:45:27] PIR 0 [17-04-2012 11:45:28] rcvd: O <7> [17-04-2012 11:45:29] rcvd: B <3> <70> [17-04-2012 11:45:29] BAT 10.0516951675434 [17-04-2012 11:45:31] rcvd: O <7> [17-04-2012 11:45:31] rcvd: T <0> <118> [17-04-2012 11:45:31] TEMP 33.0633616014576 C [17-04-2012 11:45:33] rcvd: O <7> [17-04-2012 11:45:33] rcvd: U <1> <131> [17-04-2012 11:45:33] ULT 387 [17-04-2012 11:45:33] ULT 80.1090008765459 [17-04-2012 11:45:35] rcvd: O <7>

[17-04-2012 11:45:35] rcvd: V <0> [17-04-2012 11:45:35] PIR 0 [17-04-2012 11:45:37] rcvd: O <7> [17-04-2012 11:45:37] rcvd: B <3> <70> [17-04-2012 11:45:37] BAT 10.0516951675434 [17-04-2012 11:45:39] rcvd: O <7> [17-04-2012 11:45:40] rcvd: T <0> <108> [17-04-2012 11:45:40] TEMP 28.1317206799624 C [17-04-2012 11:45:42] rcvd: O <7> [17-04-2012 11:45:42] rcvd: U <1> <131> [17-04-2012 11:45:42] ULT 387 [17-04-2012 11:45:42] ULT 80.1090008765459 [17-04-2012 11:45:44] rcvd: O <7> [17-04-2012 11:45:44] rcvd: V <0>

[17-04-2012 11:45:44] PIR 0 [17-04-2012 11:45:46] rcvd: O <7> [17-04-2012 11:45:46] rcvd: B <3> <70> [17-04-2012 11:45:46] BAT 10.0516951675434 [17-04-2012 11:45:48] rcvd: O <7> [17-04-2012 11:45:48] rcvd: T <0> <107> [17-04-2012 11:45:48] TEMP 29.6112129564109 C [17-04-2012 11:45:50] rcvd: O <7> [17-04-2012 11:45:51] rcvd: U <1> <131> [17-04-2012 11:45:51] ULT 387 [17-04-2012 11:45:51] ULT 80.1090008765459 [17-04-2012 11:45:53] rcvd: O <7> [17-04-2012 11:45:53] rcvd: V <1>

GPS data log [01-May-12 2:04:16 PM] $GPGGA,083416.000,1859.4276, N,07307.6883,E,1,6,1.43,9.5,M,63.2,M,,*76 [01-May-12 2:04:17 PM] $GPGGA,083417.000,1859.4276, N,07307.6883,E,1,6,1.43,9.5,M,63.2,M,,*77 [01-May-12 2:04:18 PM] $GPGGA,083418.000,1859.4276, N,07307.6883,E,1,6,1.43,9.5,M,63.2,M,,*78 [01-May-12 2:04:19 PM] $GPGGA,083419.000,1859.4276, N,07307.6883,E,1,6,1.43,9.5,M,63.2,M,,*79 [01-May-12 2:04:20 PM] $GPGGA,083420.000,1859.4276, N,07307.6883,E,1,6,1.43,9.5,M,63.2,M,,*73 [01-May-12 2:04:21 PM] $GPGGA,083421.000,1859.4276, N,07307.6883,E,1,6,1.43,9.5,M,63.2,M,,*72

N,07307.6921,E,1,6,1.43,7.4,M,63.2,M,,*7C [01-May-12 2:04:22 PM] $GPGGA,083422.000,1859.4276, N,07307.6883,E,1,6,1.43,9.5,M,63.2,M,,*71 [01-May-12 2:04:23 PM] $GPGGA,083423.000,1859.4276, N,07307.6883,E,1,5,1.74,9.5,M,63.2,M,,*77 [01-May-12 2:04:24 PM] $GPGGA,083424.000,1859.4287, N,07307.6906,E,1,5,1.74,7.2,M,63.2,M,,*7B [01-May-12 2:04:25 PM] $GPGGA,083425.000,1859.4284, N,07307.6908,E,1,6,1.43,7.2,M,63.2,M,,*70 [01-May-12 2:04:26 PM] $GPGGA,083426.000,1859.4282, N,07307.6916,E,1,6,1.43,7.3,M,63.2,M,,*7B [01-May-12 2:04:27 PM] $GPGGA,083427.000,1859.4281, N,07307.6921,E,1,6,1.43,7.4,M,63.2,M,,*7A [01-May-12 2:04:31 PM] $GPGGA,083431.000,1859.4281, N,07307.6921,E,1,6,1.43,7.4,M,63.2,M,,*7D [01-May-12 2:04:32 PM] $GPGGA,083432.000,1859.4281, N,07307.6921,E,1,6,1.43,7.4,M,63.2,M,,*7E [01-May-12 2:04:33 PM] $GPGGA,083433.000,1859.4281, N,07307.6921,E,1,6,1.43,7.4,M,63.2,M,,*7F [01-May-12 2:04:34 PM] $GPGGA,083434.000,1859.4281, N,07307.6921,E,1,5,1.74,7.4,M,63.2,M,,*7F [01-May-12 2:04:35 PM] $GPGGA,083435.000,1859.4222, N,07307.6916,E,1,6,1.43,7.3,M,63.2,M,,*73 [01-May-12 2:04:36 PM] $GPGGA,083436.000,1859.4209, N,07307.6914,E,1,6,1.43,7.5,M,63.2,M,,*7D [01-May-12 2:04:37 PM] $GPGGA,083437.000,1859.4201, N,07307.6923,E,1,6,1.43,7.6,M,63.2,M,,*73 [01-May-12 2:04:38 PM] $GPGGA,083438.000,1859.4199, N,07307.6925,E,1,6,1.43,7.4,M,63.2,M,,*7A [01-May-12 2:04:39 PM] $GPGGA,083439.000,1859.4195,

[01-May-12 2:04:28 PM] $GPGGA,083428.000,1859.4281, N,07307.6921,E,1,6,1.43,7.4,M,63.2,M,,*75 [01-May-12 2:04:29 PM] $GPGGA,083429.000,1859.4281, N,07307.6921,E,1,6,1.43,7.4,M,63.2,M,,*74 [01-May-12 2:04:30 PM] $GPGGA,083430.000,1859.4281,

N,07307.6930,E,1,5,1.48,7.7,M,63.2,M,,*78 [01-May-12 2:04:40 PM] $GPGGA,083440.000,1859.4195, N,07307.6930,E,1,5,1.48,7.7,M,63.2,M,,*76 [01-May-12 2:04:41 PM] $GPGGA,083441.000,1859.4195, N,07307.6930,E,1,4,2.06,7.7,M,63.2,M,,*7F [01-May-12 2:04:42 PM] $GPGGA,083442.000,1859.4195, N,07307.6930,E,1,5,1.48,7.7,M,63.2,M,,*74 [01-May-12 2:04:43 PM] $GPGGA,083443.000,1859.4195, N,07307.6930,E,1,4,1.84,7.7,M,63.2,M,,*74 [01-May-12 2:04:44 PM] $GPGGA,083444.000,1859.4195, N,07307.6930,E,1,4,2.06,7.7,M,63.2,M,,*7A

[01-May-12 2:04:45 PM] $GPGGA,083445.000,1859.4195, N,07307.6930,E,1,4,2.56,7.7,M,63.2,M,,*7E [01-May-12 2:04:46 PM] $GPGGA,083446.000,1859.4195, N,07307.6930,E,1,4,1.84,7.7,M,63.2,M,,*71 [01-May-12 2:04:47 PM] $GPGGA,083447.000,1859.4195, N,07307.6930,E,1,4,1.83,7.7,M,63.2,M,,*77 [01-May-12 2:04:48 PM] $GPGGA,083448.000,1859.4195, N,07307.6930,E,1,5,1.48,7.7,M,63.2,M,,*7E [01-May-12 2:04:49 PM] $GPGGA,083449.000,1859.4195, N,07307.6930,E,1,5,1.48,7.7,M,63.2,M,,*7F

6. RESULT
We have tested our designed project in two cases: 1. When WDAS is in steady state inside the room 2. When WDAS is placed on robot The data log for both cases is given. This data log is only for 3 to 4 minutes because, for every 1 second 4 to 5 entries are recorded. The requirement of sensors to be used depends on the application in which we are employing our WDAS system. Thus sensors required for ideal case and robotics is different for example in ideal case we do not require GPS sensor as the WDAS is stationary unlike in robotics where we need to track the position of robot. Addition and removal of these sensors is very easy because we need to change the entire system but some minor changes in program and just need to initialize the ports at which additional sensors

are connected. We have already considered both analog and digital inputs so simply initializing ports and some changes in command will do the work. We have used temperature sensor, IR obstacle sensor, PIR sensor Ultrasonic distance measurement sensor and GPS. When the system in ideal case GPS signal is not available so we have not selected the GPS port so no data log is available. If we compare data log of both the cases then we came to a conclusion that in both cases our project is working well. The system is giving good response in both the cases. We have designed this system for robotics application where we have found that is giving good results, accurate measurements about the outdoor environment, any obstacle as well as information about battery status.

7. CONCLUSION AND FUTURE DEVELOPMENTS


Applications: The wireless data acquisition system presented here can be used in number of applications, some of which are listed below: Automation industries. Various industrial processes can be monitored The heart of robotics is sensor so our project is essential for robotics Used for security purpose. It can be used in areas where it is dangerous/impossible for the humans to go like nuclear reactors. Can be used to continuous monitoring of a system and alert when the system parameters exceeds a fixed threshold Can be used in medical application for wireless data logging Advantages: For future purpose, if required, port requirement can be increased by adding master and slave microcontroller. Recorded data can be viewed through the internet. Sensors can be controlled remotely via PIC using Wi-Fi access. Data cannot be hacked easily because system has inbuilt security. Low battery consumption.

Disadvantages: Limited range.

Future scope: In industries having huge span, it can placed by diving it into small units. Then all units can be connected to main central unit for monitoring. In our project there is one way communication between the PIC and the PC i.e.is only collecting the data but in future it is possible to have two way communications, so that we can give commands to PIC directly for the purpose of controlling. It can be further developed for remote controlling.

8. REFERENCE
IEEE paper:[1] Wireless data acquisition system based on ARM-Hua Fang ,Ming Tang ,Lian Peng [2] Web-Based Wireless Data Acquisition System using 32bit Single Board Computer- R. B. Ahmad1, W. M. A. Mamat1, M. R. Mohamed Juhari2, S. Daud1, N. W. Arshad3 [3] A Remote Wireless Data Acquisition System Based on Ad Hoc Network and GPRS-Hong Cai [4] PIR-sensor based human motion event classification

BOOKS:[5] PIC Microcontroller and Embedded Systems By Mazidi [6] Applying PIC18 microcontrollers By Barry B. Brey [7] PIC microcontroller project book By John Iovine [8] Piezoelectric transducers and applications By Antonio Arnau [9] Sensors and transducers By Ian Robertson Sinclair [10] Transducers in measurement and control By P. H. Sydenham [11] Network Know How An Essential Guide for the Accidental Admin WEBSITE LINKS:[12] http://www.omega.com [13] http://www.radio-electronics.com [14] http://computer.howstuffworks.com/wireless-network.htm [15] http://www.mikroe.com/eng/chapters/view/74 [16] http://www.8051projects.info [17] http://www.josephn.net [18] http://www.discovercircuits.com [19] http://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/ [20] http://www.micro-examples.com

APPENDIX

9.1 Program for developing software for PC


Main program using System; using System.IO; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO.Ports; using WDAS; namespace WDAS { public partial class frmMain : Form { delegate void dataReceivedCallback(); delegate void GPSSerialPort_DataReceivedCallback(object sender, SerialDataReceivedEventArgs e); const float MIN_BATTERY_VOLTAGE = 10.5F; const float MAX_BATTERY_VOLTAGE = 12.6F; const float BATTERY_STEP = (MAX_BATTERY_VOLTAGE - MIN_BATTERY_VOLTAGE) / 4 + 0.1F; const float ADC_REFERENCE = 5.05F; const float BATTERY_DIVIDER_RATIO = 2.65F; const float BATTERY_SUBTRACTION_FACTOR = .9f; const float TEMP_DIVIDER_RATIO = .01F; const float TEMP_SUBTRACTION_FACTOR = .2513f; const float TEMP_THRESHOLD1 = 20; const float TEMP_THRESHOLD2 = 25; const float TEMP_THRESHOLD3 = 32; const float TEMP_THRESHOLD4 = 37; const float ULTRASONIC_THRESHOLD = 7.0F; const float ULTRASONIC_A = .207F;

const float ULTRASONIC_B = 0; const int CHART_MAX = 5; const string GPS_FILE = "C:\\gps.log"; int obstacles; double batteryVoltage, dist, temperature; bool usbConnected, masterOK, slaveOK, pir; Byte[] received; int rlen, readingTemp; StreamWriter logFile; char[] gpsSplit; ToolTip ttipConnect, ttipBattery, ttipMaster, ttipSlave, ttipTemp, ttipFrontDistance; public frmMain() { InitializeComponent(); } private void frmMain_Load(object sender, EventArgs e) { cmbComPorts.Items.Add("Select COM Port"); initFlags(); logFile.WriteLine(); logFile.AutoFlush = true; log("Welcome to WDAS"); initTooltips(); initGraph(); initGPS(); paintDevices(); paintPIR(); paintUltrasonic(); checkPics(); paintBatteries(); paintObstacles(); paintTemp(); rtfLog.Focus(); refreshCOMPortList(cmbComPorts);

} void initTooltips() { ttipConnect = new ToolTip(); ttipConnect.SetToolTip(picConnect, "Connect to USB master PIC"); ttipBattery = new ToolTip(); ttipMaster = new ToolTip(); ttipSlave = new ToolTip(); ttipTemp = new ToolTip(); ttipFrontDistance = new ToolTip(); } void initGPS() { gpsSplit = new char[2]; gpsSplit[0] = '\r'; gpsSplit[1] = '\n'; } void initFlags() { usbConnected = false; masterOK = slaveOK = false; received = new Byte[PCSerialPort.ReadBufferSize]; dist = 10000; picConnect.Image = WDAS.Properties.Resources.connect; logFile = File.AppendText("Log.txt"); } void initGraph() { chartTemperature.ChartAreas.Add("Temp"); chartTemperature.ChartAreas["Temp"].AxisX.Minimum = 0; chartTemperature.ChartAreas["Temp"].AxisY.Minimum = 0; chartTemperature.ChartAreas["Temp"].AxisX.Title = "Reading #"; chartTemperature.ChartAreas["Temp"].AxisY.Title = "Temperature"; chartTemperature.Series.Add("Temperature");

chartTemperature.Series["Temperature"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; } void log(string s, bool isError = false) { string dt = "[" + DateTime.Now.ToString() + "] "; rtfLog.SelectionColor = Color.Gray; rtfLog.AppendText(dt); if (isError) { rtfLog.SelectionColor = Color.Red; s = "error: " + s; } else { rtfLog.SelectionColor = Color.White; } rtfLog.AppendText(s + "\n"); logFile.WriteLine(dt + s); rtfLog.Focus(); } void refreshCOMPortList(ComboBox c, bool update = false) { bool isDifferent = true; int i = 0; if (SerialPort.GetPortNames().Length == c.Items.Count) { isDifferent = false; foreach (string s in SerialPort.GetPortNames()) { if (i >= c.Items.Count || (string)c.Items[i++] != s) isDifferent = true; } } if (!isDifferent ) return; c.Items.Clear(); foreach (string s in SerialPort.GetPortNames()) { c.Items.Add(s);

} if (update) { if (c.Items.Count == 0) log("Please connect the USB Master PIC", true); else log("Please select the com port to which the USB Master is connected and click 'Connect' to get started"); } } void checkPics() { if (!usbConnected) slaveOK = masterOK = false; if (!masterOK) slaveOK = false; if (usbConnected && masterOK) tmrRefreshCOMPort.Interval = 10 * 1000; else tmrRefreshCOMPort.Interval = 1 * 1000; paintDevices(); } void connect(string portName) { usbConnected = false; try { PCSerialPort.PortName = portName; PCSerialPort.Open(); usbConnected = true; log("Connected via " + portName); sendCommandString("R"); tmrMasterPICTimeout.Enabled = true; tmrSlavePICTimeout.Enabled = true; } catch { log("Can't connect to '" + portName + "'", true); }

checkPics(); } void disconnect() { if (usbConnected == false) return; try { sendCommandString("Q"); System.Threading.Thread.Sleep(200); PCSerialPort.DiscardInBuffer(); PCSerialPort.DiscardOutBuffer(); PCSerialPort.Close(); log("Disconnected"); } catch { } usbConnected = false; tmrMasterPICTimeout.Enabled = false; tmrSlavePICTimeout.Enabled = false; checkPics(); } private void tmrRefreshCOMPort_Tick(object sender, EventArgs e) { refreshCOMPortList(cmbComPorts, true); refreshCOMPortList(cmbGPS); } void paintDevices() { picMaster.Image = masterOK ? WDAS.Properties.Resources.ice : WDAS.Properties.Resources.icd; picSlave.Image = slaveOK ? WDAS.Properties.Resources.ice : WDAS.Properties.Resources.icd; if (!usbConnected) { ttipMaster.SetToolTip(picMaster, "Connection not established"); ttipSlave.SetToolTip(picSlave, "Connection not established"); } else

{ ttipMaster.SetToolTip(picMaster, masterOK ? "Master OK" : "Master not responding"); ttipSlave.SetToolTip(picSlave, slaveOK ? "Slave OK" : "Slave not responding"); } } void paintPIR() { picPIR.Image = pir ? WDAS.Properties.Resources.pire : WDAS.Properties.Resources.pird; } void paintBatteries() { if (batteryVoltage < MIN_BATTERY_VOLTAGE) picBattery.Image = WDAS.Properties.Resources.bat0; else if (batteryVoltage <= MIN_BATTERY_VOLTAGE + 1 * BATTERY_STEP) picBattery.Image = WDAS.Properties.Resources.bat1; else if (batteryVoltage <= MIN_BATTERY_VOLTAGE + 2 * BATTERY_STEP) picBattery.Image = WDAS.Properties.Resources.bat2; else if (batteryVoltage <= MIN_BATTERY_VOLTAGE + 3 * BATTERY_STEP) picBattery.Image = WDAS.Properties.Resources.bat3; else picBattery.Image = WDAS.Properties.Resources.bat4; ttipBattery.SetToolTip(picBattery, batteryVoltage.ToString() + " V"); } void paintUltrasonic() { if (dist>= 1000) { log("ULT No Obstacle"); picUltrasonic.Height = picUltrasonicBackground.Height; lblUltrasonicDistance.Text = "No obstacle"; } else { log("ULT " + dist.ToString());

picUltrasonic.Height = Math.Min((int)(dist * picUltrasonicBackground.Height / 150), picUltrasonicBackground.Height); lblUltrasonicDistance.Text = dist.ToString() + " cm"; } picUltrasonic.SetBounds(picUltrasonicBackground.Location.X, picUltrasonicBackground.Location.Y + picUltrasonicBackground.Height picUltrasonic.Height, picUltrasonicBackground.Width, picUltrasonic.Height); paintObstacles(); } void paintTemp() { log("TEMP " + temperature.ToString() + " C"); ttipTemp.SetToolTip(picTemperature, temperature.ToString() + " C"); if (temperature < TEMP_THRESHOLD1) picTemperature.Image = WDAS.Properties.Resources.temp_lowest; else if (temperature < TEMP_THRESHOLD2) picTemperature.Image = WDAS.Properties.Resources.temp_lower; else if (temperature < TEMP_THRESHOLD3) picTemperature.Image = WDAS.Properties.Resources.temp_medium; else if (temperature < TEMP_THRESHOLD4) picTemperature.Image = WDAS.Properties.Resources.temp_high; else picTemperature.Image = WDAS.Properties.Resources.temp_highest; chartTemperature.Series["Temperature"].Points.AddXY(+ +readingTemp, Math.Max(temperature, 0F)); if (chartTemperature.Series["Temperature"].Points.Count > CHART_MAX) { chartTemperature.Series["Temperature"].Points.RemoveAt(0); chartTemperature.ChartAreas["Temp"].AxisX.Minimum = readingTemp - CHART_MAX + 1; chartTemperature.ChartAreas["Temp"].AxisX.Maximum = readingTemp; } } void paintObstacles()

{ picObstacleUp.Image = dist <= ULTRASONIC_THRESHOLD ? WDAS.Properties.Resources.obs_up : null; picObstacleDown.Image = (obstacles & 1) > 0 ? WDAS.Properties.Resources.obs_down : null; picObstacleLeft.Image = (obstacles & 2) > 0 ? WDAS.Properties.Resources.obs_right : null; picObstacleRight.Image = (obstacles & 4) > 0 ? WDAS.Properties.Resources.obs_left : null; } void sendCommandString(string str) { log("sending(" + str.Length + "): " + str); sendCommand(StrToByteArray(str)); } void sendCommandBytes(byte[] cmd) { string str = ""; str += cmd[0]; for (int i = 1; i < cmd.Length; ++i) str += " <" + ((int)cmd[i]).ToString() + ">"; log("sending(" + str.Length + "): " + str); sendCommand(cmd); } bool sendCommand(byte[] cmd) { int cnt = 0; try { if (usbConnected) { while (PCSerialPort.BytesToWrite > 0 && cnt < 100) { System.Threading.Thread.Sleep(10); ++cnt; }; if (cnt == 100) { log("Buffer discarded due to timeout", true); PCSerialPort.DiscardOutBuffer(); PCSerialPort.DiscardInBuffer(); }

PCSerialPort.Write(cmd, 0, cmd.Length); } else { log("Trying to send command though there is no connection", true); } } catch { log("Problem while writing to serial port", true); return false; } return true; } private void PCSerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) { try { rlen = PCSerialPort.BytesToRead; PCSerialPort.Read(received, 0, rlen); dataReceived(); } catch { log("Problem while receiving data from serial port", true); disconnect(); checkPics(); } } bool rcvd(string str) { for (int i = 0; i < str.Length; ++i) if (received[i] != str[i]) return false; return true; } string toStr() { string ret = ""; ret += (char)received[0];

for (int i = 1; i < rlen; ++i) ret += (char)received[i]; // " <" + ((int)received[i]).ToString() + "> "; return ret; } string getInt(int i) { return ((int)received[i] * 256 + received[i + 1]).ToString(); } void dataReceived() { if (rtfLog.InvokeRequired) { dataReceivedCallback d = new dataReceivedCallback(dataReceived); Invoke(d); return; } bool fromSlave, fromMaster; fromSlave = fromMaster = false; log("rcvd: " + toStr()); if (rcvd("M")) { fromMaster = true; } else if (rcvd("S")) { fromSlave = true; } else if (rcvd("B")) { fromSlave = true; batteryVoltage = getvoltage(1); paintBatteries(); log("BAT " + batteryVoltage.ToString()); } else if (rcvd("T")) { fromSlave = true; temperature = getTemp(1); paintTemp(); } else if (rcvd("U")) {

fromSlave = true; log("ULT " + getInt(1).ToString()); dist = (received[1] * 256 + received[2]) * ULTRASONIC_A + ULTRASONIC_B ; paintUltrasonic(); } else if (rcvd("V")) { fromSlave = true; log("PIR " + received[1].ToString()); pir = ((received[1] == 1)?true:false); paintPIR(); } else if (rcvd("N")) { log("N " + ((int)received[1]).ToString()); } else if (rcvd("I") || rcvd("J")) { log(""); if (rcvd("I")) { fromMaster = true; log("Master Info: "); } else { fromSlave = true; log("Slave Info: "); } log("Bytes Sent: " + getInt(1)); log("Frames Sent: " + getInt(3)); log("Frames Queued: " + getInt(5)); log("Bytes Received: " + getInt(7)); log("Frames Received: " + getInt(9)); log("Bytes received error: " + getInt(11)); log("Frame errors: " + getInt(13)); log("Bytes dropped: " + getInt(15)); } else if(rcvd("O")) { fromMaster = true; obstacles = ~received[1]; paintObstacles(); } if (fromMaster) { masterOK = true;

checkPics(); tmrMasterPICTimeout.Enabled = false; tmrMasterPICTimeout.Enabled = true; } if (fromSlave) { slaveOK = true; checkPics(); tmrSlavePICTimeout.Enabled = false; tmrSlavePICTimeout.Enabled = true; } checkPics(); } double getvoltage(int i) { return (ADC_REFERENCE / 1024) * (((int)received[i]) * 256 + (int)received[i + 1]) * BATTERY_DIVIDER_RATIO - BATTERY_SUBTRACTION_FACTOR; } double getTemp(int i) { return ((ADC_REFERENCE / 1024) * (((int)received[i]) * 256 + (int)received[i + 1]) TEMP_SUBTRACTION_FACTOR) / TEMP_DIVIDER_RATIO; } private void PCSerialPort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e) { log("COM Port error", true); } private void rtfLog_Enter(object sender, EventArgs e) { rtfLog.SelectionStart = rtfLog.Text.Length; } private void rtfLog_MouseDown(object sender, MouseEventArgs e) { rtfLog.SelectionStart = rtfLog.Text.Length; } public static byte[] StrToByteArray(string str)

{ System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); return encoding.GetBytes(str); } public string ByteToString(Byte b) { string ret = ""; for (int i = 0; i < b.Length; ++i) ret += (char)b[i]; return ret; } private void frmMain_FormClosed(object sender, FormClosedEventArgs e) { try { disconnect(); GPSSerialPort.Close(); logFile.Close(); } catch (Exception ex) { log("Closing error: " + ex.ToString()); } } private void tmrMasterPICTimeout_Tick(object sender, EventArgs e) { masterOK = false; checkPics(); } private void tmrSlavePICTimeout_Tick(object sender, EventArgs e) { slaveOK = false; checkPics(); } private void picConnect_Click(object sender, EventArgs e) { if ((string)picConnect.Tag == "connect") connect((string)cmbComPorts.Text); else disconnect();

if (usbConnected) { picConnect.Image = WDAS.Properties.Resources.disconnect; ttipConnect.SetToolTip(picConnect, "Disconnect from master pic"); picConnect.Tag = "disconnect"; } else { picConnect.Image = WDAS.Properties.Resources.connect; ttipConnect.SetToolTip(picConnect, "Connect to master pic"); picConnect.Tag = "connect"; } rtfLog.Focus(); } private void tmrGPS_Tick(object sender, EventArgs e) { ReadGPSLog(); } void ReadGPSLog() { if (!File.Exists(GPS_FILE)) return; try { FileStream gpsFilestream = new FileStream(GPS_FILE, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); StreamReader gpsFile = new StreamReader(gpsFilestream); string contents = gpsFile.ReadToEnd(); string[] lines = contents.Split(gpsSplit); string[] data = null; gpsFile.Close(); File.Delete(GPS_FILE); for (int i = lines.Length - 1; i >= 0; --i) { bool ok = true; data = lines[i].Split(',');

foreach (string s in data) if (s == "") ok = false; if (ok) { log("GPS_FILE succesful"); break; } } } catch (FileNotFoundException f) { log("GPS no file: " + f.ToString(), true); } catch (Exception e) { log("GPS error: " + e.ToString(), true); } } private void GPSSerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) { if (rtfLog.InvokeRequired) { GPSSerialPort_DataReceivedCallback d = new GPSSerialPort_DataReceivedCallback(GPSSerialPort_DataReceived); this.Invoke(d, new object [] {sender, e}); return; } string data = GPSSerialPort.ReadLine(); parseGPS(data); } void parseGPS(string data) { string[] all = data.Split(','); if (!char.IsDigit(all[1][0]) || all[3] != "N" || all[5] != "E") return; lblLatitude.Text = "Latitude: " + parseLocation(all[2]) + " N"; lblLongitude.Text = "Longitude: " + parseLocation(all[4]) + " E"; lblTime.Text = getTime(all[1]); log(data); }

string getTime(string s) { DateTime d = new DateTime( DateTime.UtcNow.Date.Year, DateTime.UtcNow.Date.Month, DateTime.UtcNow.Date.Day, Convert.ToInt16(s.Substring(0, 2)), Convert.ToInt16(s.Substring(2, 2)),Convert.ToInt16(s.Substring(4, 2))); d = d.AddHours(5); d = d.AddMinutes(30); return d.ToLongTimeString(); } string parseLocation(string s) { return s.Substring(0, 2) + " " + s.Substring(2); } private void btnGPSConnect_Click(object sender, EventArgs e) { GPSSerialPort.PortName = cmbGPS.Text; GPSSerialPort.Open(); } } }

Program for microcontroller for collecting data from sensors, processing data, master slave communication and communication with PC
9.2.1 Program for master PIC /** INCLUDES *******************************************************/ #include "./USB/usb.h" #include "./USB/usb_function_cdc.h" #include <timers.h> #include <delays.h> #include <usart.h>

extern void _startup (void); #define STATUS_SEND_THRESHOLD 100 #define TML1 TRISBbits.TRISB2 #define ML1 LATBbits.LATB2 #define TML2 TRISBbits.TRISB3 #define ML2 LATBbits.LATB3 #define TMR1 TRISBbits.TRISB4 #define MR1 LATBbits.LATB4 #define TMR2 TRISBbits.TRISB5 #define MR2 LATBbits.LATB5 #define TIR_LED TRISBbits.TRISB6 #define IR_LED LATBbits.LATB6 #define TLIGHT TRISBbits.TRISB7 #define LIGHT LATBbits.LATB7 //IR obstacles #define TOBS0 TRISDbits.TRISD0 #define OBS0 PORTDbits.RD0 #define TOBS1 TRISDbits.TRISD1 #define OBS1 PORTDbits.RD1 #define TOBS2 TRISDbits.TRISD2 #define OBS2 PORTDbits.RD2 #define ENABLE(x) x = 1 #define DISABLE(x) x = 0 #define byte BYTE #define uint unsigned int //Serial IO header #define TX_INT PIE1bits.TXIE #define RX_INT PIE1bits.RCIE #define IO_INT PIE2bits.TMR3IE // Sizes #define WINDOW_SIZE 3 #define DATA_SIZE 20 #define HEADER_SIZE 4 #define TRAILER_SIZE 3 #define FRAME_SIZE (HEADER_SIZE + DATA_SIZE + TRAILER_SIZE) #define TX_BUFFER_SIZE (WINDOW_SIZE * FRAME_SIZE) #define RX_BUFFER_SIZE 175 #define ACK_TIMEOUT 20 * (WINDOW_SIZE + 1)

//Flags #define DATA_FRAME 0xF1 #define ACK_FRAME 0xF2 #define ERROR_FRAME 0xF0 #define FLAG 0x99 #define ESC 0x81 #define FLETCHER_MOD 255 /** I N C L U D E S **********************************************************/ #include "GenericTypeDefs.h" #include "Compiler.h" #include "usb_config.h" #include "USB\usb_device.h" #include "USB\usb.h" #include "HardwareProfile.h" /** V A R I A B L E S ********************************************************/ #pragma udata USB byte in[64]; byte out[64]; #pragma udata Layer0Data byte txBuffer[TX_BUFFER_SIZE]; //Cyclic queue int rxBufferStart, rxBufferEnd, rxBufferLen, txBufferStart, txBufferEnd, txBufferLen; //Maintains the state of the cyclic buffers #pragma udata Layer0DataRX byte rxBuffer[RX_BUFFER_SIZE]; #pragma udata Layer1Data byte txFrames[WINDOW_SIZE][FRAME_SIZE], txFrameReady[WINDOW_SIZE]; byte rxFrame[FRAME_SIZE]; byte rxFrameID, txFrameIDStart, txFrameID, txFramesLeft,rxFrameIdx; volatile byte rxFrameReady; byte ackTimerOn, ackTimerCount; #pragma udata IOInfo uint txBytesSent, txFramesSent, txFramesQueued, rxBytesReceived, rxFramesReceived, rxByteErrors, rxFrameErrors, rxBytesDropped; #pragma udata MasterData

byte slave[20]; #pragma idata rom byte CML1[4] = "001", CML2[4] = "010"; rom byte CMR1[4] = "010", CMR2[4] = "001"; #pragma udata byte inLen; volatile byte statusSendCount, statusSendFlag, connected; #pragma code /** P R I V A T E P R O T O T Y P E S ***************************************/ static void InitializeSystem(void); void ProcessIO(void); void USBDeviceTasks(void); void YourHighPriorityISRCode(); void YourLowPriorityISRCode(); void UserInit(void); void initStatusSend(void); void sendStatus(void); void procCommand(void); //Serial IO void initSerialIO(void); byte readByte(void); void writeByte(byte b); void writeFrame(byte frameID); uint calcFletcherChecksum(const byte *buf, byte len); void sendFrame(const byte *data, byte len); void sendAckFrame(byte frameID); void procAckFrame(void); void rxProc(void); byte verifyFrame(void); byte getData(byte *buf); void resetAckTimer(void); void ackTimeout(void); void removeFrame(byte frameID); void rxReset(void); void sendStr(const char rom *str); void init(); //Send the data in the array buf #define sendData(buf, len) sendFrame(buf, len); void sendToSlave(const byte *cmd, byte len); byte canSend(void);

void initMotors(void); void initObstacles(void); byte getObstacles(void); #pragma code REMAPPED_RESET_VECTOR = 0x800 void _reset (void) { _asm goto _startup _endasm } #pragma code REMAPPED_HIGH_INTERRUPT_VECTOR = 0x808 void Remapped_High_ISR (void) { _asm goto YourHighPriorityISRCode _endasm } #pragma code REMAPPED_LOW_INTERRUPT_VECTOR = 0x818 void Remapped_Low_ISR (void) { _asm goto YourLowPriorityISRCode _endasm } #pragma code //These are actual interrupt handling routines. #pragma interrupt YourHighPriorityISRCode void YourHighPriorityISRCode() { if(RX_INT && PIR1bits.RCIF) { if(RCSTAbits.OERR) { //required to clear the overrun error flag ++rxByteErrors; RCSTAbits.CREN = 0; RCSTAbits.CREN = 1; } if(rxBufferLen == RX_BUFFER_SIZE) {+ +rxBytesDropped; return;} //Drop byte if no buffer space. Drop will be handled by higher layer. if(RCSTAbits.FERR) ++rxByteErrors; ++rxBytesReceived; rxBuffer[rxBufferEnd] = RCREG; //Ignore any framing and overrun errors. It will be handled by the higher layer. if(++rxBufferEnd == RX_BUFFER_SIZE) rxBufferEnd = 0; ++rxBufferLen; } #if defined(USB_INTERRUPT)

USBDeviceTasks(); #endif } //This return will be a "retfie fast", since this is in a #pragma interrupt section #pragma interruptlow YourLowPriorityISRCode void YourLowPriorityISRCode() { if(TX_INT && PIR1bits.TXIF) { //tx interrupt if(txBufferLen == 0) { //No data to transmit. So disable tx interrupt. DISABLE(TX_INT); return; } ++txBytesSent; TXREG = txBuffer[txBufferStart]; if(++txBufferStart == TX_BUFFER_SIZE) txBufferStart = 0; --txBufferLen; } if(PIR2bits.TMR3IF) { rxProc(); if(ackTimerOn && txBufferLen == 0) { ++ackTimerCount; if(ackTimerCount == ACK_TIMEOUT) ackTimeout(); } TMR3H = 0; TMR3L = 0; PIR2bits.TMR3IF = 0; if(statusSendFlag == 0 && ++statusSendCount == STATUS_SEND_THRESHOLD) { statusSendFlag = 1; statusSendCount = 0; } } } //This return will be a "retfie", since this is in a #pragma interruptlow section /** DECLARATIONS ***************************************************/ #pragma code void initMotors() { TML1 = TML2 = TMR1 = TMR2 = 0; ML1 = ML2 = MR1 = MR2 = 0; }

void initObstacles() { TOBS0 = TOBS1 = TOBS2 = 1; } void main(void) { InitializeSystem(); USBDeviceAttach(); while(1) { ProcessIO(); if(statusSendFlag) sendStatus(); } } //Init all other device void init() { TIR_LED = TLIGHT = 0; IR_LED = LIGHT = 0; } //Send obstacles mask byte getObstacles() { return OBS2 * 4 + OBS1 * 2 + OBS0; } //Initialises status sender data void initStatusSend() { statusSendCount = 0; statusSendFlag = 0; connected = 0; } //Sends all reqd data alternately void sendStatus() { static byte count = 0; if(!connected) return; inLen = 1; in[0] = 'O'; procCommand(); if(++count == 2) count = 0; statusSendFlag = 0; }

static void InitializeSystem(void) { ADCON1 = 0x0F; initMotors(); initObstacles(); initSerialIO(); initStatusSend(); init(); USBDeviceInit(); }//end InitializeSystem #define rcvd(x) in[0] == x #define put16Bits(b, i, x) b[i] = (x >> 8); b[i + 1] = (x & 0xFF); void ProcessIO(void) { byte len; // User Application USB tasks if((USBDeviceState < CONFIGURED_STATE)|| (USBSuspendControl==1)) return; if(rxFrameReady) { len = getData(slave); slave[len] = 0; putUSBUSART((char *)slave, len); } //--> Replace by single comparision? if(mUSBUSARTIsTxTrfReady()) { inLen = getsUSBUSART((char *)in, 64); procCommand(); } } CDCTxService(); //end ProcessIO

//Processes command according to data in in[] void procCommand() { if(inLen > 0) { if(rcvd('P')) { putrsUSBUSART("M"); } else if(rcvd('M')) { ML1 = CML1[in[1] - '0']; ML2 = CML2[in[1] - '0']; MR1 = CMR1[in[2] - '0']; MR2 = CMR2[in[2] - '0']; } else if(rcvd('I')) {

//Send back txBytesSent, txFramesSent, txFramesQueued, rxBytesReceived, rxFramesReceived, rxByteErrors, rxFrameErrors, rxBytesDropped; out[0] = 'I'; put16Bits(out, 1, txBytesSent); put16Bits(out, 3, txFramesSent); put16Bits(out, 5, txFramesQueued); put16Bits(out, 7, rxBytesReceived); put16Bits(out, 9, rxFramesReceived); put16Bits(out, 11, rxByteErrors); put16Bits(out, 13, rxFrameErrors); put16Bits(out, 15, rxBytesDropped); putUSBUSART((char *)out, 17); sendToSlave(in, inLen); } else if(rcvd('L')) { IR_LED = (in[1] == '1')? 1: 0; LIGHT = (in[2] == '1')? 1: 0; } else if(rcvd('R')) { connected = 1; sendToSlave(in, inLen); } else if(rcvd('Q')) { connected = 0; sendToSlave(in, inLen); } else if(rcvd('O')) { out[0] = 'O'; out[1] = getObstacles(); out[2] = 0; putUSBUSART((char *)out, 2); } else { sendToSlave(in, inLen); } } } //Send a command to slave on a priority basis void sendToSlave(const byte *cmd, byte len) { if(txFramesLeft == WINDOW_SIZE) removeFrame(txFrames[0] [2]); //--> Use a more sophisticated method to decide which frame to remove sendData(cmd, len); } //Serial IO implementation //Initialize the USART module //Load baud rate settings, enable rx interrupt etc void initSerialIO() { unsigned char temp, i; SSPCON1 = 0; // Make sure SPI is disabled Datasheet

//Refer

TRISCbits.TRISC7=1; // RX TRISCbits.TRISC6=1; // TX SPBRG = 0x71; SPBRGH = 0x02; // 0x0271 for 48MHz -> 19200 baud XTAL=20MHz, Fosc=48Mhz TXSTA = 0x24; // TX enable BRGH=1 RCSTA = 0x90; // continuous RX BAUDCON = 0x08; // BRG16 = 1 INTCON |= 0xC0; RCONbits.IPEN = 1; //Enable priority interrupts //Interrupt Priority //RX has high priority to minimize override errors IPR1bits.RCIP = 1; IPR1bits.TXIP = 0; //Initialize buffer indexes and statuses rxBufferStart = rxBufferEnd = txBufferStart = txBufferEnd = 0; rxBufferLen = txBufferLen = txFramesLeft = 0; rxFrameID = txFrameIDStart = txFrameID = rxFrameIdx = rxFrameReady = 0; txBytesSent = txFramesSent = txFramesQueued = rxBytesReceived = rxFramesReceived = rxByteErrors = rxFrameErrors = rxBytesDropped = 0; ackTimerOn = 0; //Mark all frame slots as empty for(i = 0; i < WINDOW_SIZE; ++i) txFrameReady[i] = 0; //Enable Timer 3 interrupt to process Layer 0 rx OpenTimer3(TIMER_INT_ON & T3_16BIT_RW & T3_SOURCE_INT & T3_PS_1_4 & T3_SYNC_EXT_OFF); IPR2bits.TMR3IP = 0; TMR3L = 0X00; TMR3H = 0x00; DISABLE(TX_INT); //Enable tx interrupt only when needed ENABLE(RX_INT); } //Transmit the string str void sendStr(const char rom *str) { byte len = 0; for(; str[len]; ++len) out[len] = str[len]; sendData(out, len); }

//Create a frame, add it to the frame queue and send it void sendFrame(const byte *data, byte len) { byte idx = 0, i, end; uint checksum; do { for(idx = 0; idx < WINDOW_SIZE; ++idx) if(txFrameReady[idx] == 0) break; }while(idx == WINDOW_SIZE); txFrames[idx][0] = FLAG; txFrames[idx][1] = DATA_FRAME; txFrames[idx][2] = txFrameID; txFrames[idx][3] = len; for(i = 0; i < len; ++i) txFrames[idx][i + HEADER_SIZE] = data[i]; end = len + HEADER_SIZE; checksum = calcFletcherChecksum(txFrames[idx], end); txFrames[idx][end] = (byte)(checksum >> 8); txFrames[idx][end + 1] = (byte)(checksum & 0x00FF); txFrames[idx][end + 2] = FLAG; txFrameReady[idx] = 1; ++txFramesLeft; writeFrame(txFrameID); ++txFrameID; if(ackTimerOn == 0) resetAckTimer(); ++txFramesQueued; } //Transmit a frame. void writeFrame(byte frameID) { byte idx = 0, i, tot; for(; idx < WINDOW_SIZE ; ++idx) if(txFrameReady[idx] && txFrames[idx][2] == frameID) break; //Search for the frame with the required frame ID if(idx == WINDOW_SIZE) return; //No frame found //write header for(i = 0; i < HEADER_SIZE; ++i) writeByte(txFrames[idx][i]); //write data with escaping tot = HEADER_SIZE + txFrames[idx][3]; for(; i < tot; ++i) {

if(txFrames[idx][i] == ESC || txFrames[idx][i] == FLAG) { writeByte(ESC); writeByte(~txFrames[idx][i]); } else { writeByte(txFrames[idx][i]); } } tot += TRAILER_SIZE; for(; i < tot; ++i) writeByte(txFrames[idx][i]); ++txFramesSent; } //Process a received ACK frame void procAckFrame() { byte ackID = rxFrame[2]; while(ackID != txFrameIDStart) { removeFrame(txFrameIDStart); if(txFrameIDStart == txFrameID) ++txFrameID; ++txFrameIDStart; } resetAckTimer(); } //Calculates the Fletcher checksum. See wiki article uint calcFletcherChecksum(const byte *buf, byte len) { uint a, b; byte i; a = b = 0; for(i = 0; i < len; ++i) { a += buf[i]; if(a >= FLETCHER_MOD) a -= FLETCHER_MOD; b += a; if(b >= FLETCHER_MOD) b -= FLETCHER_MOD; } return ((b << 8) | a); } //Waits till a data frame is received succesfully and copies it to buf byte getData(byte *buf) { byte len, i; while(!rxFrameReady); len = rxFrame[3]; for(i = 0; i < len; ++i) buf[i] = rxFrame[i + HEADER_SIZE]; rxReset();

return len; } //Process rx. This is a state machine which process received buffer partially if required. void rxProc() { byte cur, end; if(rxBufferLen == 0) return; //Return if no data waiting if(rxFrameReady) return; //Last frame not processed //Go forward till start flag while(rxFrameIdx == 0 && rxBufferLen >= 1) { cur = readByte(); if(cur == FLAG) { rxFrame[rxFrameIdx] = cur; ++rxFrameIdx; break; } } //Rest of header while(rxFrameIdx >= 1 && rxFrameIdx < HEADER_SIZE && rxBufferLen >= 1) { cur = readByte(); //Check for out of sync flag byte if(rxFrameIdx == 1 && cur == FLAG) continue; //Check for frame length if(rxFrameIdx == 3 && cur > DATA_SIZE) { //Invalid data length, so drop the frame rxReset(); return; } rxFrame[rxFrameIdx] = cur; rxFrameIdx++; } if(rxFrameIdx < HEADER_SIZE) return; end = HEADER_SIZE + rxFrame[3]; //Data payload while(rxFrameIdx < end && rxBufferLen >= 2) { cur = readByte(); if(cur == ESC) { cur = ~readByte(); } else if(cur == FLAG) { //a FLAG byte without ESC byte. So treat it as end of frame error rxReset();

return; } rxFrame[rxFrameIdx] = cur; rxFrameIdx++; } end += TRAILER_SIZE; //Trailer while(rxFrameIdx >= HEADER_SIZE + rxFrame[3] && rxFrameIdx < end && rxBufferLen >= 1) { cur = readByte(); rxFrame[rxFrameIdx] = cur; ++rxFrameIdx; } if(rxFrameIdx == end) { ++rxFramesReceived; if(!verifyFrame()) { //Error in frame ++rxFrameErrors; rxReset(); return; } if(rxFrame[1] == ACK_FRAME) { procAckFrame(); rxReset(); return; } //Check if it is the correct frame ID if(rxFrameID != rxFrame[2]) { sendAckFrame(rxFrameID); rxReset(); return; } //Correct data frame received rxFrameReady = 1; ++rxFrameID; sendAckFrame(rxFrameID); } } //Resets the rx statuses void rxReset() { rxFrameReady = 0;

rxFrameIdx = 0; } //Check for various error condition byte verifyFrame() { byte end = HEADER_SIZE + TRAILER_SIZE + rxFrame[3]; uint rxChecksum = ((((uint)rxFrame[end - 3]) << 8) | rxFrame[end 2]), checksum; if(rxFrame[end - 1] != FLAG) return 0; if(rxFrame[1] != ACK_FRAME && rxFrame[1] != DATA_FRAME) return 0; if(rxFrame[1] == ACK_FRAME && rxFrame[3] > 0) return 0; checksum = calcFletcherChecksum(rxFrame, end - 3); if(checksum != rxChecksum) return 0; return 1; } //Send an ACK frame void sendAckFrame(byte frameID) { byte frame[4], i; uint checksum; frame[0] = FLAG; frame[1] = ACK_FRAME; frame[2] = frameID; frame[3] = 0; checksum = calcFletcherChecksum(frame, 4); for(i = 0; i < 4; ++i) writeByte(frame[i]); writeByte((byte)(checksum >> 8)); writeByte((byte)(checksum & 0xFF)); writeByte(FLAG); } //An ACK timeout has occurred, so retransmit all the frames in queue void ackTimeout() { byte i = txFrameIDStart; for(; i != txFrameID; ++i) writeFrame(i); resetAckTimer(); } //Resets the ack timer void resetAckTimer() {

ackTimerOn = 1; ackTimerCount = 0; } //Remove the given frame void removeFrame(byte frameID) { byte idx; //Search for specified frame for(idx = 0; idx < WINDOW_SIZE; ++idx) if(txFrameReady[idx] == 1 && txFrames[idx][2] == frameID) break; if(idx == WINDOW_SIZE) return; txFrameReady[idx] = 0; //Mark slot as free --txFramesLeft; } //Read a byte from the rx buffer //Returns undefined data if there is no byte in rx buffer. This prevents infinte wait. byte readByte() { byte ret = 0x99; if(rxBufferLen != 0) { //Disable rx interrupt while reading to avoid simultaneous access DISABLE(RX_INT); ret = rxBuffer[rxBufferStart]; rxBufferStart = (rxBufferStart + 1) % RX_BUFFER_SIZE; --rxBufferLen; ENABLE(RX_INT); } return ret; } //Write a byte to the tx buffer void writeByte(byte b) { if(txBufferLen == TX_BUFFER_SIZE) { //Wait if buffer is full ENABLE(TX_INT); while(txBufferLen == TX_BUFFER_SIZE); } DISABLE(TX_INT); txBuffer[txBufferEnd] = b; txBufferEnd = (txBufferEnd + 1) % TX_BUFFER_SIZE; ++txBufferLen; ENABLE(TX_INT); } void USBCBSuspend(void) {}

void USBCBWakeFromSuspend(void){} void USBCB_SOF_Handler(void){} void USBCBErrorHandler(void){} void USBCBCheckOtherReq(void) {USBCheckCDCRequest();}//end void USBCBStdSetDscHandler(void){}//end void USBCBInitEP(void) {CDCInitEP();} void USBCBSendResume(void) { static WORD delay_count; USBResumeControl = 1; // Start RESUME signaling delay_count = 1800U; // Set RESUME line for 1-13 ms do { delay_count--; }while(delay_count); USBResumeControl = 0; } BOOL USER_USB_CALLBACK_EVENT_HANDLER(USB_EVENT event, void *pdata, WORD size) { switch(event) { case EVENT_CONFIGURED: USBCBInitEP(); break; case EVENT_SET_DESCRIPTOR: USBCBStdSetDscHandler(); break; case EVENT_EP0_REQUEST: USBCBCheckOtherReq(); break; case EVENT_SOF: USBCB_SOF_Handler(); break; case EVENT_SUSPEND: USBCBSuspend(); break; case EVENT_RESUME: USBCBWakeFromSuspend(); break; case EVENT_BUS_ERROR: USBCBErrorHandler(); break; case EVENT_TRANSFER: Nop(); break; default: break; } return TRUE; } /** EOF main.c *************************************************/

9.2.2 Program for slave PIC

#include<p18f4550.h> #include<delays.h> #include<usart.h> #include<timers.h> #include<stdlib.h> extern void _startup (void); void High_ISR(void); void Low_ISR(void); // See c018i.c in your C18 compiler dir

/** V E C T O R R E M A P P I N G *******************************************/ #pragma code _RESET_INTERRUPT_VECTOR = 0x000800 void _reset (void) { _asm goto _startup _endasm } #pragma code #pragma code _HIGH_INTERRUPT_VECTOR = 0x000808 void _high_ISR (void) { _asm goto High_ISR _endasm } #pragma code _LOW_INTERRUPT_VECTOR = 0x000818 void _low_ISR (void) { _asm goto Low_ISR _endasm } #pragma code /** D E C L A R A T I O N S **************************************************/ #pragma code //Delays declarations void delayus(unsigned char count); void delay10us(unsigned char count); void delayms(unsigned char count); void delays(unsigned char count); //Delays implementation

void delayus(unsigned char count) { OpenTimer2(TIMER_INT_OFF & T2_PS_1_1 & T2_POST_1_1 ); PR2 = 12; while(count--) { while(PIR1bits.TMR2IF == 0); PIR1bits.TMR2IF = 0; } CloseTimer2(); } void delay10us(unsigned char count) { TMR2 = 0; OpenTimer2(TIMER_INT_OFF & T2_PS_1_1 & T2_POST_1_1 ); PR2 = 120; while(count--) { while(PIR1bits.TMR2IF == 0); PIR1bits.TMR2IF = 0; } CloseTimer2(); } void delayms(unsigned char count) { unsigned char i; while(count--) { delay10us(100); }; } void delays(unsigned char count) { while(count--) { delayms(200); delayms(200); delayms(200); delayms(200); delayms(200); } } //-------/* DEFINES */ #define ENABLE(x) x = 1 #define DISABLE(x) x = 0 #define byte unsigned char #define uint unsigned int //Serial IO header #define TX_INT PIE1bits.TXIE #define RX_INT PIE1bits.RCIE // Sizes

#define WINDOW_SIZE 3 #define DATA_SIZE 20 #define HEADER_SIZE 4 #define TRAILER_SIZE 3 #define FRAME_SIZE (HEADER_SIZE + DATA_SIZE + TRAILER_SIZE) #define TX_BUFFER_SIZE (WINDOW_SIZE * FRAME_SIZE) #define RX_BUFFER_SIZE 175 #define ACK_TIMEOUT 20 * (WINDOW_SIZE + 1) //Flags #define DATA_FRAME 0xF1 #define ACK_FRAME 0xF2 #define ERROR_FRAME 0xF0 #define FLAG 0x99 #define ESC 0x81 #define FLETCHER_MOD 255 //PWM #define NUM_PWM_PORTS 3 #define PWM0 LATBbits.LATB0 #define TPWM0 TRISBbits.TRISB0 #define PWM1 LATBbits.LATB1 #define TPWM1 TRISBbits.TRISB1 #define PWM2 LATBbits.LATB3 #define TPWM2 TRISBbits.TRISB3 #define TUS_TRIG TRISBbits.TRISB5 #define US_TRIG LATBbits.LATB5 #define TUS_ECHO TRISBbits.TRISB7 #define US_ECHO PORTBbits.RB7 #define TPIR TRISBbits.TRISB6 #define PIR PORTBbits.RB6 #define MX_TIME 234 #define STATUS_SEND_THRESHOLD 100 #pragma udata Layer0Data byte txBuffer[TX_BUFFER_SIZE]; //Cyclic queue int rxBufferStart, rxBufferEnd, rxBufferLen, txBufferStart, txBufferEnd, txBufferLen; //Maintains the state of the cyclic buffers

#pragma udata Layer0DataRX byte rxBuffer[RX_BUFFER_SIZE]; #pragma udata Layer1Data byte txFrames[WINDOW_SIZE][FRAME_SIZE], txFrameReady[WINDOW_SIZE]; byte rxFrame[FRAME_SIZE]; byte rxFrameID, txFrameIDStart, txFrameID, txFramesLeft,rxFrameIdx; volatile byte rxFrameReady; byte ackTimerOn, ackTimerCount; #pragma udata IOInfo uint txBytesSent, txFramesSent, txFramesQueued, rxBytesReceived, rxFramesReceived, rxByteErrors, rxFrameErrors, rxBytesDropped; #pragma udata volatile uint PWM_DC[NUM_PWM_PORTS]; // /100 ms #pragma udata uint ADC[20]; volatile byte statusSendCount, statusSendFlag, connected; #pragma code //Serial IO void initSerialIO(void); byte readByte(void); void writeByte(byte b); void writeFrame(byte frameID); uint calcFletcherChecksum(const byte *buf, byte len); void sendFrame(const byte *data, byte len); void sendAckFrame(byte frameID); void procAckFrame(void); void rxProc(void); byte verifyFrame(void); byte getData(byte *buf); void resetAckTimer(void); void ackTimeout(void); void removeFrame(byte frameID); void rxReset(void); void sendStr(const char rom *str); //Send the data in the array buf #define sendData(buf, len) sendFrame(buf, len); byte rcvd(const rom char *str); void procCommand(void);

void timer0_isr(void); void initPWM(void); void initADC(void); uint getADC(byte c); uint getInputVoltage(byte inp); uint getUltrasonic(void); void initUltrasonic(void); void initPIR(void); void initStatusSend(void); void sendStatus(void); byte cmd[20], out[20], cmdLen; #define rcvd(x) cmd[0] == x //PWM DC at angle 200 #define PWM200 30 uint getPWM(uint angle) { return angle / 9 + 8; } #define put16Bits(b, i, x) b[i] = (x >> 8); b[i + 1] = (x & 0xFF); void procCommand() { uint tmp; byte len; if(rcvd('P')) { sendStr("S"); } if(rcvd('C')) { PWM_DC[0] = getPWM(cmd[1]); PWM_DC[1] = getPWM(cmd[2]); } else if(rcvd('B')) { tmp = getADC(0); put16Bits(cmd, 1, tmp); sendData(cmd, 3); } else if(rcvd('T')) { tmp = getADC(1); put16Bits(cmd, 1, tmp); sendData(cmd, 3); } else if(rcvd('U')) { tmp = getUltrasonic(); put16Bits(cmd, 1, tmp); sendData(cmd, 3); } else if(rcvd('V')) { cmd[1] = PIR; sendData(cmd, 2); } else if(rcvd('S')) {

PWM_DC[2] = (MX_TIME * (uint)cmd[1] / 100); } else if(rcvd('I')) { //Send back txBytesSent, txFramesSent, txFramesQueued, rxBytesReceived, rxFramesReceived, rxByteErrors, rxFrameErrors, rxBytesDropped; put16Bits(cmd, 1, txBytesSent); put16Bits(cmd, 3, txFramesSent); put16Bits(cmd, 5, txFramesQueued); put16Bits(cmd, 7, rxBytesReceived); put16Bits(cmd, 9, rxFramesReceived); put16Bits(cmd, 11, rxByteErrors); put16Bits(cmd, 13, rxFrameErrors); put16Bits(cmd, 15, rxBytesDropped); sendData(cmd, 17); } else if(rcvd('R')) { connected = 1; } else if(rcvd('Q')) { connected = 0; } } //Initialises status sender data void initStatusSend() { statusSendCount = 0; statusSendFlag = 0; connected = 0; } //Sends all reqd data alternately void sendStatus() { static byte count = 0; if(!connected) return; //cmdLen = 1; //cmd[0] = 'P'; //procCommand(); if(count == 0) { cmd[0] = 'V'; procCommand(); } else if(count == 1) { cmd[0] = 'B'; procCommand(); } else if(count == 2) { cmd[0] = 'T'; procCommand(); } else if(count == 3) { cmd[0] = 'U'; procCommand();

} if(++count == 4) count = 0; statusSendFlag = 0; } void main() { signed int b = 0, i; INTCON = 0; initSerialIO(); initPWM(); initUltrasonic(); initPIR(); initADC(); initStatusSend(); while(1) { if(rxFrameReady) { cmdLen = getData(cmd); procCommand(); } if(statusSendFlag) sendStatus(); } } void initUltrasonic() { TUS_TRIG = 0; TUS_ECHO = 1; US_TRIG = 0; } void initPIR() { TPIR = 1; } /* uint getUltrasonic() { uint cnt = 0; byte tot = 0, over = US_ECHO; PR2 = 0xFF; OpenTimer2(TIMER_INT_OFF & T2_PS_1_16 & T2_POST_1_1); PIR1bits.TMR2IF = 0; tot = 0; while(US_ECHO == 1 && tot <= 250) { if(PIR1bits.TMR2IF == 1) {

PIR1bits.TMR2IF = 0; ++tot; } } CloseTimer2(); if(tot >= 250) return 251 * 256; US_TRIG = 1; delay10us(1); US_TRIG = 0; PR2 = 0xFF; OpenTimer2(TIMER_INT_OFF & T2_PS_1_16 & T2_POST_1_1); PIR1bits.TMR2IF = 0; tot = 0; while(US_ECHO == 0 && tot <= 250) { if(PIR1bits.TMR2IF == 1) { PIR1bits.TMR2IF = 0; ++tot; } } CloseTimer2(); if(tot >= 250) return 250 * 256; PR2 = 0xFF; OpenTimer2(TIMER_INT_OFF & T2_PS_1_16 & T2_POST_1_1); PIR1bits.TMR2IF = 0; tot = 0; while(US_ECHO == 1 && tot <= 250) { if(PIR1bits.TMR2IF == 1) { PIR1bits.TMR2IF = 0; ++tot; } } CloseTimer2(); cnt = ((int)tot << 8) + ReadTimer2(); return cnt; } */ uint getUltrasonic() { uint tot = 0; PR2 = 0xFF; OpenTimer2(TIMER_INT_OFF & T2_PS_1_16 & T2_POST_1_1);

PIR1bits.TMR2IF = 0; tot = 0; while(US_ECHO == 1 && tot <= 250) { if(PIR1bits.TMR2IF == 1) { PIR1bits.TMR2IF = 0; ++tot; } } CloseTimer2(); if(tot >= 250) return 251 * 256; US_TRIG = 1; delay10us(1); US_TRIG = 0; PR2 = 0xFF; OpenTimer2(TIMER_INT_OFF & T2_PS_1_16 & T2_POST_1_1); PIR1bits.TMR2IF = 0; tot = 0; while(US_ECHO == 0 && tot <= 250) { if(PIR1bits.TMR2IF == 1) { PIR1bits.TMR2IF = 0; ++tot; } } CloseTimer2(); if(tot >= 250) return 252 * 256; PR2 = 0xFF; OpenTimer2(TIMER_INT_OFF); PIR1bits.TMR2IF = 0; tot = 0; while(US_ECHO == 1 && tot <= 250) { if(PIR1bits.TMR2IF == 1) { PIR1bits.TMR2IF = 0; ++tot; } } CloseTimer2(); if(tot >= 250) return 250 * 256 + 0; tot = (tot << 8) + ReadTimer2(); return tot;

} uint getInputVoltage(byte inp) { LATB &= 0x0F; LATB |= (inp << 4); return getADC(0); } //ADC void initADC() { ADCON0 = 0x00; ADCON1 = 0x00; ADCON2 = 0b10001110; //Right justified, 2 * Tad, Fosc / 64 TRISAbits.TRISA0 = 1; TRISAbits.TRISA1 = 1; TRISAbits.TRISA2 = 1; TRISAbits.TRISA3 = 1; } uint getADC(byte ch) { if(ch > 13) return 0; ADCON0 = (ch << 2); ADCON0bits.ADON = 1; delayus(5); //Acquisition delay ADCON0bits.GO = 1; while(ADCON0bits.GO == 1); ADCON0bits.ADON = 0; delayus(20); return ((int)ADRESH << 8) + ADRESL; } //PWM void initPWM(void){ int i; // Set all duty cycles to zero for(i=0;i<NUM_PWM_PORTS;i++){ PWM_DC[i] = getPWM(0); } TPWM0 = TPWM1 = TPWM2 = 0; PWM0 = PWM1 = PWM2 = 0;

// Read section 11.0 - 11.4 to understand the configuration of timer0 !!! OpenTimer0(TIMER_INT_ON & T0_8BIT & T0_SOURCE_INT & T0_PS_1_4); // Interrupt configuration, see datasheet 9.2 // Timer0 generates a high priority interrupt INTCON |= 0b11100000; // Interrupt priorities enabled, // low and high priority interrupts enabled. // TMR0 interrupt enabled. INTCON2 = 0b10000100; } //Serial IO implementation //Initialize the USART module //Load baud rate settings, enable rx interrupt etc void initSerialIO() { unsigned char temp, i; SSPCON1 = 0; // Make sure SPI is disabled Datasheet TRISCbits.TRISC7=1; // RX TRISCbits.TRISC6=1; // TX

//Refer

SPBRG = 0x71; SPBRGH = 0x02; // 0x0271 for 48MHz -> 19200 baud XTAL=20MHz, Fosc=48Mhz TXSTA = 0x24; // TX enable BRGH=1 RCSTA = 0x90; // continuous RX BAUDCON = 0x08; // BRG16 = 1 INTCON |= 0xC0; RCONbits.IPEN = 1; //Enable priority interrupts //Interrupt Priority //RX has high priority to minimize override errors IPR1bits.RCIP = 1; IPR1bits.TXIP = 0; //Initialize buffer indexes and statuses rxBufferStart = rxBufferEnd = txBufferStart = txBufferEnd = 0; rxBufferLen = txBufferLen = txFramesLeft = 0; rxFrameID = txFrameIDStart = txFrameID = rxFrameIdx = rxFrameReady = 0;

txBytesSent = txFramesSent = txFramesQueued = rxBytesReceived = rxFramesReceived = rxByteErrors = rxFrameErrors = rxBytesDropped = 0; ackTimerOn = 0; //Mark all frame slots as empty for(i = 0; i < WINDOW_SIZE; ++i) txFrameReady[i] = 0; //Enable Timer 3 interrupt to process Layer 0 rx OpenTimer3(TIMER_INT_ON & T3_16BIT_RW & T3_SOURCE_INT & T3_PS_1_4 & T3_SYNC_EXT_OFF); IPR2bits.TMR3IP = 0; TMR3L = 0X00; TMR3H = 0x00; DISABLE(TX_INT); //Enable tx interrupt only when needed ENABLE(RX_INT); } //Transmit the string str void sendStr(const char rom *str) { byte len = 0; for(; str[len]; ++len) out[len] = str[len]; sendData(out, len); } //Create a frame, add it to the frame queue and send it void sendFrame(const byte *data, byte len) { byte idx = 0, i, end; uint checksum; do { for(idx = 0; idx < WINDOW_SIZE; ++idx) if(txFrameReady[idx] == 0) break; }while(idx == WINDOW_SIZE); txFrames[idx][0] = FLAG; txFrames[idx][1] = DATA_FRAME; txFrames[idx][2] = txFrameID; txFrames[idx][3] = len; for(i = 0; i < len; ++i) txFrames[idx][i + HEADER_SIZE] = data[i]; end = len + HEADER_SIZE; checksum = calcFletcherChecksum(txFrames[idx], end); txFrames[idx][end] = (byte)(checksum >> 8);

txFrames[idx][end + 1] = (byte)(checksum & 0x00FF); txFrames[idx][end + 2] = FLAG; txFrameReady[idx] = 1; ++txFramesLeft; writeFrame(txFrameID); ++txFrameID; if(ackTimerOn == 0) resetAckTimer(); ++txFramesQueued; } //Transmit a frame. void writeFrame(byte frameID) { byte idx = 0, i, tot; for(; idx < WINDOW_SIZE ; ++idx) if(txFrameReady[idx] && txFrames[idx][2] == frameID) break; //Search for the frame with the required frame ID if(idx == WINDOW_SIZE) return; //No frame found //write header for(i = 0; i < HEADER_SIZE; ++i) writeByte(txFrames[idx][i]); //write data with escaping tot = HEADER_SIZE + txFrames[idx][3]; for(; i < tot; ++i) { if(txFrames[idx][i] == ESC || txFrames[idx][i] == FLAG) { writeByte(ESC); writeByte(~txFrames[idx][i]); } else { writeByte(txFrames[idx][i]); } } tot += TRAILER_SIZE; for(; i < tot; ++i) writeByte(txFrames[idx][i]); ++txFramesSent; } //Process a received ACK frame void procAckFrame() { byte ackID = rxFrame[2]; while(ackID != txFrameIDStart) { removeFrame(txFrameIDStart); if(txFrameIDStart == txFrameID) ++txFrameID; ++txFrameIDStart; } resetAckTimer(); }

//Calculates the Fletcher checksum. See wiki article uint calcFletcherChecksum(const byte *buf, byte len) { uint a, b; byte i; a = b = 0; for(i = 0; i < len; ++i) { a += buf[i]; if(a >= FLETCHER_MOD) a -= FLETCHER_MOD; b += a; if(b >= FLETCHER_MOD) b -= FLETCHER_MOD; } return ((b << 8) | a); } //Waits till a data frame is received succesfully and copies it to buf byte getData(byte *buf) { byte len, i; while(!rxFrameReady); len = rxFrame[3]; for(i = 0; i < len; ++i) buf[i] = rxFrame[i + HEADER_SIZE]; rxReset(); return len; } //--> Disable IO timer when processing? //Process rx. This is a state machine which process received buffer partially if required. void rxProc() { byte cur, end; if(rxBufferLen == 0) return; //Return if no data waiting if(rxFrameReady) return; //Last frame not processed //Go forward till start flag while(rxFrameIdx == 0 && rxBufferLen >= 1) { cur = readByte(); if(cur == FLAG) { rxFrame[rxFrameIdx] = cur; ++rxFrameIdx; break; } }

//Rest of header while(rxFrameIdx >= 1 && rxFrameIdx < HEADER_SIZE && rxBufferLen >= 1) { cur = readByte(); //Check for out of sync flag byte if(rxFrameIdx == 1 && cur == FLAG) continue; //Check for frame length if(rxFrameIdx == 3 && cur > DATA_SIZE) { //Invalid data length, so drop the frame rxReset(); return; } rxFrame[rxFrameIdx] = cur; rxFrameIdx++; } if(rxFrameIdx < HEADER_SIZE) return; end = HEADER_SIZE + rxFrame[3]; //Data payload while(rxFrameIdx < end && rxBufferLen >= 2) { cur = readByte(); if(cur == ESC) { cur = ~readByte(); } else if(cur == FLAG) { //a FLAG byte without ESC byte. So treat it as end of frame error rxReset(); return; } rxFrame[rxFrameIdx] = cur; rxFrameIdx++; } end += TRAILER_SIZE; //Trailer while(rxFrameIdx >= HEADER_SIZE + rxFrame[3] && rxFrameIdx < end && rxBufferLen >= 1) { cur = readByte(); rxFrame[rxFrameIdx] = cur; ++rxFrameIdx; } if(rxFrameIdx == end) { ++rxFramesReceived; if(!verifyFrame()) { //Error in frame ++rxFrameErrors; rxReset();

return; } if(rxFrame[1] == ACK_FRAME) { procAckFrame(); rxReset(); return; } //Check if it is the correct frame ID if(rxFrameID != rxFrame[2]) { sendAckFrame(rxFrameID); rxReset(); return; } //Correct data frame received rxFrameReady = 1; ++rxFrameID; sendAckFrame(rxFrameID); } } //Resets the rx statuses void rxReset() { rxFrameReady = 0; rxFrameIdx = 0; } //Check for various error condition byte verifyFrame() { byte end = HEADER_SIZE + TRAILER_SIZE + rxFrame[3]; uint rxChecksum = ((((uint)rxFrame[end - 3]) << 8) | rxFrame[end 2]), checksum; if(rxFrame[end - 1] != FLAG) return 0; if(rxFrame[1] != ACK_FRAME && rxFrame[1] != DATA_FRAME) return 0; if(rxFrame[1] == ACK_FRAME && rxFrame[3] > 0) return 0; checksum = calcFletcherChecksum(rxFrame, end - 3); if(checksum != rxChecksum) return 0; return 1; }

//Send an ACK frame void sendAckFrame(byte frameID) { byte frame[4], i; uint checksum; frame[0] = FLAG; frame[1] = ACK_FRAME; frame[2] = frameID; frame[3] = 0; checksum = calcFletcherChecksum(frame, 4); for(i = 0; i < 4; ++i) writeByte(frame[i]); writeByte((byte)(checksum >> 8)); writeByte((byte)(checksum & 0xFF)); writeByte(FLAG); } //An ACK timeout has occurred, so retransmit all the frames in queue void ackTimeout() { byte i = txFrameIDStart; for(; i != txFrameID; ++i) writeFrame(i); resetAckTimer(); } //Resets the ack timer void resetAckTimer() { ackTimerOn = 1; ackTimerCount = 0; } //Remove the given frame void removeFrame(byte frameID) { byte idx; //Search for specified frame for(idx = 0; idx < WINDOW_SIZE; ++idx) if(txFrameReady[idx] == 1 && txFrames[idx][2] == frameID) break; if(idx == WINDOW_SIZE) return; txFrameReady[idx] = 0; //Mark slot as free --txFramesLeft; } //Read a byte from the rx buffer //Returns undefined data if there is no byte in rx buffer. This prevents infinte wait. byte readByte() {

byte ret = 0x99; if(rxBufferLen != 0) { //Disable rx interrupt while reading to avoid simultaneous access DISABLE(RX_INT); ret = rxBuffer[rxBufferStart]; rxBufferStart = (rxBufferStart + 1) % RX_BUFFER_SIZE; --rxBufferLen; ENABLE(RX_INT); } return ret; } //Write a byte to the tx buffer void writeByte(byte b) { if(txBufferLen == TX_BUFFER_SIZE) { //Wait if buffer is full ENABLE(TX_INT); while(txBufferLen == TX_BUFFER_SIZE); } DISABLE(TX_INT); txBuffer[txBufferEnd] = b; txBufferEnd = (txBufferEnd + 1) % TX_BUFFER_SIZE; ++txBufferLen; ENABLE(TX_INT); } /*INTERRUPT */ #pragma interrupt High_ISR void High_ISR() { static unsigned int counter = 0; if(INTCONbits.TMR0IF) { INTCONbits.TMR0IF = 0; // Clear the Timer1 interrupt flag. If you forget this, you get back-to-back interrupts. //PWM0 = (PWM_DC[0] > counter ? 1 : 0); if(counter < PWM200) { if(counter == PWM_DC[0]) PWM0 = 0; if(counter == PWM_DC[1]) PWM1 = 0; } if(counter == PWM_DC[2]) PWM2 = 0; if(++counter == MX_TIME) { counter = 0; PWM0 = PWM1 = PWM2 = 1; } }

if(RX_INT && PIR1bits.RCIF) { if(RCSTAbits.OERR) { //required to clear the overrun error flag ++rxByteErrors; RCSTAbits.CREN = 0; RCSTAbits.CREN = 1; } if(rxBufferLen == RX_BUFFER_SIZE) {+ +rxBytesDropped; return;} //Drop byte if no buffer space. Drop will be handled by higher layer. if(RCSTAbits.FERR) ++rxByteErrors; ++rxBytesReceived; rxBuffer[rxBufferEnd] = RCREG; //Ignore any framing and overrun errors. It will be handled by the higher layer. if(++rxBufferEnd == RX_BUFFER_SIZE) rxBufferEnd = 0; ++rxBufferLen; } } #pragma interruptlow Low_ISR void Low_ISR(void) { if(TX_INT && PIR1bits.TXIF) { //tx interrupt if(txBufferLen == 0) { //No data to transmit. So disable tx interrupt. DISABLE(TX_INT); return; } ++txBytesSent; TXREG = txBuffer[txBufferStart]; if(++txBufferStart == TX_BUFFER_SIZE) txBufferStart = 0; --txBufferLen; } if(PIR2bits.TMR3IF) { rxProc(); if(ackTimerOn && txBufferLen == 0) { ++ackTimerCount; if(ackTimerCount == ACK_TIMEOUT) ackTimeout(); } TMR3H = 0; TMR3L = 0; PIR2bits.TMR3IF = 0;

if(statusSendFlag == 0 && ++statusSendCount == STATUS_SEND_THRESHOLD) { statusSendFlag = 1; statusSendCount = 0; } } }

Wireless Data Acquisition System


Vaibhav D Mehta, Rucha H Gajare, Minali P Jadhav
Department of Electronics and Telecommunication, Pillais Institute of Information Technology, Engineering, Media Studies and Research, India
Emails: vabs93@gmail.com, ruchagajare@gmail.com, minali.jadhav@gmail.com

Abstract - This paper introduces the wireless data acquisition system. Demand for data acquisition systems is increasing due to increasing industrialization with a need of producing the final product faster. All they need is a real time operating data acquisition system to collect the data from a huge area. It becomes quite difficult to create a network for collecting this data and feed them in automation system like PLC etc. The best way of creating such a network is using wireless technique. This can be done by setting up a Wi-Fi network and sharing the data over this network. This paper analyzes the implementation of such a network.
Keywords DAS, Data Acquisition, Wireless DAS, Wi Fi Data acquisition, Data analysing, Microcontroller based data acquisition

I. INTRODUCTION In industry with having huge span, agricultural area, security system and other practical application process, it often needs to test the site equipments, video of particular area with audio and environmental. If the area is huge from where data is to be collected, then the best way of communication is wireless. The cheapest and effective way of wireless communication is through Wi-Fi. We just need to collect the data and share it over network. This can be done by collecting data through microcontroller and save that data in personal computer. Further on connecting that personal computer to Wi-Fi we can share the recorded data. There are some free utilities such as opera through which its possible to share data over Internet. Not only sharing,

but even we can control the equipments by remote desktop the particular computer. The standard data acquisition system (DAS) contains three elements, acquisition hardware, storage unit and data transmission method. Acquisition hardware plays a key role in the system which decides the performance of DAS. Most of the research is using personal computer as acquisition hardware [1, 2]. Further on with new technique the standard personal computer to high speed personal computer for better performance of data processing and transferring to storage unit. But the microcontroller based DAS is more popular platform since its low in cost and suitable for simple and small application [3]. For cheap system we can use notebook PC which saves lots of cost for storing and data transmission and sharing in Wi-Fi [4]. Now days there are no serial ports in notebooks or laptops. Instead of that there are USB ports. Also data transmission speed is more as compared with serial ports. So to collect the data form acquisition hardware and store it in notebooks, the communication between them can only be done by USB. So we should use the Microcontroller which has USB communication or else serial to USB converter should be used. But for higher data transmission direct USB connection is preferred. Considering the microcontroller with USB communication available in market at a cheaper rate for basic requirement is from the Microchip which is PIC18F4550. Its cost is approximate 350 INR. It has 35 I/O ports, 13 internal ADC converter ports with resolution of 10 bits and lots of other features. If more ports are require then the PICs can be cascaded in master and slave configuration to work

1|Page

[Type text]

together. From this microcontroller data at the ports can be stored in memory card and can also be stored in net book for further operation [5]. We will see further, W-DAS are discussed in seven sections. Section II consists of overall structure. Section III explains the processor board. Section IV and V explains the software development and data transmission. Section VI shows the result and Section VII summarizes the overall research output II. OVERALL STRUCTURE The wireless data acquisition system using PIC18F4550 is outlined in Figure 1. The processor board collects status of various

technique can also be used for controlling the devises. This can be done with remote desktop or creating software through which PC to PC communication can be done. III. PROCESSOR BOARD Processor board consists of PIC18F4550 microcontroller which is manufactured by

microchip. This microcontroller has great advantages which suites for data logging and also requires very less components. Fig 2. Due to this the overall processor board is quite simple, ease to maintain and cheap. The basic structure of processor board is shown below. As per requirement it can be easily modified. In total PIC18F4550 has 35 Programmable I/O Lines including 10-bit 13-channel ADC. The microcontroller PIC18F4550 provides Boot uploading features. When boot upload is loaded ones in microcontroller, then we can program microcontroller directly through USB communication without removing controller from the circuit. Total power consumption is very less with long life. In certain case where we require more ports and have to process more data, we can use two microcontrollers in master slave

sensors and updates all measurements and sends that data to host PC with USB communication. Fig 1. PC logs this data and stores it with time and date. PCs in the network communicate with host PC through Wi-Fi. Data log on host PC is shared using file transfer protocol (FTP), opera unit and web hosting. For real time viewing the data log on internet, PHP web page hosting can be done. The work of collecting data, monitoring and processing is done by host PC. With data acquisition, this

2|Page

[Type text]

configuration. The total cost of the processor board is approx 450INR.

IV. SOFTWARE DEVELOPMENT From programming point of view, the software designing is divided in 3 parts. One is for the microcontroller, second is for the host pc to acquise the data in to PC and third is creating server for web page sharing for sharing data. A. Programming for microcontroller The programming for microcontroller PIC18F4550 is done by using programming language C return in MPLAB. The program in PIC microcontroller contains the code to read the data from all the defined port and log the data in PC. The communication with PC is done by using USB port. All the communication is done with handshake principal so maintain the reliability of data. PIC 18F4550 consists of 35 programmable I/O including 13 ADC ports. Whenever data is in digital form it can be directly reader with microcontroller. When data is in analog form it is converted into digital by ADC converter which is internally build up. This ADC converter converts analog data at the input into digital data I microcontroller. B. Program for PC For host PC the program is written using C#. The work of this program is to check the communication between PIC. The flowchart of the system is shown in Fig 3. After verifying the communication, it decodes the data coming from the PIC. According to data it logs it with date and time. This data is further used for generating the graph, calculation, setting alarm etc. This software is remotely viewed by other PCs in the network. While viewing they can also change the parameters reprogram the microcontroller set the limit for alarm etc.

C. Web page platform The collected data is represented with graph format and log table on a web page. Therefore user can view the current and previous data through internet. The page is developed using PHP and MySQL database use to store all data. In current mode, the graph is fixed to several date parameters which are today, yesterday,

previous 7 days and monthly. While in selection mode, the graph is generate regarding to date parameters given by user. Fig 3. V. DATA TRANSMISSION Data from microcontroller is send to PC continuously. The data is sent in string format to the PC for every sensors reading. The connection status is always recorded by the host PC process in a status file. If the communication between microcontroller and PC is broken, the data will be stored in a

3|Page

[Type text]

data-log file in microcontroller up to a limit. When communication is established, the controller sends the stored data and makes its buffer empty. A. Wireless networking There are a lot of wireless protocols in current technology such as radio frequency (RF), infra red (Ir), Bluetooth, wireless LAN (WLAN) and Zigbee. The WLAN can be divided to three categories which are 802.11a, 802.11b and 802.11g which differ in term of transfer rate. Table 1 outlines the summary of wireless technologies [6]. TABLE 1: TRANSFER RATE OF WIRELESS TECHNOLOGIES Technology Transfer rate Spike 75.06 / 35.88 kbps Zigbee 250 kbps Bluetooth 768 kbps Nanonet 2 000 kbps WLAN, IEEE 802.11b 11 000 kbps WLAN, IEEE 802.11g 22 000 kbps WLAN, IEEE 802.11 a 54 000 kbps In this research, the transmission of collected data is one using 802.11b wireless network technology. TS- 5500 uses 16-bit PCMCIA model MA401 Wi-Fi PC card from NetGear Company. The operating range of this model is up to 500 feet indoors and 1650 feet outdoors. The closed area is chosen for this research at this moment [7]. VI. RESULT Microchip PIC 18F4550 was selected for the ease of direct communication with computers. Now days there are no serial ports in PCs or laptop. Instead of that there are USB ports. Since microchip PIC18F4550 has USB connection for communication it is used instead of other microchip and serial to USB converter. It is available at cheaper rate. Besides cost, other advantage is that for

higher data transmission direct USB connection is preferred. Total power consumption is less which would ultimately lead to longer battery runtime on the system. For data log sharing, WI-FI connection is used since it is cheaper. For real time viewing, PHP can be used. PHP is selected because it can run on different platforms like Windows, Linux, Unix. It also compatible with almost all servers used today, it easy to learn and runs efficiently on server side. VII. CONCLUSION A data acquisition system is indeed a very powerful tool for research. Wireless based solutions have universally accepted, familiar and user friendly system. Portability is required for research tasks whose characteristics require them to be performed on location. Researchers will now be able to remotely monitor the progress of their study. Wireless connectivity also allows access to acquired data from any place with a connection to the World Wide Web. We can observe and modify the data remotely. It can be developed further with more features.

VII.REFERENCE [1] I. Korotaev, The PC based Control and Data Acquisition System of LEPTA, International Conference on Accelerometer and Large Experimental Physics Control Systems, Trieste, Italy, 1999, pp. 648-650. [2] Mooney, D. M. et al., A PC-Controlled Data Acquisition System for Transabdominal Recording of Cardiac Activity in the Human Fetus. ACM Symposium on Applied Computing, 1993, pp. 622-626.

4|Page

[Type text]

[3] M. Popa, M. Marcu, and A.S. Popa, A Microcontroller based Data Acquisition System with USB Interface, International Conference on Electrical, Electronic and Computer Engineering (ICEEC 04), Cairo, Egypt, 2004, pp. 206-208. [4] Laymon, C. M., Miyaoka, R. S., Park, B. K., Lewellen, T. K.., Simplified FPGA-based Data Acquisition System for PET. IEEE Transaction on Nuclear Science, Volume 50, Issue 5, 2003, pp. 1483-1486. [5]Web-Based Wireless Data Acquisition System using 32bit Single Board Computer IEEE paper May 13-15, 2008 Kuala Lumpur, Malaysia. [6] Sakari Junilla and Jarkko Niittylahti, Wireless Technologies for Data Acquisition Systems, Proceedings of the 1st International Symposium on Information and Communication Technologies. Dublin, Ireland, 2003, pp. 132137. [7] Ding Yonghong, SunYunJiang.Wireless data transmission system design based on nRF2401.[J]. Foreign electronic measurement technology, 2008 (4) : pp.45-47.

5|Page

Das könnte Ihnen auch gefallen