Anda di halaman 1dari 85




An Embedded System is a combination of computer hardware and software, and

perhaps additional mechanical or other parts, designed to perform a specific function. An
embedded system is a microcontroller-based, software driven, reliable, real-time control
system, autonomous, or human or network interactive, operating on diverse physical
variables and in diverse environments and sold into a competitive and cost conscious
market. An embedded system is not a computer system that is used primarily for
processing, not a software system on PC or UNIX, not a traditional business or scientific
application. High-end embedded & lower end embedded systems. High-end embedded
system - Generally 32, 64 Bit Controllers used with OS. Examples Personal Digital
Assistant and Mobile phones etc .Lower end embedded systems - Generally 8,16 Bit
Controllers used with an minimal operating systems and hardware layout designed for the
specific purpose.
An embedded system is a special-purpose system in which the computer is
completely encapsulated by or dedicated to the device or system it controls. Unlike a
general-purpose computer, such as a personal computer, an embedded system performs
one or a few pre-defined tasks, usually with very specific requirements. Since the system
is dedicated to specific tasks, design engineers can optimize it, reducing the size and cost
of the product.
Embedded systems are often mass-produced, benefiting from economies of
scale.Personal digital assistants (PDAs) or handheld computers are generally considered
embedded devices because of the nature of their hardware design, even though they are
more expandable in software terms. This line of definition continues to blur as devices
expand.Physically, embedded systems range from portable devices such as digital
watches and MP3 players, to large stationary installations like traffic lights, factory
controllers, or the systems controlling nuclear power plants.
In terms of complexity embedded systems can range from very simple with a
single microcontroller chip, to very complex with multiple units, peripherals and
networks mounted inside a large chassis or enclosure.

Nigama engineering college Page 1


Figure 1.1. Embedded system design calls


Figure 1.2. V Diagram

Nigama engineering college Page 2


An embedded system is any computer system hidden inside a product other than a
• They will encounter a number of difficulties when writing embedded system
software in addition to those we encounter when we write applications.
– Throughput – Our system may need to handle a lot of data in a short
period of time.
– Response–Our system may need to react to events quickly.
– Testability–Setting up equipment to test embedded software can be
– Debugability–Without a screen or a keyboard, finding out what the
software is doing wrong (other than not working) is a troublesome
– Reliability – embedded systems must be able to handle any situation
without human intervention.
– Memory space – Memory is limited on embedded systems, and you must
make the software and the data fit into whatever memory exists.
– Program installation – you will need special tools to get your software into
embedded systems.
– Power consumption – Portable systems must run on battery power, and the
software in these systems must conserve power.
– Processor hogs – computing that requires large amounts of CPU time can
complicate the response problem.
– Cost – Reducing the cost of the hardware is a concern in many embedded
system projects; software often operates on hardware that is barely
adequate for the job.
• Embedded systems have a microprocessor/ microcontroller and a memory. Some
have a serial port or a network connection. They usually do not have keyboards,
screens or disk drives.

Nigama engineering college Page 3


Military and aerospace embedded software applications:

1) Communication Applications.
2) Industrial automation and process control software.
3) Mastering the complexity of applications.
4) Reduction of product design time.
5) Real time processing of ever increasing amounts of data.
6) Intelligent, autonomous sensors.

 Real Time Systems.
 RTS is one which has to respond to events within a specified deadline.
 A right answer after the dead line is a wrong answer.


 Hard Real Time Systems
 Soft Real Time System


 "Hard" real-time systems have very narrow response time.
 Example: Nuclear power system, Cardiac pacemaker.


 "Soft" real-time systems have reduced constrains on "lateness" but still must
operate very quickly and repeatable.
 Example: Railway reservation system – takes a few extra seconds the data remains


There are many examples in our daily life that uses embedded systems.some of
those are:
 Automatic teller machines (ATMs)
 Avionics, such as inertial guidance systems, flight control hardware/software
and other integrated systems in aircraft and missiles
 Cellular telephones and telephone switches
 engine controllers and antilock brake controllers for automobiles

Nigama engineering college Page 4

 Home automation products, such as thermostats, air conditioners, sprinklers,
and security monitoring systems
 Handheld calculators
 Handheld computers
 Household appliances, including microwave ovens, washing machines,
television sets, DVD players and recorders
 Medical equipment
 Personal digital assistant
 Videogame consoles
 Computer peripherals such as routers and printers
 Industrial controllers for remote machine operation.


In the earliest years of computers in the 1940s, computers were sometimes

dedicated to a single task, but were too large to be considered "embedded". Over time
however, the concept of programmable controllers developed from a mix of computer
technology, solid state devices, and traditional electromechanical sequences.
The first recognizably modern embedded system was the Apollo Guidance
Computer, developed by Charles Stark Draper at the MIT Instrumentation Laboratory. 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 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. This program alone reduced
prices on quad nand gate ICs from $1000/each to $3/each, permitting their use in
commercial products.
Since these early applications in the 1960s, embedded systems have come down in
price. There has also been an enormous rise in processing power and functionality.

Nigama engineering college Page 5

For example the first microprocessor was the Intel 4004, which found its way into
calculators and other small systems, but required external memory and support chips.
In 1978 National Engineering Manufacturers Association released the standard for
a programmable microcontroller. The definition was an almost any computer-based
controller. They included single board computers, numerical controllers, and sequential
controllers in order to perfom event-based instructions.
By the mid-1980s, many of the previously external system components had been
integrated into the same chip as the processor, resulting in integrated circuits called
microcontrollers, and widespread use of embedded systems became feasible.


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.An embedded system is not always a separate block - very often it is physically
built-in to the device it is controlling
The software written for embedded systems is often called firmware, and is stored
in read-only memory or Flash memory chips rather than a disk drive. It often runs with
limited computer hardware resources: small or no keyboard, screen, and little memory.


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.


Simple embedded devices use buttons, LEDs, and small character- or digit-only
displays, often with a simple menu system.

Nigama engineering college Page 6

A full graphical screen, with touch sensing or screen-edge buttons provides
flexibility while minimizing space used: the meaning of the buttons can change with the
screen, and selection involves the natural behavior of pointing at what's desired.Handheld
systems often have a screen with a "joystick button" for a pointing device.
The rise of the World Wide Web has given embedded designers another quite
different option: providing a web page interface over a network connection. This avoids
the cost of a sophisticated display, yet provides complex input and display capabilities
when needed, on another computer. This is successful for remote, permanently installed
equipment. In particular, routers take advantage of this ability.


Embedded processors can be broken into two distinct categories: microprocessors

(μP) and micro controllers (μC). Micro controllers have built-in peripherals on the chip,
reducing size of the system.
There are many different CPU architectures used in embedded designs such as
ARM, MIPS, Coldfire/68k, PowerPC, x86, PIC, 8051, Atmel AVR, Renesas H8, SH,
V850, FR-V, M32R, Z80, Z8, etc. This in contrast to the desktop computer market, which
is currently limited to just a few competing architectures.
PC/104 and PC/104+ are a typical base for small, low-volume embedded and
rugged system design. These often use DOS, Linux, NetBSD, or an embedded real-time
operating system such as QNX or VxWorks.
A common configuration for very-high-volume embedded systems is the system
on a chip (SoC), an application-specific integrated circuit (ASIC), for which the CPU
core was purchased and added as part of the chip design. A related scheme is to use a
field-programmable gate array (FPGA), and program it with all the logic, including the


Embedded Systems talk with the outside world via peripherals, such as:

 Serial Communication Interfaces (SCI): RS-232, RS-422, RS-485 etc

 Synchronous Serial Communication Interface: I2C, JTAG, SPI, SSC and

Nigama engineering college Page 7

 Universal Serial Bus (USB)
 Networks: Controller Area Network, LonWorks, etc .
 Timers: PLL(s), Capture/Compare and Time Processing Units .
 Discrete IO: aka General Purpose Input Output (GPIO) .

1.13 TOOLS

 As for other software, embedded system designers use compilers, assemblers,

and debuggers to develop embedded system software. However, they may also
use some more specific tools:
 An in-circuit emulator (ICE) is a hardware device that replaces or plugs into the
microprocessor, and provides facilities to quickly load and debug experimental
code in the system.
 Utilities to add a checksum or CRC to a program, so the embedded system can
check if the program is valid.
 For systems using digital signal processing, developers may use a math
workbench such as MathCad or Mathematica to simulate the mathematics.
 Custom compilers and linkers may be used to improve optimization for the
particular hardware.
 An embedded system may have its own special language or design tool, or add
enhancements to an existing language.
Software Tools Can Come From Several Sources

 Software companies that specialize in the embedded market

 Ported from the GNU software development tools
 Sometimes, development tools for a personal computer can be used if the
embedded processor is a close relative to a common PC processor.


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.

Nigama engineering college Page 8

For low-volume or prototype embedded systems, general purpose computers may
be adapted by limiting the programs or by replacing the operating system with a real-time
operating system.


Embedded Debugging may be performed at different levels, depending on the

facilities available, ranging from assembly- or source-level debugging with an in-circuit
emulator or in-circuit debugger, to output from serial debug ports or JTAG/Nexus
interfaces, to an emulated environment running on a personal computer.As the
complexity of embedded systems grows, higher level tools and operating systems are
migrating into machinery where it makes sense.
For example, cell phones, personal digital assistants and other consumer
computers often need significant software that is purchased or provided by a person other
than the manufacturer of the electronics. In these systems, an open programming
environment such as Linux, Net BSD, OSGi or Embedded Java is required so that the
third-party software provider can sell to a large market.


Embedded systems often reside in machines that are expected to run continuously
for years without errors, and in some cases recover by themselves 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. Specific reliability issues may include:
1. The system cannot safely be shut down for repair, or it is too inaccessible to
repair. Solutions may involve subsystems with redundant spares that can be
switched over to, or software "limp modes" that provide partial function.
2. The system must be kept running for safety reasons. "Limp modes" are less
tolerable. Often backups are selected by an operator. Examples include aircraft
navigation, reactor control systems, safety-critical chemical factory controls, train
signals, engines on single-engine aircraft.

