sms controlled home appliance

56
SMS CONTROLLED HOME APPLIANCE ABSTRACT Mobile plays a vital role in day-to-day life. It is an easier way to establish communication. A number of technologies works behind it, GSM is one of them. The objective of this project is to control the Machineries in the industrial and appliances in home through the GSM Technique. In this project we interface Mobile and Microcontroller with the help of Data Cable and RS232 level converter for example when you are away from home and want to switch ‘on’ any Machine like Fan, Air cooler, by sending SMS that contains the corresponding Machine number and type of mode such that ON (or) OFF the machine by the Mobile Phone. This is interfaced with the Microcontroller in company or home. After receiving the message, the Mobile sends the data signal to the Microcontroller through the data cable and RS232 level logic converter. Level converter gives the signal in the form of 0 and 5V pulse to the Microcontroller. A relay is an electrically operated switch. Current flowing through the coil of the relay creates a magnetic field which attracts a lever and changes the switch contacts. The coil of a relay passes a relatively large 1

Upload: neelima-padala

Post on 24-Nov-2014

112 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: SMS Controlled Home Appliance

SMS CONTROLLED HOME APPLIANCE

ABSTRACT

Mobile plays a vital role in day-to-day life. It is an easier way to establish

communication. A number of technologies works behind it, GSM is one of them. The

objective of this project is to control the Machineries in the industrial and appliances in home

through the GSM Technique.

In this project we interface Mobile and Microcontroller with the help of Data

Cable and RS232 level converter for example when you are away from home and want to

switch ‘on’ any Machine like Fan, Air cooler, by sending SMS that contains the

corresponding Machine number and type of mode such that ON (or) OFF the machine by the

Mobile Phone. This is interfaced with the Microcontroller in company or home.

       After receiving the message, the Mobile sends the data signal to the Microcontroller

through the data cable and RS232 level logic converter. Level converter gives the signal in

the form of 0 and 5V pulse to the Microcontroller.

A relay is an electrically operated switch. Current flowing through the coil of the

relay creates a magnetic field which attracts a lever and changes the switch contacts. The coil

of a relay passes a relatively large current, typically 30mA for a 12V relay, but it can be as

much as 100mA for relays designed to operate from lower voltages

The Microcontroller is the embedded device which has on chip program memory

in which the machine control program is stored. Suppose if you send the SMS like Machine 1

ON, in company corresponding information is displayed in the LCD display through

Microcontroller.

Then the Microcontroller activates the relay which is connected to

corresponding Machine. Now the Machine 1 is switched ON by relay. Relay is activated

through Relay Driver Circuit which is controlled by Microcontroller. By using this project

we can control the industrial Machineries Automatically with help of GSM Technique.

1

Page 2: SMS Controlled Home Appliance

INDEX

S.No Pg.No

1. INTRODUCTION……………………………………...………………......…....…1

2. SYSTEM MODEL…………………………………………………….....…............2

2.1BASIC MODEL OF THE SYSTEM……………………………….……....…..2

2.1.1DESCRIPTION..........................................................................................3

2.2CIRCUIT DIAGRAM……………………………......………………...…....….4

3. HARWARE DESCRIPTION……………………………………......……….......…5

3.1MICROCONTROLLER (AT89S51)……………………….....……..……....…5

3.1.1CRITERIA FOR CHOOSING MICROCONTROLLER……...........….5

3.1.2DESCRIPTION………………………………….......……………....…...6

3.1.3FEATURES……………………………………………............................7

3.1.4PIN CONFIGURATION………………………..………….....….............8

3.1.5PIN DESCRIPTION…………………………………….......……......….9

3.1.6BLOCK DIAGRAM…………………………………….........….…..…10

3.2RELAY…………………………………………...………….....………...…....11

3.2.1CIRCUIT DESCRIPTION…………………………...……..…........…..13

3.3LIQUID CRYSTAL DISPLAY……………………......……....………....…...14

3.3.1PIN DESCRIPTION…………………………………...….....….………16

2

Page 3: SMS Controlled Home Appliance

3.3.2LCD COMMAND DESCRIPTION……….......………………….……18

3.3.3CHECKING THE BUSY STATUS OF LCD……………….............….19

3.3.4INITIALIZING THE LCD………………………….......………..……..19

3.4 POWER SUPPLY………………………………....…………….……..……..20

3.4.1 TRANSFORMER………………....…………………………......….....20

3.4.2 BRIDGE RECTIFIER……………......…………………………...…....21

3.4.3 IC VOLTAGE REGULATOR……………………......…………...…...21

4.SOFTWARE……………………………………………………….….....…...……22

4.1INTRODUCTION TO KEIL………………………………………...........….22

4.2CONCEPT OF COMPILER…………….....……………………….........…...22

4.3CONCEPT OF CROSS COMPILER …………………………….…......…....23

4.4WHY DO WE NEED A CROSS COMPILER.................................................23

4.5KEIL C CROSS COMPILER………………….....……………………......…24

5. SOURCE CODE…………………………….....…………………………..….…..29

5.1FLOW CHART.................................................................................................32

