You are on page 1of 87

Intelligent Car Parking Management System

using Microcontroller
Project Report
SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENT FOR
THE AWARD OF THE DEGREE
OF

BACHELOR OF TECHNOLOGY
(Electronics & Communication Engineering)

SUBMITTED BY
SANDEEP KUMAR
1154717

Under the guidance of


Er. Navneet Kaur
Assistant Professor

Shaheed Udham Singh Collage of Engineering and Technology Tangori


Mohali,Punjab

PUNJAB TECHNICAL UNIVERSITY


JALANDHAR,PUNJAB(INDIA)

DECLARATION
I hereby declare that the work which is being presented in the dissertation entitled
INTELLIGENT

CAR

PARKING

MANAGEMENT

SYSTEM

USING

MICROCONTROLLER submitted in partial fulfillment of requirements for the award of


degree of Bachelor of Technology in Electronics and Communication Engineering in the
Department of Electronics and Communication Engineering at Shaheed Udham Singh Collage
of

Engineering

and

Technology

Tangori

Mohali

under

the

Punjab

Technical

University,Jalandhar is an authentic record of my own work carried out at SUSCET,Tangori


campus under the supervision of Er. Navneet Kaur.The material embodied in this project has
not been submitted to any other university or institude for the reward of B.Tech Degree.

Name of Student
1154717

This is to certify that the above statement made by the candidate is corrent to the best of my
knowledge

Name of Guide
Er. Navneet Kaur

CERTIFICATE

This is to certify that the project entitled INTELLIGENT CAR PARKING MANAGEMENT
SYSTEM USING MICROCONTROLLER is the bonafide work carried out by SANDEEP
KUMAR student of B.Tech , Punjab Technology University,Jalandhar,during the year 2013,in
partial fulfillment of the requirements for the award of the Degree of Bachelor of Electronics and
communication Engineering and that the project has not formed the basis for the award
previously of any degree, diploma, associateship, fellowship or any other similar title.

Signature of the Guide:


Place:
Date:

ACKNOWLEDGEMENT
I am highly grateful to the Prof A.S. BAJWA, HOD(E.C.E.) of Shaheed Udham Singh Collage
of Engineering & Technology, Tangori(Mohali), for providing this opportunity to carry out the
project under guidance.
It gives me great satisfication on completion of Project entitled INTELLIGENT CAR
PARKING MANAGEMENT SYSTEM USING MICROCONTROLLER. The entire
journey from the very idea of this project to reality would not have been possible without the
guidance and support of guidance.
I am deeply indebted to my project guide ER. NAVNEET KAUR sharing their insights on the
topics and for being a constant source of inspiration & courage during the entire project
work.She was always available;correcting mistakes, intelligently directing me to proper sources
of information advising to aim for simplicity, brevity, clarity and accuracy. I am extremely
grateful for their guidance and support that was indispensable for the completion of this project.
Finally,my special thanks to all those who have help me directly or indirectly in the completion
of my project work by providing motivation, inspiration & valuable information as well.

SANDEEP KUMAR

IV

Table of contents
CHAPTER
NO.

TITLE

PAGE NO.

Title Page .....i


Declaration of the Student...........ii
Certificate ....iii
Acknowledgement...iv
Table of Contents v
Chapter 1 INTRODUCTION
1.1 Project Overview.........7
1.2 Block Diagram.8
Chapter 2 SYSTEM DESIGN AND WORKING ....8
2.1 Hardware Description .8
2.2 Software Description .80
Chapter 3 CIRCUIT DIAGRAM .................................. 86
Chapter 4 SOFTWARE CODES............................... 77

CHAPTER- 1
INTRODUCTION

1.1 Project overview


The numbers of vehicles are increasing at a very rapid rate. To manage these vehicles there is a
need of a proper parking system. The most common problem often encountered while dealing
with vehicles is the over-crowding of parking places, which finally leads to the wastage of fuel
and precious time of people.
The ultimate aim of the technology is to reduce the load on people and ease them, so here is a
need to develop an automatic parking system, which can manage the number of cars inside a
parking area. It must have the provision to inform the person trying to enter the parking area,
whether a space to park the vehicle is available inside the parking area.
In the project Intelligent Car Parking Management System using microcontroller we have
shown the concept of an automatic car parking system. As in the modern world everything is
going automatic we have built a system which will automatically sense the in the parking lot and
displays it on the LCD weather the slot is full or empty. The heart of the project is AT89C51
microcontroller.
The AT89C51 is a low-power, high-performance CMOS 8-bit microcontroller with 4K bytes of
in-system programmable Flash memory. The device is manufactured using Atmels high-density
nonvolatile memory technology and is compatible with the industry-standard 80C51 instruction
set and pin out. 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 insystem programmable Flash on a monolithic chip, the Atmel's AT89C51 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 AT89C51 is designed with static logic for operation down to zero
frequency and supports two software selectable power saving modes.

BLOCK DIAGRAM:

LCD

MCU

POWER
SUPPLY

COMPARA
TOR 1

IR
SENSOR 1

IR
SENSOR 2

CHAPTER- 2
SYSTEM DESIGN AND WORKING
2.1 Hardware Description
POWER SUPPLY
All electronic circuits need power source to run. Electronic circuits which are made up of
transistors and ICs require DC power source to run. A battery is common DC voltage source for
some type of electronic equipment especially for portable devices such as cell phones and iPods.
But non portable devices require power supplies to operate from AC power line but produce one
or more DC output.
All electronic circuits need smooth DC power supply in order to function correctly. The DC
power supply is either from battery or from power pack units. The battery power supply is not
being economical and some circuits using digital IC need their power supply to be regulated.
A POWER SUPPLY is a device which converts, regulates, and transmits the required power to
the circuit to be operated.
The input of power supply is 240volts 50 Hz frequency. The power supply converts the AC into
DC and provides one or more DC output voltages. Common voltages are
48,24,15,12,9,5,3.3,2.5,1.8,1.5,1.2 and 1 volts.
Elements of power supply
Transformer: It is a device used to convert the ac line voltage level from appropriate to

the needs of circuit to be operated. At the same time it also provides isolation between the
ac line and the circuit to be operated. The output of transformer is ac voltage but of an
appropriate magnitude for circuit to powered.
Rectifier: It is a device which converts ac voltage into pulsating dc. Rectifier uses a
unidirectional device called P-N junction diodes. Rectifier can be half wave, Full wave or
Bridge rectifier. Out of these three rectifiers we use bridge rectifier because it has
maximum efficiency.
Filter: The output from rectifier section is a pulsating DC. The filter circuit reduces the
peak to peak pulses to small ripple voltage. Filter can be capacitor filter, RC filter.
Regulator: Two common types of circuitry for voltage regulation are discrete transistors
and ICs. Discrete-Transistor regulators are of series voltage regulator, current-limiting
circuit, and shunt voltage regulator.

Indicator: Indicators are used to indicate that the power supply is on and working

properly. The most commonly used indicators used are led. The led indicator can never be
connected directly and it is applied via resistance wire between outputs and led. Indicator
is last stage of the power supply and it also shows that the power supply is working
correctly.
TRANSFORMER:

FIG.2.1 TRANSFORMER
Transformer is a device that transfers electrical energy from one circuit to another
through inductively coupled conductors the transformer's coils or "windings".
Transformers, the conductors are commonly wound around a single iron-rich core, or around
separate but magnetically coupled cores. A varying current in the first or "primary" winding
creates a varying magnetic field in the core (or cores) of the transformer. This varying magnetic
field induces a varying electromotive force (EMF) or "voltage" in the "secondary" winding. This
effect is called mutual induction. If a load is connected to the secondary circuit, electric charge
will flow in the secondary winding of the transformer and transfer energy from the primary
circuit to the load connected in the secondary circuit. The secondary induced voltage VS, of an
ideal transformer, is scaled from the primary VP by a factor equal to the ratio of the number of
turns of wire in their respective windings: By appropriate selection of the numbers of turns, a
transformer thus allows an alternating voltage to be stepped up by making NS more than NP
or stepped down, by making it
The secondary induced voltage VS, of an ideal transformer, is scaled from the primary VP by a
factor equal to the ratio of the number of turns of wire in their respective windings:

Transformers are of two types:


1. Step up transformer
2. Step down transformer
In power supply we use step down transformer. We apply 220V AC on the primary of step down
transformer. This transformer steps down this voltage to 9V AC. We give this 9 V AC to rectifier
circuit, which convert it to 5V DC.
BASIC PARTS OF A TRANSFORMER
In its most basic form a transformer consists of:
A primary coil or winding.
A secondary coil or winding.
A core that supports the coils or windings.
The primary winding is connected to a 60-hertz ac voltage source. The magnetic field (flux)
builds up (expands) and collapses (contracts) about the primary winding. The expanding and
contracting magnetic field around the primary winding cuts the secondary winding and induces
an alternating voltage into the winding. This voltage causes alternating current to flow through
the load. The voltage may be stepped up or down depending on the design of the primary and
secondary winding.

FIG.2.2
THE COMPONENTS OF A TRANSFORMER
Two coils of wire (called windings) are wound on some type of core material. In some cases the
coils of wire are wound on a cylindrical or rectangular cardboard form. In effect, the core
material is air and the transformer is called an AIR-CORE TRANSFORMER. Transformers used
at low frequencies, such as 60 hertz and 400 hertz, require a core of low-reluctance magnetic
material, usually iron. This type of transformer is called an IRON-CORE TRANSFORMER.

Most power transformers are of the iron-core type. The principle parts of a transformer and their
functions are:
The CORE, which provides a path for the magnetic lines of flux.
The PRIMARY WINDING, which receives energy from the ac source.
The SECONDARY WINDING, which receives energy from the primary winding and delivers it
to the load.
The ENCLOSURE, which protects the above components from dirt, moisture, and mechanical
damage.
RECTIFIER
The main component of rectifier circuit is diode. Thus before explaining rectifier we should
know about diodes .
Diodes

FIG.2.3.
Circuit symbol:
FIG.2.4.
Function
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.

Forward Voltage Drop

Electricity uses up a little energy pushing its way through the diode, rather like a person pushing
through a door with a spring. This means that there is a small voltage across a conducting diode,
it is called the forward voltage drop and is about 0.7V for all normal diodes which are made from
silicon. The forward voltage drop of a diode is almost constant whatever the current passing
through the diode so they have a very steep characteristic (current-voltage graph).
Reverse Voltage
When a reverse voltage is applied a perfect diode does not conduct, but all real diodes leak a
very tiny current of a few A or less. This can be ignored in most circuits because it will be very
much smaller than the current flowing in the forward direction. However, all diodes have a
maximum reverse voltage (usually 50V or more) and if this is exceeded the diode will fail and
pass a large current in the reverse direction, this is called breakdown.
Ordinary diodes can be split into two types: Signal diodes which pass small currents of 100mA
or less and Rectifier diodes which can pass large currents. In addition there are LEDs and Zener
diodes.
Connecting and soldering
Diodes must be connected the correct way round, the diagram may be
labeled a or + for anode and k or - for cathode (yes, it really is k, not c,
for cathode!). The cathode is marked by a line painted on the body.
Diodes are labeled with their code in small print; you may need a
magnifying glass to read this on small signal diodes!
Small signal diodes can be damaged by heat when soldering, but the
risk is small unless you are using a germanium diode (codes beginning OA...) in which case you
should use a heat sink clipped to the lead between the joint and the diode body. A standard
crocodile clip can be used as a heat sink.
Rectifier diodes are quite robust and no special precautions are needed for soldering them.
Testing diodes
You can use a multimeter or a simple tester (battery, resistor and LED) to check that a diode
conducts in one direction but not the other. A lamp may be used to test a rectifier diode, but do
NOT use a lamp to test a signal diode because the large current passed by the lamp will destroy
the diode!

