You are on page 1of 65

DTMF Controlled Robot MOBOT A Minor Project Submitted In partial fulfilment for the award of the Degree of Bachelor

of Technology in Department of Electronics of Communication Engineering

Session 2011-2012

Submitted By:
Shyami Govind

Supervised By:
Mr. Lalit Shrivastava Project Coordinator

Department of Electronics and Communication Engineering BMIT, Jaipur Rajasthan Technical University November, 2011

CANDIDATES DECLARATION
We hereby declare that the work, which is being presented in the project, entitled DTMF Controlled Robot, MOBOT in partial fulfilment for the award of Degree of Bachelor of Technology in Department Of Electronics and Communication Engineering and submitted to the Department of Electronics and Communication Engineering, Baldev Ram Mirdha Institute of Technology, Jaipur, Rajasthan Technical University is a record of our own investigations carried under the Guidance of Shri Lalit Shrivastava, Department of Electronics and Communication Engineering, BMIT, Jaipur. . Shyami Govind BMIT , Jaipur

Counter Signed by Mr. Lalit Shrivastava

LIST OF FIGURES

S.No. 1 2 3

Figure Fig 1.1: Sub systems of Digital Computer Fig 1.2: Microprocessor v/s Microcontroller Fig 1.3: Showing a typical microcontroller device and its different subunits

Page No. 1 2 4

4 5

Fig 3.1: Simplified model of a memory unit Fig 3.2: Simplified central processing unit with three registers

7 8

Fig 3.3: Showing connection between memory and central unit using buses

Fig 3.4: Simplified input-output unit communicating with external world

10

8 9

Fig 3.5: Watchdog Fig 3.6: Block for converting an analog input to digital output

11 12

10

Fig 3.7: Physical configuration of the interior of a microcontroller

12

11

Fig 3.8: Microcontroller outline with basic elements and internal connections

13

12 13 14

Fig 5.1: Pin Configuration of 8051 Figure 5.2: Architecture of 8051 Fig 5.3: RAM allocation in 8051 Fig 5.4: SFRs of 8051

17 20 24

15

Fig 5.5: DPL/DPH (Data Pointer Low/High, Addresses 82h/83h)

25

16 17

Fig 5.6: PCON (Power Control, Addresses 87h) Fig 5.7: TCON (Timer Control, Addresses 88h)

26 26

18 19 20 21 22

Fig 5.8: SCON (Serial Control, Addresses 98h) Fig 5.9: TMOD (Timer Mode, Addresses 89h) Fig 5.10: Timer modes Fig 5.11: IE (Interrupt Enable, Addresses A8h) Fig 5.12: IP (Interrupt Priority, Addresses B8h, BitAddressable)

27 27 28 29 29

23

Fig 5.13: PSW (Program Status Word, Addresses D0h, BitAddressable)

30

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

Fig 6.1: Circuit for an LED Fig 6.2: Interfacing of a LED with 8051 Fig 6.3: Interfacing of Keypad Matrix with 8051 Fig 6.4: Seven Segment Display Fig 6.5: A Relay Circuit Fig 6.6: Interfacing of a Relay with 8051 Fig 6.7: Connections of L293D Fig 6.8: 16x2 LCD Fig 6.9: pin diagram of LCD Fig 6.10: Interfacing of LCD Fig 7.1: Crystal Oscillator Fig 7.2 Regulator ICs Fig 7.2: Resistors Fig 7.3: Capacitor Fig 8.1: The Keil uVision Software Fig 9.1: Project Block Diagram Fig 9.2: Circuit Diagram Fig 9.3: Project Snapshot

31 32 33 34 36 37 38 39 39 40 42 43 45 46 47 51 53 57

LIST OF TABLES

S. No. 1

Table Table 5.1: Major 8 bit microcontrollers

Page No. 17

Table 5.2: Comparison of 8051 Family Members

18

Table 6.1: Timer modes

31

Table 7.1: Table to form display on Seven Segment

38

Table 7.2: Pin Description of LCD module

43

CONTENTS

Chapter No.

Topic

Page No.

Basic Concepts 1.1 Definition of Microprocessor 1.2 Definition of Microprocessor 1.3 Microcontroller v/s Microprocessor 1.4 Key features of Microcontroller

Technology Used 2.1 Embedded Systems 2.2 Variety of Embedded systems

Microcontroller Basics 3.1 Memory Unit 3.2 Central processing Unit 3.3 Bus 3.4 Input/output Unit 3.5 Serial communication 3.6 Timer Unit 3.7 Watchdog Timer 3.8 Analog to Digital Converter

Types of Microcontroller 4.1 8051 Microcontroller family 4.2 Comparison of 8051 family members 4.3 RISC v/s CISC

14

Architecture and Pin Configuration of 8051 5.1 Pin Configuration 5.2 8051 Microcontroller Architecture

17

5.3 Memory types in 8051 5.4 RAM Architecture 5.5 Special Function Register Memory

Peripherals and their Interfacing with8051 6.1 LED Interfacing 6.2 4X4 Matrix Keypad Interfacing 6.3 Seven Segment Display Interfacing 6.4 Relay Interfacing 6.5 DC Motor Interfacing 6.6 LCD Interfacing

31

Other Components 7.1 Crystal Oscillator 7.2 Zero PCB Plate 7.3 Voltage Regulator IC 7.4 Resistors 7.5 Capacitors

42

Programming and Related Software 8.1 Keil Microvision

47

Project Description 9.1 DTMF Controlled Robot 9.2 Project Methodology 9.3 Circuit Diagram 9.4 Procedure of building the Wireless Robot 9.5 Program Code 9.6 Project Snapshot

49

CHAPTER 1 INTRODUCTION

A digital computer typically consists of three major components: the Central Processing Unit (CPU), program and data memory, and an Input/output (I/O) system. The CPU controls the flow of information among the components of the computer. It also processes the data by performing digital operations. Most of the processing is done in the Arithmetic-Logic Unit (ALU) within the CPU. When the CPU of a computer is built on a single printed circuit board, the computer is called a minicomputer.

MICROPROCESSOR

Fig 1.1: Sub systems of Digital Computer

1.1 DEFENITION OF A MICROPROCESSOR

A microprocessor is a CPU that is compacted into a single-chip semiconductor device. Microprocessors are general-purpose devices, suitable for many applications. A computer built around a microprocessor is called a microcomputer. The choice of I/O and

memory devices of a microcomputer depends on the specific application. For example, most personal computers contain a keyboard and monitor as standard input and output devices.

1.2 DEFINITION OF MICROCONTROLLER

A microcontroller is an entire computer manufactured on a single chip. Microcontrollers are usually dedicated devices embedded within an application. For example, microcontrollers are used as engine controllers in automobiles and as exposure and focus controllers in cameras. In order to serve these applications, they have a high concentration of on-chip facilities such as serial ports, parallel input output ports, timers, counters, interrupt control, analog-to-digital converters, random access memory, read only memory, etc. The I/O, memory, and on-chip peripherals of a microcontroller are selected depending on the specifics of the target application. Since microcontrollers are powerful digital processors, the degree of control and programmability they provide significantly enhances the effectiveness of the application.

