Home Automation Project Report

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 82

HOME AUTOMATION USING DTMF

CONTROL

Submitted in partial fulfillment of the requirements for the


degree of B.Tech. in Electronics and Communication
Engineering.
ABSTRACT

The home automation is one of the most emerging trends in modernization of home
appliance control. Presently, conventional wall switches are located in different parts
of the house and one has to physically go near them and press them to turn the loads
on/off. The problem arises when user is out of the premises; in that case controlling
the home appliances becomes impossible. The project aims at developing a system
that can overcome this limitation of today’s electricity system. Growing consumption
of electricity and wastage of electricity can be checked with this system

Using Dual Tone Multiple Frequency signaling the range of home automation system
can be effectively increased beyond the periphery of premises. Wide use of DTMF
signaling in conventional telephone networks allows us to use Telephone Networks
for accessing home automation system from almost any location around the globe.
The system developed in this project is aimed at exploiting this utility of telephone
networks.

The system can provide access to home automation system from any place, where any
type telephone coverage is possible. The system is protected by a password interface
to prevent unauthorized access. Whenever user makes a call to system, he has to enter
a password to activate the system then by dialing designated number of the appliance
to be operated he can check the status of device and can switch on/off the device.
DTMF decoder makes it possible to decode a DTMF signal to a BCD code which can
be used to provide different functioning for different signals. The acknowledgment for
the change in status of the device is provided through a buzzer. The system saves the
status of the devices in an EEPROM to avoid resetting of system in case of power
failure.

The system provides advantages as overcoming the limited range of Infrared and
other radio frequency type remote control. The other advantages provided by the
system are Ease of Access, Portability, low power consumption. The system is highly
useful for premises involving high power consumption appliances and thereby
checking electricity wastage. The system requires low maintenance and is quite robust
against power fail

ii
TABLE OF CONTENTS

Declaration ii
Certificate iii
Acknowledgements iv
Abstract v
List of tables ix
List of figures x
List of Abbreviations xii
Chapter 1. Introduction 1-4
1.1 Introduction 1
1.2 Project idea 2
1.3 Objective 3
1.4 Organization of the report 4
Chapter 2. Working of the project 5-13
2.1 Working Principle 5
2.2 Block diagram description 6
2.2.1 DTMF Decoder Section 7
2.2.2 Microcontroller and ROM Section 8
2.2.3 Power Supply Section 9
2.2.4 Load and Relay Section 10
2.3 Circuit Diagram of proposed Project 10
2.4 PCB layout of finalized circuit 12
2.4.1 PCB Layout of MCU 12
2.4.2 PCB Layout of power circuit 12
2.4.3 PCB Layout of finalized circuit 13
CHAPTER 3 HARDWARE SPECIFICATIONS 14-44
3.1 89C51(8051 family microcontroller) 14
3.1.1 Different Microcontrollers in market 14
3.1.2 Architecture 15
3.1.3 Execution Time 16
3.1.4 Key Features 16
3.1.5 PIN Diagram 18

iii
3.1.6 Instructions 20
3.1.7 Registers 23
3.2 Memory Interface 26
3.2.1 PIN Diagram 27
3.2.2 PINS 28
3.2.3 Monitoring acknowledgement unit 31
3.2.4 STOP Condition 32
3.2.5 Clocking 32
3.2.6 Byte Write/Read Operations at a glance 33
3.3 Power Supply 34
3.3.1 Power Supply Components 34
3.3.2 Power Supply Diagram 36
3.3.3 Crystal Oscillator 36
3.4 Relays 37
3.4.1 Types of Relays 37
3.4.2 Electromagnetic Relay 37
3.5 IC 8870 DTMF(Dual Tone Multi Frequency) 38
3.5.1 Features 39
3.5.2 CM8870IC 39
3.5.3 Applications 39
3.5.4 Block Diagram 40
CHAPTER 4-SOFTWARE SPECIFICATIONS 45-60
4.1 Sprint Layout5.0 45
4.1.1 Features 45
4.2 Keil C Cross Compiler 47
4.3 Program 48
4.4 MultiSim 60
CHAPTER 5-RESULT 61-62
CHAPTER 6-FUTURE SCOPE 63-66
6.1 Future of Home Automation 64

iv
Appendices
Appendix A. Software Methodology (Working with Keil) 67-73
A.1 Working with Keil 67
A.1.1 Target Selection 68
A.1.2 Include Header File 70
A.1.3 Building Target 71

v
LIST OF TABLES

3.1 Defining Functions of PINs 27


3.2 Functional Diode Table 43
3.3 PIN Function 44

vi
LIST OF FIGURES

Fig 2.1 Block Diagram of Project . 6


Fig 2.2 Block Diagram Of DTMF Section 7
Fig 2.3 Block Diagram of MCU and ROM Section 8
Fig 2.4 Reset Circuitry 8
Fig 2.5 The power supply module 9
Fig 2.6 Steps of rectification of AC power 9
Fig 2.7 Load and Relay Section 10
Fig 2.8 Finalized Circuit Diagram 11
Fig 2.9 Layout of MCU 12
Fig 2.10 PCB Layout of used power module 12
Fig 2.11 PCB Layout of finalized circuit 13
Fig 3.1 Architecture of 8051 Microcontroller 15
Fig 3.2 Pin diagram of 89C51 microcontroller 18
Fig 3.3 Different fields of PCON register 23
Fig 3.4 Different fields of IE register 24
Fig 3.4 Different fields of IP register 24
Fig 3.4 Different fields of SCON register 25
Fig 3.5 PIN structure of Memory Interface 27
Fig 3.6 Device addressing scheme of memory Interface 30
Fig 3.7 Starting Condition 30
Fig 3.8 Transfer of bits to memory interface 31
Fig 3.9 Transfer of bits from memory interface 31
Fig 3.10 Read/Write Operation in Memory 32
Fig 3.11 Stop condition 32
Fig 3.12 Clock Signal 33
Fig 3.13 Byte write operation 33
Fig 3.13 Byte read operation 33
Fig 3.14 Step down transformer 34
Fig 3.15 Diode 35
Fig 3.16 Voltage regulator 35
Fig 3.17 Power Supply Section 36

vii
Fig 3.18 Crystal Oscillator 36
Fig 3.19 Fig Relay Mechanism 38
Fig. 3.20 DTMF Keypad 38
Fig.3.21 Block diagram of inside circuitry of DTMF decoder 40
Fig 3.22 Clock Circuitry 43
Fig 4.1 Designing of PCB layout in Sprint Layout5.0 46
Fig 4.2 Simulation of power supply using multisim 60
Fig 5.1 Complete picture of working project 62
Fig 5.2 PCB of working Project 62
Fig 6.1Future Enhancements in home automation 65
Fig 6.2 Home Automation in different ways 66

viii
LIST OF ABBREVIATIONS

LED - Light Emitting Diode


*V - Volt
Opamp - Operational amplifier
IC - Integrated Circuit
PCB - Printed Circuit Board
RAM - Random Access Memory
CMOS - Complimentary MOS
CPU - Central Processing Unit
Hz - Hertz
DTL/TTL - Transistor Transistor Logic

ix
CHAPTER-1

INTRODUCTION

1.1 INTRODUCTION TO THE PROJECT

Imagine how helpful it will be to be able to switch on your air conditioning system ten
minutes before you get home on a hot afternoon in June. How about having a security
system that will detect smoke, excessive electrical power usage, burglar attempts and
unauthorized movements in your house and alert you? This is what home automation
is about and there is no end to its application. In fact, sophisticated home automation
systems are now being developed that can maintain an inventory of household items,
record their usage through an RFID (Radio Frequency Identification) tag, and prepare
a shopping list or automatically order replacements.

Home automation has made it possible to have what is often referred to as a 'smart
home', a home that can detect and identify you, automatically adjust the lighting to
your predefined taste, open doors automatically, play your favorite music, water your
flowers in the morning, switch on the security lights at night and switch them off in
the morning, heat water for bathe and tea, stream to you anywhere in the world via the
internet a live video of what is happening in and around your house. It makes it
possible to link lighting, entertainment, security, telecommunications, heating, and air
conditioning into one centrally controlled system. This allows you to make your
house an active partner in managing your busy life.

Now a day, you can hardly find a house without a home automation system which can
range from the remote for the television, burglar alarm and hi-tech security gates, to
an automated air conditioning system that maintains the temperature at a predefined
value.

1
1.2 PROJECT IDEA

Automation plays an increasingly important role in the global economy and in daily
experience. Engineers strive to combine automated devices with mathematical and
organizational tools to create complex systems for a rapidly expanding range of
applications and human activities. Many roles for humans in industrial processes
presently lie beyond the scope of automation. Human-level pattern recognition,
language recognition, and language production ability are well beyond the capabilities
of modern mechanical and computer systems. Tasks requiring subjective assessment
or synthesis of complex sensory data, such as scents and sounds, as well as high-level
tasks such as strategic planning, currently require human expertise.

