65
TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM 1. INTRODUCTION TO EMBEDDED SYSTEM 1.1 Introduction Microcontroller are widely used in Embedded System products. An Embedded product uses the microprocessor(or microcontroller) to do one task & one task only. A printer is an example of Embedded system since the processor inside it perform one task only namely getting the data and printing it. Although microcontroller are preferred choice for many Embedded systems, There are times that a microcontroller is inadequate for the task. For this reason in recent years many manufactures of general purpose microprocessors such as INTEL, Motorolla, AMD & Cyrix have targeted their microprocessors for the high end of Embedded market.One of the most critical needs of the embedded system is to decrease power consumptions and space. This can be achieved by integrating more functions into the CPU chips. All the embedded processors have low power consumptions in additions to some forms of I/O,ROM all on a single chip. In higher performance Embedded system the trend is to integrate more & more function on the CPU chip & let the designer decide which feature he/she wants to use. 1.2 Embedded System An Embedded System employs a combination of hardware & software to perform a specific function. Software is used for 1 DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Vinod report es 1

Embed Size (px)

Citation preview

Page 1: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

1. INTRODUCTION TO EMBEDDED SYSTEM

1.1 Introduction

Microcontroller are widely used in Embedded System products. An Embedded product uses

the microprocessor(or microcontroller) to do one task & one task only. A printer is an

example of Embedded system since the processor inside it perform one task only namely

getting the data and printing it. Although microcontroller are preferred choice for many

Embedded systems, There are times that a microcontroller is inadequate for the task. For this

reason in recent years many manufactures of general purpose microprocessors such as

INTEL, Motorolla, AMD & Cyrix have targeted their microprocessors for the high end of

Embedded market.One of the most critical needs of the embedded system is to decrease

power consumptions and space. This can be achieved by integrating more functions into the

CPU chips. All the embedded processors have low power consumptions in additions to some

forms of I/O,ROM all on a single chip. In higher performance Embedded system the trend is

to integrate more & more function on the CPU chip & let the designer decide which feature

he/she wants to use.

1.2 Embedded System

An Embedded System employs a combination of hardware & software to perform a specific

function. Software is used for providing features and flexibility hardware (Processors,

Memory, etc.) is used for performance & sometimes security. An embedded system is a

special purpose system in which the computer is completely encapsulated by the device it

controls. Unlike a general purpose computer, such as a PC, an embedded system performs

predefined task’s usually with very specific tasks design engineers can optimize it reducing

the size and cost of the product. Embedded systems are often mass produced, so the cost

savings may be multiplied by millions of items. The core of any embedded system is formed

by one or several microprocessor or micro controller programmed to perform a small number

of tasks. In contrast to a general purpose computer, which can run any software application,

the user chooses, the software on an embedded system is semi-permanent, so it is often called

firmware.

1DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 2: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

Figure1.1: Example of Embedded System

1.3 Examples ofEmbedded System

a) Automated tiller machines (ATMS).

b) Integrated system in aircraft and missile.

c) Cellular telephones and telephonic switches.

d) Computer network equipment, including routers timeservers and firewalls

e) Computer printers, Copiers.

f) Disk drives (floppy disk drive and hard disk drive)

g) Engine controllers and antilock brake controllers for automobiles.

h) Home automation products like thermostat, air conditioners sprinkles and security

monitoring system.

i) House hold appliances including microwave ovens, washing machines, TV sets DVD

players/recorders.

j) Medical equipment.

k) Measurement equipment such as digital storage oscilloscopes, logic analyzers and

spectrum analyzers.

2DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 3: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

l) Multimedia appliances: internet radio receivers, TV set top boxes.

m) Small hand held computer with P1M5 and other applications.

n) Programmable logic controllers (PLC’s) for industrial automation and monitoring.

o) Stationary video game controllers.

1.4. Difference- Embedded and PC

a) An embedded system have defined process and functionwhereas PC is generic

b) Computer system can be manufactured with general requirement and the manufacturer

does not know what the customer will do, while embedded system is Application

Specific.

c) Numerous embedded system make up the computer

d) Tightly constrained: Embedded system design is tightly constraint. Important factors to

be considered are as cost, size, performance, andpower.

e) Reactiveandreal-time:

Continually reacts to changes in the system’s environment.

Must compute certain results in real-time without delay

1.5. Components of an Embedded Systems

a) Embedded hardware:-It mainly consists of a microcontroller with various peripheral IC’s.

b) Embedded RTO’S:-All intelligent devices that perform complex functions have an

embedded operating system inside.

c) Device drivers :-The software that acts as a glue between the operating system and the

peripheral device is called the device driver

d) Communication stacks:-If the embedded device is capable of communicating to the

external world,it has a communication software stack running on the top of operating

system.