1.3 MICROCONTROLLER v/s MICROPROCESSOR

Fig 1.2: Microprocessor v/s Microcontroller

Microprocessor and microcontroller are two popular terms in world of computer. However, microprocessor and microcontroller has different functions and features.

Microprocessors generally require external components or circuits to implement program memory, RAM memory and Input/output. Intel's 8085, 80386 and Pentium are examples of microprocessors. Microcontrollers incorporate program memory, RAM memory and input/output port into one chip.

One of the main differences is that microcontrollers are usually designed to perform a small set of specific functions, for example as in the case of a Automatic Braking System which performs a small set of input processing functions, whereas microprocessors tend to be designed to perform a wider set of general purpose functions. For example, microcontrollers are widely used in modern cars where they will each perform a dedicated task, i.e. a microcontroller to regulate the brakes on all four wheels, or a microcontroller to regulate the car air conditioning, or a microcontroller for automatic gate systems.

These microcontrollers will perform few other tasks (if any) other than those specified. Compared to a microprocessor in a PC which performs a wide range of tasks related to the general requirements of a PC such as performing the necessary calculations for a very wide set of software applications, performing Input/output for the main subsystems, peripheral control etc.

1.4 KEY FEATURES OF A MICROCONTROLLER High Integration of Functionality Microcontrollers sometimes are called single-chip computers because they have on-chip memory and I/O circuitry and other circuitries that enable them to function as small standalone computers without other supporting circuitry. Field Programmability, Flexibility Microcontrollers often use EEPROM or EPROM as their storage device to allow field programmability so they are flexible to use. Once the program is tested to be correct then

large quantities of microcontrollers can be programmed to be used in embedded systems. Easy to Use, Assembly language is often used in microcontrollers and since they usually follow RISC architecture, the instruction set is small. The development package of microcontrollers often includes an assembler, a simulator, a programmer to "burn" the chip and a demonstration board. Some packages include a high level language compiler such as a C compiler and more sophisticated libraries.

Most microcontrollers will also combine other devices such as: A Timer module to allow the microcontroller to perform tasks for certain time periods. A serial I/O port to allow data to flow between the microcontroller and other devices such as a PC or another microcontroller. An ADC to allow the microcontroller to accept analogue input data for processing

Fig 1.3: Showing a typical microcontroller device and its different subunits

CHAPTER 2 TECHNOLOGY USED

2.1 EMBEDDED SYSTEMS


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. In contrast, a generalpurpose computer, such as a personal computer, is designed to be flexible and to meet a wide range of an end-user's needs. Embedded systems control many of the common devices in use today. Embedded systems are controlled by a main processing core that is typically either a microcontroller or a digital signal processor (DSP).Since the embedded system is dedicated to specific tasks, design engineers can optimize it, reducing the size and cost of the product and increasing 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 and MP3players, to large stationary installations like traffic lights, factory controllers, or the system 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 an exactly defined term, as many systems have some element of programmability. For example, handheld computers share some elements with embedded systems such as the operating systems and microprocessors which power them, but are not truly embedded systems, because they allow different applications to be loaded and peripherals to be connected.

2.2 VARIETY OF EMBEDDED SYSTEMS

Embedded systems span all aspects of modern life and there are many examples of their use. Telecommunications systems employ numerous embedded systems from telephone

switches for the network to mobile phones at the end-user. Computer networking uses dedicated routers and network bridges to route data.

Consumer electronics include personal digital assistants (PDAs), mp3 players, mobile phones, videogame consoles, digital cameras, DVD players, GPS receivers, and printers. Many household appliances, such as microwave ovens, washing machines and dishwashers, are including embedded systems to provide flexibility, efficiency and features. Advanced HVAC systems use networked thermostats to more accurately and efficiently control temperature that can change by time of day and season. Home automation uses wired- and wireless-networking that can be used to control lights, climate, security, audio/visual, surveillance, etc., all of which use embedded devices for sensing and controlling.

Transportation systems from flight to automobiles increasingly use embedded systems. New airplanes contain advanced avionics such as inertial guidance systems and GPS receivers that also have considerable safety requirements. Various electric motors, brushless DC motors, induction motors and DC motors are using electric/electronic motor controllers. Automobiles, electric vehicles, and hybrid vehicles are increasingly using embedded systems to maximize efficiency and reduce pollution. Other automotive safety systems include antilock braking system (ABS), Electronic Stability Control (ESC/ESP), traction control (TCS) and automatic four-wheel drive.

Medical equipment is continuing to advance with more embedded systems for vital signs monitoring, electronic stethoscopes for amplifying sounds, and various medical imaging (PET,SPECT, CT, MRI) for non-invasive internal inspections.

Embedded systems are designed to do some specific task, rather than be a generalpurpose computer for multiple tasks. Some also have real-time performance 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.

The program instructions written for embedded systems are referred to as firmware, and are stored in read-only memory or Flash memory chips.

CHAPTER 3 - MICROCONTROLLERS BASICS

3.1 MEMORY UNIT

Memory is part of the microcontroller whose function is to store data. For a certain input we get the contents of a certain addressed memory location and that's all.

Two new concepts are brought to us: addressing and memory location. Memory consists of all memory locations, and addressing is nothing but selecting one of them. This means that we need to select the desired memory location on one hand, and on the other hand we need to wait for the contents of that location. Besides reading from a memory location, memory must also provide for writing onto it. This is done by supplying an additional line called control line. We will designate this line as R/W (read/write).Control line is used in the following way: if r/w=1, reading is done, and if opposite is true then writing is done on the memory location. Memory is the first element, and we need a few operation of our microcontroller.

Fig 3.1: Simplified model of a memory unit

The amount of memory contained within a microcontroller varies between different microcontrollers. Some may not even have any integrated memory (e.g. Hitachi 6503, now discontinued). However, most modern microcontrollers will have integrated memory. The memory will be divided up into ROM and RAM, with typically more ROM than RAM. Typically, the amount of ROM type memory will vary between around 512 bytes and 4096 bytes, although some 16 bit microcontrollers such as the Hitachi H8/3048 can have as much as128 Kbytes of ROM type memory.ROM type memory, as has already been mentioned, is used to store the program code. ROM memory can be ROM (as in One Time Programmable memory), EPROM, or EEPROM.

The amount of RAM memory is usually somewhat smaller, typically ranging between 25 bytes to 4 Kbytes. RAM is used for data storage and stack management tasks. It is also used for register stacks.

3.2 CENTRAL PROCESSING UNIT Lets add 3 more memory locations to a specific block that will have a built in capability to multiply, divide, subtract, and move its contents from one memory location onto another. The part we just added in is called "central processing unit" (CPU). Its memory locations are called registers.

Fig 3.2: Simplified central processing unit with three registers

Registers are therefore memory locations whose role is to help with performing various mathematical operations or any other operations with data wherever data can be found. Look at the current situation. We have two independent entities (memory and CPU) which are interconnected, and thus any exchange of data is hindered, as well as its functionality. If, for example, we wish to add the contents of two memory locations and return the result again back to memory, we would need a connection between memory and CPU. Simply stated, we must have some "way" through which data goes from one block to another.

3.3 BUS

