Embedded Systems(DTMF Based Device Switching)

43
Page 1 of 43 CONTENTS  Introduction   Abstract  Technology Overview  Components and Specifications  Sound beam Processor/ Amplifier  Audio Spotlight Transducer  Non-Linearity of Air  Direct Audio and Projected Audio  Special Features  Applications/ Future Expansions  Conclusion  Bibliography

Transcript of Embedded Systems(DTMF Based Device Switching)

Page 1: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 1/43

Page 1 of 43 

CONTENTS

  Introduction 

  Abstract

  Technology Overview

  Components and Specifications

  Sound beam Processor/ Amplifier

  Audio Spotlight Transducer

  Non-Linearity of Air

  Direct Audio and Projected Audio

  Special Features

  Applications/ Future Expansions

  Conclusion

 Bibliography

Page 2: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 2/43

Page 2 of 43 

INTRODUCTION

 Embedded Systems:

An embedded system is a computer system designed to do one or a few dedicated and/or

specific functions often with real-time computing constraints. It is embedded as part of a

complete device often including hardware and mechanical parts. By contrast, a general-

purpose computer, such as a personal computer (PC), is designed to be flexible and to

meet a wide range of end-user needs. Embedded systems control many devices in

common use today.

Embedded systems are controlled by one or more main processing cores that are typically

microcontrollers etc. The key characteristic, however, is being dedicated to handle a

particular task. They may require very powerful processors and extensive

communication, for example air traffic control systems may usefully be viewed as

embedded, even though they involve mainframe computers and dedicated regional and

national networks between airports and radar.

Since the embedded system is dedicated to specific tasks, design engineers can optimize

it to reduce the size and cost of the product and increase the reliability and performance.

Embedded systems range from portable devices such as digital watches and MP3 players,

to large stationary installations like traffic lights, factory controllers, the systems

controlling nuclear power plants, etc. Complexity varies from low, with a single

microcontroller chip, to very high with multiple units, peripherals and networks mounted

inside a large chassis or enclosure.

In general, "embedded system" is not a strictly definable term, as most systems have

some element of extensibility or programmability. On a continuum from "generalpurpose" to "embedded", large application systems will have subcomponents at most

points even if the system as a whole is "designed to perform one or a few dedicated

functions", and is thus appropriate to call "embedded".

Page 3: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 3/43

Page 3 of 43 

 Basic Introduction to the project:

Controlling devices using switches are common. From a few decades controlling devices

using remote control switches like infra-red remote control switch, wireless remote

control switches, light activated switches are becoming popular. But these technologies

have their own limitations. Laser beams are harmful to mankind. Some technologies like

IR remote control are used for short distance applications. In such case if we have system

which does not require any radiations or which is not harmful, long remote control

switch!! Yes here is the solution. Here is such a system which does not require any

radiations, any laser beam which has no limitation of range; it means it can be used from

any distance from meters to thousand kilometers using a simple telephone line or mobile

phone. Using a mobile phone as a media, this serves as the main part of the system.

Mobile phones today have become an essential entity for one and all and so, for any

mobile based application there is great reception. Conventionally, Wireless controlled

devices use RF circuits, which have the drawbacks of limited working range, limited

frequency range and limited control. Use of a Mobile Phone for Device control can

overcome these limitations.

It provides the advantage of robust control, working range as large as the coverage area

of the service provider, no interference with other controllers.

 Introduction to the DTMF Technology:

DTMF i.e. Dual Tone Multiple Frequency is the frequency produced by the mobile

phones whenever a key is pressed during call or pre-calling state. It 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. Each key present on the keyboard produces a different frequency when

pressed. This tone is received at the receiving end too along with the transmitting end.

This allows this technology to be used as a remote switching technique, which can be

used to switch/control various objects from far distances. Multi-frequency signaling is a

Page 4: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 4/43

Page 4 of 43 

group of signaling methods that use a mixture of two pure tone (pure sine wave) sounds. 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.

Page 5: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 5/43

Page 5 of 43 

Embedded Systems

Embedded systems are the firmware composed of microprocessors or microcontrollers

designed to perform a specific task e.g. coffee machine, door sensor, traffic lights,switching devices, aircrafts circuitry etc. An embedded system is a computer system

designed to perform one or a few dedicated functions often with real-time computing

constraints. It is embedded as part of a complete device often including hardware and

mechanical parts. By contrast, a general-purpose computer, such as a personal computer

(PC), is designed to be flexible and to meet a wide range of end-user needs. Embedded

systems control many devices in common use today. Embedded systems are controlled

by one or more main processing cores that are typically either microcontrollers or digital

signal processors (DSP).

The key characteristic, however, is being dedicated to handle a particular task, which may

require very powerful processors. For example, air traffic control systems may usefully

be viewed as embedded, even though they involve mainframe computers and dedicated

regional and national networks between airports and radar sites.(Each radar probably

includes one or more embedded systems of its own.)

Since the embedded system is dedicated to specific tasks, design engineers can optimize

it to reduce the size and cost of the product and increase the reliability and performance.