Signal diodes (small current)

Signal diodes are used to process information (electrical signals) in circuits, so they are only
required to pass small currents of up to 100mA. General purpose signal diodes such as the
1N4148 are made from silicon and have a forward voltage drop of 0.7V.
Germanium diodes such as the OA90 have a lower forward voltage drop of 0.2V and this makes
them suitable to use in radio circuits as detectors which extract the audio signal from the weak
radio signal.
For general use, where the size of the forward voltage drop is less important, silicon diodes are
better because they are less easily damaged by heat when soldering, they have a lower resistance
when conducting, and they have very low leakage currents when a reverse voltage is applied.
Protection diodes for relays
Signal diodes are also used to protect transistors and ICs from the brief high voltage produced
when a relay coil is switched off. The diagram shows how a protection diode is connected
'backwards' across the relay coil.
Current flowing through a relay coil creates a magnetic field which collapses suddenly when the
current is switched off. The sudden collapse of the magnetic field induces a brief high voltage
across the relay coil which is very likely to damage transistors and ICs. The protection diode
allows the induced voltage to drive a brief current through the coil (and diode) so the magnetic
field dies away quickly rather than instantly. This prevents the induced voltage becoming high
enough to cause damage to transistors and ICs.

Rectifier diodes

(large current)

Rectifier diodes
convert
current (DC), a
are also used
current
must

are used in power supplies to


alternating current (AC) to direct
process called rectification. They
elsewhere in circuits where a large
pass through the diode.

All
rectifier
diodes are made from silicon and
therefore have
a forward voltage drop of 0.7V.
The table shows maximum current and maximum reverse voltage for some popular rectifier
diodes. The 1N4001 is suitable for most low voltage circuits with a current of less than 1A.

Maximum
Maximum
Diode
Reverse
Current
Voltage
APPLICATION
Diodes: Rectification, free-wheeling, etc.
Zener diode: Voltage control, regulator etc.
Tunnel diode: Control the current flow, snobbier circuit, etc.

1N4001

1A

50V

1N4002

1A

100V

1N4007

1A

1000V

1N5401

3A

100V

1N5408

3A

1000V

RECTIFIER
Rectification is the conversion of alternating current (AC) to direct current (DC). This involves a
device that only allows one-way flow of electrons. This is exactly what a semiconductor diode
does.
A half-wave rectifier is a circuit that allows only one half-cycle of the AC voltage waveform to
be applied to the load, resulting in one non-alternating polarity across it. The resulting DC
delivered to the load pulsates significantly.
A full-wave rectifier is a circuit that converts both half-cycles of the AC voltage waveform to an
unbroken series of voltage pulses of the same polarity. The resulting DC delivered to the load
doesnt pulsate as much.
Polyphase alternating current, when rectified, gives a much smoother DC waveform(less
ripple voltage) than rectified single-phase AC.
HALF WAVE RECTIFIER
The simplest kind of rectifier circuit is the half-wave rectifier. It only allows one half of an AC
waveform to pass through to the load.
For most power applications, half-wave rectification is insufficient for the task. The harmonic
content of the rectifiers output waveform is very large and consequently difficult to filter.
Furthermore, the AC power source only supplies power to the load one half every full cycle,
meaning that half of its capacity is unused. Half-wave rectification is, however, a very simple
way to reduce power to a resistive load.
FULL WAVE RECTIFIER
If we need to rectify AC power to obtain the full use of both half-cycles of the sine wave, a
different rectifier circuit configuration must be used. Such a circuit is called a full-wave rectifier.
One kind of full-wave rectifier, called the center-tap design, uses a transformer with a centertapped secondary winding and two diodes,
This circuits operation is easily understood one half-cycle at a time.
Consider the first half cycle, when the source voltage polarity is positive (+) on top and negative
(-) on bottom. At this time, only the top diode is conducting; the bottom diode is blocking
current, and the load sees the first half of the sine wave, positive on top and negative on
bottom. Only the top half of the transformers secondary winding carries current during this halfcycle. During the next half-cycle, the AC polarity reverses. Now, the other diode and the other
half of the transformers secondary winding carry current while the portions of the circuit
formerly carrying current during the last half-cycle sit idle. The load still sees half of a sine
wave, of the same polarity as before: positive on top and negative on bottom.

One disadvantage of this full-wave rectifier design is the necessity of a transformer with a centertapped secondary winding. If the circuit in question is one of high power, the size and expense of
a suitable transformer is significant. Consequently, the center-tap rectifier design is only seen in
low-power applications.
The full-wave center-tapped rectifier polarity at the load may be reversed by changing the
direction of the diodes. Furthermore, the reversed diodes can be paralleled with an existing
positive-output rectifier. The result is dual-polarity full-wave center-tapped rectifier.
BRIDGE RECTIFIER
A bridge rectifier makes use of four diodes in a bridge arrangement to achieve full-wave
rectification. This is a widely used configuration, both with individual diodes wired and with
single component bridges where the diode bridge is wired internally.
According to the conventional model of current flow originally established by Benjamin Franklin
and still followed by most engineers today, current is assumed to flow through electrical
Conductors from the positive to the negative pole. In actuality, free electrons in a conductor
nearly always flow from the negative to the positive pole. In the vast majority of applications,
however, the irrelevant. Therefore, in the discussion below the conventional model is retained.
It is built around a four-diode bridge configuration. For obvious reasons, this design is called a
full-wave bridge.
The current flow is through two diodes in series for both polarities. Thus, two diode drops of the
source voltage are lost (0.72=1.4 V for Si) in the diodes. This is a disadvantage compared with a
full-wave center-tap design. This disadvantage is only a problem in very low voltage power
supplies. Diodes in a full-wave bridge rectifier circuit can often be frustrating to the new student
of electronics.
The Capacitor Filter
Capacitor passive electronic component consisting of a pair of conductors separated by a
dielectric. When a voltage potential difference exists between the conductors, an electric field is
present in the dielectric. This field stores energy and produces a mechanical force between the
plates.
An ideal capacitor is characterized by a single constant value, capacitance, which is measured in
farads.
C=Q/V

In a way, a capacitor is a little like a battery. Although they work in completely different ways,
capacitors and batteries both store electrical energy. If you have read how Batteries Work, then
you knows that a battery has two terminals. Inside the battery, chemical reactions produce
electrons on one terminal and absorb electrons at the other terminal.
BASIC
Like a battery, a capacitor has two terminals. Inside the capacitor, the terminals connect to two
metal plates separated by a dielectric. The dielectric can be air, paper, plastic or anything else
that does not conduct electricity and keeps the plates from touching each other. You can easily
make a capacitor from two pieces of aluminum foil and a piece of paper. It won't be a
particularly good capacitor in terms of its storage capacity, but it will work. In an electronic
circuit, a capacitor is shown like this: When you connect a capacitor to a battery, heres what
happens:
The plate on the capacitor that attaches to the negative terminal of the battery accepts electrons
that the battery is producing.
The plate on the capacitor that attaches to the positive terminal of the battery loses electrons to
the battery.
Function
Capacitors store electric charge. They are used with resistors in timing circuit because it takes
time for a capacitor to fill with charge. They are used to smooth varying DC supplies by acting as

a reservoir of charge. They are also used in filter circuits because capacitors easily pass AC
(changing) signals but they block DC (constant) signals.
Capacitance
This is a measure of a capacitor's ability to store charge. A large capacitance means that more
charge can be stored. Capacitance is measured in farads, symbol F. However 1F is very large, so
prefixes are used to show the smaller values.
Three prefixes (multipliers) are used, (micro), n (nano) and p (pico):

means 10-6 (millionth), so 1000000F = 1F


n means 10-9 (thousand-millionth), so 1000nF = 1F

p means 10-12 (million-millionth), so 1000pF = 1nF

Capacitor values can be very difficult to find because there are many types of capacitor with
different labeling systems!
There are many types of capacitor but they can be split into two groups, polarized and unpolarized. Each group has its own circuit symbol.
Polarized capacitors (large values, 1F +)

Circuit symbol:
Electrolytic Capacitors
Electrolytic capacitors are polarized and they must be connected the correct way round, at least
one of their leads will be marked + or -. They are not damaged by heat when soldering.
There are two designs of electrolytic capacitors; axial where the leads are attached to each end
(220F in picture) and radial where both leads are at the same end (10F in picture). Radial
capacitors tend to be a little smaller and they stand upright on the circuit board.
It is easy to find the value of electrolytic capacitors because they are clearly printed with their
capacitance and voltage rating. The voltage rating can be quite low (6V for example) and it
should always be checked when selecting an electrolytic capacitor. If the project parts list does
not specify a voltage, choose a capacitor with a rating which is greater than the project's power
supply voltage. 25V is a sensible minimum for most battery circuits.
Tantalum Bead Capacitors

Tantalum bead capacitors are polarized and have low voltage ratings like electrolytic capacitors.
They are expensive but very small, so they are used where a large capacitance is needed in a
small size.
Modern tantalum bead capacitors are printed with their capacitance, voltage and polarity in full.
However older ones use a color-code system which has two stripes (for the two digits) and a spot
of color for the number of zeros to give the value in F. The standard color code is used, but for
the spot, grey is used to mean 0.01 and white means 0.1 so that values of less than 10F can
be shown. A third color stripe near the leads shows the voltage (yellow 6.3V, black 10V, green
16V, blue 20V, grey 25V, white 30V, pink 35V). The positive (+) lead is to the right when the
spot is facing you: 'when the spot is in sight, the positive is to the right'.

For example: blue, grey, black spot means 68F


For example: blue, grey, white spot means 6.8F
For example: blue, grey, grey spot means 0.68F
Un-polarized capacitors (small values, up to 1F)

Circuit symbol:

Small value capacitors are un-polarized and may be connected either way round. They are not
damaged by heat when soldering, except for one unusual type (polystyrene). They have high
voltage ratings of at least 50V, usually 250V or so. It can be difficult to find the values of these
small capacitors because there are many types of them and several different labeling systems!
Many small value capacitors have their value printed but without a multiplier, so
you need to use experience to work out what the multiplier should be!
For example 0.1 means 0.1F = 100nF.
Sometimes the multiplier is used in place of the decimal point:
For example: 4n7 means 4.7nF.

Capacitor Number Code


A number code is often used on small capacitors where printing is difficult:
the 1st number is the 1st digit,
the 2nd number is the 2nd digit,

The 3rd number is the number of zeros to give the capacitance in pF.

Ignore any letters - they just indicate tolerance and voltage rating.

For example: 102 means 1000pF = 1nF (not 102pF!)


For example: 472J means 4700pF = 4.7nF (J means 5% tolerance).
Capacitor Color Code
A color code was used on polyester capacitors for many years. It is now obsolete, but of course
there are many still around. The colors should be read like the resistor code, the top three color
bands giving the value in pF. Ignore the 4th band (tolerance) and 5th band
(voltage rating).
For example:
Brown, black, orange means 10000pF = 10nF = 0.01F.
Note that there are no gaps between the colors bands, so 2 identical bands actually
appear as a wide band.
For example:
Wide red, yellow means 220nF = 0.22F.
Polystyrene Capacitors
This type is rarely used now. Their value (in pF) is normally printed
without units. Polystyrene capacitors can be damaged by heat when
soldering (it melts the polystyrene!) so you should use a heat sink
(such as a crocodile clip). Clip the heat sink to the lead between the capacitor and the joint.
Real capacitor values (the E3 and E6 series)
You may have noticed that capacitors are not available with every possible value, for example
22F and 47F are readily available, but 25F and 50F are not!