6. ADVANTAGES, DISADVANTAGES AND APPLICATIONS……….......….....35

6.1ADVANTAGES……………………….....……………………………......….35

6.2DISADVANTAGES…………….....………………………………….....…...35

6.3APPLICATIONS…………………………………......……………….....……35

7. RESULT AND CONCLUSION……………......……………………………..…..36

7.1RESULT……………………………….....……………………………….......36

7.2CONCLUSION…………………………......…………………….…….....….36

8. REFERENCES……………………………......………………………………...…37

3

Page 4: SMS Controlled Home Appliance

LIST OF FIGURES

S.No Pg.No

1. BASIC MODEL OF THE SYSTEM………………………………...……………..2

2. CIRCUIT DIAGRAM……………………………………………………...………4

3. PIN DIAGRAM OF 8051………………………………………………...…...……8

4. BLOCK DIAGRAM OF 8051…………………………………..………………...10

5. RELCIRCUIT………………………………………...…………..……………….11

6. RELAY SWITCH………………………………..………………………………..12

7. LCD DISPLAY………………………...……………………………………….....15

8. BLOCK DIAGRAM OF POWER SUPPLY...........................................................20

9. BRIDGE RECTIFIER..............................................................................................21

10. CIRCUIT DIAGRAM OF POWER SUPPLY.......................................................21

11. KEIL WORK SPACE............................................................................................27

12. CONVERSION TO HEXA DECIMAL FILE.......................................................28

LIST OF TABLES

S.No Pg.No

1. PIN DESCRIPTION................................................................................................16

2. LCD COMMANDS.................................................................................................18

4

Page 5: SMS Controlled Home Appliance

1. INTRODUCTION

The embedded system is a combination of computer hardware, software and

perhaps additional mechanical or other parts, designed to perform a specific function within

a given time frame. The embedded software is required for all real-time applications and is

developed using a real time operating system (RTOS), as it helps to schedule and execute

tasks based on priority in a predictable manner.

Industry analysts estimate that over 54 percent of future software

development will be in the embedded technology space. According to an IDC report the

international market as a whole expects product development worth $75 billion, which will

require as many as 150,000 trained professionals in embedded systems development by the

year 2005.

This project is based on the embedded systems technology using

microcontroller. The objective of this project is to control the Machineries in the industrial

and appliances in home through the GSM Technique. In this project we interface Mobile and

Microcontroller with the help of Data Cable and RS232 level converter for an example when

you are away from your home and you wants to switch ‘on’ the any one Machine like Fan,

Air cooler, you have to send SMS that contains the corresponding Machine number and type

of mode such that ON (or) OFF to the Mobile Phone. This is interface with the

Microcontroller in company or home.

The Microcontroller is the embedded device which has on chip program memory

in which the machine control program is stored. Suppose if you send the SMS like Machine 1

ON, in company corresponding information is displayed in the LCD display through

Microcontroller.

5

Page 6: SMS Controlled Home Appliance

2. SYSTEM MODEL

2.1BASIC MODEL OF THE SYSTEM:

6

Page 7: SMS Controlled Home Appliance

BASIC MODEL OF THE SYSTEM

3. HARDWARE DESCRIPTION

3.1MICRO CONTROLLER (AT89S51):

7

Page 8: SMS Controlled Home Appliance

3.1.1 CRITERIA FOR CHOOSING A MICROCONTROLLER

The basic criteria for choosing a microcontroller suitable for the application are:

1) The first and foremost criterion is that it must meet the task at hand efficiently and

cost effectively. In analyzing the needs of a microcontroller-based project, it is seen whether

an 8- bit, 16-bit or 32-bit microcontroller can best handle the computing needs of the task

most effectively. Among the other considerations in this category are:

i. Speed: The highest speed that the microcontroller supports.

ii. Packaging: It may be a 40-pin DIP (dual inline package) or a QFP (quad flat package), or

some other packaging format. This is important in terms of space, assembling, and

prototyping the end product.

iii. Power consumption: This is especially critical for battery-powered products.

iv. The number of I/O pins and the timer on the chip.

v. How easy it is to upgrade to higher –performance or lower consumption versions.

vi. Cost per unit: This is important in terms of the final cost of the product in which a

microcontroller is used.

2) The second criterion in choosing a microcontroller is how easy it is to develop

products around it. Key considerations include the availability of an assembler, debugger,

compiler, technical support.

3) The third criterion in choosing a microcontroller is its ready availability in needed

quantities both now and in the future. Currently of the leading 8-bit microcontrollers, the

8051 family has the largest number of diversified suppliers. By supplier is meant a producer

besides the originator of the microcontroller. By supplier is meant a producer besides the

originator of the microcontroller. In the case of the 8051, this has originated by Intel several

companies also currently producing the 8051. Thus the microcontroller AT89S52, satisfying

the criterion necessary for the proposed application is chosen for the task.

3.1.2 DESCRIPTION:

The 8052 family of microcontrollers is based on an architecture which is

highly optimized for embedded control systems. It is used in a wide variety of applications

8

Page 9: SMS Controlled Home Appliance

from military equipment to automobiles to the keyboard. Second only to the Motorola,

