You are on page 1of 73

INDEX

Sr. no.

CONTENTS

Page no.

1. ACKNOWLEDGEMENTS

2. INTRODUCTION

3. BLOCK DIAGRAM

4. CIRCUIT DIAGRAM

5. COMPONENT USED

6. POWER SUPPLY FOR DIGITAL CIRCUITS

TRANSFORMER

REGULATOR

RESISTOR

CAPACITOR

DIODE

9
11
12
13
17
23

7. MICROCONTROLLER

28

8. AT89S52

30

9. HT12E

39

10. HT12D

42

11. LCD

45

12. OPTO-ISOLATOR

58

13. RF MODULE

60

14. SOLDERING

64

15. PROGRAM

65

16. BIBILIOGRAPHY

72

ACKNOWLEDGEMENTS
With deep sense of gratitude we would like to thank all the people who have lit our path with their
kind guidance. We are very grateful to these intellectuals who did their best to help during our
paper. It is our proud privilege to express deep sense of gratitude to our B.E Project Guide Er.
Kashish Sareen for his continuous guidance and support throughout our project and paper. It would
never have been possible for us to complete this project successfully without his guidance and
support. We would also like to thank them for their timely suggestions and valuable guidance. And
lastly we would like to thank our friends and the people who are directly or indirectly related to
our paper.

Er. Kashish Sareen (HOD)


(ECE Department)

INTRODUCTION
In this project we will make one transmitter and RF receiver. From transmitter we will
send the roll no. of student. On receiver side we will mark the attendance. RF remote
control which is built using HT12E and HT12D chips. The remote control is built using
RF encoder chip HT12E that will generate different codes. These codes will be
transmitted by 434 MHz RF transmitter. At the receiving side these codes will be
received by 434 MHz RF receiver and decoded by RF decoder chip HT12D. These
codes are fed to 89S52 to take a controlling action on moon walker. We will use 16*2
LCD display.
In this project we will make a transmitter for RF data transmission. Pin no 1of RF tx
module is ground. Second is for data, third for VCC and fourth for antenna Transmitter.
RFID (radio frequency identification) is a new technology that incorporates the use of
electromagnetic or electrostatic coupling in the radio frequency (RF) portion of the
electromagnetic spectrum to uniquely identify an object, animal, or person. An RFID
system consists of three components: an antenna and transceiver (often combined into
one reader) and a transponder (the tag). The antenna uses radio frequency waves to
transmit a signal that activates the transponder. When activated, the tag transmits data
back to the antenna. RFID technology differs from bar codes. RFID can read the tag
using RF, meaning that the RFID reader can be read from a distance, right through your
clothes, wallet, backpack or purse. Besides the RFID tag consist of unique ID for each
tag. The technology used in RFID has been around since the early 1920s. In our country,
this technology already been used for several years in certain place such as in Highway
using card Touch N Go and our government also apply this technology by using RFID
as I.C (identification card). Some places, they prefer to used Barcode which is cheaper
than RFID. Technology spread very fast. In few years later, there is not impossible if
RFID will replace the barcode system in todays life.

Nowadays, there are lots of universities around our country and each of the university
consists of student up to 10 thousand. To handle a large amount of student may be
problem especially to get the attendance. Now, process to get attendance in majority
universities still used the manual process. The manual process means that when start
the class/lecture, lecturer will give a piece of attendance paper and students will check
their name and then will sign on it. At the end of class, lecturer will take back the
attendance paper and keep it as a record.
Normally, the attendance paper need much time to sign by all students especially for
class with a lot of student. Students also forget to sign that attendance and they were
assuming absent that class. The problem also will happen when lecturer forget to bring
the attendance paper to class. Students need to write their name on a piece of paper and
sometimes student will take change to cheat in process getting the attendance. The
suitable solution for this problem is by design a system that will record attendance
automatically.
In this project, RFID system used to record student attendance automatically. This
project will used student ID card as RFID tag and a RFID reader. This RFID system
will be integrate with software. This method is more effective to prevent problem in
process getting attendance manually.
Features of Project:
1.

RF module

2.

5V regulated power supply

3.

Microcontroller circuit

4.

LCD display interface

5.

Keypad

6.

HT12E and H12D interface

BLOCK DIAGRAM
BLOCK DIAGRAM OF RECEIVER

5 v dc
circuit

Micro
Controller
Circuit

On/off
Switch

Ht 12d
Decoder chip

LCD 16*2
display

RF
Module

Antenna

ENERGY
ZONE

Block Diagram of Transmitter

5 v dc
circuit

On/off
Switch

Micro
Controller
Circuit

Ht 12 E
Decoder chip

RF
Module

Switches
Antenna

CIRCUIT DIAGRAM
Circuit diagram of Receiver

Circuit Diagram of Transmitter

COMPONENT USED

1. MCU AT89s52
2. RF Module
3. HT 12E
4. HT 12D
5. 1N 4148
6. 1M OHM
7. Resistor (1K)
8. IC Base(18Pin,8Pin)
9. IC PC817
10. LEDs
11. PCB
12. Crystal(12MHz)
13. LCD
14. Micro switch
15. Battery Connector
16. Convince charges
17. Strip Line Connector
18. 470E
19. Switch(Push to on)
20. Soldering wire
21. Connecting wire
22. Transistors(TR548,TR558)
23. Capacitors(1000 f,100 f,470 f)
24. Diodes
25. IC 7805 Volt. Reg

26. TRANSFORMER 9 Volt


27. PLY BOARD
28. Tape Roll
29. Screws/Bolt
30. Batteries

POWER SUPPLY FOR DIGITAL CIRCUITS

Summary of circuit features

Brief description of operation: Gives out well regulated +5V output, output current
capability of 100 mA.

Circuit protection: Built-in overheating protection shuts down output when regulator IC
gets too hot.

Circuit complexity: Simple and easy to build.

Circuit performance: Stable +5V output voltage, reliable operation.

Availability of components: Easy to get, uses only common basic components.

Design testing: Based on datasheet example circuit, I have used this circuit successfully as
part of other electronics projects.

Applications: Part of electronics devices, small laboratory power supply.

Power supply voltage: Unregulated DC 5V power supply.

Power supply current: Needed output current 1A.

Components cost: Few rupees for the electronic components plus the cost of input
transformer.

DESCRIPTION OF POWER SUPPLY

This circuit is a small +5 volts power supply, which is useful when experimenting with digital
electronics. Small inexpensive wall transformers with variable output voltage are available from
any electronics shop. Those transformers are easily available, but usually their voltage regulation
is very poor, which makes them not very usable for digital circuit experimenter unless a better
regulation can be achieved in some way. The following circuit is the answer to the problem.

This circuit can give +5V output at about 1A current. The circuit has overload and terminal
protection.

IN 4007

7805

+5V

2
N1

N2

4700 uf

IN 4007

1000 uf

GND

Fig: Circuit diagram of power supply

The above circuit utilizes the voltage regulator IC 7805 for the constant power supply. The
capacitors must have enough high voltage rating to safely handle the input voltage feed to circuit.
The circuit is very easy to build for example into a piece of Vero board.

10

TRANSFORMER
Transformer works on the principle of mutual inductance. We know that if two coils or windings
are placed on the core of iron, and if we pass alternating current in one winding, back emf or
induced voltage is produced in the second winding. We know that alternating current always
changes with the time. So if we apply AC voltage across one winding, a voltage will be induced
in the other winding. Transformer works on this same principle. It is made of two windings wound
around the same core of iron. The winding to which AC voltage is applied is called primary
winding. The other winding is called as secondary winding.

Voltage and current relationship:

Let V1 volts be input alternating voltage applied to primary winding. I1 Amp is input alternating
current through primary winding. V2 volt is output alternating voltage produced in the secondary.
I2 amp be the current flowing through the secondary.
Then relationship between input and output voltages is given bymV1/V2 = N1/N2
Relationship between input and output currents is I1/I2 = N2/N1
(Where N1 is no. of turns of coil in primary and N2 is number of turns in secondary)

We know that Power = Current X Voltage. It is to be noted that input power is equal to output
power. Power is not changed. If V2 is greater than V1, then I2 will be less than I1. This type of
transformer is called as step up transformer. If V1 is greater than V2, then I1 will be less than I2.
This type of transformer is called as step down transformer.
For step up transformer, N2>N1, i.e., number of turns of secondary winding is more than those in
primary.
For step down transformer, N1>N2, i.e., numbers of turns of primary winding is more than those
in secondary.

11

7805 REGULATOR IC
The 78xx is a family of self-contained fixed linear voltage regulator integrated circuits. The 78xx
family is commonly used in electronic circuits requiring a regulated power supply due to their
ease-of-use and low cost. For ICs within the family, the xx is replaced with two digits, indicating
the output voltage (for example, the 7805 has a 5 volt output, while the 7812 produces 12 volts).
The 78xx line are positive voltage regulators: they produce a voltage that is positive relative to a
common ground. There is a related line of 79xx devices which are complementary negative voltage
regulators. 78xx and 79xx ICs can be used in combination to provide positive and negative supply
voltages in the same circuit.