e) Embedded application:-It performs the predefined function of the embedded device.

1.6. Features of an Embedded System

Embedded systems do a very specific task they cannot be programmed to do different things.

3DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 4: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

a) Embedded systems have very limited resources, particularly the memory. Generally, they

do not have secondary storage devices such as the CDROM or the floppy disk.

b) Embedded systems have to work against some deadlines. A specific job has to be

completed within a specific time. In some embedded systems, called real-time systems,

the deadlines are stringent. Missing a dead line may cause a catastrophe – loss of life or

damage to property.

c) Embedded systems are constrained for power, as many embedded systems operate

through a battery; the power consumption has to be very low.

d) Embedded systems need to be highly reliable. Once in a while, pressing ALT-CTRL-

DEL is OK on your desktop, but you cannot afford to reset your embedded system.

e) Some embedded systems have to operate in extreme environmental conditions such as

very high temperatures and humidity.

f) Embedded systems that address the consumer market (for example electronic toys) are

very cost-effective. Even a reduction of Rs.10 is lot of cost saving, because thousands or

millions systems may be sold.

g) Unlike desktop computers in which the hardware platform is dominated by Intel and the

operating system is dominated by Microsoft, there is a wide variety of processors and

operating systems for the embedded systems. So, choosing the right platform is the most

complex task.

1.7. Classification of Embedded Systems

Based on functionality and performance requirements, embedded systems are classified as:

a) Stand-alone Embedded Systems

b) Real-time Embedded Systems

c) Networked Information Appliances

d) Mobile Devices

4DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 5: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

a. Stand-Alone Embedded Systems

As the name implies, stand-alone systems work in stand-alone mode. They take inputs,

process them and produce the desired output. The input can be electrical signals from

transducers or commands from a human being such as the pressing of a button. The output

can be electrical signals to drive another system, an LED display or LCD display for

displaying of information to the users. Embedded systems used in process control,

automobiles, consumer electronic items etc. fall into this category.

b. Real-Time Systems

Embedded systems in which some specific work has to be done in a specific time period are

called real-time systems. For example, consider a system that has to open a valve within 30

milliseconds when the humidity crosses a particular threshold. If the valve is not opened

within 30 milliseconds, a catastrophe may occur. Such systems with strict deadlines are

called hardreal-time systems. In some embedded systems, deadlines are imposed, but not adhering to them once in a

while may not lead to a catastrophe. For example, consider a DVD player. Suppose, you

give a command to the DVD player from a remote control, and there is a delay of a few

milliseconds in executing that command. But, this delay won’t lead to a serious implication.

Such systems are called softreal-timesystems.

c. Networked Information Appliances

Embedded systems that are provided with network interfaces and accessed by networks such

as Local Area Network or the Internet are called networked information appliances. Such

embedded systems are connected to a network, typically a network running TCP/IP

(Transmission Control Protocol/Internet Protocol) protocol suite, such as the Internet or a

company’s Intranet.

These systems have emerged in recent years. These systems run the protocol TCP/IP stack

and get connected through PPP or Ethernet to a network and communicate with other nodes

in the network.

Here are some examples of such systems

5DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 6: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

A networked process control system consists of a number of embedded systems

connected as a local area network. Each embedded system can send real-time data to a

central location from where the entire process control system can be monitored. The

monitoring can be done using a web browser such as the Internet Explorer.

A web camera can be connected to the Internet. The web camera can send pictures in

real-time to any computer connected to the Internet. In such a case, the web camera has

to run the HTTP server software in addition to the TCP/IP protocol stack.

The door lock of your home can be a small embedded system with TCP/IP and HTTP

server software running on it. When your children stand in front of the door lock after

they return from school, the web camera in the door-lock will send an alert to your

desktop over the Internet and then you can open the door-lock through a click of the

mouse.

d. Mobile Devices

Mobile devices such as mobile phones, Personal Digital Assistants (PDAs), smart phones etc.

are a special category of embedded systems. Though the PDAs do many general purpose

tasks, they need to be designed just like the ‘conventional’ embedded systems.

The limitations of the mobile devices – memory constraints, small size, lack of good user

interfaces such as full-fledged keyboard and display etc. are same as those found in the

embedded systems discussed above. Hence, mobile devices are considered as embedded

systems.

However, the PDAs are now capable of supporting general purpose application software such

as word processors, games, etc.

1.8. Advantage

a) They are designed to do a specific task and have real time performance constraints which

must be met. 

b) They allow the system hardware to be simplified so costs are reduced.

6DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 7: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

c) They are usually in the form of small computerized parts in larger devices which serve a

general purpose. 

d) The program instructions for embedded systems run with limited computer hardware

resources, little memory and small or even non-existent keyboard or screen.

7DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 8: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

