Sie sind auf Seite 1von 97


Technical Specifications:


Domain : Embedded Systems

Communication : RFID/ZIG BEE Module

Controller : 8051

Crystal : 12MHz

Motors : DC Motors

Sensors : IR

Applications : PARKING AREA


Our aim is to design and develop a robot which will be used in the parking area for the automatic
detection of available parking slot and to carry the car to the respective empty slot.
Block Diagram

An embedded system is a system which is going to do a predefined specified task is the embedded system
and is even defined as combination of both software and hardware. A general-purpose definition of
embedded systems is that they are devices used to control, monitor or assist the operation of equipment,
machinery or plant. "Embedded" reflects the fact that they are an integral part of the system. At the other
extreme a general-purpose computer may be used to control the operation of a large complex processing
plant, and its presence will be obvious.

All embedded systems are including computers or microprocessors. Some of these

computers are however very simple systems as compared with a personal computer.
The very simplest embedded systems are capable of performing only a single function or
set of functions to meet a single predetermined purpose. In more complex systems an application
program that enables the embedded system to be used for a particular purpose in a specific
application determines the functioning of the embedded system. The ability to have programs
means that the same embedded system can be used for a variety of different purposes. In some
cases a microprocessor may be designed in such a way that application software for a particular
purpose can be added to the basic software in a second process, after which it is not possible to
make further changes. The applications software on such processors is sometimes referred to as
The simplest devices consist of a single microprocessor (often called a "chip”), which may itself
be packaged with other chips in a hybrid system or Application Specific Integrated Circuit (ASIC). Its
input comes from a detector or sensor and its output goes to a switch or activator which (for example)
may start or stop the operation of a machine or, by operating a valve, may control the flow of fuel to an

As the embedded system is the combination of both software and hardware,Software deals with the
languages like ALP, C, and VB etc., and Hardware deals with Processors, Peripherals, and Memory.

Memory: It is used to store data or address.

Peripherals: These are the external devices connected
Processor: It is an IC which is used to perform some task
Applications of embedded systems
 Manufacturing and process control
 Construction industry
 Transport
 Buildings and premises
 Domestic service
 Communications
 Office systems and mobile equipment
 Banking, finance and commercial
 Medical diagnostics, monitoring and life support
 Testing, monitoring and diagnostic systems

Processors are classified into four types like:

 Micro Processor (µp)
 Micro controller (µc)
 Digital Signal Processor (DSP)
 Application Specific Integrated Circuits (ASIC)
Micro Processor (µp):
A silicon chip that contains a CPU. In the world of personal computers, the terms microprocessor and
CPU are used interchangeably. At the heart of all personal computers and most workstations sits a
microprocessor. Microprocessors also control the logic of almost all digital devices, from clock radios to
fuel-injection systems for automobiles.

Three basic characteristics differentiate microprocessors:

 Instruction set: The set of instructions that the microprocessor can execute.
 Bandwidth: The number of bits processed in a single instruction.
 Clock speed: Given in megahertz (MHz), the clock speed determines how many instructions per second
the processor can execute.
In both cases, the higher the value, the more powerful the CPU. For example, a 32-bit microprocessor that
runs at 50MHz is more powerful than a 16-bit microprocessor that runs at 25MHz. In addition to
bandwidth and clock speed, microprocessors are classified as being either RISC (reduced instruction set
computer) or CISC (complex instruction set computer).

A microprocessor has three basic elements, as shown above. The ALU performs all arithmetic
computations, such as addition, subtraction and logic operations (AND, OR, etc). It is controlled by the
Control Unit and receives its data from the Register Array. The Register Array is a set of registers used
for storing data. These registers can be accessed by the ALU very quickly. Some registers have specific
functions - we will deal with these later. The Control Unit controls the entire process. It provides the
timing and a control signal for getting data into and out of the registers and the ALU and it synchronizes
the execution of instructions (we will deal with instruction execution at a later date).

Three Basic Elements of a Microprocessor

Micro Controller (µc):

A microcontroller is a small computer on a single integrated circuit containing a processor core,
memory, and programmable input/output peripherals. Program memory in the form of NOR
flash or OTP ROM is also often included on chip, as well as a typically small amount of RAM.
Microcontrollers are designed for embedded applications, in contrast to the microprocessors used
in personal computers or other general purpose applications.




Timer, Counter,serial
communication ROM,
ADC, DAC, Timers,
USART, Oscillators

Etc., Figure: Block Diagram of Micro Controller (µc)

Digital Signal Processors (DSPs):
Digital Signal Processors is one which performs scientific and mathematical operation.
Digital Signal Processor chips - specialized microprocessors with architectures designed
specifically for the types of operations required in digital signal processing. Like a general-
purpose microprocessor, a DSP is a programmable device, with its own native instruction code.
DSP chips are capable of carrying out millions of floating point operations per second, and like
their better-known general-purpose cousins, faster and more powerful versions are continually
being introduced. DSPs can also be embedded within complex "system-on-chip" devices, often
containing both analog and digital circuitry.
Application Specific Integrated Circuit (ASIC)
ASIC is a combination of digital and analog circuits packed into an IC to achieve the desired
control/computation function

ASIC typically contains

 CPU cores for computation and control

 Peripherals to control timing critical functions
 Memories to store data and program
 Analog circuits to provide clocks and interface to the real world which is analog in nature
 I/Os to connect to external components like LEDs, memories, monitors etc.
Computer Instruction Set

There are two different types of computer instruction set there are:

1. RISC (Reduced Instruction Set Computer) and

2. CISC (Complex Instruction Set computer)

Reduced Instruction Set Computer (RISC)

A RISC (reduced instruction set computer) is a microprocessor that is designed to perform a smaller
number of types of computer instruction so that it can operate at a higher speed (perform more million
instructions per second, or millions of instructions per second). Since each instruction type that a
computer must perform requires additional transistors and circuitry, a larger list or set of computer
instructions tends to make the microprocessor more complicated and slower in operation.

Besides performance improvement, some advantages of RISC and related design improvements are:

 A new microprocessor can be developed and tested more quickly if one of its aims is to be less
 Operating system and application programmers who use the microprocessor's instructions will find it
easier to develop code with a smaller instruction set.
 The simplicity of RISC allows more freedom to choose how to use the space on a microprocessor.
Higher-level language compilers produce more efficient code than formerly because they have always
tended to use the smaller set of instructions to be found in a RISC computer.

RISC characteristics

 Simple instruction set:

In a RISC machine, the instruction set contains simple, basic instructions, from which more complex
instructions can be composed.

 Same length instructions.

Each instruction is the same length, so that it may be fetched in a single operation.
 1 machine-cycle instructions.

Most instructions complete in one machine cycle, which allows the processor to handle several
instructions at the same time. This pipelining is a key technique used to speed up RISC machines.
Complex Instruction Set Computer (CISC)

CISC, which stands for Complex Instruction Set Computer, is a philosophy for designing chips that are
easy to program and which make efficient use of memory. Each instruction in a CISC instruction set
might perform a series of operations inside the processor. This reduces the number of instructions
required to implement a given program, and allows the programmer to learn a small but flexible set of

The advantages of CISC

At the time of their initial development, CISC machines used available technologies to optimize computer

 Microprogramming is as easy as assembly language to implement, and much less expensive than
hardwiring a control unit.
 The ease of micro-coding new instructions allowed designers to make CISC machines upwardly
compatible: a new computer could run the same programs as earlier computers because the new computer
would contain a superset of the instructions of the earlier computers.
 As each instruction became more capable, fewer instructions could be used to implement a given task.
This made more efficient use of the relatively slow main memory.
 Because micro program instruction sets can be written to match the constructs of high-level languages,
the compiler does not have to be as complicated.

The disadvantages of CISC

Still, designers soon realized that the CISC philosophy had its own problems, including:

 Earlier generations of a processor family generally were contained as a subset in every new version --- so
instruction set & chip hardware become more complex with each generation of computers.
 So that as many instructions as possible could be stored in memory with the least possible wasted space,
individual instructions could be of almost any length---this means that different instructions will take
different amounts of clock time to execute, slowing down the overall performance of the machine.
 Many specialized instructions aren't used frequently enough to justify their existence --- approximately
20% of the available instructions are used in a typical program.
 CISC instructions typically set the condition codes as a side effect of the instruction. Not only does
setting the condition codes take time, but programmers have to remember to examine the condition code
bits before a subsequent instruction changes them.
Memory Architecture

There two different type’s memory architectures there are:

 Harvard Architecture

 Von-Neumann Architecture

Harvard Architecture

Computers have separate memory areas for program instructions and data. There are two or more internal
data buses, which allow simultaneous access to both instructions and data. The CPU fetches program
instructions on the program memory bus.

The Harvard architecture is a computer architecture with physically separate storage and signal
pathways for instructions and data. The term originated from the Harvard Mark I relay-based computer,
which stored instructions on punched tape (24 bits wide) and data in electro-mechanical counters. These
early machines had limited data storage, entirely contained within the central processing unit, and
provided no access to the instruction storage as data. Programs needed to be loaded by an operator, the
processor could not bootitself.
Figure: Harvard Architecture

Modern uses of the Harvard architecture

The principal advantage of the pure Harvard architecture - simultaneous access to more than one
memory system - has been reduced by modified Harvard processors using modern CPU cache
systems. Relatively pure Harvard architecture machines are used mostly in applications where
tradeoffs, such as the cost and power savings from omitting caches, outweigh the programming
penalties from having distinct code and data address spaces.
 Digital signal processors (DSPs) generally execute small, highly-optimized audio or video processing
algorithms. They avoid caches because their behavior must be extremely reproducible. The difficulties of
coping with multiple address spaces are of secondary concern to speed of execution. As a result, some
DSPs have multiple data memories in distinct address spaces to facilitate SIMD and VLIW processing.
Texas Instruments TMS320 C55x processors, as one example, have multiple parallel data busses (two
write, three read) and one instruction bus.
 Microcontrollers are characterized by having small amounts of program (flash memory) and data
(SRAM) memory, with no cache, and take advantage of the Harvard architecture to speed processing by
concurrent instruction and data access. The separate storage means the program and data memories can
have different bit depths, for example using 16-bit wide instructions and 8-bit wide data. They also mean
that instruction pre-fetch can be performed in parallel with other activities. Examples include, the AVRby
Atmel Corp, the PIC by Microchip Technology, Inc. and the ARM Cortex-M3 processor (not all ARM
chips have Harvard architecture).
Even in these cases, it is common to have special instructions to access program memory as data
for read-only tables, or for reprogramming.

Von-Neumann Architecture

A computer has a single, common memory space in which both program instructions and data are stored.
There is a single internal data bus that fetches both instructions and data. They cannot be performed at the
same time

The Von Neumann architecture is a design model for a stored-program digital computer that uses a
central processing unit (CPU) and a single separate storage structure ("memory") to hold both instructions
and data. It is named after the mathematician and early computer scientistJohn von Neumann. Such
computers implement a universal Turing machine and have a sequential architecture.

A stored-programdigital computer is one that keeps its programmed instructions, as well as its data, in
read-write, random-access memory (RAM). Stored-program computers were advancement over the
program-controlled computers of the 1940s, such as the Colossus and the ENIAC, which were
programmed by setting switches and inserting patch leads to route data and to control signals between
various functional units. In the vast majority of modern computers, the same memory is used for both data
and program instructions. The mechanisms for transferring the data and instructions between the CPU and
memory are, however, considerably more complex than the original von Neumann architecture.

The terms "von Neumann architecture" and "stored-program computer" are generally used
interchangeably, and that usage is followed in this article.

Figure: Schematic of the Von-Neumann Architecture.

Basic Difference between Harvard and Von-Neumann Architecture

 The primary difference between Harvard architecture and the Von Neumann architecture is in the Von
Neumann architecture data and programs are stored in the same memory and managed by the same
information handling system.
 Whereas the Harvard architecture stores data and programs in separate memory devices and they are
handled by different subsystems.
 In a computer using the Von-Neumann architecture without cache; the central processing unit (CPU) can
either be reading and instruction or writing/reading data to/from the memory. Both of these operations
cannot occur simultaneously as the data and instructions use the same system bus.
 In a computer using the Harvard architecture the CPU can both read an instruction and access data
memory at the same time without cache. This means that a computer with Harvard architecture can
potentially be faster for a given circuit complexity because data access and instruction fetches do not
contend for use of a single memory pathway.
 Today, the vast majority of computers are designed and built using the Von Neumann architecture
template primarily because of the dynamic capabilities and efficiencies gained in designing,
implementing, operating one memory system as opposed to two. Von Neumann architecture may be
somewhat slower than the contrasting Harvard Architecture for certain specific tasks, but it is much more
flexible and allows for many concepts unavailable to Harvard architecture such as self programming,
word processing and so on.
 Harvard architectures are typically only used in either specialized systems or for very specific uses. It is
used in specialized digital signal processing (DSP), typically for video and audio processing products. It
is also used in many small microcontrollers used in electronics applications such as Advanced RISK
Machine (ARM) based products for many vendors.
Block Diagram For Regulated Power Supply (RPS):

Figure: Power Supply

Description :


A transformer is a device that transfers electrical energy from one circuit to another through
inductively coupled conductors—the transformer's coils. A varying current in the first or primary
winding creates a varying magnetic flux in the transformer's core, and thus a varying magnetic
field through the secondary winding. This varying magnetic field induces a varying
electromotive force (EMF) or "voltage" in the secondary winding. This effect is called mutual

Figure: Transformer Symbol

Transformer is a device that converts the one form energy to another form of energy like a

Figure: Transformer

Basic Principle

A transformer makes use of Faraday's law and the ferromagnetic properties of an iron core to efficiently
raise or lower AC voltages. It of course cannot increase power so that if the voltage is raised, the current
is proportionally lowered and vice versa.
Figure: Basic Principle
Transformer Working

A transformer consists of two coils (often called 'windings') linked by an iron core, as shown in
figure below. There is no electrical connection between the coils; instead they are linked by a
magnetic field created in the core.

Figure: Basic Transformer

Transformers are used to convert electricity from one voltage to another with minimal loss of power.
They only work with AC (alternating current) because they require a changing magnetic field to be
created in their core. Transformers can increase voltage (step-up) as well as reduce voltage (step-down).

Alternating current flowing in the primary (input) coil creates a continually changing magnetic field in the
iron core. This field also passes through the secondary (output) coil and the changing strength of the
magnetic field induces an alternating voltage in the secondary coil. If the secondary coil is connected to a
load the induced voltage will make an induced current flow. The correct term for the induced voltage is
'induced electromotive force' which is usually abbreviated to induced e.m.f.

The iron core is laminated to prevent 'eddy currents' flowing in the core. These are currents produced by
the alternating magnetic field inducing a small voltage in the core, just like that induced in the secondary
coil. Eddy currents waste power by needlessly heating up the core but they are reduced to a negligible
amount by laminating the iron because this increases the electrical resistance of the core without affecting
its magnetic properties.
Transformers have two great advantages over other methods of changing voltage:

1. They provide total electrical isolation between the input and output, so they can be safely used to
reduce the high voltage of the mains supply.
2. Almost no power is wasted in a transformer. They have a high efficiency (power out / power in)
of 95% or more.

Classification of Transformer

 Step-Up Transformer
 Step-Down Transformer

Step-Down Transformer

Step down transformers are designed to reduce electrical voltage. Their primary voltage is
greater than their secondary voltage. This kind of transformer "steps down" the voltage applied
to it. For instance, a step down transformer is needed to use a 110v product in a country with a
220v supply.

Step down transformers convert electrical voltage from one level or phase configuration usually
down to a lower level. They can include features for electrical isolation, power distribution, and
control and instrumentation applications. Step down transformers typically rely on the principle
of magnetic induction between coils to convert voltage and/or current levels.

Step down transformers are made from two or more coils of insulated wire wound around a core
made of iron. When voltage is applied to one coil (frequently called the primary or input) it
magnetizes the iron core, which induces a voltage in the other coil, (frequently called the
secondary or output). The turn’s ratio of the two sets of windings determines the amount of
voltage transformation.
Figure: Step-Down Transformer

An example of this would be: 100 turns on the primary and 50 turns on the secondary, a ratio of
2 to 1.

Step down transformers can be considered nothing more than a voltage ratio device.

With step down transformers the voltage ratio between primary and secondary will mirror the
"turn’s ratio" (except for single phase smaller than 1 kva which have compensated secondary). A
practical application of this 2 to 1 turn’s ratio would be a 480 to 240 voltage step down. Note that
if the input were 440 volts then the output would be 220 volts. The ratio between input and
output voltage will stay constant. Transformers should not be operated at voltages higher than
the nameplate rating, but may be operated at lower voltages than rated. Because of this it is
possible to do some non-standard applications using standard transformers.

Single phase step down transformers 1 kva and larger may also be reverse connected to step-
down or step-up voltages. (Note: single phase step up or step down transformers sized less than 1
KVA should not be reverse connected because the secondary windings have additional turns to
overcome a voltage drop when the load is applied. If reverse connected, the output voltage will
be less than desired.)

Step-Up Transformer

A step up transformer has more turns of wire on the secondary coil, which makes a larger induced voltage
in the secondary coil. It is called a step up transformer because the voltage output is larger than the
voltage input.
Step-up transformer 110v 220v design is one whose secondary voltage is greater than its primary voltage.
This kind of transformer "steps up" the voltage applied to it. For instance, a step up transformer is needed
to use a 220v product in a country with a 110v supply.

A step up transformer 110v 220v converts alternating current (AC) from one voltage to another
voltage. It has no moving parts and works on a magnetic induction principle; it can be designed
to "step-up" or "step-down" voltage. So a step up transformer increases the voltage and a step
down transformer decreases the voltage.

The primary components for voltage transformation are the step up transformer core and coil.
The insulation is placed between the turns of wire to prevent shorting to one another or to
ground. This is typically comprised of Mylar, nomex, Kraft paper, varnish, or other materials. As
a transformer has no moving parts, it will typically have a life expectancy between 20 and 25

Figure: Step-Up Transformer

Applications :

Generally these Step-Up Transformers are used in industries applications only.

Types of Transformer

Mains Transformers

Mains transformers are the most common type. They are designed to reduce the AC mains supply
voltage (230-240V in the UK or 115-120V in some countries) to a safer low voltage. The standard
mains supply voltages are officially 115V and 230V, but 120V and 240V are the values usually quoted
and the difference is of no significance in most cases.

Figure: Main Transformer

To allow for the two supply voltages mains transformers usually have two separate primary coils
(windings) labeled 0-120V and 0-120V. The two coils are connected in series for 240V (figure 2a) and in
parallel for 120V (figure 2b). They must be wired the correct way round as shown in the diagrams
because the coils must be connected in the correct sense (direction):

Most mains transformers have two separate secondary coils (e.g. labeled 0-9V, 0-9V) which may be used
separately to give two independent supplies, or connected in series to create a center-tapped coil (see
below) or one coil with double the voltage.
Some mains transformers have a centre-tap halfway through the secondary coil and they are labeled 9-0-
9V for example. They can be used to produce full-wave rectified DC with just two diodes, unlike a
standard secondary coil which requires four diodes to produce full-wave rectified DC.

A mains transformer is specified by:

1. Its secondary (output) voltages Vs.

2. Its maximum power, Pmax, which the transformer can pass, quoted in VA (volt-amp). This
determines the maximum output (secondary) current, Imax...

...where Vs is the secondary voltage. If there are two secondary coils the maximum power should
be halved to give the maximum for each coil.

3. Its construction - it may be PCB-mounting, chassis mounting (with solder tag connections) or
toroidal (a high quality design).

Audio Transformers

Audio transformers are used to convert the moderate voltage, low current output of an audio amplifier to
the low voltage, high current required by a loudspeaker. This use is called 'impedance matching' because
it is matching the high impedance output of the amplifier to the low impedance of the loudspeaker.

Figure: Audio transformer

Radio Transformers

Radio transformers are used in tuning circuits. They are smaller than mains and audio transformers and
they have adjustable ferrite cores made of iron dust. The ferrite cores can be adjusted with a non-magnetic
plastic tool like a small screwdriver. The whole transformer is enclosed in an aluminum can which acts as
a shield, preventing the transformer radiating too much electrical noise to other parts of the circuit.
Figure: Radio Transformer

Turns Ratio and Voltage

The ratio of the number of turns on the primary and secondary coils determines the ratio of the voltages...

...where Vp is the primary (input) voltage, Vs is the secondary (output) voltage, Np is the number of turns
on the primary coil, and Ns is the number of turns on the secondary coil.

Diodes allow electricity to flow in only one direction. The arrow of the circuit symbol shows the
direction in which the current can flow. Diodes are the electrical version of a valve and early
diodes were actually called valves.

Figure: Diode Symbol

A diode is a device which only allows current to flow through it in one direction. In this
direction, the diode is said to be 'forward-biased' and the only effect on the signal is that there
will be a voltage loss of around 0.7V. In the opposite direction, the diode is said to be 'reverse-
biased' and no current will flow through it.


The purpose of a rectifier is to convert an AC waveform into a DC waveform (OR) Rectifier

converts AC current or voltages into DC current or voltage. There are two different rectification
circuits, known as 'half-wave' and 'full-wave' rectifiers. Both use components called diodes to
convert AC into DC.

The Half-wave Rectifier

The half-wave rectifier is the simplest type of rectifier since it only uses one diode, as shown in
Figure: Half Wave Rectifier

Figure 2 shows the AC input waveform to this circuit and the resulting output. As you can see,
when the AC input is positive, the diode is forward-biased and lets the current through. When
the AC input is negative, the diode is reverse-biased and the diode does not let any current
through, meaning the output is 0V. Because there is a 0.7V voltage loss across the diode, the
peak output voltage will be 0.7V less than Vs.

Figure: Half-Wave Rectification

While the output of the half-wave rectifier is DC (it is all positive), it would not be suitable as a
power supply for a circuit. Firstly, the output voltage continually varies between 0V and Vs-
0.7V, and secondly, for half the time there is no output at all.
The Full-wave Rectifier

The circuit in figure 3 addresses the second of these problems since at no time is the output
voltage 0V. This time four diodes are arranged so that both the positive and negative parts of the
AC waveform are converted to DC. The resulting waveform is shown in figure 4.

Figure: Full-Wave Rectifier

Figure: Full-Wave Rectification

When the AC input is positive, diodes A and B are forward-biased, while diodes C and D are
reverse-biased. When the AC input is negative, the opposite is true - diodes C and D are
forward-biased, while diodes A and B are reverse-biased.
While the full-wave rectifier is an improvement on the half-wave rectifier, its output still isn't
suitable as a power supply for most circuits since the output voltage still varies between 0V and
Vs-1.4V. So, if you put 12V AC in, you will 10.6V DC out.

Capacitor Filter

The capacitor-input filter, also called "Pi" filter due to its shape that looks like the Greek
letterpi, is a type of electronic filter. Filter circuits are used to remove unwanted or undesired
frequencies from a signal.

Figure: Capacitor Filter

A typical capacitor input filter consists of a filter capacitor C1, connected across the rectifier output, an
inductor L, in series and another filter capacitor connected across the load.

1. The capacitor C1 offers low reactance to the AC component of the rectifier output while it offers
infinite reactance to the DC component. As a result the capacitor shunts an appreciable amount of
the AC component while the DC component continues its journey to the inductor L
2. The inductor L offers high reactance to the AC component but it offers almost zero reactance to
the DC component. As a result the DC component flows through the inductor while the AC
component is blocked.
3. The capacitor C2 bypasses the AC component which the inductor had failed to block. As a result
only the DC component appears across the load RL.
Figure: Centered Tapped Full-Wave Rectifier with a Capacitor Filter

Voltage Regulator

A voltage regulator is an electricalregulator designed to automatically maintain a constant

voltage level. It may use an electromechanical mechanism, or passive or active electronic
components. Depending on the design, it may be used to regulate one or more AC or DC
voltages. There are two types of regulator are they.

 Positive Voltage Series (78xx) and

 Negative Voltage Series (79xx)


’78’ indicate the positive series and ‘xx’indicates the voltage rating. Suppose 7805 produces the
maximum 5V.’05’indicates the regulator output is 5V.


’78’ indicate the negative series and ‘xx’indicates the voltage rating. Suppose 7905 produces the
maximum -5V.’05’indicates the regulator output is -5V.

These regulators consists the three pins there are

Pin1: It is used for input pin.

Pin2: This is ground pin for regulator

Pin3: It is used for output pin. Through this pin we get the output.

Figure: Regulator


Switches and Pushbuttons

In electronics, a switch is an electrical component that can break an electrical circuit,

interrupting the current or diverting it from one conductor to another.[1][2]

The most familiar form of switch is a manually operated electromechanical device with one or
more sets of electrical contacts, which are connected to external circuits. Each set of contacts can
be in one of two states: either "closed" meaning the contacts are touching and electricity can flow
between them, or "open", meaning the contacts are separated and the switch is non conducting.
The mechanism actuating the transition between these two states (open or closed) can be either a
"toggle" (flip switch for continuous "on" or "off") or "momentary" (push-for "on" or push-for
"off") type.

A switch may be directly manipulated by a human as a control signal to a system, such as a

computer keyboard button, or to control power flow in a circuit, such as alight switch.
Automatically operated switches can be used to control the motions of machines, for example, to
indicate that a garage door has reached its full open position or that a machine tool is in a
position to accept another work piece. Switches may be operated by process variables such as
pressure, temperature, flow, current, voltage, and force, acting as sensors in a process and used to
automatically control a system. For example, a thermostat is a temperature-operated switch used
to control a heating process. A switch that is operated by another electrical circuit is called
a relay. Large switches may be remotely operated by a motor drive mechanism. Some switches
are used to isolate electric power from a system, providing a visible point of isolation that can be
pad-locked if necessary to prevent accidental operation of a machine during maintenance, or to
prevent electric shock.

Push Button Switch with High quality and durable square tactile button which are easily fitted in
breadboard and PCB.Dimension: 6x6mm and button height is 2.5mm.

There is nothing simpler than this! This is the simplest way of controlling appearance of some voltage on
microcontroller’s input pin. There is also no need for additional explanation of how these components
Nevertheless, it is not so simple in practice... This is about something commonly unnoticeable when using
these components in everyday life. It is about contact bounce- a common problem with m e c h a n i c a l
switches. If contact switching does not happen so quickly, several consecutive bounces can be noticed
prior to maintain stable state. The reasons for this are: vibrations, slight rough spots and dirt. Anyway,
whole this process does not last long (a few micro- or miliseconds), but long enough to be registered by
the microcontroller. Concerning pulse counter, error occurs in almost 100% of cases!

The simplest solution is to connect simple RC circuit which will “suppress” each quick voltage change.
Since the bouncing time is not defined, the values of elements are not strictly determined. In the most
cases, the values shown on figure are sufficient.

If complete safety is needed, radical measures should be taken! The circuit, shown on the figure (RS flip-
flop), changes logic state on its output with the first pulse triggered by contact bounce. Even though this
is more expensive solution (SPDT switch), the problem is definitely resolved! Besides, since the
condensator is not used, very short pulses can be also registered in this way. In addition to these hardware
solutions, a simple software solution is commonly applied too: when a program tests the state of some
input pin and finds changes, the check should be done one more time after certain time delay. If the
change is confirmed it means that switch (or pushbutton) has changed its position. The advantages of such
solution are obvious: it is free of charge, effects of disturbances are eliminated too and it can be adjusted
to the worst-quality contacts.


CPU accesses the switches through ports. Therefore these switches are connected to a
microcontroller. This switch is connected between the supply and ground terminals. A single
microcontroller (consisting of a microprocessor, RAM and EEPROM and several ports all on a single
chip) takes care of hardware and software interfacing of the switch.
These switches are connected to an input port. When no switch is pressed, reading the input port
will yield 1s since they are all connected to high (Vcc). But if any switch is pressed, one of the input port
pins will have 0 since the switch pressed provides the path to ground. It is the function of the
microcontroller to scan the switches continuously to detect and identify the switch pressed.

The switches that we are using in our project are 4 leg micro switches of momentary type.




Fig: Interfacing switch with the microcontroller

Thus now the two conditions are to be remembered:

1. When the switch is open, the total supply i.e., Vcc appears at the port pin P2.0
P2.0 = 1

2. When the switch is closed i.e., when it is pressed, the total supply path is provided to ground.
Thus the voltage value at the port pin P2.0 will be zero.
P2.0 = 0

By reading the pin status, the microcontroller identifies whether the switch is pressed or not.
When the switch is pressed, the corresponding related to this switch press written in the program will be


Microprocessors and microcontrollers are widely used in embedded systems products.

Microcontroller is a programmable device. A microcontroller has a CPU in addition to a fixed amount of
RAM, ROM, I/O ports and a timer embedded all on a single chip. The fixed amount of on-chip ROM,
RAM and number of I/O ports in microcontrollers makes them ideal for many applications in which cost
and space are critical.

The Intel 8052 is Harvard architecture, single chip microcontroller (µC) which was developed by
Intel in 1980 for use in embedded systems. It was popular in the 1980s and early 1990s, but today it has
largely been superseded by a vast range of enhanced devices with 8052-compatible processor cores that
are manufactured by more than 20 independent manufacturers including Atmel, Infineon Technologies
and Maxim Integrated Products.

8052 is an 8-bit processor, meaning that the CPU can work on only 8 bits of data at a time. Data
larger than 8 bits has to be broken into 8-bit pieces to be processed by the CPU. 8052 is available in
different memory types such as UV-EPROM, Flash and NV-RAM.

The present project is implemented on KeiluVision. In order to program the device, proload tool
has been used to burn the program onto the microcontroller.

The features, pin description of the microcontroller and the software tools used are discussed in
the following sections.

• 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

• 256 x 8-bit Internal RAM

• 32 Programmable I/O Lines

• Three 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 microcontroller with 8K bytes 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 instruction set and
pinout. 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 on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller which
provides a highly-flexible and cost-effective solution to many embedded control applications.

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, a six-vector two-level interrupt
architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the AT89S52 is
designed with static logic for operation down 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.



Supply voltage.



Port 0

Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can sink eight TTL inputs.
When 1s are 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 pullups. Port 0 also receives the code bytes during Flash
programming and outputs the code bytes during program verification. External pullups are required
during program verification.

Port 1

Port 1 is an 8-bit bidirectional I/O port with internal pullups. 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 pullups and can
be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL)
because of the internal pullups. 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
Port 2