Nigama engineering college Page 9

3. The system will lose large amounts of money when shut down: Telephone
switches, factory controls, funds transfer,market making, automated sales service.


There are several different types of software architecture in common use.


In this design, the software simply has a loop. The loop calls subroutines, each of
which manages a part of the hardware or software.


Some embedded systems are predominantly interrupt controlled. This means that
tasks performed by the system are triggered by different kinds of events. An interrupt
could be generated for example by a timer in a predefined frequency, or by a serial port
controller receiving a byte.
These kinds of systems are used if event handlers need low latency and the event
handlers are short and simple.Usually these kinds of systems run a simple task in a main
loop also, but this task is not very sensitive to unexpected delays. The tasks performed in
the interrupt handlers should be kept short to keep the interrupt latency to a minimum.
Some times longer tasks are added to a queue structure in the interrupt handler to be
processed in the main loop later. This method brings the system close to a multitasking
kernel with discrete processes.


A no preemptive multitasking system is very similar to the simple control loop
scheme, except that the loop is hidden in an API. The programmer defines a series of
tasks, and each task gets its own environment to "run" in. Then, when a task is idle, it
calls an idle routine (usually called "pause", "wait", "yield", etc.).
The advantages and disadvantages are very similar to the control loop, except that
adding new software is easier, by simply writing a new task, or adding to the queue-

Nigama engineering college Page 10

In this type of system, a low-level piece of code switches between tasks based on
a timer. This is the level at which the system is generally considered to have an "operating
system", and introduces all the complexities of managing multiple tasks running
seemingly at the same time.
Any piece of task code can damage the data of another task; they must be
precisely separated. Access to shared data must be controlled by some synchronization
strategy, such as message queues, semaphores or a non-blocking synchronization scheme.
Because of these complexities, it is common for organizations to buy a real-time
operating system, allowing the application programmers to concentrate on device
functionality rather than operating system services.


 Navigation system using a GPS receiver.

 Communications systems for protocol conversion and VoIP.
 Mobile data applications using BREW–MP3 player and salary survey.
 Real-time systems using RTLinux–printing, messaging and more.
 Windows CE database applications –salary survey and energy meter reading;
 Networked information appliances using the HP Chai Appliance Platform–CRM,
location-based services and more.
 Mobile Java appliances–electronic city guide, Jini appliance control, ACRemote
 Windows XP embedded applications –air conditioner remote control, audio player
remote control, typing speed indicator, database application, electronic voting.

Nigama engineering college Page 11



• Microprocessors are single-chip CPUs used in microcomputers.

• Microcontrollers and microprocessors are different in three main aspects: hardware
architecture, applications, and instruction set features.
• Hardware architecture: A microprocessor is a single chip CPU while microcontroller
is a single IC contains a CPU and much of remaining circuitry of a complete computer.
(e.g., RAM, ROM, serial interface, parallel interface, timer, interrupt handling circuit).
• Applications: Microprocessors are commonly used as a CPU in computers while
microcontrollers are found in small, minimum component designs performing control
oriented activities.
• Microprocessor instruction sets are processing Intensive.
• Their instructions operate on nibbles, bytes, words, or even double words.
• Addressing modes provide access to large arrays of data using pointers and offsets.
• They have instructions to set and clear individual bits and perform bit operations.
• They have instructions for input/output operations, event timing, enabling and
setting priority levels for interrupts caused by external stimuli.
• Processing power of a microcontroller is much less than a microprocessor.


The 8052 microcontroller is the 8051's "big brother." It is a slightly more powerful
microcontroller, sporting a number of additional features which the developer may make
use of:
 256 bytes of Internal RAM (compared to 128 in the standard 8051).
 A third 16-bit timer, capable of a number of new operation modes and 16-bit
 Additional SFRs to support the functionality offered by the third timer.

Nigama engineering college Page 12


• Compatible with MCS-51 Products

• 8K Bytes of In-System Programmable (ISP) Flash Memory
- Endurance: 1000 Write/Erase Cycles
• 4.0V to 5.5V Operating Range
• Fully Static Operation: 0 Hz to 33 MHz
• Three-level Program Memory Lock
• 256K Internal RAM
• 32 Programmable I/O Lines
• 3 16-bit Timer/Counters
• Eight Interrupt Sources
• Full Duplex UART Serial Channel
• Low-power Idle and Power-down Modes
• Interrupt Recovery from Power-down Mode
• Watchdog Timer
• Dual Data Pointer
• Power-off Flag


The AT89S52 is a low-power, high-performance CMOS 8-bit micro controller

with 8Kbytes of in-system programmable Flash memory. The device is
manufactured. Using Atmel’s high-density nonvolatile memory technology and is
compatible with the industry-standard 80C51 micro controller.
The on-chip Flash allows the program memory to be reprogrammed in-
system or by a conventional nonvolatile memory programmer. By combining a
versatile 8-bit CPU with in-system programmable flash one monolithic chip; the
Atmel AT89S52 is a powerful micro controller, which provides a highly flexible and
cost-effective solution to many embedded control applications.

Nigama engineering college Page 13

Fig 2.1 Architecture of 8052 microcontroller

Nigama engineering college Page 14


Fig.2.2. Pin Diagram of 8052 MC

The AT89S52 provides the following standard features: 8K bytes of Flash,

256 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit
timer/counters, full duplex serial port, on-chip oscillator, and clock circuitry. In
addition, the AT89S52 is designed with static logic for perationdown to zero
frequency and supports two software selectable power saving modes. The Idle Mode
stops the CPU while allowing the RAM timer/counters, serial port, and interrupt
system to continue functioning. The Power-down mode saves the RAM contents but
freezes the oscillator, disabling all other chip functions until the next interrupt Or
hardware reset. It consists of the following pins:

VCC - Supply voltage.

GND - Ground.

Nigama engineering college Page 15


Port 0 is an 8-bit open drain bi-directional I/O port. As an output port, each
pin can sink eight TTL inputs. When 1sare written to port 0 pins, the pins can be used
as high impedance inputs. Port 0 can also be configured to be the multiplexed low
order address/data bus during accesses to external program and data memory. In this
mode, P0 has internal pull-ups. Port 0 also receives the code bytes during Flash
programming and outputs the code bytes during program verification. External pull-
ups are required during program verification


Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 Output
buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are
pulled high by the internal pull-ups and can be used as inputs. In addition, P1.0 and P1.1
can be configured to be the timer/counter 2 external count input. (P1.0/T2) and the
timer/counter 2 trigger input P1.1/T2EX), respectively, as shown in the following table.
Port 1 also receives the low-order address bytes during Flash programming and

Fig 2.3. PORT 1 Functions


Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2
output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins,
they are pulled high by the internal pull-ups and can be used as inputs. Port 2 emits
the high-order address byte during fetches from external program memory and during
accesses to external data memory that use 16-bit addresses (MOVX @DPTR).

Nigama engineering college Page 16

In this application, Port 2 uses strong internal pull-ups when emitting 1s.
During accesses to external data memory that use 8-bit addresses (MOVX @ RI),
Port 2emits the contents of the P2 Special Function Register. Port 2 also receives the
high-order address bits and some control signals during Flash programming and


Port 3 is an 8-bit bi-directional I/O port with internal pullups.The Port 3 output
buffers can sink/source four TTL inputs.When 1s are write 1s are written to Port3 pins
they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3
pins that are externally being pulled low will source current (IIL) because of the pull ups.
Port 3 also serves the functions of various special features of the AT89S52, as shown in
the following table.Port 3 also receives some control signals for Flash programming and

Fig 2.4. Port 3 Functions


Reset input. A high on this pin for two machine cycles while the oscillator is
running resets the device.


Address Latch Enable (ALE) is an output pulse for latching the low byte of
the address during accesses to external memory.

Nigama engineering college Page 17

This pin is also the program pulse input (PROG) during Flash programming.
In normal operation, ALE is emitted at a constant rate of1/6 the oscillator frequency
and may be used for external timing or clocking purposes. Note, however, that one
ALE pulse is skipped during each access to external data Memory. If desired, ALE
operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE
is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly
pulled high. Setting the ALE-disable bit has no effect if the micro controller is in
external execution mode.


Program Store Enable (PSEN) is the read strobe to external program memory.
When the AT89S52 is executing code from external program memory, PSEN is
activated twice each machine cycle, except that two PSEN activations are skipped
during each access to external data memory.


External Access Enable. EA must be strapped to GND in order to enable the

device to fetch code from external program memory locations starting at 0000H up to
FFFFH.Note, however, that if lock bit 1 is programmed, EA will be internally latched
on reset. A should be strapped to VCC for internal program executions. This pin also
receives the 12-voltProgramming enables voltage (VPP) during Flash programming.


Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.


Output from the inverting oscillator amplifier.

Nigama engineering college Page 18


XTAL1 and XTAL2 are the input and output, respectively, of an inverting
amplifier that can be configured for use as an on-chip oscillator, as shown in Figure
1. Either a quartz crystal or ceramic resonator may be used. To drive the device from
an External clock source, XTAL2 should be left unconnected while XTAL1 is driven,
as shown in Figure 2.

Figure 2.5 Oscillator Connections



Special Function Registers (SFR s) 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 the user to set the serial baud rate,
control and access timers, and configure the 8051’s interrupt 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 8-bit (1-byte)
value and is the most versatile register.

Nigama engineering college Page 19


The “R” registers are a set of eight registers that are named R0, R1. Etc up to
R7. These registers are used as auxiliary registers in many operations.


The “B” register is very similar to the accumulator in the sense that it may
hold an 8-bit (1-byte) value. Two only uses the “B” register 8051 instructions: MUL
AB and DIV AB.


The Data pointer (DPTR) is the 8051’s only user accessible 16-bit (2Bytes)
register. The accumulator, “R” registers 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) is a 2-byte address, which tells the 8051 where the
next instruction to execute is found in memory. The stack pointer like all registers except
DPTR and PC may hold an 8-bit (1-Byte) value.