That "way" is called "bus". Physically, it represents a group of 8, 16, or more wires. There are two types of buses: address and data bus. The first one consists of as many lines as the amount of memory we wish to address and the other one is as wide as data, in our case 8 bits or the connection line. First one serves to transmit address from CPU memory, and the second to connect all blocks inside the microcontroller.

Fig 3.3: Showing connection between memory and central unit using buses

As far as functionality, the situation has improved, but a new problem has also appeared: we have a unit that's capable of working by itself, but which does not have any contact with the outside world, or with us! In order to remove this deficiency, let's add a block which contains several memory locations whose one end is connected to the data bus, and the other has connection with the output lines on the microcontroller which can be seen as pins on the electronic component.

3.4 INPUT/OUTPUT UNIT

Those locations we've just added are called "ports". There are several types of ports: input, output or bidirectional ports. When working with ports, first of all it is necessary to choose which port we need to work with, and then to send data to, or take it from the port.

Fig 3.4: Simplified input-output unit communicating with external world

When working with it the port acts like a memory location. Something is simply being written into or read from it, and it could be noticed on the pins of the microcontroller.

3.5 SERIAL COMMUNICATION

As we have separate lines for receiving and sending, it is possible to receive and send data (info.) at the same time, so called full-duplex mode. Block which enables this way of communication is called a serial communication block. Unlike the parallel transmission, data

moves here bit by bit, or in a series of bits what defines the term serial communication comes from. After the reception of data we need to read it from the receiving location and store it in memory as opposed to sending where the process is reversed. Data goes from memory through the bus to the sending location, and then to the receiving unit according to the protocol.

3.6 TIMER UNIT

Since we have the serial communication explained, we can receive, send and process data However, in order to utilize it in industry we need a few additionally blocks. One of those is the timer block which is significant to us because it can give us information about time, duration, protocol etc. The basic unit of the timer is a free-run counter which is in fact a register whose numeric value increments by one in even intervals, so that by taking its value during periods T1and T2 and on the basis of their difference we can determine how much time has elapsed. 3.7 WATCHDOG TIMER

One more thing is requiring our attention is a flawless functioning of the microcontroller during its run-time. Suppose that as a result of some interference (which often does occur in industry) our microcontroller stops executing the program, or worse, it starts working incorrectly.

Fig 3.5: Watchdog

Of course, when this happens with a computer, we simply reset it and it will keep working. However, there is no reset button we can push on the microcontroller and thus solve our problem. To overcome this obstacle, we need to introduce one more block called

watchdog. This block is in fact another free-run counter where our program needs to write a zero in every time it executes correctly. In case that program gets "stuck", zero will not be written in, and counter alone will reset the microcontroller upon achieving its maximum value. This will result in executing the program again, and correctly this time around. That is an important element of every program to be reliable without man's supervision

3.8 ANALOG TO DIGITAL CONVERTER

As the peripheral signals usually are substantially different from the ones that microcontroller can understand (zero and one), they have to be converted into a pattern which can be comprehended by a microcontroller. This task is performed by a block for analog to digital conversion or by an ADC. This block is responsible for converting information about some analog value to a binary number and for follow it through to a CPU block so that CPU block can further process it.

INPUT

Fig 3.6: Block for converting an analog input to digital output

Finally, the microcontroller is now completed, and all we need to do now is to assemble it into an electronic component where it will access inner blocks through the outside pins. The picture below shows what a microcontroller looks like inside.

Fig 3.7: Physical configuration of the interior of a microcontroller

Thin lines which lead from the centre towards the sides of the microcontroller represent wires connecting inner blocks with the pins on the housing of the microcontroller so called bonding lines. Chart on the following page represents the centre section of a microcontroller.

input output Reference

Fig 3.8: Microcontroller outline with basic elements and internal connections

CHAPTER 4 - TYPES OF MICROCONTROLLERS


The predominant family of microcontrollers are 8-bit types since this word size has proved popular for the vast majority of tasks the devices have been required to perform. The microcontroller family would have a common instruction subset but family members differ in the amount, and type, of memory, timer facility, port options, etc. possessed, thus producing cost-effective devices suitable for particular manufacturing requirements. There are 4 major 8 bit micro controllers. They are Freescale's 6811, Intel's 8051, Zilog's Z8 and PIC 16x from Microchip Technology. Each of these Microcontrollers have a unique set of instruction set and register set; therefore they are not compatible with each other

Motorola Intel Zylog Microchip

6811 8051 Z8 PIC 16X

TABLE 4.1: MAJOR 8 BIT MICROCONTROLLERS

4.1 8051 MICROCONTROLLER FAMILY

The 8051 is the first microcontroller of the MCS-51 family introduced by Intel Corporation at the end of the 1970s. The 8051 family with its many enhanced members enjoys the largest market share, estimated to be about 40%, among the various microcontroller architectures. The architecture of the 8051 family of microcontrollers is referred to as the MCS-51 architecture, or sometimes simply as MCS-51.

The microcontrollers have an 8-bit data bus. They are capable of addressing 64K of program memory and a separate 64K of data memory. The 8051 has 4K of code memory implemented as on-chip Read Only Memory (ROM). The 8051 has 128 bytes of internal Random Access Memory (RAM). It has two timer/counters, a serial port, 4 general purpose

parallel input/output ports, and interrupt control logic with 6 sources of interrupts. Besides internal RAM, the 8051 has various Special Function Registers (SFR), which are the control and data registers for on-chip facilities.

4.2 COMPARISON OF 8051 FAMILY MEMBERS

FEATURES ROM RAM (in bytes) Timers I/O Pins Serial Ports Interrupt Sources

8051 4K 128 2 32 1 6

8052 8K 256 3 32 1 8

8031 0K 128 2 32 1 6

TABLE 4.2: COMPARISON OF 8051 FAMILY MEMBERS

4.3 RISC V/S CISC

Complex instruction set computer (CISC) is a computer instruction set architecture (ISA) in which each instruction can execute several low-level operations, such as a load from memory, an arithmetic operation, and a memory store, all in a single instruction. The term was retroactively coined in contrast to reduced instruction set computer (RISC).

The acronym RISC, for reduced instruction set computer, represents a CPU design strategy emphasizing the insight that simplified instructions that "do less" may still provide for higher performance if this simplicity can be utilized to make instructions execute very quickly.

For any given level of general performance, a RISC chip will typically have far fewer transistors dedicated to the core logic which originally allowed designers to increase the size of the register set and increase internal parallelism.

Other features, which are typically found in RISC architectures, are: Uniform instruction format, using a single word with the opcode in the same bit positions in every instruction, demanding less decoding; Identical general purpose registers, allowing any register to be used in any context, simplifying compiler design (although normally there are separate floating point registers); Simple addressing modes. Complex addressing performed via sequences of arithmetic and/or load-store operations;

Few data types in hardware, some CISCs have byte string instructions, or support complex numbers; this is so far unlikely to be found on a RISC. Exceptions abound, of course, within both CISC and RISC.

RISC designs are also more likely to feature a Harvard memory model, where the instruction stream and the data stream are conceptually separated; this means that modifying the memory where code is held might not have any effect on the instructions executed by the processor (because the CPU has a separate instruction and data cache), at least until a special synchronization instruction is issued. On the upside, this allows both caches to be accessed simultaneously, which can often improve performance.

