53
TRAINING REPORT OF SIX WEEKS INDUSTRIAL TRAINING, UNDERTAKEN AT APPIN TECHNOLOGY LAB ON EMBEDDED SYSTEMS SUBMITTED IN PARTIAL FULFILLMENT OF THE DEGREE (Bachelor of Engineering- ECE- 2012) Under the Guidance of: Submitted By: Name: Paras Khanna Name: Daksh Raj Chopra Department: University Roll No.:B120020081 __________________________________________________________ Chitkara University, Himachal Pradesh.

DTMF based Home Automation System

Embed Size (px)

Citation preview

Page 1: DTMF based Home Automation System

TRAINING REPORT

OF

SIX WEEKS INDUSTRIAL TRAINING,

UNDERTAKEN

AT

APPIN TECHNOLOGY LAB

ON

EMBEDDED SYSTEMS

SUBMITTED IN PARTIAL FULFILLMENT OF THE DEGREE

(Bachelor of Engineering- ECE- 2012)

Under the Guidance of: Submitted By:

Name: Paras Khanna Name: Daksh Raj Chopra

Department: University Roll No.:B120020081

__________________________________________________________ Chitkara University, Himachal Pradesh.

Page 2: DTMF based Home Automation System

ACKNOWLEGMENT

I take this opportunity to express my profound gratitude and deep regards to my guide Ravi

Sir for his exemplary guidance, monitoring and constant encouragement throughout the

course of this thesis. The blessing, help and guidance given by him time to time shall carry

me a long way in the journey of life on which I am about to embark.

I also take this opportunity to express a deep sense of gratitude to Paras Khanna, , Appin

Technology Lab for his cordial support, valuable information and guidance, which helped me

in completing this task through various stages.

I am obliged to staff members of Appin Technology Lab for the valuable information

provided by them in their respective fields. I am grateful for their cooperation during the

period of my assignment.

Lastly, I thank almighty, my parents, brother, sisters and friends for their constant

encouragement without which this assignment would not be possible.

Page 3: DTMF based Home Automation System

PREFACE

There is a famous saying “The theory without practical is lame and practical without theory is

blind.”

This project is the result of six weeks training at Appin Technology Lab. Summer training is

an integral part of “Engineering” course and it aims at providing a first-hand

experience of industry to students. This practical experience helps the students to view the

industrial work and knowledge closely. I was really fortunate of getting an opportunity to

pursue my Summer Training in reputed, well established, fast growing and professionally managed

organization like Appin Technology Lab assigned “DTMF Controlled Home Automation

System Using 8051.”

Page 4: DTMF based Home Automation System

TABLE OF CONTENTS

S. No. Contents Page No.

1. Company Profile…………………………………………………..1

2. Project Undertaken………………………………………………...2

3. Introduction to Project……………………………………………..3

4. Modular description………………………………………………..4

5. Design……………………………………………………………...5

6. Coding……………………………………………………………..6

7. Test cases……………………………………………………….....7

8. Industry Application……………………………………………....8 9. Future Enhancements……………………………………………....9 10. Data Sheets…………………………………………………………10

Page 5: DTMF based Home Automation System

I. Company Profile

II. Project Undertaken

I chose the project of DTMF controlled home appliance system. The main aim of the project

is to operate the any home appliances by using an IR remote which is interfaced with the

microcontroller. IR remote acts as the transmitter in t h i s p r o j ec t . W hen a bu t to n i s

p r e s s ed i n t h e r em ot e , t h e s i gn a l w i l l b e p a s s ed an d received by the IR

receiver TSOP Receiver. This signal is sent to the microcontroller which decodes

the signal and performs the corresponding action in accordance with the button

pressed in the remote. For example, if number 1 is pressed in the remote, the load

w i l l be s wi t ch ed o n / o f f accor d i n g to t he us e r r equ i r em en t .

The need for the above project was that this project firstly it saves our time. If you are stuck

in traffic you can switch on your microwave oven on slow cooking mode. By the time you

reach your home your food will be ready. You don’t have go to each room to check whether

the lights are on/off. You can do with a click of single button. Secondly, it save our money in

the long run. There are some appliances like a television which we switch off but not its

power supply. There is a Led still glowing in it which uses electricity. If we have this

television attached to our project then we can switch off its power supply whenever we want

and there are many other devices like this. Thirdly, it for self-maintenance and security.

Security as in if we by chance forgot to switch off any of lights then we can switch off from

our phones. Lastly, we all know that all this will make our life easy and trouble free.

Industrial applications for the project made are that one can control home appliances from

anywhere in the world even we are sitting a cup of tea in United States of America. Secondly,

it reduces wastage of electricity as discussed earlier that if we forget to switch off the lights.

Last but not the least it is very low cost compared to other technologies like GSM.

III. Introduction to Project – DTMF based Home Appliance

System

Traditionally electrical appliances in a home are controlled via switches that regulate the

electricity to these devices. As the world gets more and more technologically advanced, we

find new technology coming in deeper and deeper into our personal lives even at home.

Home automation is becoming more and more popular around the world and is becoming a

common practice. The process of home automation works by making everything in the house

automatically controlled using technology to control and do the jobs that we would normally

do manually. Home automation takes care of a lot of different activities in the house.

In the above project we can control any electrical appliances through mobile or landline from

any part of the country. One base unit is connected to the basic mobile phone in parallel with

the other mobile phone. When we want to control any electrical appliances through outer

phone then first we dial the home number, bell is ringing and after few seconds bell phone is

automatic on and that switches on the base unit to operate. Now we press the single digital

excess code, if the excess code is ok then unit give a tone pulse and switch on the base unit.

Now, again we press the switch on/off code to on/off any electrical appliances. With the help

of this code unit is on and base unit give a acknowledge pulse for on and off separately.

Page 6: DTMF based Home Automation System

We are going to develop a cellular phone based home/office appliance. This system is

designed for controlling arbitrary devices, it includes a cell phone (not included with the

system kit, end user has to connect his/her cell phone to the system) which is connect to the

system via head set. To active the cellular phone unit on the system a call is to be made and

as the call is answered, in response the user would enter a two/three digit password to access

the system to control devices. As the caller press the specific password, it results in turning

ON or OFF specific device. The device switching is achieved by Relays. Security preserved

because these dedicated passwords owned and known by selected persons only. For instance,

our system contains an alarm unit giving the user a remote on/off mechanism, which is

capable of informing up to five different numbers over telephony network about the nature of

the event.

This project we propose a unique System for Home automation utilizing Dual Tone Multi

Frequency (DTMF) that is paired with a wireless module to provide seamless wireless control