An“addressing mode” refers that you are addressing a given memory

location.In summary, the addressing modes are as follows, with an example of each:
Each of these addressing modes provides important flexibility.
Immediate Addressing MOV A, #20 H
Direct Addressing MOV A, 30 H
Indirect Addressing MOV A, @R0
Indexed Addressing
a. External Direct MOVX A, @DPTR
b. Code In direct MOVC A, @A+DPTR

Nigama engineering college Page 20

Immediate addressing is so named because the value to be stored in memory
immediately follows the operation code in memory. That is to say, the instruction
itself dictates what value will be stored in memory. For example, the instruction:
MOV A, #20H:
This instruction uses immediate Addressing because the accumulator will be
loaded with the value that immediately follows in this case 20(hexadecimal).
Immediate addressing is very fast since the value to be loaded is included in the
instruction. However, since the value to be loaded is fixed at compile-time it is not
very flexible.


Direct addressing is so named because the value to be stored in memory is

obtained by directly retrieving it from another memory location. This instruction will
read the data out of internal RAM address 30(hexadecimal) and store it in the
Accumulator. Direct addressing is generally fast since, although the value to be
loaded isn’t included in the instruction, it is quickly accessible since it is stored in the
8051’s internal RAM.
It is also much more flexible than Immediate Addressing since the value to
be loaded is whatever is found at the given address which may variable. Also it is
important to note that when using direct addressing any instruction that refers to an
address between 00h and 7Fh is referring to the SFR control registers that control the
8051 micro controller itself.


Indirect addressing is a very powerful addressing mode, which in many cases

provides an exceptional level of flexibility. Indirect addressing is also the only way to
access the extra 128 bytes of internal RAM found on the 8052. Indirect addressing
appears as follows: MOV A, @R0: This instruction causes the 8051 to analyze
Special Function Register (SFR) Memory:
Special Function Registers (SFRs) are areas of memory that control specific
functionality of the 8051 processor.

Nigama engineering college Page 21

For example, four SFRs permit access to the 8051’s 32 input/output lines.
Another SFR allows the user to set the serial baud rate, control and access timers, and
configure the 8051’s interrupt system.


Control and status bits are contained in registers T2CON and

T2MOD for Timer 2 . The register pair (RCAP2H , RCAP2L) are the Capture /
Reload registers for Timer 2 in 16-bit capture mode or 16-bit auto-reload
mode .


The individual interrupt enable bits are in the IE register. Two priorities
can be set for each of the six interrupt sources in the IP registers.

Fig 2.6. Interrupt Register bits Function

2.11 TIMER 2

Timer 2 is a 16-bit Timer / Counter that can operate as either a timer or an

event counter. The type of operation is selected by bit C/T2 in the SFR
T2CON . Timer 2 has three operating Modes : capture , auto-reload ( up or down
Counting ) , and baud rate generator . The modes are selected by bits in T2CON .
Timer 2 consists of two 8-bit registers , TH2 and TL2 . In the Timer function , the
TL2 register is incremented every machine cycle . Since a machine cycle consists
of 12 oscillator periods, the count rate is 1/12 of the oscillator frequency.In the
Counter function , the register is incremented in response to a 1-to-0 transition at
its corresponding external input pin , T2 .When the samples show a high in one
cycle and a low in the next cycle, the count is incremented .

Nigama engineering college Page 22


In the capture mode , two options are selected by bit EXEN2 in T2CON . If
EXEN2 = 0, Timer 2 is a 16-bit timer or counter which upon overflow sets bit
TF2 in T2CON . This bit can then be used to generate an interrupt . If EXEN2 =
1 , Timer 2 performs the same operation , but a 1-to-0 transition at external input
T2EX also causes the current value in TH2 and TL2 to be captured into
RCAP2H and RCAP2L , respectively.


Timer 2 can be programmed to count up or down when configured in its

16-bit auto-reload mode. This feature is invoked by the DCEN (Down Counter
Enable) bit located in the SFR T2MOD . Upon reset , the DCEN bit is set to 0
so that timer 2 will default to count up. When DCEN is set , Timer 2 can count
up or down , depending on the value of the T2EX pin . In this mode , two options
are selected by bit EXEN2 in T2CON . If EXEN2 = 0 , Timer 2 counts up to
0FFFFH and then sets the TF2 bit upon overflow .
If EXEN2 = 1 , a 16-bit reload can be triggered either by an overflow or
by a 1-to-0 transition at external input T2EX.


Timer 2 is selected as the baud rate generator by setting TCLK and/or

RCLK in T2CON . Note that the baud rates for transmit and receive can be
different if Timer 2 is used for the receiver or transmitter and Timer 1 is used
for the other function .The baud rates in Modes 1 and 3 aredetermined by Timer
2’s overflow rate according to the following equation .
Modes 1 and 3 Baud Rates =Timer 2 Overflow Rate .
The timer operation is different for Timer 2 when it is used as a baud rate
generator .Normally ,as a timer , it increments every machine cycle (at 1/12 the
oscillator frequency).As a baud rate generator , however, it increments every state
time ( at 1/2 the oscillator frequency ) .

Nigama engineering college Page 23

2.15 TIMER 0

Timer 0 functions as either a timer or event counter in four modes of

operation . Timer 0 is controlled by the four lower bits of the TMOD register and
bits 0, 1, 4 and 5 of the TCON register.

 MODE 0 ( 13-BIT TIMER)

Mode 0 configures timer 0 as a 13-bit timer which is set up as an 8-
bit timer (TH0 register) with a modulo 32 prescaler implemented with the
lower five bits of the TL0 register . The upper three bits of TL0 register are
indeterminate and should be ignored . Prescaler overflow increments the TH0

 MODE 1 ( 16-BIT TIMER )

Mode 1 is the same as Mode 0, except that the Timer register is
being run with all 16 bits . Mode 1 configures timer 0 as a 16-bit timer with
the TH0 and TL0 registers connected in cascade . The selected input increments
the TL0 register .


Mode 2 configures timer 0 as an 8-bit timer ( TL0 register ) that
automatically reloads from the TH0 register . TL0 overflow sets TF0 flag in
the TCON register and reloads TL0 with the contents of TH0 , which is
preset by software .


Mode 3 configures timer 0 so that registers TL0 and TH0 operate as
separate 8-bit timers. This mode is provided for applications requiring an
additional 8-bit timer or counter .

2.16 TIMER - 1
Timer 1 is identical to timer 0 , except for mode 3 , which is a hold-
count mode .

Nigama engineering college Page 24

 MODE 3 ( HALT )
Placing Timer 1 in mode 3 causes it to halt and hold its count . This
can be used to halt Timer 1 when TR1 run control bit is not available i.e. ,
when Timer 0 is in mode 3 .


The baud rate in Mode 0 is fixed. The baud rate in Mode 2

depends on the value of bit SMOD in Special Functio Register PCON. If
SMOD = 0 (which is its value on reset), the baud rate is 1/64 the oscillator
frequency . If SMOD = 1, the baud rate is 1/32 the oscillator frequency. In the
89S52 , the baud rates in Modes 1 and 3 are determined by the Timer 1
overflow rate. In case of Timer 2 , these baud rates can be determined by
Timer 1 , or by Timer 2 , or by both (one for transmit and the other for receive ).

2.18 TCON REGISTER : Timer/counter Control Register

Fig 2.7.Discription Of TCON Register

Nigama engineering college Page 25

2.19 TMOD REGISTER: Timer/Counter 0 and 1 Modes

Fig 2.8. Discription Of TMOD Register

Nigama engineering college Page 26



Bluetooth is a wireless protocol utilizing short-range communications technology

facilitating data transmission over short distances from fixed and/or mobile devices,
creating wireless personal area networks (PANs). The intent behind the development of
Bluetooth was the creation of a single digital wireless protocol, capable of connecting
multiple devices and overcoming issues arising from synchronization of these devices.
Bluetooth uses a very robust radio technology called frequency hopping spread
spectrum. It chops up the data being sent and transmits chunks of it on up to 75 different
frequencies. In its basic mode, the modulation is Gaussian frequency shift keying
It can achieve a gross data rate of 1 Mb/s. Bluetooth provides a way to connect
and exchange information between devices such as mobile phones, telephones, laptops,
personal computers, printers, GPS receivers, digital cameras, and video game consoles
over a secure, globally unlicensed Industrial, Scientific, and Medical (ISM) 2.4 GHz
short-range radio frequency bandwidth. The Bluetooth specifications are developed and
licensed by the Bluetooth Special Interest Group (SIG). The Bluetooth SIG consists of
companies in the areas of telecommunication, computing, networking, and consumer
Bluetooth is a standard and communications protocol primarily designed for low
power consumption, with a short range (power-class-dependent: 1 meter, 10 meters, 100
meters) based on low-cost transceiver microchips in each device. Bluetooth enables these
devices to communicate with each other when they are in range. The devices use a radio
communications system, so they do not have to be in line of sight of each other, and can
even be in other rooms, as long as the received transmission is powerful enough.
Bluetooth device class indicates the type of device and the supported services of which
the information is transmitted during the discovery process.

Maximum Permitted Power Range

mW(dBm) (approximate)

Nigama engineering college Page 27

Class 1 100 mW (20 dBm) ~100 meters

Class 2 2.5 mW (4 dBm) ~10 meters

Class 3 1 mW (0 dBm) ~1 meter

Fig 3.1. Table For Different Classes

In most cases the effective range of class 2 devices is extended if they connect to a
class 1 transceiver, compared to pure class 2 network. This is accomplished by the higher
sensitivity and transmission power of Class 1 devices.

Version Data Rate

Version 1.2 1 Mbit/s

Version 2.0 + EDR 3 Mbit/s

WiMedia Alliance
53 – 480 Mbit/s

Fig 3.2. Different Versions Of BT


In order to use Bluetooth, a device must be compatible with certain Bluetooth

profiles. These define the possible applications and uses of the technology.

Nigama engineering college Page 28


