+ All Categories
Home > Documents > Embedded Systems Trainin

Embedded Systems Trainin

Date post: 07-Apr-2018
Category:
Upload: ojasvi-rao
View: 220 times
Download: 0 times
Share this document with a friend
47
  A Practical Train ing Seminar Repor t Submitted in partial fulf illment of The requirements for the award of the degree of Bachelor of Engineering By OJASVI RAO (08ELDECO82)  Under The Supervision Submitted to Of Prof. S. K. Mehrotra Mr. Jitender Singh Saggu (I/C PTS)  TICO Institute of Embedded Technology (E&CE DEPTT) LAXMI DEVI INSTITUTE OF ENGINEERING & TECHNOLOGY ALWAR-TIJARA-DELHI HIGHWAY, CHIKANI, ALWAR(RAJ)-301028  2011-2012
Transcript
Page 1: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 1/47

   A Practical Training Seminar Report Submitted in partial fulfillment of 

The requirements for the award of the degree of 

Bachelor of Engineering 

By

OJASVI RAO(08ELDECO82)

 

Under The Supervision Submitted to

Of Prof. S. K. Mehrotra

Mr. Jitender Singh Saggu (I/C PTS) 

TICO Institute of Embedded Technology (E&CE DEPTT)

LAXMI DEVI INSTITUTE OF ENGINEERING & TECHNOLOGYALWAR-TIJARA-DELHI HIGHWAY, CHIKANI, ALWAR(RAJ)-301028

 2011-2012

Page 2: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 2/47

  Acknowledgement

It was highly educative and interactive to take training at Tico instiute of embedded

t technology. A person technically lacks without having practical knowledge, it was a

good chance for learning and practicing new things to update our self.

I am highly thankful to the respected Sir Mr.D.R Godara , and respected Sir Mr. M.L Meena for 

allowing me to join the Tico Instiute of Embedded and Technology and motivating me to do the

right things. I also take the opportunity to thanks Mr.Jitender Singh Saghu for his important

guidance in session.

Page 3: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 3/47

Preface

An engineer has to serve the market, for that one must know about the demands and

requirements in the market, the way of tackling the hurdles and find a way of working out

for their solutions at the right place.

After the completion of four year degree course an engineer must have a thorough

knowledge about the theory and practical. For this one must be practically sound with

theory aspects.

To make the engineer good at practical the engineering courses provides a 5-6 weeks

industrial training where one gets the opportunity to apply the theory in practical

 processes and production.

We have been lucky to get a chance for undergoing this training at Tico Instiute of 

Embedded Technology at Delhi.This report has been prepared on the basis of knowledge

acquired by us during training period of 40 days at the center.

Page 4: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 4/47

Contents

1. Introduction to Embedded systems ………………….. 6

2. Basic Components …………………… 9

3. Parallel Port Basics …………………… 20

4. Introduction to Microcontrollers ………………….. 26

5. Types of Motors ………………….. 43

6. Conclusion …………………… 47

7. Bibliography …………………… 48

Page 5: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 5/47

  LIST OF FIGURES

BASIC COMPONENTS:

FIG1.1 ……………………….. Resistors

FIG1.2 ………………………. Variable Resistors

FIG2.1 ………………………. Capacitors

FIG3.1 ……………………… Diodes

FIG5.1 ……………………… LED

FIG6.1 …………………….. Transistors

FIG6.2 …………………….. Basic Circuit

FIG7.1 ……………………. Relays

FIG7.1.1 ……………………. Electromechanical Relay

FIG7.1.2 ……………………. Power Relay

FIG7.2 …………………… Solid State Relay

PARALLEL PORT:

FIG3.1 …………………… Parallel Port

FIG3.2 ………………….. Female Connector  

FIG3.3 …………………. Male Connector  FIG3.1.1 …………………. Seven Segement

MICROCONTROLLER:

FIG4.1 ………………… Memory Architecture

MOTORS:

FIG5.1 …………………. DC Motor  

FIG5.2 ………………… StepperMotor  

Page 6: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 6/47

Page 7: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 7/47

The first recognizably modern embedded system was the Apollo Guidance Computer,

developed by Charles Stark Draper at the MIT Instrumentation Laboratory. Each

flight to the moon had two. They ran the inertial guidance systems of both the

command module and LEM.

At the project's inception, the Apollo guidance computer was considered the riskiest

item in the Apollo project. The use of the then new monolithic integrated circuits, to

reduce the size and weight, increased this risk.

The first mass-produced embedded system was the Autonetics D-17 guidance

computer for the Minuteman missile, released in 1961. It was built from discrete

transistor logic and had a hard disk for main memory. When the Minuteman II went

into production in 1966, the D-17 was replaced with a new computer that was the first

high-volume use of integrated circuits.

Characteristics

Embedded systems are designed to do some specific task, rather than be a general-

  purpose computer for multiple tasks. Some also have real-time performance

constraints that must be met, for reason such as safety and usability; others may have

low or no performance requirements, allowing the system hardware to be simplified

to reduce costs.

For high volume systems such as portable music players or mobile phones,

minimizing cost is usually the primary design consideration. Engineers typically

select hardware that is just “good enough” to implement the necessary functions. For 

example, a digital set-top box for satellite television has to process large amounts of 

data every second, but most of the processing is done by custom integrated circuits.

The embedded CPU "sets up" this process, and displays menu graphics, etc. for the

set-top's look and feel.

Page 8: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 8/47

The software written for embedded systems is often called firmware, and is stored in