Automation has had a notable impact in a wide range of highly visible industries
beyond manufacturing. Once ubiquitous telephone operators have been replaced
largely by automated telephone switchboards and answering machines, medical
processes such as primary screening in electrocardiograph or radiography and
laboratory analysis of human genes, blood plasmas, cells, and tissues are carried out at
much greater speed and accuracy by automated systems. Automated teller machines
have reduced the need for bank visits to obtain cash and carry out transactions. In
general, automation has been responsible for the shift in the world economy from
agrarian to industrial in the 19th century and from industrial to services in the 20th
century.

1.2.1 Building Automation

Building automation describes the functionality provided by the control of a building.


The control system is a computerized, intelligent network of electronic devices,
designed to monitor and control the mechanical and lighting systems of a building. A
building automation system is an example of a distributed control system. The
building automation system (BAS) core functionality keeps the building climate
within a specific range, provides lighting based on an occupancy schedule, and
monitors system performance and device failures and provides email and/or text
notifications to building engineering staff. The BAS functionality reduces building
energy and maintenance costs when compared to a non-controlled building.

2
1.2.2 Office Automation

Office automation refers to the varied computer machinery and software used to
digitally create, collect, store, manipulate, and relay office information needed for
accomplishing basic tasks and goals. Raw data storage, electronic transfer, and the
management of electronic business information comprise the basic activities of an
office automation system, office automation helps in optimizing or automating
existing office procedures.

1.2.3 Power Automation

Power automation is the automated control and monitoring of power plants,


substations and transformers for effectiveness, efficiency and fault detection. It has
made it possible to have a reliable municipal or national electricity system, which
often comprises remote and hard-to-reach transformers and power sub-system units. It
makes it possible to monitor different power units, relay their status and health
information, and even carry out fault detection and correction without human
interference. Example of power automation system is the Supervisory Control and
Data Acquisition (SCADA) system.

1.2.4 Home Automation

Home automation may designate an emerging practice of increased automation of


household appliances and features in residential dwellings, particularly through
electronic means that allow for things impracticable, overly expensive or simply not
possible in recent decades. Home automation includes all that a building automation
provides like climate controls, door and window controls, and in addition control of
multimedia home theatres, pet feeding, plant watering and so on. But there exists a
difference in that home automation emphasizes more on comforts through ergonomics
and ease of operation.
For this project we are focusing on Home Automation

1.3 OBJECTIVE

The objective of this project is to implement a low cost, reliable and scalable home
automation system that can be used to remotely switch on or off any household

3
appliance, using a microcontroller to achieve hardware simplicity, low cost
piezoelectric buzzer for feedback and voice dial from any phone to toggle the switch
state. This project work is complete on its own in remotely and automatically
switching on and off of any electrical appliance not limited to household appliances,
and sends a feedback message indicating the new present state of the appliance. It
does not implement control of multiple appliances or automatic detection of faults in
the controlled appliance. This project is of contributory knowledge to the
development and implementation of home automation systems in Nigeria using low
cost, locally available components like microcontroller.

1.4 ORGANISATION OF REPORT

The presented report is organized in the form of chapters which describe about
different aspect of our project starting from the introduction which gives small insight
of the project along with the motivation for us behind developing our project and the
objective of the project. The second chapter describes in detail the working of project
with the help of block diagram and PCB layout whereas the third and fourth chapters
of this report deals with the description of hardware components used and the
software(s) used along with the programming of microcontroller.

4
CHAPTER-2

WORKING OF THE PROJECT

2.1 WORKING PRINCIPLE

In this project, we show that how we can control electrical appliances with the help
of DTMF control and at the same time we can get a acknowledgement through voice
response system or piezoelectric buzzer.

In this project we use 89S52 controller to control all electrical appliances. Along with
89S52 controller we use CM 8870 DTMF decoder to decode DTMF tones from hands
free kit. We use piezoelectric buzzer for voice playback. Infra red eye sensor can
also be used to control electrical appliances via remote also.

One GSM base phone is connected with the DTMF decoder with hands free kit. We
cut the hands free speaker and cut the wires with the DTMF decoder. First of all we
dial the number connected with the circuit. Mobile phone is automatic shifted auto
answer mode. Auto answer mode setting is done with the enhancement setting of the
main setting.

Suppose a user calls the mobile phone interfaced with the home automation system.
For security purposes project is implemented with password protection mechanism. In
this case, user is asked for the password for gaining access to the home automation
system. In our case password is *8870 .When user dials these numbers , user hears
three beeps, that means user has accessed the home automation system. Now suppose
the user dials number ‘1’ (there is different tones for different keys on the mobile
handset) ,As a result these tones are decoded by the DTMF decoder also called as
Dual Tone Multi frequency signaling. Therefore different signal levels are achieved
by pressing on different keys.

5
The number ‘1’ pressed by the user is used by the DTMF decoder to achieve
particular signal level. This signal level is then processed by the microcontroller to
give the status of the appliance at number 1.

In this project we get 3 beeps if the appliances are in “OFF” state and two beeps if the
appliance is in “ON” state. To select a device we press *1 and user gets the response
whether the appliance is in OFF state or ON state. To turn OFF the appliance the user
presses and for switching it on user presses followed by the beeps of the respective
ON and OFF beeps. In case of power failure, the previous states of the electrical
appliances are preserved by interfacing an EEPROM that saves the statuses of various
loads.

2.2 BLOCK DIAGRAM DESCRIPTION

Fig.2.1 Block diagram of Project

The above block diagram shows the basic model for the DTMF decoder and its power
supply. The tracker is divided into four modules which are:

1) DTMF decoder Section

6
2) Microcontroller and ROM section
3) Power Supply Section
4) Load and relay Section

Every module has its own separate set of inputs and outputs which either are used for
controlling or for facilitating the decision making of next module. Now we will
discuss separately each and every module of the Home Automation System.

2.2.1. DTMF Decoder Section

Fig 2.2 Block diagram of DTMF Section

The CM8870/70C decoder uses a digital counting technique to determine the


frequencies of the limited tones and to verify that these tones correspond to standard
DTMF frequencies. A complex averaging algorithm is used to protect against tone
simulation by extraneous signals (such as voice) while providing tolerance to small
frequency variations. The averaging algorithm has been developed to ensure an
optimum combination of immunity to “talk-off” and tolerance to the presence of
interfering signals (third tones) and noise. When the detector recognizes the
simultaneous presence of two valid tones (known as “signal condition”), it raises the
“Early Steering” flag (EST). Any subsequent loss of signal condition will cause EST
to fall.

Features
• Full DTMF receiver
• Less than 35mW power consumption
• Industrial temperature range
• Uses quartz crystal or ceramic resonators
• Adjustable acquisition and release times.

7
2.2.2 Microcontroller and ROM section

Fig 2.3 Block diagram of MCU and ROM Section

In this module a microcontroller is programmed using Embedded that controls


bidirectional data transfer. The EEPROM attached keeps track of all the current
statuses of all the appliances. The microcontroller is such programmed that when a
user turns ON or OFF a particular appliance the microcontroller immediately instructs
the ROM to save the status of that appliance, thus retaining the statuses when the
power failure occurs.

Reset Circuitry

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

Fig. 2.4 Reset Circuitry

8
The speed with which a microcontroller executes instructions is determined by what is
known as the crystal speed. A crystal is a component connected externally to the
microcontroller. The crystal has different values, and some of the used values are
6MHZ, 10MHZ, and 11.059 MHz etc. Thus a 10MHZ crystal would pulse at the rate
of 10,000,000 times per second. The time is calculated using the formula No of
cycles per second = Crystal frequency in HZ / 12. For a 10MHZ crystal the number of
cycles would be, 10,000,000/12=833333.33333 cycles. This means that in one
second, the microcontroller would execute 833333.33333 cycles

2.2.3 Power Supply Section

Fig.2.5 The power supply module

Fig 2.6 Steps of rectification of AC power

The 5V output of this module is provided to the sensor and microcontroller


module as their power input while 12V output is fed to DC motor driving
mechanism as its power source.

9
2.2.4 Load and relay Section

Fig 2.7 Load and Relay Section

In order to enable a circuit to be isolated from the system only under faulty
conditions, protective relays are used. In normal cases, it is open circuit relay. The
relay is usually provided with 4 terminals, two of which are connected to relay
winding and other two are connected to the circuit to be controlled. It has following
characteristics:

 Sensitivity
 Speed
 Selectivity

These relays are electromagnetically operated. The parts of these relays are an iron
core & its surrounding coil of wire. An iron yoke provides a low reluctance path for
magnetic flux, the yoke being shaped so that the magnetic circuit can be closed by a
movable piece of iron called the armature, and a set of contacts

2.3 CIRCUIT DIAGRAM OF THE PROPOSED PROJECT

CM8870 decode the DTMF tones on pin no 2,3 via RC circuit. One crystal is
connected to the pin no 7,8 of the decoder . 8870 provide a 4 digit binary output on
pin no 11,12,13,14 of the IC. This output is connected to the microcontroller port 1
(pin no 1, 2, 3, 4). Pin no 40 of the controller is connected to the positive 5 volt
supply. We get this supply from the step down transformer with rectifier circuit and.
microcontroller get this signal and compare inside the controller. The 4 pins such as
11,12,13,14 of DTMF decoder are connected and are sent in digital form to 89C51
microcontroller. The microcontroller contains a password for security purposes, in