CHAPTER 5 - ARCHITECTURE AND PIN CONFIGURATION OF 8051


5.1 PIN CONFIGURATION

Fig 5.1: Pin Configuration of 8051

The various pins of 8051 microcontroller are: VCC (Pin 40) - Provides voltage to the chip. +5V GND (Pin 20) Ground

XTAL1 (Pin 19) and XTAL2 (Pin 18) - Crystal Oscillator connected to pins 18, 19. RST (Pin 9) RESET pin, it is active high. RXD (Pin 10) - It receives data in serial communication. TXD (Pin 11) - It transmits data in serial communication. INT0 (Pin 12) - External interrupt for timer 0. INT1 (Pin 13) - External interrupt for timer1 T0 (Pin 14) - Timer0. T1 (Pin 15) - Timer1. RD (Pin 16) - To read into external memory. WR (Pin 17) - To write into external memory. External Access, EA (Pin 31) o o Connected to VCC for on chip ROM. Connected to Ground for external ROM containing the code Input Pin.

Program Store Enable, PSEN (Pin 29) - Output Pin, is used for storing programming code into the external memory.

Address Latch Enable: ALE (Pin 30) - Output Pin, Active high, is used to access the address locations from external memory.

I/O Port Pins and their Functions: Four ports P0,P1,P2,P3 with 8 pins each, making a total of 32 input/output pins. PORT 0

Pins 32-39. Can be used as both Input or Output. External pull up resistors of 10K need to be connected. Dual role: 8051 multiplexes address and data through port 0 to save pins AD0-AD7. ALE is used to de multiplex data and address bus.

PORT 1

Pins 1 through 8. Both input and output. No dual function. Internal pull up registers. On RESET configured as output.

PORT 2 Pins 21 through 28. No external pull up resistor required. Both input or output. Dual Function: Along with Port 0 used to provide the 16-Bit address for external memory. It provides higher address A8-A16. PORT 3 Pins 10 through 17. No external pull up resistors required

5.2 8051 MICROCONTROLLER ARCHITECTURE

The Intel 8051 is an 8-bit microcontroller which means that most available operations are limited to 8 bits.

Some of the features that have made the 8051 popular are: 8-bit data bus 16-bit address bus 32 general purpose registers each of 8 bits 16 bit timers (usually 2, but may have more, or less). 3 internal and 2 external interrupts. Bit as well as byte addressable RAM area of 16 bytes.

Four 8-bit ports, (short models have two 8-bit ports). 16-bit program counter and data pointer

Figure 5.2: Architecture of 8051

The Accumulator The Accumulator, as its name suggests, is used as a general register to accumulate the results of a large number of instructions. It can hold an 8-bit (1-byte) value and is the most versatile register the 8051 has due to the shear number of instructions that make use of the accumulator .More than half of the 8051s 255 instructions manipulate or use the accumulator in some way.

The "R" registers The "R" registers are a set of eight registers that are named R0, R1, etc. up to and including R7.These registers are used as auxiliary registers in many operations.

The "B" Register The "B" register is very similar to the Accumulator in the sense that it may hold an 8-bit (1-byte) value. The "B" register is only used by two 8051 instructions: MUL AB and DIV AB. Thus, if you want to quickly and easily multiply or divide A by another number, you may store the other number in "B" and make use of these two instructions. Aside from the MUL and DIV instructions, the "B" register is often used as yet another temporary storage register much like a ninth "R" register.

The Data Pointer (DPTR) The Data Pointer (DPTR) is the 8051s only user-accessible 16-bit (2-byte) register. The Accumulator, "R" registers, and "B" register are all 1-byte values. DPTR, as the name suggests, is used to point to data. It is used by a number of commands which allow the 8051 to access external memory. When the 8051 accesses external memory it will access external memory at the address indicated by DPTR.

The Program Counter (PC) The Program Counter (PC) is a 2-byte address which tells the 8051 where the next instruction to execute is found in memory. When the 8051 is initialized PC always starts at 0000h and is incremented each time an instruction is executed. It is important to note that PC isnt always incremented by one. Since some instructions require 2 or 3 bytes the PC will be incremented by2 or 3 in these cases. The Program Counter is special in that there is no way to directly modify its value.

The Stack Pointer (SP) The Stack Pointer, like all registers except DPTR and PC, may hold an 8-bit (1-byte) value. The Stack Pointer is used to indicate where the next value to be removed from the stack should be taken from. When you push a value onto the stack, the 8051 first increments the value of SP and then stores the value at the resulting memory location. When you pop a value off the stack, the 8051 returns the value from the memory location indicated by SP, and then decrements the value of SP.

This order of operation is important. When the 8051 is initialized SP, will be initialized to 07h.If you immediately push a value onto the stack, the value will be stored in Internal RAM address 08h. This makes sense taking into account what was mentioned two paragraphs above: First the 8051 will increment the value of SP (from 07h to 08h) and then will store the pushed value at that memory address (08h).

5.3 MEMORY TYPES IN 8051 The 8051 has three very general types of memory. The memory types are illustrated in the following graphic. They are: On-Chip Memory, External Code Memory, and External RAM.

On-Chip Memory It refers to any memory (Code, RAM, or other) that physically exists on the microcontroller itself. On-chip memory is really one of two types: Internal RAM and Special Function Register (SFR) memory. The Internal Data Memory space, as shown in figure, is divided into three sections. They are referred to as the Lower 128, the Upper 128, and the SFR. In fact there are 384 physical bytes of memory space, though the Upper 128 and SFRs share the same addresses from location 80H to FFH. Appropriate instructions, using direct or indirect addressing modes, will access each memory block accordingly.

External Code Memory It is code (or program) memory that resides off-chip. This is often in the form of an external EPROM.

Code memory is the memory that holds the actual 8051 program that is to be run. This memory is limited to 64K and comes in many shapes and sizes: Code memory may be found on-chip, either burned into the microcontroller as ROM or EPROM. Code may also be stored completely off-chip in an external ROM or, more commonly, an external EPROM. Flash RAM is also another popular method of storing a program. Various combinations of these memory types may also be used--

that is to say, it is possible to have 4K of code memory on-chip and 64k of code memory off-chip in an EPROM. When the program is stored on-chip the 64K maximum is often reduced to 4k, 8k, or 16k. This varies depending on the version of the chip that is being used. However, code memory is most commonly implemented as off-chip EPROM. This is especially true in low-cost development systems and in systems developed by students.

External RAM This is often in the form of standard static RAM or flash RAM. As the name suggests, External RAM is any random access memory which is found off-chip. Since the memory is off-chip it is not as flexible in terms of accessing, and is also slower. For example, to increment an Internal RAM location by 1 requires only 1 instruction and 1 instruction cycle. To increment a 1-byte value stored in External RAM requires 4 instructions and 7 instruction cycles. In this case, external memory is 7 times slower! What External RAM loses in speed and flexibility it gains in quantity. While Internal RAM is limited to 128 bytes (256 bytes with an 8052), the 8051 supports External RAM up to 64K.

5.4 RAM ARCHITECTURE