2. MICROCONTROLLERS

2.1. Introduction

Circumstances that we find ourselves in today in the field of microcontrollers had their

beginnings in the development of technology of integrated circuits. This development has

made it possible to store hundreds of thousands of transistors into one chip. That was a

prerequisite for production of microprocessors, and the first computers were made by adding

external peripherals such as memory, input-output lines, timers and other. Further increasing

of the volume of the package resulted in creation of integrated circuits. These integrated

circuits contained both processor and peripherals. That is how the first chip containing a

microcomputer, or what would later be known as a microcontroller came about.

The first microcontroller 8051 was developed by Intel Corporation in the year 1981. it was

called as a “System on a chip”. Intel refers to it as MCS-51 now.

Figure2.1: Microcontroller IC

2.2. Definition of a Microcontroller

Microcontroller, as the name suggests, are small controllers. They are like single chip

computers that are often embedded into other systems to function as processing/controlling

unit. For example, the remote control you are using probably has microcontrollers inside that

8DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 9: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

do decoding and other controlling functions. They are also used in automobiles,

washingmachines, microwave ovens, toys etc. where automation is needed.

The key features of microcontrollers include:

a) High Integration of Functionality

b) 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.

c) Field Programmability, Flexibility

d) 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.

e) Easy to Use

Assembly language is often used in microcontrollers and since they usually

followRISC architecture, the instruction set is small. The development package

ofmicrocontrollers often includes an assembler, a simulator, a programmer to "burn" the chip

and a demonstration board. Some packages include a high level languagecompiler such as a

C compiler and more sophisticated libraries.

Most microcontrollers will also combine other devices such as:

a) A Timer module to allow the microcontroller to perform tasks for certain time

periods.

b) A serial I/O port to allow data to flow between the microcontroller and other devices such

as a PC or another microcontroller.

c) An ADC to allow the microcontroller to accept analogue input data for processing.

9DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 10: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

Figure2.2: Showing a typical microcontroller device and its different subunits

2.3. 8051 Architecture

2.3.1. About the 8051

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

limited to 8 bits. There are 3 basic "sizes" of the 8051: Short, Standard, and Extended. The

Short and Standard chips are often available in DIP (dual in-line package) form, but the

Extended 8051 models often have a different form factor, and are not "drop-in compatible".

10DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 11: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

2.3.2. Block Diagram

Figure2.3: 8051 architecture

All these things are called 8051 because they can all be programmed using 8051 assembly

language, and they all share certain features (although the different models all have their own

special features).Some of the features that have made the 8051 popular are:

a) 4 KB on chip program memory.

b) 128 bytes on chip data memory (RAM).

c) 4 register banks.

d) 8-bit data bus

e) 16-bit address bus

11DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 12: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

f) 32 general purpose registers each of 8 bits

g) 16 bit timers (usually 2, but may have more, or less).

h) 3 internal and 2 external interrupts.

i) Bit as well as byte addressable RAM area of 16 bytes.

j) Four 8-bit ports, (short models have two 8-bit ports).

k) 16-bit program counter and data pointer.

l) 1 Microsecond instruction cycle with 12 MHz Crystal.

m) 8051 models may also have a number of special, model-specific features, such as UARTs,

ADC, OpAmp, etc.

2.4. Pin out Description

Figure2.4: Pin configuration of microcontroller

The pins of the micro controller are explained below:

12DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 13: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

I/O Ports:Four 8-bit I/O ports.

Most have alternate functions.

Port 0 (pin 32-39)

Dual purpose I/O port.

In min. component design, it is used as a general purpose I/O port. In

Larger designs with external memory, it becomes a multiplexed data bus:

Low byte of address bus, strobe by ALE.

8-bit instruction bus, strobe by PSEN

8-bit data bus, strobe by WR and RD.

Port 1 (pin 1-8)

As an I/O port: Standard bi-directional port for interfacing to external devices as required

for I/O.

Alternate functions: Only on some derivatives.

Port 2 (pin 21-28)

Dual purpose I/O port.

As an I/O port: Standard bi-directional general purpose I/O port.

Alternate functions: High byte of address bus for external program and

Data memory accesses.

Port 3 (pin 10-17)

is an 8-bit bi-directional I/O port with internal pull-ups. It also serves the functions of various

special features of the 80C51.

Table of alternate uses of Port-3 pins:

PINS ALTERNATE USE SFR

13DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 14: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

P3.0 RXD Serial data input SBUF

P3.1 TXD Serial data output SBUF

P3.2 INT0 External Interrupt 0 TCON.1

P3.3 INT1 External Interrupt 1 TCON.3

P3.4 T0 External Timer 0 I/P TMOD

P3.5 T1 External Timer 1 I/P TMOD

P3.6 WR External Memory writes pulse -