Port 2 is an 8-bit bidirectional I/O port with internal pullups. 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 pullups and can
be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL)
because of the internal pullups. 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). 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 2 emits 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 verification.

Port 3

Port 3 is an 8-bit bidirectional I/O port with internal pullups. The Port 3 output buffers can sink/source
four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the internal pullups and can
be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL)
because of the pullups. 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

Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device.
This pin drives High for 96 oscillator periods after the Watchdog times out. The DISRTO bit in SFR
AUXR (address 8EH) can be used to disable this feature. In the default state of bit DISRTO, the RESET
HIGH out feature is enabled.


Address Latch Enable (ALE) is an output pulse for latching the low byte of the address during accesses to
external memory. This pin is also the program pulse input (PROG) during Flash programming. In normal
operation, ALE is emitted at a constant rate of 1/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 microcontroller 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.

EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt
programming enable 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.

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. 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 the below figure. There are no requirements on the duty
cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-
two flip-flop, but minimum and maximum voltage high and low time specifications must be observed.
Fig: Oscillator Connections

C1, C2 = 30 pF ± 10 pF for Crystals

= 40 pF ± 10 pF for Ceramic Resonators

Fig: External Clock Drive Configuration


The microcontroller memory is divided into Program Memory and Data Memory. Program Memory
(ROM) is used for permanent saving program being executed, while Data Memory (RAM) is used for
temporarily storing and keeping intermediate results and variables. Depending on the model in use (still
referring to the whole 8052 microcontroller family) at most a few Kb of ROM and 128 or 256 bytes of
RAM can be used. However…