78xx ICs have three terminals and are commonly found in the TO220 form factor, although smaller
surface-mount and larger TO3 packages are available. These devices support an input voltage
anywhere from a few volts over the intended output voltage, up to a maximum of 35 to 40 volts
depending on the make, and typically provide 1 or 1.5 amperes of current (though smaller or larger
packages may have a lower or higher current rating).

Fig: Regulator and PIN Layout Diagram

PIN 1: Unregulated voltage input


PIN 2: Ground
PIN 3: Regulated voltage output

12

ADVANTAGES

78xx series ICs do not require additional components to provide a constant, regulated source of
power, making them easy to use, as well as economical and efficient uses of space. Other voltage
regulators may require additional components to set the output voltage level, or to assist in the
regulation process. Some other designs (such as a switched-mode power supply) may need
substantial engineering expertise to implement.
78xx series ICs have built-in protection against a circuit drawing too much power. They have
protection against overheating and short-circuits, making them quite robust in most applications.
In some cases, the current-limiting features of the 78xx devices can provide protection not only
for the 78xx itself, but also for other parts of the circuit.

RESISTORS

The flow of charge (or current) through any material, encounters an opposing force similar in many
respect to mechanical friction. This opposing force is called resistance of the material. It is
measured in ohms. In some electric circuits resistance is deliberately introduced in the form of the
resistor.

Resistors are of following types:


1. Wire wound resistors.
2. Carbon resistors.
3. Metal film resistors.

13

Wire Wound Resistors:


Wire wound resistors are made from a long (usually Ni-Chromium) wound on a ceramic core.
Longer the length of the wire, higher is the resistance. So depending on the value of resistor
required in a circuit, the wire is cut and wound on a ceramic core. This entire assembly is coated
with a ceramic metal. Such resistors are generally available in power of 2 watts to several hundred
watts and resistance values from 1ohm to 100k ohms. Thus wire wound resistors are used for high
currents.
Carbon Resistors:
Carbon resistors are divided into three types:
a. Carbon composition resistors are made by mixing carbon grains with binding material
(glue) and moduled in the form of rods. Wire leads are inserted at the two ends. After this
an insulating material seals the resistor. Resistors are available in power ratings of 1/10,
1/8, 1/4, 1/2, 1.2 watts and values from 1 ohm to 20 ohms.
b. Carbon film resistors are made by deposition carbon film on a ceramic rod. They are
cheaper than carbon composition resistors.
c. Cement film resistors are made of thin carbon coating fired onto a solid ceramic substrate.
The main purpose is to have more precise resistance values and greater stability with heat.
They are made in a small square with leads.

Metal Film Resistors:


They are also called thin film resistors. They are made of a thin metal coating deposited on a
cylindrical insulating support. The high resistance values are not precise in value; however, such
resistors are free of inductance effect that is common in wire wound resistors at high frequency.
Variable Resistors:
Potentiometer is a resistor where values can be set depending on the requirement. Potentiometer
is widely used in electronics systems. Examples are volume control, tons control, brightness and
contrast control of radio or T.V. sets.

14

Fusible Resistors:
These resistors are wire wound type and are used in T.V. circuits for protection. They have
resistance of less than 15 ohms. Their function is similar to a fuse made to blow off whenever
current in the circuit exceeds the limit.
Resistance of a wire is directly proportional to its length and inversely proportional to its thickness.

RESISTOR COLOR CODE


Example: 1k or 1000 ohms

1st

2nd

3rd

4th

Band1
Band2

Band3
Band4

15

COLOUR CODES

COLOUR

NUMBER

MULTIPLIER

COLOUR

TOLERANCE

Black

100

Gold

Brown

101

Silver

10%

Red

102

No colour

20%

Orange

103

Yellow

104

Green

105

Blue

106

Violet

107

Grey

108

White

109

Gold

10-1

Silver

10-2

5%

16

CAPACITORS
A capacitor (formerly known as condenser) is a passive electronic component consisting of a pair
of conductors separated by a dielectric (insulator). When there is a potential difference (voltage)
across the conductors a static electric field develops in the dielectric that stores energy and
produces a mechanical force between the conductors. An ideal capacitor is characterized by a
single constant value, capacitance, measured in farads. This is the ratio of the electric charge on
each conductor to the potential difference between them.
Capacitors are widely used in electronic circuits for blocking direct current while allowing
alternating current to pass, in filter networks, for smoothing the output of power supplies, in the
resonant circuits that tune radios to particular frequencies and for many other purposes.
The effect is greatest when there is a narrow separation between large areas of conductor, hence
capacitor conductors are often called "plates", referring to an early means of construction. In
practice the dielectric between the plates passes a small amount of leakage current and also has an
electric field strength limit, resulting in a breakdown voltage, while the conductors and leads
introduce an equivalent series resistance

17

Ripple current:
Ripple current is the AC component of an applied source (often a switched-mode power supply)
whose frequency may be constant or varying. Certain types of capacitors, such as electrolytic
tantalum capacitors, usually have a rating for maximum ripple current (both in frequency and
magnitude). This ripple current can cause damaging heat to be generated within the capacitor due
to the current flow across resistive imperfections in the materials used within the capacitor, more
commonly referred to as equivalent series resistance (ESR). For example electrolytic tantalum
capacitors are limited by ripple current and generally have the highest ESR ratings in the capacitor
family, while ceramic capacitors generally have no ripple current limitation and have some of the
lowest ESR ratings.
Capacitor types
Practical capacitors are available commercially in many different forms. The type of internal
dielectric, the structure of the plates and the device packaging all strongly affect the characteristics
of the capacitor, and its applications.
Values available range from very low (Pico farad range; while arbitrarily low values are in
principle possible, stray (parasitic) capacitance in any circuit is the limiting factor) to about 5 kF
supercapacitors.
Above approximately 1 microfarad electrolytic capacitors are usually used because of their small
size and low cost compared with other technologies, unless their relatively poor stability, life and
polarized nature make them unsuitable. Very high capacity supercapacitors use a porous carbonbased electrode material.
Dielectric materials

Capacitor materials. From left: multilayer ceramic, ceramic disc, multilayer polyester film, tubular
ceramic, polystyrene, metalized polyester film, aluminum electrolytic. Major scale divisions are
in centimeters.

18

Most types of capacitor include a dielectric spacer, which increases their capacitance. These
dielectrics are most often insulators. However, low capacitance devices are available with a
vacuum between their plates, which allows extremely high voltage operation and low losses.
Variable capacitors with their plates open to the atmosphere were commonly used in radio tuning
circuits. Later designs use polymer foil dielectric between the moving and stationary plates, with
no significant air space between them.
In order to maximize the charge that a capacitor can hold, the dielectric material needs to have as
high a permittivity as possible, while also having as high a breakdown voltage as possible.
Several solid dielectrics are available, including paper, plastic, glass, mica and ceramic materials.
Paper was used extensively in older devices and offers relatively high voltage performance.
However, it is susceptible to water absorption, and has been largely replaced by plastic film
capacitors. Plastics offer better stability and aging performance, which makes them useful in timer
circuits, although they may be limited to low operating temperatures and frequencies. Ceramic
capacitors are generally small, cheap and useful for high frequency applications, although their
capacitance varies strongly with voltage and they age poorly. They are broadly categorized as class
1 dielectrics, which have predictable variation of capacitance with temperature or class 2
dielectrics, which can operate at higher voltage. Glass and mica capacitors are extremely reliable,
stable and tolerant to high temperatures and voltages, but are too expensive for most mainstream
applications. Electrolytic capacitors and supercapacitors are used to store small and larger amounts
of energy, respectively, ceramic capacitors are often used in resonators, and parasitic capacitance
occurs in circuits wherever the simple conductor-insulator-conductor structure is formed
unintentionally by the configuration of the circuit layout.

CERAMIC CAPACITOR:
In

this

project,

0.01

microfarad

capacitor

is

ceramic

capacitor.

The basis of the ceramic material is mainly barium titan ate or a similar material, but other ceramic
substance including hydrous silicate of magnesia or talc are also used. The electrodes are applied
in the form of silver which is either spread or plated on to the opposite faces of a thin tube, wafer
or disc made from the ceramic material. Connecting wires are then soldered to this deposit and the
whole capacitor dipped in for a suitable coating.

19

Fig. Tabular and disc type ceramic capacitors

ELECTROLYTIC CAPACITOR:
In this project, 10f capacitor is an electrolytic capacitor. In this type of capacitors, the dielectric
consists of an extremely thin film of aluminum oxide formed on one of its aluminum foil plates.
Intimate contact with the other plate is achieved by impregnating the paper between the foils with
an electrolyte in the form of viscous substance, such as ammonium borate. The sandwich is then
rolled into a cylindrical element and housed in either metallic cardboard, plastic or ceramic
protective tube.

Fig. Electrolytic and Tantalum capacitor

20