P3.7 RD External Memory read pulse -

Reset:It resets total 8051 micro controller.

XTAL1 & XTAL2: To connect the crystal oscillator. For 8051 crystal oscillator of 11.0592

MHZ is connected between these pins.

ALE:Address latch enable which is used to access the address locations from external

memory.

PSEN: Program store enable which is used for storing programming Code into the external

memory.

EA:External Access: 64 KB of ROM is the limit for external memory Supply and Ground

pins: Pin 40 is for +5V and pin 20 is for GND.

14DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 15: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

Reset Circuit and Clock Circuit

Figure2.5: Reset circuit of microcontroller

Crystal Oscillator:

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

Figure2.6: Crystal Oscillator

15DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 16: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

Family Members Of 8051

Table: Family members of 8051

RAM Architecture

Figure2.7: Ram Architecture

The 8051 has a bank of 128 bytes of InternalRAM. This Internal RAM is found on-

chipon 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

16DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 17: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

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.

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.

Bit Memory

The 8051, being a communication oriented microcontroller, gives the user the ability

to access a number of bitvariables. These variables may be either 1 or 0. There are 128 bit

variables available to the user, numbered 00h through 7Fh. The user may make use of these

variables with commands such as SETB and CLR. It is important to note that Bit Memory is

really a part of Internal RAM. In fact, the 128 bit variables occupy the 16 bytes of Internal

RAM from 20h through 2Fh.

Special Function Register (SFR) Memory

Special Function Registers (SFRs) are areas of memory that control specific

functionality of the 8051 processor. For example, four SFRs permit access to the 8051’s 32

input/output lines. Another SFR allows a program to read or write to the 8051’s serial

port .SFR is a part of Internal Memory. This is not the case. When using this method of

memory access (it’s 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.

Registers

The Accumulator

17DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 18: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

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 "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: MULAB and

DIVAB.

The Data Pointer (DPTR)

The Data Pointer (DPTR) is the 8051’s 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.

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.

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

Interrupts

An interrupt is a special feature which allows the 8051 to provide the illusion of

"multitasking," although in reality the 8051 is only doing one thing at a time.

18DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 19: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

Timers

Timers are one of the categories of hardware time delays. Time delays are used to

keep a system into halting System or sleepy mode. We have two timers-timer0,

timer1.Hardware time delays are used to generate exact time delays.

Central Processing Unit

Let 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. 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 data goes from one block to another.

Figure2.8: Simplified central processing unit with three registers

2.5. Typical applications

8051 chips are used in a wide variety of control systems, telecom applications, and robotics

as well as in the automotive industry. By some estimation, 8051 family chips make up over

19DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 20: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

50% of the embedded chip market.The 8051 has been in use in a wide number of devices,

mainly because it is easy to integrate into a project or build a device around. The following

are the main areas of focus:

a) Energy Management:Efficient metering systems help in controlling energy usage in

homes and industrial applications. These metering systems are made capable by

incorporating microcontrollers.

b) Touch screens:A high number of microcontroller providers incorporate touch-sensing

capabilities in their designs. Portable electronics such as cell phones, media players and

gaming devices are examples of microcontroller-based touch screens.

c) Automobiles: The 8051 finds wide acceptance in providing automobile solutions. They

are widely used in hybrid vehicles to manage engine variants. Additionally, functions

such as cruise control and anti-brake system have been made more efficient with the use

of microcontrollers. So the microcontroller 8051 has great advantage in the field of the

automobiles.

d) Medical Devices: Portable medical devices such as blood pressure and glucose monitors

e) use microcontrollers will to display data, thus providing higher reliability in providing

medical results.

20DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 21: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

3. INTERFACING

Transfer of data between microcontrollers and peripherals (memory, I/O devices etc.)

implemented using buses called interfacing.Connecting the computation capabilities of a

microcontroller to external signals or to external world.Creating man-machine interaction.

3.1. Need of Interfacing

a) The basic need is to have some input/output peripherals and man-machine interface.

b) Interactions with a computer or TV are possible using the mouse /keyboard/display

screen.

c) The no. of real world devices and systems like mobile phone and washing m/c need the

keypad and display to enable human-computer interactions.

21DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 22: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

3.2. Interfacing With Led:-

Like a normal diode, an LED consists of a chip of semiconducting material impregnated, or

doped, with impurities to create a p-n junction. As in other diodes, current flows easily from

the p-side, or anode, to the n-side, or cathode, but not in the reverse direction. Charge-carriers

—electrons and holes—flow into the junction from electrodes with different voltages.

Figure3.2: LED Interfacing of 8051 Microcontroller Circuit Diagram

When an electron meets a hole, it falls into a lower energy level, and releases energy in the