Why is this? Imagine that you decided to make capacitors every 10F giving 10, 20, 30, 40, 50
and so on. That seems fine, but what happens when you reach 1000? It would be pointless to
make 1000, 1010, 1020, and 1030 and so on because for these values 10 is a very small
difference, too small to be noticeable in most circuits and capacitors cannot be made with that
accuracy.
To produce a sensible range of capacitor values you need to increase the size of the 'step' as the
value increases. The standard capacitor values are based on this idea and they form a series
which follows the same pattern for every multiple of ten.
The
E3
series
(3
values
for
each
multiple
of
ten)
10, 22, 47 ... then it continues 100, 220, 470, 1000, 2200, 4700, 10000 etc.
Notice how the step size increases as the value increases (values roughly double each time).
The
E6
series
(6
values
for
each
multiple
of
ten)
10, 15, 22, 33, 47, 68 ... then it continues 100, 150, 220, 330, 470, 680, 1000 etc.
Notice how this is the E3 series with an extra value in the gaps.
The E3 series is the one most frequently used for capacitors because many types cannot be made
with very accurate values.
TESTING
To test the capacitors, either analog meters or special digital meters with the specified function
are used. The non-electrolyte capacitor can be tested by using the digital meter. Multi meter
mode: Continuity Positive probe: One end Negative probe: Second end Display: `0` (beep sound
occur) `OL` Result: Faulty OK.

REGULATOR IC (78XX)
It is a three pin IC used as a voltage regulator. It converts unregulated DC current into regulated
DC current. Normally we get fixed output by connecting the voltage regulator at the output of
the filtered DC (see in above diagram). It can also be used in circuits to get a low DC voltage
from a high DC voltage (for example we use 7805 to get 5V from 12V). There are two types of
voltage regulators 1. Fixed voltage regulators (78xx, 79xx) 2. Variable voltage regulators
(LM317)
In fixed voltage regulators there is another classification 1. +ve voltage regulators 2. -ve voltage
regulators POSITIVE VOLTAGE REGULATORS this include 78xx voltage regulators. The
most commonly used ones are 7805 and 7812. 7805 gives fixed 5V DC voltage if input voltage
is in (7.5V, 20V).

LED
Light Emitting Diodes

Circuit symbol:-

Function
LEDs emit light when an electric current passes through them.
Connecting and soldering
LEDs must be connected the correct way round, the diagram may be labeled a
or + for anode and k or - for cathode (yes, it really is k, not c, for cathode!).

The cathode is the short lead and there may be a slight flat on the body of round LEDs. If you
can see inside the LED the cathode is the larger electrode (but this is not an official identification
method).
LEDs can be damaged by heat when soldering, but the risk is small unless you are very slow. No
special precautions are needed for soldering most LEDs.
Testing an LED
Never connect an LED directly to a battery or power supply!
It will be destroyed almost instantly because too much current will pass
through and burn it out.
LEDs must have a resistor in series to limit the current to a safe value,
for quick testing purposes a 1k resistor is suitable for most LEDs if
your supply voltage is 12V or less. Remember to connect the LED the
correct way round!
For an accurate value please see calculating an LED resistor value below.

Colors of LEDs
LEDs are available in red, orange, amber, yellow,
green, and blue and white. Blue and white LEDs
are much more expensive than the other colors.
The color of an LED is determined by the
semiconductor material, not by the coloring of
the 'package' (the plastic body). LEDs of all
colors are available in uncolored packages which
may be diffused (milky) or clear (often described as 'water clear'). The colored packages are also
available as diffused (the standard type) or transparent.
Tri-color LEDs
The most popular type of tri-color LED has a red and a green LED combined in
one package with three leads. They are called tri-color because mixed red and
green light appears to be yellow and this is produced when both the red and green
LEDs are on.
The diagram shows the construction of a tri-color LED. Note the different lengths
of the three leads. The centre lead (k) is the common cathode for both LEDs; the
outer leads (a1 and a2) are the anodes to the LEDs allowing each one to be lit
separately, or both together to give the third color.

Bi-color LEDs
A bi-color LED has two LEDs wired in 'inverse parallel' (one forwards, one backwards)
combined in one package with two leads. Only one of the LEDs can be lit at one time and they
are less useful than the tri-color LEDs described above.

Sizes, Shapes and Viewing angles of LEDs


LEDs are available in a wide variety of sizes and shapes. The 'standard' LED
has a round cross-section of 5mm diameter and this is probably the best type
for general use, but 3mm round LEDs are also popular.
LED Clip
Round cross-section LEDs are frequently used and they are very easy to
install on boxes by drilling a hole of the LED diameter, adding a spot of glue
will help to hold the LED if necessary. LED clips are also available to secure LEDs in holes.
Other cross-section shapes include square, rectangular and triangular.
As well as a variety of colors, sizes and shapes, LEDs also vary in their viewing angle. This tells
you how much the beam of light spreads out. Standard LEDs have a viewing angle of 60 but
others have a narrow beam of 30 or less.
Calculating an LED resistor value
An LED must have a resistor connected in series to limit the
current through the LED, otherwise it will burn out almost
instantly.
The resistor value, R is given by:
R = (VS - VL) / I
VS = supply voltage
VL = LED voltage (usually 2V, but 4V for blue and white LEDs)
I = LED current (e.g. 20mA), this must be less than the maximum permitted
If the calculated value is not available choose the nearest standard resistor value which is greater,
so that the current will be a little less than you chose. In fact you may wish to choose a greater

resistor value to reduce the current (to increase battery life for example) but this will make the
LED less bright.
For example
If the supply voltage VS = 9V, and you have a red LED (VL = 2V), requiring a current I = 20mA
= 0.020A,
R = (9V - 2V) / 0.02A = 350 , so choose 390 (the nearest standard value which is greater).
Working out the LED resistor formula using Ohm's law
Ohm's law says that the resistance of the resistor, R = V/I, where:
V = voltage across the resistor (= VS - VL in this case)
I = the current through the resistor
So R = (VS - VL) / I
Connecting LEDs in series
If you wish to have several LEDs on at the same time it may
be possible to connect them in series. This prolongs battery life
by lighting several LEDs with the same current as just one
LED.
All the LEDs connected in series pass the same current so it is
best if they are all the same type. The power supply must have
sufficient voltage to provide about 2V for each LED (4V for
blue and white) plus at least another 2V for the resistor. To
work out a value for the resistor you must add up all the LED
voltages and use this for VL.
Example calculations:
A red, a yellow and a green LED in series need a supply voltage of at least 3 2V + 2V = 8V, so
a 9V battery would be ideal.
VL = 2V + 2V + 2V = 6V (the three LED voltages added up).
If the supply voltage VS is 9V and the current I must be 15mA = 0.015A,
Resistor R = (VS - VL) / I = (9 - 6) / 0.015 = 3 / 0.015 = 200 ,
so choose R = 220 (the nearest standard value which is greater).

Avoid connecting LEDs in parallel!


Connecting several LEDs in parallel with just one resistor shared between
them is generally not a good idea.

If the LEDs require slightly different voltages only the lowest voltage LED will light and it may
be destroyed by the larger current flowing through it. Although identical LEDs can be
successfully connected in parallel with one resistor this rarely offers any useful benefit because
resistors are very cheap and the current used is the same as connecting the LEDs individually. If
LEDs are in parallel each one should have its own resistor.
Reading a table of technical data for LEDs
Suppliers' catalogues usually include tables of technical data for components such as LEDs.
These tables contain a good deal of useful information in a compact form but they can be
difficult to understand if you are not familiar with the abbreviations used.
The table below shows typical technical data for some 5mm diameter round LEDs with diffused
packages (plastic bodies). Only three columns are important and these are shown in bold. Please
see below for explanations of the quantities.
Type

Color

Standard

Red

IF
max.

VF
VF VR
typ. max. max.

Luminous
intensity

Viewing
Wavelength
angle

30mA 1.7V 2.1V 5V

5mcd @ 10mA

60

660nm

Standard

Bright red 30mA 2.0V 2.5V 5V

80mcd @ 10mA

60

625nm

Standard

Yellow 30mA 2.1V 2.5V 5V

32mcd @ 10mA

60

590nm

Standard

Green

25mA 2.2V 2.5V 5V

32mcd @ 10mA

60

565nm

High intensity

Blue

30mA 4.5V 5.5V 5V

60mcd @ 20mA

50

430nm

Super bright

Red

30mA 1.85V 2.5V 5V 500mcd @ 20mA

60

660nm

Low current

Red

30mA 1.7V 2.0V 5V

60

625nm

IF max.
VF typ.
VF max.
VR max.
Luminous
intensity
Viewing angle
Wavelength

5mcd @ 2mA

Maximum forward current, forward just means with the LED connected
correctly.
Typical forward voltage, VL in the LED resistor calculation.
This is about 2V, except for blue and white LEDs for which it is about 4V.
Maximum forward voltage.
Maximum reverse voltage
You can ignore this for LEDs connected the correct way round.
Brightness of the LED at the given current, mcd = mill candela.
Standard LEDs have a viewing angle of 60, others emit a narrower beam of
about 30.
The peak wavelength of the light emitted, this determines the color of the
LED.
nm = nanometer.

Flashing LEDs
Flashing LEDs look like ordinary LEDs but they contain an integrated circuit (IC) as well as the
LED itself. The IC flashes the LED at a low frequency, typically 3Hz (3 flashes per second).
They are designed to be connected directly to a supply, usually 9 - 12V, and no series resistor is
required. Their flash frequency is fixed so their use is limited and you may prefer to build your
own circuit to flash an ordinary LED, for example our Flashing LED project which uses a 555 astable circuit.
Operating Life
Because LEDs are solid-state devices they are not subject to catastrophic failure when operated
within design parameters. DDP LEDs are designed to operate upwards of 50,000 hours at 25C
ambient temperature. Operating life is characterized by the degradation of LED intensity over
time. When the LED degrades to half of its original intensity after 50,000 hours it is at the end of
its useful life although the LED will continue to operate as output diminishes. Unlike standard
incandescent bulbs, DDP LEDs resist shock and vibration and can be cycled on and off without
excessive degradation.
Precautions While Working With LEDs

General
We cannot assume any responsibility for any accident or damage caused when the products are
used beyond the maximum ratings specified herein.
The user of these products must confirm the performance of the LEDs after they are actually
assembled into the user's products/systems. It is strongly advised that he user design fail-safe
products/systems. We will not be responsible for legal matters which are caused by the
malfunction of these products/systems.

LED Lamps

Static Electricity and Surge

Static electricity and surge damage LEDs. It is recommended to use a wrist band or
anti-electrostatic glove when handling the LEDs. All devices, equipment and
machinery must be electrically grounded.
Lead Forming
The leads should be bent at a point at least
3mm from the epoxy resin of the LEDs.
Bending should be performed with the base
firmly fixed by means of a jig or radio pliers.
Mounting Method
The leads should be formed so they are
aligned exactly with the holes on the PC
board. This will eliminate any stress on the
LEDs.
Use LEDs with stoppers or resin spacer to accurately position the LEDs. The
epoxy resin base should not be touching the PC board when mounting the LEDs.
Mechanical stress to the resin may be caused by the warping of the PC board when
soldering.
The LEDs must not be designed into a
product or system where the epoxy lens is
pressed into a plastic or metal board. The
lens part of the LED must not be glued onto
plastic or metal. The mechanical stress to the
lead frame must be minimized.
Soldering
Solder the LEDs no closer than 3mm from the base of the epoxy resin.
For solder dipping, it may be necessary to fix the LEDs for correct positioning.
When doing this, any mechanical stress to the LEDs must be avoided.