The 8051 has a bank of 128 bytes of Internal RAM. This Internal RAM is found onchip on the 8051 so it is the fastest RAM available, and it is also the most flexible in terms of reading, writing, and modifying its contents. Internal RAM is volatile, so when the 8051 is reset, this memory is cleared. The 128 bytes of internal ram is subdivided as shown on the memory map. The first 8 bytes (00h - 07h) are "register bank 0". These alternative register banks are located in internal RAM in addresses 08h through 1Fh.Bit memory actually resides in internal RAM, from addresses 20h through 2Fh. The 80 bytes remaining of Internal RAM, from addresses 30h through 7Fh, may be used by user variables that need to be accessed

frequently or at high-speed. This area is also utilized by the microcontroller as a storage area for the operating stack.

Fig 5.3: RAM allocation in 8051

Register Banks The 8051 uses 8 "R" registers which are used in many of its instructions. These "R" registers are numbered from 0 through 7 (R0, R1, R2, R3, R4, R5, R6, and R7).These registers are generally used to assist in manipulating values and moving data from one memory location to another. The concept of register banks adds a great level of flexibility to the 8051.

5.5 SPECIAL FUNCTION REGISTER (SFR) MEMORY

Special Function Registers (SFRs) are areas of memory that control specific functionality of the 8051 processor. The Special Function Register (SFR) is the upper area of

addressable memory, from address0x80 to 0xFF. This area of memory cannot be used for data or program storage, but is instead a series of memory-mapped ports and registers. Also, different status registers are mapped into the SFR, for use in checking the status of the 8051, and changing some operational parameters of the 8051.

Fig 5.4: SFRs of 8051 For example, four SFRs permit access to the 8051s 32 input/output lines. Another SFR allows a program to read or write to the 8051s serial port .SFR is a part of Internal Memory. This is not the case. When using this method of memory access (its called direct address), any instruction that has an address of 00h through 7Fh refers to an Internal RAM memory address; any instruction with an address of 80h through FFh refers to an SFR control register.

Some of the SFRs are explained below:

DPL/DPH (Data Pointer Low/High, Addresses 82h/83h) The SFRs DPL and DPH work together to represent a 16-bit value called the Data Pointer. The data pointer is used in operations regarding external RAM and some instructions involving code memory. Since it is an unsigned two-byte integer value, it can represent values from 0000h to FFFFh (0 through 65,535 decimal).

Fig 5.5: DPL/DPH (Data Pointer Low/High, Addresses 82h/83h)

PCON (Power Control, Addresses 87h) The Power Control SFR is used to control the 8051's power control modes. Certain operation modes of the 8051 allow the 8051 to go into a type of "sleep" mode which requires much less power. These modes of operation are controlled through PCON. Additionally, one of the bits in PCON is used to double the effective baud rate of the 8051's serial port.

Fig 5.6: PCON (Power Control, Addresses 87h)

TCON (Timer Control, Addresses 88h) The Timer Control SFR is used to configure and modify the way in which the 8051's two timers operate. This SFR controls whether each of the two timers is running or stopped and contains a flag to indicate that each timer has overflowed. Additionally, some non-timer related bits are located in the TCON SFR. These bits are used to configure the way in which the external interrupts are activated and also contain the external interrupt flags which are set when an external interrupt has occurred

Fig 5.7: TCON (Timer Control, Addresses 88h)

SCON (Serial Control, Addresses 98h) The Serial Control SFR is used to configure the behaviour of the 8051's onboard serial port. This SFR controls the baud rate of the serial port, whether the serial port is activated to receive data, and also contains flags that are set when a byte is successfully sent or received.

Fig 5.8: SCON (Serial Control, Addresses 98h)

TMOD (Timer Mode, Addresses 89h) The Timer Mode SFR is used to configure the mode of operation of each of the two timers. Using this SFR your program may configure each timer to be a 16-bit

timer, an 8-bit auto reload timer, a 13-bit timer, or two separate timers. Additionally, you may configure the timers to only count when an external pin is activated or to count "events" that are indicated on an external pin.

Fig 5.9: TMOD (Timer Mode, Addresses 89h)

TL0/TH0 (Timer 0 Low/High, Addresses 8Ah/8Ch) These two SFRs, taken together, represent timer 0. Their exact behaviour depends on how the timer is configured in the TMOD SFR; however, these timers always count up. What is configurable is how and when they increment in value.

TL1/TH1 (Timer 1 Low/High, Addresses 8Bh/8Dh) These two SFRs, taken together, represent timer 1. Their exact behaviour depends on how the timer is configured in the TMOD SFR; however, these timers always count up. What is configurable is how and when they increment in value.

TABLE 5.1: TIMER MODES

IE (Interrupt Enable, Addresses A8h) The Interrupt Enable SFR is used to enable and disable specific interrupts. The low 7 bits of the SFR are used to enable/disable the specific interrupts, where as the highest bit is used to enable or disable ALL interrupts. Thus, if the high bit of IE is 0 all interrupts are disabled regardless of whether an individual interrupt is enabled by setting a lower bit.

Fig 5.11: IE (Interrupt Enable, Addresses A8h)

IP (Interrupt Priority, Addresses B8h, Bit-Addressable) The Interrupt Priority SFR is used to specify the relative priority of each interrupt. On the 8051, an interrupt may either be of low (0) priority or high (1) priority. An interrupt may only interrupt interrupts of lower priority. For example, if we configure the 8051 so that all interrupts are of low priority except the serial interrupt, the serial interrupt will always be able to interrupt the system, even if another interrupt is currently executing. However, if a serial interrupt is executing no other interrupt will be able to interrupt the serial interrupt routine since the serial interrupt routine has the highest priority.

Fig 5.12: IP (Interrupt Priority, Addresses B8h, Bit-Addressable)

PSW (Program Status Word, Addresses D0h, Bit-Addressable) The Program Status Word is used to store a number of important bits that are set and cleared by8051 instructions. The PSW SFR contains the carry flag, the auxiliary carry flag, the overflow flag, and the parity flag. Additionally, the PSW register contains the register bank select flags which are used to select which of the "R" register banks are currently selected.

Fig 5.13: PSW (Program Status Word, Addresses D0h, Bit-Addressable)

SBUF (Serial Control, Addresses 99h) The Serial Buffer SFR is used to send and receive data via the on-board serial port. Any value written to SBUF will be sent out the serial port's TXD pin. Likewise, any value which the 8051receives via the serial port's RXD pin will be delivered to the user program via SBUF. In other words, SBUF serves as the output port when written to and as an input port when read from.

CHAPTER 6 - PERIPHERALS AND THEIR INTERFACING WITH 8051

6.1 LED Interfacing

LEDs are by far the most widely used means of taking output. They find huge application as indicators during experimentations to check the validity of results at different stages. They are very cheap and easily available in a variety of shape, size and colors. The principle of operation of LEDs is simple. The commonly available LEDs have a drop voltage of 1.7 V and need 10 mA to glow at full intensity. The following circuit describes how to glow a led.

Fig 6.1: Circuit for an LED

