gsm controlled home appliances

Published on November 2016 | Categories: Documents | Downloads: 33 | Comments: 0 | Views: 317
of 61
Download PDF   Embed   Report

the various home appliances can be controlled by just sending an sms through mobile phones

Comments

Content

1

CHAPTER

INTRODUCTION

[1]

1. INTRODUCTION
Nowadays, 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 today‟s and tomorrow‟s 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 PC‟s from anywhere with small mobile devices is beneficial b ecause 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.

[2]

2

CHAPTER

EQUIPMENTS USED

[3]

2. EQUIPMENTS USED
2.1 HARDWARE USED:

 AT command supporting GSM mobile phone.  89S52 Microcontroller  Max 232 IC.  Relays  Relay driver CIRCUITS  Voltage regulator 7805.  Diode IN4007  GSM MODEM
2.2 SOFTWARE USED:

 Keil u-Vision 3.0. 8051 IDE
Keil 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

[4]

3

CHAPTER

THEORY OF OPERATION

[5]

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.

[6]

4

CHAPTER

CIRCUIT DESCRIPTION

[7]

4.CIRCUIT DESCRIPTION

4.1 CIRCUIT DIAGRAM:

Fig: 4.1: Circuit Diagram. [8]

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.

[9]

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 doesn‟t start. You need to restart for the microcontroller to start. 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.

[10]

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. [11]

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 seriesconnected resistors R are placed in parallel with the ac source. The 18 V P-P appears across the two resistors [12]

connected between points AC and CB, and point C is the electrical midpoint between A and B. Hence 9 V PP 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 [13]

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.

[14]

5

CHAPTER

MICROCONTROLLER

[15]

5.MICROCONTROLLER
The 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 user‟s 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 is based 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. . [16]

Device

On-chip memory

data On-chip program memory

No. of 16 bit No. of vectored Full timer/counters interrupts

duplex

serial I/O

8031 8032 8051 8052 8751 8752

128 256 128 256 128 256

NONE NONE 4K ROM 8K ROM 4K EPROM 8K EPROM

2 3 2 3 2 3

5 6 5 6 5 6

1 1 1 1 1 1

Table: 5.1: MCS-51 Family Members

Device

On-chip data memory

On-chip program memory

No. of 16-bit Digital timer/counters I/O

Full No. duplex pins serial I/O

of Precision on-chip analog comparator NONE NONE NONE 1 1 1 NONE

AT89C51 AT89C52

128 256

4K 8K 20K 1K 2K 4K 8K

2 3 3 2 2 2 3

32 32 32 15 15 15 32

1 1 1 1 1 1 1

40 40 40 20 20 20 40

AT89C55WD 256 AT89C1051 AT89C2051 AT89C4051 AT89LV52 64 128 128 256

Table: 5.2: ATMEL Microcontrollers

[17]

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

[18]

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. [19]

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. [20]

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

[21]

6

CHAPTER

LCD

[22]

6. LCD
A liquid-crystal display (LCD) is a flat panel display, electronic visual display, or video display that uses the light modulating properties of liquid crystals. Liquid crystals do not emit light directly. LCDs are used in a wide range of applications including computer monitors, televisions, instrument panels, 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 suffer image 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 16 characters per line by 2 lines and 20 characters per line by 2 lines, respectively.

[23]

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 other way) 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 NAME FUNCTION NO. 1 2 3 4 VSS VCC VEE RS GROUND VOLTAGE +5V CONSTANT VOLTAGE 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 8 DB0 DB1 DATA BIT 0(LSB) DATA BIT 1

[24]

9 10 11 12 13 4 15 16

DB2 DB3 DB4 DB5 DB6 DB7 BPL GND

DATA BIT 2 DATA BIT 3 DATA BIT 4 DATA BIT 5 DATA BIT 6 DATA BIT 7(MSB) BACK PLANE LIGHT+5V(OPTIONAL) 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). DB0–DB7: The 8- bit data pins, D0-D7, are used to send information to the LCD or read the contents of the LCD‟s 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 high – to – low 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. [25]