When soldering, do not apply any mechanical force to the lead frame while
heating.
Repositioning after soldering must be avoided.
Soldering conditions:
Soldering Iron Dip Soldering

Reflow Soldering

Lamp 300degC(max), 260degC(max),


Not allowed.
LED 3sec(max)
5sec(max)
300degC(max),
Chip
3sec(max) with Not allowed.
LED
Twin Head iron

Cleaning
Avoid exposure to chemicals as they may attack the LED surface and cause
discoloration. When washing is required, "isopropyl alcohol" is to be used.
The influence of ultrasonic cleaning on the LEDs differs depending on factors such
as oscillator output and the way in which the LEDs are mounted. Therefore,
ultrasonic cleaning should only be performed after making certain that it will not
cause any damage.

Emission color
LED emission wavelengths vary. LEDs are classified by emission color into
different ranks. When a large volume of LEDs are purchased, LEDs with different
color ranks will be delivered
Packaging

The lead frames of the LEDs are coated with silver. Care must be taken to maintain
a clean storage atmosphere. If the LEDs are exposed to gases such as hydrogen
sulfide, it may cause discoloration of the lead frames.
Moisture proof packing is used to keep moisture away from the chip type LEDs.
When storing chip type LEDs, please use a sealable package with a moisture
absorbent material inside.

LED Cluster Lamp and LED Dot Matrix Unit


Assembly
Please refer to the recommended distance between the leads when designing lead
holes on the PC board.
Close attention must be paid on the correct positioning of O-rings and other water
proof seals when assembling products/systems.
LEDs are vulnerable to static electricity. When handling the LEDs, necessary
precautions regarding static electricity must always be taken into consideration.
Installation of LEDs
Make certain that the lead position and polarity are correct when installing the
LEDs.
The interface cable must be as short as possible.
The power supply and ground line must be selected according to their current
capacity.
Heat Dissipation
When many LEDs are mounted into a small area, heat generation must be taken
into consideration. If there is a possibility that the ambient temperature may exceed
60 degrees centigrade, some kind of forced cooling system will be needed

The ambient operating temperature must be taken into consideration when a


product/ system is being designed. There are certain limits to maximum current, at
certain temperatures which must be kept in mind.
Handling
When the surface of the LEDs must be cleaned, the LEDs should be wiped softly
with detergent. The surface may be damaged and the effect of the lens may be
reduced with violent scrubbing.

RESISTANCE:

Function
Resistors restrict the flow of electric current, for example a resistor is placed in
series with a light-emitting diode (LED) to limit the current passing through the
LED.
Connecting and soldering
Resistors may be connected either way round. They are not damaged by heat when
soldering.
Resistor values - the resistor color code
Resistance is measured in ohms; the symbol for ohm is an omega .
1 is quite small so resistor values are often given in k and M .
1 k = 1000
1 M = 1000000 .
Resistor values are normally shown using colored bands.
Each color represents a number as shown in the table.
Most resistors have 4 bands:

The first band gives the first digit.


The second band gives the second digit.

The third band indicates the number of zeros.

The fourth band is used to shows the tolerance (precision) of the resistor, this
may be ignored for almost all circuits but further details are given below.
The Resistor
Color Code
Color

Number

Black

Brown

Red

Orange

Yellow

Green

Blue

Violet

The standard color code cannot show values of less than 10 . To Grey
show these small values two special colors are used for the third White
band: gold which means 0.1 and silver which means 0.01. The
first and second bands represent the digits as normal.

This resistor has red (2), violet (7), yellow (4 zeros) and gold
bands.
So its value is 270000 = 270 k .
On circuit diagrams the is usually omitted and the value is
written 270K.

Small value resistors (less than 10 ohm)

For example:
red, violet, gold bands represent 27 0.1 = 2.7
green, blue, silver bands represent 56 0.01 = 0.56
Tolerance of resistors (fourth band of color code)
The tolerance of a resistor is shown by the fourth band of the color code. Tolerance
is the precision of the resistor and it is given as a percentage. For example a 390
resistor with a tolerance of 10% will have a value within 10% of 390 , between
390 - 39 = 351 and 390 + 39 = 429 (39 is 10% of 390).
A special color code is used for the fourth band tolerance:
silver 10%, gold 5%, red 2%, brown 1%.
If no fourth band is shown the tolerance is 20%.
Tolerance may be ignored for almost all circuits because precise resistor values are
rarely required.
Resistor shorthand

Resistor values are often written on circuit diagrams using a code system which
avoids using a decimal point because it is easy to miss the small dot. Instead the
letters R, K and M are used in place of the decimal point. To read the code: replace
the letter with a decimal point, then multiply the value by 1000 if the letter was K,
or 1000000 if the letter was M. The letter R means multiply by 1.
For example:
560R means 560
2K7 means 2.7 k = 2700
39K means 39 k
1M0 means 1.0 M = 1000 k
Real resistor values (the E6 and E12 series)
You may have noticed that resistors are not available with every possible value, for
example 22k and 47k are readily available, but 25k and 50k are not!
Why is this? Imagine that you decided to make resistors every 10 giving 10, 20,
30, 40, 50 and so on. That seems fine, but what happens when you reach 1000? It
would be pointless to make 1000, 1010, 1020, and 1030 and so on because for
these values 10 is a very small difference, too small to be noticeable in most
circuits. In fact it would be difficult to make resistors sufficiently accurate.
To produce a sensible range of resistor values you need to increase the size of the
'step' as the value increases. The standard resistor values are based on this idea and
they form a series which follows the same pattern for every multiple of ten.
The E6 series (6 values for each multiple of ten, for resistors with 20% tolerance)
10, 15, 22, 33, 47, 68 ... then it continues 100, 150, 220, 330, 470, 680, 1000 etc.
Notice how the step size increases as the value increases. For this series the step (to
the next value) is roughly half the value.

The E12 series (12 values for each multiple of ten, for resistors with 10%
tolerance)
10, 12, 15, 18, 22, 27, 33, 39, 47, 56, 68, 82 ... then it continues 100, 120, 150 etc.
Notice how this is the E6 series with an extra value in the gaps.

The E12 series is the one most frequently used for resistors. It allows you to
choose a value within 10% of the precise value you need. This is sufficiently
accurate for almost all projects and it is sensible because most resistors are only
accurate to 10% (called their 'tolerance'). For example a resistor marked 390
could vary by 10% 390 = 39 , so it could be any
value between 351 and 429 .
Power Ratings of Resistors
Electrical energy is converted to heat when current
flows through a resistor. Usually the effect is
negligible, but if the resistance is low (or the voltage
across the resistor high) a large current may pass
making the resistor become noticeably warm. The
resistor must be able to withstand the heating effect
and resistors have power ratings to show this.

High power resistors


(5W top, 25W bottom)

Power ratings of resistors are rarely quoted in parts


lists because for most circuits the standard power
ratings of 0.25W or 0.5W are suitable. For the rare cases where a higher power is
required it should be clearly specified in the parts list, these will be circuits using
low value resistors (less than about 300 ) or high voltages (more than 15V).
The power, P, developed in a resistor is given by:
P = I R where: P = power developed in the resistor in watts (W)
or
I = current through the resistor in amps (A)
P = V / R
R = resistance of the resistor in ohms ( )
V = voltage across the resistor in volts (V)

Examples:

A 470 resistor with 10V across it, needs a power rating P = V/R = 10/470
= 0.21W.
In this case a standard 0.25W resistor would be suitable.

A 27 resistor with 10V across it, needs a power rating P = V/R = 10/27 =
3.7W.
A high power resistor with a rating of 5W would be suitable.

Variable Resistors
Construction
Variable resistors consist of a resistance track with
connections at both ends and a wiper which moves
along the track as you turn the spindle. The track may be
made from carbon, cermets (ceramic and metal mixture)
or a coil of wire (for low resistances). The track is
usually rotary but straight track versions, usually called
sliders, are also available.
Variable resistors may be used as a rheostat with two Standard Variable Resistor
connections (the wiper and just one end of the track) or
as a potentiometer with all three connections in use. Miniature versions called
presets are made for setting up circuits which will not require further adjustment.
Variable resistors are often called potentiometers in books and catalogues. They are
specified by their maximum resistance, linear or logarithmic track, and their
physical size. The standard spindle diameter is 6mm.
The resistance and type of track are marked on the body:
4K7 LIN means 4.7 k linear track.
1M LOG means 1 M logarithmic track.
Some variable resistors are designed to be mounted directly on the circuit board,
but most are for mounting through a hole drilled in the case containing the circuit
with stranded wire connecting their terminals to the circuit board.
Linear (LIN) and Logarithmic (LOG) tracks
Linear (LIN) track means that the resistance changes at a constant rate as you
move the wiper. This is the standard arrangement and you should assume this type

is required if a project does not specify the type of track. Presets always have linear
tracks.
Logarithmic (LOG) track means that the resistance changes slowly at one end of
the track and rapidly at the other end, so halfway along the track is not half the
total resistance! This arrangement is used for volume (loudness) controls because
the human ear has a logarithmic response to loudness so fine control (slow change)
is required at low volumes and coarser control (rapid change) at high volumes. It is
important to connect the ends of the track the correct way round, if you find that
turning the spindle increases the volume rapidly followed by little further change
you should swap the connections to the ends of the track.
Rheostat
This is the simplest way of using a variable resistor. Two
terminals are used: one connected to an end of the track,
the other to the moveable wiper. Turning the spindle
changes the resistance between the two terminals from
zero up to the maximum resistance.

Rheostat Symbol

Rheostats are often used to vary current, for example to control the brightness of a
lamp or the rate at which a capacitor charges.
If the rheostat is mounted on a printed circuit board you may find that all three
terminals are connected! However, one of them will be linked to the wiper
terminal. This improves the mechanical strength of the mounting but it serves no
function electrically.

Potentiometer
Variable resistors used as potentiometers have all three
Potentiometer Symbol
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.
Presets
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 Preset
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.

Symbol

Presets are much cheaper than standard variable resistors so they are sometimes
used in projects where a standard variable resistor would normally be used.
Multi turn 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
(open style)

Presets (closed style)

Multi turn preset

POWER SUPPLY DESCRIPTION:


The power supply circuit comprises of four basic parts:

BRIDGE
RECTIFIER
TRANSFORMER

SHUNT
CAPACITOR

VOLTAGE
REGULATOR

INDICATOR

The transformer steps down the 220 V a/c. into 12 V a/c. The transformer work on
the principle of magnetic induction, where two coils: primary and secondary are
wound around an iron core. The two coils are physically insulated from each other
in such a way that passing a/c. current through the primary coil creates a changing
voltage in the primary coil and a changing magnetic field in the core. This in turn
induces a varying a/c. voltage in the secondary coil.
The a/c. voltage is then fed to the bridge rectifier. The rectifier circuit is used in
most electronic power supplies is the single-phase bridge rectifier with capacitor
filtering, usually followed by a linear voltage regulator. A rectifier circuit is
necessary to convert a signal having zero average value into a non-zero average
value. A rectifier transforms alternating current into direct current by limiting or
regulating the direction of flow of current. The output resulting from a rectifier is a
pulsating D.C. voltage. This voltage is not appropriate for the components that are
going to work through it.

7812
1N4007
TRANSFORMER

7805

12-0-12 V

1000uF

The ripple of the