over many devices in a house. The block diagram is a shown below. This user console has

many keys, each corresponding to the device that needs to be activated. The encoder encodes

the user choice and sends via a FM transmitter. The FM receiver receives the modulated

signal and demodulates it and the user choice is determined by the DTMF decoder. Based

upon this the required appliance is triggered.

Complete circuit is divided into four parts.

1. DTMF DECODER

2. MICROCONTROLLER

3. EXCESS CONTROL CIRCUIT

4. AUTOMATIC ON THROUGH OUTER PHONE

III.1 DTMF Signalling

Dual-tone multi-frequency signaling (DTMF) is used for telecommunication signaling over

analog telephone lines in the voice-frequency band between telephone handsets and other

communications devices and the switching center. The version of DTMF that is used in push-

button telephones for tone dialing is known as Touch-Tone. It was developed by Western

Electric and first used by the Bell System in commerce, using that name as a registered

trademark. DTMF is standardized by ITU-T Recommendation Q.23. It is also known in the

UK as MF4.

Other multi-frequency systems are used for internal signaling within the telephone network.

Introduced by AT&T in 1963, the Touch-Tone system using the telephone keypad gradually

replaced the use of rotary dial and has become the industry standard for landline service.

Page 7: DTMF based Home Automation System

Prior to the development of DTMF, numbers were dialled on automated telephone systems by

means of pulse dialing (dial pulse, DP, in the U.S.) or loop disconnect (LD) signalling, which

functions by rapidly disconnecting and re-connecting the calling party's telephone line,

similar to flicking a light switch on and off. The repeated interruptions of the line, as

the dial spins, sounds like a series of clicks. The exchange equipment interprets these dial

pulses to determine the dialed number. Loop disconnect range was restricted by telegraphic

distortion and other technical problems, and placing calls over longer distances required

either operator assistance (operators used an earlier kind of multi-frequency dial) or the

provision of subscriber trunk dialing equipment.

Other vendors of compatible telephone equipment called the Touch-Tone feature Tone

dialing or DTMF, or used their own registered trade names such as the Digitone of Northern

Electric (later known as Nortel Networks).

The DTMF system uses eight different frequency signals transmitted in pairs to represent 16

different numbers, symbols and letters - as detailed below.

As a method of in-band signaling, DTMF tones were also used by cable

television broadcasters to indicate the start and stop times of local commercial insertion

points during station breaks for the benefit of cable companies. Until better out-of-band

signaling equipment was developed in the 1990s, fast, unacknowledged, and loud DTMF

tone sequences could be heard during the commercial breaks of cable channels in the United

States and elsewhere. Previously, terrestrial television stations also used DTMF tones to shut

off and turn on remote transmitters.

Multi-frequency signaling is a group of signaling methods that use a mixture of two pure

tone (pure sine wave) sounds. Various MF signaling protocols were devised by the Bell

System and CCITT. The earliest of these were for in-band signaling between switching

centers, where long-distance telephone operators used a 16-digitkeypad to input the next

portion of the destination telephone number in order to contact the next downstream long-

distance telephone operator. This semi-automated signaling and switching proved successful

in both speed and cost effectiveness. Based on this prior success with using MF by specialists

to establish long-distance telephone calls, Dual-tone multi-frequency (DTMF) signaling was

developed for the consumer to signal their own telephone-call's destination telephone number

instead of talking to a telephone operator.

AT&Ts Compatibility Bulletin No. 105 described the product as "a method for pushbutton

signaling from customer stations using the voice transmission path." In order to prevent

consumer telephones from interfering with the MF-based routing and switching between

telephone switching centers, DTMF's frequencies differ from all of the pre-existing MF

signaling protocols between switching centers: MF/R1, R2, CCS4, CCS5, and others that

were later replaced by SS7 digital signaling. DTMF, as used in push-button telephone tone

dialing, was known throughout the Bell System by the trademark Touch-Tone. This term was

first used by AT&T in commerce on July 5, 1960 and then was introduced to the public on

November 18, 1963, when the first push-button telephone was made available to the public. It

was AT&T's registered trademark from September 4, 1962 to March 13, 1984, and is

standardized by ITU-T Recommendation Q.23. It is also known in the UK as MF4.

The engineers had envisioned phones being used to access computers, and surveyed a number

of companies to see what they would need for this role. This led to the addition of the number

Page 8: DTMF based Home Automation System