ROM or Flash memory chips rather than a disk drive. It often runs with limited

hardware resources: small or no keyboard, screen, and little RAM memory.

Embedded systems reside in machines that are expected to run continuously for years

without errors and in some cases recover by them if an error occurs. Therefore the

Software is usually developed and tested more carefully than that for Personal

computers, and unreliable mechanical moving parts such as Disk drives, switches or 

 buttons are avoided. Recovery from errors may be achieved with techniques such as a

watchdog timer that resets the computer unless the software periodically notifies the

watchdog.

User interfaces

Embedded systems range from no user interface at all - dedicated only to one task - to

full user Interfaces similar to desktop operating systems in devices such as PDAs. In

 between are devices with small character- or digit-only displays and a few buttons.

Therefore usability considerations vary widely.

On larger screens, a touch-screen or screen-edge soft buttons also provides good

flexibility while minimizing space used. The advantage of this system is that the

meaning of the buttons can change with the screen, and selection can be very close to

the natural behavior of pointing at what's desired.

Page 9: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 9/47

Basic Electronic Components

1.Resistors

 FIG:1.1 Resistors

Resistors are components

that have a predetermined

resistance. Resistance

determines how much

current will flow through

a component. Resistors are used to control voltages and currents. A very high

resistance allows very little current to flow. Air has very high resistance. Current

almost never flows through air. (Sparks and lightning are brief displays of current

flow through air. The light is created as the current burns parts of the air.) A low

resistance allows a large amount of current to flow. Metals have very low resistance.

That is why wires are made of metal. They allow current to flow from one point to

another point without any resistance. Wires are usually covered with rubber or plastic.

This keeps the wires from coming in contact with other wires and creating short

circuits. High voltage power lines are covered with thick layers of plastic to make

them safe, but they become very dangerous when the line breaks and the wire is

exposed and is no longer separated from other things by insulation.

Resistance is given in units of ohms. (Ohms are named after Mho Ohms who played

with electricity as a young boy in Germany.) Common resistor values are from 100

ohms to 100,000 ohms. Each resistor is marked with colored stripes to indicate its

resistance.

Variable Resistors

Page 10: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 10/47

FIG:1.2 Variable Resisitors

Variable resistors are also common

components. They have a dial or a

knob that allows you to change the resistance. This is very useful for many situations.

Volume controls are variable resistors. When you change the volume you are

changing the resistance which changes the current. Making the resistance higher will

let less current flow so the volume goes down. Making the resistance lower will let

more current flow so the volume goes up. The value of a variable resistor is given as

its highest resistance value. For example, a 500 ohm variable resistor can have a

resistance of anywhere between 0 ohms and 500 ohms. A variable resistor may also

 be called a potentiometer (pot for short).

2.Capacitors

Page 11: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 11/47

FIG2.1:Capacitors

 Now suppose you want to control how the current in your circuit changes (or not

changes) over time. Now why would you? Well radio signals require very fast current

changes. Robot motors cause current fluctuations in your circuit which you need to

control. What do you do when batteries cannot supply current as fast as you circuit

drains them? How do you prevent sudden current spikes that could fry your robot

circuitry? The solution to this iscapacitors.

Capacitors are like electron storage banks. If your circuit is running low, it will

deliver electrons to your circuit.In our water analogy, think of this as a water tank 

with water always flowing in, but with drainage valves opening and closing. Since

capacitors take time to charge, and time to discharge, they can also be used for timing

circuits. Quick note, some capacitors are polarized, meaning current can only flow

one direction through them. If a capacitor has a lead that is longer than the other,

assume the longer lead must always connect to positive.

Page 12: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 12/47

Power surge /drainage management

The problem with using robot components that drain a large amount of power is

sometimes your battery cannot handle the high drain rate, Motors and servos being

 perfect examples. This would cause a system wide voltage drop, often resetting your 

microcontroller, or at least causing it to not work properly. Just a side note, it is bad to

use the same power source for both your circuit and your motors. So don't do it.

Or suppose your robot motors are not operating at its full potential because the battery

cannot supply enough current, the capacitor will make up for it. The solution is to

 place a large electrolytic capacitor between the source and ground of your power 

source. Get a capacitor that is rated at least twice the voltage you expect to go through

it. Have it rated at 1mF-10mF for every  amp required. For example, if your 20V

motors will use 3 amps, use a 3mF-30mF 50V rated capacitor. Exactly how much will

depend on how often you expect your motor to change speed and direction, as well as

momentum of what you are actuating. Just note that if your capacitor is too large, it

may take a long time to charge up when you first turn your robot on. If it is too small,

it will drain of electrons and your circuit will be left with a deficit. It is also bad to

allow a large capacitor to remain fully charged when you turn off your robot. Some

things could accidentally short and fry. So use a simple power on LED in your motor 

circuit to drain the capacitor after your robot is turned off. If your capacitor is not

rated properly for voltage, then can explode with smoke. Fortunately they do not

overheat if given excessive amounts of current. So just make sure your capacitor is

rated higher than your highest expected.

Capacitors can also be used to prevent power spikes that could potentially fry

circuitry. Next to any on/off switch or anything that that could affect power suddenly

should have a capacitor across it?

Page 13: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 13/47

3.Diodes

FIG3.1:Diodes

Diodes are components that allow current to flow in only one direction. They have a

 positive side (leg) and a negative side. When the voltage on the positive leg is higher 

than on the negative leg then current flows through the diode (the resistance is very

low). When the voltage is lower on the positive leg than on the negative leg then the