All 8052 microcontrollers have 16-bit addressing bus and can address 64 kb memory. It is neither a
mistake nor a big ambition of engineers who were working on basic core development. It is a matter of
very clever memory organization which makes these controllers a real “programmers’ tidbit“.

Program Memory

The oldest models of the 8052 microcontroller family did not have any internal program memory. It was
added from outside as a separate chip. These models are recognizable by their label beginning with 803
(for ex. 8031 or 8032). All later models have a few Kbytes ROM embedded, Even though it is enough for
writing most of the programs, there are situations when additional memory is necessary. A typical
example of it is the use of so called lookup tables. They are used in cases when something is too
complicated or when there is no time for solving equations describing some process. The example of it
can be totally exotic (an estimate of self-guided rockets’ meeting point) or totally common (measuring of
temperature using non-linear thermo element or asynchronous motor speed control). In those cases all
needed estimates and approximates are executed in advance and the final results are put in the tables
(similar to logarithmic tables).

How does the microcontroller handle external memory depend on the pin EA logic state?
EA=0In this case, internal program memory is completely ignored, only a program stored in external
memory is to be executed.

EA=1In this case, a program from built-in ROM is to be executed first (to the last location). Afterwards,
the execution is continued by reading additional memory.

in both cases, P0 and P2 are not available to the user because they are used for data and address
transmission. Besides, the pins ALE and PSEN are used too.
Data Memory

