Cell phone controlled robot for gas detection

Published on June 2016 | Categories: Documents | Downloads: 36 | Comments: 0 | Views: 236
of 93
Download PDF   Embed   Report

A robot is controlled remotely to detect gases.

Comments

Content

TABLE OF CONTENTS CHAPTER 1 ...............................................................................5 INTRODUCTION ......................................................................5
1.1 GENERAL INTRODUCTION:.............................................................................. 5 AIM: .................................................................................................................. 5 1.1.1 1.2

INTRODUCTION TO EMBEDDED SYSTEMS: .................................................... 5

1.2.1 CHARACTERISTICS: ............................................................................................. 6 1.2.2 PLATFORM: ............................................................................................................ 7 1.2.3 TOOLS:..................................................................................................................... 7 1.2.4 OPERATING SYSTEM: .......................................................................................... 7 1.2.5 DEBUGGING: .......................................................................................................... 7 1.2.6 DESIGN OF EMBEDDED SYSTEMS:................................................................... 8 1.3 INTRODUCTION TO ROBOTICS: ........................................................................... 8 1.3.1 HISTORY OF REMOTE CONTROLLED VEHICLES:................................... 9 1.4 TECHNOLOGY USED: ....................................................................................... 11

CHAPTER 2 .............................................................................15 DESIGN OF THE PROJECT .................................................15
2.1 INTRODUCTION: ...................................................................................................... 15 2.2 BLOCK DIAGRAM: ................................................................................................... 15 2.2.1 BLOCK DIAGRAM DESCRIPTION:............................................................................ 16 2.3 CIRCUIT DESCRIPTION: .................................................................................................. 18 2.3.1 CIRCUIT FOR RETRIEVING INFORMATION: ........................................................... 18 2.3.2 CIRCUIT CONTROLLING ROBOT USING DTMF: ................................. 19

2.3.3 CIRCUIT SENDING INFORMATION TO THE USER: ................................ 20 2.4 CONCLUSION: ........................................................................................................... 20

CHAPTER 3 .............................................................................21 HARDWARE DESCRIPTION ...............................................21
3.1 INTRODUCTION: ...................................................................................................... 21 3.2 PIC16F877A: ................................................................................................................. 21 3.2.1 Peripheral Interface Controller (PIC):..................................................................... 21 3.2.2General Features ...................................................................................................... 22 3.2.3 Peripheral Features .............................................................................................. 23 1

3.2.4 Key Features .......................................................................................................... 23 3.2.5 Analogue Features: ............................................................................................... 24 3.2.6 Special Features .................................................................................................... 24 3.2.7 Central Processing Unit (CPU) ............................................................................... 24 3.2.8 Memory Organization of PIC16F877 ..................................................................... 25 3.2.9 Program memory .................................................................................................... 25 3.2.10 Data Memory ........................................................................................................ 26 3.2.11 Data EEPROM and FLASH ................................................................................. 27 3.2.12 Input/output Ports.................................................................................................. 27 3.2.13 Port A & TRIS A Register .................................................................................... 28 3.2.14 Port B & TRIS Register ........................................................................................ 29 3.2.15 Port C & TRIS C Register .................................................................................... 30 3.2.16 Port D & TRIS D Register .................................................................................... 31 3.2.17 Port E & TRIS E Register ..................................................................................... 31 3.2.18 USART ................................................................................................................. 31 3.2.19 Pin Diagram of PIC 16F877A............................................................................... 33 3.2.20 Master Clear .......................................................................................................... 33 3.2.21 Limitations of PIC Architecture:........................................................................... 34 3.2.22Advantages of PIC Controlled System: ................................................................. 35 Microchip PIC16F877A Microcontroller Features .............................................................. 36 High-Performance RISC CPU ......................................................................................... 36 Special Microcontroller Features ..................................................................................... 36 Peripheral Features........................................................................................................... 36 Analog Features ............................................................................................................... 37 3.3 LM35: ............................................................................................................................ 38 3.3.1 Features: .................................................................................................................. 40 3.3.2 Applications: ........................................................................................................... 40 3.4 CNG SENSOR: ............................................................................................................ 42 3.4.1 Pin Description: ...................................................................................................... 43 3.4.2 Applications: ........................................................................................................... 43 3.4.3 Features: .................................................................................................................. 43 3.4.4 Specifications: ......................................................................................................... 44 3.4.5 Deriving Gas concentration from Output Voltage: ................................................. 44 3.4.6 Sensitivity: .............................................................................................................. 45 2

3.5 LCD (Liquid Crystal Display) ....................................................................................... 46 3.5.1 General Description: ............................................................................................... 46 3.5.2 LCD diagram: ......................................................................................................... 48 3.5.3 Hardware connections:............................................................................................ 49 3.5.4 FLOWCHART:....................................................................................................... 50 3.5.5 LCD COMMANDS: ............................................................................................. 52 3.6 DTMF DECODER CM8870: ........................................................................................ 53 3.6.1 Features: .................................................................................................................. 55 3.6.2 Applications: ........................................................................................................... 55 3.7 L293D MOTOR DRIVER: ............................................................................................ 56 3.8 GSM MODEM: ................................................................................................................ 58 3.8.1 GSM: ....................................................................................................................... 58 3.8.2 SERVICES PROVIDED BY GSM: ....................................................................... 59 3.8.3 GSM SECURITY: .................................................................................................. 60 3.8.4 ADVANTAGES OF GSM: .................................................................................... 61 3.8.5 USES OF GSM: ...................................................................................................... 62 3.9 SMPS: ............................................................................................................................. 63 3.9.1 BLOCK DIAGRAM: ................................................................................................... 64 3.10 DC MOTOR: .................................................................................................................. 65

CHAPTER 4 .............................................................................66 TESTING OF THE PROJECT ..............................................66
4.1 INTRODUCTION: ........................................................................................................ 66 4.2 Interfacing GSM module and microcontroller: ............................................................ 68 4.3 Interfacing DTMF decoder and the mobile phone: ...................................................... 69 4.4 Flow chart ...................................................................................................................... 71 4.5 CONCLUSION: ............................................................................................................. 71

CHAPTER 5 .............................................................................72 SOFWARE DISCRIPTION ....................................................72
5.1 INTRODUCTION: ........................................................................................................ 72 5.2 PIC C Compiler: ............................................................................................................ 72 5.2.1 Features : ................................................................................................................. 72 5.2.2 Advantages of using embedded C:.......................................................................... 73 5.3 AT-commands: .............................................................................................................. 74 3

5.3.1 The AT command format:....................................................................................... 74 5.3.2 Using AT Commands: ............................................................................................ 74 5.3 MICRO CONTROLLER CODE: .................................................................................. 83

CHAPTER 6 .............................................................................86 RESULTS ..................................................................................86
6.1 RESULTS: ..................................................................................................................... 86

CHAPTER 7 .............................................................................88 CONCLUSION .........................................................................88 CHAPTER 8 .............................................................................89 FUTURE SCOPE .....................................................................89 Bibliography..............................................................................90 APPENDIX ...............................................................................91

4

CHAPTER 1 INTRODUCTION
1.1 GENERAL INTRODUCTION: 1.1.1 AIM:
The main aim of the project is to retrieve information from a remote area where human intervention is not possible using a robot or Remote controlled vehicle which is controlled using DTMF technology.

1.2 INTRODUCTION TO EMBEDDED SYSTEMS:
Embedded systems often use peripherals controlled by synchronous serial interfaces, which are ten to hundreds of times slower than comparable peripherals used in PCs. Programs on an embedded system often run with real-time constraints with limited hardware resources: often there is no disk drive, operating system, keyboard or screen. Embedded systems are electronic devices that incorporate microprocessors with in their implementations. The main purposes of the microprocessors are to simplify the system design and provide flexibility. Having a microprocessor in the device helps in removing the bugs, making modifications, or adding new features are only matter of rewriting the software that controls the device. Or in other words embedded computer systems are electronic systems that include a microcomputer to perform a specific dedicated application. The computer is hidden inside these products. Embedded systems are ubiquitous. Every week millions of tiny computer chips come pouring out of factories finding their way into our everyday products.

Embedded systems are self-contained programs that are embedded within a piece of hardware. Whereas a regular computer has many different applications and software that can be applied to various tasks, embedded systems are usually set to a specific task that cannot be altered without physically manipulating
5

the circuitry. Another way to think of an embeddedsystem is as a computer system that is created with optimal efficiency, thereby allowing it to complete specific functions as quickly as possible.

Embedded systems designers usually have a significant grasp of hardware technologies. They use specific programming languages and software to develop embedded systems and manipulate the equipment. When searching online, companies offer embedded systems development kits and other embedded systems tools for use by engineers and businesses.

Embedded systems technologies are usually fairly expensive due to the necessary development time and built in efficiencies, but they are also highly valued in specific industries. Smaller businesses may wish to hire a consultant to determine what sort of embedded systems will add value to their organization.

1.2.1 CHARACTERISTICS:

Two major areas of differences are cost and power consumption. Since many embedded systems are produced in tens of thousands to millions of units range, reducing cost is a major concern. Embedded systems often use a (relatively) slow processor and small memory size to minimize costs.

The slowness is not just clock speed. The whole architecture of the computer is often intentionally simplified to lower costs. For example, A flash drive may replace rotating media, and a small keypad and LCD screen may be used instead of a PC's keyboard and screen.

Firmware is the name for software that is embedded in hardware devices, e.g. in one or more ROM/Flash memory IC chips. Embedded systems are routinely expected to maintain 100% reliability while running
6

continuously for long periods, sometimes measured in years. Firmware is usually developed and tested too much harsher requirements than is general-purpose software, which can usually be easily restarted if a problem occurs. 1.2.2 PLATFORM:

There are many different CPU architectures used in embedded designs. This in contrast to the desktop computer market which is limited to just a few competing architectures mainly the Intel/AMD x86 and the Apple/Motorola/IBM Power PC‘s which are used in the Apple Macintosh. One common configuration for embedded systems is the system on a chip, an application-specific integrated circuit, for which the CPU was purchased as intellectual property to add to the IC's design. 1.2.3 TOOLS:

Like a typical computer programmer, embedded system designers use compilers, assemblers and debuggers to develop an embedded system. Those software tools can come from several sources:

1.2.4 OPERATING SYSTEM:

They often have no operating system, or a specialized embedded operating system (often a real-time operating system), or the programmer is assigned to port one of these to the new system.

1.2.5 DEBUGGING:

Debugging is usually performed with an in-circuit emulator, or some type of debugger that can interrupt the micro controller‘s internal microcode. The microcode interrupt lets the debugger operate in hardware in which only the CPU works. The CPU-based debugger can be used to test and debug the electronics of the computer from the viewpoint of the CPU.
7

1.2.6 DESIGN OF EMBEDDED SYSTEMS:

The electronics usually uses either a microprocessor or a microcontroller. Some large or old systems use general-purpose mainframes computers or minicomputers.

All embedded systems have start-up code. Usually it disables interrupts, sets up the electronics, tests the computer (RAM, CPU and software), and then starts the application code. Many embedded systems recover from short-term power failures by restarting (without recent self-tests). Restart times under a tenth of a second are common. Many designers have found one of more hardware plus software-controlled LED‘s useful to indicate errors during development (and in some instances, after product release, to produce troubleshooting diagnostics). A common scheme is to have the electronics turn off the LED(s) at reset, whereupon the software turns it on at the first opportunity, to prove that the hardware and start-up software have performed their job so far. After that, the software blinks the LED(s) or sets up light patterns during normal operation, to indicate program execution progress and/or errors. This serves to reassure most technicians/engineers and some users.

1.3 INTRODUCTION TO ROBOTICS:
Radio control (often abbreviated to R/C or simply RC) is the use of radio signals to remotely control a device. The term is used frequently to refer to the control of model vehicles from a hand-held radio transmitter. Industrial, military, and scientific research organizations make [traffic]use of radio-controlled vehicles as well. A remote control vehicle is defined as any mobile device that is controlled by a means that does not restrict its motion with an origin external to the device. This is often a radio control device, cable between control and vehicle, or an infrared controller. A remote control vehicle (Also called as RCV)

8

differs from a robot in that the RCV is always controlled by a human and takes no positive action autonomously. One of the key technologies which underpin this field is that of remote vehicle control. It is vital that a vehicle should be capable of proceeding accurately to a target area manoeuvring within that area to fulfil its mission and returning equally accurately and safely to base. Recently, Sony Ericsson released a remote control car that could be controlled by any Bluetooth cell phone. Radio is the most popular because it does not require the vehicle to be limited by the length of the cable or in a direct line of sight with the controller (as with the infrared set-up). Bluetooth is still too expensive and short range to be commercially viable.

1.3.1 HISTORY OF REMOTE CONTROLLED VEHICLES:

The First Remote Control Vehicle:

This propeller-driven radio controlled boat, built by Nikola Tesla in 1898, is the original prototype of all modern-day uninhabited aerial vehicles and precision guided weapons. In fact , all remotely operated vehicles in air, land or sea. Powered by lead-acid batteries and an electric drive motor, the vessel was designed to be maneuverer alongside a target using instructions received from a wireless remote control transmitter. Once in position, a command would be sent to detonate an explosive charge contained within the boat's forward compartment. The weapon's guidance system incorporated a secure

communications link between the pilot's controller and the surface-running torpedo in an effort to assure that control could be maintained even in the presence of electronic countermeasures. To learn more about Tesla's system for secure wireless communications and his pioneering implementation of the electronic logic-gate circuit read ‗Nikola Tesla — Guided Weapons & Computer Technology‘, Tesla Presents Series Part 3, with commentary by Leland Anderson.

Use of Remote Controlled Vehicles During World War II :

9

During World War II in the European Theatre the U.S. Air Force experimented with three basic forms radio control guided weapons. In each case, the weapon would be directed to its target by a crew member on a control plane. The first weapon was essentially a standard bomb fitted with steering controls. The next evolution involved the fitting of a bomb to a glider airframe, one version, the GB-4 having a TV camera to assist the controller with targeting. The third class of guided weapon was the remote controlled B-17.It's known that Germany deployed a number of more advanced guided strike weapons that saw combat before either the V-1 or V-2. They were the radio-controlled Henschel'sHs 293A and Ruhrstahl's SD1400X, known as "Fritz X," both airlaunched, primarily against ships at sea.

10

1.4TECHNOLOGY USED:

Dual-Tone Multi-Frequency (DTMF): Dual-tone multi-frequency (DTMF) signalling issued for telecommunication signalling over analogy telephone lines in the voice-frequency band between telephone handsets and other communications devices and the switching centre.

The version of DTMF used for telephone tone dealing is known by the trademarked term Touch-Tone (cancelled March 13,1984), and is standardized by ITU-T Recommendation Q.23. It is also known in the UK as MF4. Other multi-frequency systems are used for signalling internal to the telephone network . As a method of in-band signalling, DTMF tones were also used by cable television broadcasters to indicate the start and stop times of local commercial insertion points during station breaks for the benefit of cable companies. Until better out-of-band signalling equipment was developed in the1990s, fast, unacknowledged, and loud DTMF tone sequences could be heard during the commercial breaks of cable channels in the United States and elsewhere.

Telephone Keypad:

The contemporary keypad is laid out in a 3×4grid, although the original DTMF keypad had an additional column for four now-defunct menu selector keys. When used to dial a telephone number, pressing a single key will produce a pitch consisting of two simultaneous pure tone sinusoidal frequencies. The row in which the key appears determines the low frequency, and the column determines the high frequency. For example, pressing the '1' key will result in a sound composed of both a 697 and a 1209 hertz (Hz) tone. The original keypads had levers inside, so each button activated two contacts. The multiple tones are

11

the reason for calling the system multi frequency. These tones are then decoded by the switching centre to determine which key was pressed.

Fig 1.4.1: A DTMF TELEPHONE KEYPAD

12

Table 1.4.1 DTMF Keypad Frequencies (With Sound Clips)

697 Hz 770 Hz 852 Hz 941 Hz

1209 Hz 1 4 7 *

1336 Hz 2 5 8 0

1477 Hz 3 6 9 #

1633 Hz A B C D

Table 1.4.2 DTMF Event Frequencies Event Busy Signal Dial Tone Ringback Tone(US) Low Freq. High Freq.

480 Hz
350 Hz 440 Hz

620 Hz 440 Hz 480 Hz

13