APPLICATIONS
Capacitors have many uses in electronic and electrical systems. They are so common that it is a
rare electrical product that does not include at least one for some purpose.
Energy storage
A capacitor can store electric energy when disconnected from its charging circuit, so it can be used
like a temporary battery. Capacitors are commonly used in electronic devices to maintain power
supply while batteries are being changed. (This prevents loss of information in volatile memory.)
Conventional electrostatic capacitors provide less than 360 joules per kilogram of energy density,
while capacitors using developing technologies can provide more than 2.52 kilojoules per
kilogram.
In car audio systems, large capacitors store energy for the amplifier to use on demand. Also for a
flash tube a capacitor is used to hold the high voltage. In ceiling fans, capacitors play the important
role of storing electrical energy to give the fan enough torque to start spinning.
Pulsed power and weapons
Groups of large, specially constructed, low-inductance high-voltage capacitors (capacitor banks)
are used to supply huge pulses of current for many pulsed power applications. These include
electromagnetic forming, Marx generators, pulsed lasers (especially TEA lasers), pulse forming
networks, radar, fusion research, and particle accelerators.
Large capacitor banks (reservoir) are used as energy sources for the exploding bridgewire
detonators or slapper detonators in nuclear weapons and other specialty weapons. Experimental
work is under way using banks of capacitors as power sources for electromagnetic armour and
electromagnetic rail guns and coil guns.

Variable capacitor
A variable capacitor is a capacitor whose capacitance may be intentionally and repeatedly changed
mechanically or electronically. Variable capacitors are often used in L/C circuits to set the
resonance frequency, e.g. to tune a radio (therefore they are sometimes called tuning capacitors),
or as a variable reactance, e.g. for impedance matching in antenna tuners.

21

Mechanically controlled
In mechanically controlled variable capacitors, the distance between the plates, or the amount of
plate surface area which overlaps, can be changed.
The most common form arranges a group of semicircular metal plates on a rotary axis (rotor)
that are positioned in the gaps between a set of stationary plates (stator) so that the area of overlap
can be changed by rotating the axis. Air or plastic foils can be used as dielectric material. By
choosing the shape of the rotary plates, various functions of capacitance vs. angle can be created,
e.g. to obtain a linear frequency scale. Various forms of reduction gear mechanisms are often used
to achieve finer tuning control, i.e. to spread the variation of capacity over a larger angle, often
several turns. A vacuum variable capacitor uses a set of plates made from concentric cylinders that
can be slid in or out of an opposing set of cylinders (sleeve and plunger). These plates are then
sealed inside of a non-conductive envelope such as glass or ceramic and placed under a high
vacuum. The movable part (plunger) is mounted on a flexible metal membrane that seals and
maintains the vacuum. A screw shaft is attached to the plunger, when the shaft is turned the plunger
moves in or out of the sleeve and the value of the capacitor changes. The vacuum not only increases
the working voltage and current handling capacity of the capacitor it also greatly reduces the
chance of arcing across the plates. The most common usage for vacuum variables are in high
powered transmitters such as those used for broadcasting, military and amateur radio as well as
high powered RF tuning networks. Vacuum variables can also be more convenient since the
elements are under a vacuum the working voltage can be higher than an air variable the same size,
allowing the size of the vacuum capacitor to be reduced.

22

Very cheap variable capacitors are constructed from layered aluminium and plastic foils that are
variably pressed together using a screw. These so-called squeezers cant provide a stable and
reproducible capacitance, however. A variant of this structure that allows for linear movement of
one set of plates to change the plate overlap area is also used and might be called a slider. This has
practical advantages for makeshift or home construction and may be found in resonant loop
antennas or crystal radios.

THE DIODE
Diodes are polarized, which means that they must be inserted into the PCB the correct way round.
This is because an electric current will only flow through them in one direction (like air will only
flow one way through a tyre valve). Diodes have two connections, an anode and a cathode. The
cathode is always identified by a dot, ring or some other mark.

The PCB is often marked with a +sign for the cathode end. Diodes come in all shapes and sizes.
They are often marked with a type number. Detailed characteristics of a diode can be found by
looking up the type number in a data book. If you know how to measure resistance with a meter
then test some diodes. A good one has low resistance in one direction and high in other. They are
specialized types of diode available such as the zener and light emitting diode (LED).

23

1N4007
1N4001 - 1N4007

General Purpose Rectifiers (Glass Passivated)


Absolute Maximum Ratings* TA = 25C unless otherwise noted
Features
Low forward voltage drop.
High surge current capability.

A diode is an electrical device allowing current to move through it in one direction with far greater
ease than in the other. The most common kind of diode in modern circuit design is the
semiconductor diode, although other diode technologies exist. Semiconductor diodes are
symbolized in schematic diagrams such as Figure below. The term diode is customarily reserved
for small signal devices, I 1 A. The term rectifier is used for power devices, I > 1 A.
Semiconductor diode schematic symbol: Arrows indicate the direction of electron current flow.
When placed in a simple battery-lamp circuit, the diode will either allow or prevent current through
the lamp, depending on the polarity of the applied voltage. (Figure below)

Diode operation: (a) Current flow is permitted; the diode is forward biased. (b) Current flow is
prohibited; the diode is reversed biased.

24

When the polarity of the battery is such that electrons are allowed to flow through the diode, the
diode is said to be forward-biased. Conversely, when the battery is backward and the diode
blocks current, the diode is said to be reverse-biased. A diode may be thought of as like a switch:
closed when forward-biased and open when reverse-biased. Oddly enough, the direction of
the diode symbol's arrowhead points against the direction of electron flow. This is because the
diode symbol was invented by engineers, who predominantly use conventional flow notation in
their schematics, showing current as a flow of charge from the positive (+) side of the voltage
source to the negative (-). This convention holds true for all semiconductor symbols possessing
arrowheads: the arrow points in the permitted direction of conventional flow, and against the
permitted direction of electron flow.
Diode behavior is analogous to the behavior of a hydraulic device called a check valve. A check
valve allows fluid flow through it in only one direction as in Figure below.

Hydraulic check valve analogy: (a) Electron current flow permitted. (b) Current flow prohibited.
Check valves are essentially pressure-operated devices: they open and allow flow if the pressure
across them is of the correct polarity to open the gate (in the analogy shown, greater fluid
pressure on the right than on the left). If the pressure is of the opposite polarity, the pressure
difference across the check valve will close and hold the gate so that no flow occurs. Like check
valves, diodes are essentially pressure- operated (voltage-operated) devices. The essential
difference between forward-bias and reverse-bias is the polarity of the voltage dropped across the
diode. Let's take a closer look at the simple battery-diode-lamp circuit shown earlier, this time
investigating voltage drops across the various components in Figure below.

25

Cuts current and drops a small voltage across it, leaving most of the battery voltage dropped across
the lamp. If the battery's polarity is reversed, the diode becomes reverse-biased, and drops all of
the battery's voltage leaving none for the lamp. If we consider the diode to be a self-actuating
switch (closed in the forward-bias mode and open in the reverse-bias mode), this behavior makes
sense. The most substantial difference is that the diode drops a lot more voltage when conducting
than the average mechanical switch (0.7 volts versus tens of millivolts).
This forward-bias voltage drop exhibited by the diode is due to the action of the depletion region
formed by the P-N junction under the influence of an applied voltage. If no voltage applied is
across a semiconductor diode, a thin depletion region exists around the region of the P-N junction,
preventing current flow. (Figure below (a)) The depletion region is almost devoid of available
charge carriers, and acts as an insulator:

Diode representations: PN-junction model, schematic symbol, physical part.


The schematic symbol of the diode is shown in Figure above (b) such that the anode (pointing end)
corresponds to the P-type semiconductor at (a). The cathode bar, non-pointing end, at (b)
corresponds to the N-type material at (a). Also note that the cathode stripe on the physical part (c)
corresponds to the cathode on the symbol.
If a reverse-biasing voltage is applied across the P-N junction, this depletion region expands,
further resisting any current through it. (Figure below)

26

Depletion region expands with reverse bias.


Conversely, if a forward-biasing voltage is applied across the P-N junction, the depletion region
collapses becoming thinner. The diode becomes less resistive to current through it. In order for a
sustained current to go through the diode; though, the depletion region must be fully collapsed by
the applied voltage. This takes a certain minimum voltage to accomplish, called the forward
voltage as illustrated in Figure below.

Increasing forward bias from (a) to (b) decreases depletion region thickness.
For silicon diodes, the typical forward voltage is 0.7 volts, nominal. For germanium diodes, the
forward voltage is only 0.3 volts. The chemical constituency of the P-N junction comprising the
diode accounts for its nominal forward voltage figure, which is why silicon and germanium diodes
have such different forward voltages. Forward voltage drop remains approximately constant for a
wide range of diode currents, meaning that diode voltage drop is not like that of a resistor or even
a normal (closed) switch. For most simplified circuit analysis, the voltage drop across a conducting
diode may be considered constant at the nominal figure and not related to the amount of current.

27

WELCOME TO THE WORLD OF THE MICROCONTROLLERS.