As already mentioned, Data Memory is used for temporarily storing and keeping data and intermediate
results created and used during microcontroller’s operating. Besides, this microcontroller family includes
many other registers such as: hardware counters and timers, input/output ports, serial data buffers etc. The
previous versions have the total memory size of 256 locations, while for later models this number is
incremented by additional 128 available registers. In both cases, these first 256 memory locations
(addresses 0-FFh) are the base of the memory. Common to all types of the 8052 microcontrollers.
Locations available to the user occupy memory space with addresses from 0 to 7Fh. First 128 registers
and this part of RAM is divided in several blocks.

The first block consists of 4 banks each including 8 registers designated as R0 to R7. Prior to access them,
a bank containing that register must be selected. Next memory block (in the range of 20h to 2Fh) is bit-
addressable, which means that each bit being there has its own address from 0 to 7Fh. Since there are 16
such registers, this block contains in total of 128 bits with separate addresses (The 0th bit of the 20h byte
has the bit address 0 and the 7th bit of the 2Fh byte has the bit address 7Fh). The third groups of registers
occupy addresses 2Fh-7Fh (in total of 80 locations) and does not have any special purpose or feature.

Additional Memory Block of Data Memory

In order to satisfy the programmers’ permanent hunger for Data Memory, producers have embedded an
additional memory block of 128 locations into the latest versions of the 8052 microcontrollers. Naturally,
it’s not so simple…The problem is that electronics performing addressing has 1 byte (8 bits) on disposal
and due to that it can reach only the first 256 locations. In order to keep already existing 8-bit architecture
and compatibility with other existing models a little trick has been used.

