Introduction
This idea came in my mind because the atm is not in complete security. because
thieves activity may different role such as .
• Detach the camera.
• Break the atm.
• Pick up the atm.
• And other problem.
If any person touch the camera then system automatically sense
and display the message ,beep alerting with generate the call to
responsible person automatically .this call indicate the problem
only not a confirm signal.
If any person touch the atm then system automatically sense and
display the message ,weep alerting with generate the call to
responsible person automatically .this call indicate the problem or
a confirm signal. And automatically close the atm gate. this gate
cannot be open without authentication.
In this project we give idea of atm security by archaic technology. in this
project if any thieves activity occur in atm system automatically generate
the call and dial to responsible person in two case’.
1. Disturbance the camera.
2. Disturbance the atm.
And automatically lock the gate .when this gate open only one condition it
means when responsible use the smart card if card is valid the ask the
password if password is correct then the gate automatically open and
thieves will be catch.
PROCEDURE FOR MAKING PROJECT
Building project in the proper manner is really an art,
something which must be prectised and learned through trial and
error, it is not all that difficult. The main thing is to rem em ber t o
take each step slowly and carefull y according to the instructions
giving making since that everything at it should be before
proceeding further.
TOOLS: The electronics workbench is
an
actual
place
of
work
with
comfortably & conveniently & should be
supplied
tools
with
must
compliment
often
use
of
in
those
project
building. Probably the most important
device is a soldering tool. Other tool which should be at the
electronic work bench includes a pair of needle nose pliers,
diagonal wire cutter, a small knife, an assortment of screw driver,
nut driver, few nuts & bolts, electrical tape, plucker etc. Diagonal
wire cutter will be used to cut away any ex cess lead length from
copper side of P.C.B. 7 to cut section of the board after the circuit is
complete. The needle nose pliers are most often u sing to bend wire
leads & wrap them in order to form a strong mechanical connection.
MOUNTING & SOLDERING: Soldering
is process of joining together two
metallic parts. It is actually a process
of function in which an alloy, the
solder, with a comparatively low
melting point penetrates the surface
of the metal being joined & makes a
firm joint between them on cooling & solidifying.
RELAY
Relay
is
a
com mon,
sim ple
application
of
elect rom agnetism . It uses an elect romagnet made from an iron
rod wound wit h hundreds of fine copper wire. When elect ricit y
is applied to the wire, t he rod becom es m agnetic. A m ovable
contact arm above t he r od is t hen pulled toward the rod until it
closes a switch cont act. When t he elect ricity is removed, a
sm all spring pulls t he cont ract arm away from t he rod unt il it
closes a second swit ch cont act . By means of relay, a current
circuit can be broken or closed in one circuit as a result of a
current in anot her circuit.
Relays can have several poles and cont acts. The t ypes of
contact s could be norm ally open and norm ally closed. One
closure of t he relay can turn on t he sam e norm ally open
contact s; can turn off t he ot her norm ally closed cont acts.
Relay requires a current t hrough t heir coils, for which a
volt age is applied. This volt age f or a relay can be D.C. low
volt ages upt o 24V or could be 240V a.c.
RESISTANCE
Resistance is t he opposit ion of a mat erial t o t he current .
It is measured in Ohm s (Ω). All conductors represent a certain
amount of resist ance, since no conductor is 100% efficient . To
control the elect ron flow (current ) in a predict able m ann er, we
use
resistors.
Electronic
circuits
use
calibrat ed
lum ped
resist ance t o control the flow of current. Broadly speaking,
resist or can be divided into t wo groups viz. fix ed & adjust able
(variable) resist ors. In fix ed resist ors, the value is fix ed &
cannot be varied. In variable resist ors, t he resist ance value can
be varied by an adjuster knob. It can be divided int o (a) Carbon
composit ion (b) Wire wound (c) Special t ype. The most
comm on t ype of resist ors used in our project s is carbon t ype.
The resist ance value is norm ally indicat ed by colour bands.
Each resistance has four colours, one of t he band on eit her
side will be gold or silver, this is called fourt h band and
indicates t he t olerance, others t hree band will give the value of
resist ance (see t able). For ex am ple if a resist or has t he
following marking on it say red, violet , gold. Com paring t hese
coloured rings wit h t he colour code, it s value is 27000 ohms or
27 kilo ohms and its tolerance is ± 5%. Resist or com es in
various sizes (Power rat ing). The bigger, t he size, the more
power rat ing of 1/ 4 wat ts. The four colour rings on its body
t ells us t he value of resistor value as given below.
TRANSFORMER
PRINCIPLE OF THE TRANSFORMER:Two coils are wound over a Core such that t hey are
m agnet ically coupled. The t wo coils are known as t he primary
and secondary windings.
In a Transformer, an iron core is used. The coupling
between the coils is source of m aking a pat h for t he magnet ic
flux t o link bot h the coils. A core as in fig.2 is used and the
coils are wound on t he limbs of t he core. Because of high
permeability of iron, t he flux pat h for t he flux is only in t he
iron and hence t he flux links bot h windings. Hence t here is
very litt le ‘leakage flux ’ . This t erm leakage flux denot es t he
part of t he flux , which does not link bot h the coils, i.e., when
coupling is not perfect . In t he high frequency t ransformers,
ferrit e core is used. The transform ers may be st ep- up, st epdown, frequency mat ching, sound out put , am plifier driver etc.
The basic principles of all t he t ransf orm ers are sam e.
TRANSISTOR
The nam e is transist or derived from ‘transfer resist ors’
indicating a solid st at e Semiconduct or device. In addition to
conduct or and insulat ors, t here is a third class of material t hat
ex hibit s proportion of bot h. Under some condit ions, it acts as
an insulat or, and under ot her condit ions it’s a conductor. This
phenomenon is called Semi- conducting and allows a variable
control over elect ron flow. So, t he t ransistor is sem i conduct or
device used in elect ronics for amp lit ude. Transist or has three
t erminals, one is the collect or, one is the base and ot her is t he
emitt er, (each lead m ust be connect ed in t he circuit correctly
and only t hen t he t ransist or will funct ion). Elect rons are
emitt ed via one term inal and collect ed on anot her t erm inal,
while t he third t erm inal acts as a cont rol element . Each
t ransist or has a number marked on it s body. Every number has
it s own specificat ions.
There are m ainly t wo t ypes of t ransist or (i) NPN & (ii) PNP
NPN Transistors:
When a posit ive volt age is applied t o t he base, the
t ransist or begins t o conduct by allowing current to flow
t hrough t he collect or to em itt er circuit . The relatively sm all
current flowing t hrough the base circuit causes a m uch great er
current t o pass t hrough t he emit ter / collector circuit .
Th e
phenomenon is called current gain and it is m easure in bet a.
THE ADAPTING 3- TERMINAL VOLTAGE
REGULATORS FOR CONSTANT HIGH
VOLTAGE POWER SUPPLIES
One can get a constant high - voltage power supply using
inex pensive 3- terminal voltage regulators through some simple
techniques
described
below.
Depending
upon
the
curren t
requirement, a reasonable load regulation can be achieved. Line
regulation in all cases is equal to that of the voltage regulator used.
Though high voltage can be obtained with suitable voltage
boost circuitry using ICs like LM 723, some advantages of the
circuits presented below are: simplicity, low cost, and practically
reasonable regulation characteristics. For currents of the order of
1A or less, only one zener and some resistors and capacitors are
needed. For higher currents, one pass transistor su ch as ECP055 is
needed.
Before developing the final circuits, let us first understand the
3- terminal type constant voltage regulators. Let us see the
schematic in Fig. where 78XX is a 3 - terminal voltage regulator.
Schematic for obtaining low-voltage regulated output using 3-terminal voltage regulators.
Rectified and filtered unregulated voltage is applied at V IN and
a constant voltage appears between pins 2 and 2 of the voltage
CAPACITORS
It is an electronic component whose function is to accumulate
charges and then release it.
To understand the concept of capacitance, consider a pair of
metal plates which all are placed near to each other without
touching. If a battery is connected to t hese plates the positive pole to
one and the negative pole to the other, electrons from the battery
will be attracted from the plate connected to the positive terminal of
the battery. If the battery is then disconnected, one plate w ill be left
with an ex cess of electrons, the other with a shortage, and a
potential or voltage difference will ex ists between them. These plates
will be acting as capacitors. Capacitors are of two types: - (1) fixed
type like ceramic, polyester, electrolyt ic capacitors- these names refer
to the
DIODE
The simplest semiconductor device is made up of a sandwich
of P- type semiconducting material, with contacts provided to
connect the p- and n- type layers to an ex ternal circuit. This is a
junction Diode. If the positive terminal of the battery is co nnected
to the p- type material (cathode) and the negative terminal to the Ntype material (Anode), a large current will flow. This is called
forward current or forward biased.
If the connections are reversed, a very little current will flow.
This is because under this condition, the p - type material will accept
the electrons from the negative terminal of the battery and the Ntype mat erial will give up its free electrons to the battery, resulting
in the state of electrical equilibrium since the N- type material has
no more electrons. Thus there will be a small current to flow and
the diode is called Reverse biased.
Thus the Diode allows direct current to pass only in one
direction while blocking it in the other direction. Power diodes are
used in concerting AC into DC. In this, current will flow freely
during the first half cycle (forward biased) and practically not at all
during the other half cycle (reverse biased). This makes the diode
an effective rectifier, which convert ac into pulsating dc. Signal
diodes are used in radio circuits for detection. Zener diodes are
used in the circuit to control the voltage.
Rf id based smart door control
The many uses for RFID technology include:
•
Smart labels and security labels
Product and inventory management
•
RFID chips in car keys for security
•
Theft control
•
Placement on pharmaceuticals to prevent counterfeited drugs from
entering the legal supply chain
•
Increased efficiency in admissions into entertainment or sporting
events
•
Increased efficiency in toll road payments
•
Monitoring the whereabouts of luggage, library books, livestock, etc.
•
This project aimed to develop a wireless system to detect and
allow only the authorized persons. The system was based on
Radio Frequency Identification (RFID) technology and consists of
a passive RFID tag. The passive micro transponder tag collects
power from the 125 KHz magnetic field generated by the base
station, gathers information about the Tag ID and sends this
information to the base station. The base station receives,
decodes and checks the information available in its Database and
Manchester code was used to send those information. The system
performed as desired with a 10cm diameter antenna attached to
the transponder. The Base Station is built by using the Popular
8051 family Microcontroller. It gets the tag ID and if the tag ID is
stored in its memory then the microcontroller will allow the
person
inside.
RFID Reader Module, are also called as interrogators. They
convert radio waves returned from the RFID tag into a form that
can be passed on to Controllers, which can make use of it. RFID
tags and readers have to be tuned to the same frequency in order
to communicate. RFID systems use many different frequencies,
but the most common and widely used Reader frequency is 125
KHz.
If the
code is match then we authorized or unauthorized
the
card with predefined password. If the person is authorized then
door is open and if the person is un-authorised
then door is
close.
Administrator authorize or un-authorised
the card as per their
rules.
We use this concept in
centre
paid jim, paid class room
or any paid
Block diagram
Infra red sensor:
infrared radiation is the portion of electromagnetic spectrum having wavelengths longer
than visible light wavelengths, but smaller than microwaves, i.e., the region
roughly from 0.75µm to 1000
µm is the infrared region. Infrared waves are invisible to human eyes. The wavelength
region of 0.75µm to 3 µm is called near infrared, the region from 3 µm to 6 µm is called
mid infrared and the region higher than 6 µm is called far infrared. (The demarcations
are not rigid; regions are defined differently by many).
There are different types of IR sensors
working in various regions of the IR spectrum but the physics behind "IR sensors" is
governed by three laws:
1.
Planck’s radiation law:
Every object at a temperature T not equal to 0 K emits radiation. Infrared radiant energy
is determined by the temperature and surface condition of an object. Human eyes
cannot detect differences in infrared energy because they are primarily sensitive to
visible light energy from 400 to 700 nm. Our eyes are not sensitive to the infrared
energy.
2.
Stephan Boltzmann Law
The total energy emitted at all wavelengths by a black body is related to the absolute
temperature as
3.
Wein’s Displacement Law
Wein’s Law tells that objects of different temperature emit spectra that peak at different
wavelengths. It provides the wavelength for maximum spectral radiant emittance for a
given temperature.
The relationship between the true temperature of the black body and its peak spectral
exitance or dominant wavelength is described by this law
The world is not full of black bodies; rather it
comprises of selectively radiating bodies like rocks, water, etc. and the relationship
between the two is given by emissivity (E).
Emissivity
depends
on
object color, surface roughness, moisture content, degree of compaction, field of view,
viewing angle & wavelength.
ELEMENTS OF INFRARED DETECTION SYSTEM
A typical system for detecting infrared radiation is given in the following block diagram :
1.
Infrared Source
All objects above 0 K radiate infrared energy and hence are infrared sources. Infrared
sources also include blackbody radiators, tungsten lamps, silicon carbide, and various
others. For active IR sensors, infrared Lasers and LEDs of specific IR wavelengths are
used as IR sources.
2.
Transmission Medium
Three main types of transmission medium used for Infrared transmission are vacuum,
the atmosphere, and optical fibers.
The transmission of IR – radiation is affected by presence of CO2, water vapour and
other elements in the atmosphere. Due to absorption by molecules of water carbon
dioxide, ozone, etc. the atmosphere highly attenuates most IR wavelengths leaving
some important IR windows in the electromagnetic spectrum; these are primarily utilized
by thermal imaging/ remote sensing applications.
•
Medium wave IR (MWIR:3-5 µm)
•
Long wave IR (LWIR:8-14 µm)
Choice of IR band or a specific wavelength
is dictated by the technical requirements of a specific application.
3.
Optical Components.
Often optical components are required to converge or focus infrared radiations, to limit
spectral response, etc. To converge/focus radiations, optical lenses made of quartz,
CaF2, Ge and Si, polyethylene Fresnel lenses, and mirrors made of Al, Au or a similar
material are used. For limiting spectral responses, bandpass filters are used. Choppers
are used to pass/ interrupt the IR beams.
4.
Infrared detectors.
Various types of detectors are used in IR sensors. Important specifications of detectors
are
•
Photosensitivity or Responsivity
Responsivity is the Output Voltage/Current per watt of incident energy. Higher the
better.
•
Noise Equivalent Power (NEP)
NEP represents detection ability of a detector and is the amount of incident light equal
to intrinsic noise level of a detector.
•
Detectivity(D*: D-star)
D* is the photosensitivity per unit area of a detector. It is a measure of S/N ratio of a
detector. D* is inversely proportional to NEP. Larger D* indicates better sensing
element.
In addition, wavelength region or temperature to be measured, response time, cooling
mechanism, active area, no of elements, package, linearity, stability, temperature
characteristics, etc. are important parameters which need attention while selecting IR
detectors.
5.
Signal Processing
Since detector outputs are typically very small, preamplifiers with associated circuitry
are used to further process the received signals.
Three relay based circuit for the door open logic. Here in this
project we use three relay for any type of door open. IN this
project we use two relay for door open and one relay for
controlling the two relay. As the signal from controller is
connected to opto-coupler . Optocoupler connect first relay via
transistor and, other two relay work as a H bridge logic. Switch
connected to first relay is of the door open and close switch
components used:
Step down transformer 220 volt ac to 9-0-9 ac
Diode IN 4007 (2)
Capacitor 1000mfd (2), 27pf(2), 10mfd(1)
IC 7805 (1)
89S52 ( 8051 CONTROLLER)
Rf Reader ( 125kHtz ) serial interface
LCD 2by 16 ( alphanumeric lcd)
Push to on switch (9)
Resistor 470 ohm (1), 10k (1), 4k7(1).
Variable resistor 4.7k oh (1)
l.e.d (1)
cd Loader for door open (1)
crystal 12 Mhtz (1)
P.C.B
Rf CARD
CIRCUIT WORKING
in this project we use one 5 volt regulated power supply to convert the 220
volt ac in to 5 volt dc with the help of the 5 volt regulator circuit. First OF all
we step down the 220 volt ac into 6 volt ac with the help of step down
transformer. Step down transformer step down the voltage from 220 volt
ac to 9 volt ac. This ac is further converted into the dc voltage with the help
of the full wave rectifier circuit
Output of the diode is pulsating dc . so to convert the pulsating dc into
smooth dc we use electrolytic capacitor. Electrolytic capacitor convert the
pulsating dc into smooth dc. This DC is further regulated by the ic 7805
regulator. IC 7805 regulator provide a regulated 5 volt dc to the
microcontroller circuit and lcd circuit.
Pin no 40 of the controller is connected to the positive supply. Pin no 20 is
connected to the ground. Pin no 9 is connected to external resistor
capacitor to provide a automatic reset option when power is on.
Reset Circuitry:
Pin no 9 of the controller is connected to the reset circuit. On the circuit we
connect one resistor and capacitor circuit to provide a reset option when
power is on
As soon as you give the power supply the 8051 doesn’t start. You need to restart for the
microcontroller to start. Restarting the microcontroller is nothing but giving a Logic 1 to
the reset pin at least for the 2 clock pulses. So it is good to go for a small circuit which
can provide the 2 clock pulses as soon as the microcontroller is powered.
This is not a big circuit we are just using a capacitor to charge the
microcontroller and again discharging via resistor.
Crystals
Pin no 18 and 19 is connected to external crystal oscillator to provide a
clock to the circuit.
Crystals provide the synchronization of the internal function and to the peripherals.
Whenever ever we are using crystals we need to put the capacitor behind it to make it
free from noises. It is good to go for a 33pf capacitor.
We can also use resonators instead of costly crystal which are low cost and
external capacitor can be avoided.
But the frequency of the resonators varies a lot. And it is strictly not advised
when used for communications projects.
How is this time then calculated?
The speed with which a microcontroller executes instructions is determined
by what is known as the crystal speed. A crystal is a component connected
externally to the microcontroller. The crystal has different values, and some
of the used values are 6MHZ, 10MHZ, and 11.059 MHz etc.
Thus a 10MHZ crystal would pulse at the rate of 10,000,000 times per
second.
The time is calculated using the formula
No of cycles per second = Crystal frequency in HZ / 12.
For a 10MHZ crystal the number of cycles would be,
10,000,000/12=833333.33333 cycles.
This means that in one second, the microcontroller would execute
833333.33333 cycles.
Pin no 1 to pin no 8 is PORT 1 and Pin no 10 to 17 is PORT 3. Pin no 18
and 19 of the ic is connected to the external crystal to provide a external
clock to run the internal CPU of controller . Pin no 20 is ground pin. Pin no
21 to 28 is PORT 2 pins. Pin no 29,30,31 is not use in this project. We use
these pin when we require a extra memory for the project. If we internal
memory of the 89s51 ( which is 4k rom) then we connect pin no 31 to the
positive supply.
RF reader is connected to the rx pin of the controller. AS we place the card
on the reader then reader sense the signal and immediate provide a signal
to the controller in serial mode. Data receive by the Controller inside and
we save that data in variables. Now we immediate display this data on the
lcd screen. Data from the controller is connected to the pin no 1 of the
microcontroller directly. As the data is received on the controller , controller
get the data serially and save this data into variables. Convert the variable
data
into
ascii
code
and
display the same code on the
lcd screen. Here we use 2 by
16 lcd. To display the ascii
code.
Now when data is to be display on the lcd then first of all we register this
data for authorized and for unauthorized option. As we enter the 3 digit
password then circuit is activate. When password is okay then we press
authorized or unauthorized button. If we press authorized button then door
is open and when we press un-authorized button then door is closed.
Now microcontroller save this data in the ram memory. As we again show
the RF card to the door then now controller get the data and compare with
the ram content. If the data is to be match then door is open now and shut
off automatically after some tie
RFID Tag Categories | RFID Construction | Applications | Privacy
Issues | Chipless RFID Technology
RFID, which is an acronym for Radio Frequency Identification, is not a new
technology. It was first used in the late 1960's, but it has only become more
widespread with advances in technology.
RFID Systems consist of a transponder, also known as a tag, which is
basically a microchip connected to an antenna. The tag is mounted to an
item, such as a pallet of goods in a warehouse, and a device called a
reader communicates with the tag via radio waves. Depending on the type
of tag that is used, the reader can receive detailed information or it can
receive data as simple as an identification number.
RFID is similar to barcode systems in which data, such as a price, is
accessed when the barcode is read. The main difference is that the
barcode must come in direct contact to an optical scanner/reader and the
RFID tag can transmit to the reader via radio waves and does not have to
be in direct contact. An RFID reader can receive data from as many as
1,000 tags per second.
The radio signals can go through many non-metallic substances such as
rain, fog, snows, dirt and grime, painted surfaces, etc. This gives RFID tags
a distinct advantage over optically read items, such as barcodes, which
would be useless under similar conditions.
The many uses for RFID technology include:
•
Smart labels and security labels
Product and inventory management
•
RFID chips in car keys for security
•
Theft control
•
Placement on pharmaceuticals to prevent counterfeited drugs from
entering the legal supply chain
•
Increased efficiency in admissions into entertainment or sporting
events
•
Increased efficiency in toll road payments
•
Monitoring the whereabouts of luggage, library books, livestock, etc.
•
It is predicted that RFID use will continue to increase. It is unlikely to ever
be as cost-effective as barcoding, but it will become dominant in areas
where barcoding and other optically read technologies are not effective.
RFID Tag Categories
The basic types of RFID tags can be classified as read/write and read only.
The data stored on read/write tags can be edited, added to, or completely
rewritten, but only if the tag is within the range of the reader. The data
stored on a read only tag can be read, but cannot be edited in any way.
Read/write tags are much more expensive than read only tags, so they are
not used for tracking most commodity items.
RFID tags are further categorized as:
•
•
•
Active tags, which contain a battery that powers the microchip and
allows it to transmit a signal to the reader.
Semi-active (or semi-passive) tags, which contain a battery to run the
circuitry of the chip, but must draw power from the magnetic field
created by the reader in order to communicate with the reader.
Passive tags, which rely solely on the magnetic field created by the
radio waves sent out by the reader to create a current that can be
received by the antenna within the passive tag.
RFID Construction
RFID Tag Components
RFID tags consist of a microchip connected to an antenna, which is
constructed of a small coil of wires. The assembly is usually covered with a
protective layer (such as a laminated card), which is determined by the type
of application. The RFID tag can be a passive tag or an active tag. The
RFID tag is also known as an inlay.
Components of passive RFID system:
•
•
An antenna is attached to a microchip.
The antenna allows the chip to transmit information to a reader,
which also has an antenna.
•
The reader is the device that actually sends out the radio waves
to create a magnetic field. A passive RFID tag draws its power
from this magnetic field, which powers the circuits in the
microchip allowing it to transmit data back to the reader.
•
Reader transmits to a computer system.
•
The computer passes data onto a network.
•
Software determines how the data received should be used.
Microchip
The most expensive read/write, active RFID transponders may have
microchips with a memory capacity of up to one megabyte (1,000,000
characters). Most tags are inexpensive, passive transponders that can
store only 32 to 128 bits (characters) of information or less, so an
identification number is basically the only data that the read-only tag will
contain. When the number is read, detailed information stored in a
database in a computer can be accessed. This is similar to a barcode
system in which data, such as a price, is accessed when the barcode is
read. The main difference is that the barcode must come in direct contact
to an optical scanner/reader and the RFID tag can transmit to the reader
via radio waves and does not have to be in direct contact.
Antenna
The antenna allows the chip to receive and relay information, such as an ID
number of an individual product. Some antennas are constructed of metal
and are etched or stamped from metal, such as copper. Other types of
antennas are printed. Advances in technology are allowing printed
antennas to achieve the functionality of traditional materials and printed
antennas are less expensive. One of the most popular methods of printing
antennae is with the use of silver conductive inks printed on plastics
substrates or paper. Testing of RFID antennae is usually performed with
ohmmeters, milliohm meters, RF network analyzers, impedance-measuring
equipment, and others.
RFID Tag Shapes and Sizes
RFID tags can be manufactured in several different shapes and sizes
depending on the type of application in which they will be used.
•
Some are the size of a pencil lead or are less than a half-inch in
•
length and can be inserted under the skin of animals and livestock.
Screw-shaped tags are used to identify specific trees.
•
Rectangular RFID tags found in some products are used as an antitheft device.
•
Large, heavy duty tags that are several inches in length, width, and
depth are used to track large containers or large vehicles such as
trucks or rail cars.
Radio Frequencies
RFID tags operate under different radio frequencies, depending on the
application. The FCC of the US government determines the limits on power
output of RFID systems as well as the different radio frequencies that can
be used. Low, high, and ultra-high (UHF) frequencies are used with RFID
transponders.
•
•
Low and high frequency tags are less expensive than UHF and are
best used for merchandise tracking, animal and livestock
identification, and security access.
Tags with UHF frequencies use more power than low and high
frequency tags, but they have a greater range and the data transfer
rate is faster. They are best suited for applications in which the tag
and the reader have a more direct path with one another. Rail car
tracking and automated toll booths are some of the uses.
The communication range between the RFID tag and the reader depends
on the frequency, the antenna size of the tag, the antenna size of the
reader, and the output power.
•
•
Low and high frequency devices have communication ranges of a few
inches to several feet, depending on the application.
Ultra-high (UHF) may have ranges of 25 feet or more.
The radio signals can go through many substances such as rain, fog,
snows, dirt and grime, painted surfaces, etc. This gives RFID tags a distinct
advantage over optically read items, such as barcodes, which would be
useless under similar conditions. An RFID reader can receive data from as
many as 1,000 tags per second.
Quality Control
Quality control is a necessity because groups of manufactured inlays may
have experienced some damage before they reach the printer or converter.
The chips in the inlays can also be damaged during the printing or
converting process, which renders the RFID tag useless. Special
substrates can be used to limit the damage to the chips. Quality control
after printing or converting is also important to ensure that none of the
chips were damaged and will all be functional.
When RFID antennae are manufactured, they are usually tested with
ohmmeters, milliohm meters, RF network analyzers, and impedancemeasuring equipment. It is also important to remember that RFIDs are
electronic devices and therefore should not be exposed to or stored near
areas containing large amounts of electromagnetic or static energy.
Applications
The three most common uses for RFID tags are:
1. Tracking items in production lines
2. Tracking items in supply chains
3. Enhancing security measures
In other industrial uses, tags attached to items for tracking during assembly
or manufacture must be able to withstand heat, cold, etching processes,
cleaning and degreasing procedures, moisture, dirt, and many other types
of conditions and environments that would not be suitable for optically or
magnetically read devices.
Printing
With most types of printed applications, such as labels, the user is unaware
of the existence of the chip and antenna because of the different methods
of concealing them on the document. Some printers (such as label printers)
purchase inlays (containing the RFID) that are already manufactured and
then incorporate them into their printed products.
Label Printing
Label printing is one of the fastest growing segments of the printing
industry using RFID technology. Smart labels and electronic surveillance
labels are being used for applications in which simple, optically read
barcoding may not be suitable.
Smart Labels
Smart labels contain RFID transponders to automatically capture data. The
standard construction of a smart label consists of a pressure sensitive
facestock, an inlay, which contains the radio frequency identification
transponder, and a liner. The inlay is laminated between the facestock and
the liner. The transponder contains an antenna and microchip.
The data from the smart label is accessed when the transponder passes by
the reader. Radio wave lengths are picked up from the antenna and the
data on the microchip is transferred to the reader and then passed on to a
computer or printer. As the product moves from one stage to the next, its
movements can be monitored and data can be updated when necessary.
The smart label can identify, track in real-time, and authenticate a product.
Smart labels are used on all types of applications including supply chain
management, production control, work-in-process, baggage identification
and tracking, express delivery services, reusable container tracking, and
security systems.
Equipment is available that is able to encode a separate RFID inlay and
then bond it to the substrate after the label has been printed. A variety of
label substrates can be used. This process eliminates the need for inserting
transponders into blank label stock before the label stock is printed. Since
the printing process can damage stock containing transponders, the
process eliminates this problem by allowing the printing to happen first. The
system creates a printing system that is on-demand. There is no need for
special papers because the equipment can print on almost any label stock.
Other equipment is able to encode data on very thin UHF RFID
transponders that are inserted into smart labels. The equipment
immediately verifies the proper encoding. The equipment can then print
text, graphics, or barcodes on the smart label to complete the application.
The smart labels can be used for a number of warehousing, inventory, and
supply chain tracking applications.
There are also compact desktop printers specifically design for RFID
printing. The printers can read, write, and print labels that have an
embedded RFID transponder.
The industry acceptance of smart labels has been slow. The RFID
technology can improve performance and efficiency but is expensive to
startup. As more companies commit to the use of this new technology it will
become more widely accepted and many will benefit from its capabilities.
Electronic Article Surveillance (EAS) Labels
EAS labels are used as anti-theft devices. The label is used with EAS
monitoring equipment to detect if an item is being removed without
authorization. The EAS systems are used in retail stores, data centers, and
libraries. When applied to products, the EAS label is capable of activating
an alarm as it passes through an electronic surveillance detector, such as
those found in retail store exits. When the product is purchased, the label is
made inactive by the use of a deactivation device at the checkout station.
Once the label is deactivated it is referred to as a "dead label". Labels that
have not been deactivated are referred to as "live labels".
RFID is only one of the technologies used for EAS labels. Other common
types are AM (Acousto Magnetic) and EM (Electro Magnetic). Each of the
EAS systems has its own unique detection equipment that must be used to
allow the system to work properly.
Because of the anti-theft protection they provide, the EAS labels and EAS
systems allow more freedom for retail stores to display items that would
usually be locked in display cases. This allows the consumer to examine
the product more closely before purchasing.
Comparisons with Barcoding
RFID and barcode technology are similar in concept, but the two
technologies have different methods for reading data. RFID reads data via
radio waves and does not need a direct line of sight between the reader
and the tag. Barcodes are read optically and do require a direct line of sight
between the reader and the barcode.
Advantages of RFID systems over barcodes:
•
•
It is not necessary to have a line of sight between the
RFID tag and the reader as there is with a barcode and
scanner.
Information can be rewritten to the tag without having to
see the tag. This is true even if the tag is mixed into other
items that have been tagged.
•
Nearly 100% of RFID tags are readable, unlike items that
contain a printed barcode, which can become damaged
with improper handling.
•
The potential problems associated with substandard print
quality of barcodes, which in turn leads to scanning and
reading problems, are eliminated.
Other points to consider:
•
Barcodes are universally accepted because they are very
inexpensive and there are established standards for their
use. RFID technology is more expensive and has fewer
universal standards in the way they are used.
•
Even if RFID technology becomes as widespread as
barcoding, it will not totally replace the universally
accepted barcode technology.
Other Print/Security Applications
Besides the various types of RFID labels that are being printed for product
tracking and security, plastic cards and badges embedded with RFID
transponders are being produced. Data from identification cards embedded
with RFID tags can be read as people pass through a doorway. RFID tags
embedded in security badges offer an alternative method for controlling
access to sensitive information or limiting access to specific areas.
Merchandise/Inventory Tracking
When used with product and inventory control, a computer keeps track of
the data received from the transponders/tags through the reader and can
trigger reorders based on the adjusted inventory levels. Antennas can be
built into warehouse doorframes in order to receive data as merchandise,
cartons, and pallets of goods containing an RFID tag pass, through the
doorway.
RFID costs may not become low enough for the tags to be used on all
types of products and services. It may not be cost effective to include the
tags with every item if the items are inexpensive commodity items, but the
tags can be very useful to track full pallets of commodities for inventory
control.
Transportation
RFID tags can be used for a number of applications in the transportation
industry for monitoring and tracking of vehicles and products.
Railroads
RFID systems can be configured for rail car identification:
•
The tags are installed underneath the rail cars.
The antennae are mounted between or near the tracks.
•
The readers are usually located in a building no more than 100
•
feet away.
Trucking
Commercial trucking facilities also use RFID systems to monitor truck
movements in and out of a main terminal.
Automotive
RFID systems are very useful in the automobile manufacturing industry in
tracking individual vehicles through the assembly process. RFID systems
are also being installed in toll booths to monitor the traffic.
Airports
Most airports track passenger baggage with barcoded labels or tags, but
they are often damaged do to rough handling of the baggage. Barcoded
tags that have been damaged because of rough baggage handling, may
account for 10% of the total volume. All of these bags must be accounted
for manually, which can be a time consuming process. RFID systems can
help to eliminate the problems that occur with unreadable barcodes.
When used for tracking bags at an airport, RFID tags contain a unique
number assigned to the bag. Anyone with access to a reader could see the
number, but any personal information could not be viewed because it is
stored in a database and is not stored on the tag.
Privacy Issues
Many people mistakenly believe that RFID is similar to GPS (Global
Positioning System) and can be used for detailed tracking, but RFID has a
range of only a few feet so this isn't possible. Another misconception that
people have is that the movement of products with RFID tags can be
tracked even after the product is purchased. Most active RFID tags have a
read range of about 25 feet, which means the RFID is basically useless
outside of the retail store or business.
Security measures and safeguards used to protect consumer privacy when
using RFID systems:
•
The risk of spying or intercepting data that is transmitted via radio
•
waves is reduced with the use of data encryption and over the air
protocols.
The protocols require both the reader and the eavesdropper to be
within range of the tag.
•
The reader changes radio frequencies rapidly and at random, so it is
difficult for a potential eavesdropper to follow the reader.
•
Although it is possible for tags to be counterfeited, it is not very
practical because of built-in safeguards, such as the ability of the
RFID readers to verify authenticity of the tags.
Chipless RFID Technology
Systems are now available that provide RFID technology for printed
documents without the need for a microchip. Some of the systems involve
the use of aluminum fibers, which are embedded into paper or packaging
materials. The fibers reflect a signal, which are interpreted as data in a
computer.
Another chipless system involves the use of materials made up of very
small chemical particles that possess varying degrees of magnetism. The
chemical particles become active when exposed to the electromagnetic
waves from a reader. Each of the chemicals emits a unique signal that is
received by the reader, which interprets the signal as a binary number. The
system uses as many as 70 different chemicals, so there are 70 different
signals. Each chemical has a specific position in the 70-digit number, which
means that a unique binary number can be assigned to a document based
on the mixture of chemicals that are used.
The small particles can be embedded in paper or they can be printed onto
paper or almost any type of substrate. Printed barcodes can be created,
which can be scanned from up to 10 feet away without the need for the
barcode to be in line of sight of the reader. With slight modifications, this
technology can be used with existing barcode systems, which helps to hold
down the cost. Major upgrades of equipment are not necessary. The only
areas where the system does not work very well are in areas containing
large quantities of water or metal objects. Water absorbs RF signals and
large quantities of metal reflect the signals.
Other security measures that can be used in conjunction with the system
are:
•
•
Photocopiers can be fitted with readers to prevent unauthorized
copying.
Some applications could require that a document be photocopied
onto the same type of paper.
•
Any institution wishing to protect documents could install readers at
all exit points in the building, which would detect if any unauthorized
persons were trying to leave the building with an original or copied
document.
•
The system can also be used for counterfeit prevention and for
tracking manufactured products.
POSitive
Technology
EAS
Overview
What is EAS?
Electronic Article Surveillance is a system that protects
merchandise from theft. An EAS system has three components: 1)
Labels and hard tags—electronic sensors that are attached to
merchandise; 2) Deactivators and detachers—used at the point of
sale to electronically deactivate labels and detach reusable hard tags
as items are purchased; and 3) Detectors that create a surveillance
zone at exits or checkout aisles.
The EAS process begins by attaching labels or hard tags to
merchandise. When an item is purchased, the label is deactivated or
the hard tag is removed. However, if merchandise with an active
label or hard tag is carried past the detector, an alarm sounds.
Over 800,000 EAS systems are installed worldwide, primarily in the
retail market. This includes Apparel, Drug, Discount, Home Centers,
Hypermarkets, Food, Entertainment, and Specialty stores.
How EAS Systems Work
EAS systems operate from a simple principle regardless of the
manufacturer or the specific type of technology used: A transmitter
sends a signal at defined frequencies to a receiver. This creates a
surveillance area, usually at a checkout aisle or an exit in the case
of retail stores. Upon entering the area, a tag or label with special
characteristics creates a disturbance, which is detected by the
receiver. The exact means by which the tag or label disrupts the
signal is a distinctive part of different EAS systems. For example,
tags or labels may alter the signal by using a simple semi-conductor
junction (the basic building block of an integrated circuit), a tuned
circuit composed of an inductor and capacitor, soft magnetic strips
or wires, or vibrating resonators.
By design, the disturbed signal created by the tag and detected by
the receiver is distinctive and not likely to be created by natural
circumstances. The tag is the key element, for it must create a
unique signal to avoid false alarms. The disturbance in the electronic
environment caused by a tag or label creates an alarm condition
that usually indicate someone is shoplifting or removing a protected
item from the area.
The nature of the technology dictates how wide the exit/entrance
aisle may be. Systems are available that cover from a narrow aisle
up to a wide mall store opening. Similarly, the type of technology
affects the ease of shielding (blocking or detuning the signal), the
visibility and size of the tag, the rate of false alarms, the percentage
of detection rate (pick rate), and cost.
The physics of a particular EAS tag and resultant EAS technology
determines which frequency range is used to create the surveillance
area. EAS systems range from very low frequencies through the
radio frequency range. Similarly, these different frequencies play a
key role in establishing the features that affect operation.
How Swept-RF Works
Like other EAS technologies, swept-rf uses a transmitter to create a
surveillance area where tags and labels are detected. The
transmitter sends a signal that varies between 7.4 and 8.8 MHz
(millions of cycles per second), which is why it is called swept; it
sweeps over a range of frequencies.
The transmitter signal energizes the swept-rf tag or label, which is
composed of a circuit containing a capacitor and an inductor or coil,
both of which store electrical energy. When connected together in a
loop, the components can pass energy back and forth or "resonate."
The frequency at which the circuit resonates is controlled by
matching the storage capacity of the coil and capacitor. The tag
responds by emitting a signal that is detected by a receiver.
In addition to the small tag signal, the receiver also responds to the
much larger transmitter signal. By detecting a phase difference
between these two signals, and other properties of the tag signal,
the receiver recognizes the presence of a tag and generates an
alarm.
RF-ID Technology Overview
The core of any RF-ID system is the 'Tag' or 'Transponder' which can be attached to or
embedded within objects.
A RF-ID reader sends out a radio frequency wave to the 'Tag' and the 'Tag' broadcasts back
its stored data to the reader. The system works basically as two seperate antennas, one on
the 'Tag' and the other on the reader.
The data collected from the 'Tag'
can either be sent directly to a host computer through standard interfaces, or it can be
stored in a portable reader and later uploaded to the computer for data processing.
The automatic reading and direct use of the 'Tag' data is often called 'automatic data
capture' and with a RF-ID tag system, which works just as effectively in environments with
excessive dirt, dust, moisture and poor visability, you can be assured that it overcomes the
limitations of other automatic identification approaches.
How the Low Frequency Tag system works
When the transponder, which is battery free, is to be read, the reader sends out a 134.2KHz
power pulse to the antenna lasting approximately 50ms. The magnetic field generated is
'collected' by the antenna in the transponder that is tuned to the same frequency. This
received AC energy is rectified and stored on a small capacitor within the transponder.
When the power pulse has finished the transponder immediately transmits back its data,
using the energy stored within its capacitor as its power source.
In total 128 bits are transmitted (including error detection information) over a period of
20ms. This data is picked up by the receiving antenna and decoded by the reader unit. Once
all the data has been transmitted the storage capacitor is discharged resetting the
transponder to make it ready for the next read cycle. The period between transmission
pulses is known as the 'sync time' and lasts between 20ms and 50ms depending on the
system setup.
The transmission
technique used between the transponder and the reader is Frequency Shift Keying (FSK)
with transmissions between 134.2kHz and 124.2kHz. This approach has comparatively good
resistance to noise while also being very cost effective to implement.
System Performance
Reading Distance - one of the key benefits of the TIRIS system is its superior reading range
with low power consumption. The actual reading distance that can be acheived depends on
many factors, transponder type, electromagnetic noise, transponder orientation, antenna
type, and government regulations. In general a standard 32mm glass capsule can be read
with a stationary reader and a gate antenna from a distance of upto 1 meter Larger
transponders can acheive ranges upto 2 meters with handheld readers offering lower ranges
upto 250mm.
Data Accuracy The TIRIS system uses a 16-bit Cyclic Redundancy Check algorithim (CRCCCITT) which ensures that only 'valid' data is sent from the reader to its associated
controller. To date there have been no cases of an incorrect identification number being
read from a transponder.
Antenna Selection Of the two standard antenna types (ferrite rod and gate) the larger gate
antennas give the best reading range. Although in some environments an overall better
performance can be acheived with smaller antennas.
Each antenna has its own specific 'readout pattern' i.e. the electro magnetic field emanating
from the transponder during its reply stage. The shape and size of this pattern depends on
the specific readout antenna selected and a country's government regulations that define
the amount of electromagnetic field strength that can be generated. Electromagnetic noise
in the environment can also affect readout ranges.
Transponder Orientation The orientation of the transponder with respect to the antenna also
impacts the reading range. For maximum range the orientation of the antenna with respect
89s52 micro controller
The 8051
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.
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
Atmel’s 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.
Intel 8051
Intel 8051 is CISC architecture which is easy to program in assembly language and also has a
good support for High level languages.
The memory of the microcontroller can be extended up to 64k.
This microcontroller is one of the easiest microcontrollers to learn.
The 8051 microcontroller is in the field for more than 20 years. There are lots of books and
study materials are readily available for 8051.
Derivatives
The best thing done by Intel is to give the designs of the 8051 microcontroller to everyone. So it
is not the fact that Intel is the only manufacture for the 8051 there more than 20 manufactures,
with each of minimum 20 models. Literally there are hundreds of models of 8051
microcontroller available in market to choose. Some of the major manufactures of 8051 are
Atmel
Philips
Philips
The Philips‘s 8051 derivatives has more number of features than in any microcontroller.
The costs of the Philips microcontrollers are higher than the Atmel’s which makes us to choose
Atmel more often than Philips
Dallas
Dallas has made many revolutions in the semiconductor market. Dallas’s 8051 derivative
is the fastest one in the market. It works 3 times as fast as a 8051 can process. But we are
unable to get more in India.
Atmel
These people were the one to master the flash devices. They are the cheapest
microcontroller available in the market. Atmel’s even introduced a 20pin variant of 8051 named
2051. The Atmel’s 8051 derivatives can be got in India less than 70 rupees. There are lots of
cheap programmers available in India for Atmel. So it is always good for students to stick with
8051 when you learn a new microcontroller.
]
Architecture
Architecture is must to learn because before learning new machine it is necessary to learn the
capabilities of the machine. This is some thing like before learning about the car you cannot
become a good driver. The architecture of the 8051 is given below.
The 8051 doesn’t have any special feature than other microcontroller. The only feature is that it
is easy to learn. Architecture makes us to know about the hardware features of the
microcontroller. The features of the 8051 are
4K Bytes of Flash Memory
128 x 8-Bit Internal RAM
Fully Static Operation: 1 MHz to 24 MHz
32 Programmable I/O Lines
Two 16-Bit Timer/Counters
Six Interrupt Sources (5 Vectored)
Programmable Serial Channel
Low Power Idle and Power Down Modes
The 8051 has a 8-Bit CPU that means it is able to process 8 bit of data at a time. 8051 has 235
instructions. Some of the important registers and their functions are
Let’s now move on to a practical example. We shall work on a simple
practical application and using the example as a base, shall explore the
various features of the 8051 microcontroller.
Consider an electric circuit as follows,
The positive side (+ve) of the battery is connected to one side of a switch.
The other side of the switch is connected to a bulb or LED (Light Emitting
Diode). The bulb is then connected to a resistor, and the other end of the
resistor is connected to the negative (-ve) side of the battery.
When the switch is closed or ‘switched on’ the bulb glows. When the switch
is open or ‘switched off’ the bulb goes off
If you are instructed to put the switch on and off every 30 seconds, how
would you do it? Obviously you would keep looking at your watch and
every time the second hand crosses 30 seconds you would keep turning
the switch on and off.
Imagine if you had to do this action consistently for a full day. Do you think
you would be able to do it? Now if you had to do this for a month, a year??
No way, you would say!
The next step would be, then to make it automatic. This is where we use
the Microcontroller.
But if the action has to take place every 30 seconds, how will the
microcontroller keep track of time?
Execution time
Look at the following instruction,
clr p1.0
This is an assembly language instruction. It means we are instructing the
microcontroller to put a value of ‘zero’ in bit zero of port one. This
instruction is equivalent to telling the microcontroller to switch on the bulb.
The instruction then to instruct the microcontroller to switch off the bulb is,
Set p1.0
This instructs the microcontroller to put a value of ‘one’ in bit zero of port
one.
Don’t worry about what bit zero and port one means. We shall learn it in
more detail as we proceed.
There are a set of well defined instructions, which are used while
communicating with the microcontroller. Each of these instructions requires
a standard number of cycles to execute. The cycle could be one or more in
number.
How is this time then calculated?
The speed with which a microcontroller executes instructions is determined
by what is known as the crystal speed. A crystal is a component connected
externally to the microcontroller. The crystal has different values, and some
of the used values are 6MHZ, 10MHZ, and 11.059 MHz etc.
Thus a 10MHZ crystal would pulse at the rate of 10,000,000 times per
second.
The time is calculated using the formula
No of cycles per second = Crystal frequency in HZ / 12.
For a 10MHZ crystal the number of cycles would be,
10,000,000/12=833333.33333 cycles.
This means that in one second, the microcontroller would execute 833333.33333 cycles.
Therefore for one cycle, what would be the time? Try it out.
The instruction clr p1.0 would use one cycle to execute. Similarly, the instruction setb p1.0 also
uses one cycle.
So go ahead and calculate what would be the number of cycles required to be executed to get a
time of 30 seconds!
Getting back to our bulb example, all we would need to do is to instruct the microcontroller to
carry out some instructions equivalent to a period of 30 seconds, like counting from zero
upwards, then switch on the bulb, carry out instructions equivalent to 30 seconds and switch off
the bulb.
Just put the whole thing in a loop, and you have a never ending on-off sequence.
Let us now have a look at the features of the 8051 core, keeping the
above example as a reference,
1. 8-bit CPU.( Consisting of the ‘A’ and ‘B’ registers)
Most of the transactions within the microcontroller are carried out through
the ‘A’ register, also known as the Accumulator. In addition all arithmetic
functions are carried out generally in the ‘A’ register. There is another
register known as the ‘B’ register, which is used exclusively for
multiplication and division.
Thus an 8-bit notation would indicate that the maximum value that can be
input into these registers is ‘11111111’. Puzzled?
The value is not decimal 111, 11,111! It represents a binary number,
having an equivalent value of ‘FF’ in Hexadecimal and a value of 255 in
decimal.
We shall read in more detail on the different numbering systems namely
the Binary and Hexadecimal system in our next module.
2. 4K on-chip ROM
Once you have written out the instructions for the microcontroller, where do
you put these instructions?
Obviously you would like these instructions to be safe, and not get deleted
or changed during execution. Hence you would load it into the ‘ROM’
The size of the program you write is bound to vary depending on the
application, and the number of lines. The 8051 microcontroller gives you
space to load up to 4K of program size into the internal ROM.
4K, that’s all? Well just wait. You would be surprised at the amount of stuff
you can load in this 4K of space.
Of course you could always extend the space by connecting to 64K of
external ROM if required.
3. 128 bytes on-chip RAM
This is the space provided for executing the program in terms of moving
data, storing data etc.
4. 32 I/O lines. (Four- 8 bit ports, labeled P0, P1, P2, P3)
In our bulb example, we used the notation p1.0. This means bit zero of port
one. One bit controls one bulb.
Thus port one would have 8 bits. There are a total of four ports named p0,
p1, p2, p3, giving a total of 32 lines. These lines can be used both as input
or output.
5. Two 16 bit timers / counters.
A microcontroller normally executes one instruction at a time. However
certain applications would require that some event has to be tracked
independent of the main program.
The manufacturers have provided a solution, by providing two timers.
These timers execute in the background independent of the main program.
Once the required time has been reached, (remember the time calculations
described above?), they can trigger a branch in the main program.
These timers can also be used as counters, so that they can count the
number of events, and on reaching the required count, can cause a branch
in the main program.
6. Full Duplex serial data receiver / transmitter.
The 8051 microcontroller is capable of communicating with external
devices like the PC etc. Here data is sent in the form of bytes, at predefined
speeds, also known as baud rates.
The transmission is serial, in the sense, one bit at a time
7. 5- interrupt sources with two priority levels (Two external and three
internal)
During the discussion on the timers, we had indicated that the timers can
trigger a branch in the main program. However, what would we do in case
we would like the microcontroller to take the branch, and then return back
to the main program, without having to constantly check whether the
required time / count has been reached?
This is where the interrupts come into play. These can be set to either the
timers, or to some external events. Whenever the background program has
reached the required criteria in terms of time or count or an external event,
the branch is taken, and on completion of the branch, the control returns to
the main program.
Priority levels indicate which interrupt is more important, and needs to be
executed first in case two interrupts occur at the same time.
8. On-chip clock oscillator.
This represents the oscillator circuits within the microcontroller. Thus the
hardware is reduced to just simply connecting an external crystal, to
achieve the required pulsing rate.
PIN FUNCTION OF IC 89C51.
1
2
Supply pin of this ic is pin no 40. Normally we apply a 5
volt regulated dc power
supply to this pin. For this purpose either we use step down transformer power
supply or we use 9 volt battery with 7805 regulator.
Ground pin of this ic is pin no 20. Pin no 20 is normally connected to the ground
pin ( normally negative point of the power supply.
3
4
5.
XTAL is connected to the
pin no 18 and pin no 19 of this ic. The quartz crystal
oscillator connected to XTAL1 and XTAL2 PIN. These pins also needs two
capacitors of 30 pf value. One side of each capacitor is connected to crystal and
other pis is connected to the ground point. Normally we connect a 12 MHz or
11.0592 MHz crystal with this ic.. But we use crystal upto 20 MHz to this pins
RESET PIN.. Pin no 9 is the reset pin of this ic.. It is an active high pin. On
applying a high pulse to this pin, the micro controller will reset and terminate all
activities. This is often referred to as a power on reset. The high pulse must
be high for a minimum of 2 machine cycles before it is allowed to go low.
PORT0 Port 0 occupies a total of 8 pins. Pin no 32 to pin no 39. It can be used
for input or output. We connect all the pins of the port 0 with the pullup resistor (10 k
ohm) externally. This is due to fact that port 0 is an open drain mode. It is just like a
open collector transistor.
6.
PORT1. ALL the ports in micrcontroller is 8 bit wide pin no 1 to pin no 8 because
it is a 8 bit controller. All the main register and sfr all is mainly 8 bit wide. Port 1 is
also occupies a 8 pins. But there is no need of pull up resistor in this port. Upon
reset port 1 act as a input port. Upon reset all the ports act as a input port
7.
PORT2. port 2 also have a 8 pins. It can be used as a input or output. There is no
need of any pull up resistor to this pin.
PORT 3.
Port3 occupies a totoal 8 pins from pin no 10 to pin no 17. It can be
used as input or output. Port 3 does not require any pull up resistor. The same as
port 1 and port2. Port 3 is configured as an output port on reset. Port 3 has the
additional function of providing some important signals such as interrupts. Port 3
also use for serial communication.
ALE
ALE is an output pin and is active high. When connecting an 8031 to external memory,
port 0 provides both address and data. In other words, the 8031 multiplexes address and data
through port 0 to save pins. The ALE pin is used for demultiplexing the address and data by
connecting to the ic 74ls373 chip.
PSEN.
PSEN stands for program store eneable. In an 8031 based system in which an
external rom holds the program code, this pin is connected to the OE pin of the rom.
EA. EA. In 89c51 8751 or any other family member of the ateml 89c51 series all come with onchip rom to store programs, in such cases the EA pin is connected to the Vcc. For family
member 8031 and 8032 is which there is no on chip rom, code is stored in external memory and
this is fetched by 8031. In that case EA pin must be connected to GND pin to indicate that the
code is stored externally.
SPECIAL FUNCTION REGISTER ( SFR) ADDRESSES.
ACC
ACCUMULATOR
0E0H
B
B REGISTER
0F0H
PSW
PROGRAM STATUS WORD
0D0H
SP
STACK POINTER
81H
DPTR
DATA POINTER 2 BYTES
DPL
LOW BYTE OF DPTR
82H
DPH
HIGH BYTE OF DPTR
83H
P0
PORT0
80H
P1
PORT1
90H
P2
PORT2
0A0H
P3
PORT3
0B0H
TMOD
TIMER/COUNTER MODE CONTROL
89H
TCON
TIMER COUNTER CONTROL
88H
TH0
TIMER 0 HIGH BYTE
TLO
TIMER 0 LOW BYTE
TH1
TIMER 1 HIGH BYTE
TL1
TIMER 1 LOW BYTE
8BH
SCON
SERIAL CONTROL
98H
SBUF
SERIAL DATA BUFFER
99H
PCON
POWER CONTROL
87H
INSTRUCTIONS
SINGLE BIT INSTRUCTIONS.
8CH
8AH
8DH
SETB BIT
SET THE BIT =1
CLR BIT
CLEAR THE BIT =0
CPL BIT
COMPLIMENT THE BIT 0 =1, 1=0
JB BIT,TARGET
JUMP TO TARGET IF BIT =1
JNB BIT, TARGET
JUMP TO TARGET IF BIT =0
JBC BIT,TARGET
JUMP TO TARGET IF BIT =1 &THEN CLEAR THE BIT
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 Accnmulator.
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.
MOV A, #25H
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.
LCALL, TARGET ADDRESS.
ACALL is a limit for the 2 k byte program counter, but for upto 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 withib 2 k
byte of program memory.
LJMP is also for absoltute jump. It tranfer program execution to the target addres
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 registe 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
RLC A
ROTATE A LEFT THROUGH CARRY
Same as above but 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 intruupt 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.
DPTR INSTRUCTIONS.
MOV DPTR,#16 BIT VALUE
LOAD DATA POINTER
This instructions load the 16 bit dptr register with a 16 bit immediate value
MOV C A,@A+DPTR
This instructions moves a byte of data located in program ROM into
register A. This allows us to put strings of data, such as look up table
elements.
MOVC A,@A+PC
This instructions moves a byte of data located in the program area to A. the address of the
desired byte of data is formed by adding the program counter ( PC) register to the original value
of the accumulator.
INC BYTE
This instructions add 1 to the register or memory location specified by the
operand.
INC A
INC Rn
INC DIRECT
DEC BYTE
This instructions subtracts 1 from the byte operand. Note that CY is
unchanged
DEC A
DEC Rn
DEC DIRECT
ARITHMATIC INSTRUCTIONS.
ANL dest-byte, source-byte
This perform a logical AND operation
This performs a logical AND on the operands, bit by bit, storing the result in
the destination. Notice that both the source and destination values are byte
–size only
`
DIV AB
This instructions divides a byte accumulator by the byte in register B. It is
assumed that both register A and B contain an unsigned byte. After the
division the quotient will be in register A and the remainder in register B.
TMOD ( TIMER MODE ) REGISTER
Both timer is the 89c51 share the one register TMOD. 4 LSB bit for the timer 0 and 4 MSB for
the timer 1.
In each case lower 2 bits set the mode of the timer
Upper two bits set the operations.
GATE:
Gating control when set. Timer/counter is enabled only while the INTX pin is high
and the TRx control pin is set. When cleared, the timer is enabled whenever the TRx control bit
is set
C/T :
clock)
Timer or counter selected cleared for timer operation ( input from internal system
M1
Mode bit 1
M0
Mode bit 0
M1
M0
MODE
OPERATING MODE
0
0
0
13 BIT TIMER/MODE
0
1
1
16 BIT TIMER MODE
1
0
2
8 BIT AUTO RELOAD
1
1
3
SPLIT TIMER MODE
PSW ( PROGRAM STATUS WORD)
CY
PSW.7
CARRY FLAG
AC
PSW.6
AUXILIARY CARRY
F0
PSW.5
AVAILABLE FOR THE USER FRO GENERAL PURPOSE
RS1
PSW.4
REGISTER BANK SELECTOR BIT 1
RS0
PSW.3
REGISTER BANK SELECTOR BIT 0
0V
PSW.2
OVERFLOW FLAG
--
PSW.1
USER DEFINABLE BIT
P
PSW.0
PARITY FLAG SET/CLEARED BY HARDWARE
PCON REGISATER ( NON BIT ADDRESSABLE)
If the SMOD = 0 ( DEFAULT ON RESET)
TH1
=
CRYSTAL FREQUENCY
256---- ____________________
384 X BAUD RATE
If the SMOD IS = 1
CRYSTAL FREQUENCY
TH1
=
256-------------------------------------192 X BAUD RATE
There are two ways to increase the baud rate of data transfer in the 8051
1.
2.
To use a higher frequency crystal
To change a bit in the PCON register
PCON register is an 8 bit register . Of the 8 bits, some are unused, and some are used for the
power control capability of the 8051. the bit which is used for the serial communication is D7,
the SMOD bit. When the 8051 is powered up, D7 ( SMOD BIT) OF PCON register is zero. We
can set it to high by software and thereby double the baud rate
BAUD RATE COMPARISION FOR SMOD = 0 AND SMOD =1
TH1
( DECIMAL)
HEX
SMOD =0
SMOD =1
-3
FD
9600
19200
-6
FA
4800
9600
-12
F4
2400
4800
-24
E8
1200
2400
XTAL = 11.0592 MHZ
IE ( INTERRUPT ENABLE REGISTOR)
EA
IE.7
Disable all interrupts if EA = 0, no interrupts is acknowledged
If EA is 1, each interrupt source is individually enabled or disbaled
By sending or clearing its enable bit.
IE.6
NOT implemented
ET2
IE.5
enables or disables timer 2 overflag in 89c52 only
ES
IE.4
Enables or disables all serial interrupt
ET1
IE.3
Enables or Disables timer 1 overflow interrupt
EX1
IE.2
Enables or disables external interrupt
ET0
IE.1
Enables or Disbales timer 0 interrupt.
EX0
IE.0
Enables or Disables external interrupt 0
INTERRUPT PRIORITY REGISTER
If the bit is 0, the corresponding interrupt has a lower priority and if the bit is 1 the corresponding
interrupt has a higher priority
PT2
IP.7
NOT IMPLEMENTED, RESERVED FOR FUTURE USE.
IP.6
NOT IMPLEMENTED, RESERVED FOR FUTURE USE
IP.5
DEFINE THE TIMER 2 INTERRUPT PRIORITY LELVEL
PS
IP.4
DEFINES THE SERIAL PORT INTERRUPT PRIORITY LEVEL
PT1
IP.3
DEFINES THE TIMER 1 INTERRUPT PRIORITY LEVEL
PX1
IP.2
DEFINES EXTERNAL INTERRUPT 1 PRIORITY LEVEL
PT0
IP.1
DEFINES THE TIMER 0 INTERRUPT PRIORITY LEVEL
PX0
IP.0
DEFINES THE EXTERNAL INTERRUPT 0 PRIORITY LEVEL
SCON: SERIAL PORT CONTROL REGISTER , BIT ADDRESSABLE
SCON
SM0
:
SCON.7 Serial Port mode specifier
SM1
:
SCON.6 Serial Port mode specifier
SM2
:
SCON.5
REN
:
SCON.4 Set/cleared by the software to Enable/disable reception
TB8
:
SCON.3 The 9th bit that will be transmitted in modes 2 and 3, Set/cleared
By software
RB8
:
SCON.2 In modes 2 &3, is the 9th data bit that was received. In mode 1,
If SM2 = 0, RB8 is the stop bit that was received. In mode 0
RB8 is not used
T1
:
SCON.1 Transmit interrupt flag. Set by hardware at the end of the 8th bit
Time in mode 0, or at the beginning of the stop bit in the other
Modes. Must be cleared by software
SCON.0 Receive interrupt flag. Set by hardware at the end of the 8th bit
R1
Time in mode 0, or halfway through the stop bit time in the other
Modes. Must be cleared by the software.
TCON
TIMER COUNTER CONTROL REGISTER
This is a bit addressable
TF1
TCON.7
Timer 1 overflow flag. Set by hardware when the Timer/Counter 1
Overflows. Cleared by hardware as processor
TR1
TCON.6
Timer 1 run control bit. Set/cleared by software to turn Timer
Counter 1 On/off
TF0
TCON.5
Timer 0 overflow flag. Set by hardware when the timer/counter 0
Overflows. Cleared by hardware as processor
TR0
TCON.4
Timer 0 run control bit. Set/cleared by software to turn timer
Counter 0 on/off.
IE1
TCON.3
External interrupt 1 edge flag
ITI
TCON.2
Interrupt 1 type control bit
IE0
TCON.1
External interrupt 0 edge
IT0
TCON.0
Interrupt 0 type control bit.
-
8051 Instruction Set
Arithmetic Operations
Mnemonic
Description
Size
Cycles
ADD A,Rn
Add register to Accumulator (ACC).
1
1
ADD A,direct Add direct byte to ACC.
ADD A,@Ri
2
1
.
1
1
.
2
1
1
1
2
1
2
1
1
1
Subtract direct byte from ACC with borrow 2
1
Add indirect RAM to ACC
ADD A,#data Add immediate data to ACC
ADDC A,Rn
Add register to ACC with carry
ADDC A,direct
Add direct byte to ACC with carry.
ADDC A,@Ri Add indirect RAM to ACC with carry. 1
ADDC A,#data
SUBB A,Rn
SUBB A,direct
.
1
Add immediate data to ACC with carry.
Subtract register from ACC with borrow.
SUBB A,@Ri Subtract indirect RAM from ACC with borrow.
SUBB A,#data
INC A
INC Rn
1
Subtract immediate data from ACC with borrow.
Increment ACC.
Increment register.
1
2
1
1
1
1
1
INC direct
Increment direct byte.
2
1
INC @Ri
Increment indirect RAM.
1
1
Decrement ACC.
1
1
DEC A
DEC Rn
Decrement register.
1
1
DEC direct
Decrement direct byte.
2
1
DEC @Ri
Decrement indirect RAM.
1
1
INC DPTR
Increment data pointer.
1
2
MUL AB
Multiply A and B Result: A <- low byte, B <- high byte.
1
4
DIV AB
Divide A by B Result: A <- whole part, B <- remainder.
1
4
DA A
Decimal adjust ACC.
1
1
Size
Cycles
Logical Operations
Mnemonic
Description
ANL A,Rn
AND Register to ACC.
ANL A,direct AND direct byte to ACC.
ANL A,@Ri
AND indirect RAM to ACC.
ANL A,#data AND immediate data to ACC.
1
1
2
1
1
1
2
1
ANL direct,A AND ACC to direct byte.
2
1
ANL direct,#data
3
2
ORL A,Rn
AND immediate data to direct byte.
OR Register to ACC.
1
ORL A,direct OR direct byte to ACC.
ORL A,@Ri
OR indirect RAM to ACC.
ORL A,#data OR immediate data to ACC.
ORL direct,A OR ACC to direct byte.
ORL direct,#data
XRL A,Rn
1
2
1
1
2
1
2
OR immediate data to direct byte.
Exclusive OR Register to ACC.
1
1
3
1
1
2
XRL A,direct Exclusive OR direct byte to ACC.
XRL A,@Ri
Exclusive OR indirect RAM to ACC.
2
1
1
1
XRL A,#data Exclusive OR immediate data to ACC.
2
1
XRL direct,A Exclusive OR ACC to direct byte.
2
1
XRL direct,#data
3
2
XOR immediate data to direct byte.
CLR A
Clear ACC (set all bits to zero).
1
1
CPL A
Compliment ACC.
1
1
RL A
Rotate ACC left.
RLC A
Rotate ACC left through carry.
RR A
Rotate ACC right.
RRC A
SWAP A
Rotate ACC right through carry.
Swap nibbles within ACC.
1
1
1
1
1
1
1
1
1
1
Data Transfer
Mnemonic
Description
Size
Cycles
MOV A,Rn
Move register to ACC.
1
1
MOV A,direct
Move direct byte to ACC.
MOV A,@Ri
Move indirect RAM to ACC.
1
1
MOV A,#data
Move immediate data to ACC.
2
1
MOV Rn,A
Move ACC to register.
1
1
2
MOV Rn,direct
Move direct byte to register.
2
2
MOV Rn,#data
Move immediate data to register.
2
1
MOV direct,A
MOV direct,Rn
Move ACC to direct byte.
Move register to direct byte.
2
1
2
2
MOV direct,direct
Move direct byte to direct byte.
3
2
MOV direct,@Ri
Move indirect RAM to direct byte.
2
2
1
MOV direct,#data
Move immediate data to direct byte.
3
2
MOV @Ri,A
Move ACC to indirect RAM.
1
1
MOV @Ri,direct
Move direct byte to indirect RAM.
2
2
2
1
MOV DPTR,#data16 Move immediate 16 bit data to data pointer register.3
2
MOV @Ri,#data
Move immediate data to indirect RAM.
MOVC A,@A+DPTR Move code byte relative to DPTR to ACC (16 bit address). 1
MOVC A,@A+PC
Move code byte relative to PC to ACC (16 bit address).1
2
MOVX A,@Ri
Move external RAM to ACC (8 bit address). 1
2
MOVX A,@DPTR
Move external RAM to ACC (16 bit address).
1
MOVX @Ri,A
Move ACC to external RAM (8 bit address). 1
2
MOVX @DPTR,A
Move ACC to external RAM (16 bit address).
1
2
PUSH direct
Push direct byte onto stack.
2
2
POP direct
Pop direct byte from stack.
2
2
2
2
XCH A,Rn
Exchange register with ACC.
1
1
XCH A,direct
Exchange direct byte with ACC.
2
1
XCH A,@Ri
Exchange indirect RAM with ACC.
1
1
XCHD A,@Ri
Exchange low order nibble of indirect
1
1
RAM with low order nibble of ACC
Boolean Variable Manipulation
Mnemonic
Description
Size
Cycles
CLR C
Clear carry flag.
1
1
CLR bit
Clear direct bit.
2
1
SETB C
Set carry flag.
SETB
bitSet direct bit
CPL C
Compliment carry flag.
CPL bit
Compliment direct bit.
1
2
1
1
2
1
1
1
ANL C,bit
AND direct bit to carry flag.
2
2
ANL C,/bit
AND compliment of direct bit to carry.
2
2
ORL C,bit
OR direct bit to carry flag.
2
2
ORL C,/bit
OR compliment of direct bit to carry.
2
2
MOV C,bit
Move direct bit to carry flag.
2
1
MOV bit,C
Move carry to direct bit.
2
2
JC rel
Jump if carry is set.
2
2
2
2
JNC rel
Jump if carry is not set.
JB bit,rel
Jump if direct bit is set.
3
2
JNB bit,rel
Jump if direct bit is not set.
3
2
JBC bit,rel
Jump if direct bit is set & clear bit.
3
2
Size
Cycles
Program Branching
Mnemonic
Description
ACALL
addr11
LCALL
Absolute subroutine call.
addr16
Long subroutine call.
2
2
3
2
RET
Return from subroutine.
1
2
RETI
Return from interrupt.
1
2
AJMP addr11 Absolute jump.
2
2
LJMP addr16 Long jump.
3
2
SJMP rel
Short jump (relative address).
JMP @A+DPTR
JZ rel
Jump indirect relative to the DPTR.
Jump relative if ACC is zero.
2
1
2
2
2
JNZ rel
Jump relative if ACC is not zero.
2
2
CJNE A,direct,rel
Compare direct byte to ACC and jump if not equal. 3
2
CJNE A,#data,rel
Compare immediate byte to ACC and jump if not equal.3
2
CJNE Rn,#data,rel
Compare immediate byte to register and jump if not equal.3
2
2
CJNE @Ri,#data,rel Compare immediate byte to indirect and jump if not equal.3
DJNZ Rn,rel
Decrement register and jump if not zero.
DJNZ direct,rel
Decrement direct byte and jump if not zero.
Other Instructions
Mnemonic
NOP
Description
No operation. 1
Size
1
Cycles
2
2
2
3
2
exists which allows us to communicate with the vast 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 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 4bit 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.
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
LCD DETAIL LCD DETAIL .
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.
directly with the LCD.
44780 BACKGROUND
The 44780 and/or put data on the data bus. When the other lines are completely ready, AN
EXAMPLE HARDWARE CONFIGURATION
As.
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 1,
P0.2, etc. Let's go ahead and write our initial equates:
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 insutrction:
SETB RW
HANDLING THE EN CONTROL LINE
As we:
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 write the code:
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 Thus, to send this
38h command to the LCD we must execute the following 8051 instructions:
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
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 after the LCD An
subroutine:
CLEAR_LCD:
SETB EN
CLR RS
MOV DATA,#01h
CLR EN
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
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
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 left-hand
corner of the screen. However, what if we wanted to display the word "Hello" in the
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
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:
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
PIN WISE DETAIL OF LCD
1.
Vss
GROUND
2.
Vcc
+5VOLT SUPPLY
3
Vee
POWER SUPPLY TO CONTROL CONTRAST
4.
RS
RS = 0 TO SELECT COMMAND REGISTER
RS = 1 TO SELECT DATA REGISTER