form of a photon. The wavelength of the light emitted, and therefore its color, depends on the

band gap energy of the materials forming the p-n junction. In silicon or germanium diodes,

theelectrons and holes recombine by a non-radiatetransition which produces no optical

emission, because these are indirect band gap materials. The materials used for an LED have

a direct band gap with energies corresponding to near-infrared, visible or near-ultraviolet

light. LED development began with infrared and red devices made with gallium arsenide.

Advances in materials science have made possible the production of devices with ever-

shorter wavelengths, producing light in a variety ofcolors.Conventional LEDs are made from

a variety of inorganic semiconductor materials, producing the following colors:

Aluminum gallium arsenide (AlGaAs) — red and infrared

22DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 23: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

Aluminium gallium phosphide (AlGaP) — green

Aluminium gallium indium phosphide (AlGaInP) — high-brightness

orange-red, orange, yellow, and green

Gallium arsenide phosphide (GaAsP) — red, orange-red, orange, and yellow

Gallium phosphide (GaP) — red, yellow and green

Gallium nitride (GaN) — green, pure green (or emerald green), and blue

also white (if it has an AlGaN Quantum Barrier)

/* PROGRAM TO GLOW LED*/

#include<reg51.h>

void delay()

{

int a;

for(a=0;a<=30000;a++);

}

void main()

{

while(1)

{

P2=0x00;

delay();

P2=0xFF;

delay();

23DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 24: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

}

}

LED Interfacing with 8051 Circuit Applications:

a) LEDs are widely used in many applications like in seven segments.

b) They are used in dot matrix displays.

c) They can be used for street lights.

d) They are used as indicators.

e) They can be used in traffic lights.

f) They are used in emergency lights

g) They can used to make electronic designs.

3.3. LCD Interfacing

3.3.1. Pin Configuration

Figure3.3: pin configuration for 16 X 2 LCD

LCD stands for Liquid Crystal Display. The most commonly used LCDs found in the market

today are 1 Line, 2 Line or 4 Line LCDs which have only 1 controller and support at most of

80characters.

8 data pins D7:D0

Bi-directional data/command pins. Alphanumeric characters are sent in ASCII format.

RS:  Register Select

24DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 25: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

RS=0->Command Register is selected

RS = 1 -> Data Register is selected

R/W: Read or Write

0 -> Write,  1 -> Read 

E: Enable (Latch data)

Used to latch the data present on the data pins.A high-to-low edge is needed to latch the data.

VEE : contrast control.

3.3.2. Ddram - Display Data Ram

Display data RAM (DDRAM) stores display data represented in 8-bit character codes. Its

extended capacity is 80 X 8 bits, or 80 characters. The area in display data RAM (DDRAM)

that is not used for display can be used as general data RAM. So whatever you send on the

DDRAM is actually displayed on the LCD.

3.3.3. BF - Busy Flag

Busy Flag is a status indicator flag for LCD. When we send a command or data to the LCD

for processing, this flag is set (i.e. BF =1) and as soon as the instruction is executed

successfully this flag is cleared (BF = 0). This is helpful in producing and exact amount of

delay. For the LCD processing. To read Busy Flag, the condition RS = 0 and R/W = 1 must

be met and The MSB of the LCD data bus (D7) act as busy flag. When BF = 1 means LCD is

busy and will not accept next command or data and BF = 0 means LCD is ready for the next

command or data to process.

3.3.4. Instruction Register (IR) and Data Register (DR)

There are two 8-bit registers controller Instruction and Data register. Instruction register

corresponds to the register where you send commands to LCD e.g. LCD shift command,

LCD clear, LCD address etc. and Data register is used for storing data which is to be

displayed on LCD. When send the enable signal of the LCD is asserted, the data on the pins

25DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 26: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

is latched in to the data register and data is then moved automatically to the DDRAM and

hence is displayed on the LCD.

3.3.5. INTERFACING  LCD TO 8051

Figure3.4: Circuit of Interfacing LCD To 8051

The LCD 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.The three control lines are  EN, RS, and RW. Note

that the EN line must be raised/lowered before/after each instruction sent to the LCD

regardless of whether that instruction is read or write, text or instruction EN is the LCD's way

of knowing that you are talking to it. If you don't raise/lower EN, the LCD doesn't know

you're talking to it on the other lines.

3.3.6. LCD Commands

Commands and Instruction set

Only the instruction register (IR) and the data register (DR) of the LCD can be controlled by

the MCU. Before starting the internal operation of the LCD, control information is

temporarily stored into these registers to allow interfacing with various MCUs, which operate

26DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 27: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

at different speeds, or various peripheral control devices. The internal operation of the LCD is

determined by signals sent from the MCU.

Sending Commands to LCD

To send commands we simply need to select the command register. Everything is same as we