The value of resistance R can be calculated using the equation, R= (V-1.7)/10 mA. Since most of the controllers work on 5V, so substituting V= 5V, the value of resistance comes out to be 330 ohm. The resistance 220 ohm, 470 ohm is commonly used substitute in case 330 ohm is not available.

LEDs are connected to the port P0. LEDs need approximately 10mA current to flow through them in order to glow at maximum intensity. However the output of the controller is not sufficient enough to drive the LEDs, so if the positive leg of the LED is connected to the

pin and the negative to ground as shown in the figure, the LED will not glow at full illumination.

Fig 6.2: Interfacing of a LED with 8051

To overcome this problem LEDs are connected in the reverse order and they run on negative logic i.e., whenever 1 is given on any pin of the port, the LED will switch off and when logic 0 is provided the LED will glow at full intensity.

As soon as we provide supply to the controller, the LEDs start blinking i.e., they become on for a certain time duration and then become off for the same time duration. This delay is provided by calling the delay function. The values inside the delay function have been set to provide a delay in multiples of millisecond (delay (100) will provide a delay of 100 millisecond).

6.2 4X4 Matrix Keypad Interfacing

A 4x4 matrix keypad requires eight Input/output ports for interfacing. Rows are connected to Peripheral Input/output (PIO) pins configured as output. Columns are connected

to PIO pins configured as input with interrupts. In this configuration, four pull-up resistors must be added in order to apply a high level on the corresponding input pins. The corresponding hexadecimal value of the pressed key is sent on four LEDs.

Fig 6.3: Interfacing of Keypad Matrix with 8051

The rows are connected to an output port and the columns are connected to an input port. If no key has been pressed, reading the input port will yield 1s for all columns since they are all connected to high (Vcc) If all the rows are grounded and a key is pressed, one of the columns will have 0 since the key pressed provides the path to ground. It is the function of the microcontroller to scan the keyboard continuously to detect and identify the key pressed. How it is done is explained next.

To detect a pressed key, the microcontroller grounds all rows by providing 0 to the output latch, and then it reads the columns. If the data read from the columns is D3-D0=1111, no key has been pressed and the process continues until a key press is detected. However, if one of the column bits has a zero, this means that a key press has occurred. For example, if

D3-D0=1101, this means that a key in the D1 column has been pressed. After a key press is detected, the microcontroller will go through the process of identifying the key. Starting with the top row, the microcontroller grounds it by providing a low to row D0 only; then it reads the columns. If the data read is all1s, no key in that row is activated and the process is moved to the next row. It grounds the next row, reads the columns, and checks for any zero. This process continues until the row is identified. After identification of the row in which the key has been pressed, the next task is to find out which column the pressed key belongs to. This should be easy since the microcontroller knows at any time which row and column are being accessed.

6.3 Seven Segment Display Interfacing

The 7 segment display is found in many displays such as microwaves or fancy toaster ovens and occasionally in non cooking devices. It is just 7 LEDs that have been combined into one case to make a convenient device for displaying numbers and some letters. The display is shown on the left. The pin out of the display is on the right.

Figure 6.4: Seven Segment Display

This version is a common anode version. That means that the positive leg of each LED is connected to a common point which is pin 3 in this case. Each LED has a negative leg that is connected to one of the pins of the device. To make it work you need to connect pin 3 to 5 volts. Then to make each segment light up, connect the ground pin for that led to ground. A resistor is required to limit the current. Rather than using a resistor from each LED to ground, you can just use one resistor from Vcc to pin 3 to limit the current. The following table shows how to form the numbers 0 to 9 and the letters A, b, C, d, E, and F

To Display 0 1 2 3 4 5 6 7 8 9 A B C D E F

a (Pin 1) 0 1 0 0 1 0 0 0 0 0 0 1 0 1 0 0

b (Pin 10) c (Pin 8) 0 0 0 0 0 1 1 0 0 0 0 1 1 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 1

d (Pin 6) 0 1 0 0 1 0 0 1 0 1 1 0 0 0 0 1

e (Pin 5) 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 0

f (Pin 2) 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0 0

g (Pin 9) 1 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0

TABLE 6.1: TABLE TO FORM DISPLAY ON SEVEN SEGMENT

6.4 Relay Interfacing

Relays are devices which allow low power circuits to switch a relatively high Current/Voltage ON/OFF. For a relay to operate a suitable pull-in & holding currentshould be passed through its coil. Generally relay coils are designed to operate from a particular voltage often its 5V or 12V.

The function of relay driver circuit is to provide the necessary current (typically 25 to 70ma) to energize the relay coil.

Figure shows the basic relay driver circuit. As you can see an NPN transistor BC547 is being used to control the relay. The transistor is driven into saturation (turned ON) when a LOGIC 1 is written on the PORT PIN thus turning ON the relay. The relay is turned OFF by writing LOGIC 0 on the port pin. A diode (1N4007/1N4148) is connected across the relay coil; this is done so as to protect the transistor from damage due to the BACK EMF generated in the relay's inductive coil when the transistor is turned OFF. When the transistor is switched OFF the energy stored in the inductor is dissipated through the diode & the internal resistance of the relay coil. Normally 1N4148 can be used as it is fast switching diode with a maximum forward current of 300ma. This diode is also called as free-wheeling diode.

Fig 6.5: A Relay Circuit

The LED is used to indicate that the RELAY has been turned ON. The resistor R1 defines the current flowing through the LED thereby defining the LEDs intensity. Resistor R2 is used as a Series Base Resistor to set the base current. When working with 8051 controllers I have noted that its not compulsory to use this resistor as the controller has internal 10k resistor which acts as a base resistor.

Microcontrollers have internal pull up resistors hence when a port pin is HIGH the output current flows through this internal pull up resistor. 8051 microcontrollers have an internal pull up of 10K. Hence the maximum output current will be 5v/10k = 0.5ma. This current is not sufficient to drive the transistor into saturation and turn ON the relay. Hence an external pull up resistor R3 is used.

Fig 6.6: Interfacing of a Relay with 8051

6.5 DC Motor interfacing

A direct current (DC) motor is a fairly simple electric motor that uses electricity and a magnetic field to produce torque, which turns the motor. At its most simple, a DC motor requires two magnets of opposite polarity and an electric coil, which acts as an electromagnet. The repellent and attractive electromagnetic forces of the magnets provide the torque that causes the DC motor to turn.

DC motors are used for a variety of purposes, including electric razors, electric car windows, and remote control cars. The simple design and reliability of a DC motor makes it a

good choice for many different uses, as well as a fascinating way to study the effects of magnetic fields.

H-Bridge An H-bridge is an electronic circuit which enables a voltage to be applied across a load in either direction. These circuits are often used in robotics and other applications to allow DC motors to run forwards and backwards. H-bridges are available as integrated circuits, or can be built from discrete components

The H-Bridge arrangement is generally used to reverse the polarity of the motor, but can also be used to 'brake' the motor, where the motor comes to a sudden stop, as the motor's terminals are shorted, or to let the motor 'free run' to a stop, as the motor is effectively disconnected.

The L293D is a quadruple half H-bridge bidirectional motor driver IC that can drive current of up to 600mA with voltage range of 4.5 to 36 volts. It is suitable to drive small DCGeared motors, bipolar stepper motor etc. circuit.