Using trick in this case means that additional memory block shares the same addresses with existing
locations intended for the SFRs (80h- FFh). In order to differentiate between these two physically
separated memory spaces, different ways of addressing are used. A direct addressing is used for all
locations in the SFRs, while the locations from additional RAM are accessible using indirect addressing.
Fig: Microcontroller internal structure
How to extend memory?

In case on-chip memory is not enough, it is possible to add two external memory chips with capacity of
64Kb each. I/O ports P2 and P3 are used for their addressing and data transmission.

From the users’ perspective, everything functions quite simple if properly connected because the most
operations are performed by the microcontroller itself. The 8052 microcontroller has two separate reading
signals RD#(P3.7) and PSEN#. The first one is activated byte from external data memory (RAM) should
be read, while another one is activated to read byte from external program memory (ROM). These both
signals are active at logical zero (0) level. A typical example of such memory extension using special
chips for RAM and ROM is shown on the previous picture. It is called Hardward architecture.
Even though the additional memory is rarely used with the latest versions of the microcontrollers, it will
be described here in short what happens when memory chips are connected according to the previous
scheme. It is important to know that the whole process is performed automatically, i.e. with no
intervention in the program.

 When the program during execution encounters the instruction which resides in external memory
(ROM), the microcontroller will activate its control output ALE and set the first 8 bits of address
(A0-A7) on P0. In this way, IC circuit 74HCT573 which "lets in" the first 8 bits to memory
address pins is activated.
 A signal on the pin ALE closes the IC circuit 74HCT573 and immediately afterwards 8 higher
bits of address (A8-A15) appear on the port. In this way, a desired location in additional program
memory is completely addressed. The only thing left over is to read its content.
 Pins on P0 are configured as inputs, the pin PSEN is activated and the microcontroller reads
content from memory chip. The same connections are used both for data and lower address byte.

Similar occurs when it is a needed to read some location from external Data Memory. Now, addressing is
performed in the same way, while reading or writing is performed via signals which appear on the control
outputs RD or WR.


While operating, processor processes data according to the program instructions. Each instruction consists
of two parts. One part describes what should be done and another part indicates what to use to do it. This
later part can be data (binary number) or address where the data is stored. All 8052 microcontrollers use
two ways of addressing depending on which part of memory should be accessed:

Direct Addressing

On direct addressing, a value is obtained from a memory location while the address of that location is
specified in instruction. Only after that, the instruction can process data (how depends on the type of
instruction: addition, subtraction, copy…). Obviously, a number being changed during operating a
variable can reside at that specified address. For example:
Since the address is only one byte in size ( the greatest number is 255), this is how only the first 255
locations in RAM can be accessed in this case the first half of the basic RAM is intended to be used
freely, while another half is reserved for the SFRs.

Indirect Addressing

On indirect addressing, a register which contains address of another register is specified in the instruction.
A value used in operating process resides in that another register. For example:

Only RAM locations available for use are accessed by indirect addressing (never in the SFRs). For all
latest versions of the microcontrollers with additional memory block (those 128 locations in Data
Memory), this is the only way of accessing them. Simply, when during operating, the instruction
including “@” sign is encountered and if the specified address is higher than 128 (7F hex.), the processor
knows that indirect addressing is used and jumps over memory space reserved for the SFRs.

On indirect addressing, the registers R0, R1 or Stack Pointer are used for specifying 8-bit addresses. Since
only 8 bits are available, it is possible to access only registers of internal RAM in this way (128 locations
in former or 256 locations in latest versions of the microcontrollers). If memory extension in form of
additional memory chip is used then the 16-bit DPTR Register (consisting of the registers DPTRL and
DPTRH) is used for specifying addresses. In this way it is possible to access any location in the range of
SFRs (Special Function Registers)

SFRs are a kind of control table used for running and monitoring microcontroller’s operating. Each of
these registers, even each bit they include, has its name, address in the scope of RAM and clearly defined
purpose ( for example: timer control, interrupt, serial connection etc.). Even though there are 128 free
memory locations intended for their storage, the basic core, shared by all types of 8052 controllers, has
only 21 such registers. Rest of locations areintensionally left free in order to enable the producers to
further improved models keeping at the same time compatibility with the previous versions. It also
enables the use of programs written a long time ago for the microcontrollers which are out of production