have done in the initialization routine. But we will summarize the common steps and put

them in a single subroutine.

Following are the steps:

a) Move data to LCD port

b) Select command register

c) Select write operation

d) Send enable signal

e) Wait for LCD to process the command

Command Function

0F For switching on LCD, blinking the cursor.

1 Clearing the screen

2 Return home.

4 Decrement cursor

6 Increment cursor

E Display on and also cursor on

80 Force cursor to beginning of the first line

C0 Force cursor to beginning of second line

27DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 28: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

Command Function

38 Use two lines and 5x7 matrix

83 Cursor line 1 position 3

3C Activate second line

0C3 Jump to second line position 3

0C1 Jump to second line position1

Programming LCD to 8051:

Coming to the programming you should follow these steps:

a) STEP1: Initialization of LCD.

b) STEP2: Sending command to LCD.

c) STEP3: Writing the data to LCD.

Initializing LCD:

To initialize LCD to the 8051 the following instruction and commands are to be embed in to

the functions

a) 0x38 is used for 8-bit data initialization.

b) 0xFH for making LCD on and initializing the cursor.

c) 0X6H for incrementing the cursor which will help to display another character in the

LCD

d) 0x1H for clearing the LCD.

Sending Data to the LCD:

28DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 29: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

a) E=1; enable pin should be high

b) RS=1; Register select should be high for writing the data

c) Placing the data on the data registers

d) R/W=0; Read/Write pin should be low for writing the data.

3.4. KEYPAD INTERFACING

3.4.1. Introduction

Keypads are a part of HMI or Human Machine Interface and play really important role in a

small embedded system where human interaction or human input is needed. Matrix keypads

are well known for their simple architecture and ease of interfacing with any microcontroller.

3.4.2. Constructing a Matrix keypad

Construction of a keypad is really simple. As per the outline shown in the figure below we

have four rows and four columns.

Figure3.5: Matrix Keypad

In between each overlapping row and column line there is a key. So keeping this outline we

can construct a keypad using simple SPST Switches as shown below:

29DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 30: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

3.4.3. Scanning a Matrix Keypad

There are many methods depending on how you connect your keypad with your controller,

but the basic logic is same. We make the columns as i/p and we drive the rows making them

o/p, this whole procedure of reading the keyboard is called scanning.

In order to detect which key is pressed from the matrix, we make row lines low one by one

and read the columns. Let’s say we first make Row1 low, and then read the columns. If any

of the key in row1 is pressed will make the corresponding column as low i.e. if second key is

pressed in Row1, then column2 will give low. So we come to know that key 2 of Row1 is

pressed. This is how scanning is done.

So to scan the keypad completely, we need to make rows low one by one and read the

columns. If any of the button is pressed in a row, it will take the corresponding column to a

low state which tells us that a key is pressed in that row. If button 1 of a row is pressed then

Column 1 will become low, if button 2 then column2 and so on.

3.4.4. Interfacing Matrix keypad

Figure3.6: keypad interface

3.5. Seven Segment LEDs

30DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 31: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

Figure3.7: 7 segment display

3.5.1. Introduction

The 7 segment display can also be used for displaying numbers. Each of the segments of the

display is connected to a pin on the 8051. In order to light up a segment on the pin must be

set to 0V. To turn a segment off the corresponding pin must be set to 5V. This is simply done

by setting the pins on the 8051 to '1' or '0'.LED displays are Power-hungry (10mA per LED)

and Pin-hungry (8 pins per 7-seg display). But they are cheaper than LCD display.

7-SEG  Display are available in two types -1. Common anode   &   2.common cathode ,  but

command anode display are most suitable for interfacing with 8051 since 8051 port pins can

sink current better than sourcing it.

31DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 32: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

Seven segment displays are used to indicate numerical information. Seven segments display

can display digits from 0 to 9 and even we can display few characters like A, b, C, H, E, e, F,

etc. These are very popular and have many more applications.

3.5.2. Interfacing 7 Segment Display to 8051 Circuit Principle:

Seven segment displays internally consist of 8 LEDs. In these LEDs, 7 LEDs are used to

indicate the digits 0 to 9 and single LED is used for indicating decimal point. Generally seven

segments are two types, one is common cathode and the other is common anode.

Figure3.8: Interfacing 7 Segment Display to 8051 Circuit Diagram

32DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 33: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

/* PROGRAM TO SWITCH ON SEVEN SEGMENT DISPLAY MOVING FROM LSB TO

MSB */

#include<reg51.h>

void delay()

{

int a;

for(a=0;a<=30000;a++);

}

void main()