Fig 6.7: Connections of L293D

6.6 LCD Interfacing

Fig 6.8: 16x2 LCD

A Liquid Crystal Display (LCD) is a thin, flat panel used for electronically displaying information such as text, images, and moving pictures. Its uses include monitors for computers, televisions, instrument panels. Among its major features are its lightweight construction, its portability, and its ability to be produced in much larger screen sizes than are practical for the construction of cathode ray tube (CRT) display technology. Its low electrical power consumption enables it to be used in battery-powered electronic equipment. It is an electronically-modulated optical device made up of any number of pixels filled with liquid crystals and arrayed in front of a light source (backlight or reflector) to produce images in color or monochrome.

Figure 6.9: pin diagram of LCD

TABLE 6.2: PIN DESCRIPTION OF LCD MODULE

The standard requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The user may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit data bus is used, the LCD will require a total of 7 data lines. If an 8-bit data bus is used, the LCD will require a total of 11 data lines.

Fig 6.10: Interfacing of LCD

The three control lines are EN, RS, and RW.

EN: Enable It is used to latch the data present on the data pins. The EN line must be raised/ lowered before/after each instruction sent to the LCD regardless of whether that instruction is read or writes text or instruction. If you don't raise/lower EN, the LCD doesn't know you're talking to it on the other lines.

RS: Register Select RS = 0 p Command Register RS = 1 p Data Register

RW: Read / Write R/W = 0 p Write R/W = 1 p Read

D0 to D7: Bi-directional data/command pins

CHAPTER 7 - OTHER COMPONENTS


7.1 Crystal Oscillator

It is often required to produce a signal whose frequency or pulse rate is very stable and exactly known. This is important in any application where anything to do with time or exact measurement is crucial. A crystal oscillator is an electronic circuit that uses the mechanical resonance of a vibrating crystal of piezoelectric material to create an electrical signal with a very precise frequency. This frequency is commonly used to keep track of time (as in quartz wristwatches), to provide a stable clock signal for digital integrated circuits, and to stabilize frequencies for radio transmitters and receivers. The most common type of piezoelectric resonator used is the quartz crystal, so oscillator circuits designed around them were called "crystal oscillators".

Fig 7.1: Crystal Oscillator

7.2 ZERO PCB PLATE

PCB is a platform where many of the embedded systems to be made. PCB (Printed Circuit Board) is used for the assembly of various components on a single plate. The connections on the PCB should be identical to the circuit diagram, but while the circuit

diagram is arranged to be readable, the PCB layout is arranged to be functional, so there is rarely any visible correlation between the circuit diagram and the layout. PCB layout can be performed manually (using CAD) or in combination with an Auto router. The best results are usually still achieved using at least some manual routing Sometimes abbreviated PCB, a thin plate on which chips and other electronic components are placed. Computers consist of one or more boards, often called cards or adapters

7.3 VOLTAGE REULATOR IC(78XX)

A voltage regulator is an electrical regulator designed to automatically maintain a constant voltage level. It may use an electromechanical mechanism, or passive or active electronic components. Depending on the design, it may be used to regulate one or more AC or DC voltages.

With the exception of passive shunt regulators, all modern electronic voltage regulators operate by comparing the actual output voltage to some internal fixed reference voltage. Any difference is amplified and used to control the regulation element in such a way as to reduce the voltage error. This forms a negative feedback control loop; increasing the open-loop gain tends to increase regulation accuracy but reduces stability.

Fig 7.2 Regulator ICs

The 78xx (also sometimes known as LM78xx) series of devices is a family of selfcontained fixed linear voltage regulator integrated circuits. The 78xx family is a very popular choice for many electronic circuits which require a regulated power supply, due to their ease of use and relative cheapness. When specifying individual ICs within this family, the xx is replaced with a two-digit number, which indicates the output voltage the particular device is designed to provide (for example, the 7805 has a 5 volt output, while the 7809 produces 9 volts).The 78xx line are positive voltage regulators, meaning that they are designed to produce a voltage that is positive relative to a common ground. There is a related line of 79xx devices which are complementary negative voltage regulators. 78xx and 79xx ICs can be used in combination to provide both positive and negative supply voltages in the same circuit, if necessary.

7.4 RESISTORS

A resistor is a two-terminal electronic component that produces a voltage across its terminals that is proportional to the electric current passing through it in accordance with Ohm's law: V = IR Resistors are elements of electrical networks and electronic circuits and are ubiquitous in most electronic equipment. Practical resistors can be made of various compounds and films, as well as resistance wire (wire made of a high-resistivity alloy, such as nickel/chrome).The primary characteristics of a resistor are the resistance, the tolerance, maximum working voltage and the power rating. Other characteristics include temperature coefficient, noise, and inductance.

Resistors can be integrated into hybrid and printed circuits, as well as integrated circuits. Size, and position of leads (or terminals) are relevant to equipment designers; resistors must be physically large enough not to overheat when dissipating their power.

Fig 7.2: Resistors

Function Resistors restrict the flow of electric current, for example a resistor is placed in series with a light-emitting diode (LED) to limit the current passing through the LED.

7.5 CAPACITORS

A capacitor or condenser is a passive electronic component consisting of a pair of conductors separated by a dielectric (insulator). When a potential difference (voltage) exists across the conductors, an electric field is present in the dielectric. This field stores energy and produces a mechanical force between the conductors. The effect is greatest when there is a narrow separation between large areas of conductor; hence capacitor conductors are often called plates.

An ideal capacitor is characterized by a single constant value, capacitance, which is measured in farads. This is the ratio of the electric charge on each conductor to the potential difference between them.

In practice, the dielectric between the plates passes a small amount of leakage current. The conductors and leads introduce an equivalent series resistance and the dielectric has an electric field strength limit resulting in a breakdown voltage.

Fig 7.3: Capacitor

Capacitors are widely used in electronic circuits to block the flow of direct current while allowing alternating current to pass, to filter out interference, to smooth the output of power supplies, and for many other purposes. They are used in resonant circuits in radio frequency equipment to select particular frequencies from a signal with many frequencies.

CHAPTER 8 - PROGRAMMING AND RELATED SOFTWARE


8.1 Keil Microvision

Keil development tools for the 8051 Microcontroller Architecture support every level of software developer from the professional applications engineer to the student just learning about embedded software development.

The industry-standard Keil C Compilers, Macro Assemblers, Debuggers, Real-time Kernels, Single-board Computers, and Emulators support all 8051 derivatives and help you get your projects completed on schedule.

Fig 8.1: The Keil uVision Software

The Keil 8051 Development Tools are designed to solve the complex problems facing embedded software developers.

When starting a new project, simply select the microcontroller we use from the Device Database and the Vision IDE sets all compiler, assembler, linker, and memory options for you.

Numerous example programs are included to help us get started with the most popular embedded 8051 devices. The Keil Vision Debugger accurately simulates on-chip peripherals (IC, CAN, UART, SPI, Interrupts, I/O Ports, A/D Converter, D/A Converter, and PWM Modules) of our 8051 device. Simulation helps us understand hardware configurations and avoids time wasted on setup problems. Additionally, with simulation, we can write and test applications before target hardware is available.