Some embedded systems are mass-produced, benefiting from economies of scale.

Physically embedded systems range from portable devices such as digital watches

andMP3 players, to large stationary installations like traffic lights, factory controllers, or

the systems controlling nuclear power plants.

Complexity varies from low, with a single microcontroller chip, to very high with

multiple units, peripherals and networks mounted inside a large chassis or enclosure. In

general, "embedded system" is not a strictly definable term, as most systems have some

element of extensibility or programmability.

Page 6: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 6/43

Page 6 of 43 

For example, handheld computers share some elements with embedded systems such as

the operating systems and microprocessors they allow different applications to be loaded

and peripherals to be connected. Moreover, even systems which don't expose

programmability as a primary feature generally need to support software updates. On a

continuum from "general purpose" to "embedded", large application systems will have

subcomponents at most points even if the system as a whole is "designed to perform one

or a few dedicated functions", and is thus appropriate to call "embedded".

The embedded systems have the following characteristics:

1.  Embedded systems are designed to do some specific task, rather than be a

general-purpose computer for multiple tasks. Some also have real-timeperformance constraints that must be met, for reasons such as safety and usability;

others may have low or no performance requirements, allowing the system

hardware to be simplified to reduce costs.

2.  Embedded systems are not always standalone devices. Many embedded systems

consist of small, computerized parts within a larger device that serves a moregeneral purpose. For example, the Gibson Robot Guitar features an embedded

system for tuning the strings, but the overall purpose of the Robot Guitar is, of 

course, to play music. Similarly, an embedded system in an automobile provides a

specific function as a subsystem of the car itself.

3.  The program instructions written for embedded systems are referred to as

firmware, and are stored in read-only memory or Flash memory chips. They run

with limited computer hardware resources: little memory, small or non-existent

keyboard and/or screen.

Page 7: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 7/43

Page 8: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 8/43

Page 8 of 43 

an electric current, hydraulic fluid pressure or pneumatic pressure, and converts

that energy into some kind of motion.

vi.   Memory: Generally in the microcontrollers EEPROMs are used.

Page 9: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 9/43

Page 9 of 43 

CLASSIFICATION OF EMBEDDED SYSTEMS:

1.  Stand Alone Embedded System: These systems takes the input in the form of 

electrical signals from transducers or commands from human beings such as

pressing of a button etc., process them and produce desired output. This entire

process of taking input, processing it and giving output is done in

standalone mode i.e. without moving during their runtime phase.

Such embedded systems come under stand-alone embedded systems

E.g.: microwave oven, air conditioner etc.

2.  Real-time embedded systems: Embedded systems which are used to perform a

specific task or operation in a specific time period those systems are called as

real-time embedded systems. There are two types of real-time embedded systems.

a.  Hard Real-time embedded systems: These embedded systems follow an

absolute dead line time period i.e., if the tasking is not done in a particular time

period then there is a cause of damage to the entire equipment.

Page 10: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 10/43

Page 10 of 43 

E.g.: Consider a system in which we have to open a valve within 30 milliseconds.

If this valve is not opened in 30 ms this may cause damage to the entire

equipment.

b.  Soft Real Time embedded systems: These embedded systems follow a

relative dead line time period i.e., if the task is not done in a particular time that

will not cause damage to the equipment.

E.g.: Consider a TV remote control system, if the remote control takes a few

milliseconds delay it will not cause damage either to the TV or to the remote

control. These systems which will not cause damage when they are not operated

at considerable time period those systems comes under soft real-time embedded

systems.

3.  Network communication embedded systems: A wide range network interfacing

communication is provided by using embedded systems.

E.g.: Consider a web camera that is connected to the computer with internet can be used

to spread communication like sending pictures, images, videos etc., to another

computer with internet connection anywhere in the world.

DIFFERENT TYPES OF PROCESSING UNITS:

The central processing unit can be any one of the following microprocessor,

microcontroller, digital signal processing.

Page 11: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 11/43

Page 11 of 43 

1.  Microcontroller: It is of low cost processor and one of the main advantages

of microcontrollers is, the components such as memory, serial communication

interfaces, analog to digital converters etc.., all these are built on a single chip.

The numbers of external components that are connected to it are very less

according to the application.

2.  Microprocessors: These are more powerful than microcontrollers. They are

used in major applications with a number of tasking requirements. But the

microprocessor requires many external components like memory, serial

communication, hard disk, input output ports etc ., so the power consumption is

also very high when compared to microcontrollers.

3.  Digital signal processing: It is used mainly for the applications that particularly

involved with processing of signals.

EXPLANATION OF EMBEDDED SYSTEMS:

Software Architecture: There are several different types of software architecture in

common use.

1.  Simple Control Loop: In this design, the software simply has a loop. The loop

calls subroutines, each of which manages a part of the hardware or software.

2.  Interrupt Controlled System: Some embedded systems are predominantly

interrupt controlled. This means that tasks performed by the system are triggered

by different kinds of events. An interrupt could be generated for example by a

timer in a predefined frequency, or by a serial port controller receiving a byte.