Look around. Notice the smart intelligent systems? Be it the T.V, washing machines, video
games, telephones, automobiles, aero planes, power systems, or any application having a LED or
a LCD as a user interface, the control is likely to be in the hands of a micro controller!
Measure and control, thats where the micro controller is at its best. Micro controllers are here to
stay. Going by the current trend, it is obvious that micro controllers will be playing bigger and
bigger roles in the different activities of our lives.
These embedded chips are very small, but are designed to replace components much bigger and
bulky in size. They process information very intelligently and efficiently. They sense the
environment around them. The signals they gather are tuned into digital data that streams through
tributaries of circuit lines at the speed of light. Inside the microprocessor collates and calculators.
The software has middling intelligence. Then in a split second, the processed streams are shoved
out.

What is the primary difference between a microprocessor and a micro controller?


Unlike the microprocessor, the micro controller can be considered to be a true Computer on a
chip.
In addition to the various features like the ALU, PC, SP and registers found on a microprocessor,
the micro controller also incorporates features like the ROM, RAM, Ports, timers, clock circuits,
counters, reset functions etc.
While the microprocessor is more a general-purpose device, used for read, write and calculations
on data, the micro controller, in addition to the above functions also controls the environment.

8051 micro controller


The 8051 developed and launched in the early 80`s, is one of the most popular micro controller in
use today. It has a reasonably large amount of built in ROM and RAM. In addition it has the ability
to access external memory. The generic term `8x51` is used to define the device. The value of x
defining the kind of ROM, i.e. x=0, indicates none, x=3, indicates mask ROM, x=7, indicates
EPROM and x=9 indicates EEPROM or Flash.

28

A note on ROM
The early 8051, namely the 8031 was designed without any ROM. This device could run only with
external memory connected to it. Subsequent developments lead to the development of the PROM
or the programmable ROM. This type had the disadvantage of being highly unreliable.
The next in line, was the EPROM or Erasable Programmable ROM. These devices used ultraviolet
light erasable memory cells. Thus a program could be loaded, tested and erased using ultra violet
rays. A new program could then be loaded again.

An improved EPROM was the EEPROM or the electrically erasable PROM. This does not require
ultra violet rays, and memory can be cleared using circuits within the chip itself.

Finally there is the FLASH, which is an improvement over the EEPROM. While the terms
EEPROM and flash are sometimes used interchangeably, the difference lies in the fact that flash
erases the complete memory at one stroke, and not act on the individual cells. This results in
reducing the time for erasure.

Different microcontrollers in market.

PIC

One of the famous microcontrollers used in the industries. It is based on RISC Architecture which
makes the microcontroller process faster than other microcontroller.

INTEL

These are the first to manufacture microcontrollers. These are not as sophisticated other
microcontrollers but still the easiest one to learn.

ATMEL

Atmels AVR microcontrollers are one of the most powerful in the embedded industry. This is the
only microcontroller having 1kb of ram even the entry stage. But it is unfortunate that in India we
are unable to find this kind of microcontroller.

29

AT89S52
Features
Compatible with MCS-51 Products
4K Bytes of In-System Programmable (ISP) Flash Memory Endurance: 1000 Write/Erase
Cycles
4.0V to 5.5V Operating Range
Fully Static Operation: 0 Hz to 33 MHz
Three-level Program Memory Lock
128 x 8-bit Internal RAM
32 Programmable I/O Lines
Two 16-bit Timer/Counters
Six Interrupt Sources
Full Duplex UART Serial Channel
Low-power Idle and Power-down Modes
Interrupt Recovery from Power-down Mode
Watchdog Timer
Dual Data Pointer Power-off Flag
Fast Programming Time
Flexible ISP Programming (Byte and Page Mode)
Green (Pb/Halide-free) Packaging Option

Description
The AT89S51 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 Indus-try-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 pro-grammar. By combining a versatile 8-bit CPU with InSystem Programmable Flash on a monolithic chip, the Atmel AT89S51 is a powerful
microcontroller which provides a highly-flexible and cost-effective solution to many embedded
control applications. The AT89S51 provides the following standard features: 4K bytes of Flash,

30

128 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, two 16-bit timer/counters, a
five-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock
circuitry. In addition, the AT89S51 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 external interrupt or hardware reset.

Pin Configurations

31

Block Diagram

32

Pin Description
VCC
Supply voltage (all packages except 42-PDIP).
GND
Ground (all packages except 42-PDIP; for 42-PDIP GND connects only the logic core and
the embedded program memory).
VDD
Supply voltage for the 42-PDIP which connects only the logic core and the embedded
program memory.
PWRVDD
Supply voltage for the 42-PDIP which connects only the I/O Pad Drivers. The
application board must connect both VDD and PWRVDD to the board supply voltage.
PWRGND
Ground for the 42-PDIP which connects only the I/O Pad Drivers. PWRGND and GND
are weakly connected through the common silicon substrate, but not through any metal link. The
application board must connect both GND and PWRGND to the board ground.
Port 0
Port 0 is an 8-bit open drain bi-directional I/O port. As an output port, each pin can sink
eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high-impedance
inputs. Port 0 can also be configured to be the multiplexed low-order address/data bus during
accesses to external program and data memory. In this mode, P0 has internal pull-ups. Port 0 also
receives the code bytes during Flash programming and outputs the code bytes during program
verification. External pull-ups are required during program verification.
Port 1
Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output buffers
can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the
inter-nal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled
low will source current (IIL) because of the internal pull-ups. Port 1 also receives the low-order
address bytes during Flash programming and verification.

33

Port 2
Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2 output buffers
can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the
inter-nal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled
low will source current (IIL) because of the internal pull-ups. Port 2 emits the high-order address
byte during fetches from external program memory and during accesses to external data memory
that use 16-bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pullups when emitting 1s. During accesses to external data memory that use 8-bit addresses (MOVX
@ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the highorder address bits and some control signals during Flash programming and verification.
Port 3
Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output buffers
can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the
inter-nal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled
low will source current (IIL) because of the pull-ups. Port 3 receives some control signals for Flash
programming and verification.
RST
Reset input. A high on this pin for two machine cycles while the oscillator is running resets
the device. This pin drives High for 98 oscillator periods after the Watchdog times out. The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default state of
bit DISRTO, the RESET HIGH out feature is enabled.
ALE/PROG
Address Latch Enable (ALE) is an output pulse for latching the low byte of the address
during accesses to external memory. This pin is also the program pulse input (PROG) during Flash
programming.
In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be
used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during
each access to external data memory. If desired, ALE operation can be disabled by setting bit 0 of
SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction.
Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the
microcontroller is in external execution mode.

34

PSEN
Program Store Enable (PSEN) is the read strobe to external program memory. When the
AT89S51 is executing code from external program memory, PSEN is activated twice each
machine cycle, except that two PSEN activations are skipped during each access to exter-nal data
memory.
EA/VPP
External Access Enable. EA must be strapped to GND in order to enable the device to
fetch code from external program memory locations starting at 0000H up to FFFFH. Note,
however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be
strapped to VCC for internal program executions. This pin also receives the 12-volt programming
enable voltage (VPP) during Flash programming.

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

XTAL2
Output from the inverting oscillator amplifier

REGISTER
Interrupt Registers:
The individual interrupt enable bits are in the IE register. Two priorities can be set for each of the
five interrupt sources in the IP register.
Dual Data Pointer Registers:
To facilitate accessing both internal and external data memory, two banks of 16-bit Data Pointer
Registers are provided: DP0 at SFR address locations 82H- 83H and DP1 at 84H-85H. Bit DPS =
0 in SFR AUXR1 selects DP0 and DPS = 1 selects DP1. The user should ALWAYS initialize the
DPS bit to the appropriate value before accessing the respective Data Pointer Register.
Power off Flag:
The Power off Flag (POF) is located at bit 4 (PCON.4) in the PCON SFR. POF is set to
1 during power up. It can be set and rest under software control and is not affected by reset.

35

Memory Organization
MCS-51 devices have a separate address space for Program and Data Memory. Up
to 64K bytes each of external Program and Data Memory can be addressed.
Program Memory
If the EA pin is connected to GND, all program fetches are directed to external
memory. On the AT89S51, if EA is connected to VCC, program fetches to addresses 0000H
through FFFH are directed to internal memory and fetches to addresses 1000H through FFFFH are
directed to external memory.
Data Memory
The AT89S51 implements 128 bytes of on-chip RAM. The 128 bytes are accessible via direct and
indirect addressing modes. Stack operations are examples of indirect addressing, so the 128 bytes
of data RAM are available as stack space.

Timer 0 and 1
Timer 0 and Timer 1 in the AT89S51 operate the same way as Timer 0 and Timer 1 in the
AT89C51. For further information on the timers operation.

Interrupts
The AT89S51 has a total of five interrupt vectors: two external interrupts (INT0 and INT1), two
timer interrupts (Timers 0 and 1), and the serial port interrupt.

Oscillator Characteristics
XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier that can be
configured for use as an on-chip oscillator. Either a quartz crystal or ceramic resonator may be
used. To drive the device from an external clock source, XTAL2 should be left unconnected while
XTAL1 is driven. There are no requirements on the duty cycle of the external clock signal, since
the input to the internal clock-ing circuitry is through a divide-by-two flip-flop, but minimum and
maximum voltage high and low time specifications must be observed.

36

MOV INSTRUCTIONS
MOV instruction simply copy the data from one location to another location
MOV D, S
Copy the data from(S) source to D (destination)
MOV R0, A ; Copy contents of A into Register R0
MOV R1, A ; Copy contents of A into register R1
MOV A, R3 ; copy contents of Register R3 into Accumulator.

DIRECT LOADING THROUGH MOV


MOV A, #23H; Direct load the value of 23h in A
MOV R0, #12h; direct load the value of 12h in R0
MOV R5, #0F9H; Load the F9 value in the Register R5

ADD INSTRUCTIONS.
ADD instructions adds the source byte to the accumulator (A) and place the result in the
Accumulator.

ADD A, #42H; By this instructions we add the value 42h in Accumulator (42H+ 25H)
ADDA, R3; By this instructions we move the data from register r3 to accumulator and then add
the contents of the register into accumulator.

SUBROUTINE CALL FUNCTION.


ACALL, TARGET ADDRESS.
By this instructions we call subroutines with a target address within 2k bytes from the current
program counter.

37

LCALL, TARGET ADDRESS.


ACALL is a limit for the 2 k byte program counter, but for up to 64k byte we use LCALL
Instructions. Note that LCALL is a 3 byte instructions. ACALL is a two byte instructions.

AJMP TARGET ADDRESS.


This is for absolute jump
AJMP stand for absolute jump. It transfers program execution to the target address
unconditionally. The target address for this instruction must be within 2 k byte of program
memory.
LJMP is also for absolute jump. It transfer program execution to the target address
unconditionally. This is a 3 byte instructions LJMP jump to any address within 64 k byte
location.
INSTRUCTIONS RELATED TO THE CARRY
JC TARGET: Jump to the target if CY flag =1
JNC TARGET: Jump to the target address if CY flag is = 0
INSTRUCTIONS RELASTED TO JUMP WITH ACCUMULATOR
JZ TARGET: Jump to target if a = 0
JNZ TARGET: Jump if accumulator is not zero
This instructions jumps if register A has a value other than zero
INSTRUCTIONS RELATED TO THE ROTATE
RL A: Rotate left the accumulator
BY this instructions we rotate the bits of A left. The bits rotated out of A are rotated back into A
at the opposite end
RR A
By this instruction we rotate the contents of the accumulator from right to left from LSB to MSB
RRC A
This is same as RR A but difference is that the bit rotated out of register first enter in to carry and
then enter into MSB

38

RLC A:
Rotate A left through carry same as above but shift the data from MSB to carry and carry to LSB
RET
This is return from subroutine. This instructions is used to return from a subroutine previously
entered by instructions LCALL and ACALL.
RET1
This is used at the end of an interrupt service routine. We use this instructions after interrupt
routine,

PUSH.

This copies the indicated byte onto the stack and increments SP by. This instructions supports
only direct addressing mode.

POP.

POP FROM STACK.


This copies the byte pointed to be SP to the location whose direct address is indicated, and
decrements SP by 1. Notice that this instructions supports only direct addressing mode.

HT12 E
HT12E is an encoder integrated circuit of 212 series of encoders. They are paired with 212 series
of decoders for use in remote control system applications. It is mainly used in interfacing RF and
infrared circuits. The chosen pair of encoder/decoder should have same number of addresses and
data format.
Simply put, HT12E converts the parallel inputs into serial output. It encodes the 12 bit parallel
data into serial for transmission through an RF transmitter. These 12 bits are divided into 8 address
bits and 4 data bits.
HT12E has a transmission enable pin which is active low. When a trigger signal is received on
TE pin, the programmed addresses/data are transmitted together with the header bits via an RF or
an infrared transmission medium. HT12E begins a 4-word transmission cycle upon receipt of a
transmission enable. This cycle is repeated as long as TE is kept low. As soon as TE returns to
high, the encoder output completes its final cycle and then stop.

39

The 212 encoders are a series of CMOS LSIs for remote control system applications. They are
capable of encoding information which consists of N address bits and 12_N data bits. Each
address/data input can be set to one of the two logic states. The programmed addresses/ data are
transmitted together with the header bits via an RF or an infrared transmission medium upon
receipt of a trigger signal. The capability to select a TE trigger on the HT12E or a DATA trigger
on the HT12A further enhances the application flexibility of the 212 series of encoders. The
HT12A additionally provides a 38 kHz carrier for infrared systems.

40

41

Features

Operating voltage
2.4V~5V for the HT12A
2.4V~12V for the HT12E

Low power and high noise immunity CMOS technology

Low standby current: 0.1_A (typ.) at VDD=5V

HT12A with a 38kHz carrier for infrared transmission medium

Minimum transmission word

Four words for the HT12E

One word for the HT12A

Built-in oscillator needs only 5% resistor

Data code has positive polarity

Minimal external components

Pair with Holtek_s 212 series of decoders

18-pin DIP, 20-pin SOP package

Applications of HT12E

Burglar alarm system

Smoke and fire alarm system

Garage door controllers

Car door controllers

Car alarm system

Security system

Cordless telephones

Other remote control system

42

HT12D
HT12D is a decoder integrated circuit that belongs to 212 series of decoders. This series of
decoders are mainly used for remote control system applications, like burglar alarm, car door
controller, security system etc. It is mainly provided to interface RF and infrared circuits. They
are paired with 212 series of encoders. The chosen pair of encoder/decoder should have same
number of addresses and data format.
In simple terms, HT12D converts the serial input into parallel outputs. It decodes the serial
addresses and data received by, say, an RF receiver, into parallel data and sends them to output
data pins. The serial input data is compared with the local addresses three times continuously. The
input data code is decoded when no error or unmatched codes are found. A valid transmission in
indicated by a high signal at VT pin. HT12D is capable of decoding 12 bits, of which 8 are address
bits and 4 are data bits. The data on 4 bit latch type output pins remain unchanged until new is
received.
12 decoders are a series of CMOS LSIs for remote control system applications. They are Paired
with Holtek_s 212 series of encoders (refer to the encoder/decoder cross reference table).
For proper operation, a pair of encoder/decoder with the same number of addresses and data format
should be chosen. The decoders receive serial addresses and data from a programmed 212 series
of encoders that are transmitted by a carrier using an RF or an IR transmission medium. They
compare the serial input data three times continuously with their local addresses. If no error or
unmatched codes are found, the input data codes are decoded and then transferred to the output
pins.
The VT pin also goes high to indicate a valid transmission. The 212 series of decoders are capable
of decoding informations that consist of N bits of address and 12_N bits of data. Of this series, the
HT12D is arranged to provide 8 address bits and 4 data bits, and HT12F is used to decode 12 bits
of address information. 12 decoders are a series of CMOS LSIs for remote control system
applications. They are paired with Holtek_s 212 series of encoders (refer to the encoder/decoder
cross reference table).
For proper operation, a pair of encoder/decoder with the same number of addresses and data format
should be chosen.
The decoders receive serial addresses and data from a programmed 212 series of encoders that are
transmitted by a carrier using an RF or an IR transmission medium. They compare the serial input

43

data three times continuously with their local addresses. If no error or unmatched codes are found,
the input data codes are decoded and then transferred to the output pins.The VT pin also goes high
to indicate a valid transmission.

PIN DIAGRAM

44

Features

Operating voltage: 2.4V~12V

Low power and high noise immunity CMOS Technology

Low standby current

Capable of decoding 12 bits of information

Pair with Holtek_s 212 Series of encoders

Binary address setting

Received codes are checked 3 times

Address/Data number combination

HT12D: 8 address bits and 4 data bits

HT12F: 12 address bits only

Built-in oscillator needs only 5% resistor

Valid transmission indicator

Easy interface with an RF or an infrared transmission medium

Minimal external components

Applications

Burglar alarm system

Smoke and fire alarm system

Garage door controllers

Car door controllers

Car alarm system

Security system

Cordless telephones

Other remote control systems

45

LCD
Frequently, an 8051 program must interact with the outside world using input and output devices
that communicate directly with a human being. One of the most common devices attached to an
8051 is an LCD display. Some of the most common LCDs connected to the 8051 are 16x2 and
20x2 displays. This means 16 characters per line by 2 lines and 20 characters per line by 2 lines,
respectively.
Fortunately, a very popular standard exists which allows us to communicate with the vast majority
of LCDs regardless of their manufacturer. The standard is referred to as HD44780U, which refers
to the controller chip which receives data from an external source (in this case, the 8051) and
communicates directly with the LCD.

46

Pin Description

44780 BACKGROUND
The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The
user may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit
data bus is used, the LCD will require a total of 7 data lines (3 control lines plus the 4 lines for the
data bus). If an 8-bit data bus is used, the LCD will require a total of 11 data lines (3 control lines
plus the 8 lines for the data bus).
The three control lines are referred to as EN, RS, and RW.
The EN line is called "Enable." This control line is used to tell the LCD that you are sending it
data. To send data to the LCD, your program should first set this line high (1) and then set the

47

other two control lines and/or put data on the data bus. When the other lines are completely ready,
bring EN low (0) again. The 1-0 transition tells the 44780 to take the data currently found on the
other control lines and on the data bus and to treat it as a command.
The RS line is the "Register Select" line. When RS is low (0), the data is to be treated as a command
or special instruction (such as clear screen, position cursor, etc.). When RS is high (1), the data
being sent is text data which should be displayed on the screen. For example, to display the letter
"T" on the screen you would set RS high.
The RW line is the "Read/Write" control line. When RW is low (0), the information on the data
bus is being written to the LCD. When RW is high (1), the program is effectively querying (or
reading) the LCD. Only one instruction ("Get LCD status") is a read command. All others are write
commands--so RW will almost always be low.
Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation selected by the
user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3, DB4,
DB5, DB6, and DB7.

AN EXAMPLE HARDWARE CONFIGURATION


As we've mentioned, the LCD requires either 8 or 11 I/O lines to communicate with. For the sake
of this tutorial, we are going to use an 8-bit data bus--so we'll be using 11 of the 8051's I/O pins to
interface with the LCD.
Let's draw a sample psuedo-schematic of how the LCD will be connected to the 8051.

48

As you can see, we've established a 1-to-1 relation between a pin on the 8051 and a line on the
44780 LCD. Thus as we write our assembly program to access the LCD, we are going to equate
constants to the 8051 ports so that we can refer to the lines by their 44780 name as opposed to
P0.1, P0.2, etc. Let's go ahead and write our initial equates:

DB0 EQU P1.0


DB1 EQU P1.1
DB2 EQU P1.2
DB3 EQU P1.3
DB4 EQU P1.4
DB5 EQU P1.5
DB6 EQU P1.6
DB7 EQU P1.7
EN EQU P3.7
RS EQU P3.6
RW EQU P3.5
DATA EQU P1

Having established the above equates, we may now refer to our I/O lines by their 44780 name. For
example, to set the RW line high (1), we can execute the following instruction:
SETB RW

HANDLING THE EN CONTROL LINE


As we mentioned above, the EN line is used to tell the LCD that you are ready for it to execute an
instruction that you've prepared on the data bus and on the other control lines. Note that the EN
line must be raised/lowered before/after each instruction sent to the LCD regardless of whether
that instruction is read or write, text or instruction. In short, you must always manipulate EN when
communicating with the LCD. EN is the LCD's way of knowing that you are talking to it. If you
don't raise/lower EN, the LCD doesn't know you're talking to it on the other lines.

49

Thus, before we interact in any way with the LCD we will always bring the EN line high with the
following instruction:
SETB EN
And once we've finished setting up our instruction with the other control lines and data bus lines,
we'll always bring this line back low:
CLR EN
Programming Tip: The LCD interprets and executes our command at the instant the EN line is
brought low. If you never bring EN low, your instruction will never be executed. Additionally,
when you bring EN low and the LCD executes your instruction, it requires a certain amount of
time to execute the command. The time it requires to execute an instruction depends on the
instruction and the speed of the crystal which is attached to the 44780's oscillator input.

CHECKING THE BUSY STATUS OF THE LCD


As previously mentioned, it takes a certain amount of time for each instruction to be executed by
the LCD. The delay varies depending on the frequency of the crystal attached to the oscillator input
of the 44780 as well as the instruction which is being executed.
While it is possible to write code that waits for a specific amount of time to allow the LCD to
execute instructions, this method of "waiting" is not very flexible. If the crystal frequency is
changed, the software will need to be modified. Additionally, if the LCD itself is changed for
another LCD which, although 44780 compatible, requires more time to perform its operations, the
program will not work until it is properly modified.
A more robust method of programming is to use the "Get LCD Status" command to determine
whether the LCD is still busy executing the last instruction received.
The "Get LCD Status" command will return to us two tidbits of information; the information that
is useful to us right now is found in DB7. In summary, when we issue the "Get LCD Status"
command the LCD will immediately raise DB7 if it's still busy executing a command or lower
DB7 to indicate that the LCD is no longer occupied. Thus our program can query the LCD until
DB7 goes low, indicating the LCD is no longer busy. At that point we are free to continue and
send the next command. Since we will use this code every time we send an instruction to the LCD,
it is useful to make it a subroutine. Let's write the code:

50

WAIT_LCD:
SETB EN ;Start LCD command
CLR RS ;It's a command
SETB RW ;It's a read command
MOV DATA,#0FFh ;Set all pins to FF initially
MOV A,DATA ;Read the return value
JB ACC.7,WAIT_LCD ;If bit 7 high, LCD still busy
CLR EN ;Finish the command
CLR RW ;Turn off RW for future commands
RET
Thus, our standard practice will be to send an instruction to the LCD and then call our WAIT_LCD
routine to wait until the instruction is completely executed by the LCD. This will assure that our
program gives the LCD the time it needs to execute instructions and also makes our program
compatible with any LCD, regardless of how fast or slow it is.

Programming Tip: The above routine does the job of waiting for the LCD, but were it to be used
in a real application a very definite improvement would need to be made: as written, if the LCD
never becomes "not busy" the program will effectively "hang," waiting for DB7 to go low. If this
never happens, the program will freeze. Of course, this should never happen and won't happen
when the hardware is working properly. But in a real application it would be wise to put some kind
of time limit on the delay--for example, a maximum of 256 attempts to wait for the busy signal to
go low. This would guarantee that even if the LCD hardware fails, the program would not lock up.

INITIALIZING THE LCD


Before you may really use the LCD, you must initialize and configure it. This is accomplished by
sending a number of initialization instructions to the LCD.
The first instruction we send must tell the LCD whether we'll be communicating with it with an 8bit or 4-bit data bus. We also select a 5x8 dot character font. These two options are selected by
sending the command 38h to the LCD as a command. As you will recall from the last section, we
mentioned that the RS line must be low if we are sending a command to the LCD. Thus, to send
this 38h command to the LCD we must execute the following 8051 instructions:
51

SETB EN
CLR RS
MOV DATA, #38h
CLR EN
LCALL WAIT_LCD
Programming Tip: The LCD command 38h is really the sum of a number of option bits. The
instruction itself is the instruction 20h ("Function set"). However, to this we add the values 10h to
indicate an 8-bit data bus plus 08h to indicate that the display is a two-line display.
We've now sent the first byte of the initialization sequence. The second byte of the initialization
sequence is the instruction 0Eh. Thus we must repeat the initialization code from above, but now
with the instruction. Thus the next code segment is:
SETB EN
CLR RS
MOV DATA, #0Eh
CLR EN
LCALL WAIT_LCD

Programming Tip: The command 0Eh is really the instruction 08h plus 04h to turn the LCD on.
To that an additional 02h is added in order to turn the cursor on.
The last byte we need to send is used to configure additional operational parameters of the LCD.
We must send the value 06h.
SETB EN
CLR RS
MOV DATA, #06h
CLR EN
LCALL WAIT_LCD
Programming Tip: The command 06h is really the instruction 04h plus 02h to configure the LCD
such that every time we send it a character, the cursor position automatically moves to the right.
So, in all, our initialization code is as follows:
INIT_LCD:
SETB EN
CLR RS
52

MOV DATA, #38h


CLR EN
LCALL WAIT_LCD
SETB EN
CLR RS
MOV DATA,#0Eh
CLR EN
LCALL WAIT_LCD
SETB EN
CLR RS
MOV DATA,#06h
CLR EN
LCALL WAIT_LCD
RET
Having executed this code the LCD will be fully initialized and ready for us to send display data
to it.
CLEARING THE DISPLAY
When the LCD is first initialized, the screen should automatically be cleared by the 44780
controller. However, it's always a good idea to do things yourself so that you can be completely
sure that the display is the way you want it. Thus, it's not a bad idea to clear the screen as the very
first operation after the LCD has been initialized.
An LCD command exists to accomplish this function. Not surprisingly, it is the command 01h.
Since clearing the screen is a function we very likely will wish to call more than once, it's a good
idea to make it a subroutine:
CLEAR_LCD:
SETB EN
CLR RS
MOV DATA, #01h
CLR EN

53

LCALL WAIT_LCD
RET
How that we've written a "Clear Screen" routine, we may clear the LCD at any time by simply
executing an LCALL CLEAR_LCD.
Programming Tip: Executing the "Clear Screen" instruction on the LCD also positions the cursor
in the upper left-hand corner as we would expect.

WRITING TEXT TO THE LCD


Now we get to the real meat of what we're trying to do: All this effort is really so we can display
text on the LCD. Really, we're pretty much done.
Once again, writing text to the LCD is something we'll almost certainly want to do over and over-so let's make it a subroutine.
WRITE_TEXT:
SETB EN
SETB RS
MOV DATA, A
CLR EN
LCALL WAIT_LCD
RET
The WRITE_TEXT routine that we just wrote will send the character in the accumulator to the
LCD which will, in turn, display it. Thus to display text on the LCD all we need to do is load the
accumulator with the byte to display and make a call to this routine. Pretty easy, huh?
A "HELLO WORLD" PROGRAM
Now that we have all the component subroutines written, writing the classic "Hello World"
program--which displays the text "Hello World" on the LCD is a relatively trivial matter. Consider:
LCALL INIT_LCD
LCALL CLEAR_LCD
MOV A,#'H'
LCALL WRITE_TEXT
MOV A,#'E'
54

LCALL WRITE_TEXT
MOV A,#'L'
LCALL WRITE_TEXT
MOV A,#'L'
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
MOV A,#' '
LCALL WRITE_TEXT
MOV A,#'W'
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
MOV A,#'R'
LCALL WRITE_TEXT
MOV A,#'L'
LCALL WRITE_TEXT
MOV A,#'D'
LCALL WRITE_TEXT
The above "Hello World" program should, when executed, initialize the LCD, clear the LCD
screen, and display "Hello World" in the upper left-hand corner of the display.
CURSOR POSITIONING
The above "Hello World" program is simplistic in the sense that it prints its text in the upper lefthand corner of the screen. However, what if we wanted to display the word "Hello" in the upper
left-hand corner but wanted to display the word "World" on the second line at the tenth character?
This sounds simple--and actually, it is simple. However, it requires a little more understanding of
the design of the LCD.
The 44780 contains a certain amount of memory which is assigned to the display. All the text we
write to the 44780 is stored in this memory, and the 44780 subsequently reads this memory to

55

display the text on the LCD itself. This memory can be represented with the following "memory
map":

Thus, the first character in the upper left-hand corner is at address 00h. The following character
position (character #2 on the first line) is address 01h, etc. This continues until we reach the 16th
character of the first line which is at address 0Fh.
However, the first character of line 2, as shown in the memory map, is at address 40h. This means
if we write a character to the last position of the first line and then write a second character, the
second character will not appear on the second line. That is because the second character will
effectively be written to address 10h--but the second line begins at address 40h.
Thus we need to send a command to the LCD that tells it to position the cursor on the second line.
The "Set Cursor Position" instruction is 80h. To this we must add the address of the location where
we wish to position the cursor. In our example, we said we wanted to display "World" on the
second line on the tenth character position.
Referring again to the memory map, we see that the tenth character position of the second line is
address 4Ah. Thus, before writing the word "World" to the LCD, we must send a "Set Cursor
Position" instruction--the value of this command will be 80h (the instruction code to position the
cursor) plus the address 4Ah. 80h + 4Ah = C4h. Thus sending the command C4h to the LCD will
position the cursor on the second line at the tenth character position:
SETB EN
CLR RS
MOV DATA,#0C4h
CLR EN
LCALL WAIT_LCD
The above code will position the cursor on line 2, character 10. To display "Hello" in the upper
left-hand corner with the word "World" on the second line at character position 10 just requires us
to insert the above code into our existing "Hello World" program. This results in the following:

56

LCALL INIT_LCD
LCALL CLEAR_LCD
MOV A,#'H'
LCALL WRITE_TEXT
MOV A,#'E'
LCALL WRITE_TEXT
MOV A,#'L'
LCALL WRITE_TEXT
MOV A,#'L'
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
SETB EN
CLR RS
MOV DATA,#0C4h
CLR EN
LCALL WAIT_LCD
MOV A,#'W'
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
MOV A,#'R'
LCALL WRITE_TEXT
MOV A,#'L'
LCALL WRITE_TEXT
MOV A,#'D'
LCALL WRITE_TEXT

57

LCD COMMAND

CLEAR DISPLAY SCREEN

RETURN HOME

DECREMENT CURSOR (SHIFT CURSOR TO LEFT)

SHIFT DISPLAY RIGHT.

INCREMENT CURSOR (SHIFT CURSOR TO RIGHT)

SHIFT DISPLAY LEFT

DISPLAY OFF, CURSOR OFF

DISPLAY OFF CURSOR ON

DISPLAY ON CURSOR OFF

DISPLAY ON CURSOR BLINKING

DISPLAY ON CURSOR BLINKING.

SHIFT CURSOR POSITION TO LEFT

SHIFT CURSOR POSITION TO RIGHT

SHIFT THE ENTIRE DISPLAY TO THE LEFT

SHIFT THE ENTIRE DISPLAY TO THE RIGHT

FORCE CURSOR TO BEGINNING OF IST LINE

FORCE CURSOR TO BEGINNING OF 2ND LINE

58

OPTO-ISOLATOR

In electronics, an opto-isolator, also called an optocoupler, photo coupler, or optical isolator, is a


component that transfers electrical signals between two isolated circuits by using light. Optoisolators prevent high voltages from affecting the system receiving the signal. Commercially
available opto-isolators withstand input-to-output voltages up to 10 kV and voltage transients with
speeds up to 10 kV/s.
A common type of opto-isolator consists of an LED and a phototransistor in the same opaque
package. Other types of source-sensor combinations include LED-photodiode, LED-LASCR,
and lamp-photoresist or pairs. Usually opto-isolators transfer digital (on-off) signals, but some
techniques allow them to be used with analog signals.

59

Circuit Diagram

Operation
An opto-isolator contains a source (emitter) of light, almost always a near infrared light-emitting
diode (LED), that converts electrical input signal into light, a closed optical channel (also called
dialectical channel), and a photo sensor, which detects incoming light and either generates
electric energy directly, or modulates electric current flowing from an external power supply. The
sensor can be a photo resistor, a photodiode, a phototransistor, a silicon-controlled rectifier (SCR)
or a triac. Because LEDs can sense light in addition to emitting it, construction of symmetrical,
bidirectional opto-isolators is possible. An opto coupled solid state relay contains a photodiode
opto-isolator which drives a power switch, usually a complementary pair of MOSFETs. A slotted
optical switch contains a source of light and a sensor, but its optical channel is open,
allowing modulation of light by external objects obstructing the path of light or reflecting light
into the sensor.

Crystal Oscillator
An oscillator is something that produces an output that repeats regularly. In the electronics field
this

will

be

an

electrical

waveform,

often

but

not

always

sine

wave.

The most important property of an oscillator is its frequency: the rate at which the output repeats.
This is measured in Hertz (Hz for short). One Hertz is one repetition (aka cycle) per second. One
Megahertz

(MHz)

is

one

million

repetitions

per

second.

One of the problems in designing a high quality oscillator is maintaining the output frequency at
the value required. One method is to control it by a quartz crystal; this is cut so that it vibrates
mechanically at the design frequency, and is coupled to the electronics by the piezo-electric

60

effect. A 12 MHz crystal oscillator is an electronic circuit, whose output frequency is controlled
by a quartz crystal to repeat 12 million times per second.

Fig: crystal oscillator

RF MODULE
An RF module (radio frequency module) is a (usually) small electronic device used to transmit
and/or receive radio signals between two devices. In an embedded system it is often desirable to
communicate with another device wirelessly. This wireless communication may be accomplished
through optical communication or through Radio Frequency (RF) communication. For many
applications the medium of choice is RF since it does not require line of sight. RF communications
incorporate a transmitter and/or receiver.
RF modules are widely used in electronic design owing to the difficulty of designing radio
circuitry. Good electronic radio design is notoriously complex because of the sensitivity of radio
circuits and the accuracy of components and layouts required to achieve operation on a specific
frequency. In addition, reliable RF communication circuit requires careful monitoring of the
manufacturing process to ensure that the RF performance is not adversely affected. Finally, radio
circuits are usually subject to limits on radiated emissions, and require Conformance testing and
certification by a standardization organization such as ETSI or the FCC. For these reasons, design
engineers will often design a circuit for an application which requires radio communication and
then "drop in" a pre-made radio module rather than attempt a discrete design, saving time and
money on development.
RF modules are most often used in medium and low volume products for consumer applications
such as garage door openers, wireless alarm systems, industrial remote controls, smart sensor
applications, and wireless home automation systems. They are sometimes used to replace

61

older infra-red communication designs as they have the advantage of not requiring line-of-sight
operation.
Several carrier frequencies are commonly used in commercially-available RF modules, including
those in the industrial, scientific and medical (ISM) radio bands such as 433.92 MHz, 315 MHz,
868 MHz, 915 MHz, and 2400 MHz These frequencies are used because of national and
international regulations governing the use of radio for communication.
RF modules may comply with a defined protocol for RF communications such as Zig
bee, Bluetooth low energy, or Wi-Fi, or they may implement a Proprietary protocol.

Types of RF modules
1. Transmitter Module
2. Receiver Module
3. Transceiver module
Transmitter Module
An RF transmitter module is a small PCB sub-assembly capable of transmitting a radio wave
and modulating that wave to carry data. Transmitter modules are usually implemented alongside
a micro controller which will provide data to the module which can be transmitted. RF Transmitters
are usually subject to Regulatory Requirements which dictate the maximum allowable Transmitter
power output, Harmonics, and band edge requirements.

62

Receiver modules
An RF Receiver module receives the modulated RF signal, and demodulates it. There are two types
of RF receiver modules: superheterodyne receivers and super-regenerative receivers. Superregenerative modules are usually low cost and low power designs using a series of amplifiers to
extract modulated data from a carrier wave. Super-regenerative modules are generally imprecise
as their frequency of operation varies considerably with temperature and power supply voltage.
Superheterodyne receivers have a performance advantage over super-regenerative; they offer
increased accuracy and stability over a large voltage and temperature range. This stability comes
from a fixed crystal design which in turn leads to a comparatively more expensive product.
Transceiver modules
An RF Transceiver module incorporates both a transmitter and receiver. The circuit is typically
designed for Half-duplex operation, although full duplex modules are available, typically at a
higher cost due to the added complexity.

63

APPLICATION

Vehicle monitoring

Remote control

Telemetry

Small-range wireless network

Wireless meter reading

Access control systems

Wireless home security systems

Area paging

Industrial data acquisition system

Radio tags reading

RF contactless smart cards

Wireless data terminals

Wireless fire protection systems

Biological signal acquisition

Hydrological and meteorological monitoring

Robot remote control

Wireless data transmissions

64

SOLDERING
Soldering is the process of joining two metallic conductors the joint where two metal conductors
are to be joined or fused is heated with a device called soldering iron and then as allow of tin and
lead called solder is applied which melts and converse the joint. The solder cools and solidifies
quickly to ensure is good and durable connection between the jointed metal converting the joint
solder also present oxidation.
SOLDERING & DESOLDERING TECHNIQUES:
There are basically two soldering techniques:

Manual soldering with iron.

Mass soldering.

The iron consist of an insulated handle connected via a metal shank to the bit the function of bit is
to Stare host & convey it to the component. To store and deliver molten solder 7 flux.To remove
surplus solder from joints.Soldering bit are made of copper because it has good heat capacity &
thermal conductivity. It may erode after long term use to avoid it coating of nickel or tin is used.

SOLDERING WITH IRON :


The surface to be soldered must be cleaned & fluxed. The soldering iron switched on & bellowed
to attain soldering temperature. The solder in form of wire is allied hear the component to be
soldered &b heated with iron. The surface to be soldered is filled, iron is removed & the joint is
cold without disturbing. Solder joint are supposed to Provide permanent low resistance path Make
a robust mechanical link between PCB & leads of components. Allow heat flow between
component, joining elements & PCB.Retain adequate strength with temperature variation.
The following precaution should be taken while soldering.

Use always an iron plated copper core tip for soldering iron.

Slightly for the tip with a cut file when it is cold.

Use a wet sponge to wipe out dirt from the tip before soldering instead of asking the iron.
65

Tighten the tip screw if necessary before iron is connected to power supply.

Clean component lead & copper pad before soldering.

Use proper tool for component handling instead of direct handling.

Apply solder between component leads, PCB pattern & tip of soldering iron.

Iron should be kept in contact with the joint s for 2-3 second s only instead of keeping for
very long or very small time.

Use optimum quantity of solder.

Use multistoried wire instead of single strands solvent like isopropyl alcohol.

Every time soldering is over, put a little clean solder on the tip.

AT89S52 Program
;RF ATTENDENCE
RS BIT P2.5
RW BIT P2.4
E BIT P2.3

LCD EQU P0

ORG 00H
AJMP START
ORG 30H
START:
MOV LCD,#00H
MOV A,#38H

;2*16 MATRIX

ACALL COMMAND
MOV A,#0CH

;DISPLAY ON CURSOR OFF

ACALL COMMAND
66

MOV A,#80H

;MOVE CURSOR TO FIRST LINE SECOND COLOUMN

ACALL COMMAND
MOV DPTR,#TABLE1

;DISPLAY ERP

ACALL DISPLAY

MOV A,#0C0H

;MOVE CURSOR TO FIRST LINE SECOND COLOUMN

ACALL COMMAND
MOV DPTR,#TABLE7

;DISPLAY ERP

ACALL DISPLAY
MAIN:
jnb p1.0,act1
jnb p1.1,act2
jnb p1.2,act3
jnb p1.3,act4
jnb p1.4,act5 ; CHECK ATTENDENCE
jnb p1.5,act6
jnb p1.6,act7
jnb p1.7,act8
ret

act1:
INC R0
cpl p2.0

ACALL READING5
SJMP MAIN
act2:
INC R1

cpl p2.1
ACALL READING5

67

SJMP MAIN
act3:
INC R2

cpl p2.2
ACALL READING5
SJMP MAIN
act4:
INC R3

cpl p2.6
ACALL READING5

SJMP MAIN

act5:
ACALL READING1
SJMP MAIN
act6:
ACALL READING2
SJMP MAIN
act7:
ACALL READING3
SJMP MAIN
act8:
ACALL READING4
SJMP MAIN

READING5:
ACALL LCDCLR
MOV A,#0C0H

;MOVE CURSOR TO FIRST LINE SECOND COLOUMN

68

ACALL COMMAND
MOV DPTR,#TABLE6

;DISPLAY ERP

ACALL DISPLAY
SJMP MAIN
READING1:
ACALL LCDCLR
MOV A,#0C0H
ACALL COMMAND
MOV DPTR,#TABLE2
ACALL DISPLAY
MOV A,#0CAH
ACALL COMMAND
MOV A,R0
ACALL HTD
ACALL OUT1
AJMP MAIN
READING2:
ACALL LCDCLR

MOV A,#0C0H
ACALL COMMAND
MOV DPTR,#TABLE3
ACALL DISPLAY
MOV A,#0CAH
ACALL COMMAND
MOV A,R1
ACALL HTD
ACALL OUT1
AJMP MAIN
READING3:

69

ACALL LCDCLR
MOV A,#0C0H
ACALL COMMAND
MOV DPTR,#TABLE4
ACALL DISPLAY
MOV A,#0CAH
ACALL COMMAND
MOV A,R2

ACALL HTD
ACALL OUT1
AJMP MAIN
READING4:

ACALL LCDCLR
MOV A,#0C0H
ACALL COMMAND
MOV DPTR,#TABLE5
ACALL DISPLAY
MOV A,#0CAH
ACALL COMMAND
MOV A,R3

ACALL HTD
ACALL OUT1
AJMP MAIN
BUZZE:
clr buzz
acall DELAY
ACALL DELAY
ACALL DELAY

70

ACALL DELAY
SETB BUZZ
RET
HTD:
;CONVERT HEX(BINARY) TO ASCII
MOV B,#10
DIV AB
MOV C1,B
MOV B,#10
DIV AB
MOV C2,B
MOV C3,A
RET
OUT1:
MOV A,C3
ORL A,#30H
ACALL WRITE
MOV A,C2
ORL A,#30H
ACALL WRITE
MOV A,C1
ORL A,#30H
ACALL WRITE
RET
LCDCLR:
MOV A,#01H

;CLEAR DISPLAY SCREEN

ACALL COMMAND
RET ; DISPLAY DATA ON LCD
DISPLAY:
CLR A
MOVC A,@A+DPTR

71

INC DPTR
ACALL WRITE
JMP DISPLAY
JZ NEXT
NEXT:
RET
WRITE:

MOV LCD,A
SETB RS
CLR RW
SETB E
acall delay1
CLR E
RET
COMMAND:

MOV LCD,A
CLR RS
CLR RW
SETB E
acall delay1
CLR E
RET

delay1:
MOV R6,#255
AGAIN1: MOV R7,#255
BACK1: DJNZ R7,BACK1
DJNZ R6,AGAIN1

72

TABLE1: DB 'RF ATTENDENCE',0


TABLE7: DB ' 2012 ',0
TABLE2: DB 'ROLL NO.1',0
TABLE3: DB 'ROLL NO.2',0
TABLE4: DB 'ROLL NO.3',0
TABLE5: DB 'ROLL NO.4',0
TABLE6: DB 'ATTEND.STORED',0
End

BIBILIOGRAPHY
1. HAND BOOK OF ELECTRONICS

A.K. MAINI.

2. HAND BOOK OF ELECTRONICS

GUPTA & KUMAR.

3. LET US C
4. SHYAM SERIES
5. DIGITAL SYSTEMS PRINCIPLES AND APPLICATION

YASHWANT KANITKAR.
TATA MC GRILL.
RONALD LTOCCI.

6. ELECTRONICS FOR YOU

(MARCH 1998).

7. DIGITAL DESIGN

MORIS MANO.

8. RELAYS AND ITS APPLICATION

SHARMA, MC.

9. MODERN ALL ABOUT MOTHERBOARD


10.POWER SUPPLY FOR ALL OCCASION

LOTHIA, M.
SHARMA, MC.

73