68HC11 in eight bit processors sales, the 8052 family of microcontrollers is available in a

wide array of variations from manufacturers such as Intel, Philips, and Siemens. These

manufacturers have added numerous features and peripherals to the 8052 such as I2C

interfaces, analog to digital converters, watchdog timers, and pulse width modulated outputs.

Variations of the 8052 with clock speeds up to 40MHz and voltage requirements

down to 1.5 volts are available. This wide range of parts based on one core makes the 8052

family an excellent choice as the base architecture for a company's entire line of products

since it can perform many functions and developers will only have to learn this one platform.

The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller

with 8K bytes of in-system programmable Flash memory. The device is manufactured using

Atmel’s high-density nonvolatile memory technology and is compatible with the industry-

standard 80C52 instruction set and pin out.

The on-chip Flash allows the program memory to be reprogrammed in-system

or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU

with in-system programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful

microcontroller which provides a highly-flexible and cost- effective solution to many

embedded control applications. In addition, the AT89S52 is designed with static logic for

operation down to zero frequency and supports two software selectable power saving modes.

The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial

port, and interrupt system to continue functioning. The Power-down mode saves the RAM

con-tents but freezes the oscillator, disabling all other chip functions until the next interrupt

or hardware reset.

3.1.3 FEATURES:

• Compatible with MCS-52 Products

• 8K Bytes of In-System Programmable (ISP) Flash Memory

9

Page 10: SMS Controlled Home Appliance

• 4.0V to 5.5V Operating Range

• Fully Static Operation: 0 Hz to 33 MHz

• 256 x 8-bit Internal RAM

• 32 Programmable I/O Lines

• Two 16-bit Timer/Counters

• Eight Interrupt Sources

• Full Duplex UART Serial Channel

• Low-power Idle and Power-down Modes

• Interrupt Recovery from Power-down Mode

• Watchdog Timer

• Fast Programming Time

3.1.4 PIN CONFIGURATION:

10

Page 11: SMS Controlled Home Appliance

PIN DIAGRAM OF 8051

3.1.5 PIN DESCRIPTION:

VCC: Supply voltage.

11

Page 12: SMS Controlled Home Appliance

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 can also be configured to be the multiplexed low-order address/data

bus during accesses to external program and data memory.

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

addition, P1.0 and P1.1 can be configured to be the timer/counter2 external count input