10
this project we are having password *8870 that is used to compare with the numbers
associated with bit levels coming from DTMF decoder.

The circuit diagram of the whole working project is shown in the following figure

Fig 2.8 Finalised Circuit Diagram

11
2.4 PCB LAYOUT OF THE FINALIZED CIRCUIT

This section includes various PCB layouts of various sections of project. Given below
contains the snapshots of microcontroller section, power supply section and the
finalized circuit. These are drawn using software called Sprint Layout5.0.

2.4.1 PCB Layout of MCU

Fig 2.9 Layout of MCU

This snapshot shows the microcontroller section that consists of 40 pins (89C51) and
layout is drawn in accordance with circuit diagram shown in figure 2.8. The software
has an option called ‘Track’. The above figure that shows different lines are called as
tracks. The thickness of the track can be adjusted in accordance with the PCB area.

2.4.2 PCB layout of the power circuit

Fig 2.10 PCB layout of the used power module

12
This snapshot can be referred to as the power supply section of the project. The gaps
shown in snapshot between various tracks drawn are given for various ICs such as
voltage regulator, resistors and capacitors that filter AC component coming from
Step down transformer.

2.4.3 PCB layout of finalized circuit

Fig 2.11 PCB layout of finalized circuit

Using the method explained above, a fully PCB layout can be realised which is in
accordance with the circuit diagram as shown in figure 2.8

13
CHAPTER-3

HARDWARE SPECIFICATIONS

3.1 89C51 (8051 FAMILY MICRO CONTROLLER)