D.C. voltage is smoothened using a filter capacitor of 1000 micro-Farad 25V. The
filter capacitor stores electrical charge. If it is large enough the capacitor will store
charge as the voltage rises and give up the charge as the voltage falls. This has the
effect of smoothing out the waveform and provides steadier voltage output. A filter
capacitor is connected at the rectifier output and the d.c voltage is obtained across
the capacitor. When this capacitor is used in this project, it should be twice the
supply voltage. When the filter is used, the RC charge time of the filter capacitor
must be short and the RC discharge time must be long to eliminate ripple action. In
other words the capacitor must charge up fast, preferably with no discharge.
- When the rectifier output voltage is increasing, the capacitor charges to the peak
voltage Vm. Just past the positive peak, the rectifier output voltage starts to fall
but at this point the capacitor has +Vm voltage across it. Since the source
voltage becomes slightly less than Vm, the capacitor will try to send current
back through the diode of rectifier. This reverse biases the diode. The diode
disconnects or separates the source the source form load. The capacitor starts to
discharge through load. This prevents the load voltage from falling to zero. The
capacitor continues to discharge until source voltage becomes more than
capacitor voltage. The diode again starts conducting and the capacitor is again

charged to peak value Vm. When capacitor is charging the rectifier supplies the
charging through capacitor branch as well as load current, the capacitor sends
currents through the load. The rate at which capacitor discharge depends upon
time constant RC. The longer the time constant, the steadier is the output
voltage. An increase in load current i.e. decrease in resistance makes time
constant of discharge path smaller. The ripple increase and d.c. output voltage V
dc decreases. Maximum capacity cannot exceed a certain limit because the
larger the capacitance the greater is the current required to charge the capacitor.
The voltage regulator regulates the supply if the supply if the line
voltage increases or decreases. The series 78xx regulators provide fixed regulated
voltages from 5 to 24 volts. An unregulated input voltage is applied at the IC Input
pin i.e. pin 1 which is filtered by capacitor. The out terminal of the IC i.e. pin 3
provides a regular output. The third terminal is connected to ground. While the
input voltage may vary over some permissible voltage range, and the output
voltage remains constant within specified voltage variation limit. The 78xx ICs are
positive voltage regulators whereas 79xx ICs are negative voltage regulators.
These voltage regulators are integrated circuits designed as fixed voltage
regulators for a wide variety of applications. These regulators employ current
limiting, thermal shutdown and safe area compensation. With adequate heat
sinking they can deliver output currents in excess of 1 A. These regulators have
internal thermal overload protection. It uses output transistor safe area
compensation and the output voltage offered is in 2% and 4% tolerance.

MICRONTROLLER:
In our day to day life the role of micro-controllers has been immense. They are
used in a variety of applications ranging from home appliances, FAX machines,
Video games, Camera, Exercise equipment, Cellular phones musical Instruments to
Computers, engine control, aeronautics, security systems and the list goes on.
A BRIEF INTRODUCTION TO 8051 MICROCONTROLLER:
When we have to learn about a new computer we have to familiarize about the
machine capability we are using, and we can do it by studying the internal
hardware design (devices architecture), and also to know about the size, number
and the size of the registers.
A microcontroller is a single chip that contains the processor (the CPU), nonvolatile memory for the program (ROM or flash), volatile memory for input and
output (RAM), a clock and an I/O control unit. Also called a "computer on a chip,"
billions of microcontroller units (MCUs) are embedded each year in a myriad of
products from toys to appliances to automobiles. For example, a single vehicle can
use 70 or more microcontrollers. The following picture describes a general block
diagram of microcontroller.
AT89S52:
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 Atmels high-density nonvolatile memory technology and is compatible with
the industry-standard 80C51 instruction set and pin out. 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 insystem 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 twolevel 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
con-tents but freezes the oscillator, disabling all other chip functions until the next
interrupt. The hardware is driven by a set of program instructions, or software.
Once familiar with hardware and software, the user can then apply the
microcontroller to the problems easily. The pin diagram of the 8051 shows all of
the input/output pins unique to microcontrollers: The following are some of the
capabilities of 8051 microcontroller.
1. Internal ROM and RAM
2. I/O ports with programmable pins
3. Timers and counters
4. Serial data communication
The 8051 architecture consists of these specific features:
16 bit PC &data pointer (DPTR)
8 bit program status word (PSW)
8 bit stack pointer (SP)
Internal ROM 4k
Internal RAM of 128 bytes.
4 register banks, each containing 8 registers
80 bits of general purpose data memory
32 input/output pins arranged as four 8 bit ports: P0-P3
Two 16 bit timer/counters: T0-T1
Two external and three internal interrupt sources Oscillator and clock
circuits.
Circumstances that we find ourselves in today in the field of microcontrollers had
their beginnings in the development of technology of integrated circuits. This
development has made it possible to store hundreds of thousands of transistors into
one chip. That was a prerequisite for production of microprocessors, and the first
computers were made by adding external peripherals such as memory, input-output
lines, timers and other. Further increasing of the volume of the package resulted in
creation of integrated circuits. These integrated circuits contained both processor
and peripherals. That is how the first chip containing a microcomputer, or what
would later be known as a microcontroller came about.

The first microcontroller 8051 was developed by Intel Corporation in the


year 1981. It was called as a System on a chip. Intel refers to it as MCS-51 now.

Definition of a Microcontroller
Microcontroller, as the name suggests, are small controllers. They are like single
chip computers that are often embedded into other systems to function as
processing/controlling unit. For example, the remote control you are using
probably has microcontrollers inside that do decoding and other controlling
functions. They are also used in automobiles, washing machines, microwave
ovens, toys ... etc, where automation is needed.
The key features of microcontrollers include:
1. High Integration of Functionality
2. Microcontrollers sometimes are called single-chip computers because they
have on-chip memory and I/O circuitry and other circuitries that enable them
to function as small standalone computers without other supporting circuitry.
3. Field Programmability, Flexibility.
4. Microcontrollers often use EEPROM or EPROM as their storage device to
allow field programmability so they are flexible to use. Once the program is
tested to be correct then large quantities of microcontrollers can be
programmed to be used in embedded systems.
5. Easy to Use Assembly language is often used in microcontrollers and since
they usually follow RISC architecture, the instruction set is small. The
development package of microcontrollers often includes an assembler, a
simulator, a programmer to "burn" the chip and a demonstration board.
Some packages include a high level language compiler such as a C compiler
and more sophisticated libraries.

Most microcontrollers will also combine other devices such as:


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

Showing a typical microcontroller device and its different subunits

8051 Architecture

MICROCONTROLLERS VERSUS MICROPROCESSORS

What is the difference between a microprocessor and microcontroller? The


microprocessors (such as 8086, 80286, 68000 etc.) contain no RAM, no ROM and
no I/O ports on the chip itself. For this reason they are referred as general- purpose
microprocessors. A system designer using general- purpose microprocessor must
add external RAM, ROM, I/O ports and timers to make them functional. Although
the addition of external RAM, ROM, and I/O ports make the system bulkier and
much more expensive, they have the advantage of versatility such that the designer
can decide on the amount of RAM, ROM and I/O ports needed to fit the task at
hand. This is the not the case with microcontrollers. A microcontroller has a CPU
(a microprocessor) in addition to the fixed amount of RAM, ROM, I/O ports, and
timer are all embedded together on the chip: therefore, the designer cannot add any
external memory, I/O, or timer to it. The fixed amount of on chip RAM, ROM, and
number of I/O ports in microcontrollers make them ideal for many applications in
which cost and space are critical. In many applications, for example a TV remote
control, there is no need for the computing power of a 486 or even a 8086
microprocessor. In many applications, the space it takes, the power it consumes,
and the price per unit are much more critical considerations than the computing
power. These applications most often require some I/O operations to read signals
and turn on and off certain bits. It is interesting to know that some

microcontrollers manufactures have gone as far as integrating an ADC and other


peripherals into the microcontrollers.
MICROCONTROLLERS FOR EMBEDDED SYSTEMS
In the literature discussing microprocessors, we often see a term embedded system.
Microprocessors and microcontrollers are widely used in embedded system
products. An embedded product uses a microprocessor (or microcontroller) to do
one task and one task only. A printer is an example of embedded system since the
processor inside it performs one task only: namely, get data and print it.
Contrasting this with a IBM PC which can be used for a number of applications
such as word processor, print server, network server, video game player, or internet
terminal. Software for a variety of applications can be loaded and run. Of course
the reason a PC can perform myriad tasks is that it has RAM memory and an
operating system that loads the application software into RAM and lets the CPU
run it. In an embedded system, there is only one application software that is burned
into ROM. An PC contains or is connected to various embedded products such as
the keyboard, printer, modem, disk controller, sound card, CD-ROM driver, mouse
and so on. Each one of these peripherals has a microcontroller inside it that
performs only one task. For example, inside every mouse there is a microcontroller
to perform the task of finding the mouse position and sending it to the PC.

Although microcontrollers are the preferred choice for many embedded


systems, there are times that a microcontroller is inadequate for the task. For this
reason, in many years the manufacturers for general-purpose microprocessors have
targeted their microprocessor for the high end of the embedded market.
INTRODUCTION TO 8051
In 1981, Intel Corporation introduced an 8-bit microcontroller called the 8051.
This microcontroller had 128 bytes of RAM, 4K bytes of on-chip ROM, two
timers, one serial port, and four ports (8-bit) all on a single chip. The 8051 is an 8bit processor, meaning the CPU can work on only 8- bit pieces to be processed by
the CPU. The 8051 has a total of four I/O ports, each 8- bit wide. Although 8051
can have a maximum of 64K bytes of on-chip ROM, many manufacturers put only
4K bytes on the chip.
The 8051 became widely popular after Intel allowed other manufacturers to make
any flavor of the 8051 they please with the condition that they remain code
compatible with the 8051. This has led to many versions of the 8051 with different
speeds and amount of on-chip ROM marketed by more than half a dozen
manufacturers. It is important to know that although there are different flavors of
the 8051, they are all compatible with the original 8051 as far as the instructions
are concerned. This means that if you write your program for one, it will run on

any one of them regardless of the manufacturer. The major 8051 manufacturers are
Intel, Atmel, Dallas Semiconductors, Philips Corporation, Infineon.
AT89C51 FROM ATMEL CORPORATION
This popular 8051 chip has on-chip ROM in the form of flash memory. This is
ideal for fast development since flash memory can be erased in seconds compared
to twenty minutes or more needed for the earlier versions of the 8051. To use the
AT89C51 to develop a microcontroller-based system requires a ROM burner that
supports flash memory: However, a ROM eraser is not needed. Notice that in flash
memory you must erase the entire contents of ROM in order to program it again.
The PROM burner does this erasing of flash itself and this is why a separate burner
is not needed. To eliminate the need for a PROM burner Atmel is working on a
version of the AT89C51 that can be programmed by the serial COM port of the PC.
FEATURES OF AT89C51
- 4K on-chip ROM
- 128 bytes internal RAM (8-bit)
- 32 I/O pins
- Two 16-bit timers
- Six Interrupts
- Serial programming facility
- 40 pin Dual-in-line Package

PIN diagram

PIN DESCRIPTION

The 89C51 have a total of 40 pins that are dedicated for various functions such as
I/O, RD, WR, address and interrupts. Out of 40 pins, a total of 32 pins are set aside
for the four ports P0, P1, P2, and P3, where each port takes 8 pins. The rest of the
pins are designated as Vcc, GND, XTAL1, XTAL, RST, EA, and PSEN. All these
pins except PSEN and ALE are used by all members of the 8051 and 8031
families. In other words, they must be connected in order for the system to work,
regardless of whether the microcontroller is of the 8051 or the 8031 family. The
other two pins, PSEN and ALE are used mainly in 8031 based systems.
Vcc
Pin 40 provides supply voltage to the chip. The voltage source is +5 V.
GND
Pin 20 is the ground.
XTAL1 and XTAL2
The 8051 have an on-chip oscillator but requires external clock to run it. Most
often a quartz crystal oscillator is connected to input XTAL1 (pin 19) and XTAL2
(pin 18). The quartz crystal oscillator connected to XTAL1 and XTAL2 also needs
two capacitors of 30 pF value. One side of each capacitor is connected to the
ground.