(P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively.

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, Port2 pins that are

externally being pulled low will source current (IIL) because of the internal pull-ups

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, Port3 pins that are

externally being pulled low will source current (IIL) because of the pull ups. Port 3 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. This pin drives high for 98 oscillator periods after the watchdog times out.

12

Page 13: SMS Controlled Home Appliance

3.1.6 BLOCK DIAGRAM:

BLOCK DIAGRAM OF THE 8051

13

Page 14: SMS Controlled Home Appliance

3.2RELAY:

RELAY CIRCUIT

A relay is an electrically operated switch. Current flowing through the coil of

the relay creates a magnetic field which attracts a lever and changes the switch contacts. The

coil current can be on or off so relays have two switch positions and they are double throw

(changeover) switches. Relays allow one circuit to switch a second circuit which can be

completely separate from the first. For example a low voltage battery circuit can use a relay

to switch a 230V AC mains circuit. There is no electrical connection inside the relay between

the two circuits; the link is magnetic and mechanical.

The coil of a relay passes a relatively large current, typically 30mA for a 12V

relay, but it can be as much as 100mA for relays designed to operate from lower voltages.

Most ICs (chips) cannot provide this current and a transistor is usually used to amplify the

small IC current to the larger value required for the relay coil. The maximum output current

for the popular 555 timer IC is 200mA so these devices can supply relay coils directly

without amplification.

14

Page 15: SMS Controlled Home Appliance

Relays are usually SPDT or DPDT but they can have many more sets of switch

contacts, for example relays with 4 sets of changeover contacts are readily available. Most

relays are designed for PCB mounting but you can solder wires directly to the pins providing

you take care to avoid melting the plastic case of the relay. The animated picture shows a

working relay with its coil and switch contacts. You can see a lever on the left being attracted

by magnetism when the coil is switched on. This lever moves the switch contacts. There is

one set of contacts (SPDT) in the foreground and another behind them, making the relay

DPDT. You can see a lever on the left being attracted by magnetism when the coil is

switched on. This lever moves the switch contacts.

RELAY SWITCH

The relay's switch connections are usually labeled COM, NC and NO:

COM = Common, always connect to this, it is the moving part of the switch.

NC = Normally Closed, COM is connected to this when the relay coil is off.

NO = Normally Open, COM is connected to this when the relay coil is on.

15

Page 16: SMS Controlled Home Appliance

3.2.1 CIRCUIT DESCRIPTION:

This circuit is designed to control the load. The load may be motor or any other

load. The load is turned ON and OFF through relay. The relay ON and OFF is controlled by

the pair of switching transistors (BC 547). The relay is connected in the Q2 transistor

collector terminal. A Relay is nothing but electromagnetic switching device which consists of

three pins. They are Common, Normally close (NC) and Normally open (NO).

The relay common pin is connected to supply voltage. The normally open (NO)

pin connected to load. When high pulse signal is given to base of the Q1 transistors, the

transistor is conducting and shorts the collector and emitter terminal and zero signals is given

to base of the Q2 transistor. So the relay is turned OFF state.

When low pulse is given to base of transistor Q1 transistor, the transistor is

turned OFF. Now 12v is given to base of Q2 transistor so the transistor is conducting and

relay is turned ON. Hence the common terminal and NO terminal of relay are shorted. Now

load gets the supply voltage through relay.

16

Page 17: SMS Controlled Home Appliance

3.3 LIQUID CRYSTAL DISPLAY

The LCD is used for the purpose of displaying the words which we give in the

program code. This code will be executed on microcontroller chip. By following the

instructions in code the LCD display the related words.

Liquid crystal displays (LCDs) have materials which combine the properties of

both liquids and crystals. Rather than having a melting point, they have a temperature range

within which the molecules are almost as mobile as they would be in a liquid, but are

grouped together in an ordered form similar to a crystal.

An LCD consists of two glass panels, with the liquid crystal material sand witched

in between them. The inner surface of the glass plates are coated with transparent electrodes

which define the character, symbols or patterns to be displayed polymeric layers are present

in between the electrodes and the liquid crystal, which makes the liquid crystal molecules to

maintain a defined orientation angle.

One each polarisers are pasted outside the two glass panels. These polarisers

would rotate the light rays passing through them to a definite angle, in a particular direction.

When the LCD is in the off state, light rays are rotated by the two polarisers and

the liquid crystal, such that the light rays come out of the LCD without any orientation, and

hence the LCD appears transparent.

When sufficient voltage is applied to the electrodes, the liquid crystal molecules

would be aligned in a specific direction. The light rays passing through the LCD would be

rotated by the polarisers, which would result in activating /highlighting the desired

characters.

The LCD’s are lightweight with only a few millimeters thickness. Since the LCD’s

consume less power, they are compatible with low power electronic c rcuits, and can be

powered for long durations.

The LCD don’t generate light and so light is needed to read the display. By using

backlighting, reading is possible in the dark. The LCD’s have long life and a wide operating

temperature range.

17

Page 18: SMS Controlled Home Appliance

The LCDs used exclusively in watches, calculators and measuring instruments

are the simple seven-segment displays, having a limited amount of numeric data. The recent

advances in technology have resulted in better legibility, more information displaying

capability and a wider temperature range. These have resulted in the LCDs being extensively

used in telecommunications and entertainment electronics. The LCDs have even started

replacing the cathode ray tubes (CRTs) used for the display of text and graphics, and also in

small TV applications. . Fig below shows the LCD display.

LCD DISPLAY

The LCD display consists of two lines, 20 characters per line that is interfaced

with the PIC16F73.The protocol (handshaking) for the display is as shown in Fig. The

display contains two internal byte-wide registers, one for commands (RS=0) and the second

for characters to be displayed (RS=1). It also contains a user-programmed RAM area (the

character RAM) that can be programmed to generate any desired character that can be

formed using a dot matrix. To distinguish between these two data areas, the hex command

byte 80 will be used to signify that the display RAM address 00h will be chosen Port1 is used

to furnish the command or data type, and ports 3.2 to 3.4 furnish register select and

read/write levels.

A liquid crystal is a material (normally organic for LCDs) that will flow like a

liquid but whose molecular structure has some properties normally associated with solids.

The Liquid Crystal Display (LCD) is a low power device. The power requirement is typically

in the order of microwatts for the LCD. However, an LCD requires an external or internal

light source. It is limited to a temperature range of about 0°C to 60°C and lifetime is an area

of concern, because LCDs can chemically degrade.

18

Page 19: SMS Controlled Home Appliance

There are two major types of LCDs which are:

Dynamic-scattering LCDs and

Field-effect LCDs

The turn-on and turn-off time is an important consideration in all displays. The

response time of LCDs is in the range of 100 to 300ms.The lifetime of LCDs is steadily

increasing beyond 10,000+hours limit. Since the color generated by LCD units is dependent

on the source of illumination, there is a wide range of color choice. The lifetime of LCDs is

steadily increasing . Since the color generated by LCD units is dependent on the source of

illumination, there is a wide range of color choice.

3.3.1PIN DESCRIPTION

Pins Description

1 "Vss" - Ground

2 "Vcc" - +5v power supply

3 "Vee" - Contrast Voltage

4 "R/S" - Instruction/Register Select

5 "R/W" - Read/Write LCD Registers

6 "E" - Enable

7 - 14 Data I/O Pins

TABLE: PIN DESCRIPTION

Vcc, Vss, VEE

While Vcc and Vss provide +5v and ground, respectively, Vee is used for controlling

LCD contrast.

19

Page 20: SMS Controlled Home Appliance

RS, Register Select

There are two very important registers inside the LCD. The RS pin is used for their

selection as follows.

If RS = 0, the instruction command code register is selected, allowing the user to send

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

R/W, Read/Write

R/W input allows the user to write information to the LCD or read information from

it.

R/W = 1 when reading;

R/W = 0 when writing.

E, Enable

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 latch in the data pins. This pulse must be a minimum of 450 ns wide.

D0 - D7

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.To display letters and numbers, send ASCII codes for

the letters A - Z, a - z, and numbers 0 - 9 to these pins while RS = 1. When RS = 0 to check

the busy flag bit to see if the LCD is ready to receive information. The busy flag is D7 and

can be read when R/W = 1 and RS = 0, as follows: if R/W = 1, RS = 0. When D7 =1 (busy

flag = 1), the LCD is busy taking care of internal operation and will not accept any new

information. The description of the pins is shown in Table below.

20

Page 21: SMS Controlled Home Appliance

3.3.2 LCD Commands

RS R/W D7 D6 D5 D4 D3 D2 D1 D0 Function

0 0 0 0 0 0 0 0 0 1 Clear LCD &memory,

Home cursor

0 0 0 0 0 0 0 0 1 0 Clear and home cursor

only

0 0 0 0 0 0 0 1 1/0 S Screen action as

display character

Written S=1/0:shift

screen/ cursor

0 0 0 0 0 0 1 D C B D=1/0: Screen on/off

C=1/0: Cursor on/off

B=1/0: Cursor blink/no

blinks

0 0 0 0 0 1 S/C R/L 0 0 S/C=1/0: Screen/Cursor

R/L==1/0: Shift one

space R/L

0 0 0 0 1 DL N F 0 0 DL=1/0: 8/4 bits per

character N=1/0: 2/1

Rows of characters

F=1/0:

5*10/5*7dots/character

0 0 0 1 Character address Write to character

RAM address after this

0 0 1 Display data address Write to display RAM

21

Page 22: SMS Controlled Home Appliance

address after this

0 1 BF Current addresses BF=1/0:busy/Not busy

3.3.3 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 crystal attached

to the oscillator input of the controller as well as the instruction which is being executed.

While it is possible to write code that waits for a specific amount of time to allow the LCD to

execute instructions, this method of "waiting" is not very flexible.

3.3.4 INITIALIZING THE LCD

LCD must be initialized and configured before using. This is accomplished by

sending a number of initialization instructions to the LCD.

The first instruction send must tell the LCD whether it is to be communicated

with an 8-bit or 4-bit data bus. 5x8 dot character font should also be selected. These two

options are selected by sending the command 38h to the LCD as a command.

a) Clearing the Display