These kinds of systems are used if event handlers need low latency and the event

handlers are short and simple. Usually these kinds of systems run a simple task in

a main loop also, but this task is not very sensitive to unexpected delays.

Page 12: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 12/43

Page 12 of 43 

Sometimes the interrupt handler will add longer tasks to a queue structure. Later,

after the interrupt handler has finished, these tasks are executed by the main loop.

This method brings the system close to a multitasking kernel with discrete

processes.

3.  Cooperative Multitasking: A non-preemptive multitasking system is very

similar to the simple control loop scheme, except that the loop is hidden in an

API. The programmer defines a series of tasks, and each task gets its own

environment to run´ in. When a task is idle, it calls an idle routine, usually called

pause, wait, yield, nop (stands for no operation), etc. The advantages and

disadvantages are very similar to the control loop, except that adding new

software is easier, by simply writing a new task, or adding to the queue-

interpreter.

4.  Primitive Multitasking: In this type of system, a low-level piece of code

switches between tasks or threads based on a timer (connected to an interrupt).

This is the level at which the system is generally considered to have an "operating

system" kernel. Depending on how much functionality is required, it introduces

more or less of the complexities of managing multiple tasks running conceptually

in parallel. As any code can potentially damage the data of another task (except in

larger systems using an MMU) programs must be carefully designed and tested,

and access to shared data must be controlled by some synchronization strategy,

such as message queues, semaphores or a non-blocking synchronization scheme.

Because of these complexities, it is common for organizations to buy a real-time

operating system, allowing the application programmers to concentrate on device

functionality rather than operating system services, at least for large systems;

smaller systems often cannot afford the overhead associated with a generic real

time system, due to limitations regarding memory size, performance, and/or

battery life.

5.  Microkernels and Exokernels: A microkernel is a logical step up from a real-

time OS. The usual arrangement is that the operating system kernel allocates

Page 13: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 13/43

Page 13 of 43 

memory and switches the CPU to different threads of execution. User mode

processes implement major functions such as file systems, network interfaces, etc.

In general, microkernels succeed when the task switching and inter task 

communication is fast, and fail when they are slow. Exokernels communicate

efficiently by normal subroutine calls. The hardware and all the software in the

system are available to, and extensible by application programmers. 

APPLICATIONS OF EMBEDDED SYSTEMS:

1.  Consumer Applications: At home we use a number of embedded systems which

include microwave oven, remote control, vcd players, camera etc.

2.  Office Automation: We use machines like fax machine, modem, printer etc.

3.  Industrial Automation: Today a lot of industries are using embedded systems

for process control. In industries we design the embedded systems to perform a

specific operation like monitoring temperature, pressure, humidity, voltage, etc.

and basing on these monitored levels we do control other devices, we can send

information to a centralized monitoring station.

4.  Other Applications: The robots are also an example of embedded system.

Embedded systems also fid applications in computer networking.

Page 14: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 14/43

Page 14 of 43 

MICROCONTROLLER

A micro-controller can be compared to a small stand-alone computer; it is a very

powerful device, which is capable of executing a series of pre-programmed tasks and

interacting with other hardware devices. Being packed in a tiny integrated circuit (IC)

whose size and weight is usually negligible, it is becoming the perfect controller for

robots or any machines requiring some kind of intelligent automation. A single

microcontroller can be sufficient to control a small mobile robot, an automatic washer

machine or a security system. Any microcontroller contains a memory to store the

program to be executed, and a number of input/output lines that can be used to interact

with other devices, like reading the state of a sensor or controlling a motor.

Nowadays, microcontrollers are so cheap and easily available that it is common to use

them instead of simple logic circuits like counters for the sole purpose of gaining some

design flexibility and saving some space. Some machines and robots will even rely on a

multitude of microcontrollers, each one dedicated to a certain task. Most recent

microcontrollers are 'In System Programmable', meaning that you can modify the

program being executed, without removing the microcontroller from its place.

Today, microcontrollers are an indispensable tool for the robotics hobbyist as well as for

the engineer. Starting in this field can be a little difficult, because you usually can't

understand how everything works inside that integrated circuit, so you have to study the

system gradually, a small part at a time, until you can figure out the whole image and

understand how the system works. One of the prime controllers is 89S52.

The 8051 is the name of a big family of microcontrollers. The device which we are going

to use along this tutorial is the 'AT89S52'  which is a typical 8051 microcontroller

manufactured by Atmel. Note that this part doesn't aim to explain the functioning of the

different components of 89S52 microcontroller, but rather to give you a general idea of 

the organization of the chip and the available features.

Page 15: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 15/43

Page 15 of 43 

The block diagram provided by Atmel in their datasheet showing the architecture the

89S52 device can seem very complicated, and since we are going to use the C high level

language to program it. This figure shows the main features and components that the

designer can interact with. You can notice that the 89S52 has 4 different ports, each one

having 8 Input/output lines providing a total of 32 I/O lines. Those ports can be used to

output DATA and orders do other devices, or to read the state of a sensor, or a switch.