{

P2=0x3F;

delay();

P2=0x30;

delay();

P2=0x5B;

delay();

P2=0x1F;

delay();

P2=0x66;

delay();

P2=0x6D;

delay();

P2=0x7C;

33DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 34: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

delay();

P2=0x07;

delay();

P2=0x7F;

delay();

P2=0x3F;

delay();

}

3.5.3. Digit Drive Pattern:

To display the digits on 7 segment, we need to glow different logic combinations of

segments. For example if you want to display the digit 3 on seven segment then you need to

glow the segments a, b, c, d and g. The below table show you the Hex decimal values what

we need to send from PORT2 to Display the digits from 0 to 9.

Digit h g f e D c b a Hex value

0 0 0 1 1 1 1 1 1 0x3f

1 0 0 0 0 0 1 1 0 0x06

2 0 1 0 1 1 0 1 1 0x5b

3 0 1 0 0 1 1 1 1 0x4f

4 0 1 1 0 0 1 1 0 0x66

5 0 1 1 0 1 1 0 1 0x6d

34DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 35: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

Digit h g f e D c b a Hex value

6 0 1 1 1 1 1 0 1 0x7d

7 0 0 0 0 0 1 1 1 0x07

8 0 1 1 1 1 1 1 1 0x7f

9 0 1 1 0 0 1 1 1 0x67

3.5.4. Interfacing 7 Segment Display to 8051 Circuit Applications:

a) Seven segments are widely used in digital clocks to display the time.

b) These are used in electronic meters for displaying the numerical information.

c) Used in Instrument panels

d) Used in digital readout displays.

3.5.5. Limitations of the Circuit:

a) The complexity is increased to display large information.

b) It is not possible to display the symbols on seven segment.

35DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 36: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

4. C PROGRAMMING TECHNIQUES FOR 8051

4.1. WHY USE C?

a) It is a “mid-level”, with “high-level” features (such as support for functions and

modules), and “low-level” features (such as good access to hardware via pointers).

b) It is very efficient.

c) It is popular and well understood.

d) Even desktop developers who have used only Java or C++ can soon understand C syntax.

e) Good, well-proven compilers are available for every embedded processor (8-bit to 32-bit

or more).

4.2. Key Features Of Embedded C-

a) It is easy and less time consuming to write in C than Assembly.

b) C is easier to modify and update.

c) You can use code available in function libraries.

d) C code is portable to other microcontroller with little or no modification.

e) A good understanding of C data types for 8051 can help programmers to create smaller

hex files.

4.3. Simple Way of Programming

#include<reg51.h>

#define variable

Function type function name (variable type variable name)

{

36DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 37: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

- - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - -

}

Void main()

{

- - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - -

}

4.4. Supports following data types-

a) unsigned char, signed char

b) unsigned int, signed int,

c) Single bit: sbit(SFR) , bit (bit-addressable RAM)

d) Special function register: SFR

Data type Size Range

bit 1-bit RAM bit-addressable only

sbit 1-bit SFR bit-addressable only

(signed) int 16-bit -32768 to +32767

unsigned int 16-bit 0 to 65535

(signed) char 8-bit -128 to +127

unsigned char 8-bit 0 to 255

//SFR= specific function register.

Unsigned Char

a) The most widely used data types for the 8051

b) 8-bitdata type

c) The range of unsigned char: 0-255(00-FFH)

37DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 38: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

d) When do you use unsigned char?

–To set counter value.

–The string of ASCII character .

–For toggling ports.

Signed Char

a) 8-bitdata type.

b) 2’s complement representation.

c) The range of unsigned char: -128:+127(00-FFH)

d) When do you use signed char?

–To present a given quantity such as temperature.

Integer

a) 16-bitdata type

–The range of unsigned int: 0-65535

–The range of signed int: -32,768-32,767

b) Since the 8051 is an 8-bit microcontroller and the int data type takes two bytes of RAM,

we must not use the intdata type unless we have to.

c) You should try to use unsigned char instead on int.

Access Single Bit of SFR

Way to access a single bit of SFR

–Use sbitandnameof SFR

#include <reg51.h>

Sbit MYBIT = P1^5;//D5 of P1

–Use sbit declare the bit of SFR and declare by you

Sbit MYBIT = 0x95;//D5 of P1

Reg51.h is not necessary.

4.5. Description of the project:

This is a software based project to understand the basic concept of the LCD,7 segment and

Keypad.

38DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 39: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

Password Based Door Lock System using 8051 Microcontroller

Principle Behind the Circuit:

The main component in the circuit is 8051 controller. In this project 4×3 keypad is used to

enter the password. The password which is entered is compared with the predefined

password.

If the entered password is correct then the system opens the door by rotating door motor and

displays the status of door on LCD. If the password is wrong then door is remain closed and

displays “password is wrong” on LCD.

Figuer4.1: Circuit Diagram of Password Based Door Lock System using 8051

Microcontroller