When the LCD is first initialized, the screen should automatically be cleared by the

controller.

b) Writing Text into the LCD

The data to be displayed is send to the LCD through data bus.

c) Cursor Positioning

The cursor positioning in a LCD can be done in the right entry mode or left entry mode. As

left entry mode is flexible it is implemented.

.

22

Page 23: SMS Controlled Home Appliance

3.4 POWER SUPPLY:

The power supply circuits built using filters, rectifiers, and then voltage

regulators. Starting with an ac voltage, a steady dc voltage is obtained by rectifying the ac

voltage, then filtering to a dc level, and finally, regulating to obtain a desired fixed dc

voltage. The regulation is usually obtained from an IC voltage regulator unit, which takes a

dc voltage and provides a somewhat lower dc voltage, which remains the same even if the

input dc voltage varies, or the output load connected to the dc voltage changes. The block

diagram of power supply is shown in fig below.

AC Transformer Rectifier Filter Regulator Load

BLOCK DIAGRAM OF POWER SUPPLY

3.4. TRANSFORMER

The potential transformer will step down the power supply voltage (0-230V) to (0-

6V) level. Then the secondary of the potential transformer will be connected to the precision

rectifier, which is constructed with the help of op–amp. The advantages of using precision

rectifier are it will give peak voltage output as DC, rest of the circuits will give only RMS

output.

23

Page 24: SMS Controlled Home Appliance

3.4.2BRIDGE RECTIFIER

Bridge rectifier is used to maintain the proper DC polarity at the input to the

circuit. It comprises of four diodes connected to form a bridge. It uses the entire AC wave

(both positive and negative sections). 1.4V is used up in the bridge rectifier because each

diode uses 0.7V when conducting and there are always two diodes conducting, as shown in

fig

AC I/P

BRIDGE RECTIFIER

3.4.3 IC VOLTAGE REGULATORS:

The series 78 regulators provide fixed regulated voltages from 5 to 24 V.

Unregulated input voltage Vin is filtered by capacitor C1 and connected to the IC’s IN

terminal. The IC’s OUT terminal provides a regulated + 12V which is filtered by capacitor

C2. The third IC terminal is connected to ground (GND).

CIRCUIT DIAGRAM OF POWER SUPPLY

24

Page 25: SMS Controlled Home Appliance

4. SOFTWARE

4.1INTRODUCTION TO KEIL:

Keil is a cross compiler. So first we have to understand the concept of compilers

and cross compilers. After then we shall learn how to work with keil.

4.2CONCEPT OF COMPILER: -

Compilers are programs used to convert a High Level Language to object code.

Desktop compilers produce an output object code for the underlying microprocessor, but not

for other microprocessors. I.E the programs written in one of the HLL like ‘C’ will compile