It must be noted that there are various speeds of the 8051 family. Speed refers to
the maximum oscillator frequency connected to the XTAL. For example, a 12 MHz
chip must be connected to a crystal with 12 MHz frequency or less. Likewise, a 20
MHz microcontroller requires a crystal frequency of no more than 20 MHz When
the 8051 is connected to a crystal oscillator and is powered up, we can observe the
frequency on the XTAL2 pin using oscilloscope.
RST
Pin 9 is the reset pin. It is an input and is active high (normally low). Upon
applying a high pulse to this pin, the microcontroller will reset and terminate all
activities. This is often referred to as a power on reset. Activating a power-on
reset will cause all values in the registers to be lost. Notice that the value of
Program Counter is 0000 upon reset, forcing the CPU to fetch the first code from
ROM memory location 0000. This means that we must place the first line of source
code in ROM location 0000 that is where the CPU wakes up and expects to find
the first instruction. In order to RESET input to be effective, it must have a
minimum duration of 2 machine cycles. In other words, the high pulse must be
high for a minimum of 2 machine cycles before it is allowed to go low.

EA
All the 8051 family members come with on-chip ROM to store programs. In such
cases, the EA pin is connected to the Vcc. For family members such as 8031 and
8032 in which there is no on-chip ROM, code is stored on an external ROM and is
fetched by the 8031/32. Therefore for the 8031 the EA pin must be connected to
ground to indicate that the code is stored externally. EA, which stands for external
access, is pin number 31 in the DIP packages. It is input pin and must be
connected to either Vcc or GND. In other words, it cannot be left unconnected.
PSEN
This is an output pin. PSEN stands for program store enable. It is the read strobe
to external program memory. When the microcontroller is executing from external
memory, PSEN is activated twice each machine cycle.
ALE
ALE (Address latch enable) is an output pin and is active high. When
connecting a microcontroller to external memory, port 0 provides both address and
data. In other words the microcontroller multiplexes address and data through port
0 to save pins. The ALE pin is used for de-multiplexing the address and data by
connecting to the G pin of the 74LS373 chip.
I/O port pins and their functions

The four ports P0, P1, P2, and P3 each use 8 pins, making them 8-bit ports. All the
ports upon RESET are configured as output, ready to be used as output ports. To
use any of these as input port, it must be programmed.
Port 0
Port 0 occupies a total of 8 pins (pins 32 to 39). It can be used for
input or output. To use the pins of port 0 as both input and output ports, each
pin must be connected externally to a 10K-ohm pull-up resistor. This is due
to fact that port 0 is an open drain, unlike P1, P2 and P3. With external pullup resistors connected upon reset, port 0 is configured as output port. In
order to make port 0 an input, the port must be programmed by writing 1 to
all the bits of it. Port 0 is also designated as AD0-AD7, allowing it to be
used for both data and address. When connecting a microcontroller to an
external memory, port 0 provides both address and data. The microcontroller
multiplexes address and data through port 0 to save pins. ALE indicates if P0
has address or data. When ALE=0, it provides data D0-D7, but when ALE=1
it has address A0-A7. Therefore, ALE is used for de-multiplexing address
and data with the help of latch 74LS373.

Port 1
Port 1 occupies a total of 8 pins (pins 1 to 8). It can be used as input or
output. In contrast to port 0, this port does not require pull-up resistors since
it has already pull-up resistors internally. Upon reset, port 1 is configures as
an output port. Similar to port 0, port 1 can be used as an input port by
writing 1 to all its bits.
Port 2
Port 2 occupies a total of 8 pins (pins 21 to 28). It can be used as input or
output. Just like P1, port 2 does not need any pull-up resistors since it has
pull-up resistors internally. Upon reset port 2 is configured as output port. To
make port 2 inputs, it must be programmed as such by writing 1s to it.
Port 3
Port 3 occupies a total of 8 pins (pins 10 to 17). It can be used as input or
output. P3 does not need any pull-up resistors, the same as P1 and P2 did
not. Although port 3 is configured as output port upon reset, this is not the
way it is most commonly used. Port 3 has an additional function of
providing some extremely important signals such as interrupts. Some of the
alternate functions of P3 are listed below:

P3.0

RXD (Serial input)

P3.1

TXD (Serial output)

P3.2

INT0 (External interrupt 0)

P3.3

INT1 (External interrupt 1)

P3.4

T0 (Timer 0 external input)

P3.5

T1 (Timer 1 external input)

P3.6

WR (External memory write strobe)

P3.7

RD (External memory read strobe)

INSIDE THE 89C51


Registers
In the CPU, registers are used to store information temporarily. That
information could be a byte of data to be processed, or an address pointing
to the data to be fetched. In the 8051 there us only one data type: 8 bits. With
an 8- bit data type, any data larger than 8 bits has to be broken into 8-bit
chunks before it is processed.

A
B
R0
R1
R2

DPTR

DPH

DPL

PC

Program Counter

R3
R4

(b) Some 8051 16-bit registers

R5
R6
R7

(a) Some 8051 8-bit registers


The most commonly used registers of the 8051 are A(accumulator), B, R0,
R1, R2, R3, R4, R5, R6, R7, DPTR (data pointer) and PC (program
counter). All the above registers are 8-bit registers except DPTR and the
program counter. The accumulator A is used for all arithmetic and logic
instructions.
Program Counter and Data Pointer
The program counter is a 16- bit register and it points to the address of the
next instruction to be executed. As the CPU fetches op-code from the
program ROM, the program counter is incremented to point to the next
instruction. Since the PC is 16 bit wide, it can access program addresses

0000 to FFFFH, a total of 64K bytes of code. However, not all the members
of the 8051 have the entire 64K bytes of on-chip ROM installed.
The DPTR register is made up of two 8-bit
registers, DPH and DPL, which are used to furnish memory addresses for
internal and external data access. The DPTR is under the control of program
instructions and can be specified by its name, DPTR. DPTR does not have a
single internal address; DPH and DPL are assigned an address each.
Flag bits and the PSW Register
Like any other microprocessor, the 8051 have a flag register to indicate
arithmetic conditions such as the carry bit. The flag register in the 8051 is
called the program status word (PSW) register.
The program status word (PSW) register is an 8-bit
register. It is also referred as the flag register. Although the PSW register is
8-bit wide, only 6 bits of it are used by the microcontroller. The two unused
bits are user definable flags. Four of the flags are conditional flags, meaning
they indicate some conditions that resulted after an instruction was
executed. These four are CY (carry), AC (auxiliary carry), P (parity), and
OV (overflow). The bits of the PSW register are shown below:

CY

AC

F0

RS1

RS0

OV

--

CY

PSW.7

Carry flag

AC

PSW.6

Auxiliary carry flag

--

PSW.5

Available to the user for general purpose

RS1 PSW.6

Register bank selector bit 1

RS0 PSW.3

Register bank selector bit 0

OV

PSW.2

Overflow flag

F0

PSW.1

User definable bit

PSW.0

Parity flag

CY, the carry flag


This flag is set whenever there is a carry out from the d7 bit. This
flag bit is affected after an 8-bit addition or subtraction. It can also be set to
1 or 0 directly by an instruction such as SETB C and CLR C where
SETB C stands for set bit carry and CLR C for clear carry.

AC, the auxiliary carry flag


If there is carry from D3 to D4 during an ADD or SUB operation,
this bit is set: otherwise cleared. This flag is used by instructions that
perform BCD arithmetic.
P, the parity flag
The parity flag reflects the number of 1s in the accumulator register only. If
the register A contains an odd number of 1s, then P=1. Therefore, P=0 if A
has an even number of 1s.
OV, the overflow flag
This flag is set whenever the result of a signed number operation is too
large, causing the high order bit to overflow into the sign bit. In general the
carry flags are used to detect errors in unsigned arithmetic operations.
MEMORY SPACE ALLOCATION
1. Internal ROM
The 89C51 has 4K bytes of on-chip ROM. This 4K bytes ROM memory
has memory addresses of 0000 to 0FFFh. Program addresses higher than
0FFFh, which exceed the internal ROM capacity, will cause the
microcontroller to automatically fetch code bytes from external memory.
Code bytes can also be fetched exclusively from an external memory,

addresses 0000h to FFFFh, by connecting the external access pin to ground.


The program counter doesnt care where the code is: the circuit designer
decides whether the code is found totally in internal ROM, totally in
external ROM or in a combination of internal and external ROM.
2. Internal RAM
The 1289 bytes of RAM inside the 8051 are assigned addresses 00 to 7Fh.
These 128 bytes can be divided into three different groups as follows:
1. A total of 32 bytes from locations 00 to 1Fh are set aside for register
banks and the stack.
2. A total of 16 bytes from locations 20h to 2Fh are set aside for bit
addressable read/write memory and instructions.
3. A total of 80 bytes from locations 30h to 7Fh are used for read and write
storage, or what is normally called a scratch pad. These 80 locations of
RAM are widely used for the purpose of storing data and parameters by
8051 programmers.

Reset circuit of 8051

Family Members of 8051

Features

8051

8031

8052

8032

ROM

4K

0K

8K

0K

RAM(bytes)

128

128

256

256

Timers

I/O Pins

32

32

32

32

Serial Port

Interrupt
Sources

Family members of 8051


RAM Architecture

Ram Architecture

The 8051 has a bank of 128 bytes of Internal RAM. This Internal RAM is
found on-chip on the 8051 so it is the fastest RAM available, and it is also the most
flexible in terms of reading, writing, and modifying its contents. Internal RAM is
volatile, so when the 8051 is reset this memory is cleared. The 128 bytes of
internal ram is subdivided as shown on the memory map. The first 8 bytes (00h 07h) are "register bank 0". These alternative register banks are located in internal
RAM in addresses 08h through 1Fh.Bit memory actually resides in internal RAM,
from addresses 20h through 2Fh. The 80 bytes remaining of Internal RAM, from
addresses 30h through 7Fh, may be used by user variables that need to be accessed
frequently or at high-speed. This area is also utilized by the microcontroller as a
storage area for the operating stack.
Register Banks
The 8051 uses 8 "R" registers which are used in many of its instructions.
These "R" registers are numbered from 0 through 7 (R0, R1, R2, R3, R4, R5, R6,
and R7).These registers are generally used to assist in manipulating values and
moving data from one memory location to another. The concept of register banks
adds a great level of flexibility to the 8051.
Bit Memory
The 8051, being a communication oriented microcontroller, gives the user
the ability to access a number of bit variables. These variables may be either 1 or 0.
There are 128 bit variables available to the user, numbered 00h through 7Fh. The
user may make use of these variables with commands such as SETB and CLR. It is
important to note that Bit Memory is really a part of Internal RAM. In fact, the 128
bit variables occupy the 16 bytes of Internal RAM from 20h through 2Fh.

Special Function Register (SFR) Memory


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

Registers
The Accumulator
The Accumulator, as its name suggests, is used as a general register to
accumulate the results of a large number of instructions. It can hold an 8-bit (1byte) value and is the most versatile register
The "R" registers
The "R" registers are a set of eight registers that are named R0, R1, etc. up to
and including R7. These registers are used as auxiliary registers in many
operations.
The "B" Register
The "B" register is very similar to the Accumulator in the sense that it may
hold an 8-bit (1-byte) value. The "B" register is only used by two 8051
instructions: MUL AB and DIV AB.

The Data Pointer (DPTR)