Most of the ports of the 89S52 have 'dual function' meaning that they can be used for two

different functions: the first one is to perform input/output operations and the second one

is used to implement special features of the microcontroller like counting external pulses,

interrupting the execution of the program according to external events, performing serial

data transfer or connecting the chip to a computer to update the software.

Each port has 8 pins, and will be treated from the software point of view as an 8-bit

variable called 'register', each bit being connected to a different Input/output pin. You can

also notice two different memory types: RAM and EEPROM. Shortly, RAM is used to

store variable during program execution, while the EEPROM memory is used to store the

program itself, that's why it is often referred to as the 'program memory'. The memory

organization will be discussed in detail later.

At this stage, it is just important to note that the 89S52 incorporates hardware circuits that

can be used to prevent the processor from executing various repetitive tasks and save

processing power for more complex calculations. Those simple tasks can be counting the

number of external pulses on a pin, or generating precise timing sequences. It is clear that

the CPU (Central Processing Unit) is the heart of the microcontrollers; it is the CPU that

will Read the program from the FLASH memory and execute it by interacting with the

different peripherals discussed above.

Page 16: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 16/43

Page 16 of 43 

Architecture of a Microcontroller:

Page 17: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 17/43

Page 17 of 43 

Pin diagram:

The pin diagram of a general microcontroller can be given as:

The description of the pin diagram can be given as:

Page 18: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 18/43

Page 18 of 43 

Pins 1-8: Port 1 Each of these pins can be configured as an input or an output.

Pin 9: RS a logic one on this pin disables the microcontroller and clears the contents of 

most registers. In other words, the positive voltage on this pin resets the microcontroller.

By applying logic zero to this pin, the program starts execution from the beginning.

Pins10-17: Port 3 Similar to port 1, each of these pins can serve as general input or

output. Besides, all of them have alternative functions:

Pin 10: RXD Serial asynchronous communication input or Serial synchronous

communication output.

Pin 11: TXD Serial asynchronous communication output or Serial synchronouscommunication clock output.

Pin 12: INT0 Interrupt 0 input.

Pin 13: INT1 Interrupt 1 input.

Pin 14: T0 Counter 0 clock input.

Pin 15: T1 Counter 1 clock input.

Pin 16: WR Write to external (additional) RAM.

Pin 17: RD Read from external RAM.

Pin 18, 19: X2, X1 Internal oscillator input and output. A quartz crystal which specifies

operating frequency is usually connected to these pins. Instead of it, miniature ceramics

resonators can also be used for frequency stability. Later versions of microcontrollers

operate at a frequency of 0 Hz up to over 50 Hz.

Pin 20: GND Ground.

Pin 21-28: Port 2 If there is no intention to use external memory then these port pins are

configured as general inputs/outputs. In case external memory is used, the higher address

byte, i.e. addresses A8-A15 will appear on this port. Even though memory with capacity

Page 19: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 19/43

Page 19 of 43 

of 64Kb is not used, which means that not all eight port bits are used for its addressing,

the rest of them are not available as inputs/outputs.

Pin 29: PSEN if external ROM is used for storing program then a logic zero (0) appears

on it every time the microcontroller reads a byte from memory.

Pin 30: ALE Prior to reading from external memory, the microcontroller puts the lower

address byte (A0-A7) on P0 and activates the ALE output. After receiving signal from

the ALE pin, the external register (usually 74HCT373 or 74HCT375 add-on chip)

memorizes the state of P0 and uses it as a memory chip address. Immediately after that,

the ALU pin is returned its previous logic state and P0 is now used as a Data Bus. As

seen, port data multiplexing is performed by means of only one additional (and cheap)

integrated circuit. In other words, this port is used for both data and address transmission.

Pin 31: EA By applying logic zero to this pin, P2 and P3 are used for data and address

transmission with no regard to whether there is internal memory or not. It means that

even there is a program written to the microcontroller, it will not be executed. Instead, the

program written to external ROM will be executed. By applying logic one to the EA pin,

the microcontroller will use both memories, first internal then external (if exists).

Pin 32-39: Port 0 Similar to P2, if external memory is not used, these pins can be used as

general inputs/outputs. Otherwise, P0 is configured as address output (A0-A7) when the

ALE pin is driven high (1) or as data output (Data Bus) when the ALE pin is driven low

(0).

Pin 40: VCC +5V power supply.

Memory Organization in a Microcontroller:

Page 20: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 20/43

Page 20 of 43 

A RAM stands for Random Access Memory, it has

basically the same purpose of the RAM in a desktop

computer, which is to store some data required during

the execution time of different programs. While an

EEPROM, also called as FLASH memory is a more

elaborated ROM (Read Only Memory) which is the

memory where the program being executed is stored.

Even if that's not exactly true, you can compare an

EEPROM to the Hard-Disk of a desktop computer from

a general point of view. The EEPROM term stands for

Electronically Erasable and Programmable Read Only

Memory.

In microcontrollers, like in any digital system, memory

is organized in  Registers, Which is the basic unit of 