the code to run on the system for a particular processor like x86 (underlying microprocessor

in the computer). For example compilers for Dos platform is different from the Compilers for

Unix platform.

So if one wants to define a compiler then compiler is a program that translates

source code into object code. The compiler derives its name from the way it works, looking

at the entire piece of source code and collecting and reorganizing the instruction. See there is

a bit little difference between compiler and an interpreter. Interpreter just interprets whole

program at a time while compiler analyzes and execute each line of source code in

succession, without looking at the entire program. 

The advantage of interpreters is that they can execute a program immediately.

Secondly programs produced by compilers run much faster than the same programs executed

by an interpreter. However compilers require some time before an executable program

emerges. Now as compilers translate source code into object code, which is unique for each

type of computer, many compilers are available for the same language.

25

Page 26: SMS Controlled Home Appliance

 4.3CONCEPT OF CROSS COMPILER: -

A cross compiler is similar to the compilers but we write a program for

the target processor (like 8051 and its derivatives) on the host processors (like computer of

x86)

It means being in one environment you are writing a code for another

environment is called cross development. And the compiler used for cross development is

called cross compile

So the definition of cross compiler is a compiler that runs on one

computer but produces object code for a different type of computer. Cross compilers are used

to generate software that can run on computers with a new architecture or on special-purpose

devices that cannot host their own compilers. Cross compilers are very popular for embedded

development, where the target probably couldn't run a compiler. Typically an embedded

platform has restricted RAM, no hard disk, and limited I/O capability. Code can be edited

and compiled on a fast host machine (such as a PC or Unix workstation) and the resulting

executable code can then be downloaded to the target to be tested. Cross compilers are

beneficial whenever the host machine has more resources (memory, disk, I/O etc) than the

target.  Keil C Compiler is one such compiler that supports a huge number of host and target

combinations. It supports as a target to 8 bit microcontrollers like Atmel and Motorola etc.

4.4WHY DO WE NEED A CROSS COMPILER?

> There are several advantages of using cross compiler. Some of them are described as

follows

> By using this compilers not only can development of complex embedded systems be

completed in a fraction of the time, but reliability is improved, and maintenance is easy.

> Knowledge of the processor instruction set is not required.

> Register allocation and addressing mode details are managed by the compiler.

> The ability to combine variable selection with specific operations improves program

readability.

> Keywords and operational functions that more nearly resemble the human thought process

can be used.

26

Page 27: SMS Controlled Home Appliance

> Program development and debugging times are dramatically reduced when compared to

assembly language programming.

> The library files that are supplied provide many standard routines (such as formatted

output, data conversions, and floating-point arithmetic) that may be incorporated into your

application.

> Existing routine can be reused in new programs by utilizing the modular programming

techniques available with C.

> The C language is very portable and very popular. C compilers are available for almost all

target systems. Existing software investments can be quickly and easily converted from or

adapted to other processors or environments.

> Now after going through the concept of compiler and cross compilers lets we start with

Keil C cross compiler.

4.5KEIL C CROSS COMPILER: -

> Keil is a German based Software development company. It provides several

development tools like

> IDE (Integrated Development environment)

> Project Manager

> Simulator

> Debugger

> C Cross Compiler , Cross Assembler, Locator/Linker

> Keil Software provides you with software development tools for the 8051 family of

microcontrollers. With these tools, you can generate embedded applications for the multitude

of 8051 derivatives.

> The keil 8051 tool kit includes three main tools, assembler, compiler and linker.

> An assembler is used to assemble your 8051 assembly program

> A compiler is used to compile your C source code into an object file

27

Page 28: SMS Controlled Home Appliance

> A linker is used to create an absolute object module suitable for your in-circuit emulator. 

8051 project development cycle: - these are the steps to develop 8051 project using keil

Create source files in C or assembly.

Compile or assemble source files.

Correct errors in source files.

Link object files from compiler and assembler.

Test linked application.

Now let us start how to work with keil.

To open keil software click on start menu then program and then select keil2 .You can see

three different windows on the screen. 1) project work space window 2) editing window 3)

output window. Project workspace window is for showing all the related files connected with

your project.

Editing window is the place where you will edit the code

Output window will show the output when you compile or build or run your project.

Now to start with new project follow the steps

Click on project menu and select new project

You will be asked to create new project in specific directory

Just move to your desired directory and there create a new folder for your project

named "first".

 Give the name of project as "test". By default it will be saved as *.v2 extension.

Now you will be asked to chose your target device for which you want to write the

program.

Scroll down the cursor and select generic from list. expand the list and select 8051

When you click OK, you will be asked to add startup code and file to your project folder.

click yes. Now on your screen expand target1 list fully.

Now click on file menu and select new file. editor window will open. Now you can

start writing your code.

28

Page 29: SMS Controlled Home Appliance

As you start writing program in C, same way here also you have to first include the

header file. Because our target is 8051 our header file will be "reg51.h"

If you scroll down cursor you will see that all the SFRs like P0-P3, TCON, TMOD,

ACC, bit registers and byte registers are already defined in this header file. so one can

directly use these register names in coding

Now you can write your program same as c language starting with void main()