CHAPTER 9 PROJECT DESCRIPTION

9.1 DTMF CONTROLLED ROBOT

Although the appearance and the capabilities of robots vary vastly, all robots share the feature of a mechanical, movable structure under some form of control. The control of robot involves three distinct phases: perception, processing and action. Generally, the preceptors are sensors mounted on the robot, processing is done by the on-board microcontroller or processor, and the task is performed using motors or with some other actuators.

In this project the robot is controlled by a mobile phone that makes a call to the mobile phone attached to the robot. In the course of the call, if any button is pressed, tone corresponding to the button pressed is heard at the other end of the call. This tone is called Dual Tone Multi Frequency tone (DTMF). The robot receives this DTMF tone with the help of a phone stacked on the robot. The received tone is processed by the 8051 microcontroller with the help of DTMF decoder MT8870. The decoder decodes the DTMF tone in to its equivalent binary digit and this binary number is send to the microcontroller. The microcontroller is pre programmed to take a decision for any give input and send the output decisions to the motor drivers in order to drive the motors for forward or backward motion or a turn. The mobile that makes the call to the mobile phone stacked in the robot acts as a remote. So this simple robotic project does not require the construction of receiver and transmitter units.

Dual-tone multi-frequency signalling (DTMF) is used for telecommunication signalling over analog telephone lines in the voice-frequency band between telephone handsets and other communications devices and the switching centre. The version of DTMF that is used in push-button telephones for tone dialling is known as touch tone. DTMF assigns a specific frequency (consisting of two separate tones) to each key so that it can be easily identified by the electronic circuit.

Conventionally, Wireless-controlled robots use RF circuits, which have the drawbacks of limited working range, limited frequency range and the limited control. Use of a mobile phone for robotic control can overcome these limitations. It provides the advantage of robust control, working range as large as the coverage area of the service provider with no interference with other controllers.

9.2 PROJECT OVERVIEW

In this project the robot, is controlled by a mobile phone that makes a call to the mobile phone attached to the robot. In the course of the call, if any button is pressed control corresponding to the button pressed is heard at the other end of the call. This tone is called dual tone multi frequency tome (DTMF) robot receives this DTMF tone with the help of phone stacked in the robot.

The received tone is processed by the 8051 microcontroller with the help of DTMF decoder MT8870 the decoder decodes the DTMF tone in to its equivalent binary digit and this binary number is send to the microcontroller, the microcontroller is pre programmed to take a decision for any give input and outputs its decision to motor drivers in order to drive the motors for forward or backward motion or a turn. The mobile that makes a call to the mobile phone stacked in the robot acts as a remote. So this simple robotic project does not require the construction of receiver and transmitter units. DTMF signalling is used for telephone signalling over the line in the voice _ frequency band to the call switching centre. The version of DTMF used for telephone dialling is known as touch _tone.

TABLE 9.1: DTMF FREQUENCIES

DTMF assigns a specific frequency (consisting of two separate tones) to each key s that it can easily be identified by the electronic circuit. The signal generated by the DTMF encoder is the direct algebraic submission, in real time of the amplitudes of two sine (cosine) waves of different frequencies, i.e., pressing _5_ will send a tone made by adding 1336 Hz and 770 Hz to the other end of the mobile. The tones and assignments in a DTMF system shown below

Input Device

Microcon troller

M o t o r D r i v e r

Left Motor

Right Motor

Fig. 9.1: Project Block Diagram

9.3 PROJECT METHODOLOGY

Figure shows the block diagram and circuit diagram of the microcontroller- based robot. The important components of this robot are DTMF decoder, Microcontroller and motor driver.

An MT8870 series dtmf decoder is used here. All types of the mt8870 series use digital counting techniques to detect and decode all the sixteen DTMF tone pairs in to a

four bit code output. The built -in dila tone rejection circuit eliminated the need for prefiltering. When the input signal given at pin2 (IN-) single ended input configuration is recognized to be effective, the correct four bit decode signal of the DTMF tone is transferred to Q1 (pin11) through Q4(pin14) outputs.

9.4 CIRCUIT DESCRIPTION

Components 8052 microcontroller 1 MT8870 DTMF Decoder 1 L293d motor driver ic 1 1n4007 diode 1 100k resistances 2 10 k resistances 5 22k resistances - 3 330 k resistances 3 220 k resistance 5 33pf capacitor - 2 0.47mf capacitors 1 0.1mf capacitors 1 10microf capacitor - 1 22pf capacitors 4 3.57mhz crystal 1 12mhz crystal 1 2 geared motors (6v, 50 rpm) 2 wheels 2 cell phone - 2 hands free - 1

Software used Keil compiler

Equipments Used Soldering iron Soldering wire Nipper Cutter etc.

9.5 CIRCUIT DIAGRAM

Fig 9.2: Circuit Diagram

9.6 PROCEDURE OF BUILDING THE WIRELESS ROBOT 1. Circuit Diagram of the project is designed and finalized (given above). 2. All the components and software platform (also mentioned above) are selected. 3. All the hardware components are soldered on the general circuit board.

4. The program/code of the project is written in C language and compiled using keil compiler. 5. The hex code of the program is burnt into the flash code memory of the microcontroller. 6. Testing is done at various levels to finalize the project.

9.7 PROGRAM CODE

#include <REGX51.H> sfr ldata=0x90; sbit rs=P2^7; sbit rw=P2^6; sbit en=P2^5; sbit pr00=P3^0; sbit pr01=P3^1; sbit pl00=P3^2; sbit pl01=P3^3; sbit men=P2^0; sbit D0=P2^1; sbit D1=P2^2; sbit D2=P2^3; sbit D3=P2^4; void delay(unsigned int a) { unsigned int i,j; for(i=0;i<=1275;i++) { for(j=0;j<=a;j++); } } void main()

{ while(1) { P1=0xaa;

if( D3==0 && D0==1 && D1==0 && D2==0 && men==1) { pr00=1; pr01=0; pl00=1; pl01=0; } else if(D3==0 &&D0==0 && D1==1 && D2==0 && men==1) { pr00=0; pr01=1;

pl00=0; pl01=1; } else if(men==1 && D0==0 && D1==0 && D2==1 && D3==0) { pr00=0; pr01=1; pl00=1; pl01=0; } else if(men==1 && D0==0 && D1==0 && D2==0 && D3==1) { pr00=1; pr01=0;

pl00=0; pl01=1; }

else { pr00=0; pr01=0; pl00=0; pl01=0; }}}

9.8 WORKING

In order to control the robot, you have to make a call to the cell phone attached to the robot from any phone. Now the phone is picked by the phone on the robot through auto answer mode(which is in the phone, just enable it). Now when you press When you press When you press When you press the robot will move forward

the robot will move left the robot will move backwards the robot will move right

When you press any other key, the robot will stop.

9.9 PROJECT SNAPSHOTS

CHAPTER 10 - REFRENCES

10.1 BOOKS
The 8051 Microcontroller and Embedded Systems- By Muhammad Ali Mazidi, Janice Gillispie Mazidi, Rolin D. McKinlay. The 8051 Microcontroller by K.J Ayala

10.2 WEBSITES

www.wikipedia.com www.instructables.com

You might also like