cell phone controlled robot for gas detection

Upload: dinnu1014

Post on 04-Jun-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 Cell phone controlled robot for gas detection

    1/93

    1

    TABLE OF CONTENTS

    CHAPTER 1 ............................................................................... 5

    INTRODUCTION ...................................................................... 5

    1.1 GENERAL INTRODUCTION:.............................................................................. 5

    1.1.1 AIM:.................................................................................................................. 5

    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

  • 8/13/2019 Cell phone controlled robot for gas detection

    2/93

    2

    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

  • 8/13/2019 Cell phone controlled robot for gas detection

    3/93

    3

    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

  • 8/13/2019 Cell phone controlled robot for gas detection

    4/93

    4

    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

  • 8/13/2019 Cell phone controlled robot for gas detection

    5/93

    5

    CHAPTER 1

    INTRODUCTION

    1.1GENERAL 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.2INTRODUCTION 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

  • 8/13/2019 Cell phone controlled robot for gas detection

    6/93

    6

    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

  • 8/13/2019 Cell phone controlled robot for gas detection

    7/93

    7

    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 PCs which are used in theApple 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 controllers 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.

  • 8/13/2019 Cell phone controlled robot for gas detection

    8/93

    8

    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 LEDs 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/13/2019 Cell phone controlled robot for gas detection

    9/93

    9

    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 byLeland Anderson.

    Use of Remote Controlled Vehicles During World War II :

  • 8/13/2019 Cell phone controlled robot for gas detection

    10/93

    10

    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 air-

    launched, primarily against ships at sea.

  • 8/13/2019 Cell phone controlled robot for gas detection

    11/93

    11

    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 asMF4. 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 34grid, 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

  • 8/13/2019 Cell phone controlled robot for gas detection

    12/93

    12

    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

  • 8/13/2019 Cell phone controlled robot for gas detection

    13/93

    13

    Table 1.4.1 DTMF Keypad Frequencies (With Sound Clips)

    Table 1.4.2 DTMF Event Frequencies

    1209 Hz 1336 Hz 1477 Hz 1633 Hz

    697 Hz 1 2 3 A770 Hz 4 5 6 B

    852 Hz 7 8 9 C

    941 Hz * 0 # D

    Event Low Freq. High Freq.

    Busy Signal 480 Hz 620 Hz

    Dial Tone 350 Hz 440 Hz

    Ringback Tone(US) 440 Hz 480 Hz

  • 8/13/2019 Cell phone controlled robot for gas detection

    14/93

    14

    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 nowdefunct 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.

  • 8/13/2019 Cell phone controlled robot for gas detection

    15/93

    15

    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:

    Fig 2.1 BLOCK DIAGRAM

    Sensors

    GSM

    Mode

    mController

    LCD

    Cell

    Phone

    Acting as

    a remote

    Cell Phone

    Motors

    Motor Driver

    DTMF

    Decoder

  • 8/13/2019 Cell phone controlled robot for gas detection

    16/93

    16

    2.2.1 BLOCK DIAGRAM DESCRIPTION:

    Block diagram is classified into 3 main parts

    1. Information retrieving2. Controlling the robot3. 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.

  • 8/13/2019 Cell phone controlled robot for gas detection

    17/93

    17

    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.

  • 8/13/2019 Cell phone controlled robot for gas detection

    18/93

  • 8/13/2019 Cell phone controlled robot for gas detection

    19/93

    19

    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.

  • 8/13/2019 Cell phone controlled robot for gas detection

    20/93

    20

    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.

  • 8/13/2019 Cell phone controlled robot for gas detection

    21/93

    21

    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

    http://www.circuitstoday.com/wp-content/uploads/2011/01/PIC-16F877.gif
  • 8/13/2019 Cell phone controlled robot for gas detection

    22/93

    22

    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 3688bit of RAM (data memory), 2568 of EEPROM (data memory),

    and 8k14 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.05.56)volts. High sink/source current (25mA). Commercial, industrial and extended temperature ranges. Low power consumption (

  • 8/13/2019 Cell phone controlled robot for gas detection

    23/93

    23

    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)

  • 8/13/2019 Cell phone controlled robot for gas detection

    24/93

    24

    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

  • 8/13/2019 Cell phone controlled robot for gas detection

    25/93

    25

    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/secondapproximately).

    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

    8K14 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.

  • 8/13/2019 Cell phone controlled robot for gas detection

    26/93

    26

    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 (SFRs).

    RP1:RP0 BANK

    00 0

    01 1

    10 2

    11 3

    Table 3.2

  • 8/13/2019 Cell phone controlled robot for gas detection

    27/93

    27

    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 on-

    chip 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 , PORTC,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).

  • 8/13/2019 Cell phone controlled robot for gas detection

    28/93

    28

    PORT-A RA0 to RA5 6 bit wide

    PORT-B RB-0 to RB-7 8 bit wide

    PORT-C RC-0 to RC-7 8 bit wide

    PORT-D RD-0 to RD-7 8 bit wide

    PORT-E RE-0 to RE-2 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

  • 8/13/2019 Cell phone controlled robot for gas detection

    29/93

    29

    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). 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 ORed together to generate the RB

    port change interrupt with flag bit RBIF (INTCON). This interrupt can wake the

  • 8/13/2019 Cell phone controlled robot for gas detection

    30/93

    30

    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-on-

    change feature. Polling of PORTB is not recommended while using the interrupt-on-

    change 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 pins can be configured with

    normal I2C levels, or with SMBus levels, by using the CKE bit (SSPSTAT).

    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, read-

    modify write instructions (BSF, BCF, XORWF) with TRISC as the destination,

  • 8/13/2019 Cell phone controlled robot for gas detection

    31/93

    31

    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). 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) is set. In this mode, the

    user must make certain that the TRISE bits are set and that the pins areconfigured 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 0s. 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

  • 8/13/2019 Cell phone controlled robot for gas detection

    32/93

    32

    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) SynchronousMaster (half-duplex) SynchronousSlave (half-duplex)

    Bit SPEN (RCSTA) and bits TRISC 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.

  • 8/13/2019 Cell phone controlled robot for gas detection

    33/93

    33

    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

  • 8/13/2019 Cell phone controlled robot for gas detection

    34/93

    34

    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.

  • 8/13/2019 Cell phone controlled robot for gas detection

    35/93

    35

    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 withoutsacrificing 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.

  • 8/13/2019 Cell phone controlled robot for gas detection

    36/93

    36

    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 +85C) 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

  • 8/13/2019 Cell phone controlled robot for gas detection

    37/93

    37

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

    Synchronous Serial Port with two modes:o PI Mastero 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 2 analog comparatorso Programmable on-chip voltage reference moduleo Programmable input multiplexing from device inputs and internal

    VREF

    o Comparator outputs are externally accessible

  • 8/13/2019 Cell phone controlled robot for gas detection

    38/93

    38

    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 14Cat room temperature and 34C over

    a full 55 to +150Ctemperature range. Low cost is assured by trimming

    andcalibration at the wafer level. The LM35s 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.1C in still air. The LM35 israted to operate over a 55 to +150C temperature

    range,while the LM35C is rated for a 40 to +110C range (10with 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

  • 8/13/2019 Cell phone controlled robot for gas detection

    39/93

    39

    Table 3.3 Electrical Characteristics of LM35

  • 8/13/2019 Cell phone controlled robot for gas detection

    40/93

    40

    3.3.1 Features:

    Calibrated directly in Celsius (Centigrade) Linear + 10.0 mV/C scale factor 0.5C accuracy guaranteeable (at +25C) Rated for full 55 to +150C range Suitable for remote applications Low cost due to wafer-level trimming Operates from 4 to 30 volts Less than 60 A current drain Low self-heating, 0.08C in still air Nonlinearity only 14C 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.01C 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 dies temperature will not be

    affected by the air temperature.The TO-46 metal package can also be soldered to a

  • 8/13/2019 Cell phone controlled robot for gas detection

    41/93

    41

    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.

  • 8/13/2019 Cell phone controlled robot for gas detection

    42/93

    42

    3.4 CNG SENSOR:

    CNG Sensor is used in gas leakage detecting equipments

    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

  • 8/13/2019 Cell phone controlled robot for gas detection

    43/93

    43

    3.4.1 Pin Description:

    Pin No.1 - GNDPower Supply Ground

    Pin No.2A.OUTAnalog 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

  • 8/13/2019 Cell phone controlled robot for gas detection

    44/93

    44

    3.4.4 Specifications:

    Target Gas: iso-butane, Propane, LPG

    Detection Range: 100 to 10000 PPM (part per millions)

    Output Voltage Range: 0 to 5 VDC

    Working Voltage : 5 VDC

    Current Consumption : 180 mA

    Warmup Time: 10 Minutes

    Response Time : 10s Seconds

    Resume Time: 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

  • 8/13/2019 Cell phone controlled robot for gas detection

    45/93

    45

    3.4.6 Sensitivity:

    Fig 3.6 SENSITIVITY GRAPH

    Typical Sensitivity Characteristics of sensor

    for several gases in their

    Temperature: 20 deg C

    Humidity: 65%

    Oxygen concentration: 21%

    RL = 10K Ohm

    Ro = resistance at 1000 ppm of LPG in clean air

    Rs= resistance at various concentrations of gases

  • 8/13/2019 Cell phone controlled robot for gas detection

    46/93

    46

    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 0C to 60C 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 and2. 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 = 0 => Command

    RS = 1 => Data

  • 8/13/2019 Cell phone controlled robot for gas detection

    47/93

    47

    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 = 0 => Write

    RW = 1 => 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 => High Impedance

    EN = 1 => 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 = 0 => ACK

  • 8/13/2019 Cell phone controlled robot for gas detection

    48/93

    48

    3.5.2 LCD diagram:

    16 x 2 Char LCD

    R1

    R2

    GND

    Vcc

    VfRSRWEN

    D0D7

    A KD0

    D7

    ACK

    Fig 3.7 LCD DIAGRAM

    Fig 3.8Block Diagram

    Data Lines

    P1.0

    P1.2

    P1.1

    Embedded

    Controller

    LCD

    D0-D7 RS RW EN

  • 8/13/2019 Cell phone controlled robot for gas detection

    49/93

    49

    3.5.3 Hardware connections:

    CONTROLER

    PINS

    LCD PINS PIN NAME WITH FEATURE

    (P1.0) 4 RS (Control Pin)

    (P1.1) 5 RW (Control pin )

    (P1.2) 6 EN (Control pin)

    Port 0 7 to 14 Data Port

    40 15 & 2 Vcc

    20 16 & 1 Gnd

    Table 3.4 CONNECTIONS TO LCD PINS

  • 8/13/2019 Cell phone controlled robot for gas detection

    50/93

    50

    3.5.4 FLOWCHART:

    START

    Configure port pins for all hardware

    connections

    Is LCD Free

    Wait

    o

    Yes

    Clear RS Bit

    Enable LCD

    Send Command

    Disable LCD

    Is Command

    Count Zeroo

    1

  • 8/13/2019 Cell phone controlled robot for gas detection

    51/93

    51

    Is LCD Free

    Wait

    No

    Yes

    Set RS Bit

    Enable LCD

    Send Data

    Disable LCD

    Is Data

    Count ZeroNo

    1

    STOP

  • 8/13/2019 Cell phone controlled robot for gas detection

    52/93

    52

    3.5.5 LCD COMMANDS:

    No. Instruction HexDecimal

    1 Function Set: 8-bit, 1 Line, 5x7 Dots 0x3048

    2 Function Set: 8-bit, 2 Line, 5x7 Dots 0x3856

    3 Function Set: 4-bit, 1 Line, 5x7 Dots 0x2032

    4 Function Set: 4-bit, 2 Line, 5x7 Dots 0x2840

    5 Entry Mode 0x06 6

    6

    Display off Cursor off

    0x08

    8

    (clearing display without clearing DDRAM content)

    7 Display on Cursor on 0x0E14

    8 Display on Cursor off 0x0C12

    9 Display on Cursor blinking 0x0F15

    10 Shift entire display left 0x1824

    12 Shift entire display right 0x1C28

    13 Move cursor left by one character 0x1016

    14 Move cursor right by one character 0x1420

    15 Clear Display (also clear DDRAM content) 0x011

    16 Set DDRAM address or coursor position on display 0x80+add*128+add*

    17

    Set CGRAM address or set pointer to CGRAM

    location 0x40+add**

    64+add**

    Table 3.5 LCD COMMANDS

  • 8/13/2019 Cell phone controlled robot for gas detection

    53/93

    53

    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

  • 8/13/2019 Cell phone controlled robot for gas detection

    54/93

    54

    Fig 3.9 BLOCK DIAGRAM OF DTMF DECODER

  • 8/13/2019 Cell phone controlled robot for gas detection

    55/93

    55

    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

  • 8/13/2019 Cell phone controlled robot for gas detection

    56/93

    56

    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 atfrequencies 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

  • 8/13/2019 Cell phone controlled robot for gas detection

    57/93

    57

    Fig 3.21 L293D MOTOR CONNECTIONS

  • 8/13/2019 Cell phone controlled robot for gas detection

    58/93

    58

    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 backward-

    compatibility 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.

  • 8/13/2019 Cell phone controlled robot for gas detection

    59/93

  • 8/13/2019 Cell phone controlled robot for gas detection

    60/93

    60

    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.

  • 8/13/2019 Cell phone controlled robot for gas detection

    61/93

  • 8/13/2019 Cell phone controlled robot for gas detection

    62/93

  • 8/13/2019 Cell phone controlled robot for gas detection

    63/93

  • 8/13/2019 Cell phone controlled robot for gas detection

    64/93

    64

    3.9.1 BLOCK DIAGRAM:

    Fig 3.22 BLOCK DIAGRAM OF SMPS

    Fig 3.23 SMPS

  • 8/13/2019 Cell phone controlled robot for gas detection

    65/93

    65

    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

  • 8/13/2019 Cell phone controlled robot for gas detection

    66/93

    66

    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.

  • 8/13/2019 Cell phone controlled robot for gas detection

    67/93

    67

    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 LCDfrom 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

  • 8/13/2019 Cell phone controlled robot for gas detection

    68/93

    68

    4.2 Interfacing GSM module and microcontroller:

    Both the microcontroller PIC 16F877A and GSM module SIM 300

    support RS 232 protocol. So we dont 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

  • 8/13/2019 Cell phone controlled robot for gas detection

    69/93

  • 8/13/2019 Cell phone controlled robot for gas detection

    70/93

    70

    Fig 4.4 INTERFACING OF DTMF DECODER AND MOBILE PHONE

  • 8/13/2019 Cell phone controlled robot for gas detection

    71/93

    71

    4.4 Flow chart

    4.5 CONCLUSION:

    The various blocks in the proto type are interfaced and tested. A flow chart is drawnexplaining the working of robot

    Read values from sensors

    Send data to cell phone

    Display on LCD

    T>=40

    Or

    L>=3000

    Yes

    No

  • 8/13/2019 Cell phone controlled robot for gas detection

    72/93

  • 8/13/2019 Cell phone controlled robot for gas detection

    73/93

    73

    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)

  • 8/13/2019 Cell phone controlled robot for gas detection

    74/93

    74

    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 commandsdirectly 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.

    {Argument}{=n}

    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:

  • 8/13/2019 Cell phone controlled robot for gas detection

    75/93

    75

    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 )

    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).

  • 8/13/2019 Cell phone controlled robot for gas detection

    76/93

  • 8/13/2019 Cell phone controlled robot for gas detection

    77/93

    77

    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

  • 8/13/2019 Cell phone controlled robot for gas detection

    78/93

    78

    Defined values :

    The 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 :

    0x01 (SMS-SUBMIT, no validity period)

    (TP TP-MR) 0x03 (Message Reference)

    (TP TP-DA) 0x06 0x91 0x21 0x43 0x65 (destination address +123456)

    (TP TP-PID) 0x00 (Protocol Identifier)

    (TP TP-DCS) 0x00 (Data Coding Scheme : 7 bits alphabet)

    (TP TP-UDL) 0x04 (User Data Length, 4 characters of text)

    TP-UD 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 readfrom the memory selected by +CPMS command.

    Syntax :

    Command syntax : AT+CMGR=

    Response syntax for text mode:

    +CMGR : ,,[,] [,,,

  • 8/13/2019 Cell phone controlled robot for gas detection

    79/93

    79

    ,,,,] (for SMS MS MS-

    DELIVER only)

    +CMGR : ,,[,] [,,,,, [], ,

    ,] (for SMS-SUBMIT only)

    +CMGR : ,,,[],[],,, (for SMS SMS-

    STATUS-REPORT only)

    Response syntax for PDU mode :

    +CMGR: , [] ,

    A message read with status REC UNREAD will be updated in memory with the

    status REC READ.

    Note :

    the 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.

  • 8/13/2019 Cell phone controlled robot for gas detection

    80/93

    80

    Table 5.5 Syntax for AT+CNMI

    Defined values:

    : controls the processing of unsolicited result codes

    Only=2 is supported.

    Any other value for (0,1 or 3) is accepted (return code will be OK), but the

    processing of unsolicited result codes will be the same as with=2.

    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

  • 8/13/2019 Cell phone controlled robot for gas detection

    81/93

    81

    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