gsm controlled home appliances

Embed Size (px)

Citation preview

  • 7/28/2019 gsm controlled home appliances

    1/61[1]

    1

    CHAPTER

    INTRODUCTION

  • 7/28/2019 gsm controlled home appliances

    2/61[2]

    1. INTRODUCTIONNowadays, the communication becomes very simple, fast ,interactive and more compact, that makes the

    global as a small village. So it is very easy of anyone to subscribe in the local or global telecommunication

    network with individual mobile phone device. Mobile devices such as mobile phones, are becoming

    multipurpose devices. These devices are capable of storing data as well as running custom application. As

    more people adopt these devices and begin to use them for personal and business task the need for

    controlling to the access to the data stored within the devices will become vital.

    With todays and tomorrows wireless technology such as Bluetooth and G3, mobile devices will frequently

    be in close and interactive communication. Many environments including offices, meeting rooms,

    automobiles and classrooms already contain many computers and computerised application and the smart

    homes of the nearest future will have ubiquitous embedded computation. PC remote control with small

    device is a challenging topic of mobile computing. Enabling user to use data and function stored in/served

    by their home /office PCs from anywhere with small mobile devices is beneficial because user can access

    the data at any time they want without caring heavy notebook. Furthermore user can control applications

    they want to keep running even when they are out. Several systems and methods have been proposed and

    developed for controlling remote PC with mobile phone.

    This paper represents a simple, practical and very low cost method which applies the SMS technique that is

    already available in all type of mobile phones devices and provide with modern mobile telecommunication

    networks.

    The project is aimed at developing and testing the use of mobile phones to remotely control an appliance

    control system. The microcontroller would then control a device based on the information given to it. The

    proposed solution will need to be easy to use, simple, secure, robust and be useful on most mobile phones.

    To achieve this testing will need to be carried out to create a useful system.

  • 7/28/2019 gsm controlled home appliances

    3/61[3]

    2

    CHAPTER

    EQUIPMENTS USED

  • 7/28/2019 gsm controlled home appliances

    4/61[4]

    2. EQUIPMENTS USED

    2.1 HARDWARE USED:

    AT command supporting GSM mobile phone.

    89S52 MicrocontrollerMax 232 IC.RelaysRelay driver CIRCUITSVoltage regulator 7805.Diode IN4007GSM MODEM

    2.2 SOFTWARE USED:

    Keil u-Vision 3.0. 8051 IDEKeil Software is used provide you with software development tools for 8051 based microcontrollers.

    With the Keil tools, you can generate embedded applications for virtually every 8051 derivative. The

    supported microcontrollers are listed in the -vision

    PRO51 Programmer Software

  • 7/28/2019 gsm controlled home appliances

    5/61[5]

    3

    CHAPTER

    THEORY OF OPERATION

  • 7/28/2019 gsm controlled home appliances

    6/61[6]

    3. THEORY OF OPERATION

    This project consist of two parts one is the hand held device called remote controller, the other one is a base

    station which control the appliances connected to it. The hand held remote controller is a mobile set from

    which a DTMF code can be send over mobile network to another mobile set. The mobile at the receiver end

    decodes the DTMF code and send it to the microcontroller based mother board.

    In this project we interfaced 8051 microcontrollerwith GSM Modem to decode the received message and do

    the required action. The protocol used for the communication between the two is AT command.

    The microcontroller pulls the SMS received by phone, decodes it, recognizes theMobile no. and then

    switches on the relays attached to its port to control the appliances.

  • 7/28/2019 gsm controlled home appliances

    7/61[7]

    4

    CHAPTER

    CIRCUIT DESCRIPTION

  • 7/28/2019 gsm controlled home appliances

    8/61[8]

    4.CIRCUIT DESCRIPTION

    4.1 CIRCUIT DIAGRAM:

    Fig: 4.1: Circuit Diagram.

  • 7/28/2019 gsm controlled home appliances

    9/61[9]

    4.2 POWER SUPPLY:

    4.2.1 Basic Principle Of Transformer

    Two coils are wound over a Core such that they are magnetically coupled. The two coils are known as the

    primary and secondary windings.

    In a transformer, an iron core is used. The coupling between the coils is source of making a path for the

    magnetic flux to link both the coils. A core as in fig.2 is used and the coils are wound on the limbs of the

    core. Because of high permeability of iron, the flux path for the flux is only in the iron and hence the flux

    links both windings. Hence there is very little leakage flux. This term leakage flux denotes the part of the

    flux, which does not link both the coils, i.e., when coupling is not perfect. In the high frequency

    transformers, ferrite core is used. The transformers may be step-up, step-down, frequency matching, sound

    output, amplifier driver etc. The basic principles of all the transformers are same.

    Fig: 4.2: Transformer Winding.

    In this project we use one 5 volt regulated power supply to convert the 220 volt ac in to 5 volt dc with the

    help of the 5 volt regulator circuit. First of all we step down the 220 volt ac into 6 volt ac with the help of

    step down transformer. Step down transformer step down the voltage from 220 volt ac to 9 volt ac. This ac

    is further converted into the dc voltage with the help of the full wave rectifier circuit

    Fig: 4.3: Power Supply Circuit.

  • 7/28/2019 gsm controlled home appliances

    10/61[10]

    Output of the diode is pulsating DC, so to convert the pulsating dc into smooth dc we use electrolytic

    capacitor. Electrolytic capacitor converts the pulsating dc into smooth dc. This DC is further regulated by the

    IC 7805 regulator. IC 7805 regulator provide a regulated 5 volt dc to the microcontroller circuit and LCD

    circuit.

    Pin no 40 of the controller is connected to the positive supply. Pin no 20 is connected to the ground. Pin no 9

    is connected to external resistor capacitor to provide an automatic reset option when power is on.

    4.3 RESET CIRCUITRY:

    Pin no 9 of the controller is connected to the reset circuit. On the circuit we connect one resistor and

    capacitor circuit to provide a reset option when power is on

    As soon as you give the power supply the 8051 doesnt start. You need to restart for the microcontroller tostart. Restarting the microcontroller is nothing but giving a Logic 1 to the reset pin at least for the 2 clock

    pulses. So it is good to go for a small circuit which can provide the 2 clock pulses as soon as the

    microcontroller is powered.

    This is not a big circuit we are just using a capacitor to charge the microcontroller and again discharging via

    resistor.

    Fig: 4.4: Reset Circuit.

  • 7/28/2019 gsm controlled home appliances

    11/61[11]

    4.4 CRYSTAL OSCILLATOR:

    Crystals provide the synchronization of the internal function and to the peripherals. Whenever ever we are

    using crystals we need to put the capacitor behind it to make it free from noises. It is good to go for a 33pf

    capacitor.

    We can also useresonators instead of costly crystal which are low cost and external capacitor can be

    avoidedBut the frequency of the resonators varies a lot. And it is strictly not advised when used for

    communications projects

    Pin no 18 and 19 is connected to external crystal oscillator to provide a clock to the circuit.

    Fig: 4.5: Crystal Oscillator.

    4.4.1 Calculation Of Time:

    The speed with which a microcontroller executes instructions is determined by what is known as the crystal

    speed. A crystal is a component connected externally to the microcontroller. The crystal has different values,

    and some of the used values are 6MHZ, 10MHZ and 11.059MHZ etc. Thus a 10MHZ crystal would pulse at

    a rate of 10,000,000 times per second.

    The time is calculated using the formula

    No of cycles per second = Crystal frequency in HZ / 12.

    For a 10MHZ crystal the number of cycles would be,

    10,000,000/12=833333.33333 cycles.

  • 7/28/2019 gsm controlled home appliances

    12/61[12]

    This means that in one second, the microcontroller would execute 833333.33333 cycles .

    Pin no 1 to pin no 8 is PORT 1 and Pin no 10 to 17 is PORT 3. Pin no 18 and 19 of the IC is connected to the

    external crystal to provide a external clock to run the internal CPU of controller. Pin no 20 is ground pin. Pin

    no 21 to 28 is PORT 2 pins. Pin no 29, 30,31 is not use in this project. We use these pin when we require a

    extra memory for the project. If we internal memory of the 89S51(which is 4k ROM) then we connect pin no

    31 to the positive supply.

    4.5 USE OF DIODES IN RECTIFIER:

    Electric energy is available in homes and industries in India, in the form of alternating voltage. The supply

    has a voltage of 220V (RMS) at a frequency of 50 Hz. In the USA, it is 110V at 60 Hz. For the operation of

    most of the devices in electronic equipment, a dc voltage is needed. For instance, a transistor radio requires a

    dc supply for its operation. Usually, this supply is provided by dry cells. But sometime we use a battery

    eliminator in place of dry cells. The battery eliminator converts the ac voltage into dc voltage and thus

    eliminates the need for dry cells. Nowadays, almost all-electronic equipment includes a circuit that converts

    ac voltage of mains supply into dc voltage. This part of the equipment is called Power Supply. In general, at

    the input of the power supply, there is a power transformer. It is followed by a diode circuit called Rectifier.

    The output of the rectifier goes to a smoothing filter, and then to a voltage regulator circuit. The rectifier

    circuit is the heart of a power supply.

    4.5.1 Rectification:

    Rectification is a process of rendering an alternating current or voltage into a unidirectional one. The

    component used for rectification is called Rectifier. A rectifier permits current to flow only during the

    positive half cycles of the applied AC voltage by eliminating the negative half cycles or alternations of the

    applied AC voltage. Thus pulsating DC is obtained. To obtain smooth DC power, additional filter circuits

    are required.

    A diode can be used as rectifier. There are various types of diodes. But, semiconductor diodes are very

    popularly used as rectifiers. A semiconductor diode is a solid-state device consisting of two elements is

    being an electron emitter or cathode, the other an electron collector or anode. Since electrons in a

    semiconductor diode can flow in one direction only-from emitter to collector- the diode provides the

    unilateral conduction necessary for rectification. Out of the semiconductor diodes, copper oxide and

    selenium rectifier are also commonly used.

    4.5.2 Full Wave Rectifier:

    It is possible to rectify both alternations of the input voltage by using two diodes in the circuit arrangement.

    Assume 6.3 V RMS (18 V p-p) is applied to the circuit. Assume further that two equal-valued series-

    connected resistors R are placed in parallel with the ac source. The 18 V P-P appears across the two resistors

  • 7/28/2019 gsm controlled home appliances

    13/61[13]

    connected between points AC and CB, and point C is the electrical midpoint between A and B. Hence 9 V P-

    P appears across each resistor. At any moment during a cycle of vin,if point A is positive relative to C, point

    B is negative relative to C. When A is negative to C, point B is positive relative to C. The effective voltage

    in proper time phase which each diode "sees" is in Fig. The voltage applied to the anode of each diode is

    equal but opposite in polarity at any given instant.

    When A is positive relative to C, the anode of D1 is positive with respect to its cathode. Hence D1 will

    conduct but D2 will not. During the second alternation, B is positive relative to C. The anode of D2 is

    therefore positive with respect to its cathode and D2 conducts while D1 is cut off.

    There is conduction then by either D1 or D2 during the entire input-voltage cycle.Since the two diodes have

    a common-cathode load resistor RL, the output voltage across RL will result from the alternate conduction

    of D1

    and D2

    . The output waveform vout

    across RL

    , therefore has no gaps as in the case of the half-wave

    rectifier.The output of a full-wave rectifier is also pulsating direct current. In the diagram, the two equal

    resistors R across the input voltage are necessary to provide a voltage midpoint C for circuit connection and

    zero reference. Note that the load resistor RL is connected from the cathodes to this centre reference point C.

    An interesting fact about the output waveform vout is that its peak amplitude is not 9 V as in the case of the

    half-wave rectifier using the same power source, but is less than 4 V. The reason, of course, is that the

    peak positive voltage of A relative to C is 4 V, not 9 V, and part of the 4 V is lost across R.Though the

    full wave rectifier fills in the conduction gaps, it delivers less than half the peak output voltage that results

    from half-wave rectification.

    4.5.3 Bridge Rectifier:

    A more widely used full-wave rectifier circuit is the bridge rectifier. It requires four diodes instead of two,

    but avoids the need for a centre-tapped transformer. During the positive half-cycle of the secondary voltage,

    diodes D2 and D4 are conducting and diodes D1 and D3 are non-conducting. Therefore, current flows

    through the secondary winding, diode D2, load resistor RL and diode D4. During negative half-cycles of the

    secondary voltage, diodes D1 and D3 conduct, and the diodes D2 and D4 do not conduct. The current

    therefore flows through the secondary winding, diode D1, load resistor RL and diode D3. In both cases, the

    current passes through the load resistor in the same direction. Therefore, a fluctuating, unidirectional voltage

    is developed across the load.

    4.6 FILTERATION:

    The rectifier circuits we have discussed above deliver an output voltage that always has the same polarity:but however, this output is not suitable as DC power supply for solid-state circuits. This is due to the

    pulsation or ripples of the output voltage. This should be removed out before the output voltage can be

    supplied to any circuit. This smoothing is done by incorporating filter networks. The filter network consists

  • 7/28/2019 gsm controlled home appliances

    14/61[14]

    of inductors and capacitors. The inductors or choke coils are generally connected in series with the rectifier

    output and the load. The inductors oppose any change in the magnitude of a current flowing through them by

    storing up energy in a magnetic field. An inductor offers very low resistance for DC whereas; it offers very

    high resistance to AC. Thus, a series connected choke coil in a rectifier circuit helps to reduce the pulsations

    or ripples to a great extent in the output voltage. The fitter capacitors are usually connected in parallel with

    the rectifier output and the load. As, AC can pass through a capacitor but DC cannot, the ripples are thus

    limited and the output becomes smoothed. When the voltage across its plates tends to rise, it stores up

    energy back into voltage and current. Thus, the fluctuations in the output voltage are reduced considerable.

    Filter network circuits may be of two types in general:

    4.6.1 Choke Input Filter:

    If a choke coil or an inductor is used as the first - components in the filter network, the filter is called

    choke input filter. The D.C. along with AC pulsation from the rectifier circuit at first passes through the

    choke (L). It opposes the AC pulsations but allows the DC to pass through it freely. Thus AC pulsations are

    largely reduced. The further ripples are by passed through the parallel capacitor C. But, however, a little

    nipple remains unaffected, which are considered negligible. This little ripple may be reduced by

    incorporating a series a choke input filters.

    4.6.2 Capacitor Input Filter:

    If a capacitor is placed before the inductors of a choke-input filter network, the filter is called capacitor input

    filter. The D.C. along with AC ripples from the rectifier circuit starts charging the capacitor C. to about peak

    value. The AC ripples are then diminished slightly. Now the capacitor C, discharges through the inductor or

    choke coil, which opposes the AC ripples, except the DC. The second capacitor C by passes the further AC

    ripples. A small ripple is still present in the output of DC, which may be reduced by adding additional filter

    network in series.

  • 7/28/2019 gsm controlled home appliances

    15/61[15]

    5

    CHAPTER

    MICROCONTROLLER

  • 7/28/2019 gsm controlled home appliances

    16/61[16]

    5.MICROCONTROLLERThe word microprocessor in broader sense is CPU only. The functional blocks like memory and other

    peripherals are to be connected externally to a microprocessor chip to form a complete microprocessor

    board. The system which was built in this way is called a Single board microcomputer. Examples are

    8085, 8086 etc. For the design requirements of automation a device which has all the functional blocks

    inside a IC is required. Therefore, the concept of Single chip microcomputers came into reality, Single

    chip microcomputers and microcontroller.

    Microcontrollers are Single chip microcomputers more suited for control and automation of machines and

    processors. Microcontrollers have central processing units (CPU), memory, I/O ports, timers and counters

    analog to digital converter (ADC), digital to analog converter (DAC), serial ports interrupt logic oscillator

    circuitory and many more functional blocks on chip. These functional blocks may be varied from device to

    device and from one manufacturer to another. All these functional blocks on a Single integrated circuit

    results into reduced size of control board, low power consumption, more reliability and ease of integration

    within an application design.

    The examples of microcontrollers are INTEL, MCS-51 PIC family by microchip ATMEL 89CXX,

    89CXX51. These are the microcontrollers used for general purpose applications. In the sense that they are

    users programmable and has functional blocks suitable to meet a more general design requirement. These

    are general purpose and application specific microcontroller products as well. Application specific standard

    products (ASSPs) are tailored for a specific application, but are not proprietary to a single customer while

    general purpose products are neither applications nor customer specific.

    Today microcontrollers have become an integral part of all automatic and semi-automatic machines. Remote

    controller, hand-held communication devices, dedicated controllers that use microcontrollers have certainly

    improved the functions, operational and performance-based specifications.

    5.1 MCS-51 FAMILY

    For a give application, it is necessary to find out the functional needs and select a suitable microcontroller.

    There are so many families of microcontroller available such as PIC by microchip, INTEL MCS-51 family

    and ATMEL 89XX51 series, ATMEL AVR family.

    MCS-51 and ATMEL 89XX, 89XX51 microcontrollers are 8-bit microcontrollers. MCS-51 is an industry

    standard which supports many microcontroller families like ATMEL 89XX/89XX51, 8031, 8032, 8051,

    8052, 8751, 87512 etc. Generally MCS-51 family members are also referred to as 8051 microcontrollers.

    MCS-51 is the standard family of 8-bit microcontrollers, operating at the frequency of 12 MHz. the design isbased on HNMOS technology. CHMOS versions of these devices are also available and are represented by

    the part number with an additional letter C as 80C51, 87C51 etc. .

  • 7/28/2019 gsm controlled home appliances

    17/61[17]

    Table: 5.1: MCS-51 Family Members

    Device On-chip

    data

    memory

    On-chip

    program

    memory

    No. of 16-bit

    timer/counters

    Digital

    I/O

    Full

    duplex

    serial I/O

    No. of

    pins

    Precision

    on-chip

    analog

    comparator

    AT89C51 128 4K 2 32 1 40 NONE

    AT89C52 256 8K 3 32 1 40 NONE

    AT89C55WD 256 20K 3 32 1 40 NONE

    AT89C1051 64 1K 2 15 1 20 1

    AT89C2051 128 2K 2 15 1 20 1

    AT89C4051 128 4K 2 15 1 20 1

    AT89LV52 256 8K 3 32 1 40 NONE

    Table: 5.2: ATMEL Microcontrollers

    Device On-chip data

    memory

    On-chip

    program

    memory

    No. of 16 bit

    timer/counters

    No. of vectored

    interrupts

    Full duplex

    serial I/O

    8031 128 NONE 2 5 1

    8032 256 NONE 3 6 1

    8051 128 4K ROM 2 5 1

    8052 256 8K ROM 3 6 1

    8751 128 4K EPROM 2 5 1

    8752 256 8K EPROM 3 6 1

  • 7/28/2019 gsm controlled home appliances

    18/61[18]

    ATMEL family microcontrollers are 20 to 40 pin devices and these devices support fully static operation

    from 0 to 24 MHz. the low frequency operation is very important when the power consumption is to be kept

    low. Also ATMEL 89CXX devices support low voltage operation.

    5.2 FEATURES OF 8051 AND 89C51

    5.2.1 Salient Features Of 8051 Microcontroller:

    1. MCS-51 is a family of 8-bit microcontroller by INTEL, designed around HMOS technology.

    2. Operating frequency is 12 MHz.

    3. Available in ROM/EPROM/EEPROM versions.

    4. Separate 64K program and 64k data memory.

    5. Multiply and divide instructions available.

    6. Has a Boolean processor and supports bitwise operator.7. Available in CHMOS versions also.

    8. 32 I/O can either be used as for 8-bit ports or 32-bit I/O.

    9. 16-bit address bus multiplexed with port 0 and port 2. Port 0 is also data bus.

    5.2.2 Salient Features Of 89C51 Microcontroller:

    1.Compatible with MCS-51 Products

    2. 4K Bytes of In-System Reprogrammable Flash Memory

    3. Endurance: 1,000 Write/Erase Cycles

    4. Fully Static Operation: 0 Hz to 24 MHz

    5. Three-Level Program Memory Lock

    6. 128 x 8-Bit Internal RAM

    7. 32 Programmable I/O Lines

    8. Two 16-Bit Timer/Counters

    9. Six interrupt services

    10. Programmable Serial Channel

    11.Low Power Idle and Power Down Modes

  • 7/28/2019 gsm controlled home appliances

    19/61[19]

    5.3 PIN CONFIGURATION AND DESCRIPTION:

    Fig: 5.1: Pin Configuration.

    VCC

    Supply voltage.

    GND

    Ground.

    Port 0

    Port 0 is an 8-bit open drain bidirectional I/O port. As an output port each pin can sink eight TTL inputs.

    When 1s are written to port 0 pins, the pins can be used as high impedance inputs. Port 0 may also be

    configured to be the multiplexed low order address/data bus during accesses to external program and data

    memory. In this mode P0 has internal pull-ups. Port 0 also receives the code bytes during Flash

    programming, and outputs the code bytes during program verification.

  • 7/28/2019 gsm controlled home appliances

    20/61[20]

    External pull-ups are required during program verification.

    Port 1

    Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output buffers can sink/source four

    TTL inputs. When 1s are written to Port 1 pins they are pulled high by the internal pull-ups and can be used

    as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the

    internal pull-ups. Port 1 also receives the low-order address bytes during Flash programming and

    verification.

    Port 2

    Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2 output buffers can sink/source four

    TTL inputs. When 1s are written to Port 2 pins they are pulled high by the internal pull-ups and can be used

    as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the

    internal pull-ups. Port 2 emits the high-order address byte during fetches from external program memory and

    during accesses to external data memory that uses 16-bit addresses (MOVX @ DPTR). In this application it

    uses strong internal pull-ups when emitting 1s. During accesses to external data memory that uses 8-bit

    addresses (MOVX @ RI); Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives

    the high-order address bits and some control signals during Flash programming and verification.

    Port 3

    Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output buffers can sink/source four

    TTL inputs. When 1s are written to Port 3 pins they are pulled high by the internal pull-ups and can be used

    as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the

    pull-ups. Port 3 also serves the functions of various special features of the AT89C51 as listed below:

    Port 3 also receives some control signals for Flash programming and verification.

    RST

    Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device.

    ALE/PROG

    Address Latch Enable output pulse for latching the low byte of the address during accesses to external

    memory. This pin is also the program pulse input (PROG) during Flash programming. In normal operation

    ALE is emitted at a constant rate of 1/6 the oscillator frequency, and may be used for external timing or

    clocking purposes. Note, however, that one ALE pulse is skipped during each access to external Data

    Memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set,

    ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting

    the ALE-disable bit has no effect if the microcontroller is in external execution mode.

  • 7/28/2019 gsm controlled home appliances

    21/61[21]

    PSEN

    Program Store Enable is the read strobe to external program memory.

    Port Pin Alternate Functions

    P3.0 RXD (serial input port)

    P3.1 TXD (serial output port)

    P3.2 INT0 (external interrupt 0)

    P3.3 INT1 (external interrupt 1)

    P3.4 T0 (timer 0 external input)

    P3.5 T1 (timer 1 external input)

    P3.6 WR (external data memory write strobe)

    P3.7 RD (external data memory read strobe)

    When the AT89C51 is executing code from external program memory, PSEN is activated twice each

    machine cycle, except that two PSEN activations are skipped during each access to external data memory.

    EA/VPP

    External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from

    external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is

    programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program

    executions. This pin also receives the 12-volt programming enable voltage (VPP) during Flash

    programming, for parts that require 12-volt VPP.

    XTAL1

    Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

    XTAL2

    Output from the inverting oscillator amplifier

  • 7/28/2019 gsm controlled home appliances

    22/61[22]

    6

    CHAPTER

    LCD

  • 7/28/2019 gsm controlled home appliances

    23/61[23]

    6. LCD

    A liquid-crystal display (LCD) is a flat panel display, electronic visual display, orvideo display that uses

    the light modulating properties ofliquid crystals. Liquid crystals do not emit light directly.

    LCDs are used in a wide range of applications including computer monitors, televisions, instrumentpanels, aircraft cockpit displays, and signage. They are common in consumer devices such as video players,

    gaming devices, clocks, watches, calculators, and telephones, and have replaced cathode ray tube (CRT)

    displays in most applications. They are available in a wider range of screen sizes than CRT and plasma

    displays, and since they do not use phosphors, they do not sufferimage burn-in. LCDs are, however,

    susceptible to image persistence.

    Fig: 6.1: LCD 2x16 Module.

    Frequently, an 8051 program must interact with the outside world using input and output devices that

    communicate directly with a human being. One of the most common devices attached to an 8051 is an LCD

    display. Some of the most common LCDs connected to the 8051 are 16x2 and 20x2 displays. This means 16characters per line by 2 lines and 20 characters per line by 2 lines, respectively.

    http://en.wikipedia.org/wiki/Flat_panel_displayhttp://en.wikipedia.org/wiki/Electronic_visual_displayhttp://en.wikipedia.org/wiki/Video_displayhttp://en.wikipedia.org/wiki/Liquid_Crystalshttp://en.wikipedia.org/wiki/Computer_monitorhttp://en.wikipedia.org/wiki/Televisionhttp://en.wikipedia.org/wiki/Instrument_panelhttp://en.wikipedia.org/wiki/Instrument_panelhttp://en.wikipedia.org/wiki/Flight_instrumentshttp://en.wikipedia.org/wiki/Clockhttp://en.wikipedia.org/wiki/Watchhttp://en.wikipedia.org/wiki/Calculatorhttp://en.wikipedia.org/wiki/Telephonehttp://en.wikipedia.org/wiki/Cathode_ray_tubehttp://en.wikipedia.org/wiki/Plasma_displayhttp://en.wikipedia.org/wiki/Plasma_displayhttp://en.wikipedia.org/wiki/Screen_burn-inhttp://en.wikipedia.org/wiki/Image_persistencehttp://en.wikipedia.org/wiki/Image_persistencehttp://en.wikipedia.org/wiki/Screen_burn-inhttp://en.wikipedia.org/wiki/Plasma_displayhttp://en.wikipedia.org/wiki/Plasma_displayhttp://en.wikipedia.org/wiki/Cathode_ray_tubehttp://en.wikipedia.org/wiki/Telephonehttp://en.wikipedia.org/wiki/Calculatorhttp://en.wikipedia.org/wiki/Watchhttp://en.wikipedia.org/wiki/Clockhttp://en.wikipedia.org/wiki/Flight_instrumentshttp://en.wikipedia.org/wiki/Instrument_panelhttp://en.wikipedia.org/wiki/Instrument_panelhttp://en.wikipedia.org/wiki/Televisionhttp://en.wikipedia.org/wiki/Computer_monitorhttp://en.wikipedia.org/wiki/Liquid_Crystalshttp://en.wikipedia.org/wiki/Video_displayhttp://en.wikipedia.org/wiki/Electronic_visual_displayhttp://en.wikipedia.org/wiki/Flat_panel_display
  • 7/28/2019 gsm controlled home appliances

    24/61[24]

    6.1 FEATURES OF LCD:

    1. The declining prices of LCDs.

    2. The ability to display numbers, characters, and graphics. This is in contrast to LED Seven display,which

    are limited to numbers and a few characters.

    3. Incorporation of a refreshing controller into the LCD, thereby relieving the CPU of the task of refreshing

    the LCD. In contrast, the LED Seven Segment Displays must be refreshed by the CPU (or in some otherway) to keep displaying data, in case of multiplexed displays.

    4. Ease of programming for characters and graphics.

    6.2 PIN DETAILS OF 2X16 MODULE:

    PIN

    NO.

    NAME FUNCTION

    1 VSS GROUND VOLTAGE

    2 VCC +5V

    3 VEE CONSTANT VOLTAGE

    4 RS REGISTER SELECT

    0 = INSTRUCTION REGISTER

    1 = DATA REGISTER

    5 R/W READ/WRITE, TO CHOOSE READ OR WRITE MODE

    0 = WRITE MODE

    1 = READ MODE

    6 E ENABLE

    0 = START TO LATCH DATA TO LCD SCREEN

    1 = DISABLE

    7 DB0 DATA BIT 0(LSB)

    8 DB1 DATA BIT 1

  • 7/28/2019 gsm controlled home appliances

    25/61[25]

    9 DB2 DATA BIT 2

    10 DB3 DATA BIT 3

    11 DB4 DATA BIT 4

    12 DB5 DATA BIT 5

    13 DB6 DATA BIT 6

    4 DB7 DATA BIT 7(MSB)

    15 BPL BACK PLANE LIGHT+5V(OPTIONAL)

    16 GND GROUND VOLTAGE (OPTIONAL)

    Table: 6.1: Pin Details Of LCD.

    6.3 PIN DESCRIPTION OF LCD:

    1.DataLines:

    The LCD Character standard requires 3 control lines. You may select whether the LCD is to operate with a

    4-bit data bus or an 8-bit data bus. If a 4-bit data bus is used the LCD will require a total of 7 data lines (3

    control lines plus the 4 lines for the data bus). If an 8-bit data bus is used the LCD will require a total of 11

    data lines (3 control lines plus the 8 lines for the data bus).

    DB0DB7:

    The 8- bit data pins, D0-D7, are used to send information to the LCD or read the contents of the LCDs

    internal registers.In the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3, DB4,

    DB5, DB6, and DB7.

    2.ControlLines:

    The three control lines are referred to as EN, RS, and RW.

    (A)ENLine:The EN line is called "Enable.". This control line is used to tell the LCD that you are sending it

    data. The enable pin is used by the LCD to latch information presented to its data pins. When data is

    supplied to data pins, a hightolow pulse must be applied to this pin in order for the LCD to latch in the

    data present at the data pins. This pulse must be a minimum of 450 ns wide.EN line is high (1) and wait for

    the minimum amount of time required by the LCD datasheet (this varies from LCD to LCD), and end by

    bringing it low (0) again.

  • 7/28/2019 gsm controlled home appliances

    26/61[26]

    (B)RS registerLine:

    The RS line is the "Register Select" line. There are two very important registers inside the LCD. The RS pin

    is used for their follows. IF RS=0,the instruction command code register is selected, allowing the user to

    send a command such as clear display, cursor at home, etc. If RS=1 the data register is selected allowing the

    user to send data to be displayed on the LCD.

    For example, to display the letter "T" on the screen you would set RS high.

    (C)R/WLINE:

    The RW line is the "Read/Write" control line. When RW is low (0), the information on the data bus is being

    written to the LCD. When RW is high (1), the program is effectively querying (or reading) the LCD. Only

    one instruction ("Get LCD status") is a read command. All others are write commands--so RW will almost

    always be low.

    CODE

    (HEX)

    Command to LCD register

    1 Clear display screen

    2 Return home

    3 Decrement cursor (shift cursor to left)

    4 Increment cursor (shift cursor to right)

    5 Shift display right

    6 Shift display left

    7 Display off, cursor off

    8 Display off, cursor off

    9 Display off, cursor off

    A Display off cursor on

    C Display on cursor off

  • 7/28/2019 gsm controlled home appliances

    27/61[27]

    E Display on cursor blinking

    F Display on cursor blinking

    10 Shift cursor position to left

    14 Shift cursor position to right

    18 Shift the entire display to left

    1C Shift the entire display to right

    80 Force cursor to beginning of 1st line

    0C0 Force cursor to beginning of 2nd line

    38 2 lines and 5 X 7 matrix

    Table: 6.2: Codes Of LCD.

    6.4 PROGRAMMING:

    The LCD interprets and executes our command at the instant the EN line is brought low. If you never bring

    EN low, your instruction will never be executed. Additionally, when you bring EN low and the LCD

    executes your instruction, it requires a certain amount of time to execute the command. The time it requires

    to execute an instruction depends on the instruction and the speed of the crystal which is attached to the

    44780's oscillator input.

    6.4.1 Checking The Busy Status Of The LCD:

    As previously mentioned, it takes a certain amount of time for each instruction to be executed by the LCD.The delay varies depending on the frequency of the we will use this code every time we send an instruction

    to

    WAIT_LCD:

    SETB EN : Start LCD command

    CLR RS : It's a command

    SETB RW :It's a read commandMOV DATA,#0FFh : Set all pins to FF initially

    MOV A,DATA : Read the return value

    JB ACC.7,WAIT_LCD : If bit 7 high, LCD still busy

  • 7/28/2019 gsm controlled home appliances

    28/61[28]

    CLR EN : Finish the command

    CLR RW : Turn off RW for future commands

    RET

    Thus, our standard practice will be to send an instruction to the LCD and then call ourWAIT_LCD routine

    to wait until the instruction is completely executed by the LCD. This will assure that our program gives the

    LCD the time it needs to execute instructions and also makes our program compatible with any LCD,

    regardless of how fast or slow it is.

    Programming Tip: The above routine does the job of waiting for the LCD, but were it to be used in a real

    application a very definite improvement would need to be made: as written, if the LCD never becomes "not

    busy" the program will effectively "hang," waiting for DB7 to go low. If this never happens, the program

    will freeze. Of course, this should never happen and wont happen when the hardware is working properly.

    But in a real application it would be wise to put some kind of time limit on the delay--for example, a

    maximum of 256 attempts to wait for the busy signal to go low. This would guarantee that even if the LCD

    hardware fails, the program would not lock up.

    6.4.2 INITIALIZING THE LCD:

    SETB EN

    CLR RS

    MOV DATA,#38hCLR EN

    LCALL WAIT_LCD

    Programming Tip: The LCD command 38h is really the sum of a number of option bits. The instruction

    itself is the instruction 20h ("Function set"). However, to this we add the values 10h to indicate an 8-bit data

    bus plus 08h to indicate that the display is a two-line display.

    We've now sent the first byte of the initialization sequence. The second byte of the initialization sequence is

    the instruction 0Eh. Thus we must repeat the initialization code from above, but now with the instruction.

    Thus the next code segment is:

    SETB EN

    CLR RS

    MOV DATA,#0Eh

    CLR EN

    LCALL WAIT_LCD

    Programming Tip: The command 0Eh is really the instruction 08h plus 04h to turn the LCD on. To that an

    additional 02h is added in order to turn the cursor on.

  • 7/28/2019 gsm controlled home appliances

    29/61[29]

    The last byte we need to send is used to configure additional operational parameters of the LCD. We must

    send the value 06h.

    SETB EN

    CLR RS

    MOV DATA,#06h

    CLR EN

    LCALL WAIT_LCD

    Programming Tip: The command 06h is really the instruction 04h plus 02h to configure the LCD such that

    every time we send it a character, the cursor position automatically moves to the right.

    So, in all, our initialization code is as follows:

    INIT_LCD:

    SETB EN

    CLR RS

    MOV DATA,#38h

    CLR EN

    LCALL WAIT_LCD

    SETB EN

    CLR RS

    MOV DATA,#0Eh

    CLR EN

    LCALL WAIT_LCD

    SETB EN

    CLR RS

    MOV DATA,#06h

    CLR EN

    LCALL WAIT_LCD

    RET

    Having executed this code the LCD will be fully initialized and ready for us to send display data to it.

    CLEARING THE DISPLAY:

    When the LCD is first initialized, the screen should automatically be cleared by the 447e, it's a good idea to

    make it a subroutine:

    CLEAR_LCD:

  • 7/28/2019 gsm controlled home appliances

    30/61[30]

    SETB EN

    CLR RS

    MOV DATA,#01h

    CLR EN

    LCALL WAIT_LCD

    RET

    How that we've written a "Clear Screen" routine, we may clear the LCD at any time by simply executing an

    LCALL CLEAR_LCD.

    Programming Tip: Executing the "Clear Screen" instruction on the LCD also positions the cursor in the

    upper left-hand corner as we would expect.

    WRITING TEXT TO THE LCD:

    Now we get to the real meat of what we're trying to do: All this effort is really so we can display text on the

    LCD. Really, we're pretty much done.

    Once again, writing text to the LCD is something we'll almost certainly want to do over and over--so let's

    make it a subroutine.

    WRITE_TEXT:

    SETB EN

    SETB RS

    MOV DATA,A

    CLR EN

    LCALL WAIT_LCD

    RET

    The WRITE_TEXT routine that we just wrote will send the character in the accumulator to the LCD which

    will, in turn, display it. Thus to display text on the LCD all we need to do is load the accumulator with the

    byte to display and make a call to this routine. Pretty easy, huh?

    A "HELLO WORLD" PROGRAM:

    Now that we have

    LCALL INIT_LCD

    LCALL CLEAR_LCD

    MOV A,#'H'

    LCALL WRITE_TEXT

  • 7/28/2019 gsm controlled home appliances

    31/61[31]

    MOV A,#'E'

    LCALL WRITE_TEXT

    MOV A,#'L'

    LCALL WRITE_TEXT

    MOV A,#'L'

    LCALL WRITE_TEXT

    MOV A,#'O'

    LCALL WRITE_TEXT

    MOV A,#' '

    LCALL WRITE_TEXT

    MOV A,#'W'

    LCALL WRITE_TEXT

    MOV A,#'O'

    LCALL WRITE_TEXT

    MOV A,#'R'

    LCALL WRITE_TEXT

    MOV A,#'L'

    LCALL WRITE_TEXT

    MOV A,#'D'

    LCALL WRITE_TEXT

    The above "Hello World" program should, when executed, initialize the LCD, clear the LCD screen, and

    display "Hello World" in the upper left-hand corner of the display.

    6.4.3 CURSOR POSITIONING:

    The

    Fig 6.2: Cursor Positioning.

    Thus, the

    SETB EN

    CLR RS

    MOV DATA,#0C4h

    CLR EN

    LCALL WAIT_LCD

  • 7/28/2019 gsm controlled home appliances

    32/61[32]

    The above code will position the cursor on line 2, character 10. To display "Hello" in the upper left-hand

    corner with the word "World" on the second line at character position 10 just requires us to insert the above

    code into our existing "Hello World" program. This results in the following:

    LCALL INIT_LCD

    LCALL CLEAR_LCD

    MOV A,#'H'

    LCALL WRITE_TEXT

    MOV A,#'E'

    LCALL WRITE_TEXT

    MOV A,#'L'

    LCALL WRITE_TEXT

    MOV A,#'L'

    LCALL WRITE_TEXTMOV A,#'O'

    LCALL WRITE_TEXT

    SETB EN

    CLR RS

    MOV DATA,#0C4h

    CLR EN

    LCALL WAIT_LCD

    MOV A,#'W'

    LCALL WRITE_TEXT

    MOV A,#'O'

    LCALL WRITE_TEXT

    MOV A,#'R'

    LCALL WRITE_TEXT

    MOV A,#'L'

    LCALL WRITE_TEXT

    MOV A,#'D'

    LCALL WRITE_TEXT

  • 7/28/2019 gsm controlled home appliances

    33/61[33]

    7

    CHAPTER

    PROGRAM

  • 7/28/2019 gsm controlled home appliances

    34/61[34]

    7.PROGRAM

    $include (reg51xa.INC)

    LCD_DATA equ P0

    lcd_rs bit P2.7

    lcd_rw bit P2.6

    lcd_en bit P2.5

    cmd0 equ 26h

    cmd1 equ 27h

    cmd2 equ 28h

    cmd3 equ 29h

    cmd4 equ 2ah

    cmd5 equ 2bh

    temp equ 2ch

    temp_data equ 2dh

    flag0 bit 00h

    out1 bit p1.3

    out2 bit p1.4

    out3 bit p1.5

    out4 bit p1.6

    out5 bit p1.7

    ok3 bit p2.4

    org 0000h

    ljmp main

    org 0003h

  • 7/28/2019 gsm controlled home appliances

    35/61[35]

    reti

    org 000bh

    reti

    org 0013h

    reti

    org 001bh

    reti

    org 0023h

    reti

    main:

    lcall DELAY11

    mov psw,#00h

    mov sp,#070h

    mov tmod,#20h

    mov tcon,#00h

    mov scon,#050h

    anl pcon,#7fh

    mov ie,#90h

    mov ip,#00h

    mov p0,#0ffh

    mov p1,#0ffh

    mov p2,#0ffh

    mov p3,#0ffh

    mov cmd0,#00h

    mov cmd1,#00h

    mov cmd2,#00h

  • 7/28/2019 gsm controlled home appliances

    36/61[36]

    mov cmd3,#00h

    mov cmd4,#00h

    mov cmd5,#00h

    mov r1,#2fh

    mov r4,#15h

    setb buz

    setb ok0

    setb ok1

    setb ok2

    setb ok3

    clr lcd_rs

    clr lcd_rw

    clr lcd_en

    lcall INIT_LCD

    lcall CLR_LCD

    mov dptr,#MSG1

    lcall LINE_1

    lcall LINE_2

    main_lp1:

    mov r1,#2fh

    mov r4,#11h

    blank0:mov r1,#20h

    inc r1

    djnz r4,blank0

    mov r1,#2fh

    mov r4,#11h

  • 7/28/2019 gsm controlled home appliances

    37/61[37]

    sync_cmd1:

    mov a,#'A'

    lcall TRANS

    mov a,#'T'

    lcall TRANS

    mov a,#13d

    lcall TRANS

    clr ok0

    clr buz

    lcall DELAY11

    lcall DELAY11

    setb buz

    lcall DELAY11

    lcall DELAY11

    setb ok0

    text_cmd1:

    mov a,#'A'

    lcall TRANS

    mov a,#'T'

    lcall TRANS

    mov a,#'+'

    lcall TRANS

    mov a,#'C'

    lcall TRANS

    mov a,#'M'

    lcall TRANS

  • 7/28/2019 gsm controlled home appliances

    38/61[38]

    mov a,#'G'

    lcall TRANS

    mov a,#'F'

    lcall TRANS

    mov a,#'='

    lcall TRANS

    mov a,#'1'

    lcall TRANS

    mov a,#13d

    lcall TRANS

    clr buz

    lcall DELAY11

    lcall DELAY11

    setb buz

    lcall DELAY11

    lcall DELAY11

    setb ok1

    delet_cmd1:

    mov a,#'A'

    lcall TRANS

    mov a,#'T'

    lcall TRANS

    mov a,#'+'

    lcall TRANS

    mov a,#'C'

    lcall TRANS

  • 7/28/2019 gsm controlled home appliances

    39/61[39]

    mov a,#'M'

    lcall TRANS

    mov a,#'G'

    lcall TRANS

    mov a,#'D'

    lcall TRANS

    lcall TRANS

    mov a,#'1'

    lcall TRANS

    mov a,#13d

    lcall TRANS

    lcall DELAY11

    lcall DELAY11

    setb buz

    lcall DELAY11

    lcall DELAY11

    setb ok2

    mov r1,#2fh

    mov r4,#11h

    blank10: mov r1,#20h

    inc r1

    djnz r4,blank10

    mov r1,#2fh

    mov r4,#11h

    setb ea

  • 7/28/2019 gsm controlled home appliances

    40/61[40]

    keyboard:

    jnb flag0,nxt11_lp2

    clr flag0

    mov r1,#2fh

    mov r4,#11h

    blank1:mov r1,#20h

    inc r1

    djnz r4,blank1

    mov r1,#2fh

    mov r4,#11h

    ljmp data_recv

    nxt11_lp2:

    ljmp keyboard

    read_cmd:

    mov a,#'A'

    lcall TRANS

    mov a,#'T'

    lcall TRANS

    mov a,#'+'

    lcall TRANS

    mov a,#'C'

    lcall TRANS

    mov a,#'M'

    lcall TRANS

    mov a,#'G'

  • 7/28/2019 gsm controlled home appliances

    41/61[41]

    lcall TRANS

    mov a,#'R'

    lcall TRANS

    mov a,#'='

    lcall TRANS

    mov a,#'1'

    lcall TRANS

    mov a,#13d

    lcall TRANS

    ret

    delet_cmd:

    mov a,#'A'

    lcall TRANS

    mov a,#'T'

    lcall TRANS

    mov a,#'+'

    lcall TRANS

    mov a,#'C'

    lcall TRANS

    mov a,#'M'

    lcall TRANS

    mov a,#'G'

    lcall TRANS

    mov a,#'D'

    lcall TRANS

  • 7/28/2019 gsm controlled home appliances

    42/61[42]

    lcall TRANS

    mov a,#'1'

    lcall TRANS

    mov a,#13d

    lcall TRANS

    ret

    TRANS:

    mov sbuf,a

    jnb ti,$

    clr ti

    clr ri

    lcall DELAY1

    ret

    data_recv:

    recv3: jnb ri,recv3

    mov a,sbuf

    clr ri

    cjne a,#00h,back

    sjmp back_ret

    back:

    mov r1,a

    inc r1

    djnz r4,recv3

    back_ret:

    lcall CLR_LCD

  • 7/28/2019 gsm controlled home appliances

    43/61[43]

    mov dptr,#MSG2

    lcall LINE_1

    lcall DELAY1

    lcall LINE_2

    mov r1,#32h

    mov r4,#0dh

    crxdn1: mov a,r1

    mov LCD_DATA,a

    cjne a,#00h,cbrxdn

    sjmp cbrxdn1

    cbrxdn:

    lcall DATA_BYTE

    lcall DELAY1

    djnz r4,crxdn1

    cbrxdn1:

    clr buz

    lcall DELAY11

    lcall DELAY11

    setb buz

    lcall DELAY11

    lcall DELAY11

    mov r4,#30d

    lcall LINE_2

    lcall read_cmd

    clr ok3

    clr ri

  • 7/28/2019 gsm controlled home appliances

    44/61[44]

    clr ri

    recv4: jnb ri,recv4

    mov a,sbuf

    clr ri

    lcall delay

    djnz r4,recv4

    recv14:jnb ri,recv14

    mov a,sbuf

    mov temp_data,a

    clr ri

    lcall delay

    mov a,temp_data

    cjne a,#10d,recv14

    back_ret2:

    mov r1,#2fh

    mov r4,#10h

    lcall LINE_2

    recv5: jnb ri,recv5

    mov a,sbuf

    clr ri

    mov b,a

    cjne a,#13d,back1

    mov a,cmd4

    cjne a,#10d,back1

    mov a,cmd3

  • 7/28/2019 gsm controlled home appliances

    45/61[45]

    cjne a,#'O',back1

    mov a,cmd2

    cjne a,#'K',back1

    mov a,cmd1

    cjne a,#13d,back1

    mov a,cmd0

    cjne a,#10d,back1

    sjmp back_ret1

    back1:

    mov a,b

    inc r1

    sjmp recv5

    back_ret1:

    lcall CLR_LCD

    mov dptr,#MSG3

    lcall LINE_1

    lcall DELAY1

    lcall LINE_2

    mov a,r1

    mov temp,a

    mov r1,#2fh

    crx11: mov LCD_DATA,a

    lcall DATA_BYTE

    inc r1

    lcall DELAY1

    mov a,r1

  • 7/28/2019 gsm controlled home appliances

    46/61[46]

    cjne a,temp,crx11

    mov r1,#2fh

    mov cmd0,a

    mov r1,#30h

    mov cmd1,a

    mov r1,#31h

    mov cmd2,a

    mov r1,#32h

    mov cmd3,a

    clr c

    lcall cmp_out

    clr buz

    lcall DELAY11

    lcall DELAY11

    setb buz

    lcall DELAY11

    lcall DELAY11

    setb ok3

    ljmp delet_cmd1

    cmp_out:

    mov a,cmd0

    cjne a,#'S',cmp_out1

    mov a,cmd1

    cjne a,#'W',cmp_out1

    mov a,cmd2

    cjne a,#'1',cmp_out1

  • 7/28/2019 gsm controlled home appliances

    47/61[47]

    mov a,cmd3

    cjne a,#'0',cmp_out1

    clr out1

    ljmp cmp_out_end

    cmp_out1:

    mov a,cmd0

    cjne a,#'S',cmp_out2

    mov a,cmd1

    cjne a,#'W',cmp_out2

    mov a,cmd2

    cjne a,#'1',cmp_out2

    mov a,cmd3

    cjne a,#'1',cmp_out2

    setb out1

    ljmp cmp_out_end

    cmp_out2:

    mov a,cmd0

    cjne a,#'S',cmp_out3

    mov a,cmd1

    cjne a,#'W',cmp_out3

    mov a,cmd2

    cjne a,#'2',cmp_out3

    mov a,cmd3

    cjne a,#'0',cmp_out3

    clr out2

    ljmp cmp_out_end

  • 7/28/2019 gsm controlled home appliances

    48/61[48]

    cmp_out3:

    mov a,cmd0

    cjne a,#'S',cmp_out4

    mov a,cmd1

    cjne a,#'W',cmp_out4

    mov a,cmd2

    cjne a,#'2',cmp_out4

    mov a,cmd3

    cjne a,#'1',cmp_out4

    setb out2

    ljmp cmp_out_end

    cmp_out4:

    mov a,cmd0

    cjne a,#'S',cmp_out5

    mov a,cmd1

    cjne a,#'W',cmp_out5

    mov a,cmd2

    cjne a,#'3',cmp_out5

    mov a,cmd3

    cjne a,#'0',cmp_out5

    clr out3

    ljmp cmp_out_end

    cmp_out5:

    mov a,cmd0

    cjne a,#'S',cmp_out6

    mov a,cmd1

  • 7/28/2019 gsm controlled home appliances

    49/61[49]

    cjne a,#'W',cmp_out6

    mov a,cmd2

    cjne a,#'3',cmp_out6

    mov a,cmd3

    cjne a,#'1',cmp_out6

    setb out3

    ljmp cmp_out_end

    cmp_out6:

    mov a,cmd0

    cjne a,#'S',cmp_out7

    mov a,cmd1

    cjne a,#'W',cmp_out7

    mov a,cmd2

    cjne a,#'4',cmp_out7

    mov a,cmd3

    cjne a,#'0',cmp_out7

    clr out4

    ljmp cmp_out_end

    cmp_out7:

    mov a,cmd0

    cjne a,#'S',cmp_out8

    mov a,cmd1

    cjne a,#'W',cmp_out8

    mov a,cmd2

    cjne a,#'4',cmp_out8

    mov a,cmd3

  • 7/28/2019 gsm controlled home appliances

    50/61[50]

    cjne a,#'1',cmp_out8

    setb out4

    ljmp cmp_out_end

    cmp_out8:

    mov a,cmd0

    cjne a,#'S',cmp_out9

    mov a,cmd1

    cjne a,#'W',cmp_out9

    mov a,cmd2

    cjne a,#'5',cmp_out9

    mov a,cmd3

    cjne a,#'0',cmp_out9

    clr out5

    ljmp cmp_out_end

    cmp_out9:

    mov a,cmd0

    cjne a,#'S',cmp_out_end

    mov a,cmd1

    cjne a,#'W',cmp_out_end

    mov a,cmd2

    cjne a,#'5',cmp_out_end

    mov a,cmd3

    cjne a,#'1',cmp_out_end

    setb out5

    ljmp cmp_out_end

    cmp_out_end:

  • 7/28/2019 gsm controlled home appliances

    51/61[51]

    mov cmd0,#00h

    mov cmd1,#00h

    mov cmd2,#00h

    mov cmd3,#00h

    ret

    WRITE_M:

    mov r1,LCD_DATA

    lcall DATA_BYTE

    lcall DELAY1

    ret

    LINE_1:

    mov LCD_DATA,#080h

    lcall COMMAND_BYTE

    lcall DELAY1

    lcall WRITE_MSG

    ret

    LINE_2:

    mov LCD_DATA,#0c0h

    lcall COMMAND_BYTE

    lcall DELAY1

    ret

    INIT_LCD:

    mov LCD_DATA,#038h

    lcall COMMAND_BYTE

    lcall DELAY1

  • 7/28/2019 gsm controlled home appliances

    52/61[52]

    mov LCD_DATA,#038h

    lcall COMMAND_BYTE

    lcall DELAY1

    mov LCD_DATA,#038h

    lcall COMMAND_BYTE

    lcall DELAY1

    mov LCD_DATA,#038h

    lcall COMMAND_BYTE

    lcall DELAY1

    mov LCD_DATA,#008h

    lcall COMMAND_BYTE

    lcall DELAY1

    mov LCD_DATA,#00ch

    lcall COMMAND_BYTE

    lcall DELAY1

    mov LCD_DATA,#006h

    lcall COMMAND_BYTE

    lcall DELAY1

    ret

    CLR_LCD:

    mov LCD_DATA,#001h

    lcall COMMAND_BYTE

    lcall DELAY1

    ret

    WRITE_MSG:

    mov a,#00h

  • 7/28/2019 gsm controlled home appliances

    53/61[53]

    movc a,@a+dptr

    cjne a,#'',WRITE_CONT

    ret

    WRITE_CONT:

    mov LCD_DATA,a

    lcall DATA_BYTE

    ljmp WRITE_MSG

    COMMAND_BYTE:

    clr lcd_rs

    lcall DELAY

    ljmp CMD10

    DATA_BYTE:

    setb lcd_rs

    lcall DELAY

    CMD10:

    clr lcd_rw

    lcall DELAY

    setb lcd_en

    lcall DELAY

    clr lcd_en

    lcall DELAY

    ret

    DELAY:

    mov r6,#10d

    DEL:

    djnz r6,DEL

  • 7/28/2019 gsm controlled home appliances

    54/61[54]

    ret

    DELAY1:

    mov r6,#0d

    mov r7,#20d

    DELAY10:

    djnz r6,DELAY10

    djnz r7,DELAY10

    ret

    DELAY41:

    mov r6,#0d

    mov r7,#6d

    DLP410:

    djnz r6,DLP410

    djnz r7,DLP410

    ret

    DELAY11:

    mov r6,#0d

    mov r7,#0d

    mov r5,#2d

    DLP11:

    djnz r6,DLP11

    djnz r7,DLP11

    djnz r5,DLP11

    ret

    MSG1: db ' SMS CONTROL '

    MSG2: db ' NEW MASSAGE '

  • 7/28/2019 gsm controlled home appliances

    55/61[55]

    MSG3: db ' DATA RECEIVED '

    END.

  • 7/28/2019 gsm controlled home appliances

    56/61[56]

    8

    CHAPTER

    CONCLUSION

  • 7/28/2019 gsm controlled home appliances

    57/61[57]

    8. CONCLUSION

    This project is designed as a concept to control devices over mobile instructions. This project performs

    satisfactorily in the laboratory condition. The reliability of switching is quite high. Accuracy and

    performance is quite acceptable for application in industrial and consumer sector.

    This project is designed to make home automation easy to control when a user is not at home. The project is

    designed to allow easy use of a mobile phone to control appliances in the home. Using a mobile phone the

    development of the control system will be carried out using SMS. This will communicate with another

    mobile phone or GSM modem, which in turn controls the devices attached to microcontroller modules

  • 7/28/2019 gsm controlled home appliances

    58/61[58]

    9

    CHAPTER

    FUTURE EXPANSION

  • 7/28/2019 gsm controlled home appliances

    59/61[59]

    9. FUTURE EXPANSION

    This project has a vast field for expansion. The controller is designed with latest technology of

    communication and control. This project is designed with constrain of time and cost. It can be used in

    industry where a number of devices can be controlled remotely.

    Easy to control various appliances and portable as everything can be controlled by just sending an SMS.

    This project can be modified and expanded in the following fields.

    1. The controller can be interfaced to with sensor to sent back he information to the user regarding its initial

    position

    2. Multiple devices can be controlled by a single command

    3. A timer based control unit can be developed so that ON TIMER and OFF TIMER can be implemented.

    4. A call based protection system or security system can be combined with this design.

  • 7/28/2019 gsm controlled home appliances

    60/61[60]

    10

    CHAPTER

    REFERENCES

  • 7/28/2019 gsm controlled home appliances

    61/61

    10. REFERENCES

    1. Mykepredko,Programming and Customizing the 8051-Microcontroller,Tata Mcgraw-Hill,1999

    2. Ajay.v.deshmukh,Microcontroller[theory and application], Tata Mcgraw-Hill,2005

    3.www.8052.com

    4.www.howstuffworks.com

    5.www.answers.com

    6.www.google.com

    7.www.efy.com

    8.www.datasheetcatalog.com

    http://www.8052.com/http://www.8052.com/http://www.8052.com/http://www.howstuffworks.com/http://www.howstuffworks.com/http://www.howstuffworks.com/http://www.answers.com/http://www.answers.com/http://www.answers.com/http://www.google.com/http://www.google.com/http://www.google.com/http://www.efy.com/http://www.efy.com/http://www.efy.com/http://www.datasheetcatalog.com/http://www.datasheetcatalog.com/http://www.datasheetcatalog.com/http://www.datasheetcatalog.com/http://www.efy.com/http://www.google.com/http://www.answers.com/http://www.howstuffworks.com/http://www.8052.com/