int system

download int system

of 46

Transcript of int system

  • 8/7/2019 int system

    1/46

    Table of Contents

    1.Introduction

    2. Literature survey

    3.Formation of the Problem

    4.System specification

    5.Design of solution

    6.Implementation

    7.Results and Discussions

    8.System testing

    9.Conclusion and future scope

    10.References

    List of Figures

    Figure 2.1 A typical embedded system block diagram

    Figure 2.2 The structure of a GSM network

    Figure 4.1: AT89C51 Pin Diagram

    Figure 4.2 Oscillator and timing circuit

    Figure 4.3 SMOD Register

    Figure 4.4 TCON Register

  • 8/7/2019 int system

    2/46

    Figure 4.5 TMOD Register

    Figure 4.6 IE Register

    Figure 4.7 IP Register

    Figure 4.8 PSW Register

    Figure 4.9 PORT3 Alternate Use

    Figure 4.10 Data framing

    Figure 4.11 Data transfer

    Figure 4.12 SCON Register

    Figure 4.13 UART modes

    Figure 4.14Voltage levels for RS232 and TTL

    Figure 4.15 RS232 Pin Diagram

    Figure 4.16 LM35

    Figure 4.17 Gas sensor

    Figure 4.18 Gas sensor circuit.Figure 4.19 PIR sensor Figure 4.20 ADC0808

  • 8/7/2019 int system

    3/46

    Abstract

    Intelligent system for Gas, Human detection and Temperature Monitor control using GSM

    Aim: The main aim of this project is to develop intelligent system for gas, Human detection andTemperature Monitor control using GSM

    Project Description :

    In this project we are connecting different sensors like Temperature, gas and PIR sensor to thecontroller. The Controller continuously monitors the values from all the sensors. If the values are not within the range it will take decision and indicates using GSM network. Any person can receive the SMS sentby GSM modem and further can decide what to do.In this project we are implementing safety and at thesame time security also.The safety is against gas and temperature and security is like to detect human

  • 8/7/2019 int system

    4/46

    being in prohibited areas.This kind of system is useful in areas like industries where we should avoid theexistence of gas and fire at any cost.

    Block diagram:

    Hardware :

    AT89C51

    GSM Modem

    LM35

    Gas and PIR sensors

    Software:

    Keil uVision 2

    8051 programmer

    Application Areas:

    Industrial safety systems

    Security systems

    AT89C51

    LM35

    GAS

    PIR

    SENSOR

    CONTROLLING

    PART

    GSMMODEM

  • 8/7/2019 int system

    5/46

    CHAPTER 1

    Introduction

    1.1Overview

    The overview of this project is to implement intelligent system which can detect temperature,gasand humanbeings using 8051 controller.8051 is very efficient architechture which can be usedfor low end security systems and GSM is widely adapted technology for communication.

    1.2Purpose

    Purpose of the current work is to study and analyse the design of intelligent system with the helpof 8051 controller and GSM technology..

    1.3 Scope

    Current work focuses on how to effectively use GSM technology and 8051 controller for intelligent security systems.

    1.4 Organization of the document

  • 8/7/2019 int system

    6/46

    CHAPTER 2

    Literature survey

    2.1 Embedded Systems

    An embedded system is a special-purpose computer system designed to perform one or a few dedicatedfunctions, often with real-time computing constraints. It is usually embedded as part of a complete deviceincluding hardware and mechanical parts. In contrast, a general-purpose computer, such as a personalcomputer, can do many different tasks depending on programming. Embedded systems control many of the common devices in use today.

  • 8/7/2019 int system

    7/46

    Since the embedded system is dedicated to specific tasks, design engineers can optimize it, reducing thesize and cost of the product, or increasing the reliability and performance. Some embedded systems aremass-produced, benefiting from economics of scale. Physically, embedded systems range from portabledevices such as digital watches and mp4 players, to large stationary installations like traffic lights, factorycontrollers, or the systems controlling nuclear power stations. Complexity varies from low, with a singlemicrocontroller chip, to very high with multiple units, peripherals and networks mounted inside a largechassis or enclosure.

    In general, "embedded system" is not an exactly defined term, as many systems have some element of programmability. For example, handheld computers share some elements with embedded systems suchas the operating systems and microprocessors which power them but are not truly embedded systems,because they allow different applications to be loaded and peripherals to be connected

    2.2 Characteristics

    1. Embedded systems are designed to do some specific task, rather than be a general-purposecomputer for multiple tasks. Some also have real-time performance constraints that must be met,for reasons such as safety and usability; others may have low or no performance requirements,allowing the system hardware to be simplified to reduce costs.

    2. Embedded systems are not always standalone devices. Many embedded systems consist of small,computerized parts within a larger device that serves a more general purpose. For example, thefeatures an embedded system for tuning the strings, but the overall purpose of the Robot Guitar is, of course, to play music. Similarly, an embedded system in automobiles provides a specificfunction as a subsystem of the car itself.

    3. The program instructions written for embedded systems are referred to as firmware, and arestored in read-only memory or flash memory chips. They run with limited computer hardwareresources: little memory, small or non-existent keyboard and/or screen.

    Figure 2.1 A typical embedded system block diagram

    2.3 Micro Controllers

  • 8/7/2019 int system

    8/46

    The micro controller, nowadays, is an indispensable device for electrical/electronic engineers

    and also for technicians in the area, because of its versatility and its enormous application. .Born

    of parallel developments in computer architecture and integrated circuit fabrication ,the

    microprocessor or computer on chip first becomes a commercial reality in 1971.with the

    introduction of the 4 bit 4004 by a small, unknown company by the name of Intel corporation.

    Other, well established, semiconductor firms soon followed Intels pioneering technology so that

    by the late 1970s we could choose from a half dozen or so micro processor typThe 1970s also

    saw the growth of the number of personal computer users from a Handful of hobbyists and

    hackers to millions of business, industrial, governmental, defense, and educational and private

    users now enjoying the advantages of inexpensive computing.

    A bye product of microprocessor development was the micro controller. The same fabrication

    techniques and programming concepts that make possible general-purpose microprocessor also

    yielded the micro controller.

    Among the applications of a micro controller we can mention industrial automation,

    mobile telephones, radios, microwave ovens and VCRs. Besides, the present trend in digital

    electronics is toward restricting to micro controllers and chips that concentrate a great quantity of

    logical circuits, like PLDs (Programmable Logic Devices) and GALs (Gate Array Logic). In

    dedicated systems, the micro controller is the best solution, because it is cheap and easy to

    manage.

    2.4 8051 Micro Controller

    Despite its relatively old age, the 8051 is one of the most popular micro

    controllers in use today. Many derivative micro controllers have since been developed that are

    based on--and compatible with--the 8051. Thus, the ability to program an 8051 is an important

    skill for anyone who plans to develop products that will take advantage of micro controllers.In

    8051 architecture there are so many controllers developed by different semiconductor

    companies.Here we are going to use the controller manufactured by Atmel semiconductors

    which is AT89C51.All the controllers belongs to 8051 architecture follow harward architecture

    and CISC design.

    2.5 GSM Technology

  • 8/7/2019 int system

    9/46

    GSM (Global System for Mobile Communications : originally from Groupe Spcial Mobile ) is

    the most popular standard for mobile telephony systems in the world. The GSM Association, its

    promoting industry trade organization of mobile phone carriers and manufacturers, estimates that

    80% of the global mobile market uses the standard.GSM is used by over 2 billion people across

    more than 212 countries and territories.Its ubiquity enables international roaming arrangements

    between mobile phone operators, providing subscribers the use of their phones in many parts of

    the world. GSM differs from its predecessor technologies in that both signaling and speech

    channels are digital, and thus GSM is considered a second generation (2G) mobile phone system.

    This also facilitates the wide-spread implementation of data communication applications into the

    system.The ubiquity of implementation of the GSM standard has been an advantage to both

    consumers, who may benefit from the ability to roam and switch carriers without replacing

    phones, and also to network operators, who can choose equipment from many GSM equipmentvendors. GSM also pioneered low-cost implementation of the short message service (SMS), also

    called text messaging, which has since been supported on other mobile phone standards as well.

    The standard includes a worldwide emergency telephone number feature.

    Newer versions of the standard were backward-compatible with the original GSM system. For

    example, Release '97 of the standard added packet data capabilities by means of General Packet

    Radio Service(GPRS). Release '99 introduced higher speed data transmission using Enhanced

    Data Rates for GSM Evolution(EDGE).

    In 1982, the European Conference of Postal and Telecommunications Administrations (CEPT)

    created the Groupe Spcial Mobile(GSM) to develop a standard for a mobile telephone system

    that could be used across Europe. In 1987, a memorandum of understanding was signed by 13

    countries to develop a common cellular telephone system across Europe.Finally the system

    created by SINTEF led by Torleiv Maseng was selected.

    In 1989, GSM responsibility was transferred to the European Telecommunications StandardsInstitute (ETSI) and phase I of the GSM specifications were published in 1990. The first GSM

    network was launched in 1991 by Radiolinja in Finland with joint technical infrastructure

    maintenance from Ericsson.By the end of 1993, over a million subscribers were using GSM

    phone networks being operated by 70 carriers across 48 countries.

  • 8/7/2019 int system

    10/46

    GSM is a cellular network, which means that mobile phones connect to it by searching for cells

    in the immediate vicinity. There are five different cell sizes in a GSM networkmacro, micro,

    pico, femto and umbrella cells. The coverage area of each cell varies according to the

    implementation environment. Macro cells can be regarded as cells where the base station antenna

    is installed on a mast or a building above average roof top level. Micro cells are cells whose

    antenna height is under average roof top level; they are typically used in urban areas. Picocells

    are small cells whose coverage diameter is a few dozen metres; they are mainly used indoors.

    Femtocells are cells designed for use in residential or small business environments and connect

    to the service providers network via a broadband internet connection. Umbrella cells are used to

    cover shadowed regions of smaller cells and fill in gaps in coverage between those cells.

    GSM networks operate in a number of different carrier frequency ranges (separated into GSM

    frequency ranges for 2G and UMTS frequency bands for 3G), with most 2G GSM networks

    operating in the 900 MHz or 1800 MHz bands. Where these bands were already allocated, the

    850 MHz and 1900 MHz bands were used instead (for example in Canada and the United

    States). In rare cases the 400 and 450 MHz frequency bands are assigned in some countries

    because they were previously used for first-generation systems.

    Most 3G GSM EDGE networks in Europe operate in the 2100 MHz frequency band.

    Figure 2.2 The structure of a GSM network

  • 8/7/2019 int system

    11/46

    2.6 Intelligent systems

    Now a days intelligent systems became very serious issue at any where.To get good results at

    any time, we need a system which can work at any circumstances.In this project we are going to

    use GSM technology which is widely accepted technology for mobile communications.With theuse of 8051 controller and GSM technogy we are going to implement an intelligent system.

    CHAPTER 3

    Problem formulation

    The problem with the intelligent systems is they should work at any time without any fail.Here inthis project we are going to implement safety against temperature and gas.Along with this humandetection also we are implementing.These things are very important in areas like industrieswhere we should monitor the status of temperature and gas at the same time if it ios restrictedarea we need to monitor the presense of human beings also.

    CHAPTER 4

    System Specification

    4.1 8051 Micro Controller

    The features of the micro controller are as follows:

    Compatible with MCS-51 Products

    4K Bytes of In-System Reprogrammable Flash Memory

    Fully Static Operation: 0 Hz to 24 MHz

    Three-level Program Memory Lock

    128 x 8-bit Internal RAM

  • 8/7/2019 int system

    12/46

    32 Programmable I/O Lines

    Two 16-bit Timer/Counters

    Programmable Serial Channel

    Low-power Idle and Power-down Modes Six Interrupt Sources

    4.2 8051 Description

    The 8051 microcontroller unit is a fast, single-chip, and is a derivative of the 80C51microcontroller family. It is a fully functional 8-bit embedded controller that executes all ASM51

    instructions and has the same instruction set as the 80C51. The 8051 accesses instructions from

    two kinds of program memory, serves software and hardware interrupt, and provide serial

    communications interface and timer systems.

    The 8051 micro controller unit is a high-performance, synthesizable 80C51 function specifically

    designed for reusability. It can operate at frequencies up to 14 MHz in FLEX devices.

    The 8051 consist of the following modules:

    Functional core 8051 mega function

    Program memory Internal_Program_Memory

    Data memory Internal_Data_Memory

    Open-drain I/O pins OPNDRN

    The 8051 is an 8-bit microprocessor originally designed in the 1980's by Intel that has gained

    great popularity since its introduction. Its standard form includes several standard on-chip

    peripherals, including timers, counters, and UART's, plus 4kbytes of on-chip program memory

    and 128 bytes (note: bytes, not Kbytes) of data memory, making single-chip implementations

    possible. Its hundreds of derivatives, manufactured by several different companies (like Philips)

  • 8/7/2019 int system

    13/46

    include even more on-chip peripherals, such as analog-digital converters, pulse-width

    modulators, I2C bus interfaces, etc. Costing only a few dollars per IC, the 8051 is estimated to be

    used in a large percentage (maybe 1/2?) all embedded system products. The 8051 memory

    architecture includes 128 bytes of data memory that are accessible directly by its instructions. A

    32-byte segment of this 128-byte memory block is bit addressable by a subset of the 8051

    instructions, namely the bit-instructions. External memory of up to 64 Kbytes is accessable by a

    special "movx" instruction. Up to 4 Kbytes of program instructions can be stored in the internal

    memory of the 8051, or the 8051 can be configured to use up to 64 Kbytes of external program

    memory The majority of the 8051's instructions are executed within 12 clock cycles.

    A T 8 9 C 5 1

    9

    1 8

    1 9

    2 93 03 1

    12345678

    2 12 2

    2 32 42 52 62 72 8

    1 01 11 21 31 41 51 61 7

    3 93 83 73 63 53 43 3

    3 2

    4 0

    2 0

    R S T

    X T A L 2X T A L 1

    P S E NA L E / P R O G

    E A / V P P

    P 1 . 0P 1 . 1P 1 . 2P 1 . 3P 1 . 4P 1 . 5P 1 . 6P 1 . 7

    P 2 . 0 / A 8P 2 . 1 / A 9P 2 . 2 / A 1 0

    P 2 . 3 / A 1 1P 2 . 4 / A 1 2P 2 . 5 / A 1 3P 2 . 6 / A 1 4P 2 . 7 / A 1 5

    P 3 . 0 / R X DP 3 . 1 / T X DP 3 . 2 / I N T 0P 3 . 3 / I N T 1P 3 . 4 / T 0P 3 . 5 / T 1P 3 . 6 / W RP 3 . 7 / R D

    P 0 . 0 / A D 0P 0 . 1 / A D 1P 0 . 2 / A D 2P 0 . 3 / A D 3P 0 . 4 / A D 4P 0 . 5 / A D 5P 0 . 6 / A D 6P 0 . 7 / A D 7

    V C C

    G N D

  • 8/7/2019 int system

    14/46

    Figure 4.1: AT89C51 Pin Diagram

    A typical 8051 contains CPU with Boolean processor, 5 or 6 interrupts, 16-bit

    timer/counters,programmable full-duplex serial port, 32 I/O lines (four 8-bit ports),RAM and

    ROM. The 8051 architecture is a tad bizarre, but then so are the architectures of most microcontrollers due to their specialization. One vexing problem with the 8051 is its very non-

    orthogonal instruction set - especially the restrictions on accessing the different address spaces.

    However, after some time programming the chip, you can get used to it - maybe even appreciate.

    8051 has four I/O port (P0, P1, P2, and P3), ored in an external ROM or EPROM chip or if

    you are using external RAM chips) you may not use P0 or P2. This is because the 8051 uses

    ports P0 and P2 to address the external memory. Thus if you are using external RAM or code

    memory you may only use ports P1 and P3 for your own use. One strong point of the 8051 is theway it handles interrupts. Most interrupt routines are very short, and generally can fit into the 8-

    byte area. Of course if your interrupt routine is longer, you can still jump to the appropriate

    routine from within the 8 byte interrupt region. The 8051 instruction set is optimized for the one-

    bit operations so often desired in real-world, real-time control applications. The Boolean

    processor provides direct support for bit manipulation. This leads to more efficient programs

    that need to deal with binary input and output conditions inherent in digital-control problems.

    Bit addressing can be used for test pin monitoring or program control flags.

    4.3 The 8051 Oscillator and Clock:

    The heart of the 8051 circuitry that generates the clock pulses by

    which all the internal all internal operations are synchronized. Pins XTAL1 And XTAL2 is

    provided for connecting a resonant network to form an oscillator. Typically a quartz crystal and

    capacitors are employed. The crystal frequency is the basic internal clock frequency of the

    microcontroller. The manufacturers make 8051 designs that run at specific minimum and

    maximum frequencies typically 1 to 16 MHz

  • 8/7/2019 int system

    15/46

    Figure 4.2 Oscillator and timing circuit

    4.4 Types of memory:

    The 8051 have three general types of memory. They are on-chip memory,

    external Code memory and external Ram. On-Chip memory refers to physically existing memory

    on the micro controller itself. External code memory is the code memory that resides off chip.

    This is often in the form of an external EPROM. External RAM is the Ram that resides off chip.

    This often is in the form of standard static RAM or flash RAM.

    4.4.1 Code memory

    Code memory is the memory that holds the actual 8051 programs that is to be run. This

    memory is limited to 64K. Code memory may be found on-chip or off-chip. It is possible to have

    4K of code memory on-chip and 60K off chip memory simultaneously. If only off-chip memory

    is available then there can be 64K of off chip ROM. This is controlled by pin provided as EA

    4.4.2 Internal RAM

    The 8051 have a bank of 128 bytes of internal RAM. The internal RAM is found on-chip.

    So it is the fastest Ram available. And also it is most flexible in terms of reading and writing.

    Internal Ram is volatile, so when 8051 is reset, this memory is cleared. 128 bytes of internal

    memory are subdivided. The first 32 bytes are divided into 4 register banks. Each bank contains

  • 8/7/2019 int system

    16/46

    8 registers. Internal RAM also contains 128 bits, which are addressed from 20h to 2Fh. These

    bits are bit addressed i.e. each individual bit of a byte can be addressed by the user. They are

    numbered 00h to 7Fh. The user may make use of these variables with commands such as SETB

    and CLR.

    4.5 Special Function registered memory:

    Special function registers are the areas of memory that control specific functionality of

    the 8051 micro controller.

    4.5.1. Accumulator (0E0h)

    As its name suggests, it is used to accumulate the results of large no of instructions. It can

    hold 8 bit values.

    4.5.2. B Register (0F0h)

    The B register is very similar to accumulator. It may hold 8-bit value. The b register is

    only used by MUL AB and DIV AB instructions. In MUL AB the higher byte of the product gets

    stored in B register. In div AB the quotient gets stored in B with the remainder in A.

    4.5.3. Stack pointer (81h)

    The stack pointer holds 8-bit value. This is used to indicate where the next value to be

    removed from the stack should be taken from. When a value is to be pushed onto the stack, the8051 first store the value of SP and then store the value at the resulting memory location. When a

    value is to be popped from the stack, the 8051 returns the value from the memory location

    indicated by SP and then decrements the value of SP.

    4.5.4.Data pointer

    The SFRs DPL and DPH work together work together to represent a 16-bit value called

    the data pointer. The data pointer is used in operations regarding external RAM and some

    instructions code memory. It is a 16-bit SFR and also an addressable SFR.

    4.5.5. Program counter

    The program counter is a 16 bit register, which contains the 2 byte address, which tells the

    8051 where the next instruction to execute to be found in memory. When the 8051 is initialized

  • 8/7/2019 int system

    17/46

    PC starts at 0000h. And is incremented each time an instruction is executes. It is not addressable

    SFR.

    4.5.6. PCON (power control, 87h)

    The power control SFR is used to control the 8051s power control modes. Certain

    operation modes of the 8051 allow the 8051 to go into a type of sleep mode which Sconsumes

    much lee power.

    Figure 4.3 SMOD Register

    4.5.7. TCON (timer control, 88h)

    The timer control SFR is used to configure and modify the way in which the 8051s two

    timers operate. This SFR controls whether each of the two timers is running or stopped and

    contains a flag to indicate that each timer has overflowed. Additionally, some non-timer related

    bits are located in TCON SFR. These bits are used to configure the way in which the external

    interrupt flags are activated, which are set when an external interrupt occurs.

    Figure 4.4 TCON Register

    4.5.8. TMOD (Timer Mode, 89h)

    The timer mode SFR is used to configure the mode of operation of each of the two timers.

    Using this SFR your program may configure each timer to be a 16-bit timer, or 13 bit timer, 8-bit

    auto reload timer, or two separate timers. Additionally you may configure the timers to only

    count when an external pin is activated or to count events that are indicated on an external pin.

  • 8/7/2019 int system

    18/46

    Figure 4.5 TMOD Register

    4.5.9. TO (Timer 0 low/high, address 8A/8C h)

    These two SFRs taken together represent timer 0. Their exact behavior depends on how

    the timer is configured in the TMOD SFR; however, these timers always count up. What is

    configurable is how and when they increment in value.

    4.5.10. T1 (Timer 1 Low/High, address 8B/ 8D h)

    These two SFRs, taken together, represent timer 1. Their exact behavior depends on how the

    timer is configured in the TMOD SFR; however, these timers always count up..

    4.5.11. P0 (Port 0, address 90h, bit addressable)

    This is port 0 latch. Each bit of this SFR corresponds to one of the pins on a micro

    controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port

    0 is pin P0.0, bit 7 is pin p0.7. Writing a value of 1 to a bit of this SFR will send a high level on

    the corresponding I/O pin whereas a value of 0 will bring it to low level.

    4.5.12. P1 (port 1, address 90h, bit addressable)

    This is port latch1. Each bit of this SFR corresponds to one of the pins on a micro

    controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port

    0 is pin P1.0, bit 7 is pin P1.7. Writing a value of 1 to a bit of this SFR will send a high level on

    the corresponding I/O pin whereas a value of 0 will bring it to low level

    4.5.13.P2 (port 2, address 0A0h, bit addressable)

    This is a port latch2. Each bit of this SFR corresponds to one of the pins on a micro

    controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port

    0 is pin P2.0, bit 7 is pin P2.7. Writing a value of 1 to a bit of this SFR will send a high level on

    the corresponding I/O pin whereas a value of 0 will bring it to low level.

  • 8/7/2019 int system

    19/46

    4.5.14.P3 (port 3, address B0h, bit addressable)

    This is a port latch3. Each bit of this SFR corresponds to one of the pins on a micro

    controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port

    0 is pin P3.0, bit 7 is pin P3.7. Writing a value of 1 to a bit of this SFR will send a high level on

    the corresponding I/O pin whereas a value of 0 will bring it to low level

    4.5.14.IE (interrupt enable, 0A8h)

    The Interrupt Enable SFR is used to enable and disable specific interrupts. The low 7 bits

    of the SFR are used to enable/disable the specific interrupts, where the MSB bit is used to enable

    or disable all the interrupts. Thus, if the high bit of IE is 0 all interrupts are disabled regardless of

    whether an individual interrupt is enabled by setting a lower bit.

    Figure 4.6 IE Register

    4.5.14.IP (Interrupt Priority, 0B8h)

    The interrupt priority SFR is used to specify the relative priority of each interrupt. On

    8051, an interrupt may be either low or high priority. An interrupt may interrupt interrupts. For e.g., if we configure all interrupts as low priority other than serial interrupt. The serial interrupt

    always interrupts the system, even if another interrupt is currently executing. However, if a serial

    interrupt is executing no other interrupt will be able to interrupt the serial interrupt routine since

    the serial interrupt routine has the highest priority.

    Figure 4.7 IP Register

    4.5.15.PSW (Program Status Word, 0D0h)

    The program Status Word is used to store a number of important bits that are set and

    cleared by 8051 instructions. The PSW SFR contains the carry flag, the auxiliary carry flag, the

  • 8/7/2019 int system

    20/46

    parity flag and the overflow flag. Additionally, it also contains the register bank select flags,

    which are used to select, which of the R register banks currently in use.

    Figure 4.8 PSW Register

    4.5.16.SBUF (Serial Buffer, 99h)

    SBUF is used to hold data in serial communication. It is physically two registers. One is

    writing only and is used to hold data to be transmitted out of 8051 via TXD. The other is read

    only and holds received data from external sources via RXD. Both mutually exclusive registers

    use address 99h.

    4.6. I/O ports:

    One major feature of a microcontroller is the versatility built into the input/output (I/O)

    circuits that connect the 8051 to the outside world. The main constraint that limits numerous

    functions is the number of pins available in the 8051 circuit. The DIP had 40 pins and the

    success of the design depends on the flexibility incorporated into use of these pins. For this

    reason, 24 of the pins may each used for one of the two entirely different functions whichdepend, first, on what is physically connected to it and, then, on what software programs are used

    to program the pins.

    4.6.1.PORT 0

    Port 0 pins may serve as inputs, outputs, or, when used together, as a bi directional low-

    order address and data bus for external memory. To configure a pin as input, 1 must be written

    into the corresponding port 0 latch by the program. When used for interfacing with the external

    memory, the lower byte of address is first sent via PORT0, latched using Address latch enable

    (ALE) pulse and then the bus is turned around to become the data bus for external memory.

    4.6.2.PORT 1

  • 8/7/2019 int system

    21/46

    Port 1 is exclusively used for input/output operations. PORT 1 pins have no dual

    function. When a pin is to be configured as input, 1 is to be written into the corresponding Port 1

    latch.

    4.6.3.PORT 2

    Port 2 may be used as an input/output port. It may also be used to supply a high order

    address byte in conjunction with Port 0 low-order byte to address external memory. Port 2 pins

    are momentarily changed by the address control signals when supplying the high byte a 16-bit

    address. Port 2 latches remain stable when external memory is addressed, as they do not have to

    be turned around (set to 1) for data input as in the case for Port 0.

    4.6.4.PORT 3

    Port 3 may be used to input /output port. The input and output functions can beprogrammed under the control of the P3 latches or under the control of various special function

    registers. Unlike Port 0 and Port 2, which can have external addressing functions and change all

    eight-port b se, each pin of port 3 maybe individually programmed to be used as I/O or as one of

    the alternate functions. The Port 3 alternate uses are:

    Pin (SFR) Alternate UseP3.0-RXD (SBUF) Serial data inputP3.1-TXD (SBUF) Serial data output

    P3.2-INTO 0 (TCON.1) External interrupt 0

    P3.3 - INTO 1 (TCON.3) External interrupt 1

    P3.4 - T0 (TMOD) External Timer 0 input

    P3.5 T1 (TMOD) External timer 1 input

    P3.6 - WR External memory write pulse

    P3.7 - RD External memory read pulse

    Figure 4.9 : Port 3 Alternate Uses

  • 8/7/2019 int system

    22/46

    4.7 INTERRUPTS:

    Interrupts are hardware signals that are used to determine conditions that exist in external

    and internal circuits. Any interrupt can cause the 8051 to perform a hardware call to an interrupt

    handling subroutine that is located at a predetermined absolute address in the program memory.

    Five interrupts are provided in the 8051. Three of these are generated automatically by the

    internal operations: Timer flag 0, Timer Flag 1, and the serial port interrupt (RI or TI) Two

    interrupts are triggered by external signals provided by the circuitry that is connected to the pins

    INTO 0 and INTO1. The interrupts maybe enable or disabled, given priority or otherwise

    controlled by altering the bits in the Interrupt Enabled (IE) register, Interrupt Priority (IP)

    register, and the Timer Control (TCON) register. . These interrupts are mask able i.e. they can be

    disabled. Reset is a non maskable interrupt which has the highest priority. It is generated when a

    high is applied to the reset pin. Upon reset, the registers are loaded with the default values.Each interrupt source causes the program to do store the address in PC onto the stack and

    causes a hardware call to one of the dedicated addresses in the program memory. The appropriate

    memory locations for each for each interrupt are as follows:

    Interrupt AddressRESET 0000IE0 (External interrupt

    0)

    0003

    TF0 (Timer 0 interrupt) 000BIE1 (External interrupt

    1)

    0013

    TF1 (Timer 1 interrupt) 001BSERIAL 0023

    EA disable all interrupts. If EA=0, now interrupt is acknowledged. If EA=1, each interrupt

    source is individually enabled or disabled by setting its enable a lap bit.

  • 8/7/2019 int system

    23/46

    ---- Not implemented, reserved for future use.

    ET2 Enables or disables timer 2 overflow or capturer interrupt.

    ES Enables or disables the serial port interrupt.

    ET1 Enables or disables timer 1 overflow interrupt.

    EX1 Enables or disables timer external interrupt 1.

    ET0 Enables or disables timer 0 overflow interrupt.

    EX0 Enables or disables timer external interrupt 0.

    4.8 Asynchronous serial communication and data framing

    The data coming in the receiving end of the data line in a serial data

    transfer is all 0s and 1s; it is difficult to make sense of the data unless the sender and receiver agree on a set of rules, a protocol, on how the data is packed, how many bits constitute the

    character, and when the data begins and ends.

    4.8.1 Start and Stop bits

    Asynchronous serial data communication is widely used for character orientation transmissions. In the asynchronous method, each character is placed between start

    and stop bits. This is called the framing. In data framing for asynchronous communications, thedata, such as ASCII characters, are packed in between a start and stop bits. The start bit is always

    one-bit but the stop bit can be one or two bits. The start bit is always a 0 and the stop bit is 1.

    4.8.2. Parity Bit

    In some systems in order to maintain data integrity, the parity bit of the character

    byte is included in the data frame. This means that for each character we have a single parity bit

    in addition to start and stop bits. The parity bit is odd or even. In case of odd parity bit the

    number of data bits of a book of including the parity bit, is even.

    4.8.3 Data Transfer rate

  • 8/7/2019 int system

    24/46

    The rate of data transfer in serial data communication is stated in bps or

    it can be called as baud rate. Baud rate is defined as the number of signal changes per second. As

    far as the conductor wire is concerned, the baud rates as bps are the same.

    Figure 4.10: DATA FRAMING

    Figure 4.11: Data Transfer between 89C51 and System

  • 8/7/2019 int system

    25/46

    4.9 Registers used for Communication

    4.9.1. SBUF Register:

    SBUF is an 8 bit register used solely for serial communication in the 8051. For

    byte of data to be transfers via TxD line, it must be placed in SBUF register. SBUF also holds

    the byte of data when it is received by the 8051s RxD line.

    The moment a byte is written into SBUF, it is framed with the start and stop

    bits and transferred serially via TxD line. Similarly when bits are received serially via RxD, the

    8051 defames it by eliminating a byte out of the received, and then placing it in the SBUF.

    4.9 .2.SCON (Serial control register):

    Bit addressableAddress location 98H

    Figure 4.12: SCON register:

    REN- Set or cleared by software to enable or disable reception.

    TB8- Not widely used

    RB8 - Not widely used

    TI - Transmits interrupt flag. Set by hardware at the beginning of the stop bit in mode 1.

    It must be cleared by software

    RI- Received interrupts flag. Set by hardware halfway through the stop bit mode 1. It must

    be cleared by software.

  • 8/7/2019 int system

    26/46

    SM0 SM1 Serial mode 00 0 Synchronous mode0 1 8-bit data, 1 start bit, 1 stop

    bit, variable baud rate1 0 9-bit data, 1 start bit, 1 stop

    bit, fixed baud rate1 1 9-bit data, 1 start bit, 1 stop

    bit, variable baud rate

    Figure 4.13: UART modes

    4.10.MAX232 Driver/Receiver:

    This module is primary of interest for people building their own electronics with an RS-232

    interface. Off-the-shelf computers with RS-232 interfaces already contain the necessary

    electronics, and there is no need to add the circuitry as described here.

    Serial RS-232 (V.24) communication works with voltages (-15V ... -3V for high [sic]) and

    +3V ... +15V for low [sic]) which are not compatible with normal computer logic voltages. On

    the other hand, classic TTL computer logic operates between 0V ... +5V (roughly 0V ... +0.8V

    for low, +2V ... +5V for high). Modern low-power logic operates in the range of 0V ... +3.3V or even lower.

    So, the maximum RS-232 signal levels are far too high for computer logic electronics, and the

    negative RS-232 voltage for high can't be grokked at all by computer logic. Therefore, to receive

    serial data from an RS-232 interface the voltage has to be reduced, and the low and high voltage

    level inverted. In the other direction (sending data from some logic over RS-232) the low logic

    voltage has to be "bumped up", and a negative voltage has to be generated, too.

    RS-232 TTL Logic

    -----------------------------------------------

    -15V ... -3V +2V ... +5V high

  • 8/7/2019 int system

    27/46

    +3V ... +15V 0V ... +0.8V low

    Figure 4.14 Voltage levels for RS232 and TTL

    All this can be done with conventional analog electronics, e.g. a particular power supply and a

    couple of transistors or the once popular 1488 (transmitter) and 1489 (receiver) ICs. However,

    since more than a decade it has become standard in amateur electronics to do the necessary

    signal level conversion with an integrated circuit (IC) from the MAX232 family (typically a

    MAX232A or some clone). In fact, it is hard to find some RS-232 circuitry in amateur

    electronics without a MAX232A or some clone.

    The MAX232 from Maxim was the first IC which in one package contains the necessary drivers

    (two) and receivers (also two), to adapt the RS-232 signal voltage levels to TTL logic. It became

    popular, because it just needs one voltage (+5V) and generates the necessary RS-232 voltage

    levels (approx. -10V and +10V) internally. This greatly simplified the design of circuitry.

    Circuitry designers no longer need to design and build a power supply with three voltages (e.g.

    -12V, +5V, and +12V), but could just provide one +5V power supply, e.g. with the help of a

    simple 78x05 voltage converter.

    The MAX232 has a successor, the MAX232A. The ICs are almost identical, however, the

    MAX232A is much more often used (and easier to get) than the original MAX232, and the

    MAX232A only needs external capacitors 1/10th the capacity of what the original MAX232

    needs.

    It should be noted that the MAX232(A) is just a driver/receiver. It does not generate the

    necessary RS-232 sequence of marks and spaces with the right timing, it does not decode the RS-

    232 signal, it does not provide a serial/parallel conversion. All it does is to convert signal voltage

    levels. Generating serial data with the right timing and decoding serial data has to be done by

    additional circuitry, e.g. by a 16550 UART or one of these small micro controllers (e.g. Atmel

    AVR, Microchip PIC) getting more and more popular.

    The MAX232 and MAX232A were once rather expensive ICs, but today they are cheap. It has

    also helped that many companies now produce clones (ie. Sipex). These clones sometimes need

  • 8/7/2019 int system

    28/46

    different external circuitry, e.g. the capacities of the external capacitors vary. It is recommended

    to check the data sheet of the particular manufacturer of an IC instead of relying on Maxim's

    original data sheet.

    The original manufacturer (and now some clone manufacturers, too) offers a large series of similar ICs, with different numbers of receivers and drivers, voltages, built-in or external

    capacitors, etc. E.g. The MAX232 and MAX232A need external capacitors for the internal

    voltage pump, while the MAX233 has these capacitors built-in. The MAX233 is also between

    three and ten times more expensive in electronic shops than the MAX232A because of its

    internal capacitors. It is also more difficult to get the MAX233 than the garden variety

    MAX232A.A similar IC, the MAX3232 is nowadays available for low-power 3V logic.

    4.11 MAX232Application:

    The MAX232(A) has two receivers (converts from RS-232 to TTL voltage levels) and two

    drivers (converts from TTL logic to RS-232 voltage levels). This means only two of the RS-232

    signals can be converted in each direction. The old MC1488/1498 combo provided four drivers

    and receivers.

    Typically a pair of a driver/receiver of the MAX232 is used for TX and RX and the second one

    for CTS and RTS. There are not enough drivers/receivers in the MAX232 to also connect the

    DTR, DSR, and DCD signals. Usually these signals can be omitted when e.g. communicating

    with a PC's serial interface. If the DTE really requires these signals either a second MAX232 is

    needed, or some other IC from the MAX232 family can be used (if it can be found in consumer

    electronic shops at all). An alternative for DTR/DSR is also given below.Maxim's data sheet

    explains the MAX232 family in great detail, including the pin configuration and how to connect

    such an IC to external circuitry. Exactly to connect the RS-232 signals to the IC. So here is one

    possible example:

    MAX232 Pin Nbr. MAX232 Pin Name Signal Voltage DB9 Pin

  • 8/7/2019 int system

    29/46

    7 T2out CTS RS-232 7

    8 R2in RTS RS-232 8

    9 R2out RTS TTL n/a

    10 T2in CTS TTL n/a

    11 T1in TX TTL n/a

    12 R1out RX TTL n/a

    13 R1in RX RS-232 2

    14 T1out TX RS-232 3

    15 GND GND 0 5

    Figure 4.15 RS232-DB9 pin Diagram

    4.12.LM35

    The LM35 series are precision integrated-circuit temperature sensors, whose output voltage islinearly proportional to the Celsius (Centigrade) temperature.The LM35 thus has an advantage over linear temperature sensors calibrated in Kelvin, as theuser is not required to subtract a large constant voltage from its output to obtain convenientCentigrade scaling. The LM35 does not require any external calibration or trimming to providetypical accuracies of 14C at room temperature and 34C over a full 55 to +150Ctemperature range.

    Low cost is assured by trimming and calibration at the wafer level. The LM35s low outputimpedance,linear output, and precise inherent calibration make interfacing to readout or controlcircuitry especially easy. It can be used with single power supplies, or with plus andminussupplies. As it draws only 60 A from its supply, it hasvery low self-heating, less than 0.1C instill air. The LM35 is rated to operate over a 55 to +150C temperature range,while theLM35C is rated for a 40 to +110C range (10with improved accuracy).

    The LM35 series is available packaged in hermetic TO-46 transistor packages, while theLM35C, LM35CA, and LM35D are also available in the plastic TO-92 transistor package. TheLM35D is also available in an 8-lead surface mount small outline package and a

  • 8/7/2019 int system

    30/46

    plastic TO-220 package.

    4.12.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 rangeSuitable for remote applicationsLow cost due to wafer-level trimmingOperates from 4 to 30 voltsLess than 60 A current drainLow self-heating, 0.08C in still air Nonlinearity only 14C typicalLow impedance output, 0.1 W for 1 mA load

    Figure 4.16 LM35

    4.13.GAS sensor

    The sensor we are going to use is LPG gas sensor MQ-6. This is a simple-to-use liquefied petroleumgas (LPG) sensor, suitable for sensing LPG (composed of mostly propane and butane) concentrations in

    the air. The MQ-6 can detect gas concentrations anywhere from 200 to 10000ppm.

    This sensor has a high sensitivity and fast response time. The sensor's output is an analog resistance. Thedrive circuit is very simple; all you need to do is power the heater coil with 5V, add a load resistance, andconnect the output to an ADC.

    4.13.1.Features

    High sensitivity to LPG, iso-butane, propaneSmall sensitivity to alcohol, smoke.Fast response .Stable and long lifeSimple drive circuit

    They are used in gas leakage detecting equipments in family and industry, are suitable for detecting of LPG, iso-butane, propane, LNG, avoid the noise of alcohol and cooking fumes andcigarette smoke. Sensor composed by micro AL2O3 ceramic tube, Tin Dioxide (SnO2) sensitivelayer, measuring electrode and heater are fixed into a crust made by plastic and stainless steelnet. The heater provides necessary work conditions for work of sensitive components. The

  • 8/7/2019 int system

    31/46

    enveloped MQ-6 have 6 pin ,4 of them are used to fetch signals, and other 2 are used for providing heating current.

    Figure 4.17 Gas sensor

    Figure 4.18 Gas sensor circuit

    4.14 PIR Sensor

    The PIR (Passive Infra-Red) Sensor is a pyroelectric device that detects motion by measuringchanges in the infrared levels emitted by surrounding objects. This motion can be detected bychecking for a high signal on a single I/O pin.

  • 8/7/2019 int system

    32/46

    4.14.1. Features

    Single bit outputSmall size makes it easy to concealCompatible with all Parallax microcontrollers3.3V & 5V operation with

  • 8/7/2019 int system

    33/46

    A/Dconversion techniques. The ADC0808, ADC0809 offers highspeed, high accuracy, minimal

    temperature dependence, excellentlong-term accuracy and repeatability, and consumes minimal

    power. These features make this device ideally suitedto applications from process and machine

    control to consumerand automotive applications. For 16-channel multiplexer with common

    output .

    Figure 4.20 ADC0808

    4.16 LCD

    8 data pins D7:D0

    Bi-directional data/command pins.Alphanumeric characters are sent in ASCII format.

    RS: Register Select

  • 8/7/2019 int system

    34/46

    RS = 0 -> Command Register is selected

    RS = 1 -> Data Register is selected

    R/W: Read or Write

    0 -> Write, 1 -> Read

    E: Enable (Latch data)

    Used to latch the data present on the data pins.

    A high-to-low edge is needed to latch the data.

    VEE : contrast control

    4.17 GSM AT Commands:

    The Initial setup AT commands are

    AT Returns a "OK" to confirm that modem is working

    AT+CPIN="xxxx" To enter the PIN for your SIM ( if enabled )

    AT+CREG? A "0,1" Reply confirms your modem is connected to GSM network

    AT+CSQ Indicates the signal strength, 31.99 is maximum.

    AT+CMGF=1 To format SMS as a TEXT message

    AT+CSCA="+xxxxx" Set your SMS center's number. Check with your provider.

    AT+CMGS="+yyyyy" > Your SMS text message here

    The "+yyyyy" is your receipent's mobile number.

    AT+CNMI=1,2,0,0,0 Set how the modem will response when a SMS is received

    When a new SMS is received by the GSM modem, the DTE will receive the following

    +CMT : "+61xxxxxxxx" , , "04/08/30,23:20:00+40"

    This the text SMS message sent to the modem

  • 8/7/2019 int system

    35/46

    AT+CMGR=3 AT command to send read the received SMS from modem at 3 rd slot.

    +CMGR: "REC READ","+61xxxxxx",,"04/08/28,22:26:29+40"

    This is the new SMS received by the GSM modem

    AT+CMGD=3 To clear the SMS receive memory location in the GSM modem.

    CHAPTER 5

    System Design

    Designing of this system is possible when you select the specific controller to suite.For this weselected 8051 controller.With the help of 8051 controller intelligent system can be developed byconnecting LM35,gas sensor and PIR sensor ant the same time GSM modem also.

    CHAPTER 6

    Implementation

    The applications as discussed in the design are implemented and the source code related to thecurrent work is pasted in the appendix.

    CHAPTER 7

    System Testing

    The system can be tested with the use of KEIL compiler.This one we are using to write programsfor 8051 controller.After writing programs using 8051 programmer we can dump code in to thecontroller.Gsm modem we can connect to the controller by using one UART of 8051.Now thiscontroller will monitor the status the three different sensors and sends message if there is any

    problem.

  • 8/7/2019 int system

    36/46

    CHAPTER 8

    Results and Evaluation

    This chpater lists down the results realized from the practical work and examines whether

    ideas/solution approaches recommended in research are met by the practical implementation.

    Because now a days GSM technology became very popular,here its very easy to use for intelligent systems with the help of 8051 controller.In all low end applications now a days weare using 8051 controllers like industrial automation and data acquisition.

    CHAPTER 9

    Conclusion and Future Scope

    The controller we used having the following featurtes like 8 bit 8051 architecture in a tiny 40 pin

    DIP package,128B RAM and 4kB on-chip Flash Program Memory. For low end applications this

    controller is very easy to use and at the same time GSM also widely accepted protocol for mobile

    communication .

    Future Scope

    In future small scale intelligent systems based on 8051 controllers can be widely used along withthe help of GSM technology.

    References

    [1] 8051 Architecture and Programming by Mazidi

    [2] 8051 Programming by Ayala [3] GSM AT commands user manual

    [4] MAX232 user guide by MAXIM semiconductors

    [5] Wikipedia

    [6]Sparkfun.com

    [7]national.com

  • 8/7/2019 int system

    37/46

    Source code:

    void Delay( unsigned int);

    void Delay_1ms();void Delay_30ms();void lcd_init(); //lcd initialisationvoid lcd_clear(); //clear displayvoid lcd_cmd( unsigned char );void lcd_pos( unsigned char ); //set the lcd addressvoid lcd_char( unsigned char ); //convert the integer voidlcd_print( unsigned char *); //write the string to LCDsbit RS=P3^7; //REg selsbit RW =P3^6; //READ/WRITEsbit EN =P3^5; //ENABLE

    sfr LCD=0xA0;

    sbit adc_a =P1^0;

    sbit adc_b =P1.1;

    sbit adc_c =P1^2;

    sbit adc_start =P1^3;

    sbit adc_ale=P1^4;

    sbit adc_clk =P1^5;

    sbit pir =P1^6;

    //DATA0-DATA7 TO P2unsigned char i;

    void GSM_Init( void );void Modem_send( unsigned char *);void send_sms( unsigned char *,unsigned char *,unsigned char *,unsigned char *,unsigned char

    *);

    void uart_init( void );

    main(){ unsigned char j,key,pw[5];

  • 8/7/2019 int system

    38/46

    lcd_init(); lcd_print( "LCD is Ready" );Delay1(100);uart_init();

    lcd_clear();lcd_print( "uart is Ready" );Delay1(100);

    GSM_Init();Delay1(50);

    lcd_clear();Delay1(100);

    cd_print( "gsm is Ready" );

    while(1)

    {

    lcd_clear();adc_ale=0;adc_start=0adc_a=0;

    adc_b=0;

    adc_c=0;

    Delay1(10);adc_ale=1;Delay1(10);adc_start=1;Delay1(10);adc_ale=0;Delay1(10);adc_start=0;Delay1(10);

    Value=P1;If(value>200){send_sms( "AT+CMGS=\"" ,"\"" ,gas detected);

    }

    adc_a=0;

  • 8/7/2019 int system

    39/46

    adc_b=0;

    adc_c=0;

    Delay1(10);adc_ale=1;Delay1(10);adc_start=1;Delay1(10);adc_ale=0;Delay1(10);adc_start=0;Delay1(10);Value=P1;If(value>50)

    {

    send_sms( "AT+CMGS=\"" ,"\"" ,Temp high);

    }

    If(PIR==1)

    {

    send_sms( "AT+CMGS=\"" ,"\"" ,object detected);

    }

    void MSDelay( unsigned char itime){ unsigned int i,j; for (i=0;i

  • 8/7/2019 int system

    40/46

    unsigned int d; for ( d=0;d

  • 8/7/2019 int system

    41/46

  • 8/7/2019 int system

    42/46

    //===============================================//// Delays ////===============================================//void Delay_1ms(){

    unsigned int d; for ( d=0;d

  • 8/7/2019 int system

    43/46

    void Modem_send( unsigned char *ch){

    unsigned char cha;while (*ch){

    SBUF = *ch;while (TI == 0);TI = 0;ch++;

    }Enter();TI = 0;RI = 0;while (1){

    while (RI == 0);

    RI = 0;cha = SBUF;if (cha == 'O');while (RI == 0);RI = 0;cha = SBUF;if (cha == 'K')

    break ;SBUF = 'A' ;while (TI == 0);TI = 0;SBUF = '/';while (TI == 0);TI = 0;

    }TI = 0;RI = 0;

    }void send_sms( unsigned char *cmd1, unsigned char *cmd2, unsigned char *ch1)

    {unsigned char number[11]={ "9885514414" };unsigned char cha= 'X' ,P;while (*cmd1){

    RI=0;TI=0;SBUF=*cmd1;while (TI==0);TI=0;RI=0;

  • 8/7/2019 int system

    44/46

    cmd1++;}

    for (P=0;P

  • 8/7/2019 int system

    45/46

    TI=0;SBUF=*ch2;while (TI==0);TI=0;RI=0;

    ch2++;}for (P=0;P

  • 8/7/2019 int system

    46/46