C Code Circuit Operation:

#include<reg52.h>

sbit r=P3^2;

sbit e=P3^1;

sbit l=P3^0;

int a[3];

void delay(unsigned intMS)

{

39DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 40: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

Inti,j;

For (i=0;i<127;i++)

{

For (j=0;j<MS;j++)

{}

}

}

void com()

{

r=0;

e=1;

delay(100);

e=0;

}

void display()

{

r=1;

e=1;

delay(100);

e=0;

}

void star()

{

P1='*';

display();

delay(100);

}

void keypad()

{

int i=0;

while(i<3)

{

40DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 41: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

P2=0xf7;

if(P2==0xf6)

{

a[i]=1;

star();

i++;

}

else if(P2==0xf5)

{

a[i]=2;

star();

i++;

}

else if(P2==0xf3)

{

a[i]=3;

star();

i++;

}

P2=0xef;

if(P2==0xee)

{

a[i]=4;

star();

i++;

}

else if(P2==0xed)

{

a[i]=5;

star();

i++;

}

41DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 42: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

else if(P2==0xeb)

{

a[i]=6;

star();

i++;

}

P2=0xdf;

if(P2==0xde)

{

a[i]=7;

star();

i++;

}

else if(P2==0xdd)

{

a[i]=8;

star();

i++;

}

else if(P2==0xdb)

{

a[i]=9;

star();

i++;

}

P2=0xbf;

if(P2==0xbd)

{

a[i]=0;

star();

i++;

}

42DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 43: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

}

}

void main()

{

int b[3];

int c[3];

char d [18]="enter new password";

char e[14]="enter password";

char f[14]="wrong password";

char g[16]="correct password";

char h[11]="door opened";

intx,y;

intn,j,p,k,m,q,r;

int s;

P1=0x38;

com();

P1=0x0c;

com();

P1=0x01;

com();

for(n=0;n<18;n++)

{

P1=d[n];

display();

}

keypad();

P1=0x01;

com();

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

{

b[j]=a[j];

43DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 44: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

}

while(1)

{

for(p=0;p<14;p++)

{

P1=e[p];

display();

}

keypad();

P1=0xc1;

com();

for(k=0;k<3;k++)

{

c[k]=a[k];

}

x=y=1;

l=0;

for(m=0;m<3;m++)

{

if(b[m]==c[m])

{

x=0;

}

else

y=0;

}

if(y==0)

{

for(q=0;q<14;q++)

{

P1=f[q];

display();

44DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 45: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

}

P1=0x01;

com();

}

else if(x==0)

{

for(r=0;r<16;r++)

{

P1=g[r];

display();

}

delay(100);

P1=0x01;

com();

for(s=0;s<11;s++)

{

P1=h[s];

display();

}

P1=0x01;

com();

l=1;

}

delay(2000);

}

}

45DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 46: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

5. SOFTWARES

a) Keil compiler

The KEIL 8051 Development Tools are designed to solve the complex problems facing

embedded software developers.

b) Proteus

c) Flash magic

46DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 47: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

CONCLUSION

a) The world of embedded systems is a dreamer’s paradise with unlimited possibilities.

b) It make controlling all the systems around just by a simple gesture and the things respond

to you as if it was some magic.

c) As microprocessors are becoming smaller and cheaper, more and more products are

becoming ‘smart’ with microprocessors embedded in them.

d) The basic architecture and function of a microcontroller is discussed. With examples, the

need for low power microcontroller is illustrated.

e) Microcontrollers are of prime importance for electronic control and communication of

any modern appliance. Any household appliance e.g. washing machine, refrigerator, air-

conditioner or office appliances e.g. electronic printer, Photostat copier, fax machine

contains one or more microcontrollers. Because of its bulk usage a marginal saving in

power for one 8051 results to enormous saving as a whole.

f) In any device design, when one feature is optimized another feature degrades. When low

power is achieved the speed or performance may go down. Though this microcontroller

consumes negligible power its other features are comparable to the existing

microcontrollers available in the market.

47DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Page 48: Vinod report es   1

TRAINING REPORT (VINOD 12EEAEC094) EMBEDDED SYSTEM

BIBLOGRAPHY

Books References

a) Raj Kamal, Embedded systems, TMG

b) Mazidi and Mazidi, The 8051 microcontroller and embedded systems - Pearson

education.

c) Peatman,J.B. Design with microcontrollers and microcomputers, McGraw Hill

d) Peatman,J.B. Design with microcontrollers and microcomputers, McGraw Hill

Website Referencesa) http://www.embedded.com

b) www.8051.org

c) www.8051projects.net

d) www.keil.com

e) www.ceg.rajasthan.gov.in

48DEPARTMENT OF ELECTRONICS AND COMMUNICATION