current does not flow (the resistance is very high). The negative leg of a diode is the

one with the line closest to it. It is called the cathode. The positive end is called the

anode.

Usually when current is flowing through a diode, the voltage on the positive leg is

0.65 volts higher than on the negative leg.

4.Switches

Switches are devices that create a short circuit or an open circuit depending on the

 position of the switch. For a light switch, ON means short circuit (current flows

through the switch, and lights light up.) When the switch is OFF, that means there is

an open circuit (no current flows, lights go out.

When the switch is ON it looks and acts like a wire. When the switch is OFF there is

no connection.

Page 14: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 14/47

5.The LED 

FIG5.1:LED

An LED is the device shown above. Besides red, they can also be yellow, green and

 blue. The letters LED stand for Light Emitting Diode. The important thing to

remember about diodes (including LEDs) is that current can only flow in one

direction.

6.The Transistor

  FIG6.1:Transistors

Transistors are basic components in all of today's electronics. They are just simple

switches that we can use to turn things on and off. Even though they are simple, they

are the most important electrical component. For example, transistors are almost the

only components used to build a Pentium processor. A single Pentium chip has about

3.5 million transistors. The ones in the Pentium are smaller than the ones we will use

 but they work the same way.

Transistors that we will use in projects look like this:

The transistor has three legs, the Collector (C), Base (B), and Emitter (E). Sometimes

they are labeled on the flat side of the transistor. Transistors always have one round

side and one flat side. If the round side is facing you, the Collector leg is on the left,

the Base leg is in the middle, and the Emitter leg is on the right.

Page 15: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 15/47

Transistor Symbol

The following symbol is used in circuit drawings (schematics) to represent a

transistor.

FIG6.2: Basic Circuit

The Base (B) is the On/Off switch for the transistor. If a current is flowing to the

Base, there will be a path from the Collector (C) to the Emitter (E) where current can

flow (The Switch is On.) If there is no current flowing to the Base, then no current

can flow from the Collector to the Emitter. (The Switch is off.) Below is the basic

circuit we will use for all of our transistors.

Page 16: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 16/47

7.Relays

A relay is usually an electromechanical device that is actuated by an electrical current.

The current flowing in one circuit causes the opening or closing of another circuit.

Relays are like remote control switches and are used in many applications because of 

their relative simplicity, long life, and proven high reliability. They are used in a wide

variety of applications throughout industry, such as in telephone exchanges, digital

computers and automation systems.

How do relays work?

All relays contain a sensing unit, the electric coil, which is powered by AC or DC

current. When the applied current or voltage exceeds a threshold value, the coil

activates the armature, which operates either to close the open contacts or to open the

closed contacts. When a power is supplied to the coil, it generates a magnetic force

that actuates the switch mechanism. The magnetic force is, in effect, relaying the

action from one circuit to another. The first circuit is called the control circuit; the

second is called the load circuit. A relay is usually an electromechanical device that is

actuated by an electrical current.

FIG7.1:Relays

Page 17: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 17/47

Types of Relays

There are two basic classifications of relays: 

1. Electromechanical Relay

2. Solid State Relay.

Electromechanical relays have moving parts, whereas solid state relays have no

moving parts. Advantages of Electromechanical relays include lower cost, no heat

sink is required, multiple poles are available, and they can switch AC or DC with

equal ease.

1.Electromechanical Relays

General Purpose Relay: The general-purpose relay is rated by the amount of current

its switch contacts can handle. Most versions of the general-purpose relay have one to

eight poles and can be single or double throw. These are found in computers, copy

machines, and other consumer electronic equipment and appliances.

FIG7.1.1:Electromechanical relays

Power Relay:

Page 18: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 18/47

The power relay is capable of handling larger power loads – 10-50 amperes or more.

They are usually single-pole or double-pole units.

FIG7.1.2:Power Relay

Contactor: A special type of high power relay, it’s used mainly to control high

voltages and currents in industrial electrical applications. Because of these high power 

requirements, contactors always have double-make contacts.

Time-Delay Relay: The contacts might not open or close until some time interval

after the coil has been energized. This is called delay-on-operate. Delay-on-release

means that the contacts will remain in their actuated position until some interval after 

the power has been removed from the coil.

A third delay is called interval timing. Contacts revert to their alternate position at a

specific interval of time after the coil has been energized.

The timing of these actions may be a fixed parameter of the relay, or adjusted by a

knob on the relay itself, or remotely adjusted through an external circuit.

2.Solid State Relays

Page 19: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 19/47

FIG7.2:Solid State Relay

These active semiconductor devices use light instead of magnetism to actuate a

switch. The light comes from an LED, or light emitting diode. When control power is

applied to the device’s output, the light is turned on and shines across an open space.

On the load side of this space, a part of the device  senses the presence of the light, and

triggers a solid state switch that either opens or closes the circuit  under control.

Often, solid state relays are used where the circuit under control must be protected

from the introduction of electrical noises.

Advantages of Solid State Relays include low EMI/RFI, long life, no moving parts,

no contact bounce, and fast response.

The drawback to using  a solid state relay is that it can only accomplish single pole

switching.

Page 20: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 20/47

3.Parallel port basics:

In computers, ports are used mainly for two reasons: Device control and

communication. We can program PC's Parallel ports for both. Parallel ports are

mainly meant for connecting the printer to the PC. But we can program this port for 

many more applications beyond that.Parallel ports are easy to program and faster 

compared to the serial ports. But main disadvantage is it needs more number of 

transmission lines. Because of this reason parallel ports are not used in long distance

communications. Let us know the basic difference between working of parallel port

and serial port. In serial ports, there will be two data lines: One transmission and one

receive line. To send a data in serial port, it has to be sent one bit after another withsome extra bits like start bit, stop bit and parity bit to detect errors. But in parallel

 port, all the 8 bits of a byte will be sent to the port at a time and a indication will be

sent in another line. There will be some data lines, some control and some

handshaking lines in parallel port. If three bytes of data 01000101 10011100

10110011 is to be sent to the port, following figures will explain how they are sent to

the serial and parallel ports respectively. We can understand why parallel port

communication is faster compared to that of serial.

FIG3.1:Parallel Port

Page 21: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 21/47

In the PC there will be D-25 type of female connector having 25 pins and in the printer;

there will be a 36-pin Centronics connector. Connecting cable will combine these

connecters using following convention. Pin structure of D-25 and Centronics connecters

are explained bellow.

FIG3.2:Female Connector 

 Normally, data, control and status registers will have following addresses. We need these

addresses in programming.

Register LPT1 LPT2

Data register (Base Address + 0) 0x378 0x278

Status register (Base Address + 1) 0x379 0x279

Control register (Base Address + 2) 0x37a 0x27a

 Note: All the parallel ports do not have bidirectional capability. Earlier parallel ports had

only output enabled in data pins since printers only inputs data. But latter, to make

  parallel port capable of communicating with other devises, bidirectional ports are

introduced.

By default, data port is output port. To enable the bidirectional property of the port, we

need to set the bit 5 of control register.

21

Page 22: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 22/47

To know the details of parallel ports available in your computer, follow this procedure:

• Right click on My Computer, go to "Properties".

• Select the tab Hardware, Click Device manager.

• You will get a tree structure of devices. In that Expand

"Ports (Com1 & LPT)".

• Double Click on the ECP Printer Port (LPT1) or any other 

LPT port if available.

• You will get details of LPT port. Make sure that "Use this Port (enable)" is

selected.

• Select tab recourses. In that you will get the address range of port.

22

Page 23: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 23/47

To start programming, you will need a D-25 type Male connector. Its pin structures can

 be found in the connector as follows:

FIG3.3:Male Connector 

23

Page 24: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 24/47

3.1Interfacing of Seven Segment with Parallel port:-

Apparatus:

Seven segment C-5611, Parallel Port Connector cord, Jumper Wires Bread Board.

 

Procedure:

 

1. Open windows 98 as OS

2. Connect the male connector of the parallel port cord to the PC

3. Now connect the Female Connector of cord with seven segment C-5611 as

shown in table.

 

Table: Connection between Seven Segment and Female Connector 

Seven Segment Pin

No.

Female Connector Pin No.

1 6

2 5

3 19

4 4

5 9

6 3

7 2

8 20

9 7

10 8

24

Page 25: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 25/47

Relationship of decimal No. , Segment Display and Hexadecimal Equivalent

Pin Out of seven segment

FIG3.1.1:Seven Segement

25

Page 26: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 26/47

4.Microcontrollers

The 8051 Microcontroller

Overview

The 8051 family of micro controllers is based on an architecture which is highly

optimized for embedded control systems. It is used in a wide variety of applications from

military equipment to automobiles to the keyboard on your PC. Second only to the

Motorola 68HC11 in eight bit processors sales, the 8051 family of microcontrollers is

available in a wide array of variations from manufacturers such as Intel, Philips, and

Siemens. These manufacturers have added numerous features and peripherals to the 8051

such as I2C interfaces, analog to digital converters, watchdog timers, and pulse width

modulated outputs. Variations of the 8051 with clock speeds up to 40MHz and voltage

requirements down to 1.5 volts are available. This wide range of parts based on one core

makes the 8051 family an excellent choice as the base architecture for a company's entire

line of products since it can perform many functions and developers will only have to

learn this one platform.

The basic architecture consists of the following features:

One 8051 processor cycle consists of twelve oscillator periods. Each of the twelve

oscillator periods is used for a special function by the 8051 core such as op code fetches

and samples of the interrupt daisy chain for pending interrupts. The time required for any

8051 instruction can be computed by dividing the clock frequency by 12, inverting that

result and multiplying it by the number of processor cycles required by the instruction in

question. Therefore, if you have a system which is using an 11.059MHz clock, you can

compute the number of instructions per second by dividing this value by 12. This gives

an instruction frequency of 921583 instructions per second. Inverting  this will provide

the amount of time taken by each instruction cycle (1.085 microseconds).

26

Page 27: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 27/47

• an eight bit ALU

• 32 discrete I/O pins (4 groups of 8) which can be individually accessed

• two 16 bit timer/counters

full duplex UART• 6 interrupt sources with 2 priority levels

• 128 bytes of on board RAM

• separate 64K byte address spaces for DATA and CODE memory

Memory Organization

The 8051 architecture provides the user with three physically distinct memory spaces

which can be seen in Figure A - 1. Each memory space consists of contiguous addresses

from 0 to the maximum size, in bytes, of the memory space. Address overlaps are

resolved by utilizing instructions which refer specifically to a given address space. The

three memory spaces function as described below.

Figure 4.1 - 8051 Memory Architecture

27

Page 28: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 28/47

The CODE Space

The first memory space is the CODE segment in which the executable program resides.

This segment can be up to 64K (since it is addressed by 16 address lines). The processor 

treats this segment as read only and will generate signals appropriate to access a memory

device such as an EPROM. However, this does not mean that the CODE segment must be

implemented using an EPROM. Many embedded systems these days are using EEPROM

which allows the memory to be overwritten either by the 8051 itself or by an external

device. This makes upgrades to the product easy to do since new software can be

downloaded into the EEPROM rather than having to disassemble it and install a new

EPROM.

Additionally, battery backed SRAMs can be used in place of an EPROM. This method

offers the same capability to upload new software to the unit as does an EEPROM, and

does not have any sort of read/write cycle limitations such as an EEPROM has. However,

when the battery supplying the RAM eventually dies, so does the software in it. Using an

SRAM in place of an EPROM in development systems allows for rapid downloading of 

new code into the target system. When this can be done, it helps avoid the cycle of 

 programming/testing/erasing with EPROM’s, and can also help avoid hassles over an in

circuit emulator which is usually a rare commodity. In addition to executable code, it is

common practice with the 8051 to store fixed lookup tables in the CODE segment. To

facilitate this, the 8051 provides instructions which allow rapid access to tables via the

data pointer (DPTR) or the program counter with an offset into the table optionally

 provided by the accumulator. This means that oftentimes, a table's base address can be

loaded in DPTR and the element of the table to access can be held in the accumulator.

The addition is performed by the 8051 during the execution of the instruction which can

save many cycles depending on the situation.

28

Page 29: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 29/47

The DATA Space

The second memory space is the 128 bytes of internal RAM on the 8051, or the first 128

 bytes of internal RAM on the 8052. This segment is typically referred to as the DATA

segment. The RAM locations in this segment are accessed in one or two cycles

depending on the instruction. This access time is much quicker than access to the

XDATA segment because memory is addressed directly rather than via a memory pointer 

such as DPTR which must first be initialized. Therefore, frequently used variables and

temporary scratch variables are usually assigned to the DATA segment. Such allocation

must be done with care, however, due to the limited amount of memory in this segment.

Variables stored in the DATA segment can also be accessed indirectly via R0 or R1. The

register being used as the memory pointer must contain the address of the byte to be

retrieved or altered. These instructions can take one or two processor cycles depending on

the source/destination data byte.

The DATA segment contains two smaller segments of interest. The first sub segment

consists of the four sets of register banks which compose the first 32 bytes of RAM. The

8051 can use any of these four groups of eight bytes as its default register bank. The

selection of register banks is changeable at any time via the RS1 and the RS0 bits in the

Processor Status Word (PSW). These two bits combine into a number from 0 to 3 (with

RS1 being the most significant bit) which indicates the register bank to be used.

Register bank switching allows not only for quick parameter passing, but also opens the

door for simplifying task switching on the 8051.

The second sub-segment in the DATA space is a bit addressable segment in which each

 bit can be individually accessed. This segment is referred to as the BDATA segment. The

 bit addressable segment consists of 16 bytes (128 bits) above the four register banks in

memory. The 8051 contains several single bit instructions which are often very useful in

control applications and aid in replacing external combinatorial logic with software in the

8051 thus reducing parts count on the target system. It should be noted that these 16 bytes

can also be accessed on a "byte-wide" basis just like any other byte in the DATA space.

29

Page 30: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 30/47

Special Function Registers

Control registers for the interrupt system and the peripherals on the 8051 are contained in

internal RAM at locations 80 hex and above. These registers are referred to as special

function registers (or SFRs for short). Many of them are bit addressable. The bits in the

 bit addressable SFRs can either be accessed by name, index or bit address. Thus, you can

refer to the EA bit of the Interrupt Enable SFR as EA, IE.7, or 0AFH. The SFRs control

things such as the function of the timer/counters, the UART, and the interrupt sources as

well as their priorities.

These registers are accessed by the same set of instructions as the bytes and bits in the

DATA segment. A memory map of the SFRs indicating the registers which are bit

addressable is shown in Table A - 1.

30

Page 31: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 31/47

The IDATA Space

Certain 8051 family members such as the 8052 contain an additional 128 bytes of internal

RAM which reside at RAM locations 80 hex and above. This segment of RAM is

typically referred to as the IDATA segment. Because the IDATA addresses and the SFR 

addresses overlap, address conflicts between IDATA RAM and the SFRs are resolved by

the type of memory access being performed, since the IDATA segment can only be

accessed via indirect addressing modes.

The XDATA Space

The final 8051 memory space is 64K in length and is addressed by the same 16 address

lines as the CODE segment. This space is typically referred to as the external data

memory space (or the XDATA segment for short). This segment usually consists of some

sort of RAM (usually an SRAM) and the I/O devices or external peripherals to which the

8051 must interface via its bus. Read or write operations to this segment take a minimum

of two processor cycles and are performed using either DPTR, R0, or R1. In the case of 

DPTR, it usually takes two processor cycles or more to load the desired address in

addition to the two cycles required to perform the read or write operation. Similarly,

loading R0 or R1 will take minimum of one cycle in addition to the two cycles imposed

 by the memory access itself. Therefore, it is easy to see that a typical operation with the

XDATA segment will, in general, take a minimum of three processor cycles. Because of 

this, the DATA segment is a very attractive place to store any frequently used variables.

It is possible to fill this segment entirely with 64K of RAM if the 8051 does not need to

 perform any I/O with devices in its bus or if the designer wishes to cycle the RAM on and

off when I/O devices are being accessed via the bus.

31

Page 32: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 32/47

Bit processing and Boolean logic

The 8051 contains a single bit Boolean processor which can be used to perform logical

operations on any of the 128 addressable bits in the BIT segment, the 128 addressable

 bits in the SFRs, and any of the 32 I/O lines (port 0 through port 3). The 8051 can

 perform OR, AND, XOR, complement, set, and clear operations on bits as well as

moving bit values as one would normally move byte values.

MOV C, 22H ; move the bit value at address

; 22H to the carry bit

ORL C, 23H ; or the bit value at address

; 23H into the carry bit

ANL 24H, C ; and the carry bit into bit

; address 24H

There are also conditional branches which use addressed bits as the condition. One such

 branch which is especially useful is the “jump if bit is set and clear bit” instruction. This

"branch and clear" can be performed in two processor cycles and saves a cycle or two

over splitting the jump and the clear into two separate op codes. As an example, suppose

that you had to write a routine which waited for pin P0.0 to set, but could not wait

indefinitely. This routine would have to decrement a timeout value and exit the polling

loop when this timeout is exceeded. When pin P0.0 sets, the processor must force it back 

to 0 and exit the polling loop. With normal logic flow, the routine would look like the

following.

32

Page 33: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 33/47

  MOV timeout, #TO_VAL ; set the timeout value

L2: JB P0.0, L1 ; check the bit

DJNZ timeout, L2 ; decrement the timeout counter 

; and sample again

L1: CLR P0.0 ; force P0.0 to logic level 0

RET ; exit the routine

Using the JBC instruction, the same routine would be coded as follows.

MOV timeout, #TO_VAL ; set the timeout value

L2: JBC P0.0, L1 ; check the bit and force P0.0

; to logic level 0 if set

DJNZ timeout, L2 ; decrement the timeout counter 

L1: RET ; exit the routine

While the second routine may not offer a huge amount of savings in the code, it does

make the code a little simpler and more elegant. There will be many situations in your 

use of assembly code on the 8051 controller where this instruction will come in handy.

33

Page 34: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 34/47

On-Board Timer/Counters

The standard 8051 has two timer/counters (other 8051 family members have varying

amounts), each of which is a full 16 bits. Each timer/counter can be function as a free

running timer (in which case they count processor cycles) or can be used to count falling

edges on the signal applied to their respective I/O pin (either T0 or T1). When used as a

counter, the input signal must have a frequency equal to or lower than the instruction

cycle frequency divided by 2 (i.e.: the oscillator frequency /24) since the incoming signal

is sampled every instruction cycle, and the counter is incremented only when a 1 to 0

transition is detected (which will require two samples). If desired, the timer/counters can

force a software interrupt when they overflow.

The TCON (Timer Control) SFR is used to start or stop the timers as well as hold the

overflow flags of the timers. The TCON SFR is detailed below in Table A - 7. The

timer/counters are started or stopped by changing the timer run bits (TR0 and TR1) in

TCON. The software can freeze the operation of either timer as well as restart the timers

simply by changing the TRx bit in the TCON register. The TCON register also contains

the overflow flags for the timers. When the timers overflow, they set their respective flag

(TF0 or TF1) in this register. When the processor detects a 0 to 1 transition in the flag, aninterrupt occurs if it is enabled. It should be noted that the software can set or clear this

flag at any time. Therefore, an interrupt can be prevented as well as forced by the

software.

Timer Control Register (TCON) - Bit Addressable

TF1 Timer 1 overflow flag. Set when timer 1 overflows. Cleared by

 processor upon vectoring to the interrupt service routine.

TR1 Timer 1 control bit. If TR1=1, timer 1 runs. If TR1=0, timer 1

stops.

34

Page 35: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 35/47

TF0 Timer 0 overflow flag. Set when timer 0 overflows. Cleared by

 processor upon vectoring to the interrupt service routine.

TR0 Timer 0 control bit. If TR0=1, timer 1 runs. If TR0=0, timer 1

stops.

IE1 External interrupt 1 edge flag. Set when a valid falling edge is

detected at pin P3.3. Cleared by hardware when the interrupt is

serviced.

IT1 Interrupt 1 type control bit. If IT1=1, interrupt 1 is triggered by a

falling edge on P3.3. If IT1=0, interrupt 1 is triggered by a low

logic level on P3.3

IE0 External interrupts 0 edge flag. Set when a valid falling edge is

detected at pin P3.2. Cleared by hardware when the interrupt is

serviced.

IT0 Interrupt 0 type control bit. If IT0=1, interrupt 1 is triggered by a

falling edge on P3.2. If IT0=0 ,interrupt 0 is triggered by a low

logic level on P3.2

The timers are configured by altering the value in the TMOD (timer mode) SFR. By

changing TMOD, the software can control the mode of both timers as well as the source

they use to count (the signal at their I/O pin or the processor cycles). The upper nibble of 

TMOD controls the operation of timer 1 and the low nibble controls the operation of 

timer 0. The layout of the TMOD register (which is not bit addressable) is shown below.

35

Page 36: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 36/47

The source for the timer can be configured by altering the C/T bit in TMOD. Setting this

 bit to true will force the timer to count pulses on the I/O pin assigned to it. Setting this bit

false will force counting of processor cycles. When a timer is forced to count processor 

cycles it can do this either under hardware or software control. Software control iscommanded by setting the GATE bit of TMOD to 0. In this case, the timer will count any

time its TRx bit in the TCON register is high. In the hardware control mode, both the

TRx bit and the INTx pin on the chip must be high for the timer to count. When a low is

detected at the INTx pin, the timer will stop. This is useful for measuring pulse widths of 

signals on the INTx pin if one does not mind surrendering an external interrupt source to

the incoming signal.

36

Page 37: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 37/47

Timer Mode 0 and Mode 1

The timer/counters can be operated in one of four modes, under software control. In

mode 0, the timer/counter will behave like a 13 bit counter. When the counter overflows,

the TF0 or TF1 (timer flag) bit in the TCON (timer control) SFR is set. This will cause

the appropriate timer interrupt (assuming it is enabled). Both timer 0 and timer 1 operate

in the same way for mode 0. The operation of the timers in mode 1 is the same as it is for 

mode 0 with the exception that all sixteen bits of the timer are used instead of only

thirteen.

Timer Mode 2

In mode 2, the timer is set up as an eight bit counter which automatically reloads

whenever an overflow condition is detected. The low byte of the timer (TL0 or TL1) is

used as the counter and the high byte of the timer (TH0 or TH1) holds the reload value

for the counter. When the timer/counter overflows, the value in THx is loaded into TLx

and the timer continues counting from the reload value. Both timer 0 and timer 1 function

identically in mode 2. Timer 1 is often used in this mode to generate baud rates for the

UART.

Timer Mode 3

In mode 3, timer 0 becomes two eight bit counters which are implemented in TH0 and

TL0. The counter implemented in TL0 maintains control of all the timer 0 flags, but the

counter in TH0 takes over the control flags in TCON from timer 1. This implies that

timer 1 can no longer force interrupts, however, it can be used for any purpose which will

not require the overflow interrupt such as a baud rate generator for the UART, or as a

timer/counter which is polled by the software.

37

Page 38: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 38/47

On-Board UART

The 8051 features an on board, full duplex UART which is under software control. The

UART is configured via the SCON (Serial CONtrol) SFR. The SCON register allows the

user to select the UART mode, enable reception, and check UART status. SCON is

illustrated in Table A - 10.

The UART features a one byte buffer for incoming data so that another byte can be

ringing into the UART before the last byte has been read. However, after one byte time,

the buffer will be overwritten as the next incoming byte is completed. Therefore, the

software must be capable of responding to an incoming byte within one serial byte time.

This is also true for outgoing data assuming that it is required to be back to back.

The 8051 supports standard ten bit frames as well as an eleven bit frame designed for 

inter processor communications and a high speed 8 bit shift register mode. The baud rate

is variable for all modes except the eight bit shift mode and one of the inter processor 

modes.

38

Page 39: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 39/47

UART Mode 0

In mode 0 the UART acts as an eight bit shift register clocking data in and out at a baud

rate of 1/12th of the oscillator frequency. Data is sent LSB first and enters and exits the

UART via the RXD pin. Therefore mode 0 does not support full duplex since the RXD

 pin is used for all incoming and outgoing data and the TXD pin is used to echo the shift

clock. This mode is useful for situations in which the micro controller is used to interface

to a serial device such as an EEPROM which has a serial eight bit interface format.

Transmission of a byte begins when the SBUF SFR is the destination register of a move

instruction. At this point, the eight bits are clocked out and the TI bit is set when the

transmission of the eighth bit is complete. Reception begins when the REN bit of the

SCON register is set true. The RI bit is set when the eighth bit is clocked in.

UART Mode 1

In mode 1 of the UART, 8 data bits are transmitted in a ten bit frame: one start bit, eight

data bits, and one stop bit. This mode is suitable for communications to most serial

devices including personal computers. The baud rate is variable and is controlled by the

overflow rate of timer 1 in the auto reload mode or, optionally, by timer 2 in the baud rate

generating mode on an 8052. Overflow interrupts should be disabled for the timer being

used to generate the baud rate. The SMOD bit in the PCON (power control) SFR can be

set high to double the baud rate implemented by the UART. The TI and RI interrupt

signals are activated halfway through the transmission or reception of the stop bit.

Typically, this will allow the software time to respond to the interrupt and load SBUF

with the next byte in back to back during data block transfers. The amount of processing

time available depends on the baud rate in use and the oscillator frequency being used to

drive the 8051. If timer 1 is going to be used to 

generate the desired baud rate of the

UART, you must compute the reload value for TH1 using the following equation:

39

Page 40: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 40/47

TH1=256-(K*OscFreq)/(384*Baud Rate)

K=1 if SMOD=0

K=2 if SMOD=1

Any baud rate which does not give a positive reload value less than 256 can not be

generated by the 8051 at the given clock frequency. Reload values which are not integers

must be very close to the next integer. Oftentimes the resultant baud rate may be close

enough to allow the system to work. This evaluation must be made by the developer.

Thus, if you have an 8051 which is using a 9.216MHz oscillator and you want to generate

a baud rate of 9600 baud you must go through these steps. First, run the equation for K=1

then later try it for K=2. For K=1, the numerator becomes 9216000 and the denominator 

 becomes 3686400. Dividing these two values gives a result of 2.5. From this it is obvious

that the reload value given by this function will not be an integer. Rerunning the equation

with K=2 gives a numerator of 18432000 and a denominator of 3686400. Dividing these

two values gives an answer of 5 which you subtract from 256. This gives a reload value

of 251 or 0FBH for TH1.

For an 8052 using timer 2 to generate the baud rate, the reload value for RCAP2H and

RCAP2L must be computed. Again, you must start from the desired baud rate and solve

the following equation to obtain the reload values.

[RCAP2H, RCAP2L]=65536-OscFreq/(32*Baud Rate)

Assume that you again have a system with an oscillator at 9.216MHz, and you want to

generate a baud rate of 9600 baud. For this to be possible, the resultant 16 bit answer of 

the above equation must be both positive and “near integer.” You end up dividing

9216000 by 307200 and getting an intermediate result of 30. Subtracting this from 65536

gives an answer of 65506 or FFE2H. You should then use a reload value of 255 or FFH

for RCAP2H and a reload value of 226 or E2H for RCAP2L.

40

Page 41: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 41/47

UART Mode 2

Mode 2 of the UART causes and eleven bit frame to be transmitted: one start bit, eight

data bits, a ninth (or stick) bit, and one stop bit. The value of the ninth bit is determined

 by the TB8 bit of SCON for transmissions and the RB8 bit of SCON for receptions. The

ninth bit is typically used for inter processor communications. To facilitate this, the

UART can be initialized to fire a receive interrupt only when the ninth bit (or stick bit) is

set. This feature is referred to as the multiprocessor communication feature by Intel and is

controlled by the SM2 bit in the SCON register. When SM2 is set, the ninth data bit must

 be set for the UART to fire an interrupt. When it is cleared, the UART will fire a receive

interrupt whenever a valid eleven bit frame rings in. The stick bit is used to lower the

amount of unnecessary interrupts during serial communications across a multidrop serial

 bus. In such situations an address or command byte is sent first with the stick bit set. All

 processors on the bus are interrupted and check the incoming byte to see if it is necessary

for them to receive the message. If it is, the SM2 bit is cleared to remove the restriction of 

having the stick bit set, and the rest of the message is received. Otherwise, the SM2 bit is

left set and the normal processing continues without constantly being disturbed by a

string of interrupts for the incoming byte stream.

The baud rate for mode two is 1/64th of the oscillator frequency when the SMOD bit is

cleared and it is 1/32nd of the oscillator frequency when the SMOD bit is set. Therefore,

very high baud rates (over 345K baud) are achievable using this mode and a relatively

common oscillator frequency such as 11.059MHz.

41

Page 42: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 42/47

5.Types of Motors

1.DC Motors

 

FIG5.1:DC Motors

From the start, DC motors seem quite simple. Apply a voltage to both terminals, and it

spins. But what if you want to control which direction the motor spins? Correct, you

reverse the wires. Now what if you want the motor to spin at half that speed? You would

use less voltage. But how would you get a robot to do those things autonomously? How

would you know what voltage a motor should get? Why not 50V instead of 12V? What

about motor overheating? Operating motors can be much more complicated than you

think .

DC motors are non-polarized - meaning that you can reverse voltage without any bad

things happening. Typical DC motors are rated from about 6V-12V. The larger ones are

often 24V or more. But for the purposes of a robot, you probably will stay in the 6V-12V

range. So why do motors operate at different voltages? As we all know (or should),

voltage is directly related to motor torque. More voltage, higher the torque. But don't go

running your motor at 100V because that’s just not nice. A DC motor is rated at the

voltage it is most efficient at running. If you apply too few volts, it just wont work.

If you apply too much, it will overheat and the coils will melt. So the general rule is, try

to apply as close to the rated voltage of the motor as you can. Also, although a 24V motor 

42

Page 43: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 43/47

might be stronger, do you really want your robot to carry a 24V battery (which is heavier 

and bigger) around? So a standard recommendation is do not surpass 12V motors unless

you really need the torque.

43

Page 44: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 44/47

2.Stepper Motors

  FIG5.2:Steeper Motor 

Stepper Motors work under a very similar principle to DC motors, except they

have many coils instead of just one. So to operate a stepper motor, one must

activate these different coils in particular patterns to generate motor rotation. So

stepper motors need to be sent patterned commands to rotate. These commands

are sent as high and low logic over several lines, and must be pulsed in a

 particular order and combination. Steppers are often used because each 'step,'

separated by a set step angle, can be counted and used for feedback control. For 

example, a 10 degree step angle stepper motor would require 36 commands to

rotate 360 degrees. However external torque can force movement to a different

step, invalidating feedback. Therefore external torque must never exceed the

holding torque of a stepper.

44

Page 45: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 45/47

Notes on Stepper Motors

• Stepper motors can be easily found in any 3.5" disk drive

• Require special stepper motor controllers

• Have a set resolution, higher resolutions mean higher accuracy but lower holding

torque

• If torque applied to stepper is greater than holding torque, stepper will lose

accurate position measurements

Voltage 

• Polarized (current cannot be reversed)

• Typically from 5-12V, but can range to extremes in special application motors

• Higher voltages generally mean more torque, but also require more power 

• Steppers can run above or below rated voltage (to meet other design

requirements)

• Most efficient at rated voltage

45

Page 46: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 46/47

Conclusion

An engineer must have a good practical as well as theoretical knowledge. He must be

technically sound as book knowledge is incomplete.

The technical training was an educative as well as interactive. We learned how to make

the people learn. Technical lectures presented by the professional technicians related to

topics like embedded system, Assembly language were really interesting and healthy to

learn the industrial trends. The additional activities such as a session on Aptitude

questions and presentations related to the topics provided the chance for overall

development of an engineer. It made us learn about the importance of teamwork.

46

Page 47: Embedded Systems Trainin

8/3/2019 Embedded Systems Trainin

http://slidepdf.com/reader/full/embedded-systems-trainin 47/47

Bibliography

• http://www.wikipedia.com

• http://www.epanorma.net

• http://www.electronicsteacher.com

• Embedded Systems – Muhammad Ali Mazidi


Recommended