The Data Pointer (DPTR) is the 8051s only user-accessible 16-bit (2-byte)
register. The Accumulator, "R" registers, and "B" register are all 1-byte values.
DPTR, as the name suggests, is used to point to data. It is used by a number of
commands which allow the 8051 to access external memory.
The Program Counter (PC)
The Program Counter (PC) is a 2-byte address which tells the 8051 where
the next instruction to execute is found in memory. When the 8051 is initialized PC
always starts at 0000h and is incremented each time an instruction is executed.
The Stack Pointer (SP)
The Stack Pointer, like all registers except DPTR and PC, may hold an 8-bit
(1-byte) value. The Stack Pointer is used to indicate where the next value to be
removed from the stack should be
Interrupts
An interrupt is a special feature which allows the 8051 to provide the
illusion of "multitasking," although in reality the 8051 is only doing one thing at a
time.
Timers
Timers are one of the categories of hardware time delays. Time delays are
used to keep a system into halting System or sleepy mode. We have two timerstimer0, timer1.Hardware time delays are used to generate exact time delays.

Central Processing Unit


Let add 3 more memory locations to a specific block that will have a built in
capability to multiply, divide, subtract, and move its contents from one memory
location onto another. The part we just added in is called "central processing unit"
(CPU). Its memory locations are called registers. Registers are therefore memory
locations whose role is to help with performing various mathematical operations or
any other operations with data wherever data can be found. Look at the current
situation. We have two independent entities (memory and CPU) which are
interconnected, and thus any exchange of data is hindered, as well as its
functionality. If, for example, we wish to add the contents of two memory locations
and return the result again back to memory, we would need a connection between
memory and CPU. Simply stated, we must have some "way" through data goes
from one block to another.

Figure

Liquid Crystal Display


LCD Display

Liquid crystal displays (LCD) are widely used in recent years as compares to
LEDs. This is due to the declining prices of LCD, the ability to display numbers,
characters and graphics, incorporation of a refreshing controller into the LCD, their
by relieving the CPU of the task of refreshing the LCD and also the ease of
programming for characters and graphics. HD 44780 based LCDs are most
commonly used.
The liquid - crystal display (LCD) consist of a liquid crystal material (normally
organic for LCDs) that will flow like a liquid but whose molecular structure has
some properties normally associated with solids.
The LCD does not generate its own light but depends on an external or
internal source.
Under dark conditions, it would be necessary for the unit to have its own
internal light source either behind or to the side of the LCD.
During the day, or in the lighted areas, a reflector can be put behind the LCD
to reflect the light back through the display for maximum intensity. The
LCD has the distinct advantage of having the lower power requirement than
the LED. It is typical in the order of microwatts for the display, as compared
to the same order of mill watts for LEDs. LCD is limited to a temperature
range of about 0 to 60 C. Lifetime is an area of concern because LCDs can
chemically degrade. LCDs can add a lot to out applications in terms of
providing a useful interface for the user, debugging an application or just
giving it a "professional" look. The most common type of LCD controller is
the Hitachi 44780 which provides a relatively simple interface between a
processor and an LCD. Besides this there are several other reasons for LCDs

replacing LEDs(seven segment LEDs or other multisegment LEDs).This is


due the following reasons :The declining prices of LCDs.
The ability to display numbers, characters and graphics. This is in contrast to
LEDs, which are limited to numbers and a few characters.
In corporation 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 (or in some other way) to keep displaying the data.
Ease of programming for characters and graphics.

LCD pin description


The LCD discuss in this section has the most common connector used for the
Hitachi 44780 based LCD is 14 pins in a row and modes of operation and how to

16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1

Gnd
Vcc
D7
D6
D5
D4
D3
D2
D1
D0
E
R/W
RS
Contrast
Vcc
Gnd

16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1

program and interface with microcontroller is describes in this section.

LCD Pin Description Diagram

VCC, VSS, VEE


The voltage VCC and VSS provided by +5V and ground respectively while VEE is
used for controlling LCD contrast. Variable voltage between Ground and Vcc is
used to specify the contrast (or "darkness") of the characters on the LCD screen.
RS (register select)
There are two important registers inside the LCD. The RS pin is used for their
selection as follows. If RS=0, the instruction command code register is selected,
then allowing to user to send a command such as clear display, cursor at home etc..
If RS=1, the data register is selected, allowing the user to send data to be displayed
on the LCD.
R/W (read/write)
The R/W (read/write) input allowing the user to write information from it. R/W=1,
when it read and R/W=0, when it writing.

EN (enable)
The enable pin is used by the LCD to latch information presented to its data pins.
When data is supplied to data pins, a high power, a high-to-low pulse must be
applied to this pin in order to for the LCD to latch in the data presented at the data
pins.
D0-D7 (data lines)
The 8-bit data pins, D0-D7, are used to send information to the LCD or read the
contents of the LCDs internal registers. To displays the letters and numbers, we
send ASCII codes for the letters A-Z, a-z, and numbers 0-9 to these pins while
making RS =1. There are also command codes that can be sent to clear the display
or force the cursor to the home position or blink the cursor.
We also use RS =0 to check the busy flag bit to see if the LCD is ready to receive
the information. The busy flag is D7 and can be read when R/W =1 and RS =0, as
follows: if R/W =1 and RS =0, when D7 =1(busy flag =1), the LCD is busy taking
care of internal operations and will not accept any information. When D7 =0, the
LCD is ready to receive new information.

WORKING
The interface used by LCD is a parallel bus, allowing simple and fast
reading/writing of data to and from the LCD. This waveform will write an ASCII
Byte out to the LCD's screen. The ASCII code to be displayed is eight bits long and
is sent to the LCD either four or eight bits at a time. If four bit mode is used, two
"nibbles" of data (Sent high four bits and then low four bits with an "Enable"
Clock pulse with each nibble) are sent to make up a full eight bit transfer.

The "Enable" Clock is used to initiate the data transfer within the LCD. Sending
parallel data as either four or eight bits are the two primary modes of operation.
While there are secondary considerations and modes, deciding how to send the
data to the LCD is most critical decision to be made for an LCD interface
application. Eight bit mode is best used when speed is required in an application
and at least ten I/O pins are available. Four bit mode requires a minimum of six
bits. To wire a microcontroller to an LCD in four bit mode, just the top four bits
(DB4-7) are written to.
The "RS" bit is used to select whether data or an instruction is being transferred
between the microcontroller and the LCD. If the Bit is set, then the byte at the
current LCD "Cursor" Position can be read or written. When the Bit is reset, either
an instruction is being sent to the LCD or the execution status of the last instruction
is read back (whether or not it has completed). Reading Data back is best used in
applications which required data to be moved back and forth on the LCD (such as
in applications which scroll data between lines).In our Project we have
permanently grounded R/W pin which means we are not retrieving any data from
LCD.
The LCD can be thought of as a "Teletype" display because in normal operation,
after a character has been sent to the LCD, the internal "Cursor" is moved one
character to the right. The "Clear Display" and "Return Cursor and LCD to Home
Position" instructions are used to reset the Cursor's position to the top right
character on the display. To move the Cursor, the "Move Cursor to Display"
instruction is used. For this instruction, bit 7 of the instruction byte is set with the
remaining seven bits used as the address of the character on the LCD the cursor is
to move to. These seven bits provide 128 addresses, which matches the maximum
number of LCD character addresses available. Eight programmable characters are
available and use codes 0x000 to 0x007. They are programmed by pointing the
LCD's "Cursor" to the Character Generator RAM The last aspect of the LCD to
discuss is how to specify a contrast voltage to the Display. I typically use a
potentiometer wired as a voltage divider. This will provide an easily variable
voltage between Ground and Vcc, which will be used to specify the contrast (or
"darkness") of the characters on the LCD screen. You may find that different LCDs
work differently with lower voltages providing darker characters.

DIFFERENT TYPES OF LCDs:


There is different type of LCDs available in the market such as:
16*2 Green
16*2 Jumbo
16*4 Green
20*4 Blue
128*64 Graphical
Here 16*2 stands for the LCD would have 16 columns and two rows. Green
stands for it has green back light.

BUZZER
A buzzer or beeper is a signaling device, usually electronic, typically used in
automobiles, household appliances such as a microwave oven, or game shows.
It most commonly consists of a number of switches or sensors connected to a
control unit that determines if and which button was pushed or a preset time has
lapsed, and usually illuminates a light on the appropriate button or control panel,
and sounds a warning in the form of a continuous or intermittent buzzing or
beeping sound. Initially this device was based on an electromechanical system
which was identical to an electric bell without the metal gong (which makes the
ringing noise). Often these units were anchored to a wall or ceiling and used the
ceiling or wall as a sounding board. Another implementation with some ACconnected devices was to implement a circuit to make the AC current into a noise
loud enough to drive a loudspeaker and hook this circuit up to a cheap 8-ohm
speaker. Nowadays, it is more popular to use a ceramic-based piezoelectric sounder
like a Son alert which makes a high-pitched tone. Usually these were hooked up to
"driver" circuits which varied the pitch of the sound or pulsed the sound on and off.
In game shows it is also known as a "lockout system," because when one person
signals ("buzzes in"), all others are locked out from signaling. Several game shows
have large buzzer buttons which are identified as "plungers".

The word "buzzer" comes from the rasping noise that buzzers made when they
were electromechanical devices, operated from stepped-down AC line voltage at
50 or 60 cycles. Other sounds commonly used to indicate that a button has been
pressed are a ring or a beep.

IR SENSOR AS A REFLECTOR:
Infrared (IR) light or the infrared part of the spectrum is electromagnetic radiation
with wavelength between 700 to 3000 nanometers (nm). As human can see only
waves between 400 to 700 nanometers, infrared light is invisible to the human eye.
Sensors for surveillance cameras, however, may detect wavelength up to 1100 nm.
This provides an additional source of light for cameras. As this part of the spectrum
will be considered as red by sensors, IR is filtered out under color mode, when
there is more than enough light. This ensures that the color is accurate and not
distorted to red. When it is dark and the camera struggles to see with every last bit
of light, models equipped with removable IR-Cut filter will move the filter aside to
let in IR light, and shift to black and white mode to avoid the color shift.
In such cases, it is possible to shine an additional source of IR onto the scene by IR
LEDs. This additional IR light is visible to the surveillance camera but not to the
human eye. This provides a much brighter image in the dark without alerting to
subjects that they can be easily seen.
IR (Infrared) is the typical light source being used in the
sensor for robot to detect opaque object. In this project, no programming,
microcontroller and soldering are required.
IR Sensor (IR Receiver and IR Emitter)
The basic principle of IR sensor is based on an IR emitter and an IR receiver. IR
emitter will emit infrared continuously when power is supplied to it. On the other
hand, the IR receiver will be connected and perform the task of a voltage divider.
IR receiver can be imagined as a transistor with its base current determined by the

intensity of IR light received. The lower the intensity of IR light cause higher
resistance between collector-emitter terminals of transistor, and limiting current
from collector to emitter. This change of resistance will further change the voltage
at the output of voltage divider. In others word, the greater the intensity of IR light
hitting IR receiver, the lower the resistance of IR receiver and hence the output
voltage of voltage divider will decreased. Usually the IR emitter and IR receiver
will be mounted side by side, pointing to a reflective surface. The further distance
away between emitter and receiver decrease the amount of infrared light hitting the
receiver if the distance between the sensor and a reflective surface is fixed. Since
the output voltage from voltage divider varies with the intensity of IR light, and
microcontroller is not used in this project, a comparator (LM324) is used to show
the changes.
LM324
A LM324 consists of 4 comparators in a chip. It issued to compare voltage pairs.
Each comparator has VRef+ and VRef-. Depending on the applications, user may
either connect a fixed reference voltage to VRef+ or VRef-..In this example, the
output voltage from voltage divider (IR Receiver) is connected to VRef- and a
preset (variable resistor) is being used to generate voltage for VRef+. VRef+ is
considered as the threshold voltage for comparator output to change. If VRef- is
greater than VRef+, Vout will be low (0V) and vice versa. Hence, the voltage
generated by comparator output of LM324 can provide digital logic to
microcontroller and in this project it is being use to drive LED.