Bluetooth and Wi-Fi have different applications in today's offices, homes, and on
the move: setting up networks, printing, or transferring presentations and files from PDAs
to computers. Both are versions of unlicensed wireless technology. Wi-fi differs from
bluetooth in that it provides higher throughput and covers greater distances, but requires
more expensive hardware and may present higher power consumption.
They use the same frequency range, but employ different modulation techniques.
While Bluetooth is a replacement for cabling in a variety of small-scale applications, Wi-
Fi is a replacement for cabling for general local area network access. Bluetooth can be
taken as replacement for USB or any other serial cable link, whereas Wi-Fi is wireless
Ethernet communications according to the protocol architectures of IEEE 802.3 with
TCP/IP. Both standards are operating at a specified bandwidth not identical with that of
other networking standards; the mechanical plug compatibility problem known with
cables is replaced by the compatibility requirement for an air interface and a protocol


Bluetooth exists in many products, such as telephones, printers, modems and

headsets. The technology is useful when transferring information between two or more
devices that are near each other in low-bandwidth situations. Bluetooth is commonly used
to transfer sound data with telephones (i.e. with a Bluetooth headset) or byte data with
hand-held computers (transferring files).
Bluetooth protocols simplify the discovery and setup of services between devices.
Bluetooth devices can advertise all of the services they provide. This makes using
services easier because more of the security, network address and permission
configuration can be automated than with many other network types.


Apple has supported Bluetooth since Mac OS X v10.2 which was released in
2002. For Microsoft platforms, Windows XP Service Pack 2 and later releases have native
support for Bluetooth. Linux has two popular Bluetooth stacks, BlueZ and Affix. The
Nigama engineering college Page 29
BlueZ stack is included with most Linux kernels and it was originally developed by
Qualcomm. The Affix stack was developed by Nokia. FreeBSD features Bluetooth
support since its 5.0 release. NetBSD features Bluetooth support since its 4.0 release. Its
Bluetooth stack has been ported to OpenBSD as well.


A mobile phone that is Bluetooth enabled is able to pair with many devices. To
ensure the broadest support of feature functionality together with legacy device support.
The OMTP forum has recently published a recommendations paper, entitled "Bluetooth
Local Connectivity", see external links below to download this paper. This publication
recommends two classes, Basic and Advanced, with requirements that cover imaging,
printing, stereo audio and in car usage.

3.1.6 BLUETOOTH 1.0 AND 1.0B

Versions 1.0 and 1.0B had many problems, and manufacturers had difficulty
making their products interoperable. Versions 1.0 and 1.0B also included mandatory
Bluetooth hardware device address (BD_ADDR) transmission in the Connecting process
(rendering anonymity impossible at the protocol level), which was a major setback for
certain services planned for use in Bluetooth environments.

3.1.7 BLUETOOTH 1.1

 Ratified as IEEE Standard 802.15.1-2002.
 Many errors found in the 1.0B specifications were fixed.
 Added support for non-encrypted channels.
 Received Signal Strength Indicator (RSSI).

3.1.8 BLUETOOTH 1.2

This version is backward-compatible with 1.1 and the major enhancements include
the following:
 Faster Connection and Discovery

Nigama engineering college Page 30

 Adaptive frequency-hopping spread spectrum (AFH), which improves resistance
to radio frequency interference by avoiding the use of crowded frequencies in the
hopping sequence.
 Higher transmission speeds in practice, up to 721 kbit/s, as in 1.1.
 Extended Synchronous Connections (eSCO), which improve voice quality of
audio links by allowing retransmissions of corrupted packets, and may optionally
increase audio latency to provide better support for concurrent data transfer.
 Host Controller Interface (HCI) support for three-wire UART.
 Ratified as IEEE Standard 802.15.1-2005.

3.1.9 BLUETOOTH 2.0

This version of the Bluetooth specification was released on November 10, 2004. It
is backward-compatible with the previous version 1.1. The main difference is the
introduction of an Enhanced Data Rate (EDR) for faster data transfer. The nominal rate of
EDR is about 3 megabits per second, although the practical data transfer rate is 2.1
megabits per second. The additional throughput is obtained by using a different radio
technology for transmission of the data. Standard, or Basic Rate, transmission uses
Gaussian Frequency Shift Keying (GFSK) modulation of the radio signal; EDR uses a
combination of GFSK and Phase Shift Keying (PSK) modulation.
According to the 2.0 specification, EDR provides the following benefits:
 Three times faster transmission speed — up to 10 times (2.1 Mbit/s) in some
 Reduced complexity of multiple simultaneous connections due to additional
 Lower power consumption through a reduced duty cycle. The Bluetooth Special
Interest Group (SIG) published the specification as "Bluetooth 2.0 + EDR" which
implies that EDR is an optional feature.

Aside from EDR, there are other minor improvements to the 2.0 specification, and
products may claim compliance to "Bluetooth 2.0" without supporting the higher data
rate. At least one commercial device, the HTC TyTN pocket PC phone, states "Bluetooth
2.0 without EDR" on its data sheet.

Nigama engineering college Page 31

3.1.10 BLUETOOTH 2.1

Bluetooth Core Specification Version 2.1 is fully backward-compatible with 1.1, and
was adopted by the Bluetooth SIG on July 26, 2007. This specification includes the
following features:
 Extended inquiry response: provides more information during the inquiry
procedure to allow better filtering of devices before connection. This information
includes the name of the device, a list of services the device supports, as well as
other information like the time of day, and pairing information.
 Sniff subrating: reduces the power consumption when devices are in the sniff
low-power mode, especially on links with asymmetric data flows. Human
interface devices (HID) are expected to benefit the most, with mouse and
keyboard devices increasing the battery life by a factor of 3 to 10. It lets devices
decide how long they will wait before sending keep alive messages to one another.
Previous Bluetooth implementations featured keep alive message frequencies of
up to several times per second. In contrast, the 2.1 specification allows pairs of
devices to negotiate this value between them to as infrequently as once every 5 or
10 seconds.
 Encryption Pause Resume: enables an encryption key to be refreshed, enabling
much stronger encryption for connections that stay up for longer than 23.3 hours
(one Bluetooth day).
 Secure Simple Pairing: radically improves the pairing experience for Bluetooth
devices, while increasing the use and strength of security. It is expected that this
feature will significantly increase the use of Bluetooth.
 Near Field Communication (NFC) cooperation: automatic creation of secure
Bluetooth connections when NFC radio interface is also available. This
functionality is part of the Secure Simple Pairing where NFC is one way of
exchanging pairing information.
 For example, a headset should be paired with a Bluetooth 2.1 phone including
NFC just by bringing the two devices close to each other (a few centimeters).
Another example is automatic uploading of photos from a mobile phone or camera
to a digital picture frame just by bringing the phone or camera close to the frame.


Nigama engineering college Page 32

On 28 March 2006, the Bluetooth Special Interest Group announced its selection
of the WiMedia Alliance Multi-Band Orthogonal Frequency Division Multiplexing (MB-
OFDM) version of UWB for integration with current Bluetooth wireless technology.
UWB integration will create a version of Bluetooth wireless technology with a
high-speed/high-data-rate option. This new version of Bluetooth technology will meet the
high-speed demands of synchronizing and transferring large amounts of data, as well as
enabling high-quality video and audio applications for portable devices, multi-media
projectors and television sets, and wireless VOIP.
At the same time, Bluetooth technology will continue catering to the needs of very
low power applications such as mouse, keyboards, and mono headsets, enabling devices
to select the most appropriate physical radio for the application requirements, thereby
offering the best of both worlds.

3.1.12 BLUETOOTH 3.0

The next version of Bluetooth after v2.1, code-named Seattle (the version number
of which is TBD) has many of the same features, but is most notable for plans to adopt
ultra-wideband (UWB) radio technology. This will allow Bluetooth use over UWB radio,
enabling very fast data transfers of up to 480 Mbit/s, while building on the very low-
power idle modes of Bluetooth.


“Bluetooth is defined as a layer protocol architecture consisting of core protocols,

cable replacement protocols, telephony control protocols, and adopted protocols”.
Bluetooth’s core protocols form a five-layer stack, consisting of the following:
Bluetooth Radio – specifics details of the air interface, including frequency,
frequency hopping, modulation scheme, and transmission power.
Baseband – concerned with connection establishment within a piconet,
addressing, packet format, timing, and power control.
Link Manager Protocol (LMP) – Establishes the link setup between Bluetooth
devices and manages ongoing links, including security aspects (e.g. authentication and
encryption), and control and negotiation of baseband packet size

Nigama engineering college Page 33

Logical Link Control and Adaptation Protocol (L2CAP) – adapts the upper-
layer protocols to the baseband layer, providing both connectionless and connection-
oriented services.
Service Discovery Protocol (SDP) – handles device information, services, and
queries for service characteristics between two or more Bluetooth devices.
Cable replacement protocol: Radio frequency communications (RFCOMM) is
the cable replacement protocol used to create a virtual serial port used to make
replacement of cable technologies transparent through minimal modification of existing
devices. RFCOMM provides for binary data transport and emulates EIA-232 (formerly
RS-232) control signals over the Bluetooth baseband layer.
Telephony control protocol-binary (TCS BIN) is the bit-oriented protocol that
defines the call control signaling for the establishment of voice and data calls between
Bluetooth devices. Additionally, “TCS BIN defines mobility management procedures for
handling groups of Bluetooth TCS devices”
Adapted protocols are defined by other standards-making organizations and
incorporated into Bluetooth’s protocol stack., allowing Bluetooth to create protocols only
when necessary. The adopted protocols include:
Point-to-Point Protocol (PPP) – Internet standard protocol for transporting IP
datagrams over a point-to-point link.
TCP/IP/UDP – Foundation Protocols for TCP/IP protocol suite.
Object Exchange Protocol (OBEX) – Session-layer protocol for the exchange of
objects, providing a model for object and operation representation.
Wireless Application Environment / Wireless Application Protocol
(WAE/WAP) – WAE specifies an application framework for wireless devices and WAP is
an open standard to provide mobile users access to telephony and information services.