sign (#, ''pound'' or "diamond" in this context, "hash", "square" or "gate" in the UK, and

"octothorpe'' by the original engineers) and asterisk or "star" (*) keys as well as a group of

keys for menu selection: A, B, C and D. In the end, the lettered keys were dropped from most

phones, and it was many years before the two symbol keys became widely used for vertical

service codes such as *67 in the United States of America and Canada to suppress caller ID.

Public payphones that accept credit cards use these additional codes to send the information

from the magnetic strip.

The United States Armed Forces also used the letters, relabelled, in their now-

defunct AUTOVON telephone system to indicate the priority of a call. Precedence dialing is

still done on the military phone networks, but using number combinations (Example:

Entering 93 before a number is a priority call) rather than the separate tones and

the Government Emergency Telecommunications Service has superseded AUTOVON for

any civilian priority telephone company access.

Present-day uses of the A, B, C and D keys on telephone networks are few, and exclusive to

network control. For example, the A key is used on some networks to cycle through different

carriers at will (thereby listening in on calls). Their use is probably prohibited by most

carriers. The A, B, C and D tones are used in radio phone patch and repeater operations to

allow, among other uses, control of the repeater while connected to an active phone line.

The *, #, A, B, C and D keys are still widely used worldwide by amateur radio operators for

repeater control, remote-base operations and some telephone communications systems.

DTMF signaling tones can also be heard at the start or end of some VHS (Video Home

System) cassette tapes. Information on the master version of the video tape is encoded in the

DTMF tone. The encoded tone provides information to automatic duplication machines, such

as format, duration and volume levels, in order to replicate the original video as closely as

possible.

DTMF tones are sometimes used in caller ID systems to transfer the caller ID information,

but in the United States only Bell 202 modulated FSK signaling is used to transfer the data.

Fig 1. DTMF keypad layout.

Ac register signalling is used in dtmf telephones, here tones rather than make/break pulse are

used for dialling, and each dialled digit is uniquely represented by a pair of sine waves tones.

These tones (one from low group for row and another from high group from column) are sent

to the exchange when a digit is dialled by pushing the key, these tone lies within the speech

band of 300 to 3400 Hz, and are chosen so as to minimize the possibility of any valid

frequency pair existing in normal speech simultaneously. Actually, this minimisator is made

possible by forming pairs with one tone from the higher group and the other from the lower

Page 9: DTMF based Home Automation System

of frequencies. A valid dtmf signal is the sum of two tones, one from a lower group (697-940

Hz) and the other from a higher group (1209-1663 Hz). Each group contains four individual

tones. This scheme allows 10 unique combinations. Ten of these code represent digits 1

through 9 and 0. Tones in DTMF dialling are so chose that none of the tones is harmonic of

are other tone. Therefore, there is no change of distortion caused by harmonics. Each tone is

sent as along as the key remains pressed. The dtmf signal contains only one component from

each of the high and low group. This significantly simplifies decoding because the composite

dtmf signal may be separated with band pass filters into single frequency components, each

of which may be handled individually.

Fig 2. 1209 Hz on 697 Hz to make the 1 tone

The underlying principle mainly relies up on the ability of DTMF (Double Tune Multi

Frequency) ICs to generate DTMF corresponding to a number or code in the number pad and

to detect the same number or code from its corresponding DTMF. In detail, a DTMF

generator generates two frequencies corresponding to a number or code in the number pad

which will be transmitted through the communication networks, constituting the transmitter

section which is simply equivalent to a mobile set. In the receiver part, the DTMF detector

IC, for example IC MT 8870 detects the number or code represented by DTMF back, through

the inspection of the two transmitted frequencies. The DTMF frequencies representing the

number/ codes are shown below.

Table 1. DTMF keypad frequencies (with sound clips)

Page 10: DTMF based Home Automation System

IV. Modular Description

List of components used in the project are:-

1. Microcontroller - AT89S52

2. DTMF Decoder – MT8870

3. ULN 2003

4. Relay

5. Led

6. Resistors

7. Pull – Up Resistor

8. Capacitors

9. Crystal Oscillator

10. Push Button

11. Mic

12. Voltage Regulator

13. Bulb Holders

14. Bulbs

15. Plug

16. AC Power Supply

1. Microcontroller - AT89S52

Fig 3. Architecture of 8051 Family

Page 11: DTMF based Home Automation System

1.1 Features

• Compatible with MCS-51™ Products

• 4K Bytes of In-System Reprogrammable Flash Memory

– Endurance: 1,000 Write/Erase Cycles

• Fully Static Operation: 0 Hz to 24 MHz

• Three-Level Program Memory Lock

• 128 x 8-Bit Internal RAM

• 32 Programmable I/O Lines

• Two 16-Bit Timer/Counters

• Six Interrupt Sources

• Programmable Serial Channel

• Low Power Idle and Power Down Modes

1.2 Description

The AT89S51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes

of Flash Programmable and Erasable Read Only Memory (PEROM). The device is

manufactured using Atmel’s high density nonvolatile memory technology and is compatible

with the industry standard MCS-51™ instruction set and pinout. 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 Flash on a monolithic chip, the Atmel

AT89S51 is a powerful microcomputer which provides a highly flexible and cost effective

solution to many embedded control applications. The AT89S51 provides the following

standard features: 4K bytes of Flash, 128 bytes of RAM, 32 I/O lines, two 16-bit timer/counters,

five vector two-level interrupt architecture, a full duplex serial port, and on-chip oscillator and

clock circuitry.

In addition, the AT89S51 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.

Page 12: DTMF based Home Automation System

The Power down Mode saves the RAM contents but freezes the oscillator disabling all other

chip functions until the next hardware reset.

1.3 Pin Description

Fig 4. Pin diagram of 8051

Page 13: DTMF based Home Automation System

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.

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

Page 14: DTMF based Home Automation System

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

PSEN

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

Page 15: DTMF based Home Automation System

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

Page 16: DTMF based Home Automation System

Oscillator Characteristics

XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which can

be configured for use as an on-chip oscillator, as shown in Figure 1. Either a quartz crystal or

ceramic resonator may be used. To drive the device from an external clock source, XTAL2

should be left unconnected while XTAL1 is driven as shown in Figure 2.There are no

requirements on the duty cycle of the external clock signal, since the input to the internal

clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage

high and low time specifications must be observed.

Fig 5. External Clock Drive Configuration

Idle Mode

In idle mode, the CPU puts itself to sleep while all the on chip peripherals remain active. The

mode is invoked by software. The content of the on-chip RAM and all the special functions

registers remain unchanged during this mode. The idle mode can be terminated by any enabled

Interrupt or by hardware reset. It should be noted that when idle is terminated by a Hardware

reset, the device normally resumes program execution, from where it left off, up to two machine

Page 17: DTMF based Home Automation System

cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to

internal RAM in this event, but access to the port pins is not inhibited. To eliminate the

possibility of an unexpected write to a port pin when Idle is terminated by reset, the instruction

following the one that invokes Idle should not be one that writes to a port pin or to external

memory.

Status of External Pins during Idle and Power down Modes

Mode Program Memory ALE PSEN PORT0 PORT1 PORT2 PORT3

Idle Internal 1 Data

Idle External 1 Float Data Address Data

Power down Internal 0 Data

Power down External 0 Float Data

Power down Mode

In the power down mode the oscillator is stopped, and the instruction that invokes power down

is the last instruction executed. The on-chip RAM and Special Function Registers retain their

values until the power down mode is terminated. The only exit from power down is a hardware

reset. Reset redefines the SFRs but does not change the on-chip RAM. The reset should not be

activated before VCC is restored to its normal operating level and must be held active long

enough to allow the oscillator to restart and stabilize.

Program Memory Lock Bits

On the chip are three lock bits which can be left un-programmed (U) or can be programmed

(P) to obtain the additional features listed in the table below:

When lock bit 1 is programmed, the logic level at the EA pin is sampled and latched during

reset. If the device is powered up without a reset, the latch initializes to a random value, and

holds that value until reset is activated. It is necessary that the latched value of EA be in

agreement with the current logic level at that pin in order for the device to function properly.

Page 18: DTMF based Home Automation System

Lock Bit Protection Modes

Program Lock Bits Protection Type

LB1 LB2 LB3

1 U No program lock features.

2 P U MOVC instructions executed from external program memory are disabled from fetching

code

Bytes from internal memory, EA is sampled and latched on reset, and further programming of

the

Flash is disabled.

3 P U Same as mode 2, also verify is disabled.

4 P same as mode 3, also external execution is disabled.

Programming the Flash

The AT89S51 is normally shipped with the on-chip Flash memory array in the erased state

(that is, contents = FFH) and ready to be programmed. The programming interface accepts

either a high-voltage (12-volt) or a low-voltage (VCC) program enable signal. The low voltage

programming mode provides a convenient way to program the AT89S51 inside the user’s

system, while the high-voltage programming mode is compatible with conventional third party

Flash or EPROM programmers. The AT89S51 is shipped with either the high-voltage or low-

voltage programming mode enabled. The respective top-side marking and device signature

codes are listed in the following table. The AT89S51 code memory array is programmed byte-

by byte

In either programming mode. To program any nonblank byte in the on-chip Flash Memory, the

entire memory must be erased using the Chip Erase Mode.

Programming Algorithm:

Page 19: DTMF based Home Automation System

Before programming the AT89S51, the address, data and control signals should be set up

according to the Flash programming mode table and Figures 3 and 4. To program the AT89S51,

take the following steps.

1. Input the desired memory location on the address lines.

2. Input the appropriate data byte on the data lines.

3. Activate the correct combination of control signals.

4. Raise EA/VPP to 12V for the high-voltage programming mode.

5. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. The byte-write

cycle is self-timed and typically takes no more than 1.5 ms. Repeat steps 1 through 5, changing

the address and data for the entire array or until the end of the object file is reached.

Data Polling:

The AT89S51 features Data Polling to indicate the end of a write cycle. During a write cycle,

an attempted read of the last byte written will result in the complement of the written datum on

PO.7. Once the write cycle has been completed, true data are valid on all outputs, and the next

cycle may begin. Data Polling may begin any time after a write cycle has been initiated.

Ready/Busy:

The progress of byte programming can also be monitored by the RDY/BSY output signal. P3.4

is pulled low after ALE goes high during programming to indicate BUSY. P3.4 is pulled high

again when programming is done to indicate READY.

Program Verify:

If lock bits LB1 and LB2 have not been programmed, the programmed code data can be read

back via the address and data lines for verification. The lock bits cannot be verified directly.

Verification of the lock bits is achieved by observing that their features are enabled.

Page 20: DTMF based Home Automation System

Chip Erase:

The entire Flash array is erased electrically by using the proper combination of control signals

and by holding ALE/PROG low for 10 ms. The code array is written with all “1”s. The chip

erase operation must be executed before the code memory can be re-programmed.

Reading the Signature Bytes:

The signature bytes are read by the same procedure as a normal verification of locations 030H,

031H, and 032H, except that P3.6 and P3.7 must be pulled to a logic low. The values returned

are as follows.

(030H) = 1EH indicates manufactured by Atmel

(031H) = 51H indicates 89S51

(032H) = FFH indicates 12V programming

(032H) = 05H indicates 5V programming

Programming Interface

Every code byte in the Flash array can be written and the entire array can be erased by using

the appropriate combination of control signals. The write operation cycle is self timed and once

initiated, will automatically time itself to completion. All major programming vendors offer

worldwide support for the Atmel microcontroller series. Please contact your local

programming vendor for the appropriate software revision.

Flash Programming Modes

Note: 1. Chip Erase requires a 10-ms PROG pulse.

SPECIAL FUNCTION REGISTER (SFR) ADDRESSES:

ACC ACCUMULATOR 0E0H

Page 21: DTMF based Home Automation System

B B REGISTER 0F0H

PSW PROGRAM STATUS WORD 0D0H

SP STACK POINTER 81H

DPTR DATA POINTER 2 BYTES

DPL LOW BYTE OF DPTR 82H

DPH HIGH BYTE OF DPTR 83H

P0 PORT0 80H

P1 PORT1 90H

P2 PORT2 0A0H

P3 PORT3 0B0H

TMOD TIMER/COUNTER MODE CONTROL 89H

TCON TIMER COUNTER CONTROL 88H

TH0 TIMER 0 HIGH BYTE 8CH

TLO TIMER 0 LOW BYTE 8AH

TH1 TIMER 1 HIGH BYTE 8DH

TL1 TIMER 1 LOW BYTE 8BH

SCON SERIAL CONTROL 98H

SBUF SERIAL DATA BUFFER 99H

PCON POWER CONTROL 87H

TMOD (TIMER MODE) REGISTER

Page 22: DTMF based Home Automation System

Both timers are the 89S51 share the one register TMOD. 4 LSB bit for the timer 0 and 4 MSB

for the timer 1.

In each case lower 2 bits set the mode of the timer

Upper two bits set the operations.

GATE: Gating control when set. Timer/counter is enabled only while the INTX pin is high and

the TRx control pin is set. When cleared, the timer is enabled whenever the TRx control bit is

set.

C/T: Timer or counter selected cleared for timer operation (input from internal system clock)

M1 Mode bit 1

M0 Mode bit 0

M1 M0 MODE OPERATING MODE

0 0 0 13 BIT TIMER/MODE

0 1 1 16 BIT TIMER MODE

1 0 2 8 BIT AUTO RELOAD

1 1 3 SPLIT TIMER MODE

PSW (PROGRAM STATUS WORD)

CY PSW.7 CARRY FLAG

AC PSW.6 AUXILIARY CARRY

F0 PSW.5 AVAILABLE FOR THE USER FRO GENERAL PURPOSE

RS1 PSW.4 REGISTER BANK SELECTOR BIT 1

Page 23: DTMF based Home Automation System

RS0 PSW.3 REGISTER BANK SELECTOR BIT 0

0V PSW.2 OVERFLOW FLAG

-- PSW.1 USER DEFINABLE BIT

P PSW.0 PARITY FLAG SET/CLEARED BY HARDWARE

PCON REGISATER (NON BIT ADDRESSABLE)

If the SMOD = 0 (DEFAULT ON RESET)

TH1 = CRYSTAL FREQUENCY

256---- ____________________

384 X BAUD RATE

If the SMOD IS = 1

CRYSTAL FREQUENCY

TH1 = 256--------------------------------------

192 X BAUD RATE

There are two ways to increase the baud rate of data transfer in the 8051

1. To use a higher frequency crystal

2. To change a bit in the PCON register

PCON register is an 8 bit register. Of the 8 bits, some are unused, and some are used for the

power control capability of the 8051. The bit which is used for the serial communication is D7,

the SMOD bit. When the 8051 is powered up, D7 (SMOD BIT) OF PCON register is zero. We

can set it to high by software and thereby double the baud rate

Page 24: DTMF based Home Automation System

BAUD RATE COMPARISION FOR SMOD = 0 AND SMOD =1

TH1 (DECIMAL) HEX SMOD =0 SMOD =1

-3 FD 9600 19200

-6 FA 4800 9600

-12 F4 2400 4800

-24 E8 1200 2400

XTAL = 11.0592 MHZ

IE (INTERRUPT ENABLE REGISTOR)

EA IE.7 Disable all interrupts if EA = 0, no interrupts is acknowledged

If EA is 1, each interrupt source is individually enabled or disabled

By sending or clearing its enable bit.

IE.6 NOT implemented

ET2 IE.5 enables or disables timer 2 overflag in 89c52 only

ES IE.4 Enables or disables all serial interrupt

ET1 IE.3 Enables or Disables timer 1 overflow interrupt

EX1 IE.2 Enables or disables external interrupt

ET0 IE.1 Enables or Disables timer 0 interrupt.

EX0 IE.0 Enables or Disables external interrupt 0

INTERRUPT PRIORITY REGISTER

If the bit is 0, the corresponding interrupt has a lower priority and if the bit is 1 the

corresponding interrupt has a higher priority

Page 25: DTMF based Home Automation System

IP.7 NOT IMPLEMENTED, RESERVED FOR FUTURE USE.

IP.6 NOT IMPLEMENTED, RESERVED FOR FUTURE USE

PT2 IP.5 DEFINE THE TIMER 2 INTERRUPT PRIORITY LELVEL

PS IP.4 DEFINES THE SERIAL PORT INTERRUPT PRIORITY LEVEL

PT1 IP.3 DEFINES THE TIMER 1 INTERRUPT PRIORITY LEVEL

PX1 IP.2 DEFINES EXTERNAL INTERRUPT 1 PRIORITY LEVEL

PT0 IP.1 DEFINES THE TIMER 0 INTERRUPT PRIORITY LEVEL

PX0 IP.0 DEFINES THE EXTERNAL INTERRUPT 0 PRIORITY LEVEL

SCON: SERIAL PORT CONTROL REGISTER, BIT ADDRESSABLE

SCON

SM0 : SCON.7 Serial Port mode specified

SM1 : SCON.6 Serial Port mode specifier

SM2 : SCON.5

REN : SCON.4 Set/cleared by the software to Enable/disable reception

TB8 : SCON.3 the 9th bit that will be transmitted in modes 2 and 3, Set/cleared

By software

RB8 : SCON.2 In modes 2 &3, is the 9th data bit that was received. In mode 1,

If SM2 = 0, RB8 is the stop bit that was received. In mode 0

RB8 is not used

T1 : SCON.1 Transmit interrupt flag. Set by hardware at the end of the 8th bit

R1 SCON.0 Receive interrupt flag. Set by hardware at the end of the 8th bit

Page 26: DTMF based Home Automation System

TCON TIMER COUNTER CONTROL REGISTER

This is a bit addressable

TF1 TCON.7 Timer 1 overflows flag. Set by hardware when the Timer/Counter 1

Overflows. Cleared by hardware as processor

TR1 TCON.6 Timer 1 run control bit. Set/cleared by software to turn Timer

Counter 1 On/off

TF0 TCON.5 Timer 0 overflows flag. Set by hardware when the timer/counter 0

Overflows. Cleared by hardware as processor

TR0 TCON.4 Timer 0 run control bit. Set/cleared by software to turn timer

Counter 0 on/off.

IE1 TCON.3 External interrupt 1 edge flag

ITI TCON.2 Interrupt 1 type control bit

IE0 TCON.1 External interrupt 0 edge

IT0 TCON.0 Interrupt 0 type control bit.

MCS-51 FAMILY INSTRUCTION SET

Notes on Data Addressing Modes

Rn - Working register R0-R7

Direct - 128 internal RAM locations, any l/O port, control or status register

@Ri - Indirect internal or external RAM location addressed by register R0 or R1

#data - 8-bit constant included in instruction

#data 16 - 16-bit constant included as bytes 2 and 3 of instruction

Bit - 128 software flags, any bit addressable l/O pin, control or status bit

Page 27: DTMF based Home Automation System

A - Accumulator

Notes on Program Addressing Modes

addr16 - Destination address for LCALL and LJMP may be anywhere within the 64-Kbyte

program memory address space. addr11 - Destination address for ACALL and AJMP will be

within the same 2-Kbyte page of program memory as the first byte of the following instruction.

Rel - SJMP and all conditional jumps include an 8 bit offset byte. Range is + 127/– 128 bytes

relative to the first byte of the following instruction.

ACALL addr11

Function: Absolute call

Description: ACALL unconditionally calls a subroutine located at the indicated address. The

instruction increments the PC twice to obtain the address of the following instruction, then

pushes the 16-bit result onto the stack (low-order byte first) and increments the stack pointer

twice. The destination address is obtained by successively concatenating the five high-order

bits of the incremented PC, op code bits 7-5, and the second byte of the instruction. The

subroutine called must therefore start within the same 2K block of program memory as the first

byte of the instruction following ACALL. No flags are affected. Example: Initially SP equals

07H. The label”SUBRTN” is at program memory location 0345H. After executing the

instruction ACALL SUBRTN at location 0123H, SP will contain 09H, internal RAM location

08H and 09H will contain 25H and 01H, respectively, and the PC will contain 0345H.

Operation: ACALL

(PC) ¬ (PC) + 2

(SP) ¬ (SP) + 1

((SP)) ¬ (PC7-0)

(SP) ¬ (SP) + 1

((SP)) ¬ (PC15-8)

Page 28: DTMF based Home Automation System

(PC10-0) ¬ Page address

Bytes: 2

Cycles: 2

Encoding: a10 a9 a8 1 0 0 0 1 a7 a6 a5 a4 a3 a2 a1 a0

JB bit, rel

Function: Jump if bit is set

Description: If the indicated bit is a one, jump to the address indicated; otherwise proceed with

the next instruction. The branch destination is computed by adding the signed relative-

displacement in the third instruction byte to the PC, after incrementing the PC to the first byte

of the next instruction. The bit tested is not modified. No flags are affected.

Example: The data present at input port 1 is 11001010B. The accumulator holds 56

(01010110B). The instruction sequence

JB P1.2, LABEL1

JB ACC.2, LABEL2

will cause program execution to branch to the instruction at label LABEL2.

Operation: JB

(PC) ¬ (PC) + 3

if (bit) = 1

then (PC) ¬ (PC) + rel

Bytes: 3

Cycles: 2

Encoding: 0 0 1 0 0 0 0 0 bit address rel. address

JNB bit, rel

Function: Jump if bit is not set

Page 29: DTMF based Home Automation System

Description: If the indicated bit is a zero, branch to the indicated address; otherwise proceed

with the next instruction. The branch destination is computed by adding the signed relative-

displacement in the third instruction byte to the PC, after incrementing the

PC to the first byte of the next instruction. The bit tested is not modified. No flags are affected.

Example: The data present at input port 1 is 11001010B. The accumulator holds 56H

(01010110B). The instruction sequence

JNB P1.3, LABEL1

JNB ACC.3, LABEL2

will cause program execution to continue at the instruction at label LABEL2.

Operation: JNB

(PC) ¬ (PC) + 3

if (bit) = 0

then (PC) ¬ (PC) + rel.

Bytes: 3

Cycles: 2

Encoding: 0 0 1 1 0 0 0 0 bit address rel. address

LCALL addr16

Function: Long call

Description: LCALL calls a subroutine located at the indicated address. The instruction adds

three to the program counter to generate the address of the next instruction and then pushes the

16-bit result onto the stack (low byte first), incrementing the stack pointer by two. The high-

order and low-order bytes of the PC are then loaded, respectively, with the second and third

bytes of the LCALL instruction. Program execution continues with the instruction at this

address. The subroutine may therefore begin anywhere in the full 64 Kbytes program memory

address space. No flags are affected.

Page 30: DTMF based Home Automation System

Example: Initially the stack pointer equals 07H. The label”SUBRTN” is assigned to program

memory location 1234H. After executing the instruction

LCALL SUBRTN

at location 0123H, the stack pointer will contain 09H, internal RAM locations 08H and 09H

will contain 26H and 01H, and the PC will contain 1234H.

Operation: LCALL

(PC) ¬ (PC) + 3

(SP) ¬ (SP) + 1

((SP)) ¬ (PC7-0)

(SP) ¬ (SP) + 1

((SP)) ¬ (PC15-8)

(PC) ¬ addr15-0

Bytes: 3

Cycles: 2

Encoding: 0 0 0 1 0 0 1 0 addr15. . addr8 addr7. . addr0

MOV <dest-byte>, <src-byte>

Function: Move byte variable

Description: The byte variable indicated by the second operand is copied into the location

specified by the first operand. The source byte is not affected. No other register or flag is

affected. This is by far the most flexible operation. Fifteen combinations of source and

destination addressing modes are allowed.

Example: Internal RAM location 30H holds 40H. The value of RAM location 40H is 10H. The

data present at input port 1 is 11001010B (0CAH).

MOV R0, #30H; R0 < = 30H

Page 31: DTMF based Home Automation System

MOV A, @R0; A < = 40H

MOV R1, A; R1 < = 40H

MOV B, @R1; B < = 10H

MOV @R1, P1; RAM (40H) < = 0CAH

MOV P2, P1; P2 < = 0CAH

leaves the value 30H in register 0, 40H in both the accumulator and register 1, 10H

in register B, and 0CAH (11001010B) both in RAM location 40H and output on port 2.

MOV A, Rn

Operation: MOV

(A) ¬ (Rn)

Bytes: 1

Cycles: 1

RET

Function: Return from subroutine

Description: RET pops the high and low-order bytes of the PC successively from the stack,

decrementing the stack pointer by two. Program execution continues at the resulting address,

generally the instruction immediately following an ACALL or LCALL. No flags are affected.

Example: The stack pointer originally contains the value 0BH. Internal RAM locations 0AH

and 0BH contain the values 23H and 01H, respectively. The instruction RET will leave the

stack pointer equal to the value 09H. Program execution will continue at location 0123H.

Operation: RET

Page 32: DTMF based Home Automation System

(PC15-8) ¬ ((SP))

(SP) ¬ (SP) – 1

(PC7-0) ¬ ((SP))

(SP) ¬ (SP) – 1

Bytes: 1

Cycles: 2

Encoding: 0 0 1 0 0 0 1 0

SETB <bit>

Function: Set bit

Description: SETB sets the indicated bit to one. SETB can operate on the carry flag or any

directly addressable bit. No other flags are affected.

Example: The carry flag is cleared. Output port 1 has been written with the value 34H

(00110100B). The instructions

SETB C

SETB P1.0

will leave the carry flag set to 1 and change the data output on port 1 to 35H (00110101B).

SETB C

Operation: SETB

(C) ¬ 1

Bytes: 1

Cycles: 1

SETB bit

Page 33: DTMF based Home Automation System

Operation: SETB

(bit) ¬ 1

Bytes: 2

Cycles: 1

Encoding: 1 1 0 1 0 0 1 1

Encoding: 1 1 0 1 0 0 1 0 bit address

SJMP rel

Function: Short jump

Description: Program control branches unconditionally to the address indicated. The branch

destination is computed by adding the signed displacement in the second instruction byte to the

PC, after incrementing the PC twice. Therefore, the range of destinations allowed is from 128

bytes preceding this instruction to 127 bytes following it.

Example: The label ”RELADR” is assigned to an instruction at program memory location

0123H. The instruction

SJMP RELADR

will assemble into location 0100H. After the instruction is executed, the PC will contain the

value 0123H.

Note:

Under the above conditions the instruction following SJMP will be at 102H. Therefore, the

displacement byte of the instruction will be the relative offset (0123H-0102H) = 21H. In other

words, an SJMP with a displacement of 0FEH would be a one-instruction infinite loop.

Operation: SJMP

(PC) ¬ (PC) + 2

(PC) ¬ (PC) + rel

Bytes: 2

Page 34: DTMF based Home Automation System

Cycles: 2

Encoding: 1 0 0 0 0 0 0 0 rel. address

Fig 5. ATMEL SERIES OF MICROCONTROLLERS

2. DTMF Decoder – MT8870

In DTMF decoder circuit we use IC MT8870. It converts the dual tones to corresponding

binary outputs.

F low F high KEY BCD

697 1209 1 0001

697 1336 2 0010

697 1477 3 0011

770 1209 4 0100

770 1336 5 0101

Page 35: DTMF based Home Automation System

770 1477 6 0110

852 1209 7 0111

852 1336 8 1000

852 1477 9 1001

941 1209 0 1010

Table 2. MT8870 OUTPUT TRUTH TABLE

3. ULN 2003

A ULN2003 is a high-voltage, high-current Darlington transistor array.

It consists of seven NPN Darlington pairs that feature high-voltage outputs with common-

cathode flyback diodes for switching inductive loads.

It is very similar to the ULN2801A, ULN2802A, ULN2803A, ULN2804A, and ULN2805A,

only differing in logic input levels (TTL,CMOS, PMOS) and number of inputs (8).

The drivers can be paralleled for higher current capability, even stacking one chip on top of

another, both electrically and physically has been done.

Fig 7. Pin diagram of ULN 2003

Page 36: DTMF based Home Automation System

3.1 Features

500 mA rated collector current (single output)

50 V output

Includes output flyback diodes

Inputs compatible with various types of logic

3.2 Applications

Typical usage of the ULN2003A is to drive relays, lamp and LED displays or stepper motors.

4. Relay

A relay is an electrically operated switch. Many relays use an electromagnet to mechanically

operate a switch, but other operating principles are also used, such as solid-state relays.

Relays are used where it is necessary to control a circuit by a low-power signal (with

complete electrical isolation between control and controlled circuits), or where several

circuits must be controlled by one signal. The first relays were used in long

distance telegraph circuits as amplifiers: they repeated the signal coming in from one circuit

and re-transmitted it on another circuit. Relays were used extensively in telephone exchanges

and early computers to perform logical operations.

A type of relay that can handle the high power required to directly control an electric motor

or other loads is called a contactor. Solid-state relays control power circuits with no moving

parts, instead using a semiconductor device to perform switching. Relays with calibrated

operating characteristics and sometimes multiple operating coils are used to protect electrical

circuits from overload or faults; in modern electric power systems these functions are

performed by digital instruments still called "protective relays".

Fig 8. Simple electromechanical relay

Page 37: DTMF based Home Automation System

5. Led

A light-emitting diode (LED) is a two-lead semiconductor light source. It is a basic pn-

junction diode, which emits light when activated. When a fitting voltage is applied to the

leads, electrons are able to recombine with electron holes within the device, releasing energy

in the form of photons. This effect is called electroluminescence, and the color of the light

(corresponding to the energy of the photon) is determined by the energy band gap of the

semiconductor.

Fig 9. Blue, pure green, and red LEDs in 5 mm diffused cases

Recent developments in LEDs permit them to be used in environmental and task lighting.

LEDs have many advantages over incandescent light sources including lower energy

consumption, longer lifetime, improved physical robustness, smaller size, and faster

switching. Light-emitting diodes are now used in applications as diverse as aviation

lighting, automotive headlamps, advertising, general lighting, traffic signals, and camera

flashes. However, LEDs powerful enough for room lighting are still relatively expensive, and

require more precise current and heat management than compact fluorescent lamp sources of

comparable output.

LEDs have allowed new text, video displays, and sensors to be developed, while their high

switching rates are also useful in advanced communications technology.

6. Capacitor

A capacitor (originally known as a condenser) is a passive two-terminal electrical

component used to store energy electrostatically in an electric field. The forms of practical

capacitors vary widely, but all contain at least two electrical conductors (plates) separated by

a dielectric (i.e. insulator). The conductors can be thin films of metal, aluminum foil or disks,

etc. The "nonconducting" dielectric acts to increase the capacitor's charge capacity. A

dielectric can be glass, ceramic, plastic film, air, paper, mica, etc. Capacitors are widely used

as parts of electrical circuits in many common electrical devices. Unlike aresistor, an ideal

capacitor does not dissipate energy. Instead, a capacitor stores energy in the form of

an electrostatic field between its plates.

Page 38: DTMF based Home Automation System

Fig 10. A typical electrolytic capacitor

When there is a potential difference across the conductors (e.g., when a capacitor is attached

across a battery), an electric field develops across the dielectric, causing

positive charge +Q to collect on one plate and negative charge −Q to collect on the other

plate. If a battery has been attached to a capacitor for a sufficient amount of time, no current

can flow through the capacitor. However, if a time-varying voltage is applied across the leads

of the capacitor, a displacement current can flow.

Capacitors are widely used in electronic circuits for blocking direct current while

allowing alternating current to pass. In analog filternetworks, they smooth the output

of power supplies. In resonant circuits they tune radios to particular frequencies. In electric

power transmission systems, they stabilize voltage and power flow.

6.1. Capacitor filtering

The simple capacitor filter is the most basic type of power supply filter. The application of

the simple capacitor filter is very limited. It is sometimes used on extremely high-voltage,

low-current power supplies for cathode-ray and similar electron tubes, which require very

little load current from the supply. The capacitor filter is also used where the power-supply

ripple frequency is not critical; this frequency can be relatively high.

7. Resistor

A resistor is a passive two-terminal electrical component that implements electrical

resistance as a circuit element. Resistors act to reduce current flow, and, at the same time, act

to lower voltage levels within circuits. In electronic circuits resistors are used to limit current

flow, to adjust signal levels, bias active elements, terminate transmission lines among other

uses. High-power resistors that can dissipate many watts of electrical power as heat may be

used as part of motor controls, in power distribution systems, or as test loads for generators.

Fig 11. A typical axial-lead resistor

Page 39: DTMF based Home Automation System

Resistors may have fixed resistances that only change a little with temperature, time or

operating voltage. Variable resistors can be used to adjust circuit elements (such as a volume

control or a lamp dimmer), or as sensing devices for heat, light, humidity, force, or chemical

activity.

8. Pull - Up Resistor

Pull-up resistors are used in electronic logic circuits to ensure that inputs to logic systems

settle at expected logic levels if external devices are disconnected or high-impedanceis

introduced. They may also be used at the interface between two different types of logic

devices, possibly operating at different power supply voltages.

Fig 12. When the switch is open the voltage of the gate input is pulled up to the level of Vin. When the switch is closed, the input voltage at

the gate goes to ground.

A pull-up resistor weakly "pulls" the voltage of the wire it is connected to towards its voltage

source level when the other components on the line are inactive. When all other connections

on the line are inactive, they are high-impedance and act like they are disconnected. Since the

other components act as though they are disconnected, the circuit acts as though it is

disconnected, and the pull-up resistor brings the wire up to the high logic level. When another

component on the line goes active, it will override the high logic level set by the pull-up

resistor. The pull-up resistor ensures that the wire is at a defined logic level even if no active

devices are connected to it.

9. Crystal Oscillator

A crystal oscillator is an electronic oscillator circuit that uses the mechanical resonance of a

vibrating crystal of piezoelectric material to create an electrical signal with a very

precise frequency.[1][2][3] This frequency is commonly used to keep track of time (as in quartz

wristwatches), to provide a stable clock signal for digital integrated circuits, and to stabilize

frequencies for radio transmitters andreceivers. The most common type of piezoelectric

resonator used is the quartz crystal, so oscillator circuits incorporating them became known

as crystal oscillators,[1] but other piezoelectric materials including polycrystalline ceramics

are used in similar circuits.

Page 40: DTMF based Home Automation System

Fig 13. A miniature 16 MHz quartz crystal enclosed in a hermetically sealed HC-49/S package, used as the resonator in a crystal oscillator

Quartz crystals are manufactured for frequencies from a few tens of kilohertz to hundreds of

megahertz. More than two billion crystals are manufactured annually. Most are used for

consumer devices such as wristwatches, clocks, radios, computers, and cellphones. Quartz

crystals are also found inside test and measurement equipment, such as counters, signal

generators, and oscilloscopes.

10. AC Power Supply

Fig 14. Circuit diagram of Power Supply

Page 41: DTMF based Home Automation System

V. Design

Fig 15. Block diagram of the circuit

Fig 16. Circuit diagram

Page 42: DTMF based Home Automation System

V.1. Working

IN this project our first part is DTMF decoder. The DTMF IC receives the DTMF pulse and

then converts it into binary coded decimal. Pin No. 18 of the IC is connected to positive

supply. In this circuit we use +5 volt regulated power supply for the smooth working. DTMF

signal is applied to the pin No. 2 and 3 of the IC through resistor and capacitor network.

Capacitor of 0.1 uF works as a dc blocking capacitor. Pin No. 5, 6, 9 is connected to the

Ground pin. Pin No. 7 and 8 is connected to the 12.095 crystal. Pin No. 16 and 17 is

connected to RC network work as an auto reset, when we switch on the power supply.

BCD output is available on the pin No 11, 12, 13, 14 and this output is connected to the

microcontroller 89C51.

Our next part of the circuit is 89C51. 89C51 is a 40 pin IC. Pin No. 40 of the IC is connected

to the positive supply. Pin No. 9 is rest pin. One capacitor and resistor network is connected

to pin No 9. This microcontroller has a total of four input output ports each 8 bit wide.

We use port 2 as a BCD input. Output from the 8870 is connected to the p2 – 4 pins.

8870 PORT2 IC pin

Pin 11 p2.0 21

Pin 12 p2.1 22

Pin 13 p2.2 23

Pin 14 p2.3 24

Output is available on the port1 and port 3, here we use only 10 output from the

microcontroller. All the output is available on the PORT1.

P1.0 pin no 39

P1.1 pin no 38

P1.2 pin no 37

P1.3 pin no 36

P1.4 pin no 35

P1.5 pin no 34

P1.6 pin no 33

P1.7 pin no 32

P3.0 pin no 10

P3.1 pin no 11

All the output led is connected to this output. Note that 0 logic is available on these pin, so

cathode of the Led is connected to this pin.

Another pins of the port 3 is also connected for another useful uses.

P3.3 Acknowledge of code lock

P3.4 Time indication of the code lock

P3.5 Led indication of sound output for on/off signal

P3.2 Output frequency for opto-coupler input.

Page 43: DTMF based Home Automation System

VI. Coding

VI.1. Software

The μ Vision IDE is, for most developers, the easiest way to create embedded system

programs. This chapter describes commonly used μ Vision features and explains how to use

them.

Page 44: DTMF based Home Automation System

Keil software converts the C-codes into the Intel Hex code.

Page 45: DTMF based Home Automation System

VI.2. Code

#include <REGX51.H>

sbit sw1=P1^0;

sbit sw2=P1^1;

sbit sw3=P1^2;

sbit sw4=P1^3;

sbit op1=P2^0;

sbit op2=P2^1;

sbit op3=P2^2;

sbit op4=P2^3;

sbit op5=P2^4;

sbit op6=P2^5;

sbit op7=P2^6;

void main()

{

if(sw1==1 && sw2==0 && sw3==0 && sw4==0)

{

op4=1;

}

else if(sw1==0 && sw2==1 && sw3==0 && sw4==0)

{

op5=1;

}

else if(sw1==1 && sw2==1 && sw3==0 && sw4==0)

{

op6=1;

}

else if(sw1==0 && sw2==0 && sw3==1 && sw4==0)

{

op7=1;

}

else if(sw1==1 && sw2==1 && sw3==0 && sw4==1)

{

P2=0xf8;

}

else if(sw1==0 && sw2==1 && sw3==0 && sw4==1)

{

P2=0x00;

}

else

{

P2 = 0x00;

}

}

Page 46: DTMF based Home Automation System

VII. Test Cases

With the knowledge of operation of the system was tested step by step to the transistor output

and the load was connected across the collector terminal of the transistor.

VIII. Industry Applications

The need for the above project was that this project firstly it saves our time. If you are stuck

in traffic you can switch on your microwave oven on slow cooking mode. By the time you

reach your home your food will be ready. You don’t have go to each room to check whether

the lights are on/off. You can do with a click of single button. Secondly, it save our money in

the long run. There are some appliances like a television which we switch off but not its

power supply. There is a Led still glowing in it which uses electricity. If we have this

television attached to our project then we can switch off its power supply whenever we want

and there are many other devices like this. Thirdly, it for self-maintenance and security.

Security as in if we by chance forgot to switch off any of lights then we can switch off from

our phones. Lastly, we all know that all this will make our life easy and trouble free.

Industrial applications for the project made are that one can control home appliances from

anywhere in the world even we are sitting a cup of tea in United States of America. Secondly,

it reduces wastage of electricity as discussed earlier that if we forget to switch off the lights.

Last but not the least it is very low cost compared to other technologies like GSM.

IX. Future Enhancements

Future scope of the device can be that we instead of calling from one phone to other which

makes it costly we can send a message for the switching of lights. This will make it easier.

Page 47: DTMF based Home Automation System

X. Data Sheets

X.1. AT89C51

Table 2. Flash Programming Modes

Page 48: DTMF based Home Automation System

Table 3. Serial Programming Instruction Set

Page 49: DTMF based Home Automation System

X.2. ULN 2003

Page 50: DTMF based Home Automation System
Page 51: DTMF based Home Automation System

X.3. MT 8870

Page 52: DTMF based Home Automation System

Fig 17. Block diagram of 8870

Table 4. Pin description of 8870

Page 53: DTMF based Home Automation System

References

[1]. http://en.wikipedia.org/wiki/ULN2003A

[2]. http://en.wikipedia.org/wiki/Crystal_oscillator

[3]. http://en.wikipedia.org/wiki/Pull-up_resistor

[4]. http://en.wikipedia.org/wiki/Light-emitting_diode

[5]. http://en.wikipedia.org/wiki/Relay

[6]. http://en.wikipedia.org/wiki/Capacitor

[7]. http://en.wikipedia.org/wiki/Resistor

[8]. http://en.wikipedia.org/wiki/Dual-tone_multi-frequency_signaling

[9]. http://www.electronicshub.org/dtmf-controlled-home-automation-system-circuit/

[10]. http://www.engineersgarage.com/contribution/dtmf-controlled-home-automation-

system-using-8951?page=2