construction of a memory. Each register is composed of 

a number of bits (usually 8) where the data can be

stored. In the 8051 family of microcontrollers for

example, most registers are 8-bit register, capable of 

storing values ranging from 0 to 255. In order to use

bigger values, various register can be used

simultaneously. Figure 1.3.A shows a typical 8-bit

registers, where the notation D0 to D7 stands for the 8

DATA bits of the register.

D7 D6 D5 D4 D3 D2 D1 D0

As you shall see, the RAM memory of the 89S52, which contains 256 registers, is

divided into two main parts, the GPR part, and the SFR part. GPR stands for 'GeneralPurpose Register' and are the registers that you can use to store any data during the

execution of your program. SFRs (Special function Register) are registers used to control

the functioning of the microcontroller and to assist the processor through the various

operations being executed. For example, SFRs can be used to control Input/Output lines,

Page 21: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 21/43

Page 21 of 43 

to retrieve data transmitted through the serial port of a desktop computer, or to configure

one of the on-chip counters and timers.

In a memory each register has a specific address which is used by the processor to read

and write from specific memory location. Figure 1.3.B shows the memory organization

of the 256 registers of the RAM of the 89S52 microcontroller. The address is noted in

Hexadecimal format as this notation simplifies digital logic calculations for the designers,

00 corresponds to the first location and FF which is equal to 256 corresponds to the last

location.

A programmer that would use the assembly language, have to take this memory

organization into consideration while choosing the locations where his variables are

stored, as writing general purpose data into special function registers could prevent the

microcontroller from working correctly, but since we will use the C language using the

KEIL IDE (integrated development environment), this part will be totally handled by the

compiler.

Programming of a Microcontroller:

The C source code is very high level language, meaning that it is far from being at the

base level of the machine language that can be executed by a processor. This machine

language is basically just zero's and one's and is written in Hexadecimal format, that why

they are called HEX files.

There are several types of HEX files; we are going to produce machine code in the

INTEL HEX-80 format, since this is the output of the KEIL IDE that we are going to use.

Diagram shows that to convert a C program to machine language, it takes several stepsdepending on the tool you are using, however, the main idea is to produce a HEX file at

the end. This HEX file will be then used by the 'burner' to write every byte of data at the

appropriate place in the EEPROM of the 89S52.

Page 22: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 22/43

Page 22 of 43 

Variables:

One of the most basic concepts of programming is to handle variables. knowing the exact

type and size of a variable is a very important issue for microcontroller programmers,

because the RAM is usually limited is size. There are two main design considerations to

be taken in account when choosing the variables types: the occupied space in ram and the

processing speed. Logically, a variable that occupies a big number of registers in RAM

will be more slowly processed than a small variable that fits on a single register.

For you to choose the right variable type for each one of your applications, you will have

to refer to the following table:

Data Type  Bits  Bytes  Value Range 

bit 1 -- 0 to 1

signed char 8 1 -128 to +127

unsigned char 8 1 0 to 255

signed int 16 2 -32768 to +32767

Page 23: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 23/43

Page 23 of 43 

unsigned int 16 2 0 to 65535

signed long 32 4 -2147483648 to 2147483647

unsigned long 32 4 0 to 4294967295

float 32 4±1.175494E-38 to

±3.402823E+38

This table shows the number of bits and bytes occupied by each type of variables, noting

that each byte will fit into a register. You will notice that most variables can be either

'signed' or unsigned 'unsigned', and the major difference between the two types is the

range, but both will occupy the same exact space in memory.

The names of the variables shown in the table are the same that are going to be used in

the program for variables declarations. Note that in C programming language, any

variable have to be declared to be used. Declaring a variable, will attribute a specific

location in the RAM or FLASH memory to that variable. The size of that location will

depend on the type of the variable that has been declared.

To understand the difference between those types, consider the following example source

code where we start by declaring three 'unsigned char' variables, and one 'signed char'

and then perform some simple operations:

Page 24: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 24/43

Page 24 of 43 

In that program the values of 'c' will be equal to '155' and not '-100' as you might have

known, because the variable 'c' is an unsigned type, and when the value to be stored in a

variable is bigger than the maximum value range of this variable, it overflows and rolls

back to the other limit. Back to our example, the program is trying to store '-100' in 'c',

but since 'c' is unsigned, its range of values is from '0 to 255' so, trying to store a value

below zero, will cause the variable to overflow, and the compiler will subtract the '-100'

from the other limit plus 1, from '255 + 1' giving '156'. We add 1 to the range because the

overflow and roll back operation from 0 to 255 counts for the subtraction of one bit. On

the other hand, the value of ’d’ will be equal to '-100' as expected, because it is a 'signed'

variable. Generally, we try to avoid storing value that is out of range, because sometime,

even if the compiler doesn't halt on that error, the results can be sometimes totally un-

expected.

Note that in the C programming language, any code line is ended with a semicolon ';',

except for the lines ending with brackets '{' '}'.

Loop Statements:

In most programs, it is required at a certain time, to differentiate between different