A master Bluetooth device can communicate with up to seven devices. This

network group of up to eight devices is called a piconet.A piconet is an ad-hoc computer
network, using Bluetooth technology protocols to allow one master device to interconnect

Nigama engineering college Page 34

with up to seven active devices. Up to 255 further devices can be inactive, or parked,
which the master device can bring into active status at any time.
At any given time, data can be transferred between the master and one other
device, however, the devices can switch roles and the slave can become the master at any
time. The master switches rapidly from one device to another in a round-robin fashion.
(Simultaneous transmission from the master to multiple other devices is possible, but not
used much.) Bluetooth specification allows connecting two or more piconets together to
form a scatternet, with some devices acting as a bridge by simultaneously playing the
master role and the slave role in one piconet.
Many USB Bluetooth adapters are available, some of which also include an IrDA
adapter. Older (pre-2003) Bluetooth adapters, however, have limited services, offering
only the Bluetooth Enumerator and a less-powerful Bluetooth Radio incarnation. Such
devices can link computers with Bluetooth, but they do not offer much in the way of
services that modern adapters do.


Any Bluetooth device will transmit the following information on demand:

 Device name.
 Device class.
 List of services.
 Technical information, for example, device features, manufacturer, Bluetooth
specification used, clock offset.
Any device may perform an inquiry to find other devices to connect to, and any
device can be configured to respond to such inquiries. However, if the device trying to
connect knows the address of the device, it always responds to direct connection requests
and transmits the information shown in the list above if requested.
Use of device services may require pairing or acceptance by its owner, but the
connection itself can be initiated by any device and held until it goes out of range.
Some devices can be connected to only one device at a time, and connecting to them
prevents them from connecting to other devices and appearing in inquiries until they
disconnect from the other device. Every device has a unique 48-bit address. However
these addresses are generally not shown in inquiries. Instead, friendly Bluetooth names
are used, which can be set by the user. This name appears when another user scans for

Nigama engineering college Page 35

devices and in lists of paired devices.Most phones have the Bluetooth name set to the
manufacturer and model of the phone by default. Most phones and laptops show only the
Bluetooth names and special programs that are required to get additional information
about remote devices. This can be confusing as, for example, there could be several
phones in range named T610 (see Bluejacking).

3.1.17 PAIRING

Pairs of devices may establish a trusted relationship by learning (by user input) a
shared secret known as a passkey. A device that wants to communicate only with a trusted
device can cryptographically authenticate the identity of the other device. Trusted devices
may also encrypt the data that they exchange over the airwaves so that no one can listen
in the encryption can, however, be turned off, and passkeys are stored on the device file
system, not on the Bluetooth chip itself. Since the Bluetooth address is permanent, a
pairing is preserved, even if the Bluetooth name is changed. Pairs can be deleted at any
time by either device. Devices generally require pairing or prompt the owner before they
allow a remote device to use any or most of their services. Some devices, such as mobile
phones, usually accept OBEX business cards and notes without any pairing or prompts.
Certain printers and access points allow any device to use its services by default,
much like unsecured Wi-Fi networks. Pairing algorithms are sometimes manufacturer-
specific for transmitters and receivers used in applications such as music and
Bluetooth 2.1 has an optional "touch-to-pair" feature based on NFC. By simply
bringing two devices into close range (around 10cm), pairing can securely take place
without entering a passkey or manual configuration.


The protocol operates in the license-free ISM band at 2.4-2.4835 GHz. To avoid
interfering with other protocols that use the 2.45 GHz band, the Bluetooth protocol
divides the band into 79 channels (each 1 MHz wide) and changes channels up to 1600
times per second.

Nigama engineering college Page 36

Implementations with versions 1.1 and 1.2 reach speeds of 723.1 kbit/s. Version
2.0 implementations feature Bluetooth Enhanced Data Rate (EDR) and reach 2.1 Mbit/s.
Technically, version 2.0 devices have a higher power consumption, but the three times
faster rate reduces the transmission times, effectively reducing power consumption to half
that of 1.x devices (assuming equal traffic load).

3.1.19 BLUE TOOTH WE USE:PARANI-ESD100/110/200/210

1) Output Interface UART, Compliant Bluetooth stack v1.2-improved AFH
(Adaptive Frequency Hoping), Fast connection.
2) Transmit Power - ESD100/110: Max. +18dBm ESD200/210: Max. +4dBm.
3) Receiving Sensitivity - ESD100/110: -88dBm (0.1%BER) ESD200/210: -80dBm
4) Antenna gain - Chip: 0dBi, Stub: +2dBi, Dipole: +3dBi, Patch: +9dBi.
5) Compact size - ESD100:27.5 x 30 x 14(mm)
ESD110: 27.5 x 27.7 x 14(mm)
ESD200/210:18 x 20 x 11.7 (mm).
6) Provides transparent RS232 serial cable replacement.
7) Supports Bluetooth Serial Port Profile.
8) Interoperability with PDA, laptops etc.
9) Built-in chip antenna included
10) Supports firmware upgrade via windows-based
Software (Parani Updater).
11) Working distance ( In an open field ):
Parani-ESD100: Class 1, Nom. 100 meters,Parani-ESD110: Class 1, Nom. 100
meters, up to 1000m using patch antenna. Parani-ESD200: Class 2, Nom.
30meters. Parani-ESD210: Class 2, Nom. 30meters, up to 300m using patch

Is OEM Bluetooth-Serial Module type product line based on Bluetooth

technology. Parani-ESD Series is designed for integration into user devices by on-board
installation. They are connected to the device via built-in UART interface and
communicate with other Bluetooth device.

Nigama engineering college Page 37

Parani-ESD Series enables RS232-based serial devices to communicate wirelessly
throughout the range of 30m ~300m (Parani- ESD210-Class 2) or 100m ~ 1000m (Parani-
ESD110-Class 1).
Parani-ESD100/200 has a built-in on-board antenna and Parani- ESD110/210 has
an antenna connector for connecting external antenna. Users can extend Bluetooth
communication range by connecting the external antenna to antenna connector.
Users may configure the Parani-ESD Series by using easy-to-use Windows-based
utility software or by using standard AT command set.


 RS232 cable replacement

 Wireless Factory monitoring
 Truck/Bus monitoring system
 PLC programming
 Car Diagnostics
 Wireless Printing
 Wireless POS system
 Wireless logistics
 Wireless machine (healthcare/industrial) monitoring

Pin Discription

Nigama engineering college Page 38

Fig.3.3 Pin Discription


 Wireless control of and communication between a mobile phone and a hands-free

headset. This was one of the earliest applications to become popular.
 Wireless networking between PCs in a confined space and where little bandwidth
is required.
 Wireless communications with PC input and output devices, the most common
being the mouse, keyboard and printer.
 Transfer of files between devices with OBEX.

 Transfer of contact details, calendar appointments, and reminders between devices

with OBEX.
 Replacement of traditional wired serial communications in test equipment, GPS
receivers, medical equipment, bar code scanners, and traffic control devices.
 For controls where infrared was traditionally used.
 Sending small advertisements from Bluetooth enabled advertising hoardings to
other, discoverable, Bluetooth devices.

Nigama engineering college Page 39

 Two seventh-generation game consoles, Nintendo's Wii and Sony's PlayStation 3
use Bluetooth for their respective wireless controllers.
 Dial-up internet access on personal computer or PDA using a data-capable mobile
phone as a modem.



Nigama engineering college Page 40

 Broadcast Channel: Enables Bluetooth information points. This will drive the
adoption of Bluetooth into mobile phones, and enable advertising models based
around users pulling information from the information points, and not based
around the object push model that is used in a limited way today.
 Topology Management: Enables the automatic configuration of the piconet
topologies especially in scatternet situations that are becoming more common
today. This should all be invisible to the users of the technology, while also
making the technology just work.
 Alternate MAC PHY: Enables the use of alternative MAC and PHY's for
transporting Bluetooth profile data. The Bluetooth Radio will still be used for
device discovery, initial connection and profile configuration, however when lots
of data needs to be sent, the high speed alternate MAC PHY's will be used to
transport the data. This means that the proven low power connection models of
Bluetooth are used when the system is idle, and the low power per bit radios are
used when lots of data needs to be sent.
 QoS improvements: Enable audio and video data to be transmitted at a higher
quality, especially when best effort traffic is being transmitted in the same piconet.


DC motor is designed to run on DC electric power. Two examples of pure DC

designs are Michael Faraday's homopolar motor (which is uncommon), and the ball
bearin motor, which is (so far) a novelty. By far the most common DC motor types are the
brushed and brushless types, which use internal and external commutation respectively to
create an oscillating AC current from the DC source -- so they are not purely DC
machines in a strict sense.


1. Brushed DC Motors
2. Brushless DC motors
3. Coreless DC motors


Nigama engineering college Page 41

The classic DC motor design generates an oscillating current in a wound rotor
with a split ring commutator, and either a wound or permanent magnet stator. A rotor
consists of a coil wound around a rotor which is then powered by any type of battery.
Many of the limitations of the classic commutator DC motor are due to the
need for brushes to press against the commutator. This creates friction.
At higher speeds, brushes have increasing difficulty in maintaining contact.
Brushes may bounce off the irregularities in the commutator surface, creating sparks.
This limits the maximum speed of the machine. The current density per unit area of
the brushes limits the output of the motor. The imperfect electric contact also causes
electrical noise. Brushes eventually wear out and require replacement, and the
commutator itself is subject to wear and maintenance. The commutator assembly on a
large machine is a costly element, requiring precision assembly of many parts. there
are three types of dc motor 1. dc series motor 2. dc shunt motor 3. dc compound
motor - these are also two type a. cummulative compound b. deffercial compound.