The 8051 developed and launched in the early 80`s, is one of the most popular micro
controller in use today. It has a reasonably large amount of built in ROM and RAM.
In addition it has the ability to access external memory.
The generic term `8x51` is used to define the device. The value of x defining the kind
of ROM, i.e. x=0, indicates none, x=3, indicates mask ROM, x=7, indicates EPROM
and x=9 indicates EEPROM or Flash. The early 8051, namely the 8031 was designed
without any ROM. This device could run only with external memory connected to it.
Subsequent developments lead to the development of the PROM or the programmable
ROM. This type had the disadvantage of being highly unreliable.
The next in line, was the EPROM or Erasable Programmable ROM. These devices
used ultraviolet light erasable memory cells. Thus a program could be loaded, tested
and erased using ultra violet rays. A new program could then be loaded again.
An improved EPROM was the EEPROM or the electrically erasable PROM. This
does not require ultra violet rays, and memory can be cleared using circuits within the
chip itself.
Finally there is the FLASH, which is an improvement over the EEPROM. While the
terms EEPROM and flash are sometimes used interchangeably, the difference lies in
the fact that flash erases the complete memory at one stroke, and not act on the
individual cells. This results in reducing the time for erasure.

3.1.1 Different microcontrollers in market.

 PIC: One of the famous microcontrollers used in the industries. It is based on


RISC Architecture which makes the microcontroller process faster than other
microcontroller.

14
 INTEL: These are the first to manufacture microcontrollers. These are not as
sophisticated other microcontrollers but still the easiest one to learn.

 ATMEL: Atmel’s AVR microcontrollers are one of the most powerful in the
embedded industry. This is the only microcontroller having 1kb of ram even
the entry stage. But it is unfortunate that in India we are unable to find this
kind of microcontroller.
3.1.2 Architecture

Architecture is must to learn because before learning new machine it is necessary to


learn the capabilities of the machine. This is something like before learning about the
car you cannot become a good driver. The 8051 doesn’t have any special feature than
other microcontroller. The only feature is that it is easy to learn. Architecture makes
us to know about the hardware features of the microcontroller. The features of the
8051 are

 4K Bytes of Flash Memory


 128 x 8-Bit Internal RAM
 Fully Static Operation: 1 MHz to 24 MHz
 32 Programmable I/O Lines
 Two 16-Bit Timer/Counters
 Six Interrupt Sources (5 Vectored)
 Programmable Serial Channel
 Low Power Idle and Power Down Modes

Fig 3.1 Architecture of 8051 Microcontroller

15
3.1.3 Execution time

(i) clr p1.0

This is an assembly language instruction. It means we are instructing the


microcontroller to put a value of ‘zero’ in bit zero of port one. This instruction is
equivalent to telling the microcontroller to switch on the bulb. The instruction then is
used to instruct the microcontroller to switch off the bulb.

(ii) Set p1.0

This instructs the microcontroller to put a value of ‘one’ in bit zero of port one.
Don’t worry about what bit zero and port one means. We shall learn it in more detail
as we proceed. They are a set of well defined instructions, which are used while
communicating with the microcontroller. Each of these instructions requires a
standard number of cycles to execute. The cycle could be one or more in number.

3.1.4 Key Features:

(i) 8-bit CPU.( Consisting of the ‘A’ and ‘B’ registers)

Most of the transactions within the microcontroller are carried out through the ‘A’
register, also known as the Accumulator. In addition all arithmetic functions are
carried out generally in the ‘A’ register. There is another register known as the ‘B’
register, which is used exclusively for multiplication and division. Thus an 8-bit
notation would indicate that the maximum value that can be input into these registers
is ‘11111111’.The value is not decimal 111, 11,111. It represents a binary number,
having an equivalent value of ‘FF’ in Hexadecimal and a value of 255 in decimal.

(ii) 4K on-chip ROM

Once you have written out the instructions for the microcontroller, where do you put
these instructions. Obviously you would like these instructions to be safe, and not get
deleted or changed during execution. Hence you would load it into the ‘ROM’
The size of the program you write is bound to vary depending on the application, and
the number of lines. The 8051 microcontroller gives you space to load up to 4K of
program size into the internal ROM. 4K, that’s all? Well just wait. You would be

16
surprised at the amount of stuff you can load in this 4K of space. Of course you could
always extend the space by connecting to 64K of external ROM if required.

(iii) 128 bytes on-chip RAM

This is the space provided for executing the program in terms of moving data, storing
data etc.

(iv) 32 I/O lines. (Four- 8 bit ports, labeled P0, P1, P2, P3)
Port one would have 8 bits. There are a total of four ports named p0, p1, p2, p3,
giving a total of 32 lines. These lines can be used both as input or output.

(v) Two 16 bit timers / counters.

A microcontroller normally executes one instruction at a time. However certain


applications would require that some event has to be tracked independent of the main
program. The manufacturers have provided a solution, by providing two timers.
These timers execute in the background independent of the main program. Once the
required time has been reached, (remember the time calculations described in
previous chapter), they can trigger a branch in the main program. These timers can
also be used as counters, so that they can count the number of events, and on reaching
the required count, can cause a branch in the main program.

(vi) Full Duplex serial data receiver / transmitter.

The 8051 microcontroller is capable of communicating with external devices like the
PC etc. Here data is sent in the form of bytes, at predefined speeds, also known as
baud rates. The transmission is serial, in the sense, one bit at a time. .

(vii) Interrupt sources with two priority levels (Two external and three internal)

During the discussion on the timers, we had indicated that the timers can trigger a
branch in the main program. However, what would we do in case we would like the
microcontroller to take the branch, and then return back to the main program, without
having to constantly check whether the required time / count has been reached?
This is where the interrupts come into play. These can be set to either the timers, or to
some external events. Whenever the background program has reached the required

17
criteria in terms of time or count or an external event, the branch is taken, and on
completion of the branch, the control returns to the main program.
Priority levels indicate which interrupt is more important, and needs to be executed
first in case two interrupts occur at the same time..

(viii) On-chip clock oscillator

This represents the oscillator circuits within the microcontroller. Thus the hardware is
reduced to just simply connecting an external crystal, to achieve the required pulsing
rate.

3.1.5 Pin Diagram

Fig 3.2 Pin diagram of 89C51 microcontroller

 Supply pin of this IC is pin no 40. Normally we apply a 5 volt regulated dc


power supply to this pin. For this purpose either we use step down transformer
power supply or we use 9 volt battery with 7805 regulator.

 Ground pin of this IC is pin no 20. Pin no 20 is normally connected to the


ground pin (normally negative point of the power supply.

 XTAL: is connected to the pin no 18 and pin no 19 of this IC. The quartz
crystal oscillator connected to XTAL1 and XTAL2 PIN. These pins also need
two capacitors of 30 pf value. One side of each capacitor is connected to

18
crystal and other pins are connected to the ground point. Normally we connect
a 12 MHz or 11.0592 MHz crystal with this IC. But we use crystal up to 20
MHz to these pins.

 RESET PIN: Pin no 9 is the reset pin of this IC. It is an active high pin. On
applying a high pulse to this pin, the micro controller will reset and terminate
all activities. This is often referred to as a power on reset. The high pulse must
be high for a minimum of 2 machine cycles before it is allowed to go low.

 PORT0: Port 0 occupies a total of 8 pins. Pin no 32 to pin no 39. It can be


used for input or output. We connect all the pins of the port 0 with the pull-up
resistor (10 k ohm) externally. This is due to fact that port 0 is an open drain
mode. It is just like a open collector transistor.

 PORT1: ALL the ports in microcontroller are 8 bit wide pin no 1 to pin no 8
because it is a 8 bit controller. All the main register and sfr all is mainly 8 bit
wide. Port 1 is also occupies a 8 pins. But there is no need of pull up resistor in
this port. Upon reset port 1 act as a input port. Upon reset all the ports act as a
input port

 PORT2: Port 2 also has 8 pins. It can be used as a input or output. There is no
need of any pull up resistor to this pin.

 PORT 3: Port3 occupies a total 8 pins from pin no 10 to pin no 17. It can be
used as input or output. Port 3 does not require any pull up resistor. The same
as port 1 and port2. Port 3 is configured as an output port on reset. Port 3 has
the additional function of providing some important signals such as interrupts.
Port 3 also use for serial communication.

 ALE: ALE is an output pin and is active high. When connecting an 8031 to
external memory, port 0 provides both address and data. In other words, the
8031 multiplexes address and data through port 0 to save pins. The ALE pin is

19
used for de multiplexing the address and data by connecting to the IC 74ls373
chip.

 PSEN: PSEN stands for program store enable. In an 8031 based system in
which an external ROM holds the program code, this pin is connected to the
OE pin of the rom.

 EA. In 89c51 8751 or any other family member of the Atmel 89c51 series all
come with on-chip ROM to store programs, in such cases the EA pin is
connected to the VCC. For family member 8031 and 8032 is which there is no
on chip ROM, code is stored in external memory and this is fetched by 8031.
In that case EA pin must be connected to GND pin to indicate that the code is
stored externally.

3.1.6 Instructions

(i) Single bit Instructions:


SETB BIT SET THE BIT =1
CLR BIT CLEAR THE BIT =0
CPL BIT COMPLIMENT THE BIT 0 =1, 1=0
JB BIT, TARGET JUMP TO TARGET IF BIT =1
JNB BIT, TARGET JUMP TO TARGET IF BIT =0
JBC BIT, TARGET JUMP TO TARGET IF BIT =1 &THEN CLEAR THE
BIT
(ii) Move Instructions:

MOV instruction simply copy the data from one location to another location

MOV D, S Copy the data from(S) source to D(destination)


MOV R0, A Copy contents of A into Register R0
MOV R1,A Copy contents of A into register R1
MOV A, R3 Copy contents of Register R3 into Accumulator
MOV A, #23H Direct load the value of 23h in A
MOV R0, #12h Direct load the value of 12h in R0

20
MOV R5, #0F9H Load the F9 value in the Register R5

(iii) ADD INSTRUCTIONS.

ADD instructions adds the source byte to the accumulator ( A) and place the result in
the accumulator.

MOV A, #25H
ADD A,#42H: By this instructions we add the value 42h in Accumulator
(42H+ 25H)
ADDA, R3: By this instructions we move the data from register r3 to
accumulator and then add the contents of the register into
accumulator .

(iv) SUBROUTINE CALL FUNCTION.

ACALL, TARGET ADDRESS: By this instructions we call subroutines with a target


address within 2k bytes from the current program counter.

(v) LCALL, TARGET ADDRESS.

ACALL is a limit for the 2 K byte program counter, but for up to 64k byte we use
LCALL instructions. Note that LCALL is a 3 byte instruction while ACALL is a two
byte instruction.

(vi) Instructions related to carry

JC TARGET: Jump to the target if CY flag=1


JNC TARGET: Jump to the target address if CY flag=0

(vii) Instructions related to rotate:

(i) RLA (Rotate left the accumulator)


By these instructions we rotate the bits of A left. The bits rotated out of A are rotated
back into A at the opposite end.

21
(ii) RRA
By this instruction we rotate the contents of the accumulator from right to left from
LSB to MSB.

(iii) RRC A
This is same as RR A but difference is that the bit rotated out of register first enter in
to carry and then enter into MSB

(iv) RLC A (Rotate left through carry)


Same as above but shift the data from MSB to carry and carry to LSB.

(v) RET
This is return from subroutine. This instruction is used to return from a subroutine
previously entered by instructions LCALL and ACALL.

(vi) RET1
This is used at the end of an interrupt service routine. We use this instruction after
interrupt routine.

(vii) PUSH
This copies the indicated byte onto the stack and increments SP. This instruction
supports only direct addressing mode.

(viii) POP: POP FROM STACK.

This copies the byte pointed to be SP to the location whose direct address is indicated,
and decrements SP by 1. Notice that this instructions supports only direct addressing
mode.

8) DPTR INSTRUCTIONS

MOV DPTR,#16 BIT VALUE

This instructions load the 16 bit DPTR register with a 16 bit immediate value

(i) MOV C A,@A+DPTR


This instruction moves a byte of data located in program ROM into register A. This
allows us to put strings of data, such as look up table elements.

22
(ii) MOVC A,@A+PC
This instructions moves a byte of data located in the program area to A. the address of
the desired byte of data is formed by adding the program counter ( PC) register to the
original value of the accumulator.

(iii) INC BYTE


This instruction adds 1 to the register or memory location specified by the operand.

INC A
INC R
INC DIRECT
DEC BYTE
This instruction subtracts 1 from the byte operand. Note that CY is unchanged
DEC A
DEC R
DEC DIRECT

3.1.7 Registers:
(i) PCON Register:

Fig 3.3 Different fields of PCON register

If the SMOD = 0 (Default on Reset)

There are two ways to increase the baud rate of data transfer in the 8051
 To use a higher frequency crystal
 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

23
BIT) OF PCON register is zero. We can set it to high by software and thereby
double the baud rate.

(ii) IE (Interrupt enable register)

Fig 3.4 Different fields of IE register

 EA: 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 interrupts.
 EX0 IE.0 Enables or disables external interrupt 0

(iii) Interrupt priority register

Fig 3.4 Different fields of IP 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
 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 level.
 PS IP.4 Define the serial port interrupt priority level.
 PT1 IP.3 Define the timer 1 interrupt priority level.
 PX1 IP.2 Define the external interrupt 1 priority level.

24
 PT0 IP.1 Define the timer 0 interrupt priority level.
 PX0 IP.0 Define the external interrupt 0 priority level.

(iv) SCON: Serial port Control Register(Bit addressable)

Fig 3.4 Different fields of SCON register

 SM0 : SCON.7 Serial Port mode specifier.


 SM1 : SCON.6 Serial Port mode specifier.
 SM2 : SCON.5 Serial Port mode specifier
 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
8th bit time in mode 0, or at the beginning of the stop bit in the
other modes. It must be cleared by software. .
 R1 : SCON.0 Receive interrupt flag. Set by hardware at the end of
the 8th bit Time in mode 0, or halfway through the stop bit time
in the other modes. It must be cleared by the software

(v) TCON Timer 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 process
TR1 TCON.6 Timer 1 run control bit. Set/cleared by software to turn Timer

25
counter 1 On/off
TF0 TCON.5 Timer 0 overflow flag. Set by hardware when the timer/counter
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.

3.2 MEMORY INTERFACE

AT24C02 is an electrically erasable and programmable ROM. It has a 2Kbits of


memory size arranged in 32 pages of 8 byte each. There are 256 (32 x 8) words each
of one byte. The data is transferred and received serially through serial data (SDA)
pin.
The SCL is clock input and is used to synchronize EEPROM with microcontroller for
various operations. When data is to be read or write, first a start condition is created
followed by device address, byte address and the data itself. Finally a stop condition is
provided. The start condition occurs when SDA and SCL get high to low
simultaneously. The stop condition is when SDA remains low while SCL goes from
high to low. The data is read or written between the start and stop conditions on every
transition of SCL from high to low. For more details on different operations and
addressing, refer interfacing 24C02 with 8051.

A total of eight EEPROMs can be connected through a bus. There are three address
pins in AT24C02 for selecting a particular chip. The device can be addressed serially
by the software. It makes use of an internal register of the EEPROM whose 4 MSB
bits are 1010, the next three are the EEPROM address bits and the LSB signifies
whether data is to be read or written. This last bit is 1 for write and 0 for read
operation. For example, if in an EEPROM all address bits are grounded, then for write
operation a hex value 0xA1 (1010 0001) will be sent. Here 000, in last bits, addresses
the EEPROM and 1 in LSB indicates a write operation. Similarly for read operation
the device address to be sent is 0xA0 (1010 0000).

26
Next, the byte or page address is sent followed by the data byte. This data byte is to be
written on or read by the microcontroller.

3.2.1 PIN DIAGRAM

Fig 3.5 PIN structure of Memory Interface

Table no.3.1 Defining Functions of PINs

Pin Function Name


No
1 Address input pins; Provide addresses when more than one AD0

2 EEPROM is interfaced to a single microcontroller; AD1

3 Ground when only one EEPROM is used AD2

4 Ground (0V) Ground

5 Bi-directional pin for serial data transfer Serial Data

6 Provides clock signals Serial Clock

27
EEPROM stands for electrically erasable programmable read only memory. It is a
secondary storage device that once written (programmed) can hold data even when
the power is removed. The EEPROM is a class of read only memory that can be
electrically erased and reprogrammed.

AT24C02 is a two wire 2Kbits serial EEPROM by Atmel. The memory is organized
in 256 words of single byte each arranged in 32 pages of 8 bytes each. The addressing
of memory locations requires eight bit addresses.

AT24C02 is two-wire serially programmable i.e., for programming, the data and
control signals are provided serially along with clock signals from the other wire. The
read-write operations are accomplished by sending a set of control signals including
the address and/or data bits. The control signals must be accompanied with proper
clock signals.

The AT24C02 has hard wire addressing of 3 bit length. This facilitates interfacing of
a maximum of eight (23) 24C02 devices to a system thereby, incorporating a
maximum 16Kbits memory. Multiple 24C02 devices can be connected to a
microcontroller/microprocessor based system using I2C interface. The project
demonstrates interfacing of a single 24C02 IC with AT89C51 (8051) microcontroller.
The microcontroller is programmed to perform write operation of a single byte and
read the same. The byte written and read is displayed on a LCD display. Of the two
wire serial EEPROMs from ATMEL, 24C02 is one of them and comes in different
packages. No matter what the package type, following are the pins of 24C02 IC

3.2.2 Pins:
(i) A0-A2: Pins 1-3 are the address pins. Since multiple 24C02 and other similar
devices can be connected to a system, they require addressing. These devices are hard
wire addressed i.e. the address pins are permanently grounded and/or connected to
Vcc. It is notable that in other two-wire serial EEPROMs from Atmel, all the address
pins may not be used. In this circuit all address pins are grounded, so the device will
have an address 000.(ii) WP: Pin7 is the Write Protect pin. When it is kept low
(ground), normal read and write operations are allowed. When it is given a high,
24C02 is protected from any write operation. In the circuit WP pin has been grounded
to allow write operation.

28
(iii) VCC: A 5V DC supply is required to power the AT24C02. This is same as the
power supply of the microcontroller. So a separate supply to power 24C02 is not
required.

(iv) GND: Pin4 is Ground pin (0V)

(v) SDA: Pin5 is serial data pin. The data and control bits are read and write serially
from this bidirectional pin.

(vi) SCL: Pin6 is serial clock pin. A clock signal is required every time a bit is
transferred to or from the SDA pin. A positive edge clock, i.e., a low to high, transfers
data to the EEPROM and a negative edge trigger, i.e., a high to low, carries data
from the EEPROM. In the circuit SDA and SCL are connected to bits 0 and 1 of port
P1, respectively. The data pins of the LCD are connected to port 2 of the
microcontroller. The RS, RW and enable pins of the LCD are interfaced to bit 0, 1
and 6 of port P3, respectively.

As many 24C02 devices can be used in a system using a two wire serial (I2C)
interface. The controller needs to send a device address to select a particular 24C02
device. Also whether a read or write operation is to be done must be specified. This is
done by device addressing.

Since 24C02 devices understand 8 bit words the device addresses are also single byte
long. The first four MSBs are a fixed sequence of high and low (1010). The next three
bits are the device address bits which must match with the hard wire address of the
24C02 device. The LSB specifies whether a write or read operation is to be done. If
this bit is high (1), a read operation is initiated; and if it is low (0), write is initiated.

Any read or write operation in 24C02 requires a sequence of interaction with the
controller. This involves the following steps:

 To set Start condition to initiate any Read or Write operation.

29
Fig 3.6 Device addressing scheme of memory Interface

 To transfer a bit to/from EEPROM.


 To monitor acknowledgements for the receipt or transfer of each word.
 A superset of signals for transferring words perform Read or Write operations.
 Setting the Stop condition to terminate the operation.

These steps are explained in more detail in following sections.

1) Start condition:

Any read or write operation in EEPROM is initiated by Start condition. This occurs
when there is a high to low transition of SDA while SCL is high. (Refer the following
diagram) This tells the EEPROM that words from the controller are ready for it. SCL
is set low at the end of start condition. This is because any read or write operation first
involves transfer of some words to EEPROM. That requires a low to high transition of
clock corresponding to each bit of the word

Fig 3.7 Starting Condition

30
2) Transfer a bit of a word to/from EEPROM:

First of all, it must be noted that transferring a bit to/from EEPROM is not the same as
write/read operation and so they should not be confused with each other. A read or
write operation is the whole process that takes place only after a start condition and
before stop condition. Transfer of bits to/from an EEPROM is a part of transferring 8
bit word(s) in between the start and stop conditions because every byte is transferred
serially bit by bit.

Fig 3.8 Transfer of bits to memory interface

SDA is normally pulled high by the device it is interfaced with. When SCL is high the
signal changes (H-L or L-H) at SDA are considered as start or stop condition. A low
to high transition at SCL transfers a bit to the EEPROM, i.e., at a low to high
transition of SCL, SDA pin of EEPROM behaves as input for bits of word(s). If the
data changes when the SCL is high, it will be misinterpreted as start or stop condition.

Fig 3.9 Transfer of bits from memory interface

3.2.3 Monitoring acknowledgement unit


When a word is sent to the EEPROM, it sends back a zero (0) to tell the controller
that the word has been received successfully by it. The controller reads this

31
acknowledgement bit by sending a high to low transition at SCL. Acknowledgement
bit must be checked every time a word is sent to the EEPROM.

(i) Read/Write Operations:

A sequential transfer of words from/to the EEPROM constitutes the read/write. Thus
any read or write operation supported by the EEPROM can be accomplished by
sending and/or receiving a sequence of words to/from the EEPROM. There is a fixed
set of words which need to be sent to and/or received by the EEPROM corresponding
to each read and write operation.

Fig 3.10 Read/Write Operation in Memory

3.2.4 STOP Condition

A stop condition is provided to terminate a read or write operation. A low to high


transition of SDA when SCL is high sets the stop condition.

Fig 3.11 Stop condition

3.2.5 Clocking:

When a sequence of words is transferred to EEPROM, a clock is needed to be sent by


the controller after transmission of each word. This is required so that the controller

32
can receive its acknowledgement. Clock is just a high transition followed by a low
transition of SCL when the initial clock signal is low.

Fig 3.12 Clock Signal

3.2.6 Byte Write/Read Operations at a glance:

Fig 3.13 Byte write operation

Fig 3.13 Byte read operation

33
3.3 POWER SUPPLY:

In this project power supplies with +5V & -5V option normally +5V is enough for
total circuit. Another supply is used in case of OP amp circuit .Transformer primary
side has 230/50HZ AC voltage whereas at the secondary winding the voltage is step
downed to 12/50hz and this voltage is rectified using two full wave rectifiers .The
rectified output is given to a filter circuit to filter the unwanted ac in the signal After
that the output is again applied to a regulator LM7805 (to provide +5v) regulator.
WhereasLM7805 is for providing 5V regulation.
A step down transformer is used to convert 230V 50HZ line voltage 12V ac input to
the supply pin of the circuit. The ac voltage is converted to pulsated dc using a center
tapped full wave rectifier.
Any ripples if present are eliminated using a capacitive filter at the output of the full
wave rectifier.
The capacitive filter output is input to LM 7805(voltage regulator), which produces a
dc equivalent of ac 5V. This 5V dc acts as VCC to the micro controller.

3.3.1 Power Supply components.


Various components such as step down transformer, Voltage regulator, and diodes are
used. A brief overview is given below:

1) Step down Transformer


Step down transformer from 220 volt Ac to 9-0-9 ac. We use step down transformer
to step down the voltage from 220 to 9 volt ac. This AC is further connected to the
rectifier circuit for AC to DC conversion. Transformer current rating is 750 ma.

Fig 3.14 Step down transformer

34
2) Diode
In this project we use IN 4007 diode as a rectifier. IN 4007 is special diode to convert
the AC into DC.

Fig 3.15 Diode

In this project we use two diode as a rectifier. Here we use full wave rectifier. Output
of rectifier is pulsating DC. To convert the pulsating dc into smooth dc we use
electrolytic capacitor as a main filter. Capacitor converts the pulsating dc into smooth
dc and this DC is connected to the regulator circuit for regulated 5 volt DC.

Fig 3.16 Voltage regulator

35
3.3.2 Power Supply Block diagram

Fig 3.17 Power Supply Section

3.3.3 Crystal Oscillator

Crystal oscillator is an electronic circuit that produces electrical oscillations at a


particular designed frequency determined by the physical characteristics of one or
more crystals, generally of quartz, positioned in the circuit feedback loop. A
piezoelectric effect causes a crystal such as quartz to vibrate and resonate at a
particular frequency. The quartz crystal naturally oscillates at a particular frequency,
its fundamental frequency that can be hundreds of megahertz. The crystal oscillator is
generally used in various forms such as a frequency generator, a frequency modulator
and a frequency converter. Crystals provide the synchronization of the internal
function and to the peripherals. Whenever ever we are using crystals we need to put
the capacitor behind it to make it free from noises. It is good to go for a 33pf
capacitor.

Fig 3.18 Crystal Oscillator


36
We can also resonators instead of costly crystal which are low cost and external
capacitor can be avoided. But the frequency of the resonators varies a lot. And it is
strictly not advised when used for communications projects.

3.4 RELAYS
In order to enable a circuit to be isolated from the system only under faulty
conditions, protective relays are used. In normal cases, it is open circuit relay. The
relay is usually provided with 4 terminals, two of which are connected to relay
winding and other two are connected to the circuit to be controlled. It has following
characteristics:
 Sensitivity
 Speed
 Selectivity

3.4.1 Types of Relays:


 Electromagnetic Attraction Type: These relays are actuated by DC or AC
quantities.
 Electromagnetic Induction Type: It’s operation depends upon EMI
phenomena.
 Thermal Relays: Its operation depends upon the heating effect of electric
Current.
 Distance Relays: It’s operation depends upon the ratio of voltage to current.

3.4.2 Electromagnetic Relay:


These relays are electromagnetically operated. The parts of these relays are an
iron core & its surrounding coil of wire. An iron yoke provides a low reluctance path
for magnetic flux, the yoke being shaped so that the magnetic circuit can be closed by
a movable piece of iron called the armature, and a set of contacts. The armature is
hinged to the yoke and is held by a string in such a way that there is an air gap in the
magnetic circuit. Figure shows the principle of operation of this relay. When an
electric current flows in the coil, the armature is attracted to the iron core. Electrical
switching contacts are mounted on the armature. When the armature coil is energized,
these movable contacts break their connections with one set of fixed contacts and

37
close a connection to a previously open contact. When electric power is removed from
the relay coil, spring returns the armature to its original position.

Standard voltages for D.C. relay are 6,12,24,48 & 110 volts and for A.C. relays are
6,12,24,48,120 & 240 volts.

Fig 3.19 Fig Relay Mechanism

3.5 IC 8870 DTMF(DUAL TONE MULTI FREQUENCY) DECODER

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


telephone lines in the voice-frequency band between telephone handsets and other
communications devices and the centers. 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. 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.

Fig. 3.20 DTMF Keypad

38
The earliest of these were for in-band signaling between switching centers, where
long-distance telephone operators used a 16-digit keypad 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.

3.5.1 Features
• Full DTMF receiver
• Less than 35mW power consumption
• Industrial temperature range
• Uses quartz crystal or ceramic resonators
• Adjustable acquisition and release times

3.5.2 CM8870IC
 Power down mode
 Inhibit mode
 Buffered OSC3 output (PLCC package only)
 CM8870C is fully compatible with CM8870 for 18-pin devices by grounding
pin 5 and pin 6.

3.5.3 Applications
• PABX
• Central office
• Mobile radio
• Remote control
• Remote data entry
• Call limiting
• Telephone answering systems
• Paging systems

39
The CAMD CM8870/70C provides full DTMF receiver capability by integrating both
the band-split filter and digital decoder functions into a single 18-pin DIP, SOIC, or
20-pin PLCC package. The CM8870/70C is manufactured using state-of-the-art
CMOS process technology for low power consumption (35mW, MAX) and precise
data handling. The filter section uses a switched capacitor technique for both high and
low group filters and dial tone rejection. The CM8870/70C decoder uses digital
counting techniques for the detection and decoding of all 16 DTMF tone pairs into a
4-bit code. This DTMF receiver minimizes external component count by providing an
on-chip differential input amplifier, clock generator, and a latched three-state interface
bus. The on-chip clock generator requires only a low cost TV crystal or ceramic
resonator as an external component.

3.5.4 Block Diagram

Fig.3.21 Block diagram of inside circuitry of DTMF decoder

The CAMD CM8870/70C DTMF Integrated Receiver provides the design engineer
with not only low power consumption, but high performance in a small 18-pin DIP,
SOIC, or 20-pin PLCC package configuration. The CM8870/70C’s internal
architecture consists of a band-split filter section which separates the high and low
tones of the received pair, followed by a digital decode (counting) section which
verifies both the frequency and duration of the received tones before passing the
resultant 4-bit code to the output bus.

40
(i) Filter Section
Separation of the low-group and high-group tones is achieved by applying the dual-
tone signal to the inputs of two 9th-order switched capacitor bandpass filters. The
bandwidths of these filters correspond to the bands enclosing the low-group and high-
group tones (See Figure 3). The filter section also incorporates notches at 350Hz and
440Hz which provides excellent dial tone rejection. Each filter output is followed by a
single order switched capacitor section which smoothes the signals prior to limiting.
Signal limiting is performed by high-gain comparators. These comparators are
provided with a hysteresis to prevent detection of unwanted low-level signals and
noise. The outputs of the comparators provide full-rail logic swings at the frequencies
of the incoming tones.

(ii) Decoder Section


The CM8870/70C decoder uses a digital counting technique to determine the
frequencies of the limited tones and to verify that these tones correspond to standard
DTMF frequencies. A complex averaging algorithm is used to protect against tone
simulation by extraneous signals (such as voice) while providing tolerance to small
frequency variations. The averaging algorithm has been developed to ensure an
optimum combination of immunity to “talk-off” and tolerance to the presence of
interfering signals (third tones) and noise. When the detector recognizes the
simultaneous presence of two valid tones (known as “signal condition”), it raises the
“Early Steering” flag (EST). Any subsequent loss of signal condition will cause EST
to fall.

(iii) Steering Circuit:


Before the registration of a decoded tone pair, the receiver checks for a valid signal
duration (referred to as “character-recognition-condition”). This check is performed
by an external RC time constant driven by EST. A logic high on EST causes VC (See
Figure 4) to rise as the capacitor discharges. Providing signal condition is maintained
(EST remains high) for the validation period (TGTP), VC reaches the threshold
(VTST) of the steering logic to register the tone pair, thus latching its corresponding
4-bit code (See Figure) into the output latch. At this point, the GT output is activated
and drives VC to VDD. GT continues to drive high as long as EST remains high,
signaling that a received tone pair has been registered. The contents of the output
41
latch are made available on the 4-bit output bus by raising the three-state control input
(TOE) to a logic high. The steering circuit works in reverse to validate the inter digit
pause between signals. Thus, as well as rejecting signals too short to be considered
valid, the receiver will tolerate signal interruptions (drop outs) too short to be
considered a valid pause.
This capability together with the capability of selecting the steering time constants
externally, allows the designer to tailor performance to meet a wide variety of system
requirements.

(iv) Guard Time Adjustment


In situations which do not require independent selection of receive and pause, the
simple steering circuit of Figure 4 is applicable. Component values are chosen
according to the following formula:
tREC = tDP + Tgtp tGTP = 0.67 RC The value of tDP is a parameter of the device
and tREC is the minimum signal duration to be recognized by the receiver. A value
for C of 0.1µF is recommended for most applications, leaving R to be selected by the
designer. For example, a suitable value of R for a tREC of 40ms would be 300K. A
typical circuit using this steering configuration is shown in Figure 1. The timing
requirements for most telecommunication applications are satisfied with this circuit.
Different steering arrangements may be used to select independently the guard-times
for tone-present (tGTP) and tone absent (tGTA). This may be necessary to meet
system specifications which place both accept and reject limits on both tone duration
and interdigit pause. Guard time adjustment also allows the designer to tailor system
parameters such as talk-off and noise immunity. Increasing tREC improves talk-off
performance, since it reduces the probability that tones simulated by speech will
maintain signal condition for long enough to be registered. On the other hand, a
relatively short tREC with a long tDO would be appropriate for extremely noisy
environments where fast acquisition time and immunity to drop-outs would be
requirements.

(v) Clock Signal


The internal clock circuit is completed with the addition of a standard television color
burst crystal or ceramic resonator having a resonant frequency of 3.579545MHz. The
CM8870C in a PLCC package has a buffered oscillator output (OSC3) that can be
42
used to drive clock inputs of other devices such as a microprocessor or other
CM887X’s as shown in Figure 7. Multiple CM8870/70Cs can be connected as shown
in figure 8 such that only one crystal or resonator is required.

Fig 3.22 Clock Circuitry

Table 3.2 Functional Diode Table

43
Table 3.3 PIN Functions

44
CHAPTER 4

SOFTWARE SPECIFICATIONS

Soft wares used in designing this project are specified below:

 Keil C cross compiler


 Multisim
 Sprint Layout 5.0

4.1 SPRINT LAYOUT 5.0:

Sprint-Layout offers all needed functions to design your own layouts. Of course, there
is an extensive library with all common components included. For manufacturing
your PCB’s by hand, there is an excellent printout-procedure with many options
available. If you want to produce professional boards, there are many PCB-
manufacturer, which accept Sprint-Layout files. If required, you can export your
layout to the GERBER and EXCELLON format. Sprint-Layout is also able to create
HPGL files for isolation-milling.. Sprint-Layout is equipped with tools to draw pads,
tracks, copper areas, labels and so on. Just select the corresponding mode and place
your elements. All parameter like track-width, pad-size, etc. are always visible at a
glance, and can be edited every time. The active grid-capture lets you easily place
your elements exactly.

You can edit existing layout-elements very easy. For example if you adjust the width
of a track, you will see the result immediately on your layout. Additional functions
like copy, move, rotate, mirror, etc. are self evident.

4.1.1 Features:

(i) Component-library: Components which you have drawn once, can be added to the
component-library. The component-library is already filled with many common used

45
components. So you don’t have to create them again. You can easily drag &drop the
components from the library to your layout. After that you can mirror, rotate or label
them like you want.

(ii) Free rotating: You can rotate all components or elements in any angle. This makes
it possible to place your components in the best manner.

(iii) Automatic Ground-Plane: This function fills unused areas of a layout with copper
automatically. This accelerates the corroding process and saves corroding material.
You may also use this function to create a screen for HF-boards You can also define
thermal-pads on the automatic ground-plane.

(iv) The Photo view: The photo view lets you take a look at your board as if it was
already manufactured, with drillings, silk screen, etc. This helps you to find typically
mistakes like wrong mirrored components or text.

(v) Test-function: This function is very helpful to check your layout. You can click on
any position of your layout, and Sprint-Layout will find all connected layout-
elements, and light them up.

Fig 4.1 Designing of PCB layout in Sprint Layout5.0

46
4.2 KEIL 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. Keil provides following tools for 8051 development

1. C51 Optimizing C Cross Compiler,


2. A51 Macro Assembler,
3. 8051 Utilities (linker, object file converter, library manager),
4. Source-Level Debugger/Simulator,
5. µVision for Windows Integrated Development Environment.

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.
A linker is used to create an absolute object module suitable for your in-circuit
emulator.

4.2.1 8052 Project Development Cycle


These are the steps to develop 8051 project using keil

1. Create source files in C or assembly.

2. Compile or assemble source files.

3. Correct errors in source files.

4. Link object files from compiler and assembler.

47
5. Test linked application.

4.3 PROGRAM

#include<reg51.h>
#define dataport P0 //lcd 16x2 data port
#define cont_port P2
// Crystal 11.0592Mhz
sbit rs = cont_port^7; //lcd rd pin @ P2_0
sbit en = cont_port^6; //lcd en pin @ P2_2
sbit input = P3^3; //ir pin connected to Port3_3
bit row4=1;
bit outside=1;
sbit light1=P2^0;
sbit light2=P2^1;
sbit light3=P2^2;
sbit light4=P2^3;
sbit light5=P2^4;
sbit light6=P2^5;
sbit light7=P2^6;
sbit light8=P2^7;
sbit light9=P0^7;
sbit light0=P0^6;
sbit d0=P1^3;
sbit d1=P1^2;
sbit d2=P1^1;
sbit d3=P1^0;
sbit type_pass = P1^4;
sbit corr_pass = P1^5;
sbit incr_pass = P1^6;
sbit device_on = P1^7;
sbit device_of = P3^0;
sbit green = P0^4;
sbit red = P0^5;

48
sbit ack=P3^7;
int i;
int cmd,add,flip,val,val1,nflip;
void delay1() { //delay of 3.024msec
TMOD=1;
TL0=0x1E;
TH0=0xF0;
TR0=1;
TR0=0;
TF0=0;
}
void delay() {//delay of 1.658msec
TMOD=1;
TL0=0x07;
TH0=0xFA;
TR0=1;
while(TF0 == 0);
TR0=0;
TF0=0; }
void mdelay(int msec) {
while(msec != 0) {
TMOD=1;
TL0=0x1D;
TH0=0xF5;
TR0=1;
while(TF0 == 0);
TR0=0;
TF0=0;
msec--;
}}
void tog() {//calculate flip bit
flip=input;
void address() { //calculate the address

49
for(i=0; i<5; i++) {
add=(add<<1) | input;
delay();
}}

void command() //calculate the command


{
for(i=0; i<6; i++)
{
void value()
{
if(cmd >=0 && cmd <=9)
{

val=cmd;
// val=val*10+cmd;
else {
return;
}}
void IR();
void dtmf();
void password();
void main() {
green=0;
red=1;
while(1){

if(input==0)
IR();
if(ack==0)
password();}}
void dtmf(){
char sec1=0;
int rec1;
50
while(sec1<100){
rec1=30000;
while(ack==1){
rec1--;
if(rec1==0 && ack==1)
break;}
sec1++;
if(d0==1&&d1==0&&d2==0&&d3==0&&ack==0){
light1=~light1;
if(light1==0){
device_on=0;
mdelay(100);
device_on=1;
mdelay(300);
}
else{
device_of=0;
mdelay(100);
device_of=1;
mdelay(300);
}
sec1=0;
}
else if(d0==0&&d1==1&&d2==0&&d3==0&&ack==0){
light2=~light2;
if(light2==0){
device_on=0;
mdelay(100);
device_on=1;
mdelay(300);
}
else{
device_of=0;
}
51
sec1=0;
}
else if(d0==1&&d1==1&&d2==0&&d3==0&&ack==0){
light3=~light3;
if(light3==0){
device_on=0;
mdelay(100);
device_on=1;
mdelay(300);
}
else {}
sec1=0;}
else if(d0==0&&d1==0&&d2==1&&d3==0&&ack==0){
light4=~light4;
if(light4==0){
device_on=0;
mdelay(100);
device_on=1;
mdelay(300);}
else {
device_of=0;
mdelay(100);
device_of=1;
mdelay(300);
}
sec1=0;
else if(d0==1&&d1==0&&d2==1&&d3==0&&ack==0)
{
light5=~light5;
if(light5==0)
device_on=0;
mdelay(100);
device_on=1;
mdelay(300);
52
}
else
{
device_of=0;
mdelay(100);
device_of=1;
mdelay(300);

sec1=0;

else if(d0==0&&d1==1&&d2==1&&d3==0&&ack==0)

light6=~light6;
if(light6==0)
{
device_on=0;
mdelay(100);
device_on=1;
mdelay(300);
}
else
{
device_of=0;
mdelay(100);
device_of=1;
mdelay(300);
}
sec1=0;
}

else if(d0==1&&d1==1&&d2==1&&d3==0&&ack==0)
{
light7=~light7;
53
if(light7==0)
{
device_on=0;
mdelay(100);
device_on=1;
mdelay(300);
}
else
{
device_of=0;
mdelay(100);
device_of=1;
mdelay(300);
}
sec1=0;
}

else if(d0==0&&d1==0&&d2==0&&d3==1&&ack==0)
{
light8=~light8;
if(light8==0)
{
device_on=0;
mdelay(100);
device_on=1;
mdelay(300);
}
else
{
device_of=0;
mdelay(100);
device_of=1;
mdelay(300);
}
54
sec1=0;
}
else if(d0==1&&d1==0&&d2==0&&d3==1&&ack==0)
{
light9=~light9;
if(light9==0)
{
device_on=0;
mdelay(100);
device_on=1;
mdelay(300);
}
else {
device_of=0;
mdelay(100);
device_of=1;
mdelay(300);}
sec1=0;}
else if(d0==0&&d1==1&&d2==0&&d3==1&&ack==0){
light0=~light0;
if(light0==0){
device_on=0;
mdelay(100);
device_on=1;
mdelay(300);}
else {
device_of=0;
mdelay(100);
device_of=1;
mdelay(300);}
sec1=0;}
else if(d0==0&&d1==0&&d2==1&&d3==1&&ack==0){
mdelay(300);
green=0;
55
red=1;
return
void password(){
char pass=0;
char sec=0;
int number;
green=1;
red=0;
passkey[0]=2;
passkey[1]=2;
passkey[2]=2;
passkey[3]=2;
type_pass=0;
mdelay(100);
type_pass=1;
mdelay(300);

while(pass < 4 && sec < 100){


number=30000;
while(ack==1){
number--;
if(number==0 && ack==1)
break;}
sec++;{
if(ack==0)
sec=0;
if((d0==0&&d1==1&&d2==0&&d3==1&&ack==0)){
passkey[pass]=0;
while(ack==0);
pass++;}
else if((d0==1&&d1==1&&d2==1&&d3==0&&ack==0)){
passkey[pass]=7;
while(ack==0);
pass++;}
56
else if((d0==0&&d1==0&&d2==0&&d3==1&&ack==0)){
passkey[pass]=8;
while(ack==0);
pass++;}
else if((d0!=0||d1!=0||d2!=0||d3!=0)&&ack==0){
passkey[pass]=2;
while(ack==0);
pass++;}}}
if(pass>3){
if(passkey[0]==8 && passkey[1]==8 && passkey[2]==7 &&
passkey[3]==0){
corr_pass=0;
mdelay(100);
corr_pass=1;
mdelay(300);
dtmf();
green=0;
red=1;
return;}
else {
incr_pass=0;
mdelay(100);
incr_pass=1;
mdelay(300);
green=0;
red=1;
return;}}
green=0;
red=1;}
void IR(){
add=0;
cmd=0;
while(input == 1 && row4 == 1 && outside == 1);
if(input==0){
57
delay1();
tog();
delay();
address();
command();
nflip=flip;
if(add == 0 && (flip==1 || flip == 0))
{

value();
if(cmd==3)
{
light1=~light1;
mdelay(100);
}
else if(cmd==5)
{
light2=~light2;
mdelay(100);
}
else if(cmd==7)
{
light3=~light3;
mdelay(100);
}
else if(cmd==9)
{
light4=~light4;
mdelay(100);
}
else if(cmd==11)
{
light5=~light5;
mdelay(100);
58
}
else if(cmd==13)
{
light6=~light6;
mdelay(100);
}
else if(cmd==15)
{
light7=~light7;
mdelay(100);
}
else if(cmd==17)
{
light8=~light8;
mdelay(100);
}
else if(cmd==19)
{
light9=~light9;
mdelay(100);
}
else if(cmd==1)
{
light0=~light0;
mdelay(100);

59
4.4 MULTI SIM 12.0

We have used Multi Sim software to simulate the power supply section of our project.

Fig 4.2 Simulation of power supply using multisim software

60
CHAPTER- 5

RESULTS

Our main objective in this project was to design a system such that it allows a user to
operate the electrical appliances likes fans and lights of home using his mobile phone
and to know the statuses of appliances with the additional features of password
protection and memory interface that stores the current statuses of various appliances,
in case power failure occurs.

This project can be made to offer various advantages like:


 Climate
Controls for your heating and air conditioning (HVAC) systems, in the form
of programmable thermostats, address comfort and efficiency by maintaining a
schedule consistent with your family’s presence in the home. Convenience is
achieved when the automation system can detect motion and change the
temperature set point based on the garage door opening in combination with
the time of day. Or detect open doors or windows and shut down the HVAC
system until they are closed climate.

 Lighting
Lighting controls also provide convenience, comfort, and efficiency by
controlling when interior/exterior lights are turned on and the brightness level.
Lighting scenes are merely the combination on/off and brightness level
settings for multiple lights in the home to achieve a desired environment for a
given situation or occasion. Once a lighting scene is defined, it can be invoked
by time of day, motion or contact sensing, or the push of a single button at a
convenient place in the home

 Controls for your heating and air conditioning (HVAC) systems, in the form
of programmable thermostats, address comfort and efficiency by maintaining a
schedule consist family presence in the home.

61
Fig 5.1 Complete picture of working project

Fig 5.2 PCB of working Project

62
CHAPTER-6

FUTURE SCOPE

The Home Automation System can be enhanced with more and more digital systems
and can be used to enhance the usability of the project. As a result ,many systems that
are now developed such as speed control of fans and advanced home security. These
project can further be modified using Advanced Embedded Systems.
Some of its future features that can be added to enhance the functioning of the project

 Home data network


Increasingly home automation systems are being designed to utilize the home
data network to pass control information or stream digital media as mentioned
above. This infrastructure subsystem will play a larger role over time allowing
the integration of entertainment, computing, and control devices with
appliances into a coordinated.

 Security
Security and alarm systems normally address most of the safety issues in the
home environment. However, adequate lighting at night can prevent unwanted
accidents such as falling down the stairs or add to the burglary deterrent by
flashing exterior lights when motion is detected. Convenience improves when
security sensors can also be used to trigger climate and lighting scenes when
the alarm system is disarmed.
 Entertainment
Automated controls for your entertainment centre address simplicity and
convenience in the delivery of entertainment content. The universal remote
functionality replaces a myriad of individual device remotes and provides the
ability to control the entertainment activity by emitting multiple commands
with the press of a single button. A consistent operational interface is provided

63
when the same universal remote is deployed in multiple entertainment centers.
These systems are enhanced when the universal remote provides connectivity
to your home computing resources to retrieve media (e.g. digital photos and
music) to play on the entertainment display.
Note efficiency translates into dollar savings in energy cost for your home. A
simple example is turning on outside lights to 80% brightness at sunset to save
20% of the electricity usage for this one typical lighting scene. With whole-house
automation systems, described in more detail later, you have the greatest
opportunity to meet all your lifestyle factors by coordinating the operation of each
of the above subsystems into one cohesive system.

6.1 FUTURE OF HOME AUTOMATION

Predicting the future of just about anything is very risky business. Home automation
is an industry still selling and installing X10 devices nearly 30 years after the
technology was made commercially available in 1980. Nevertheless, we believe the
future of home automation will very much ride the digital age and develop along with
the computer and networking systems in the years to come. Indeed, as described by
the story on the Windows Media Centre, companies such as Microsoft and
Exceptional Innovation with their Life/ware software are positioning the Windows
Vista Ultimate Media Centre PC as the heart and sole of a complete solution for home
automation that will rely on web services to seamlessly interface with lighting
controls, climate controls, security panels, and IP surveillance cameras to accompany
the digital media management capabilities of Windows Media Centre. Another great
example of how the integration of traditional home automation systems with
Windows Media Centre and the home network has already taken hold is this "Cool
Homes" article published in electronic houses.

Advances in home networking technology using both wired and wireless Ethernet will
enable the addition of more devices to the network at an affordable incremental cost.
Those building new homes today should consider installing Cat6 wiring throughout
the home to position for Gigabit Ethernet future bandwidth which will improve the
performance of digital video streaming among devices in the home. The IEEE
802.11n standard for home Wi-Fi networks will likewise provide similar

64
improvements in wireless bandwidth. Even though the 802.11n specification is still in
draft form, pre-n home wireless routers delivering up to 300 Mbps bandwidth have
been available for the last 2 years and offer significant advances in signal strength
throughout the home. This improvement in bandwidth bodes well for existing
homeowners wanting to retrofit a home automation solution without knocking down
walls or tearing up drywall.

Fig 6.1Future Enhancements in home automation

Coupled with the above advances in Ethernet technology is the emergence of radio
frequency (RF) communications protocols such as ZigBee (IEEE 802.15.4 standard)
and Z-Wave developed by Zen Systems. RF communications has speed advantages
over Ethernet for small amounts of information which is typical of the command
sequences required for controlling lights or thermostats. We choose to highlight the
industry leading Control product line specifically because the system architecture is
built on a communications infrastructure that utilizes the strength of Ethernet for
digital audio streaming and Zig Bee for control information between the system
controller and other devices and user interfaces in the system. These new RF
protocols also enable wireless contact and motion sensors to be deployed in security
systems. An example is the ZigBee-based sensors from Card Access which also
improve the attractiveness of security features for existing homes.

65
Analogous to the computer and networking industries, the degree to which smart
home functionality will become mainstream will depend on the systems and software
developed to enable a "plug n' play" environment where a homeowner can purchase
lighting devices or thermostats that can easily be added to a PC-based or proprietary
home automation system without engaging a custom installer/integrator.

More recently we've discussed the potential of home automation from the
cloud which could have the ability to extend smart home technology to a much larger
market if a central server with a thin home controller client architecture was
developed and deployed. While Apple and others are touting the "cloud" as a
repository for all your media, it's not clear any of the top HA companies are looking at
the central server/remote client approach.

Fig 6.2 Home Automation in different ways

With the proliferation of household appliances available with an Ethernet connection


to add to the audio/video devices also having this connection, clearly a new level of
"automation" would be possible in the future if the "plug n' play" capability enjoyed
on today's computers is extended to these other home devices. This of course will
require manufacturers to see a compelling reason to include the appropriate chips and
firmware in these appliances to enable recognition by other controllers on the home
network.

66
APPENDIX A

(SOFTWARE METHODOLOGY)

A.1 WORKING WITH KEIL

To open keil software click on start menu then program and then select
keil2.Following window will appear on the screen.

You can see three different windows in this screen. 1) project work space window 2)
editing window 3) output window.

67
 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
 Move to your desired directory and there create a new folder for your project
named "first". Here new project is created in d:\keil2\myprojects\first as
shown in figure

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


extension.
A.1.1 TARGET SELECTION

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

68
 Scroll down the cursor and select generic from list. expand the list and select
8051 (all variants)

 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. You
will see following window.

69
 Now click on file menu and select new file. editor window will open. Now
you can start writing your code.

A.1.2 INCLUDE HEADER FILE

 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"
 After including this file, right click on the file and select open document
<reg51.h>.Following window will appear.

 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.
70
 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

A.1.3 BUILDING TARGET

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

71
 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 un
checking 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
 To run the program you can use any of the option provided "go", "step by
step", "step forward" etc.
 Now after testing your program you need to download this program on your
target board i.e. 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.

72
 Select output tag and check "create hex file" box
 Now when you again build your program you will see the message in output
window "hex file is created".
 In your project folder you can see the hex file with same name of your project
as "test.hex".
 you can directly load this file in 8051 target board and run the application on
actual environment.

73

You might also like