situations, to make decision according to specific input, or to direct the flow of the code

depending on some criteria. All the above situations describe an indispensable aspect of 

programming: 'conditions'. In other words, this feature allows to execute a block of code

only under certain conditions, and otherwise execute another code block or continue with

the flow of the program.

The most famous way to do that is to use the 'if' statement, according to the following

syntax.

Page 25: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 25/43

Page 25 of 43 

It is important to see how the code is organized in this part. The 'expression' is the

condition that shall be valid for the 'code block' to be executed. The code block is all

delimited by the two brackets '{' and '}'. In other words, all the code between those two

brackets will be executed if and only if the expression is valid. The expression can be any

combination of mathematical and logical expressions, as you can see in the following

example:

Notice the use of the two equal signs (==) between two variables or constants, In C

language, this means that you are asking whether P1 equals 0 or not. Writing this

expression with only one equal sign, would cause the compiler to store 0 in P1. This issue

is a source of logical error for many beginners in C language, this error won’t generate

any alert from the compiler and is very hard to identify in a big program, so pay attention,

it can save you lot of debugging time. Otherwise it is clear that in that previous example,

the code block is only executed if both the two expressions are true. Here is a list of all

the operators you can use to write an expression describing a certain condition:

Operator  Description 

== Equal to

<, > Smaller than, bigger than.

Page 26: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 26/43

Page 26 of 43 

<=, >= Smaller than or equal to, bigger than or equal to.

!= Not equal to

The 'If' code block can get a little more sophisticated by introducing the 'else' and 'else if'

statement. Observe the following example source code:

Here, There are four different code blocks, only one shall be executed if and only if the

corresponding condition is true. The last code block will only be executed if none of the

previous expression is valid. Note that you can have as many 'else if' blocks as you need,

each one with its corresponding condition, BUT you can only have one 'else' block,

which is completely logical. However you can chose not to have and 'else' block at all if 

you want.

There are some other alternatives to the 'if...else' code block, that can provide faster

execution speeds, but also have some limitations and restrictions like the 'Select...case'

code block. For now, it is enough to understand the 'if...else' code block, whose

performance is quite fair and have a wide range of applications.

Page 27: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 27/43

Page 27 of 43 

Another very important tool in the programming languages is the loop. In C language like

in many others, loops are usually restricted to certain number of loops like in the 'for'

code block or restricted to a certain condition like the 'while' block.

Let's start with the 'for' code block, which is a highly controllable and configurable loop.

Consider the following example source code:

Here the code between the two brackets '{' '}' will be executed a certain number of times,

each time with the counting variable 'i' increasing by 1 according to the statement 'i++'.

The code will keep looping as long as the condition 'i<10' is true. Usually the counting

value 'i' is reused in the body of the loop, which makes the particularity of this loop. The

'for' loop functioning can be recapitulated by the following syntax:

Where start represents the start value assigned to the count value before the loop begins.

The condition is the expression that is is to remain true for the loop to continue; as long

as this conditions is satisfied, the code will keep looping. Finally,  step is the increase or

decrease of the counting variable; it can be any statement that changes its value, whether

by an addition or subtraction.

Page 28: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 28/43

Page 28 of 43 

The second type of loop that we are going to study is the 'while' loop. The syntax of this

one is simpler than the previous one, as you can observe in the following example source

code that is equivalent to the previous method:

Here there is only one parameter to be defined, which is the condition to keep this loop

alive, which is 'i < 10' in our example. Then, it is the responsibility of the programmer to

design the software carefully to provide an exit for that loop, or to make it an infinite

loop.

General Structure of C program:

All C programs have this common organization scheme, sometimes it's followed,

sometimes it's not, however, it is imperative for this category of programming that this

organization scheme be followed in order to be able to develop your applications

successfully. Any application can be divided into the following parts, noting that it

should be written in this order:

Headers Includes and constants definitions: In this part, header files (.h) are included

into your source code. Those headers files can be system headers to declare the name of 

SFRs, to define new constants, or to include mathematical functions like trigonometric

functions, root square calculations or numbers approximations. Header files can also

Page 29: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 29/43

Page 29 of 43 

contain your own functions that would be shared by various programs.

Variables declarations: More precisely, this part is dedicated to 'Global Variables'

declarations. Variables declared in this place can be used anywhere in the code. Usually

in microcontroller programs, variables are declared as global variables instead of local

variables, unless you are running short of RAM memory and want to save some space, so

we use local variables, whose values will be lost each time you switch from a function to

another. To summarize, global variables as easier to use and implement than local

variables, but they consume more memory space.

Functions’ body: Here you group all your functions. Those functions can be simple ones

that can be called from another place in your program, as they can be called from an

'interrupt vector'. In other words, the sub-programs to be executed when an interrupt

occurs is also written in this place.

Initialization: The particularity of this part is that it is executed only one time when the

microcontroller was just subjected to a 'RESET' or when power is just switched ON, then

the processor continue executing the rest of the program but never executes this part

again. This particularity makes it the perfect place in a program to initialize the values of 