Some of the problems of the brushed DC motor are eliminated in the brushless
design. In this motor, the mechanical "rotating switch" or commutator/brushgear
assembly is replaced by an external electronic switch synchronised to the rotor's
position. Brushless motors are typically 85-90% efficient, whereas DC motors with
brushgear are typically 75-80% efficient. Midway between ordinary DC motors and
stepper motors lies the realm of the brushless DC motor.
Built in a fashion very similar to stepper motors, these often use a permanent
magnet external rotor, three phases of driving coils, one or more Hall effect sensors to
sense the position of the rotor, and the associated drive electronics. The coils are
activated, one phase after the other, by the drive electronics as cued by the signals
from the Hall effect sensors. In effect, they act as three-phase synchronous motors
containing their own variable-frequency drive electronics. A specialized class of
brushless DC motor controllers utilize EMF feedback through the main phase
connections instead of Hall effect sensors to determine position and velocity. These
motors are used extensively in electric radio-controlled vehicles. When configured
with the magnets on the outside, these are referred to by modelists as outrunner

Nigama engineering college Page 42

Brushless DC motors are commonly used where precise speed control is
necessary, as in computer disk drives or in video cassette recorders, the spindles
within CD, CD-ROM (etc.) drives.
They have several advantages over conventional motors:
 Compared to AC fans using shaded-pole motors, they are very efficient, running
much cooler than the equivalent AC motors. This cool operation leads to much-
improved life of the fan's bearings.
 Without a commutator to wear out, the life of a DC brushless motor can be
significantly longer compared to a DC motor using brushes and a commutator.
Commutation also tends to cause a great deal of electrical and RF noise; without a
commutator or brushes, a brushless motor may be used in electrically sensitive
devices like audio equipment or computers.
 The same Hall effect sensors that provide the commutation can also provide a
convenient tachometer signal for closed-loop control (servo-controlled)
applications. In fans, the tachometer signal can be used to derive a "fan OK"
 The motor can be easily synchronized to an internal or external clock, leading to
precise speed control.
 Brushless motors have no chance of sparking, unlike brushed motors, making
them better suited to environments with volatile chemicals and fuels. Also,
sparking generates ozone which can accumulate in poorly ventilated buildings
risking harm to occupants' health.
 Brushless motors are usually used in small equipment such as computers and are
generally used to get rid of unwanted heat.
 They are also very quiet motors which is an advantage if being used in equipment
that is affected by vibrations.. Larger brushless motors up to about 100 kW rating
are used in electric vehicles. They also find significant use in high-performance
electric model aircraft.


Nigama engineering college Page 43

Nothing in the design of any of the motors described above requires that the
iron (steel) portions of the rotor actually rotate; torque is exerted only on the windings
of the electromagnets.
Taking advantage of this fact is the coreless DC motor, a specialized form of a
brush or brushless DC motor. Optimized for rapid acceleration, these motors have a
rotor that is constructed without any iron core.
The rotor can take the form of a winding-filled cylinder inside the stator
magnets, a basket surrounding the stator magnets, or a flat pancake (possibly formed
on a printed wiring board) running between upper and lower stator magnets. The
windings are typically stabilized by being impregnated with Electrical epoxy potting
systems. Filled epoxies that have moderate mixed viscosity and a long gel time. These
systems are highlighted by low shrinkage and low exotherm. Typically UL 1446
recognized as a potting compound for use up to 180C (Class H) UL File No. E
Because the rotor is much lighter in weight (mass) than a conventional rotor
formed from copper windings on steel laminations, the rotor can accelerate much
more rapidly, often achieving a mechanical time constant under 1 ms. This is
especially true if the windings use aluminum rather than the heavier copper. But
because there is no metal mass in the rotor to act as a heat sink, even small coreless
motors must often be cooled by forced air.
These motors were commonly used to drive the capstan(s) of magnetic tape
drives and are still widely used in high-performance servo-controlled systems, like
radio-controlled vehicles/aircraft, humanoid robotic systems, industrial automation,
medical devices, etc.


The L293 and L293D are quadruple high-current half-H drivers. The L293 is
designed to provide bidirectional drive currents of up to 1 A at voltages from 4.5 V to 36
V. The L293D is designed to provide bidirectional drive currents of up to 600-mA at
voltages from 4.5 V to 36 V. Both devices are designed to drive inductive loads such as
relays, solenoids, dc and bipolar stepping motors, as well as other high-current/high-
voltage loads in positive-supply applications. All inputs are TTL compatible.

Nigama engineering college Page 44

Each output is a complete totem-pole drive circuit, with a Darlington transistor sink and a
pseudo- Darlington source. Drivers are enabled in pairs, with drivers 1 and 2 enabled by
1,2EN and drivers 3 and 4 enabled by 3,4EN. When an enable input is high, the
associated drivers are enabled, and their outputs are active and in phase with their inputs.
When the enable input is low, those drivers are disabled, and their outputs are off
and in the high-impedance state. With the proper data inputs, each pair of drivers forms a
full-H (or bridge) reversible drive suitable for solenoid or motor applications.


 Featuring Unitrode L293 and L293D

Products Now From Texas Instruments
 Wide Supply-Voltage Range: 4.5 V to 36 V
 Separate Input-Logic Supply
 Internal ESD Protection
 Thermal Shutdown
 High-Noise-Immunity Inputs


Nigama engineering college Page 45

Fig 3.4 Pin Diagram Of L293 & L293D

On the L293, external high-speed output clamp diodes should be used for
inductive transient suppression. A VCC1 terminal, separate from VCC2, is provided for
the logic inputs to minimize device power dissipation. The L293and L293D are
characterized for operation from 0OC to 7OC.


Fig 3.5 block diagram of driver circuit


Fig 3.6. Logic Diagram

Nigama engineering college Page 46


 Audio
 Automotive
 Broadband
 Digital control
 Military
 Optical networking
 Security
 Telephony
 Video & Imaging
 Wire less

3.3 LCD (Liquid Crystal Display)

A liquid crystal display (LCD) is a thin, flat display device made of any number
of color or monochrome arrayed in front of a light source or reflector. Each pixel consists
of a column of liquid crystal molecules suspended between two transparent electrodes,
and two polarizing filters, the axes of polarity of which are perpendicular to each other.
Without the liquid crystals between them, light passing through one would be blocked by
the other. The liquid crystal twists the polarization of light entering one filter to allow it to
pass through the other.
A program must interact with the outside world using input and output devices
that communicate directly with a human being. One of the most common devices attached
to an controller is an LCD display. Some of the most common LCDs connected to the
contollers are 16X1, 16x2 and 20x2 displays. This means 16 characters per line by 1 line
16 characters per line by 2 lines and 20 characters per line by 2 lines, respectively.

Nigama engineering college Page 47

Many microcontroller devices use 'smart LCD' displays to output visual
information. LCD displays designed around LCD NT-C1611 module, are inexpensive,
easy to use, and it is even possible to produce a readout using the 5X7 dots plus cursor of
the display. They have a standard ASCII set of characters and mathematical symbols.
For an 8-bit data bus, the display requires a +5V supply plus 10 I/O lines (RS RW
D7 D6 D5 D4 D3 D2 D1 D0).

available. Line lengths of

8, 16,
20, 24,
32 and
ers are
Nigama engineering college Page 48
d, in
For a 4-bit data bus it only requires the supply lines plus 6 extra lines(RS RW D7
D6 D5 D4). When the LCD display is not enabled, data lines are tri-state and they do not
interfere with the operation of the microcontroller.


(1) Interface with either 4-bit or 8-bit microprocessor.

(2) Display data RAM
(3) 80x8 bits (80 characters).
(4) Character generator ROM
(5) 160 different 5 *7 dot-matrix character patterns.
(6) Character generator RAM
(7) 8 different user programmed 5 7 dot-matrix patterns.
(8).Display data RAM and character generator RAM may be
Accessed by the microprocessor.
(9) Numerous instructions
(10) Clear Display, Cursor Home, Display ON/OFF, Cursor ON/OFF,
Blink Character, Cursor Shift, Display Shift.
(11) Built-in reset circuit is triggered at power ON.
(12) Built-in oscillator.

 Data can be placed at any location on the LCD. For 16×1 LCD, the address locations

Fig 3.7 Address locations for a 1x16 line LCD

Nigama engineering college Page 49


Fig 3.8 Shapes Of Different LCD

Even limited to character based modules,there is still a wide variety of shapes and
sizes available. Line lenghs of 8,16,20,24,32 and 40 charecters are all standard, in one,
two and four line versions.
Several different LC technologies exists. “supertwist” types, for example, offer
Improved contrast and viewing angle over the older “twisted nematic” types. Some
modules are available with back lighting, so so that they can be viewed in dimly-lit
conditions. The back lighting may be either “electro-luminescent”, requiring a high
voltage inverter circuit, or simple LED illumination.


Fig 3.9. Electrical Block Diagram

Nigama engineering college Page 50


Fig 3.10. Power Supply Circuit For Lcd


Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins
(two pins are extra in both for back-light LED connections).

Fig 3.11. Pin Diagram of 1x16 Lines Lcd

Nigama engineering college Page 51

Fig 3.12. Pin Discription 16*1 LCD


EN: Line is called "Enable." This control line is used to tell the LCD that you are sending
it data. To send data to the LCD, your program should make sure this line is low (0) and
then set the other two control lines and/or put data on the data bus. When the other lines
are completely ready, bring EN high (1) and wait for the minimum amount of time
required by the LCD datasheet (this varies from LCD to LCD), and end by bringing it low
(0) again.

RS: Line is the "Register Select" line. When RS is low (0), the data is to be treated as a
command or special instruction (such as clear screen, position cursor, etc.). When RS is
high (1), the data being sent is text data which sould be displayed on the screen. For
example, to display the letter "T" on the screen you would set RS high.

RW: Line is the "Read/Write" control line. When RW is low (0), the information on the
data bus is being written to the LCD. When RW is high (1), the program is effectively
querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read
command. All others are write commands, so RW will almost always be low.Finally, the
data bus consists of 4 or 8 lines (depending on the mode of operation selected by the
user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3,
DB4, DB5, DB6, and DB7.

Nigama engineering college Page 52


 E - 0 Access to LCD disabled- 1 Access to LCD enabled.

 R/W - 0 Writing data to LCD- 1 Reading data from LCD.
 RS - 0 Instructions-1 Character.


1) Set R/W bit to low