After completing the code save the file in project folder with ".c" extension.

Now right click on "source group 1" in project workspace window. select "add files to

source group 1"

Select the C file you have created and click add button

you will see that the c file has been added in source group

Now to compile the program from project menu select "build target". In the output

window you will see the progress

If there is any compilation error then target will not be created. Remove all the errors

and again build the target till you find "0 Error(s)"

Now you are ready to run your program. from debug menu select "start/stop debug

session"

You will see your project workspace window now shows most of the SFRs as well as

GPRs r0-r7. Also one more window is now opened named "watches". in this window you

can see different variable values. 

If there is any compilation error then target will not be created. Remove all the errors

and again build the target till you find "0 Error(s)"

Now you are ready to run your program. from debug menu select "start/stop debug

session"

You will see your project workspace window now shows most of the SFRs as well as

GPRs r0-r7. Also one more window is now opened named "watches". in this window you

can see different variable values. 

29

Page 30: SMS Controlled Home Appliance

KEIL WORK SPACE

To add variable in watch window go to "watch#1" tab. then type F2 to edit and type

the name of your variable

If you want to see the output on ports go to peripheral menu and select I/O ports.

Select the desire port. you can give input to port pins by checking or unchecking any check

box. Here the check mark means digit 1 and no check mark means 0. the output on the pin

will be shown in same manner

30

Page 31: SMS Controlled Home Appliance

to run the program you can use any of the option provided "go", "step by step", "step

forward", "step over" etc.

Now after testing your program you need to down load this program on your target

board that is 8051. for this you have to create hex file

To create hex file first stop debug session. Again you will be diverted to project

workspace window.

Right click on "target 1" and select "option for target 1". Following window will

appear.

 

CONVERSION TO HEXADECIMAL FILE

31

Page 32: SMS Controlled Home Appliance

5. SOURCE CODE

#include <AT89X52.H> #include <smcl_lcd.h>

void ser_init(); void ser_out(unsigned char); void ser_conout(unsigned char*,unsigned char);

sbit light = P1^0; sbit fan = P1^1; sbit tv = P1^2; sbit radio = P1^3; unsigned char i,v[80],status,k;