some constants, or to define the mode of operation of the timers, counters, interrupts, and

other features of the microcontroller.

Infinite loop: An infinite loop in a microcontroller program is what is going to keep it

alive, because a processor have to be allays running for the system to function, exactly

like a heart have to be always beating for a person to live. Usually this part is the core of 

any program, and it’s from here that all the other functions are called and executed.

Page 30: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 30/43

Page 30 of 43 

Interrupts in Microcontroller:

Microcontrollers must provide real time (predictable, though not necessarily fast)

response to events in the embedded system they are controlling. When certain events

occur, an interrupt system can signal the processor to suspend processing the current

instruction sequence and to begin an interrupt service routine (ISR, or "interrupt

handler"). The ISR will perform any processing required based on the source of the

interrupt before returning to the original instruction sequence. Possible interrupt sources

are device dependent, and often include events such as an internal timer overflow,

completing an analog to digital conversion, a logic level change on an input such as from

a button being pressed, and data received on a communication link. Where power

consumption is important as in battery operated devices, interrupts may also wake a

microcontroller from a low power sleep state where the processor is halted until required

to do something by a peripheral event.

Interrupt Flag Interrupt Handler Address

External 0 IE0 0003h

Timer 0 TF0 000Bh

External 1 IE1 0013h

Timer 1 TF1 001Bh

Serial RI/TI 0023h

Page 31: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 31/43

Page 31 of 43 

Project

Project: DTMF Based Device switching.

 Description: DTMF i.e. Dual Tone Multiple Frequency is the frequency produced by the

mobile phones whenever a key is pressed during call or pre-calling state. It 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. Each key present on the keyboard produces a different frequency when

pressed. This tone is received at the receiving end too along with the transmitting end.

This allows this technology to be used as a remote switching technique, which can be

used to switch/control various objects from far distances. Multi-frequency signaling is a

group of signaling methods that use a mixture of two pure tone (pure sine wave) sounds.

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.

Page 32: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 32/43

Page 32 of 43 

Hardware Utilized:

1.  Etched PCB Board

2.  AT89S52 Micro-controller

3.  Crystal Oscillators

4.  Registers

5.  Resistor Banks

6.  Capacitors

7.  7805 Voltage regulator

8.  +12 V DC Supply

9.  LEDs

10.  8870 DTMF Decoder

11.  L293D IC

12.  ULN2003 IC

13.  DC Motor (12V)

14.  Wires etc.

Page 33: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 33/43

Page 33 of 43 

Hardware description:

Description of various hardware components and their interfacing:

1.  Light Emitting Diodes (LEDs):

1.1.1.  Introduction:  A light-emitting diode (LED) is a semiconductor light source.

LEDs are used as indicator lamps in many devices and are increasingly used for

other lighting. Introduced as a practical electronic component in 1962, early LEDs

emitted low-intensity red light, but modern versions are available across

the visible, ultraviolet and infrared wavelengths, with very high brightness. When a light-

emitting diode is forward biased (switched on), 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 colour of the light

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

semiconductor.

1.1.2.  Colour Description:

Colour Produced Material Used

Infrared Gallium Arsenide

Red Aluminium gallium arsenide

Orange Gallium arsenide phosphide

Yellow Gallium arsenide phosphide

Green Indium Gallium nitride

Blue Zinc selenide

Ultraviolet Boron nitride

1.1.3.  Interfacing: The interfacing of an LED is a rather easy job, in this process we

 just need to provide a high pulse at the port at which the LED is interfaced.

Page 34: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 34/43

Page 34 of 43 

1.1.4. Advantages:

  Efficiency: LEDs emit more light per watt than incandescent light bulbs.

Their efficiency is not affected by shape and size, unlike fluorescent light bulbs or

tubes.

  Color: LEDs can emit light of an intended color without using any color

filters as traditional lighting methods need. This is more efficient and can lower

initial costs.

  Size: LEDs can be very small (smaller than 2 mm2) and are easily

populated onto printed circuit boards.

  On/Off time: LEDs light up very quickly. A typical red indicator LED

will achieve full brightness in under a microsecond. LEDs used in

communications devices can have even faster response times.  Cycling: LEDs are ideal for uses subject to frequent on-off cycling, unlike

fluorescent lamps that fail faster when cycled often, or HID lamps that require a

long time before restarting.

  Dimming: LEDs can very easily be dimmed either by pulse-width

modulation or lowering the forward current.

  Cool light: In contrast to most light sources, LEDs radiate very little heat

in the form of IR that can cause damage to sensitive objects or fabrics. Wasted

energy is dispersed as heat through the base of the LED.

  Slow failure: LEDs mostly fail by dimming over time, rather than the

abrupt failure of incandescent bulbs.

  Lifetime: LEDs can have a relatively long useful life. One report

estimates 35,000 to 50,000 hours of useful life, though time to complete failure

may be longer. Fluorescent tubes typically are rated at about 10,000 to 15,000

hours, depending partly on the conditions of use, and incandescent light bulbs at

1,000 – 2,000 hours.

  Shock resistance: LEDs, being solid state components, are difficult to

damage with external shock, unlike fluorescent and incandescent bulbs which are

fragile.

  Focus: The solid package of the LED can be designed to focus its light.

Incandescent and fluorescent sources often require an external reflector to collect

light and direct it in a usable manner.

Page 35: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 35/43

Page 35 of 43 

1.1.5.  Disadvantages:

  High initial price: LEDs are currently more expensive, price per lumen,

on an initial capital cost basis, than most conventional lighting technologies. The

additional expense partially stems from the relatively low lumen output and the

drive circuitry and power supplies needed.

  Temperature dependence: LED performance largely depends on the

ambient temperature of the operating environment. Over-driving an LED in high

ambient temperatures may result in overheating the LED package, eventually

leading to device failure. Adequate heat sinking is needed to maintain long life.

This is especially important in automotive, medical, and military uses where

devices must operate over a wide range of temperatures, and need low failure

rates.

  Voltage sensitivity: LEDs must be supplied with the voltage above the

threshold and a current below the rating. This can involve series resistors or

current-regulated power supplies.

  Light quality: Most cool-white LEDs have spectra that differ

significantly from a black body radiator like the sun or an incandescent light. The

spike at 460 nm and dip at 500 nm can cause the color of objects to be perceived

differently under cool-white LED illumination than sunlight or incandescent

sources, due to metamerism, red surfaces being rendered particularly badly by

typical phosphor based cool-white LEDs. However, the color rendering properties

of common fluorescent lamps are often inferior to what is now available in state-

of-art white LEDs.

2.  IC 7805: 7805 is a voltage regulator integrated circuit. It is a member of 78xx

series of fixed linear voltage regulator ICs. The voltage source in a circuit may

have fluctuations and would not give the fixed voltage output. The voltage

regulator IC maintains the output voltage at a constant value. The xx in 78xx

indicates the fixed output voltage it is designed to provide. 7805 provides +5V

regulated power supply. Capacitors of suitable values can be connected at input

and output pins depending upon the respective voltage levels.

Page 36: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 36/43

Page 36 of 43 

Pin Diagram:

3.  IC L293D:

  Introduction: L293D Dual H-Bridge Motor Driver so with one IC we can

interface two DC motors which can be controlled in both clockwise and counter

clockwise direction and if you have motor with fix direction of motion the you

can make use of all the four I/Os to connect up to four DC motors. L293D has

output current of 600mA and peak output current of 1.2A per channel. Moreover

for protection of circuit from back EMF output diodes are included within the IC.

The output supply (VCC2) has a wide range from 4.5V to 36V, which has made

L293D a best choice for DC motor driver.

Page 37: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 37/43

Page 37 of 43 

  Schematic Diagram: A simple schematic for interfacing a DC motor using

L293D is shown.

4.  IC 8870(DTMF Decoder IC):

  Introduction: 8870 IC is a DTMF decoder IC which is installed in the

systems which require DTMF tones for their functioning. The 8870 IC is a

primitive sought of IC which generates various codes on receiving the DTMF

frequency as input.

Page 38: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 38/43

Page 38 of 43 

  Pin Diagram or interfacing:

  Frequency Description:

Page 39: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 39/43

Page 39 of 43 

Coding(DTMF Based Device Switching):

#include<reg51.h>

#define dtmf P1

sbit led=P3^7;

sbit motor1_a=P2^0;

sbit motor1_b=P2^1;

sbit motor2_a=P2^2;

sbit motor2_b=P2^3;

void delay( );

void motor_run( );

void motor_stop( );

void led_on( );

void led_off( );

void main( )

{

dtmf=0x0f;

for(;;)

{

if(dtmf==0x01)

Page 40: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 40/43

Page 40 of 43 

{

motor_run( );

}

if(dtmf==0x02)

{

led_on( );

}

if(dtmf==0x03)

{

motor_stop( );

}

if(dtmf==0x04)

{

led_off( );

}

}

}

void led_on( )

Page 41: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 41/43

Page 41 of 43 

{

led=1;

return;

}

void led_off( )

{

led=0;

return;

}

void motor_run( )

{

motor1_a=1;

motor1_b=0;

motor2_a=1;

motor2_b=0;

return;

}

void motor_stop( )

Page 42: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 42/43

Page 42 of 43 

{

motor1_a=0;

motor1_b=0;

motor2_a=0;

motor2_b=0;

return;

}

void delay( )

{

unsigned char i,j;

for(i=0;i<255;i++)

for(j=0;j<255;j++);

}

Page 43: Embedded Systems(DTMF Based Device Switching)

8/2/2019 Embedded Systems(DTMF Based Device Switching)

http://slidepdf.com/reader/full/embedded-systemsdtmf-based-device-switching 43/43

BIBLIOGRAPHY

 Heath, Steve (2003). Embedded systems design. 

  Michael Barr. "Embedded Systems Glossary"

  Hodges, D.A., Jackson H.G., and Saleh, R. (2003). Analysis and Design of Digital

 Integrated Circuits.

  www.wikipedia.com