(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 Command to LCD register (HEX) 1 2 3 4 5 6 7 8 9 A C Clear display screen Return home Decrement cursor (shift cursor to left) Increment cursor (shift cursor to right) Shift display right Shift display left Display off, cursor off Display off, cursor off Display off, cursor off Display off cursor on Display on cursor off

[26]

E F 10 14 18 1C 80 0C0 38

Display on cursor blinking Display on cursor blinking Shift cursor position to left Shift cursor position to right Shift the entire display to left Shift the entire display to right Force cursor to beginning of 1st line Force cursor to beginning of 2nd line 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 command MOV 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 [27]

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 our WAIT_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 won‟t 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,#38h CLR 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. [28]

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: [29]

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 [30]

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 [31]

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_TEXT MOV 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

[32]

7

CHAPTER

PROGRAM

[33]

7.PROGRAM

$include (reg51xa.INC) LCD_DATA lcd_rs lcd_rw lcd_en cmd0 cmd1 cmd2 cmd3 cmd4 cmd5 temp temp_data flag0 out1 out2 out3 out4 out5 ok3 equ bit bit bit equ equ equ equ equ equ equ equ bit bit bit bit bit bit bit P0 P2.7 P2.6 P2.5 26h 27h 28h 29h 2ah 2bh 2ch 2dh 00h p1.3 p1.4 p1.5 p1.6 p1.7 p2.4

org 0000h ljmp main org 0003h [34]

reti org 000bh reti org 0013h reti org 001bh reti org 0023h reti main: lcall DELAY11 mov psw,#00h mov mov sp,#070h 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 mov mov cmd0,#00h cmd1,#00h cmd2,#00h [35]

mov mov mov mov mov

cmd3,#00h cmd4,#00h cmd5,#00h r1,#2fh r4,#15h setb setb setb setb setb buz ok0 ok1 ok2 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 mov blank0:mov r1,#2fh r4,#11h r1,#20h inc djnz mov mov r1,#2fh r4,#11h [36] r1 r4,blank0

sync_cmd1: mov lcall mov lcall mov lcall clr clr lcall DELAY11 lcall DELAY11 setb lcall DELAY11 lcall DELAY11 setb text_cmd1: mov lcall mov lcall mov lcall mov lcall mov lcall a,#'A' TRANS a,#'T' TRANS a,#'+' TRANS a,#'C' TRANS a,#'M' TRANS [37] ok0 buz a,#'A' TRANS a,#'T' TRANS a,#13d TRANS ok0 buz

mov lcall mov lcall mov lcall mov lcall mov lcall clr lcall DELAY11 lcall DELAY11 setb lcall DELAY11 lcall DELAY11 setb delet_cmd1: mov lcall mov lcall mov lcall mov lcall

a,#'G' TRANS a,#'F' TRANS a,#'=' TRANS a,#'1' TRANS a,#13d TRANS buz

buz

ok1

a,#'A' TRANS a,#'T' TRANS a,#'+' TRANS a,#'C' TRANS [38]

mov lcall mov lcall mov lcall lcall mov lcall mov lcall

a,#'M' TRANS a,#'G' TRANS a,#'D' TRANS TRANS a,#'1' TRANS a,#13d TRANS

lcall DELAY11 lcall DELAY11 setb lcall DELAY11 lcall DELAY11 setb mov mov blank10: r1,#2fh r4,#11h mov r1,#20h inc djnz mov mov setb r1,#2fh r4,#11h ea [39] r1 r4,blank10 ok2 buz

keyboard: jnb clr mov mov blank1:mov r1,#2fh r4,#11h r1,#20h inc djnz mov mov r1,#2fh r4,#11h ljmp nxt11_lp2: ljmp keyboard data_recv r1 r4,blank1 flag0,nxt11_lp2 flag0

read_cmd: mov lcall mov lcall mov lcall mov lcall mov lcall mov a,#'A' TRANS a,#'T' TRANS a,#'+' TRANS a,#'C' TRANS a,#'M' TRANS a,#'G' [40]

lcall mov lcall mov lcall mov lcall mov lcall ret

TRANS a,#'R' TRANS a,#'=' TRANS a,#'1' TRANS a,#13d TRANS

delet_cmd: mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall a,#'A' TRANS a,#'T' TRANS a,#'+' TRANS a,#'C' TRANS a,#'M' TRANS a,#'G' TRANS a,#'D' TRANS [41]

lcall mov lcall mov lcall ret

TRANS a,#'1' TRANS a,#13d TRANS

TRANS: mov jnb clr clr lcall ret data_recv: recv3: jnb ri,recv3 mov clr cjne sjmp back: mov inc djnz back_ret: lcall CLR_LCD [42] r1,a r1 r4,recv3 a,sbuf ri a,#00h,back back_ret sbuf,a ti,$ ti ri DELAY1

mov dptr,#MSG2 lcall LINE_1 lcall DELAY1 lcall LINE_2 mov mov crxdn1: r1,#32h r4,#0dh mov a,r1 mov cjne sjmp cbrxdn: lcall DATA_BYTE lcall DELAY1 djnz cbrxdn1: clr lcall DELAY11 lcall DELAY11 setb lcall DELAY11 lcall DELAY11 mov r4,#30d lcall LINE_2 lcall read_cmd clr clr ok3 ri [43] buz buz r4,crxdn1 LCD_DATA,a a,#00h,cbrxdn cbrxdn1

clr recv4: jnb ri,recv4 mov clr lcall

ri

a,sbuf ri delay

djnz r4,recv4 recv14:jnb ri,recv14 mov mov clr lcall mov a,sbuf temp_data,a ri delay a,temp_data

cjne a,#10d,recv14 back_ret2: mov mov r1,#2fh r4,#10h

lcall LINE_2 recv5: jnb ri,recv5 mov clr mov a,sbuf ri b,a

cjne mov cjne mov

a,#13d,back1 a,cmd4 a,#10d,back1 a,cmd3 [44]

cjne mov cjne mov cjne mov cjne sjmp back1: mov

a,#'O',back1 a,cmd2 a,#'K',back1 a,cmd1 a,#13d,back1 a,cmd0 a,#10d,back1 back_ret1

a,b inc r1

sjmp recv5 back_ret1: lcall CLR_LCD mov dptr,#MSG3 lcall LINE_1 lcall DELAY1 lcall LINE_2 mov mov mov crx11: a,r1 temp,a r1,#2fh mov lcall inc lcall DELAY1 mov a,r1 [45] LCD_DATA,a DATA_BYTE r1

cjne mov

a,temp,crx11 r1,#2fh mov cmd0,a

mov

r1,#30h mov cmd1,a

mov

r1,#31h mov cmd2,a

mov

r1,#32h mov clr lcall clr c cmp_out buz cmd3,a

lcall DELAY11 lcall DELAY11 setb lcall DELAY11 lcall DELAY11 setb ljmp cmp_out: mov cjne mov cjne mov cjne a,cmd0 a,#'S',cmp_out1 a,cmd1 a,#'W',cmp_out1 a,cmd2 a,#'1',cmp_out1 [46] ok3 delet_cmd1 buz

mov cjne clr ljmp cmp_out1: mov cjne mov cjne mov cjne mov cjne setb ljmp cmp_out2: mov cjne mov cjne mov cjne mov cjne clr ljmp

a,cmd3 a,#'0',cmp_out1 out1 cmp_out_end

a,cmd0 a,#'S',cmp_out2 a,cmd1 a,#'W',cmp_out2 a,cmd2 a,#'1',cmp_out2 a,cmd3 a,#'1',cmp_out2 out1 cmp_out_end

a,cmd0 a,#'S',cmp_out3 a,cmd1 a,#'W',cmp_out3 a,cmd2 a,#'2',cmp_out3 a,cmd3 a,#'0',cmp_out3 out2 cmp_out_end [47]

cmp_out3: mov cjne mov cjne mov cjne mov cjne setb ljmp cmp_out4: mov cjne mov cjne mov cjne mov cjne clr ljmp cmp_out5: mov cjne mov a,cmd0 a,#'S',cmp_out6 a,cmd1 [48] a,cmd0 a,#'S',cmp_out5 a,cmd1 a,#'W',cmp_out5 a,cmd2 a,#'3',cmp_out5 a,cmd3 a,#'0',cmp_out5 out3 cmp_out_end a,cmd0 a,#'S',cmp_out4 a,cmd1 a,#'W',cmp_out4 a,cmd2 a,#'2',cmp_out4 a,cmd3 a,#'1',cmp_out4 out2 cmp_out_end

cjne mov cjne mov cjne setb ljmp cmp_out6: mov cjne mov cjne mov cjne mov cjne clr ljmp cmp_out7: mov cjne mov cjne mov cjne mov

a,#'W',cmp_out6 a,cmd2 a,#'3',cmp_out6 a,cmd3 a,#'1',cmp_out6 out3 cmp_out_end

a,cmd0 a,#'S',cmp_out7 a,cmd1 a,#'W',cmp_out7 a,cmd2 a,#'4',cmp_out7 a,cmd3 a,#'0',cmp_out7 out4 cmp_out_end

a,cmd0 a,#'S',cmp_out8 a,cmd1 a,#'W',cmp_out8 a,cmd2 a,#'4',cmp_out8 a,cmd3 [49]

cjne setb ljmp cmp_out8: mov cjne mov cjne mov cjne mov cjne clr ljmp cmp_out9: mov cjne mov cjne mov cjne mov cjne setb ljmp cmp_out_end:

a,#'1',cmp_out8 out4 cmp_out_end

a,cmd0 a,#'S',cmp_out9 a,cmd1 a,#'W',cmp_out9 a,cmd2 a,#'5',cmp_out9 a,cmd3 a,#'0',cmp_out9 out5 cmp_out_end

a,cmd0 a,#'S',cmp_out_end a,cmd1 a,#'W',cmp_out_end a,cmd2 a,#'5',cmp_out_end a,cmd3 a,#'1',cmp_out_end out5 cmp_out_end

[50]

mov mov mov mov

cmd0,#00h cmd1,#00h cmd2,#00h cmd3,#00h ret

WRITE_M: mov lcall lcall DELAY1 ret LINE_1: mov LCD_DATA,#080h r1,LCD_DATA DATA_BYTE

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 [51]

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 [52]

movc cjne ret

a,@a+dptr a,#'',WRITE_CONT

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 DEL: djnz r6,DEL [53] r6,#10d

ret DELAY1: mov mov DELAY10: djnz djnz ret DELAY41: mov mov DLP410: djnz djnz ret DELAY11: mov mov mov DLP11: djnz djnz djnz ret MSG1: db MSG2: db ' SMS CONTROL ' ' NEW MASSAGE ' [54] r6,DLP11 r7,DLP11 r5,DLP11 r6,#0d r7,#0d r5,#2d r6,DLP410 r7,DLP410 r6,#0d r7,#6d r6,DELAY10 r7,DELAY10 r6,#0d r7,#20d

MSG3: db END.

' DATA RECEIVED '

[55]

8

CHAPTER

CONCLUSION

[56]

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

[57]

9

CHAPTER

FUTURE EXPANSION

[58]

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.

[59]

10

CHAPTER

REFERENCES

[60]

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

[61]

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

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

Back to log-in

Close