2) Set RS bit to logic 0 or 1 (instruction or character)
3) Set data to data lines (if it is writing)
4) Set E line to high
5) Set E line to low


1) Set R/W bit to high

2) Set RS bit to logic 0 or 1 (instruction or character)
3) Set data to data lines (if it is writing)
4) Set E line to high
5) Set E line to low


First, a little tip: it is manually a lot easier to enter characters and commands in
hexadecimal rather than binary (although, of course, you will need to translate commands
from binary couple of sub-miniature hexadecimal rotary switches is a simple matter,
although a little bit into hex so that you know which bits you are setting). Replacing the
d.i.l. switch pack with a of re-wiring is necessary. The switches must be the type where On
= 0, so that when they are turned to the zero position, all four outputs are shorted to the
common pin, and in position “F”, all four outputs are open circuit.
All the available characters that are built into the module are shown in Table 3.
Studying the table, you will see that codes associated with the characters are quoted in
binary and hexadecimal, most significant bits (“left-hand” four bits) across the top, and
least significant bits (“right-hand” four bits) down the left.
Most of the characters conform to the ASCII standard, although the Japanese and
Greek characters (and a few other things) are obvious exceptions.

Nigama engineering college Page 53

Since these intelligent modules were designed in the “Land of the Rising Sun,” it
seems only fair that their Katakana phonetic symbols should also be incorporated. The
more extensive Kanji character set, which the Japanese share with the Chinese, consisting
of several thousand different characters, is not included!
Using the switches, of whatever type, and referring to Table 3, enter a few
characters onto the display, both letters and numbers. The RS switch (S10) must be “up”
(logic 1) when sending the characters, and switch E (S9) must be pressed for each of them.
Thus the operational order is: set RS high, enter character, trigger E, leave RShigh, enter
another character, trigger E, and so on. The first 16 codes in Table 3, 00000000 to
00001111, ($00 to $0F) refer to the CGRAM. This is the Character Generator RAM
(random access memory), which can be used to hold user-defined graphics characters.
This is where these modules really start to show their potential, offering such
capabilities as bar graphs, flashing symbols, even animated characters. Before the user-
defined characters are set up, these codes will just bring up strange looking symbols.
Codes 00010000 to 00011111 ($10 to $1F) are not used and just display blank
characters. ASCII codes “proper” start at 00100000 ($20) and end with 01111111 ($7F).
Codes 10000000 to 10011111 ($80 to $9F) are not used, and 10100000 to 11011111 ($A0
to $DF) are the Japanese characters.


Fig 3.13 Block Schematic Of Regulator


A rechargeable battery, storage battery, secondary cell, or accumulator is a type of

electrical battery which can be charged, discharged into a load, and recharged many
times, while a non-rechargeable or primary battery is supplied fully charged, and
discarded once discharged. It is composed of one or more electrochemical cells. The term
"accumulator" is used as it accumulates and stores energy through a reversible
electrochemical reaction. Rechargeable batteries are produced in many different shapes
and sizes, ranging from button cells to megawatt systems connected to stabilize an
electrical distribution network.

Nigama engineering college Page 54

Several different combinations of electrode materials and electrolytes are used,
including lead–acid, nickel cadmium (NiCd), nickel metal hydride (NiMH), lithium ion
(Li-ion), and lithium ion polymer (Li-ion polymer). Rechargeable batteries typically
initially cost more than disposable batteries, but have a much lower total cost of
ownership and environmental impact, as they can be recharged inexpensively many times
before they need replacing. Some rechargeable battery types are available in the same
sizes and voltages as disposable types, and can be used interchangeably with them.
Rechargeable batteries also present many environmental advantages, as they generate less
waste. They were once associated with being quite expensive, but rechargeable batteries
have become increasingly more affordable in recent years. When purchasing rechargeable
batteries, buyers should familiarise themselves with the various types and their uses,
consider their advantages and disadvantages, understand how to charge and store them
properly, and learn about the proper recycling process.


Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable
output voltages. They are also rated by the maximum current they can pass. Negative
voltage regulators are available, mainly for use in dual supplies. Most regulators include
some automatic protection from excessive current ('overload protection') and overheating
('thermal protection').
Many of the fixed voltage regulator ICs have 3 leads and look like power
transistors, such as the 7805 +5V 1A regulator shown on the right. They include a hole for
attaching a heatsink if necessary.