Tones #, *, A, B, C, and D:
The engineers had envisioned phones being used to access computers, and surveyed a number of companies to see what they would need for this role. This led to the addition of the number sign (#, sometimes called 'octothorpe' in this context) and asterisk or "star" (*) keys as well as a group of keys for menu selection: A, B, C and D. In the end, the lettered keys were dropped from most phones, and it was many years before these keys became widely used for vertical service codes such as *67 in the United States and Canada to suppress caller ID. The U.S. military also used the letters, relabelled, in their now defunct Auto von phone system. Here they were used before dealing the phone in order to give some calls priority, cutting in over existing calls if need be. The idea was to allow important traffic to get through every time. The levels of priority available were Flash Override (A), Flash (B), Immediate (C), and Priority (D), with Flash Override being the highest priority.

14

CHAPTER 2 DESIGN OF THE PROJECT

2.1 INTRODUCTION:
The following chapter gives a brief explanation about the block diagram of cell phone controlled robot for information retrieving and the circuit diagram descriptions.

2.2 BLOCK DIAGRAM:

Sensors

Controller

GSM Mode m

Cell Phone

DTMF Decoder

Motor Driver LCD

Cell Phone Acting as a remote

Motors

Fig 2.1 BLOCK DIAGRAM

15

2.2.1 BLOCK DIAGRAM DESCRIPTION: Block diagram is classified into 3 main parts 1. Information retrieving 2. Controlling the robot 3. Sending retrieved data to user phone

2.2.1.1 INFORMATION RETRIEVING: The action of sensor is to collect data from the surrounding environment. The sensors used here are temperature and gas sensorsso, these sensors would collect the temperature and gas values from the external world and give the data to microcontroller for further processing. The microcontroller would perform required action on the data and simultaneously send the data to Liquid Crystal Display(LCD) and Global System Monitoring(GSM) module. LCD continuously displays all the values detected by the sensors and through GSM module we can send the values detected by the sensor to the user cell phone.

2.2.1.2 CONTROLLING THE ROBOT: Another cell phone is used and it is connected to Dual Tone Multi Frequency(DTMF) decoder through audio jack. This cell phone is used to transfer the keys that are pressed on the user cell phone to the DTMF decoder. The function of the DTMF decoder is to decode the signal of the key pressed on the keypad into 4-bit binary value and this binary value is given to the motor driver IC. The motor driver IC has four inputs and the 4-bit binary values are given to the four inputs of motor driver IC. A single motor driver IC can drive two motors simultaneously so this IC has four outputs where two motors can be connected. Depending upon the input logic the direction of the motors can be decided. The robot can move into directions depending on which input is on and which input is off.

16

2.2.1.3 SENDING DATA TO THE USER: GSM module is used to send the retrieved data to the user cell phone. Attention Terminal(AT) commands are used to send the data. There are many sub commands under AT commands but we use only send SMS command as in this application we are only sending data to the user cell phone. We are not receiving any data from the user cell phone. GSM module is pre programmed to send the data. This data is written in the microcontroller memory. The GSM module and the microcontroller can be directly interfaced by the Tx, Rx pins as both of them support RS 232 protocol.

17

2.3 CIRCUIT DESCRIPTION:
The circuit of the project is mainly divided into 3 modules. They are:

2.3.1 CIRCUIT FOR RETRIEVING INFORMATION:

Fig 2.2.1 CIRCUIT FOR RETRIEVING INFORMATION

The sensors are connected to the micro controller which are displayed on the LCD. The sensors give the analogue output which are digitalized internally in the micro controller.

18

2.3.2 CIRCUIT CONTROLLING ROBOT USING DTMF:

Fig 2.2.2 CIRCUIT CONTROLLING ROBOT USING DTMF

A DTMF decoder is used to control the robot by giving necessary inputs to the DC Motors.

A cell phone is connected to DTMF decoder through a audio jack. When a key is pressed on the cell phone which is used to call the mobile a frequency is sent to the decoder which is intercepted into output bits.

19

2.3.3 CIRCUIT SENDING INFORMATION TO THE USER:

Fig 2.2.3 CIRCUIT SENDING INFORMATION TO THE USER

The micro controller is programmed in such a way that when the limits that are set for the sensor are broke a message is received by the user from the robot regarding the parameters about every 10 second till they got back to their normal values.

2.4 CONCLUSION:
Block diagram of cell phone controlled robot for information retrieving and its circuitry is discussed.

20

CHAPTER 3 HARDWARE DESCRIPTION
3.1 INTRODUCTION:
This chapter explains about the hardware components that are used in the project such as pic micro controller, L293D motor drivers, DTMF decoders, DC motors, LCD, GSM modem.

3.2 PIC16F877A:
3.2.1 Peripheral Interface Controller (PIC): Peripheral Interface Controllers (PIC) is one of the advanced microcontrollers developed by microchip technologies. These microcontrollers are widely used in modern electronics applications. A PIC controller integrates all type of advanced interfacing ports and memory modules. These controllers are more advanced than normal microcontroller like INTEL 8051. The first PIC chip was announced in 1975 (PIC1650). As like normal microcontroller, the PIC chip also combines a microprocessor unit called CPU and is integrated with various types of memory modules (RAM, ROM, EEPROM, etc), I/O ports, timers/counters, communication ports, etc. PIC 16F877 is one of the most advanced microcontroller from Microchip.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. The figure of a PIC16F877 chip is shown below

Fig 3.1 PIC Microcontroller

21

All PIC microcontroller family uses Harvard architecture. This architecture has the program and data accessed from separate memories so the device has a program memory bus and a data memory bus (more than 8 lines in a normal bus). This improves the bandwidth (data throughput) over traditional von Neumann architecture where program and data are fetched from the same memory (accesses over the same bus). Separating program and data memory further allows instructions to be sized differently than the 8-bit wide data word. The PIC has number of advanced features, the important features of PIC16F877 series is given below.

3.2.2General Features                 

It is a high performance RISC CPU. Only 35 simple word instructions. All single cycle instructions except for program branches which are two cycles. Operating speed: clock input (200MHz), instruction cycle (200nS). Up to 368×8bit of RAM (data memory), 256×8 of EEPROM (data memory), and 8k×14 of flash memory. Pin out compatible to PIC 16C74B, PIC 16C76, PIC 16C77. Eight level deep hardware stack. Interrupt capability (up to 14 sources). Different types of addressing modes (direct, Indirect, relative addressing modes). Power on Reset (POR). Power-Up Timer (PWRT) and oscillator start-up timer. Low power- high speed CMOS flash/EEPROM. Fully static design. Wide operating voltage range (2.0 – 5.56)volts. High sink/source current (25mA). Commercial, industrial and extended temperature ranges. Low power consumption (<0.6mA typical @3v-4MHz, 20µA typical @3v32MHz and <1 A typical standby).
22

3.2.3 Peripheral Features

        

Timer 0: 8 bit timer/counter with pre-scalar. Timer 1:16 bit timer/counter with pre-scalar. Timer 2: 8 bit timer/counter with 8 bit period registers with pre-scalar and post-scalar. Two Capture (16bit/12.5nS), Compare (16 bit/200nS), Pulse Width Modules (10bit). 10bit multi-channel A/D converter Synchronous Serial Port (SSP) with SPI (master code) and I2C (master/slave). Universal Synchronous Asynchronous Receiver Transmitter (USART) with 9 bit addresses detection. Parallel Slave Port (PSP) 8 bit wide with external RD, WR and CS controls (40/46pin). Brown Out circuitry for Brown-Out Reset (BOR).

3.2.4 Key Features

         

Maximum operating frequency is 20MHz. Flash program memory (14 bit words), 8KB. Data memory (bytes) is 368. EEPROM data memory (bytes) is 256. 5 input/output ports. 3 timers. 2 CCP modules. 2 serial communication ports (MSSP, USART). PSP parallel communication port 10bit A/D module (8 channels)

23

3.2.5 Analogue Features:    10-bit, up to 8-channel analogue-to-Digital Converter (A/D) Brown-out Reset (BOR) analogue Comparator module with two analogue comparators, programmable on-chip voltage reference (VREF) module, programmable input multiplexing from device inputs and internal voltage reference & comparator outputs are externally accessible.

3.2.6 Special Features

        

100000 times erase/write cycle enhanced memory. 1000000 times erase/write cycle data EEPROM memory. Self programmable under software control. In-circuit serial programming and in-circuit debugging capability. Single 5V,DC supply for circuit serial programming WDT with its own RC oscillator for reliable operation. Programmable code protection. Power saving sleep modes. Selectable oscillator options.

3.2.7 Central Processing Unit (CPU)

The function of CPU in PIC is same as a normal microcontroller CPU. A PIC CPU consists of several sub units such as instruction decoder, ALU, accumulator, control unit, etc. The CPU in PIC normally supports Reduced Instruction Set Computer (RISC) architecture (Reduced Instruction Set Computer (RISC), a type of microprocessor that focuses on rapid and efficient processing of a relatively small set of instructions. RISC design is based on the premise that most of the instructions a computer decodes and executes are simple. As a result, RISC architecture limits the number of instructions that are built into the

24

microcontroller but optimizes each so it can be carried out very rapidly (usually within a single clock cycle). These RISC structure gives the following advantages.    The RISC structure only has 35 simple instructions as compared to others. The execution time is same for most of the instructions (except very few numbers). The execution time required is very less (5 million instructions/second approximately).

3.2.8 Memory Organization of PIC16F877

The memory of a PIC 16F877 chip is divided into 3 sections. They are  


Program memory Data memory and Data EEPROM

3.2.9 Program memory Program memory contains the programs that are written by the user. The program counter (PC) executes these stored commands one by one. Usually PIC16F877 devices have a 13 bit wide program counter that is capable of addressing 8K×14 bit program memory space. This memory is primarily used for storing the programs that are written (burned) to be used by the PIC. These devices also have 8K*14 bits of flash memory that can be electrically erasable /reprogrammed. Eachtime we write a new program to the controller, we must delete the old one at that time. The program memory map and stack is shown in appendix. Program counters (PC) is used to keep the track of the program execution by holding the address of the current instruction. The counter is automatically incremented to the next instruction during the current instruction execution.

25

The PIC16F87XA family has an 8-level deep x 13-bit wide hardware stack. The stack space is not a part of either program or data space and the stack pointers are not readable or writable. In the PIC microcontrollers, this is a special block of RAM memory used only for this purpose.

3.2.10 Data Memory

The data memory of PIC16F877 is separated into multiple banks which contain the general purpose registers (GPR) and special function registers (SPR). According to the type of the microcontroller, these banks may vary. The PIC16F877 chip only has four banks (BANK 0, BANK 1, BANK 2, and BANK4). Each bank holds 128 bytes of addressable memory. The data memory bank organization is shown in appendix. The banked arrangement is necessary because there are only 7 bits are available in the instruction word for the addressing of a register, which gives only 128 addresses. The selection of the banks are determined by control bits RP1, RP0 in the STATUS registers Together the RP1, RP0 and the specified 7 bits effectively form a 9 bit address. The first 32 locations of Banks 1 and 2, and the first 16 locations of Banks2 and 3 are reserved for the mapping of the Special Function Registers (SFR‘s).

RP1:RP0 00 01 10 11

BANK 0 1 2 3

Table 3.2

26

A bit of RP1 & RP0 of the STATUS register selects the bank access.

3.2.11 Data EEPROM and FLASH
The data EEPROM and Flash program memory is readable and writable during normal operation (over the full VDD range). This memory is not directly mapped in the register file space. Instead, it is indirectly addressed through the Special Function Registers. There are six SFRs used to read and write this memory: • • • • • • EECON1 EECON2 EEDATA EEDATH EEADR EEADRH

The EEPROM data memory allows single-byte read and writes. The Flash program memory allows single-word reads and four-word block writes. Program memory write operations automatically perform an erase-before write on blocks of four words. A byte write in data EEPROM memory automatically erases the location and writes the new data (erase-before-write). The write time is controlled by an onchip timer. The write/erase voltages are generated by an on-chip charge pump, rated to operate over the voltage range of the device for byte or word operations.

3.2.12 Input/output Ports

PIC16F877 has 5 basic input/output ports. They are usually denoted by PORT A (R A), PORT B (RB), PORT C (RC), PORT D (RD), and PORT E (RE). These ports are used for input/ output interfacing. In this controller, ―PORT A‖ is only 6 bits wide (RA-0 to RA-7), ‖PORT B‖ , ―PORT C‖,‖PORT D‖ are only 8 bits wide (RB-0 to RB-7,RC-0 to RC-7,RD-0 to RD-7), ‖PORT E‖ has only 3 bit wide (RE-0 to RE-7).

27

PORT-A PORT-B PORT-C PORT-D PORT-E

RA0 to RA5 RB-0 to RB-7 RC-0 to RC-7 RD-0 to RD-7 RE-0 to RE-2

6 bit wide 8 bit wide 8 bit wide 8 bit wide 3 bit wide

Table 3.2

All these ports are bi-directional. The direction of the port is controlled by using TRIS(X) registers (TRIS A used to set the direction of PORT-A, TRIS B used to set the direction for PORT-B, etc.). Setting a TRIS(X) bit ‗1‘ will set the corresponding PORT(X) bit as input. Clearing a TRIS(X) bit ‗0‘ will set the corresponding PORT(X) bit as output. (If we want to set PORT A as an input, just set TRIS(A) bit to logical ‗1‘ and want to set PORT B as an output, just set the PORT B bits to logical ‗0‘.)

3.2.13 Port A & TRIS A Register

PORTA is a 6-bit wide, bidirectional port. The corresponding data direction register is TRISA. Setting a TRISA bit (= 1) will make the corresponding PORTA pin an input (i.e., put the corresponding output driver in a High- Impedance mode). Clearing a TRISA bit (= 0) will make the corresponding PORTA pin an output (i.e., put the contents of the output latch on the selected pin). Reading the PORTA register reads the status of the pins, whereas writing to it will write to the port latch. All write operations are read-modify-write operations. Therefore, a write to a port
28

implies that the port pins are read, the value is modified and then written to the port data latch. Pin RA4 is multiplexed with the Timer0 module clock input to become the RA4/T0CKI pin. The RA4/T0CKI pin is a Schmitt Trigger input and an open-drain output. All other PORTA pins have TTL input levels and full CMOS output drivers. Other PORTA pins are multiplexed with analog inputs and the analog VREF input for both the A/D converters and the comparators. The operation of each pin is selected by clearing/setting the appropriate control bits in the ADCON1 and/or CMCON registers.

The TRISA register controls the direction of the port 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.

3.2.14 Port B & TRIS Register

PORTB is an 8-bit wide, bidirectional port. The corresponding data direction register is TRISB. Setting a TRISB bit (= 1) will make the corresponding PORTB pin an input (i.e., put the corresponding output driver in a High-Impedance mode). Clearing a TRISB bit (= 0) will make the corresponding PORTB pin an output (i.e., put the contents of the output latch on the selected pin). Three pins of PORTB are multiplexed with the In-Circuit Debugger and Low-Voltage Programming function: RB3/PGM, RB6/PGC and RB7/PGD. 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 (OPTION_REG<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. Four of the PORTB pins, RB7:RB4, have an interrupton- change feature. Only pins configured as inputs can cause this interrupt to occur (i.e., any RB7:RB4 pin configured as an output is excluded from the interrupton- change comparison). The input pins (of RB7:RB4) are compared with the old value latched on the last read of PORTB. The ―mismatch‖ outputs of RB7:RB4 are OR‘ed together to generate the RB port change interrupt with flag bit RBIF (INTCON<0>). This interrupt can wake the

29

device from Sleep. The user, in the Interrupt Service Routine, can clear the interrupt in the following manner: Any read or write of PORTB. This will end the

 

Mismatch condition. Clear flag bit RBIF. A mismatch condition will continue to set flag bit RBIF.

Reading PORTB will end the mismatch condition and allow flag bit RBIF to be cleared. The interrupt-on-change feature is recommended for wake-up on key depression operation and operations where PORTB is only used for the interrupt-onchange feature. Polling of PORTB is not recommended while using the interrupt-onchange feature. This interrupt-on-mismatch feature, together with software configurable pull-ups on these four pins, allow easy interface to a keypad and make it possible for wake-up on key depression.

3.2.15 Port C & TRIS C Register

PORTC is an 8-bit wide, bidirectional port. The corresponding data direction register is TRISC. Setting a TRISC bit (= 1) will make the corresponding PORTC pin an input (i.e., put the corresponding output driver in a High-Impedance mode). Clearing a TRISC bit (= 0) will make the corresponding PORTC pin an output (i.e., put the contents of the output latch on the selected pin). PORTC is multiplexed with several peripheral functions. PORTC pins have Schmitt Trigger input buffers. When the I2C module is enabled, the PORTC<4:3> pins can be configured with normal I2C levels, or with SMBus levels, by using the CKE bit (SSPSTAT<6>).

When enabling peripheral functions, care should be taken in defining TRIS bits for each PORTC pin. Some peripherals override the TRIS bit to

make a pin an output, while other peripherals override the TRIS bit to make a pin an input. Since the TRIS bit override is in effect while the peripheral is enabled, readmodify write instructions (BSF, BCF, XORWF) with TRISC as the destination,
30

should be avoided. The user should refer to the corresponding peripheral section for the correct TRIS bit settings.

3.2.16 Port D & TRIS D Register

PORTD is an 8-bit port with Schmitt Trigger input buffers. Each pin is individually configurable as an input or output. PORTD can be configured as an 8-bit wide microprocessor port (Parallel Slave Port) by setting control bit, PSPMODE (TRISE<4>). In this mode, the input buffers are TTL.

3.2.17 Port E & TRIS E Register

PORTE

has

three

pins

(RE0/RD/AN5,

RE1/WR/AN6

and

RE2/CS/AN7) which are individually configurable as inputs or outputs. These pins have Schmitt Trigger input buffers. The PORTE pins become the I/O control inputs for the microprocessor port when bit PSPMODE (TRISE<4>) is set. In this mode, the user must make certain that the TRISE<2:0> bits are set and that the pins are configured as digital inputs. Also, ensure that ADCON1 is configured for digital I/O. In this mode, the input buffers are TTL. Register 4-1 shows the TRISE register which also controls the Parallel Slave Port operation. PORTE pins are multiplexed with analog inputs. When selected for analog input, these pins will read as ‗0‘s. TRISE controls the direction of the RE pins, even when they are being used as analog inputs. The user must make sure to keep the pins configured as inputs when using them as analog inputs.

3.2.18 USART

The Universal Synchronous Asynchronous Receiver Transmitter (USART) module is one of the two serial I/O modules. (USART is also known as a Serial Communications Interface or SCI). These ports are used for the transmission (TX) and reception (RX) of data. These transmissions possible with help of various digital
31

data transceiver modules like RF, IR, Bluetooth, ZIGBEE etc. This is the one of the simplest way to communicate the PIC chip with other devices. The USART can be configured as a full-duplex asynchronous system that can communicate with peripheral devices, such as CRT terminals and personal computers, or it can be configured as a half-duplex synchronous system that can communicate with peripheral devices, such as A/D or D/A integrated circuits, serial EEPROMs, etc. The USART can be configured in the following modes:    Asynchronous (full-duplex) Synchronous – Master (half-duplex) Synchronous – Slave (half-duplex)

Bit SPEN (RCSTA<7>) and bits TRISC<7:6> have to be set in order to configure pins RC6/TX/CK and RC7/RX/DT as the Universal Synchronous Asynchronous Receiver Transmitter. The parameters for serial communication are      Data rate (Baud rate in bps) Data size (packet size) Start bit (if any) Stop bit (if any) Parity bit (if any)

PIC 16F877A have no start bit, one stop bit & no parity bit. Therefore the transmitted or received information is 9-bit in size, where 8-bit is data & one bit is stop bit. The USART module also has a multi-processor communication capability using 9-bit address detection.

32

3.2.19 Pin Diagram of PIC 16F877A

The 40 pin PDIP pin- out of PIC 16F877A is shown below:

Fig.3.2 PIN DIAGRAM

Some pins for these I/O ports are multiplexed with an alternate function for the peripheral features on the device. These are given in appendix.

3.2.20 Master Clear

PIC16F87XA devices have a noise filter in the MCLR Reset path. The filter will detect and ignore small pulses. Voltages applied to the pin that exceed its specification can result in both Resets and current consumption outside of device
33

specification during the Reset event. For this reason, Microchip recommends that the MCLR pin no longer be tied directly to VDD. The use of an RCR network, as shown in Fig.6.5 is suggested. During normal operation this pin should be high. When reset it is low, during reset, the following conditions will occur     Queue will clear All registers will clear IP points to the first location of memory RAM will clear

Fig 3.3 MCLR PIN OF PIC16F877A 3.2.21 Limitations of PIC Architecture:     

Peripheral Interface Controller has only one accumulator. Small instruction set. Register banking switch required to access RAM of other devices. Operations and registers are not orthogonal. Program memory is not accessible.

34

The PIC requires external clock generator. We use crystal oscillator for clock generation.

3.2.22Advantages of PIC Controlled System: •

Reliability: The PIC controlled system often resides machines that are expected to run

continuously for many years without any error and in some cases recover by themselves if an error occurs(with help of supporting firmware). • Performance: Many of the PIC based embedded system use a simple pipelined RISC processor for computation and most of them provide on-chip SRAM for data storage to improve the performance. • Power consumption: A PIC controlled system operates with minimal power consumption without sacrificing performance. Power consumption can be reduced by independently and dynamically controlling multiple power platforms. • Memory: Most of the PIC based systems are memory expandable and will help in easily adding more and more memory according to the usage and type of application. In small applications the inbuilt memory can be used. The PIC16F877A CMOS FLASH-based 8-bit microcontroller is upward compatible with the PIC16C5x, PIC12Cxxx and PIC16C7x devices. It features 200 ns instruction execution, 256 bytes of EEPROM data memory, self programming, an ICD, 2 Comparators, 8 channels of 10-bit Analog-to-Digital (A/D) converter, 2 capture/compare/PWM functions, a synchronous serial port that can be configured as either 3-wire SPI or 2-wire I2C bus, a USART, and a Parallel Slave Port.

35

Microchip PIC16F877A Microcontroller Features

High-Performance RISC CPU
      

Lead-free; RoHS-compliant Operating speed: 20 MHz, 200 ns instruction cycle Operating voltage: 4.0-5.5V Industrial temperature range (-40° to +85°C) 15 Interrupt Sources 35 single-word instructions All single-cycle instructions except for program branches (two-cycle)

Special Microcontroller Features
         

Flash Memory: 14.3 Kbytes (8192 words) Data SRAM: 368 bytes Data EEPROM: 256 bytes Self-reprogrammable under software control In-Circuit Serial Programming via two pins (5V) Watchdog Timer with on-chip RC oscillator Programmable code protection Power-saving Sleep mode Selectable oscillator options In-Circuit Debug via two pins

Peripheral Features
  

33 I/O pins; 5 I/O ports Timer0: 8-bit timer/counter with 8-bit prescaler Timer1: 16-bit timer/counter with prescaler
o

Can be incremented during Sleep via external crystal/clock

 

Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler Two Capture, Compare, PWM modules
36

o o o 

16-bit Capture input; max resolution 12.5 ns 16-bit Compare; max resolution 200 ns 10-bit PWM

Synchronous Serial Port with two modes:
o o

PI Master I2C Master and Slave

 

USART/SCI with 9-bit address detection Parallel Slave Port (PSP)
o

8 bits wide with external RD, WR and CS controls



Brown-out detection circuitry for Brown-Out Reset

Analog Features
  

10-bit, 8-channel A/D Converter Brown-Out Reset Analog Comparator module
o o o

2 analog comparators Programmable on-chip voltage reference module Programmable input multiplexing from device inputs and internal VREF

o

Comparator outputs are externally accessible

37

3.3 LM35:

The

LM35

series

are

precision

integrated-circuit

temperaturesensors, whose output voltage is linearly proportional to theCelsius (Centigrade) temperature. The LM35 thus has anadvantage over linear temperature sensors calibrated in° Kelvin, as the user is not required to subtract a largeconstant voltage from its output to obtain convenient Centigradescaling. The LM35 does not require any external calibration or trimming to provide typical accuracies of ±1⁄4°Cat room temperature and ±3⁄4°C over a full −55 to +150°Ctemperature range. Low cost is assured by trimming andcalibration at the wafer level. The LM35‘s low output impedance,linear output, and precise inherent calibration makeinterfacing to readout or control circuitry especially easy. Itcan be used with single power supplies, or with plus andminus supplies. As it draws only 60 μA from its supply, it hasvery low self-heating, less than 0.1°C in still air. The LM35 israted to operate over a −55° to +150°C temperature range,while the LM35C is rated for a −40° to +110°C range (−10°with improved accuracy). The LM35 series is available packagedin hermetic TO-46 transistor packages, while theLM35C, LM35CA, and LM35D are also available in theplastic TO-92 transistor package. The LM35D is also availablein an 8-lead surface mount small outline package and aplastic TO-220 package.

Fig 3.4 BOTTOM VIEW OF LM35

38

Table 3.3 Electrical Characteristics of LM35

39

3.3.1 Features:           

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

3.3.2 Applications: The LM35 can be applied easily in the same way as otherintegrated-circuit temperature sensors. It can be glued orcemented to a surface and its temperature will be withinabout 0.01°C of the surface temperature. This presumes that the ambient air temperature is almost thesame as the surface temperature; if the air temperature weremuch higher or lower than the surface temperature, theactual temperature of the LM35 die would be at an intermediate temperature between the surface temperature and theair temperature. This is expecially true for the TO-92 plasticpackage, where the copper leads are the principal thermalpath to carry heat into the device, so its temperature mightbe closer to the air temperature than to the surface temperature.To minimize this problem, be sure that the wiring to theLM35, as it leaves the device, is held at the same temperatureas the surface of interest. The easiest way to do this isto cover up these wires with a bead of epoxy which willinsure that the leads and wires are all at the same temperatureas the surface, and that the LM35 die‘s temperature will not be affected by the air temperature.The TO-46 metal package can also be soldered to a
40

metalsurface or pipe without damage. Of course, in that case theV− terminal of the circuit will be grounded to that metal.Alternatively, the LM35 can be mounted inside a sealed-endmetal tube, and can then be dipped into a bath or screwedinto a threaded hole in a tank. As with any IC, the LM35 andaccompanying wiring and circuits must be kept insulated anddry, to avoid leakage and corrosion. This is especially true if the circuit may operate at cold temperatures where condensationcan occur. Printed-circuit coatings and varnishes suchas Humiseal and epoxy paints or dips are often used toinsure that moisture cannot corrode the LM35 or its connections. These devices are sometimes soldered to a smalllight-weight heat fin, to decrease the thermal time constantand speed up the response in slowly-moving air. On the other hand, a small thermal mass may be added to the sensor, to give the steadiest reading despite small deviationsin the air temperature.

41

3.4 CNG SENSOR:
CNG Sensor is used in gas leakage detecting equipment‘s for detecting of LPG, iso-butane, propane, LNG combustible gases. The sensor does not get trigger with the noise of alcohol, cooking fumes and cigarette smoke. The sensor needs 5V to operate, Give regulated +5V DC supply, The sensor will take around180mA supply. The sensor will heat a little bit since it has internal heater that heats the sensing element.

Fig 3.5 CNG SENSOR
42

3.4.1 Pin Description: Pin No.1 - GND – Power Supply Ground Pin No.2 – A.OUT – Analog Output Voltage Pin No.3 - +5V - Supply voltage DC +5V regulated

3.4.2 Applications:

· Gas leak detection system · Fire/Safety detection system · Gas leak alarm / Gas detector

3.4.3 Features:

· Simple analog output · High sensitivity to LPG, iso-butane, propane · Small sensitivity to alcohol, smoke · Fast response · Wide detection range · Stable performance and long life

43

3.4.4 Specifications:

Target Gas: Detection Range: Output Voltage Range: Working Voltage : Current Consumption : Warmup Time: Response Time : Resume Time:

iso-butane, Propane, LPG 100 to 10000 PPM (part per millions) 0 to 5 VDC 5 VDC ≤180 mA 10 Minutes ≤10s Seconds ≤30s Seconds

Standard Working Condition Temperature: -10 to 65 deg C. Humidity:≤95%RH Storage Condition Temperature: -20-70 deg C Humdity: ≤ 70%RH

3.4.5 Deriving Gas concentration from Output Voltage:

Here is a the equation which convert analog output to PPM gas concentration.

PPM = Analog Voltage in mV x 2

44

3.4.6 Sensitivity:

Fig 3.6 SENSITIVITY GRAPH

Typical Sensitivity Characteristics of sensor for several gases in their Temperature: Humidity: Oxygen concentration: RL = Ro = Rs= 20 deg C 65% 21% 10K Ohm resistance at 1000 ppm of LPG in clean air resistance at various concentrations of gases

45

3.5 LCD (Liquid Crystal Display)

3.5.1 General Description:

The Liquid Crystal Display (LCD) is a low power device (microwatts). Now a days in most applications LCDs are using rather using of LED displays because of its specifications like low power consumption, ability to display numbers and special characters which are difficult to display with other displaying circuits and easy to program. An LCD requires an external or internal light source. Temperature range of LCD is 0ºC to 60ºC and lifetime is an area of concern, because LCDs can chemically degrade these are manufactured with liquid crystal material (normally organic for LCDs) that will flow like a liquid but whose molecular structure has some properties normally associated with solids. . LCDs are classified as 1. Dynamic-scattering LCDs and 2. Field-effect LCDs

Field-effect LCDs are normally used in such applications where source of energy is a prime factor (e.g., watches, portable instrumentation etc.).They absorb considerably less power than the light-scattering type. However, the cost for field-effect units is typically higher, and their height is limited to 2 inches. On the other hand, light-scattering units are available up to 8 inches in height. Field-effect LCD is used in the project for displaying the appropriate information.

RS (Command / Data):
This bit is to specify weather received byte is command or data. So that LCD can recognize the operation to be performed based on the bit status. RS RS = 0 = 1 => => Command Data
46

RW (Read / Write):

RW bit is to specify whether controller wants READ from LCD or WRITE to LCD. The READ operation here is just ACK bit to know weather LCD is free or not. RW RW = 0 = 1 => => Write Read

EN (Enable LCD):

EN bit is to ENABLE or DISABLE the LCD. When ever controller wants to write some thing into LCD or READ acknowledgment from LCD it needs to enable the LCD. EN = 0 EN = 1 => => High Impedance Low Impedance

ACK (LCD Ready):

ACK bit is to acknowledge the MCU that LCD is free so that it can send new command or data to be stored in its internal Ram locations ACK = 1 => => Not ACK ACK

ACK = 0

47

3.5.2 LCD diagram:

16 x 2 Char LCD
A K D7 D0 EN RW RS Vf GND

ACK Vcc D0 – D7 R1

R2

Fig 3.7 LCD DIAGRAM

LCD D0-D7
RS RW EN

Data Lines Embedded Controller
P1.0 P1.1 P1.2

Fig 3.8Block Diagram
48

3.5.3 Hardware connections:

CONTROLER PINS (P1.0) (P1.1) (P1.2) Port 0 40 20

LCD PINS

PIN NAME WITH FEATURE

4 5 6 7 to 14 15 & 2 16 & 1

RS (Control Pin) RW (Control pin ) EN (Control pin) Data Port Vcc Gnd

Table 3.4 CONNECTIONS TO LCD PINS

49

3.5.4 FLOWCHART:

START

Configure port pins for all hardware connections

Wait No
Is LCD Free

Yes

Clear RS Bit Enable LCD Send Command Disable LCD

No

Is Command Count Zero

1

50

1

Wait No
Is LCD Free

Yes

Set RS Bit Enable LCD Send Data Disable LCD

No

Is Data Count Zero

STOP

51

3.5.5 LCD COMMANDS:
No. Instruction Hex Decimal 48 56 32 40 6

1 2 3 4 5

Function Set: 8-bit, 1 Line, 5x7 Dots Function Set: 8-bit, 2 Line, 5x7 Dots Function Set: 4-bit, 1 Line, 5x7 Dots Function Set: 4-bit, 2 Line, 5x7 Dots Entry Mode Display off Cursor off

0x30 0x38 0x20 0x28 0x06

8 0x08 0x0E 0x0C 0x0F 0x18 0x1C 0x10 0x14 0x01 0x80+add* 14 12 15 24 28 16 20 1 128+add*

6 7 8 9 10 12 13 14 15 16

(clearing display without clearing DDRAM content) Display on Cursor on Display on Cursor off Display on Cursor blinking Shift entire display left Shift entire display right Move cursor left by one character Move cursor right by one character Clear Display (also clear DDRAM content) Set DDRAM address or coursor position on display Set CGRAM address or set pointer to CGRAM location Table 3.5 LCD COMMANDS

64+add** 0x40+add**

17

52

3.6 DTMF DECODER CM8870:

The CAMD CM8870 provides full DTMF receiver capability by integrating both the bandsplit filter and digitaldecoder functions into a single 18-pin DIP, SOIC, or 20-pin PLCC package. The CM8870 is manufactured usingstate-of-the-art CMOS process technology for low power consumption (35mW, max.) and precise data handling. Thefilter section uses a switched capacitor technique for both high and low group filters and dial tone rejection. The CM8870 decoder uses digital counting techniques for the detection and decoding of all 16 DTMF tone pairs into a4-bit code. This DTMF receiver minimizes external component count by providing an on-chip differential input amplifier,clock generator, and a latched three-state interface bus. The on-chip clock generator requires only a low cost TVcrystal or ceramic resonator as an external component. This device contains input protectionagainst damage due to high staticvoltages or electric fieldshowever,precautions should be taken to avoidapplication of voltages higher than themaximum rating

Fig 3.8 DTMF DECODER PIN DIAGRAM
53

Fig 3.9 BLOCK DIAGRAM OF DTMF DECODER

54

3.6.1 Features:
• Full DTMF receiver • Less than 35mW power consumption • Industrial temperature range • Uses quartz crystal or ceramic resonators • Adjustable acquisition and release times • 18-pin DIP, 18-pin DIP EIAJ, 18-pin SOIC, 20-pin PLCC

3.6.2 Applications:
• PABX • Central office • Mobile radio • Remote control • Remote data entry • Call limiting • Telephone answering systems • Paging systems

55

3.7 L293D MOTOR DRIVER:

The Device is a monolithic integrated high voltage, high current four channel driver designed to accept standard DTL or TTL logic levels and drive inductive loads (such as relays solenoids, DC and stepping motors) and switching power transistors. To simplify use as two bridges each pair of channels is equipped with an enable input. A separate supply input is provided for the logic, allowing operation at a lower voltage and internal clamp diodes are included. This device is suitable for use in switching applications at frequencies up to 5 kHz. The L293D is assembled in a 16 lead plastic packaage which has 4 centre pins connected together and used for heat sinking The L293DD is assembled in a 20 lead surface mount which has 8 centre pins connected together and used for heat sinking.

Fig 3.20 L293D BLOCK DIAGRAM

56

Fig 3.21 L293D MOTOR CONNECTIONS

57

3.8 GSM MODEM: 3.8.1 GSM:
The Global System for Mobile Communications (GSM) is the most popular standard for mobile phones in the world. GSM phones are used by over a billion people across more than 200 countries. The ubiquity of the GSM standard makes international roaming very common between mobile phone operators, which enable phone users to access their services in many other parts of the world as well as their own country. GSM differs significantly from its predecessors in that both signalling and speech channels are digital, which means that it is seen as a second generation (2G) mobile phone system. This fact has also meant that data communication was built into the system from very early on. GSM is an open standard, which is currently developed by the 3GPP.From the point of view of the consumer, the key advantage of GSM systems has been higher digital voice quality and low cost alternatives to making calls such as text messaging. The advantage for network operators has been 8 the ability to deploy equipment from different vendors because the open standard allows easy inter-operability. Also, the standards have allowed network operators to offer roaming services, which mean the subscribers, can use their phone all over the world. GSM retained backwardcompatibility with the original GSM phones as the GSM standard continued to develop, for example packet data capabilities were added in the Release '97 version of the standard, by means of GPRS. Higher speed data transmission has also been introduced with EDGE in the Release '99 version of the standard.

58

3.8.2 SERVICES PROVIDED BY GSM:

From the beginning, the planners of GSM wanted ISDN compatibility in terms of the services offered and the control signalling used. However, radio transmission limitations, in terms of bandwidth and cost, do not allow the standard ISDN B-channel bit rate of 64 kbps to be practically achieved. Using the ITU-T definitions, telecommunication services can be divided into bearer services, teleservices, and supplementary services. The most basic teleservice supported by GSM is telephony. As with all other communications, speech is digitally encoded and transmitted through the GSM network as a digital stream. There is also an emergency service, where the nearest emergency-service provider is notified by dialing three digits (similar to 911).

A variety of data services is offered. GSM users can send and receive data, at rates up to 9600 bps, to users on POTS (Plain Old Telephone Service), ISDN, Packet Switched Public Data Networks, and Circuit Switched Public Data Networks using a variety of access methods and protocols, such as X.25 or X.32. Since GSM is a digital network, a modem is not required between the user and GSM network, although an audio modem is required inside the GSM network to interwork with POTS. Other data services include Group 3 facsimile, as described in ITU-T recommendation T.30, which is supported by use of an appropriate fax adaptor. A unique feature of GSM, not found in older analog systems, is the Short Message Service (SMS). SMS is a bi-directional service for short alphanumeric (upto160 bytes) Messages. Messages are transported in a store-andforward fashion. For point-to-point SMS, a message can be sent to another subscriber to the service, and an of receipt acknowledgement is provided to the sender. SMS can also be used in a cell-broadcast mode, for sending messages such as traffic updates or news updates. Messages can also be stored in the SIM card for later retrieval. Supplementary services are provided on top of tele services or bearer services. In the current (Phase I) specifications, they include several forms of call forward (such as call forwarding when the mobile subscriber is unreachable by the network), and call barring of outgoing or incoming calls, for example when roaming in another country.
59

Many additional supplementary services will be provided in the specifications, such as caller identification, call waiting, multi-party conversations.

3.8.3 GSM SECURITY:
GSM was designed with a moderate level of security. The system was designed to authenticate the subscriber using shared-secret cryptography. Communications between the subscriber and the base station can be encrypted. The development of UMTS introduces an optional USIM, that uses a longer authentication key to give greater security, as well as mutually authenticating the network and the user - whereas GSM only authenticated the user to the network (and not vice versa). The security model therefore offers

confidentiality and authentication, but limited authorization capabilities, and no non-repudiation. GSM uses several cryptographic algorithms for security. The A5/1 and A5/2 stream ciphers are used for ensuring over the- air voice privacy. A5/1 was developed first and is a stronger algorithm used within Europe and the United States; A5/2 is weaker and used in countries that may not be able to support the infrastructure necessary for A5/1. A large security advantage of GSM is that the Ki, the crypto variable stored on the SIM card that is the key to any GSM ciphering algorithm, is never sent over the air interface. Serious weaknesses have been found in both algorithms, and it is possible to break A5/2 in real-time in a cipher text-only attack. The system supports multiple algorithms so operators may replace that cipher with a stronger one.

60

3.8.4 ADVANTAGES OF GSM:
1. Roaming with GSM phones is a major advantage over the competing technology as roaming across CDMA networks. 2. Another major reason for the growth in GSM usage, particularly between 1998 to 2002, was the availability of prepaid calling from mobile phone operators. This allows people who are either unable or unwilling to enter into a contract with an operator to have mobile phones. Prepaid also enabled the rapid expansion of GSM in many developing countries where large sections of the population do not have access to banks or bank accounts and countries where there are no effective credit rating agencies. (In the USA, starting a non-prepaid contract with a cellular phone operator is almost always subject to credit verification through personal information provided by credit rating agencies). 3. The architecture of GSM allows for rapid flow of information by voice or data messaging (SMS). Users now have access to more information, whether personal, technical, economic or political, more quickly than was possible before the global presence of GSM. Even remote communities are able to integrate into networks (sometimes global) thereby making information, knowledge and culture accessible, in theory, to anyone. 4.One of the most appealing aspects of wireless communications is its mobility. Much of the success of GSM is due to its mobility management, offering users the freedom and convenience to conduct business from almost anywhere at any time. 5. GSM has been the catalyst in the tremendous shift in traffic volume from fixed networks to mobile networks. This has resulted in the emergence of a mobile paradigm, whereby the mobile phone has become the first choice of personal phone. 6. Higher digital voice quality. 7. Low cost alternatives to making calls such a text messaging.

61

3.8.5 USES OF GSM:
• Uses encryption to make phone calls more secure • Data networking • Group III facsimile services • Short Message Service (SMS) for text messages and paging • Call forwarding • Caller ID U • Call waiting. • Multi-party conferencing After a few turbulent years for the industry, we highlight some of the key factors we view as critical for the continued success of GSM. These include: • Enabling convergence with other wireless technologies • Developing Mobile Centric Applications • Evolving the mobile business model • Mobile terminal enhancements and variety • Fostering industry partnerships and co-operations • Interoperability and Inter-generational roaming between various

platforms.

62

3.9 SMPS:
A switched-mode power supply (switching-mode power supply, SMPS, or switcher) is an electronic power supply that incorporates a switching regulator to convert electrical power efficiently. Like other power supplies, an SMPS transfers power from a source like the electrical power grid to a load (such as a personal computer) while converting voltage and current characteristics. An SMPS is usually employed to efficiently provide a regulated output voltage, typically at a level different from the input voltage. Unlike a linear power supply, the pass transistor of a switching mode supply continually switches between low-dissipation, full-on and full-off states, and spends very little time in the high dissipation transitions (which minimizes wasted energy). Ideally, a switched-mode power supply dissipates no power. Voltage regulation is achieved by varying the ratio of on-to-off time. In contrast, a linear power supply regulates the output voltage by continually dissipating power in the pass transistor. This higher power conversion efficiency is an important advantage of a switched-mode power supply. Switched-mode power supplies may also be substantially smaller and lighter than a linear supply due to the smaller transformer size and weight. Switching regulators are used as replacements for the linear regulators when higher efficiency, smaller size or lighter weight are required. They are, however, more complicated, their switching currents can cause electrical noise problems if not carefully suppressed, and simple designs may have a poor power factor.

63

3.9.1 BLOCK DIAGRAM:

Fig 3.22 BLOCK DIAGRAM OF SMPS

Fig 3.23 SMPS

64

3.10 DC MOTOR:
The relationship between torque vs speed and current is linear asshown left;as the load on a motor increases, Speed will decrease.The graph pictured here represents the characteristics of a typicalmotor.

As long as the motor is used in the area of high efficiency (asrepresented by the shaded area) long life and good performance canbe expected. However, using the motor outside this range will resultin high temperature rises and deterioration of motor parts.

If voltage in continuous applied to a motor in a locked rotorcondition, the motor will heat up and fail in a relatively short time.Therefore it is important that there is some form of protectionagainst high temperature rises.

A motor's basic rating point is slightly lower than its maximumefficiency point.Load torque can be determined by measuring the current drawnwhen the motor is attached to a machine whose actual load value isknown.

Fig 3.24 DC MOTOR

65

CHAPTER 4 TESTING OF THE PROJECT
4.1 INTRODUCTION:
The following chapter gives a brief note about the procedure of testing the prototype and interfacing of the various blocks in the project and a flow chart on how the prototype works.

Fig 4.1 TOP VIEW OF PROJECT KIT Temperature sensor LM 35 outputs 10mV for every 1 deg C change in the ambient temperature. This sensor gives liner output voltage value. This temperature value is given to the Analog to Digital convertor(ADC) pin of the microcontroller, which is inbuilt in the controller. ADC which is the pin of microcontroller would then convert the analog value of the sensor to the corresponding digital value.
66

Compressed Natural Gas(CNG) MQ-9 outputs 50mV for every 100ppm change in the ambient gas. This gas value is given to ADC pin of the microcontroller. ADC which is the pin of the microcontroller converts the analog value of the sensor to the corresponding digital value. PIC16F877A is an 8-bit microcontroller, here we choose only two sensors so pins An0 and An1 are used. Few pins or all the pins can be used depending upon the application. The microcontroller after converting the analog data into digital simultaneously sends the values to LCD and GSM module. LCD which is placed on the robot body displays values for every small change in the environment. In this application 16 * 2 Alphanumeric LCD is used. LCD is connected to microcontroller through Port D which is 8-bit. Through Port D commands and data are send to LCD from microcontroller. Using GSM module we send the digital data to the user cell phone. The user mobile phone internally decodes the digital value from the GSM module. In this application SIM 300 GSM module is used.

Fig 4.2 DISPLAY OF PARAMETERS ON LCD
67

4.2 Interfacing GSM module and microcontroller:
Both the microcontroller PIC 16F877A and GSM module SIM 300 support RS 232 protocol. So we don‘t require any convertor IC. GSM module is directly connected to the Tx, Rx pins of the microcontroller. The Tx, Rx pins are the 25, 26 pins of the microcontroller. Attention terminal (AT) commands are used through which data can be sent to the user phone. In this application we only send messages not receive so, we use send SMS AT commands among the list of AT commands to send data. A second mobile is used totransfer the data of the keys pressed on the user mobile phone. This is done through dialing from the user cell phone. Initially the second phone will be put in the auto answering mode. So when we call from the user cell phone and then press the keys this data will be transferred by the second mobile phone to the DTMF decoder. The second mobile phone is connected to the DTMF decoder through audio jack. Through the second mobile the data of keys pressed will be given to the decoder.

Fig 4.3 INTERFACING OF GSM AND MICROCONTROLLER

68

4.3 Interfacing DTMF decoder and the mobile phone:

The decoder is connected to the second mobile phone using audio jack. The audio signals from the mobile will be given to the DTMF decoder. The decoder will now convert the audio signal into corresponding digital data.

The functionality of the decoder is to convert its input into corresponding 4-bit digital output. There are four Light Emitting Diode(LED) on the board which contains DTMF decoder. These LED‘s indicate the digital value of the key being pressed. For example if we press key 1 on user phone, then only one LED glows according to its binary value representation. In this application CM8870 DTMF decoder is used.

The output of DTMF decoder that is 4-bit data is given to the motor driver IC. This 4-bit data helps the robot to move in respective directions. The motor driver IC used is L293D.A single motor driver IC can drive two motors. L293D IC has 4 inputs and 4 outputs. It has two enable pins. When the enable pin is on the respective inputs are on.

Two inputs and two outputs correspond to a single motor. The 4-bit data of DTMF decoder is given to the four inputs of L293D IC and two motors are connected to its output pins. When the inputs are given to the motor the robot moves in the corresponding directions. Robot can move Forward, Backward, to both the sides.

69

Fig 4.4 INTERFACING OF DTMF DECODER AND MOBILE PHONE

70

4.4 Flow chart
Read values from sensors

Display on LCD

T>=40 Or L>=3000

No

Yes

Send data to cell phone

4.5 CONCLUSION:
The various blocks in the proto type are interfaced and tested. A flow chart is drawn explaining the working of robot
71

CHAPTER 5 SOFWARE DISCRIPTION
5.1 INTRODUCTION:
Software part of the prototype is explained in this chapter. The language used to write the code for micro controller operation and the code is also mentioned.

5.2 PIC C Compiler:
The FED PIC C compiler will handle any of the current 14 bit PIC's and future devices may be added by changes to initialization files. All devices are handled by standard C header files. Embedded C language is used for coding. C language is chosen because it is easy to learn and easy to debug. C language provides many flexible libraries which makes writing code easy. Assembly language is complex when compared to C. assembly language requires time to learn and if there is any error in the program more time is taken for debugging. Assembly language doesn‘t include any header files so user should write the full code. This is the reason embedded C is better than assembly language and we can program our PIC microcontroller using embedded C language.

5.2.1 Features :
• Designed to ANSI C Standards • Integrated Compiler Environment • Integrated Debugging Support • Supports full range of 14 bit PIC Processors • Efficient code production • Wide range of library functions
72

• Includes floating point numeric support • Includes fully integrated assembly level debugger • Supports MPLA

To open the new project then use the Project | Open/New Project menu item. A File dialog box will be brought up. Create a new directory by using the small icon of a folder with a star in the right hand corner. Select the new directory, double click to enter it, and then select the project file name. Press OK.

5.2.2 Advantages of using embedded C:
• It is easier and less time consuming • C is easier to modify and update • Easily import code available in function libraries (i.e. delays, usart, adc, etc.) • C code is portable to other microcontroller with little or no modification (ANSI C format)

73

5.3 AT-commands:
When a modem is connected to any device (computer, fax, etc.,) we need AT commands to direct the modem for its operations. Basically we send commands directly to the modem after activating Terminal mode. This mode is also called as local mode or direct mode. Apart from the basic AT commands, to send the SMS message, it is required to have some special AT commands. The basic regularly used AT commands along with the SMS AT commands are discussed below.

5.3.1 The AT command format:

Instructions sent to the modem are referred as AT commands because they are always preceded by a prefix AT that are used to get the attention of the modem. <AT> <COMMAND>{Argument}{=n}<enter> AT - attention code Command - a command consists of one letter Argument - Optional information that further defines the command =n - used when setting a register

you may string commands together in one command line as long as the total length of command does not exceed 63 bytes . The attention code, AT, is only required at the beginning of the command line. A/, +++ are the only two commands which are not preceded by AT. 5.3.2 Using AT Commands:

When issued to the fax modem, AT commands direct the fax modem to dial, answer, hang up, and to perform many other communication tasks. Some of the most commonly used commands are:

74

AT (Attention). This is the command line prefix. (All the commands listed , except A/ and +++, must be preceded by the command AT). A Answer an incoming call D Dial the following phone number E Turn echo OFF H Hang up O Return to on-line state Z Reset the modem to the values stored in the N.V. Ram +++ Return to the Command State A/ Repeat last command (Do not precede this command with AT or follow it with <Enter>) Request revision identification +CGMR: Description: This command is used to get the revised software version.

Table 5.1 syntax for AT+CGMR Preferred Message Storage +CPMS: Description: This command allows the message storage area to be selected (for reading, writing, etc).

75

Table 5.3 syntax AT+CPMS

Defined values : <mem1> - ―SM‖ - ―BM‖ - ―SR‖ : Memory used to list, read and delete messages. It can be: : SMS message storage in SIM (default) : CBM message storage (in volatile memory). : Status Report message storage (in SIM if the EF-SMR file exists,

otherwise in the ME non volatile memory) Note : ―SR‖ ME non volatile memory is cleared when another SIM card is inserted. It is kept, even after a reset, while the same SIM card is used. <mem2> : Memory used to write and send messages

If the command is correct, the following message indication is sent: +CPMS: <used1>,<total1>,<used2>,<total2> When <mem1> is selected, all following +CMGL, +CMGR and +CMGD commands are related to the type of SMS stored in this memory.
76

Preferred Message Format +CMGF: Description: The message formats supported are text mode and PDU mode. In PDU mode, a complete SMS Message including all header information is given as a binary string (in hexadecimal format). Therefore, only the following set of characters is allowed: {‗0‘,‘1‘,‘2‘,‘3‘,‘4‘,‘5‘,‘6‘,‘7‘,‘8‘,‘9‘, ‗A‘, ‗B‘,‘C‘,‘D‘,‘E‘,‘F‘}. Each pair or characters is converted to a byte (e.g.: ‗41‘ is converted to the ASCII character ‗A‘, whose ASCII code is 0x41 or 65). In Text mode, all commands and responses are in ASCII characters. The format selected is stored in EEPROM by the +CSAS command.

Syntax :

Table 5.3 syntax for AT+CMGF

Example, sending an SMS Message in PDU mode

Table 5.4 SMS Message in PDU mode

77

Defined values : The <pdu> message is composed of the SC address (« 00 means no SC address given, use default SC address read with +CSCA command) and the TPDU message. In this example, the length of octets of the TPDU buffer is 14, coded as GSM 03.40 In this case the TPDU is : 0x01 0x03 0x06 0x91 0x21 0x43 0x65 0x00 0x00 0x04 0xC9 0xE9 0x34 0x0B, which means regarding GSM 03.40 : <fo> <mr> (TP TP-MR) <da> (TP TP-DA) <pid> (TP TP-PID) <dcs> (TP TP-DCS) <length> (TP TP-UDL) TP-UD 0x01 (SMS-SUBMIT, no validity period) 0x03 (Message Reference) 0x06 0x91 0x21 0x43 0x65 (destination address +123456) 0x00 (Protocol Identifier) 0x00 (Data Coding Scheme : 7 bits alphabet) 0x04 (User Data Length, 4 characters of text) 0xC9 0xE9 0x34 0x0B (User Data : ISSY)

TPDU in hexadecimal format must be converted into two ASCII characters, e.g. octet with hexadecimal value 0x2A is presented to the ME as two characters ‗2‘ (ASCII 50) and ‗A‘ (ASCII 65). Read message +CMGR Description : This command allows the application to read stored messages. The messages are read from the memory selected by +CPMS command. Syntax : Command syntax : AT+CMGR=<index> Response syntax for text mode: +CMGR : <stat>,<oa>,[<alpha>,] <scts> [,<tooa>,<fo>,

78

<pid>,<dcs>,<sca>,<tosca>,<length>] <CR><LF> <data> (for SMS MS MSDELIVER only)

+CMGR :

<stat>,<da>,[<alpha>,] [,<toda>,<fo>,<pid>,<dcs>, [<vp>], <sca>, <tosca>,<length>]<CR><LF> <data> (for SMS-SUBMIT only)

+CMGR :

<stat>,<fo>,<mr>,[<ra>],[<tora>],<scts>,<dt>,<st> (for SMS SMS-

STATUS-REPORT only) Response syntax for PDU mode : +CMGR: <stat>, [<alpha>] ,<length> <CR><LF> <pdu> A message read with status ―REC UNREAD‖ will be updated in memory with the status ―REC READ‖.

Note : the <stat> parameter for SMS Status Reports is always ―READ‖. Example :

New message indication +CNMI Description : This command selects the procedure for message reception from the network.
79

Table 5.5 Syntax for AT+CNMI

Defined values: <mode> : controls the processing of unsolicited result codes Only <mode>=2 is supported. Any other value for <mode> (0,1 or 3) is accepted (return code will be OK), but the processing of unsolicited result codes will be the same as with<mode>=2. <mode> 0: Buffer unsolicited result codes in the TA. If TA result code buffer is full,

indications can be buffered in some other place or the oldest indications may be discarded and replaced with the new received indications 1: Discard indication and reject new received message unsolicited result codes

when TA-TE link is reserved. Otherwise forward them directly to the TE 2: Buffer unsolicited result codes in the TA when TA-TE link is reserved and

flush them to the TE after reservation. Otherwise forward them directly to the TE

80

3:

Forward unsolicited result codes directly to the TE. TA-TE link specific

inband used to embed result codes and data when TA is in on-line data mode <mt> : sets the result code indication routing for SMS-DELIVERs. Default is 0. <mt> 0: 1: 2: No SMS-DELIVER indications are routed. SMS-DELIVERs are routed using unsolicited code : +CMTI: ―SM‖,<index> SMS-DELIVERs (except class 2 messages) are routed using unsolicited code:

+CMT: [<alpha>,] <length> <CR> <LF> <pdu> (PDU mode) or +CMT : <oa>,[<alpha>,] <scts>[,<tooa>, <fo>, <pid>, <dcs>, <sca>, <tosca>, <length>] <CR><LF><data> (text mode) 3: Class 3 SMS-DELIVERS are routed directly using code in <mt>=2 ;

Message of other classes result in indication <mt>=1 <bm>: set the rules for storing received CBMs (Cell Broadcast Message)

types depend on its coding scheme, the setting of Select CBM Types (+CSCB command) and <bm>. Default is 0. <bm> 0: 1: No CBM indications are routed to the TE. The CBMs are stored. The CBM is stored and an indication of the memory location is routed to the

customer application using unsolicited result code: +CBMI: ―BM‖, <index> 2: New CBMs are routed directly to the TE using unsolicited result code. <length><CR><LF><pdu> (PDU mode) or <sn>,<mid>,<dcs>,<page>,<pages>(Text mode) <CR><LF> <data>

+CBM: +CBM: 3:

Class 3 CBMs : as <bm>=2. Other classes CBMs : as <bm>=1.

81

<ds> for SMS-STATUS-REPORTs. Default is 0. <ds> 0: 1: No SMS-STATUS-REPORTs are routed. SMS-STATUS-REPORTs are routed using unsolicited code : +CDS :

<length> <CR> <LF> <pdu> (PDU mode) or +CDS : <fo>,<mr>, [<ra>], [<tora>], <scts>,<dt>,<st> (Text mode) 2: SMS-STATUS-REPORTs are stored and routed using the unsolicited result

code : +CDSI: ―SR‖,<index> <bfr> Default is 0. <bfr> 0: TA buffer of unsolicited result codes defined within this command is flushed

to the TE when <mode> 1…3 is entered (OK response shall be given before flushing the codes) 1: TA buffer of unsolicited result codes defined within this command is cleared

when <mode> 1…3 is entered.

82

5.3 MICRO CONTROLLER CODE:
#include <16F877A.h> #device ADC=8 #fuses HS,NOWDT,NOPROTECT #use delay(clock=20000000) #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8) #include <LCD_8_BIT.c> void main() { intj,k; floatt,l; setup_adc_ports(ALL_ANALOG); setup_adc(ADC_CLOCK_DIV_16); SET_TRIS_D( 0x00 ); SET_TRIS_C( 0x00 ); init (); printf(data,"GSM Based Temp"); cmd(0xC0); printf(data,"Monitoring Robot"); delay_ms(20000); cmd(0x01); for(;;) { set_adc_channel(0); //Temperature Reading delay_us(10); j=read_adc(); t=(float)j*5/255; t=t*100; set_adc_channel(1); delay_us(10); k=read_adc(); l=(float)k*5/255; l=l*1000*2;
83

printf(data,"Temp:%fDegC",t); cmd(0xC0); printf(data,"CNG:%f PPM",l); delay_ms(1000); cmd(0x01); if((l>=1000) || (t>=35)) { printf("AT\n\r"); printf(data,"AT"); delay_ms(1000); cmd(0x01); printf("AT+CMGF=1\n\r"); printf(data,"AT+CMGF=1"); delay_ms(1000); cmd(0x01); printf("AT+CMGS="); putc('"'); printf("09347331283"); putc('"'); printf("\n\r"); printf("Temperature: %fDeg C & CNG Concentration %f PPM",t,l); putc(0x1A); printf(data,"CtrlZ"); delay_ms(1000); cmd(0x01); } } }

#define EN_low OUTPUT_LOW(PIN_C2) #define EN_high OUTPUT_HIGH(PIN_C2) #define RW_low OUTPUT_LOW(PIN_C1) #define RW_high OUTPUT_HIGH(PIN_C1) #define RS_low OUTPUT_LOW(PIN_C0)
84

#define RS_high OUTPUT_HIGH(PIN_C0) voidcmd(inti) { OUTPUT_D(i); RS_low; RW_low; EN_high; delay_ms(10); EN_low; } void data(inti) { OUTPUT_D(i); RS_high; RW_low; EN_high; delay_ms(10); EN_low; } voidinit() { // cmd(0x38); delay_ms(2); // 0x38 three times for 4x20 lcd // cmd(0x38); delay_ms(2); cmd(0x38); delay_ms(2); cmd(0x0F); cmd(0x01); cmd(0x06); }

CONCLUSION:
The code is implemented using the software and AT Commands are also given so that the user can receive the notifications.

85

CHAPTER 6 RESULTS
6.1 RESULTS:
The output of the project is determined by the parameters that are obtained by and the user on the cell phone screen through a message.

Fig 6.1 RESULT SCREEN 1

86

Fig 6.2 RESULT SCREEN 2

Fig 6.3 RESULT DISPLAYING ON LCD
87

CHAPTER 7 CONCLUSION

The project we have undertaken helped us gain a better perspective on various aspects related to our course of study as well as practical knowledge of electronic equipments and communication. We became familiar with the software analysis, designing, implementation, testing and maintenance concerned with our project. In this project, we have succeeded to implement the prototype ―Cell phone controlled robot for information retrieving‖ which is a useful looking concept that would help to find the parameters in place where human intervention is not possible. This project has a technology to record and send the parameters to users through cell phones. It also helps to monitor the situation continuously in critical conditions. This is also an inexpensive technology and very user friendly with simple operation which can work more effectively.

88

CHAPTER 8 FUTURE SCOPE
1. IR Sensors:
IR sensors can be used to automatically detect &avoid obstacles if the robot goes beyond line of sight. This avoids damage to the vehicle if we are manoeuvring it from a distant place.

2. Password Protection:
Project can be modified in order to password protect the robot so that it can be operated only if correct password is entered. Either cell phone should be password protected or necessary modification should be made in the assembly language code. This introduces conditioned access &increases security to a great extent.

3. Alarm Phone Dialler:
By replacing DTMF Decoder IC CM8870 by a 'DTMF Transceiver IC‘ CM8880, DTMF tones can be generated from the robot. So, a project called 'Alarm Phone Dialler' can be built which will generate necessary alarms for something that is desired to be monitored (usually by triggering a relay). For example, a high water alarm, low temperature alarm, opening of back window, garage door, etc. When the system is activated it will call a number of programmed numbers to let the user know the alarm has been activated. This would be great to get alerts of alarm conditions from home when user is at work.

4. Adding a Camera:
If the current project is interfaced with a camera e.g. a Webcam robot can be driven beyond line-of-sight &range becomes practically unlimited as GSM networks have a very large range.
89

Bibliography
[1] Muhammad Ali Mazidi and Janice Gallispie Mazidi, ―The 8051 Microcontroller and Embedded systems‖, 3rd Edition, Dorling Kindersley, 2000. [2] [3] [4] Jan Axelson, ―The Microcontroller Idea Book‖, McGraw-Hill, 2000, pg:56-67 Raj kamal, ―Introduction to embedded systems‖,TMH, 2002. Kenneth J.Ayala, ―The 8051 microcontroller‖, Fourth print, Thomson Asia pvt. Ltd, Singapore, 2005. [5] [6] [7] D.Roy Choudhury,Shail B. Jain,‖Linear Integrated Circuits‖,4th Edition,2010. http://www.keil.com/dd/does/datashts/silabs/c8051f34 http://www.rohm.com/httproducts/lsi/eeprom/faq.html

90

APPENDIX
PIC16F877A BLOCK DIAGRAM:

91

REGISTER MAP:

92

DIRECT/IN DIRECT ADDRESSING:

93

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close