A Register (Accumulator)
This is a general-purpose register which serves for storing intermediate results during operating. A
number (an operand) should be added to the accumulator prior to execute an instruction upon it. Once an
arithmetical operation is preformed by the ALU, the result is placed into the accumulator. If a data should
be transferred from one register to another, it must go through accumulator. For such universal purpose,
this is the most commonly used register that none microcontroller can be imagined without (more than a
half 8052 microcontroller's instructions used use the accumulator in some way).

B Register

B register is used during multiply and divide operations which can be performed only upon numbers

stored in the A and B registers. All other instructions in the program can use this register as a spare
accumulator (A).

During programming, each of registers is called by name so that their exact address is not so important for
the user. During compiling into machine code (series of hexadecimal numbers recognized as instructions
by the microcontroller), PC will automatically, instead of registers’ name, write necessary addresses into
the microcontroller.
R Registers (R0-R7)

This is a common name for the total 8 general purpose registers (R0, R1, R2 ...R7). Even they are not true
SFRs, they deserve to be discussed here because of their purpose. The bank is active when the R registers
it includes are in use. Similar to the accumulator, they are used for temporary storing variables and
intermediate results. Which of the banks will be active depends on two bits included in the PSW Register.
These registers are stored in four banks in the scope of RAM.


The AT89S52 is a low-voltage, high-performance CMOS 8-bit microcomputer with 4K bytes of

Flash programmable memory. The device is manufactured using Atmel’s high-density nonvolatile
memory technology and is compatible with the industry-standard MCS-51 instruction set. By combining
a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcomputer,
which provides a highly flexible and cost-effective solution to many embedded control applications.

In addition, the AT89S52 is designed with static logic for operation down 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
hardware reset.
Machine cycle for the 8052

The CPU takes a certain number of clock cycles to execute an instruction. In the 8052 family, these clock
cycles are referred to as machine cycles. The length of the machine cycle depends on the frequency of the
crystal oscillator. The crystal oscillator, along with on-chip circuitry, provides the clock source for the
8052 CPU.

The frequency can vary from 4 MHz to 30 MHz, depending upon the chip rating and manufacturer. But
the exact frequency of 11.0592 MHz crystal oscillator is used to make the 8052 based system compatible
with the serial port of the IBM PC.

In the original version of 8052, one machine cycle lasts 12 oscillator periods. Therefore, to calculate the
machine cycle for the 8052, the calculation is made as 1/12 of the crystal frequency and its inverse is

LCD stands for Liquid Crystal Display. LCD is finding wide spread use replacing LEDs (seven
segment LEDs or other multi segment LEDs) because of the following reasons:

1. The declining prices of LCDs.

2. The ability to display numbers, characters and graphics. This is in contrast to LEDs,
which are limited to numbers and a few characters.
3. Incorporation of a refreshing controller into the LCD, thereby relieving the CPU of the
task of refreshing the LCD. In contrast, the LED must be refreshed by the CPU to keep
displaying the data.
4. Ease of programming for characters and graphics.

These components are “specialized” for being used with the microcontrollers, which means that
they cannot be activated by standard IC circuits. They are used for writing different messages on
a miniature LCD.

A model described here is for its low price and great possibilities most frequently used in

practice. It is based on the HD44780 microcontroller (Hitachi) and can display messages in two

lines with 16 characters each . It displays all the alphabets, Greek letters, punctuation marks,

mathematical symbols etc. In addition, it is possible to display symbols that user makes up on its
own. Automatic shifting message on display (shift left and right), appearance of the pointer,

backlight etc. are considered as useful characteristics.

Pins Functions

There are pins along one side of the small printed board used for connection to the

microcontroller. There are total of 14 pins marked with numbers (16 in case the background light

is built in). Their function is described in the table below:

Function Pin Number Name Logic State Description

Ground 1 Vss - 0V

Power supply 2 Vdd - +5V

Contrast 3 Vee - 0 - Vdd

0 D0 – D7 are interpreted as commands

4 RS
1 D0 – D7 are interpreted as data

0 Write data (from controller to LCD)

5 R/W
Control of operating 1 Read data (from LCD to controller)

0 Access to LCD disabled

6 E 1 Normal operating
From 1 to 0 Data/commands are transferred to LCD

7 D0 0/1 Bit 0 LSB

8 D1 0/1 Bit 1

9 D2 0/1 Bit 2
Data / commands
10 D3 0/1 Bit 3

11 D4 0/1 Bit 4

12 D5 0/1 Bit 5
13 D6 0/1 Bit 6

14 D7 0/1 Bit 7 MSB

LCD screen:

LCD screen consists of two lines with 16 characters each. Each character consists of 5x7 dot

matrix. Contrast on display depends on the power supply voltage and whether messages are

displayed in one or two lines. For that reason, variable voltage 0-Vdd is applied on pin marked as

Vee. Trimmer potentiometer is usually used for that purpose. Some versions of displays have

built in backlight (blue or green diodes). When used during operating, a resistor for current

limitation should be used (like with any LE diode).

LCD Basic Commands

All data transferred to LCD through outputs D0-D7 will be interpreted as commands or as data,
which depends on logic state on pin RS:

RS = 1 - Bits D0 - D7 are addresses of characters that should be displayed. Built in processor

addresses built in “map of characters” and displays corresponding symbols. Displaying position
is determined by DDRAM address. This address is either previously defined or the address of
previously transferred character is automatically incremented.

RS = 0 - Bits D0 - D7 are commands which determine display mode. List of commands which
LCD recognizes are given in the table below:

Command RS RW D7 D6 D5 D4 D3 D2 D1 D0

Clear display 0 0 0 0 0 0 0 0 0 1 1.64mS

Cursor home 0 0 0 0 0 0 0 0 1 x 1.64mS

Entry mode set 0 0 0 0 0 0 0 1 I/D S 40uS

Display on/off control 0 0 0 0 0 0 1 D U B 40uS

Cursor/Display Shift 0 0 0 0 0 1 D/C R/L x x 40uS

Function set 0 0 0 0 1 DL N F x x 40uS

Set CGRAM address 0 0 0 1 CGRAM address 40uS

Set DDRAM address 0 0 1 DDRAM address 40uS

Read “BUSY” flag (BF) 0 1 BF DDRAM address -

Write to CGRAM or DDRAM 1 0 D7 D6 D5 D4 D3 D2 D1 D0 40uS

Read from CGRAM or DDRAM 1 1 D7 D6 D5 D4 D3 D2 D1 D0 40uS

I/D 1 = Increment (by 1) R/L 1 = Shift right

0 = Decrement (by 1) 0 = Shift left

S 1 = Display shift on DL 1 = 8-bit interface

0 = Display shift off 0 = 4-bit interface

D 1 = Display on N 1 = Display in two lines

0 = Display off 0 = Display in one line

U 1 = Cursor on F 1 = Character format 5x10 dots

0 = Cursor off 0 = Character format 5x7 dots

B 1 = Cursor blink on D/C 1 = Display shift

0 = Cursor blink off 0 = Cursor shift

LCD Connection

Depending on how many lines are used for connection to the microcontroller, there are 8-

bit and 4-bit LCD modes. The appropriate mode is determined at the beginning of the process in

a phase called “initialization”. In the first case, the data are transferred through outputs D0-D7 as

it has been already explained. In case of 4-bit LED mode, for the sake of saving valuable I/O

pins of the microcontroller, there are only 4 higher bits (D4-D7) used for communication, while

other may be left unconnected.

Consequently, each data is sent to LCD in two steps: four higher bits are sent first (that

normally would be sent through lines D4-D7), four lower bits are sent afterwards. With the help

of initialization, LCD will correctly connect and interpret each data received. Besides, with

regards to the fact that data are rarely read from LCD (data mainly are transferred from

microcontroller to LCD) one more I/O pin may be saved by simple connecting R/W pin to the

Ground. Such saving has its price. Even though message displaying will be normally performed,

it will not be possible to read from busy flag since it is not possible to read from display.

LCD Initialization

Once the power supply is turned on, LCD is automatically cleared. This process lasts for

approximately 15mS. After that, display is ready to operate. The mode of operating is set by

default. This means that:

1. Display is cleared

2. Mode

DL = 1 Communication through 8-bit interface

N = 0 Messages are displayed in one line

F = 0 Character font 5 x 8 dots

3. Display/Cursor on/off
D = 0 Display off

U = 0 Cursor off

B = 0 Cursor blink off

4. Character entry

ID = 1 Addresses on display are automatically incremented by 1

S = 0 Display shift off

Automatic reset is mainly performed without any problems. Mainly but not always! If for

any reason power supply voltage does not reach full value in the course of 10mS, display will

start perform completely unpredictably. If voltage supply unit can not meet this condition or if it

is needed to provide completely safe operating, the process of initialization by which a new reset

enabling display to operate normally must be applied.

Algorithm according to the initialization is being performed depends on whether

connection to the microcontroller is through 4- or 8-bit interface. All left over to be done after

that is to give basic commands and of course- to display messages.

Fig: Procedure on 8-bit initialization.


To have a clear view of the characters on the LCD, contrast should be adjusted. To adjust the
contrast, the voltage should be varied. For this, a preset is used which can behave like a variable
voltage device. As the voltage of this preset is varied, the contrast of the LCD can be adjusted.
Fig: Variable resistor


Variable resistors used as potentiometers have all three terminals connected.

This arrangement is normally used to vary voltage, for example to set the switching point of a circuit
with a sensor, or control the volume (loudness) in an amplifier circuit. If the terminals at the ends of the
track are connected across the power supply, then the wiper terminal will provide a voltage which can be
varied from zero up to the maximum of the supply.

Potentiometer Symbol

These are miniature versions of the standard variable resistor. They are designed to be mounted directly
onto the circuit board and adjusted only when the circuit is built. For example to set the frequency of an
alarm tone or the sensitivity of a light-sensitive circuit. A small screwdriver or similar tool is required to
adjust presets.

Presets are much cheaper than standard variable resistors so they are sometimes used in projects where a
standard variable resistor would normally be used.

Multiturn presets are used where very precise adjustments must be made. The screw must be
turned many times (10+) to move the slider from one end of the track to the other, giving very
fine control.

Preset Symbol


P2.0 4 (RS) 1
P2.1 5 (R/W) 2

P2.2 6(EN) 3





89S52 P1.0 D0

P1.1 D1

P1.2 D2

P1.3 D3

P1.4 D4

P1.5 D5 15

P1.6 D6 16

P1.7 D7

A relay is an electrically controllable switch widely used in industrial controls, automobiles

and appliances.

The relay allows the isolation of two separate sections of a system with two different voltage
sources i.e., a small amount of voltage/current on one side can handle a large amount of
voltage/current on the other side but there is no chance that these two voltages mix up.


Fig: Circuit symbol of a relay


When a current flow through the coil, a magnetic field is created around the coil i.e., the
coil is energized. This causes the armature to be attracted to the coil. The armature’s
contact acts like a switch and closes or opens the circuit. When the coil is not energized, a
spring pulls the armature to its normal state of open or closed. There are all types of
relays for all kinds of applications.
Fig: Relay Operation and use of protection diodes

Transistors and ICs must be protected from the brief high voltage 'spike' produced when the
relay coil is switched off. The above diagram shows how a signal diode (eg 1N4148) is
connected across the relay coil to provide this protection. The diode is connected 'backwards' so
that it will normally not conduct. Conduction occurs only when the relay coil is switched off, at
this moment the current tries to flow continuously through the coil and it is safely diverted
through the diode. Without the diode no current could flow and the coil would produce a
damaging high voltage 'spike' in its attempt to keep the current flowing.

In choosing a relay, the following characteristics need to be considered:

1. The contacts can be normally open (NO) or normally closed (NC). In the NC type, the
contacts are closed when the coil is not energized. In the NO type, the contacts are closed when
the coil is energized.

2. There can be one or more contacts. i.e., different types like SPST (single pole single throw),
SPDT (single pole double throw) and DPDT (double pole double throw) relays.

3. The voltage and current required to energize the coil. The voltage can vary from a few volts to
50 volts, while the current can be from a few milliamps to 20milliamps. The relay has a
minimum voltage, below which the coil will not be energized. This minimum voltage is called
the “pull-in” voltage.

4. The minimum DC/AC voltage and current that can be handled by the contacts. This is in the
range of a few volts to hundreds of volts, while the current can be from a few amps to 40A or
more, depending on the relay.

A relay is used to isolate one electrical circuit from another. It allows a low current control
circuit to make or break an electrically isolated high current circuit path. The basic relay consists
of a coil and a set of contacts. The most common relay coil is a length of magnet wire wrapped
around a metal core. When voltage is applied to the coil, current passes through the wire and
creates a magnetic field. This magnetic field pulls the contacts together and holds them there
until the current flow in the coil has stopped. The diagram below shows the parts of a simple

Figure: Relay


When a current flows through the coil, the resulting magnetic field attracts an armature that is
mechanically linked to a moving contact. The movement either makes or breaks a connection
with a fixed contact. When the current is switched off, the armature is usually returned by a
spring to its resting position shown in figure 6.6(b). Latching relays exist that require operation
of a second coil to reset the contact position.
By analogy with the functions of the original electromagnetic device, a solid-state relay operates
a thyristor or other solid-state switching device with a transformer or light-emitting diode to
trigger it.

Pole and throw


SPST relay stands for Single Pole Single Throw relay. Current will only flow through the
contacts when the relay coil is energized.

Figure: SPST Relay

SPDT Relay

SPDT Relay stands for Single Pole Double Throw relay. Current will flow between the movable
contact and one fixed contact when the coil is De-energized and between the movable contact
and the alternate fixed contact when the relay coil is energized. The most commonly used relay
in car audio, the Bosch relay, is a SPDT relay.

Figure: SPDT Relay

DPST Relay

DPST relay stands for Double Pole Single Throw relay. When the relay coil is energized, two
separate and electrically isolated sets of contacts are pulled down to make contact with their
stationary counterparts. There is no complete circuit path when the relay is De-energized.

Figure: DPST Relay

DPDT Relay

DPDT relay stands for Double Pole Double Throw relay. It operates like the SPDT relay but has
twice as many contacts. There are two completely isolated sets of contacts.

Figure: DPDT Relay

This is a 4 Pole Double Throw relay. It operates like the SPDT relay but it has 4 sets of isolated
Figure: 4 Pole Double Throw relay

Types of relay:

1. Latching Relay
2. Reed Relay
3. Mercury Wetted Relay
4. Machine Tool Relay
5. Solid State Relay (SSR)

Latching relay
Latching relay, dust cover removed, showing pawl and ratchet mechanism. The ratchet operates
a cam, which raises and lowers the moving contact arm, seen edge-on just below it. The moving
and fixed contacts are visible at the left side of the image.

A latching relay has two relaxed states (bi-stable). These are also called "impulse", "keep", or
"stay" relays. When the current is switched off, the relay remains in its last state. This is achieved
with a solenoid operating a ratchet and cam mechanism, or by having two opposing coils with an
over-center spring or permanent magnet to hold the armature and contacts in position while the
coil is relaxed, or with a remanent core. In the ratchet and cam example, the first pulse to the coil
turns the relay on and the second pulse turns it off. In the two coil example, a pulse to one coil
turns the relay on and a pulse to the opposite coil turns the relay off. This type of relay has the
advantage that it consumes power only for an instant, while it is being switched, and it retains its
last setting across a power outage. A remnant core latching relay requires a current pulse of
opposite polarity to make it change state.

Figure: Latching relay

Reed relay

A reed relay has a set of contacts inside a vacuum or inert gas filled glass tube, which protects
the contacts against atmospheric corrosion. The contacts are closed by a magnetic field generated
when current passes through a coil around the glass tube. Reed relays are capable of faster
switching speeds than larger types of relays, but have low switch current and voltage ratings.

Mercury-wetted Relay

A mercury-wetted reed relay is a form of reed relay in which the contacts are wetted with
mercury. Such relays are used to switch low-voltage signals (one volt or less) because of their
low contact resistance, or for high-speed counting and timing applications where the mercury
eliminates contact bounce. Mercury wetted relays are position-sensitive and must be mounted
vertically to work properly. Because of the toxicity and expense of liquid mercury, these relays
are rarely specified for new equipment. See also mercury switch.

Machine tool relay

A machine tool relay is a type standardized for industrial control of machine tools, transfer
machines, and other sequential control. They are characterized by a large number of contacts
(sometimes extendable in the field) which are easily converted from normally-open to normally-
closed status, easily replaceable coils, and a form factor that allows compactly installing many
relays in a control panel. Although such relays once were the backbone of automation in such
industries as automobile assembly, the programmable logic controller (PLC) mostly displaced
the machine tool relay from sequential control applications.

Solid-state relay

A solid state relay (SSR) is a solid state electronic component that provides a similar function to
an electromechanical relay but does not have any moving components, increasing long-term
reliability. With early SSR's, the tradeoff came from the fact that every transistor has a small
voltage drop across it. This voltage drop limited the amount of current a given SSR could handle.
As transistors improved, higher current SSR's, able to handle 100 to 1,200 Amperes, have
become commercially available. Compared to electromagnetic relays, they may be falsely
triggered by transients.

Figure: Solid relay, which has no moving parts


 Number and type of contacts – normally open, normally closed, (double-throw)

 Contact sequence – "Make before Break" or "Break before Make". For example, the old
style telephone exchanges required Make-before-break so that the connection didn't get
dropped while dialing the number.
 Rating of contacts – small relays switch a few amperes, large contactors are rated for up
to 3000 amperes, alternating or direct current
 Voltage rating of contacts – typical control relays rated 300 VAC or 600 VAC,
automotive types to 50 VDC, special high-voltage relays to about 15 000 V
 Coil voltage – machine-tool relays usually 24 VAC, 120 or 250 VAC, relays for
switchgear may have 125 V or 250 VDC coils, "sensitive" relays operate on a few milli-


Relays are used:

 To control a high-voltage circuit with a low-voltage signal, as in some types of modems,

 To control a high-current circuit with a low-current signal, as in the starter solenoid of an
 To detect and isolate faults on transmission and distribution lines by opening and closing
circuit breakers (protection relays),
 To isolate the controlling circuit from the controlled circuit when the two are at different
potentials, for example when controlling a mains-powered device from a low-voltage
switch. The latter is often applied to control office lighting as the low voltage wires are
easily installed in partitions, which may be often moved as needs change. They may also
be controlled by room occupancy detectors in an effort to conserve energy,
 To perform logic functions. For example, the boolean AND function is realized by
connecting relay contacts in series, the OR function by connecting contacts in parallel.
Due to the failure modes of a relay compared with a semiconductor, they are widely used
in safety critical logic, such as the control panels of radioactive waste handling
 As oscillators, also called vibrators. The coil is wired in series with the normally closed
contacts. When a current is passed through the relay coil, the relay operates and opens the
contacts that carry the supply current. This stops the current and causes the contacts to
close again. The cycle repeats continuously, causing the relay to open and close rapidly.
Vibrators are used to generate pulsed current.
 To generate sound. A vibrator, described above, creates a buzzing sound because of the
rapid oscillation of the armature. This is the basis of the electric bell, which consists of a
vibrator with a hammer attached to the armature so it can repeatedly strike a bell.
 To perform time delay functions. Relays can be used to act as an mechanical time delay
device by controlling the release time by using the effect of residual magnetism by means
of a inserting copper disk between the armature and moving blade assembly.

This circuits has 2 stages: A transmitter unit and a receiver unit. The
transmitters consist of an infrared led and its associated circuitry.

IR transmitter

An electroluminescent IR LED is a product which requires care in use. IR

LEDs are fabricated from narrow band heterostructures with energy gap from
0.25 to 0.4 eV. Infra red transmitter emits IR rays in planar wave

front manner. Even though Infrared rays spreads in all directions, it

propagates along straight line in forward direction. IR rays have the
characteristics of producing secondary wavelets when it collides with any
obstacles in its path.
When IR rays gets emitted from LED, it moves in the direction it is angled. When
any obstacle interferes in the path, the IR rays get cut and it produces secondary
wavelets which propagates mostly in return direction or in a direction opposite to
that of the primary waves, which produces the net result like reflection of IR rays

IR receiver

Infrared photo receiver is a two terminal PN junction device, which operates in a

reverse bias. It has a small transparent window, which allows light to strike the
PN junction. A photodiode is a type of photo detector capable of converting light
into either current or voltage, depending upon the mode of operation. Most
photodiodes will look similar to a light emitting diode. They will have two leads,
or wires, coming from the bottom. The shorter end of the two is the cathode,
while the longer end is the anode.

A photodiode consists of PN junction or PIN structure. When a photon of

sufficient energy strikes the diode, it excites an electron thereby creating a
mobile electron and a positively charged electron hole. If the absorption occurs in
the junction's depletion region, or one diffusion length away from it, these carriers
are swept from the junction by the built-in field of the depletion region. Thus
holes move toward the anode, and electrons toward the cathode, and a
photocurrent is produced.
What is Zigbee Technology?

What is Zigbee Technology?

Zigbee communication is specially built for control and sensor networks on IEEE 802.15.4
standard for wireless personal area networks (WPANs), and it is the product from Zigbee
alliance. This communication standard defines physical and Media Access Control (MAC) layers
to handle many devices at low-data rates. These Zigbee’s WPANs operate at 868 MHz, 902-
928MHz and 2.4 GHz frequencies. The date rate of 250 kbps is best suited for periodic as well as
intermediate two way transmission of data between sensors and controllers.

Zigbee Modem
Zigbee is low-cost and low-powered mesh network widely deployed for controlling and
monitoring applications where it covers 10-100 meters within the range. This communication
system is less expensive and simpler than the other proprietary short-range wireless sensor
networks as Bluetooth and Wi-Fi.
Zigbee supports different network configurations for master to master or master to slave
communications. And also, it can be operated in different modes as a result the battery power is
conserved. Zigbee networks are extendable with the use of routers and allow many nodes to
interconnect with each other for building a wider area network.
Zigbee Architecture

Zigbee system structure

Zigbee system structure consists of three different types of devices such as Zigbee coordinator,
Router and End device. Every Zigbee network must consist of at least one coordinator which acts
as a root and bridge of the network. The coordinator is responsible for handling and storing the
information while performing receiving and transmitting data operations. Zigbee routers act as
intermediary devices that permit data to pass to and fro through them to other devices. End
devices have limited functionality to communicate with the parent nodes such that the battery
power is saved as shown in the figure. The number of routers, coordinators and end devices
depends on the type of network such as star, tree and mesh networks.

Zigbee protocol architecture consists of a stack of various layers where IEEE 802.15.4 is defined
by physical and MAC layers while this protocol is completed by accumulating Zigbee’s own
network and application layers.

Zigbee protocol architecture

Physical Layer: This layer does modulation and demodulation operations up on transmitting and
receiving signals respectively. This layer’s frequency, date rate and number of channels are
given below.

Physical Layer of Zigbee Protocol

MAC Layer: This layer is responsible for reliable transmission of data by accessing different
networks with the carrier sense multiple access collision avoidance (CSMA). This also transmits
the beacon frames for synchronizing communication.
Network Layer: This layer takes care of all network related operations such as network setup,
end device connection and disconnection to network, routing, device configurations, etc.
Application Support Sub-Layer: This layer enables the services necessary for Zigbee device
object and application objects to interface with the network layers for data managing services.
This layer is responsible for matching two devices according to their services and needs.
Application Framework: It provides two types of data services as key value pair and generic
message services. Generic message is a developer defined structure, whereas the key value pair
is used for getting attributes within the application objects. ZDO provides an interface between
application objects and APS layer in Zigbee devices. It is responsible for detecting, initiating and
binding other devices to the network.
Zigbee Operating Modes and Its Topologies

Zigbee Communication Operation

Zigbee two way data is transferred in two modes: Non-beacon mode and Beacon mode. In a
beacon mode, the coordinators and routers continuously monitor active state of incoming data
hence more power is consumed. In this mode, the routers and coordinators do not sleep because
at any time any node can wake up and communicate. However, it requires more power supply
and its overall power consumption is low because most of the devices are in an inactive state for
over long periods in the network.

In a beacon mode, when there is no data communication from end devices, then the routers and
coordinators enter into sleep state. Periodically this coordinator wakes up and transmits the
beacons to the routers in the network. These beacon networks are work for time slots which
means, they operate when the communication needed results in lower duty cycles and longer
battery usage. These beacon and non-beacon modes of Zigbee can manage periodic (sensors
data), intermittent (Light switches) and repetitive data types.

Data transfer
The data is transferred in packets. These have a maximum size of 128 bytes, allowing for a
maximum payload of 104 bytes. Although this may appear low when compared to other systems,
the applications in which 802.15.4 and ZigBee are likely to be used should not require very high
data rates.
The standard supports 64 bit IEEE addresses as well as 16 bit short addresses. The 64 bit
addresses uniquely identify every device in the same way that devices have a unique IP address.
Once a network is set up, the short addresses can be used and this enables over 65000 nodes to
be supported.
It also has an optional superframe structure with a method for time synchronisation. In addition
to this it is recognised that some messages need to be given a high priority. To achieve this, a
guaranteed time slot mechanism has been incorporated into the specification. This enables these
high priority messages to be sent across the network as swiftly as possible.
What is RFID?
Radio-Frequency Identification (RFID) is the use of radio waves to read and capture information stored
on a tag attached to an object. A tag can be read from up to several feet away and does not need to be
within direct line-of-sight of the reader to be tracked.

How does a RFID system work?

A RFID system is made up of two parts: a tag or label and a reader. RFID tags or labels are embedded
with a transmitter and a receiver. The RFID component on the tags has two parts: a microchip that
stores and processes information, and an antenna to receive and transmit a signal. The tag contains the
specific serial number for one specific object.

To read the information encoded on a tag, a two-way radio transmitter-receiver called an interrogator
or reader emits a signal to the tag using an antenna. The tag responds with the information written in its
memory bank. The interrogator will then transmit the read results to an RFID computer program.
There are two types of RFID tags: passive and battery powered. A passive RFID tag will use the
interrogator’s radio wave energy to relay its stored information back to the interrogator. A batter
powered RFID tag is embedded with a small battery that powers the relay of information.

In a retail setting, RFID tags may be attached to articles of clothing. When an inventory associate uses a
handheld RFID reader to scan a shelf of jeans, the associate is able to differentiate between two pairs of
identical jeans based upon the information stored on the RFID tag. Each pair will have its own serial

With one pass of the handheld RFID reader, the associate can not only find a specific pair, but they
can tell how many of each pair are on the shelf and which pairs need to be replenished. The associate
can learn all of this information without having to scan each individual item.

 Reduces congestion
 Smooth functioning in parking slot.
 Ease of operation due to the availability of robot to make the movements of vehicles.
 Easily the empty slot in the parking slot can be identified.


The real time project will be very costly.


 Malls ,Bus Stops, Airport

 Railways


We Can use this mechanism in the places where we have a lots of issues with the
parking area and can efficiently use the limited space of parking

Hence, in a developing countries like India where we face a lots of issues regarding

parking in public areas, this can be a revolutionary mechanism.


4. Magazines:

Electronics for you


Go Wireless