For low current power supplies a simple voltage regulator can be made with a
resistor and a zener diode connected in reverse as shown in the diagram. Zener diodes are
rated by their breakdown voltage Vz and maximum power Pz (typically 400mW or
The resistor limits the current (like an LED resistor). The current through the
resistor is constant, so when there is no output current all the current flows through the
zener diode and its power rating Pz must be large enough to withstand this.

Nigama engineering college Page 55


1. The zener voltage Vz is the output voltage required

2. The input voltage Vs must be a few volts greater than Vz
(this is to allow for small fluctuations in Vs due to ripple)
3. The maximum current Imax is the output current required plus 10%
4. The zener power Pz is determined by the maximum current: Pz > Vz × Imax
5. The resistor resistance: R = (Vs - Vz) / Imax
6. The resistor power rating: P > (Vs - Vz) × Imax

Nigama engineering college Page 56



Keil an ARM Company makes C compilers, macro assemblers, real-time kernels,

debuggers, simulators, integrated environments, evaluation boards, and emulators for
ARM7/ARM9/Cortex-M3, XC16x/C16x/ST10, 251, and 8051 MCU families.
Keil development tools for the 8051 Microcontroller Architecture support every
level of software developer from the professional applications engineer to the student just
learning about embedded software development. When starting a new project, simply
select the microcontroller you use from the Device Database and the µVision IDE sets all
compiler, assembler, linker, and memory options for you.
Keil is a cross compiler. So first we have to understand the concept of compilers
and cross compilers. After then we shall learn how to work with keil.


Compilers are programs used to convert a High Level Language to object code.
Desktop compilers produce an output object code for the underlying microprocessor, but
not for other microprocessors. I.E the programs written in one of the HLL like ‘C’ will
compile the code to run on the system for a particular processor like x86 (underlying
microprocessor in the computer). For example compilers for Dos platform is different
from the Compilers for Unix platform So if one wants to define a compiler then compiler
is a program that translates source code into object code.
The compiler derives its name from the way it works, looking at the entire piece
of source code and collecting and reorganizing the instruction. See there is a bit little
difference between compiler and an interpreter. Interpreter just interprets whole program
at a time while compiler analyses and execute each line of source code in succession,
without looking at the entire program.
The advantage of interpreters is that they can execute a program immediately.
Secondly programs produced by compilers run much faster than the same programs
executed by an interpreter.

Nigama engineering college Page 57

However compilers require some time before an executable program emerges.
Now as compilers translate source code into object code, which is unique for each type of
computer, many compilers are available for the same language.


A cross compiler is similar to the compilers but we write a program for the target
processor (like 8051 and its derivatives) on the host processors (like computer of x86). It
means being in one environment you are writing a code for another environment is called
cross development. And the compiler used for cross development is called cross
compiler. So the definition of cross compiler is a compiler that runs on one computer but
produces object code for a different type of computer.


Keil is a German based Software development company. It provides several
development tools like
• IDE (Integrated Development environment)
• Project Manager
• Simulator
• Debugger
• C Cross Compiler, Cross Assembler, Locator/Linker
The Keil ARM tool kit includes three main tools, assembler, compiler and linker.
An assembler is used to assemble the ARM assembly program. A compiler is used to
compile the C source code into an object file. A linker is used to create an absolute object
module suitable for our in-circuit emulator.


To build (compile, assemble, and link) an application in µVision2, you must:

1. Select Project -(forexample,166\EXAMPLES\HELLO\HELLO.UV2).
2. Select Project - Rebuild all target files or Build target.µVision2 compiles,
assembles, and links the files in your project.

Nigama engineering college Page 58


To create a new project in µVision2, you must:

1. Select Project - New Project.

2. Select a directory and enter the name of the project file.
3. Select Project - Select Device and select an 8051, 251, or C16x/ST10 device from
the Device Database™.
4. Create source files to add to the project.
5. Select Project - Targets, Groups, Files. Add/Files, select Source Group1, and add
the source files to the project.
6. Select Project - Options and set the tool options. Note when you select the target
device from the Device Database™ all special options are set automatically. You
typically only need to configure the memory map of your target hardware. Default
memory model settings are optimal for most applications.
7. Select Project - Rebuild all target files or Build target.


To debug an application created using µVision2, you must:

1. Select Debug - Start/Stop Debug Session.

2. Use the Step toolbar buttons to single-step through your program. You may enter
G, main in the Output Window to execute to the main C function.
3. Open the Serial Window using the Serial #1 button on the toolbar.

Debug your program using standard options like Step, Go, Break, and so on.


µVision2 is a standard Windows application and started by clicking on the

program icon. To create a new project file select from the µVision2 menu Project – New
Project…. This opens a standard Windows dialog that asks you for the new project file
name. We suggest that you use a separate folder for each project. You can simply use the
icon Create New Folder in this dialog to get a new empty folder. Then select this folder
and enter the file name for the new project, i.e. Project1.

Nigama engineering college Page 59

µVision2 creates a new project file with the name PROJECT1.UV2 which
contains a default target and file group name. You can see these names in the Project.


Now use from the menu Project – Select Device for Target and select a CPU for
your project. The Select Device dialog box shows the µVision2 device data base. Just
select the microcontroller you use. We are using for our examples the Philips 80C51RD+
CPU. This selection sets necessary tool Options for the 80C51RD+ device and simplifies
in this way the tool Configuration.


Typical, the tool settings under Options – Target are all you need to start a new
application. You may translate all source files and line the application with a click on the
Build Target toolbar icon. When you build an application with syntax errors, µVision2
will display errors and warning messages in the Output Window – Build page. A double
click on a message line opens the source file on the correct location in a µVision2 editor
window. Once you have successfully generated your application you can start debugging.
After you have tested your application, it is required to create an Intel HEX file to
download the software into an EPROM programmer or simulator. µVision2 creates HEX
files with each build process when Create HEX files under Options for Target – Output is
enabled. You may start your PROM programming utility after the make process when you
specify the program under the option Run User Program #1.


µVision2 simulates up to 16 Mbytes of memory from which areas can be mapped

for read, write, or code execution access. The µVision2 simulator traps
and reports illegal memory accesses. In addition to memory mapping, the simulator also
provides support for the integrated peripherals of the various 8051 derivatives. The on-
chip peripherals of the CPU you have selected are configured from the Device.

Nigama engineering college Page 60


You have made when you create your project target. Refer to page 58 for more
Information about selecting a device. You may select and display the on-chip peripheral
components using the Debug menu. You can also change the aspects of each peripheral
using the controls in the dialog boxes.


You start the debug mode of µVision2 with the Debug – Start/Stop Debug
Session Command. Depending on the Options for Target – Debug Configuration,
µVision2 will load the application program and run the startup code µVision2 saves the
editor screen layout and restores the screen layout of the last debug session.
If the program execution stops, µVision2 opens an editor window with the source
text or shows CPU instructions in the disassembly window. The next executable statement
is marked with a yellow arrow. During debugging, most editor features are still available.
For example, you can use the find command or correct program errors. Program source
text of your application is shown in the same windows. The µVision2 debug mode differs
from the edit mode in the following aspects:
-The “Debug Menu and Debug Commands” described on page 28 are available.
The additional debug windows are discussed in the following.
-The project structure or tool parameters cannot be modified. All build commands
are disabled.


The Disassembly window shows your target program as mixed source and
assembly program or just assembly code. A trace history of previously executed
instructions may be displayed with Debug – View Trace Records. To enable the trace
history, set Debug – Enable/Disable Trace Recording.
If you select the Disassembly Window as the active window all program step
commands work on CPU instruction level rather than program source lines. You can
select a text line and set or modify code breakpoints using toolbar buttons or the context
menu commands.

Nigama engineering college Page 61

You may use the dialog Debug – Inline Assembly… to modify the CPU
instructions. That allows you to correct mistakes or to make temporary changes to the
target program you are debugging. Numerous example programs are included to help you
get started with the most popular embedded 8051 devices.
The Keil µVision Debugger accurately simulates on-chip peripherals (I²C, CAN,
UART, SPI, Interrupts, I/O Ports, A/D Converter, D/A Converter, and PWM Modules) of
your 8051 device. Simulation helps you understand hardware configurations and avoids
time wasted on setup problems. Additionally, with simulation, you can write and test
applications before target hardware is available.


Use of embedded processors in passenger cars, mobile phones, medical

equipment, aerospace systems and defense systems is widespread, and even everyday
domestic appliances such as dish washers, televisions, washing machines and video
recorders now include at least one such device.
Because most embedded projects have severe cost constraints, they tend to use
low-cost processors like the 8051 family of devices considered in this book. These
popular chips have very limited resources available most such devices have around 256
bytes (not megabytes!) of RAM, and the available processor power is around 1000 times
less than that of a desktop processor. As a result, developing embedded software presents
significant new challenges, even for experienced desktop programmers. If you have some
programming experience - in C, C++ or Java - then this book and its accompanying CD
will help make your move to the embedded world as quick and painless as possible.



 Insert the CD-ROM in your computer’s CD drive

 On most computers, the CD will “auto run”, and you will see the Keil installation
menu. If the menu does not appear, manually double click on the Setup icon, in the
root directory: you will then see the Keil menu.
 On the Keil menu, please select “Install Evaluation Software”. (You will not
require a license number to install this software).

Nigama engineering college Page 62

 Follow the installation instructions as they appear.


 The example projects for this book are NOT loaded automatically when you install
the Keil compiler.
 These files are stored on the CD in a directory “/Pont”. The files are arranged by
chapter: for example, the project discussed in Chapter 3 is in the directory
 Rather than using the projects on the CD (where changes cannot be saved), please
copy the files from CD onto an appropriate directory on your hard disk.
Note: you will need to change the file properties after copying: file transferred from
the CD will be ‘read only’.


 Open the Keil Vision2

 Go to Project – Open Project and browse for Hello in Ch03_00 in Pont and open

Go to Project – Select Device for Target ‘Target1’

Nigama engineering college Page 63

Select 8052(all variants) and click OK

Now we need to check the oscillator frequency:

Go to project – Options for Target ‘Target1’

Nigama engineering college Page 64

Make sure that the oscillator frequency is 12MHz.

Building the Target

Nigama engineering college Page 65

Build the target as illustrated in the figure below

Running the Simulation having successfully built the target, we are now ready to start the
debug session and run the simulator.

First start a debug session

Nigama engineering college Page 66

The flashing LED we will view will be connected to Port 1. We therefore want to
observe the activity on this port.

To ensure that the port activity is visible, we need to start the ‘periodic window update’

Nigama engineering college Page 67

Go to Debug - Go

While the simulation is running, view the performance analyzer to check the delay


Nigama engineering college Page 68

Go to Debug – Performance Analyzer and click on it

Nigama engineering college Page 69

Double click on DELAY_LOOP_Wait in Function Symbols: and click Define button

Nigama engineering college Page 70



1. Click on the Keil Vision Icon on Desktop

2. The following fig will appear

3. Click on the Project menu from the title bar

4. Then Click on New Project

5. Save the Project by typing suitable project name with no extension in u r own
folder sited in either C:\ or D:\

Nigama engineering college Page 71

6. Then Click on Save button above.

7. Select the component for u r project. i.e. Atmel……

8. Click on the + Symbol beside of Atmel

9. Select AT89C51 as shown below

Nigama engineering college Page 72

10. Then Click on “OK”

11. The Following fig will appear

12. Then Click either YES or NO………mostly “NO”.

13. Now your project is ready to USE.

14. Now double click on the Target1, you would get another option “Source group
1” as shown in next page.

Nigama engineering college Page 73

15. Click on the file option from menu bar and select “new”.

16. The next screen will be as shown in next page, and just maximize it by double
clicking on its blue boarder.

Nigama engineering college Page 74

17. Now start writing program in either in “EMBEDDED C” or “ASM”.

18. For a program written in Assembly, then save it with extension “. asm” and
for “EMBEDDED C” based program save it with extension “ .C”

19. Now right click on Source group 1 and click on “Add files to Group Source”.

Nigama engineering college Page 75

20. Now you will get another window, on which by default “EMBEDDED C”
files will appear.

21. Now select as per your file extension given while saving the file

22. Click only one time on option “ADD”.

23. Now Press function key F7 to compile. Any error will appear if so happen.

Nigama engineering college Page 76

24. If the file contains no error, then press Control+F5 simultaneously.

25. The new window is as follows

26. Then Click “OK”.

27. Now click on the Peripherals from menu bar, and check your required port as
shown in fig below.

Nigama engineering college Page 77

28. Drag the port a side and click in the program file.

29. Now keep Pressing function key “F11” slowly and observe.

30. You are running your program successfully.

Nigama engineering college Page 78


sbit in1 = P0^0;
sbit in2 = P0^1;
sbit in3 = P0^2;
sbit in4 = P0^3;
unsigned char mybyte,i;
void delay(unsigned int n)
unsigned in t j, k;
for (j=0 ; j<n ; j++)
for (k=0;k<1000;k++);
void send_to_modem (unsigned char s[])
unsigned char r;
void enter (void)

Nigama engineering college Page 79

void main()
TH1=0xFD; // BAUD RATE 9600
send_to_modem("Send following commands to operate Robot ");
send_to_modem("F : FRONT B : Back L : Left R : Right S : Stop");
enter(); */
Nigama engineering college Page 80
// enter();
//send_to_modem("Robot moving in forward direction");
goto start;
//send_to_modem("Robot moving in Backward direction");
goto start;
//send_to_modem("Robot turned in Left direction");
goto start;
Nigama engineering college Page 81
//send_to_modem("Robot turned in Right direction");
goto start;
//send_to_modem("Robot Stopped");
goto start;

Nigama engineering college Page 82


 For elder people .
 Useful in indutries.
 It is feasible to implement bluetooth communication between smart phone and
 The development of apps for Android in Android SDK is easy and free of cost.


 For industrial and commercial applications.

 Can be used in remote area applications.
 Helpful for mobility impaired persons.
 As a toy.
 For Pick and Place applications.
 We can interface sensors to this robot so that it can monitor some


 We can add wireless camera to this robot.

Nigama engineering college Page 83


It is feasible to implement Bluetooth communication between smartphone and

microcontroller. It can be used in various industries for picking various objects where
human intervention is not desired. On a large scale, it can be used to develop robots with
military applications. It can be used to target enemy without any human being crossing
the territory. It provides for more development of applications based on android operating
system. Such as, Application based on sensors (accelerometer, gyroscope) etc.The
development of apps for Android in Android SDK is easy and free of cost. With
tremendous smart phone in markets, it is bound to have many more applications in near
future. It is robust, sensitive and fast moving, hence can be applied in rescue operations.
The objective of the paper is to realise the smart living , more specifically the home
lighting control system using Bluetooth Technology. Robot and smartphones are a perfect
match, specially mobile robots. As phones and mobile devices are each time more
powerful, using them as robot for building robot with advanced feature such as voice
recognition. Android bluetooth-enable phones and bluetooth module via HC-06 and
communication among bluetooth devices. It is concluded that smart living will gradually
turn into areality that consumer can control their home romotely and wirelessly.

Nigama engineering college Page 84


 The 8051 Microcontroller and Embedded Systems

- M.A Mazidi & J.G Mazidi
 The Microcontroller Idea Book
- John Axelson
 Digital design and test
- Morris Mano
 Linear integrated circuits by
- Roy choudary
 Wireless Network Coexistence
- Robert Morrow
 The Savvy Guide to Home Security
- John Paul Mueller
 Implementing 802.11 with Microcontrollers: Wireless Networking for
- Fred Eady

Nigama engineering college Page 85