void main() {

lcd_init(); ser_init(); ser_out('A');ser_out('T');ser_out(0x0d);del();ser_conout("AT+CMGF=1",9);ser_out(0x0d);del();ser_conout("AT+CPMS=",8);ser_out('"'); ser_out('S'); ser_out('M'); ser_out('"'); ser_out(0x0d); del(); {

i=1;status=ES=0;

ser_conout("AT+CMGR=1",9);ser_out(0x0d); EA=ES=1; del();del(); ES=0; if(i>65) {for(k=60; k<=70; k++) {

32

Page 33: SMS Controlled Home Appliance

if(v[k]=='1' && v[k+1]=='o' && v[k+2]=='n') {status=1; goto end;if(v[k]=='1' && v[k+1]=='o' && v[k+2]=='f' && v[k+3]=='f') {status=2; goto end;}if(v[k]=='2' && v[k+1]=='o' && v[k+2]=='n') {status=3; goto end;}if(v[k]=='2' && v[k+1]=='o' && v[k+2]=='f' && v[k+3]=='f') {status=4; goto end;}if(v[k]=='3' && v[k+1]=='o' && v[k+2]=='n') {status=5; goto end;}if(v[k]=='3' && v[k+1]=='o' && v[k+2]=='f' && v[k+3]=='f') {status=6; goto end;}if(v[k]=='4' && v[k+1]=='o' && v[k+2]=='n') {status=7; goto end;}if(v[k]=='4' && v[k+1]=='o' && v[k+2]=='f' && v[k+3]=='f') {status=8; goto end;}}status=0;end:if(status) {command(0xc0);write(v[k]);write(v[k+1]);write(v[k+2]);write(v[k+3]); }ser_conout("AT+CMGD=1",9); ser_out(0x0d); del();i=1;}

if(status==1) light=0;

else if(status==2) light=1;

else if(status==3) fan = 0;

else if(status==4) fan = 1;

else if(status==5) tv = 0;

else if(status==6) tv = 1;

else if(status==7) radio=0;

else if(status==8) radio=1;

}}

void ser_init(){

33

Page 34: SMS Controlled Home Appliance

EA=1; ES=1; SCON = 0X50; TMOD = 0X20; TH1 = 0XFD;TR1 = 1; EX0 = 1; IT0=1;

}

void ser_out(unsigned char val){

SBUF = val;delay (500);SCON = 0X50;delay(8000);

}

void ser_conout(unsigned char*dat,unsigned char ln){ unsigned char i; for(i=0;i<ln;i++)

{ ser_out(dat[i]); }

}

void ser_int(void) interrupt 4{ if (RI) { RI=0; v[i]=SBUF; i++;

}}

34

Page 35: SMS Controlled Home Appliance

5.1 FLOW CHART

35

If

END

if(v[k]=='1' && v[k+1]=='o' && v[k+2]=='f' && v[k+3]=='f') {status=2; goto end;}

if(v[k]=='2' && v[k+1]=='o' && v[k+2]=='n') {status=3; goto end;}

if(v[k]=='2' && v[k+1]=='o' && v[k+2]=='f' && v[k+3]=='f') {status=4; goto end;}

if(v[k]=='3' && v[k+1]=='o' && v[k+2]=='n') {status=5; goto end;}

if(v[k]=='3' && v[k+1]=='o' && v[k+2]=='f' && v[k+3]=='f') {status=6; goto end;}

f(v[k]=='4' && v[k+1]=='o' && v[k+2]=='n') {status=7; goto end;}

if(v[k]=='4' && v[k+1]=='o' && v[k+2]=='f' && v[k+3]=='f') {status=8; goto end;}

Page 36: SMS Controlled Home Appliance

Checking the received message from mobile

To initialize the Microcontroller Registers

36

Ser _init

{

EA=1; /* this pin enable for interrupt function */

ES=1; /* this pin enable for serial interrupt function */

SCON=0X50; // this for 8 bit data transreceive serially

TMOD=0X20; // timer1 select

TH1=0XFD; 9600 baud rate data transreceive serially

TR1=1; // timer on

EX0=1;IT0=1;

END

Ser_out

{

SBUF = val; // single data transmit to mobile function using SBUF registerdelay(500);

SCON = 0X50;

delay(8000);

Page 37: SMS Controlled Home Appliance

Data Transfer to Mobile

37

END

Ser_conout

{

for(i=0;i<ln;i++) {

ser_out(dat[i]);

}

Unsigned character i;

ENDS

Page 38: SMS Controlled Home Appliance

6. ADVANTAGES,DISADVANTAGES&APPLICATIONS

6.1ADVANTAGES

1. We can operate the devices from any distance.

2. Low Cost

3. Low power Consumption.

6.2 DISADVANTAGES

1. If there is no network at that particular time we can’t transfer the message

ON the device or OFF the device.

2. Without balance in the phone we cannot transfer the message.

3. This project operates only when there is power supply.

6.3 APPLICATIONS:

1. Used in Industrial Applications.

2. Used in long distance Applications.

3. Used in fields to control the motors.

4. In Home Appliances such as Water Heaters, Room Heaters and Air conditioners.

38

Page 39: SMS Controlled Home Appliance

7. RESULT AND CONCLUSION

7.1 RESULT

In this project we interfaced Mobile and Microcontroller with the help of RS232

level converter and controlled the operation of four devices(LED’S) using four Relay circuits

by sending an SMS to the mobile which is interfaced to the Microcontroller. We used two

mobiles for transferring the message using GSM Technology. Only mobiles with AT

commands can be interfaced with the controller.

7.2 CONLUSION

Power can be saved by controlling the machines ‘on’ and ‘off’ condition with a

single SMS. This project can be further enhanced by connecting batteries to the power supply

in case of power cut. Further an acknowledgement from the machine on its ‘on’ and ‘off’

condition by modifying the code can be done.

Future scope of this project can be done by connecting sensors to the

microcontroller which can sense the rise in temperature, detect smoke, fire and automatically

generate an SMS to alert the user.

39

Page 40: SMS Controlled Home Appliance

8. REFERENCES

1. Using SMS in Mobile Phone for Home Appliances Controlling Through PC Parallel Port

Interfacing by Fadhil T. Aula, University of Salahaddin, College of Engineering, and

Electrical Engineering Department. Erbil, Iraq

2. SMS Based Wireless Home Appliance Control System (HACS) for Automating

Appliances and Security by Malik Sikandar Hayat Khiyal, Aihab Khan, and Erum Shehzadi

Software Engineering Dept., Fatima Jinnah Women University, Rawalpindi, Pakistan.

3. System integration of WAP and SMS for home network system by Chi-Hsiang Wu and

Rong-Hong Jan Department of Computer and Information Science, National Chiao Tung

University, 1001 Ta Hsueh Rd., Hsinchu 30050, Taiwan.

4. Remote-Controllable Power Outlet System for Home Power Management by Chia-

Hung Lien;   Ying-Wen Bai;   Ming-Bo Lin; at Nat. Taiwan Univ. of Sci. & Technol.,

Taipei in  Consumer Electronics, IEEE Transactions on Nov. 2007 Volume: 53  Sponsored

by: IEEE Consumer Electronics Society.

5. SMS remote control system for household appliances based on GR47 by WU Zhi-hui,

CHEN Long-dao, YE Qiang (College of Electrical Engineering, Zhejiang University,

Hangzhou 310027, China).

6. Micro Controllers by Deshmukh, Tata McGraw Hill Edition.

7. Microcontrollers (Theory & Applications) by A.V. Deshmuk, WTMH, 2005.

8. The 8051 Microcontroller and Embedded Systems by Mazidi and Mazidi,PHI, 2000.

9. Microcontrollers Architecture, Programming, Interfacing and System Design by Raj

Kamal, Pearson Education, 2005. Microcontroller and Embedded Systems by JaniceGillispie

Mazidi, Rolin D.Mc Kinlay Pearson Edition Inc .2 nd Edition, 2008.

40

Page 41: SMS Controlled Home Appliance

41