CIRCUIT DIAGRAM:

The sensitivity of the IR Sensor is tuned using the potentiometer. The


potentiometer is tune able in both the directions. Initially tune the potentiometer in
clockwise direction such that the Indicator LED starts glowing. Once that is

achieved, turn the potentiometer just enough in anti-clockwise direction to turn off
the Indicator LED. At this point the sensitivity of the receiver is maximum. Thus,
its sensing distance is maximum at this point. If the sensing distance (i.e.,
Sensitivity) of the receiver is needed to be reduced, then one can tune the
potentiometer in the anti-clockwise direction from this point. Further, if the
orientation of both TX and Rx LEDs is parallel to each other, such that both are
facing outwards, then their sensitivity is maximum. If they are moved away from
each other, such that they are inclined to each other at their soldered end, then their
sensitivity reduces. Tuned sensitivity of the sensors is limited to the surroundings.
Once tuned for a particular surrounding, they will work perfectly until the IR
illumination conditions of that region nearly constant. For example, if the
potentiometer is tuned inside room/building for maximum sensitivity and then
taken out in open sunlight, it will require retuning, since suns rays also contain
Infrared (IR) frequencies, thus acting as a IR source (transmitter). This will disturb
the receivers sensing capacity. Hence it needs to be returned to work perfectly in
the new surroundings. The output of IR receiver goes low when it receives IR
signal. Hence the output pin is normally low because, though the IR LED is
continuously transmitting, due to no obstacle, nothing is reflected back to the IR
receiver. The indication LED is off. When an obstacle is encountered, the output of
IR receiver goes low; IR signal is reflected from the obstacle surface. This drives
the output of the comparator low. This output is connected to the cathode of the
LED, which then turns ON.

Application Ideas
Obstacle detection
Shaft encoder
Fixed frequency detection
Stepper Motor
Motion Control, in electronic terms, means to accurately control the movement of
an object based on speed, distance, load, inertia or a combination of all these
factors. There are numerous types of motion control systems, including; Stepper
Motor, Linear Step Motor, DC Brush, Brushless, Servo, Brushless Servo and
more.

A stepper motor is an electromechanical device which converts electrical


pulses into discrete mechanical movements. Stepper motor is a form of ac.
motor .The shaft or spindle of a stepper motor rotates in discrete step increments
when electrical command pulses are applied to it in the proper sequence. The
motors rotation has several direct relationships to these applied input pulses. The
sequence of the applied pulses is directly related to the direction of motor shafts
rotation. The speed of the motor shafts rotation is directly related to the frequency
of the input pulses and the length of rotation is directly related to the number of
input pulses applied [39].
For every input pulse, the motor shaft turns through a specified number of
degrees, called a step. Its working principle is one step rotation for one input pulse.
The range of step size may vary from 0.72 degree to 90 degree. In position control
application, if the number of input pulses sent to the motor is known, the actual
position of the driven job can be obtained.
A stepper motor differs from a conventional motor (CM) as under:

a. Input to SM is in the form of electric pulses whereas input to a CM is


invariably from a constant voltage source.
b. A CM has a free running shaft whereas shaft of SM moves through angular
steps.
c. In control system applications, no feedback loop is required when SM is
used but a feedback loop is required when CM is used.
d. A SM is a digital electromechanical device whereas a CM is an analog
electromechanical device [40].

Open Loop Operation


One of the most significant advantages of a stepper motor is its ability to be
accurately controlled in an open loop system. Open loop control means no
feedback information about position is needed. This type of control eliminates the
need for expensive sensing and feedback devices such as optical encoders. Control
position is known simply by keeping track of the input step pulses [39].
Every stepper motor has a permanent magnet rotor (shaft) surrounded by a
stator. The most common stepper motor has four stator windings that are paired
with a center-tapped common. This type of stepper motor is commonly referred to
as a four- phase stepper motor. The center tap allows a change of current direction
in each of two coils when a winding is grounded, thereby resulting in a polarity
change of the stator. Notice that while a conventional motor shaft runs freely, the
stepper motor shaft moves in a fixed repeatable increment which allows one to
move it to a precise position. This repeatable

Rotor Alignment
Fixed movement is possible as a result of basic magnetic theory where poles of the
same polarity repel and opposite poles attract. The direction of the rotation is
dictated by the stator poles. The stator poles are determined by the current sent
through the wire coils. As the direction of the current is changed, the polarity is
also changed causing the reverse motion of the rotor. The stepper motor used here
has a total of 5 leads: 4 leads representing the four stator windings and 1 common
for the center tapped leads. As the sequence of power is applied to each stator
winding, the rotor will rotate. There are several widely used sequences where each
has a different degree of precision. Table shows the normal 4-step sequence. For
clockwise go for step 1 to 4 & for counter clockwise go for step 4 to 1.

Winding C

Winding B

1
2
3

Winding A

Winding D

Stator Windings Configuration

Step

Winding A

Winding B

Winding CWinding D

Table 3.6: Input Sequence to the Windings


Step Angle & Steps per Revolution
Movement associated with a single step, depends on the internal construction of
the motor, in particular the number of teeth on the stator and the rotor. The step
angle is the minimum degree of rotation associated with a single step.
Step per revolution is the total number of steps needed to rotate one complete
rotation or 360 degrees (e.g., 180 steps * 2 degree = 360) [31].
Since the stepper motor is not ordinary motor and has four separate coils,
which have to be energized one by one in a stepwise fashion. We term them as coil
A, B, C and D. At a particular instant the coil A should get supply and then after
some delay the coil B should get a supply and then coil C and then coil D and so
on the cycle continues. The more the delay is introduced between the energizing of
the coils the lesser is the speed of the stepper motor and vice versa.

2.2 Software Description


KEIL

Keil development tools for the 8051 microcontroller family support every level of
developer from the professional applications engineer to the student just learning
about embedded software development. The industry-standard Keil C Compilers,
Macro Assemblers, Debuggers, Real-time Kernels, and Single-board Computers
support ALL 8051-compatible derivatives and help you get your projects
completed on schedule.
The following table shows the Keil C51 Product Line (across the top) and the
Components that are included (along the left side). You may use this information to
find the development tool kit that best fits your needs.

Software Development Cycle


When you use the Keil Vision, the project development cycle is roughly the same
as it is for any other software development project.
1. Create a project, select the target chip from the device database, and
configure the tool settings.
2. Create source files in C or assembly.
3. Build your application with the project manager.
4. Correct errors in source files.
5. Test the linked application.
The following block diagram illustrates the complete Vision/ARM software
development cycle. Each component is described below.

Vision IDE
The Vision IDE combines project management, a rich-featured editor with
interactive error correction, option setup, make facility, and on-line help. Use
Vision to create your source files and organize them into a project that defines
your target application. Vision automatically compiles, assembles, and links your
embedded application and provides a single focal point for your development
efforts.
C51 Compiler & A51 Macro Assembler
Source files are created by the Vision IDE and are passed to the C51 Compiler or
A51 Macro Assembler. The compiler and assembler process source files and create
relocatable object files.
The Keil C51 Compiler is a full ANSI implementation of the C programming
language that supports all standard features of the C language. In addition,
numerous features for direct support of the 8051 architecture have been added.
The Keil A51 macro assembler supports the complete instruction set of the 8051
and all derivatives.
LIB51 Library Manager
The LIB51 library manager allows you to create object library from the object files
created by the compiler and assembler. Libraries are specially formatted, ordered
program collections of object modules that may be used by the linker at a later
time. When the linker processes a library, only those object modules in the library
that are necessary to create the program are used.
BL51 Linker/Locator
The BL51 Linker/Locator creates an absolute ELF/DWARF file using the object
modules extracted from libraries and those created by the compiler and assembler.
An absolute object file or module contains no relocatable code or data. All code
and data reside at fixed memory locations. The absolute ELF/DWARF file may be
used:

To program an Flash ROM or other memory devices,

With the Vision Debugger for simulation and target debugging,

With an in-circuit emulator for the program testing.

Vision Debugger
The Vision symbolic, source-level debugger is ideally suited for fast, reliable
program debugging. The debugger includes a high-speed simulator that let you
simulate an entire 8051 system including on-chip peripherals and external
hardware. The attributes of the chip you use are automatically configured when
you select the device from the Device Database.
The Vision Debugger provides several ways for you to test your programs on real
target hardware.

Install the MON51 Target monitor on your target system and download your
program using the Monitor-51 interface built-in to the Vision Debugger.

Use the Advanced GDI interface to attach use the Vision Debugger front
end with your target system.

Requesting Assistance
At Keil Software, we are dedicated to provide you with the best embedded
development tools and documentation available. If you have suggestions or
comments regarding any of the on-line manuals accompanying this product, please
contact us. If you think you have discovered a problem with the software, do the
following before calling technical support.
1. Read the sections in this manual that pertains to the job or task you are
trying to accomplish.
2. Make sure you are using the most current version of the software and
utilities. Check www.keil.com/updateto make sure that you have the latest
software version.
3. Isolate the problem to determine if it is a problem with the assembler,
compiler, linker, debugger, or another development tool.
4. Further isolate software problems by reducing your code to a few lines.
If you are still experiencing problems after following these steps, report them to
our technical support group. Please include your product serial number and version

number. We prefer that you send the problem via email. If you contact us by fax, be
sure to include your name and telephone numbers (voice and fax) where we can
reach you.
Try to be as detailed as possible when describing the problem you are having. The
more descriptive your example, the faster we can find a solution. If you have a
single-page code example demonstrating the problem, please email it to us. If
possible, make sure that your problem can be duplicated with the Vision
Simulator. Please try to avoid sending complete applications or long listings as this
slows down our response to you.

You can always get technical support, product updates, application notes,
and sample programs from www.keil.com/support.

Kiel software converts the C-codes into the Intel Hex code.

Chapter 3 CIRCUIT DIAGRAM


P A R K IN G M O N IT O R IN G S Y S T E M

BO AR D 1

KM 4408

5V

4408 LC D BO A RD

5V

L C D -R S
L C D -E
LC D 4
LC D 5
LC D 6
LC D 7

G N D

12V
P
P
P
P
P
P
P
P

P
P
P
P
P
P
P
P

0 .7
0 .6
0 .5
0 .4
0 .3
0 .2
0 .1
0 .0

2 .0
2 .1
2 .2
2 .3
2 .4
2 .5
2 .6
2 .7

M A IN B O A R D 8 0 5 1
KM 4450

12V
5V
5V
5V+

BO AR D 2

12

T X R -1 2 -0 -1 2 -G R
T1

4420 SU PPLY BO AR D
5V

BO AR D 3

G N D

0
12

G N D
P 3 .7
P 3 .6
P 3 .5
P 3 .4
P 3 .3
P 3 .2
T X P 3 .1
R X P 3 .0

P
P
P
P
P
P
P
P
1 .7
1 .6
1 .5
1 .4
1 .3
1 .2
1 .1
1 .0
O U T2
O U T1

BO AR D 4

5V
5V
G N D

IN 2
IN 1

KM 4444

5V BO AR D 5 KM 4430
G N D
D ATA
5V

5V BO AR D 6 KM 4430

SLOT A

G N D
D ATA
5V

SLOT B

S E B -0 2 5

W 1

You might also like