You are on page 1of 126

A PROJECT REPORT

ON

LASER COMMUNICATION

Bachelor of Technology
In
Electronics & Communication

2011-2012

Project Incharge : Submitted By:


Mr. Saurabh Sharma Akshat Mittal (0829231006)
Miss. Swati Singh Neha Singh (0829231025)
Shrey Agarwal (0829231039)
Mudit Rander
(0829231404)
Bharti Joshi (0829221010)

Department of Electronics & Communication


MEERUT INSTITUTE OF TECHNOLOGY,
MEERUT (U.P.)
CERTIFICATE

This is to certify that work which is being presented in the project


entitled LASER COMMUNICATION submitted by Mr. Akshat Mittal
Miss. Neha Singh, Mr. Shrey Agarwal, Mr. Mudit Rander, Miss. Bharti
Joshi student of final year B.Tech. In ELECTRONICS &
COMMUNICATION in partial fulfillment of the requirement for award of
the degree of B.Tech in ELECTRONICS & COMMUNICATION is a record
of students work carried out by them under my guidance and supervision.

As per the candidates declaration this work has not been submitted
elsewhere for the award of any other degree.

Dated: 27 April 2012 Signature of Project Guide


Place: Meerut Name: Miss. Swati Singh
Designation: LECTURER

Signature of Project Incharge Signature of H.O.D


ACKNOWLEDGEMENT

Enthusiasm is the feet of all progresses, with it there is


accomplishment and without it there are only slits alibis.

Acknowledgment is not a ritual but is certainly an important thing for


the successful completion of the project. At the time when we were made to
know about the project, it was really very tough to proceed further as we
were to develop the same on a platform, which was new to us. More so, the
coding part seemed so tricky that it seemed to be impossible for us to
complete the work within the given duration.

We really feel indebted in acknowledging the organizational support


and encouragement received from the management of our college.

The task of developing this system would not have been possible
without the constant help of our mentors. We take this opportunity to
express our profound sense of gratitude and respect to those who helped us
throughout the duration of this project.

We express our gratitude to Mr. Saurabh Sharma (H.O.D,MIT) Miss.


Swati Singh(Lecturer,MIT). We would again like to thank all of them for
giving their valuable time to us in developing this project.

Dated:27 April 2012 Mr. Akshat Mittal


Place: Meerut Miss. Neha Singh
Mr. Shrey Agarwal
Mr. Mudit Rander
Miss. Bharti Joshi
TABLE OF CONTENTS

INTRODUCTION

PLATFORM USED

AIM OF THE PROJECT

BLOCK DIAGRAM

WORKING OF THE PROJECT

CIRCUIT DIAGRAM

COMPONENT LIST

CIRCUIT DESCRIPTION

PCB LAYOUT

STEPS FOR MAKING PCB

PROGRAMMING
SENSING UNIT DESCRIPTION

COMPONENTS DESCRIPTION

APPLICATION

CONCLUSION

REFERENCE

Introduction
INTRODUCTION:

Laser communications systems are wireless connections through the


atmosphere. They work similarly to fiber optic links, except the beam is
transmitted through free space. While the transmitter and receiver must
require line-of-sight conditions, they have the benefit of eliminating the need
for broadcast rights and buried cables. Laser communications systems can be
easily deployed since they are inexpensive, small, low power and do not
require any radio interference studies. The carrier used for the transmission
signal is typically generated by a laser diode. Two parallel beams are
needed, one for transmission and one for reception. Due to budget
restrictions, the system implemented in this project is only one way.

This project is microcontroller based Laser communication system


used for the successful transmission of data. In this project using two
microcontroller ,we are transmitting data from one end using laser
transmitter and at other end received by laser receiver which is connected to
the pin of microcontroller ,here the transmitted as well as received data
displayed on lcd .

Platform used
Hardware requirements:

1) Microcontroller AT89C51

2) LDR

3) LM7805 Regulator

4) Power Supply

5) Resistors

6) Capacitors

7) Transistors
8) LIQUID CRYSTAL DISPLAY
9) Transformer

10) Connectors

11) Laser Transmitter


12) Laser Receiver
13) Switch

Software requirements:

1) Assembler of ATMEL microcontroller series

2) PADS for PCB designing


AIM OF THE
PROJECT
The Aim of this project is to design a communication system through
Laser,a laser diode at the transmitting end act as a transduser to convert the
digital data into laser form and transmitted ,at the receiving end a laser
transistor convert the laser data into digital form .
Here the motive of using Laser is that While the transmitter and
receiver must require line-of-sight conditions, they have the benefit of
eliminating the need for broadcast rights and buried cables. Laser
communications systems can be easily deployed since they are inexpensive,
small, low power and do not require any radio interference studies.
Block diagram
Laser communication

TRANSMITTER
DISPLAY SECTION
USING
LCD

SUPPLY Communicatio
MICRO
SECTION n
CONTROLLER
89C51

TRANSMITTER

LASER DIODE
Receiver

DISPLAY SECTION
USING
SUPPLY MICRO CONTROLLER LCD
SECTION 89C51

RECEIVER

LDR
WORKING OF
THE PROJECT
There are two microcontroller one at sending end and the other at
receiving end .Laser transmitter is connected to the pin of the
microcontroller at the sending end and the LASER receiver is
connected to microcontroller at receiver end.whenever a person is
wishing to send the data the microcontroller make the laser transmitter
to send the frequency corresponding to that data and at receiver end
that frequency can change to the original data form which will display
on the lcd connected to the pin of the microcontroller.in this way the
function of transmitting the data through laser receiver and
transmitter have been completed.
CIRCUIT
DIAGRAM
Attach the hard
copy of the ckt
diagram
Component list
Attach hard copy of
Component list
CIRCUIT
DESCRIPTION
POWER SUPPLY SECTION:

Consists of:
1. RLMT Connector--- It is a connector used to connect
the step down transformer to the bridge rectifier.

2. Bridge Rectifier --- It is a full wave rectifier used to


convert ac into dc , 9-15v ac made by transformer is
converted into dc with the help of rectifier.

3. Capacitor: -----It is an electrolytic capacitor of


rating 1000M/35V used to remove the ripples. Capacitor
is the component used to pass the ac and block the dc.

4. Regulator: ----LM7805 is used to give a fixed 5v


regulated supply.

5. Capacitor: -----It is again an electrolytic capacitor


10M/65v used for filtering to give pure dc.

6. Capacitor: ----- It is an ceramic capacitor used to


remove the spikes generated when frequency is
high(spikes).

So the output of supply section is 5v regulated dc.


MICROCONTROLLER SECTION:
Requires three connections to be successfully done for
its operation to begin.

1. +5v supply: This +5v supply is required for the


controller to get start which is provided from the power
supply section. This supply is provided at pin no.31and
40 of the 89c51 controller.

2. Crystal Oscillator: A crystal oscillator of 12 MHz is


connected at pin no.19,x1 and pin no.18,x2 to generate
the frequency for the controller. The crystal oscillator
works on piezoelectric effect.The clock generated is
used to determine the processing speed of the
controller. Two capacitors are also connected one end
with the oscillator while the other end is connected with
the ground. As it is recommended in the book to
connect two ceramic capacitor of 20 pf40pf to
stabilize the clock generated.

3. Reset section: It consists of an rc network


consisting of 10M/35V capacitor and one resistance of
1k. This section is used to reset the controller
connected at pin no.9 of AT89c51.

DISPLAY SECTION:
LCD(LIQUID CRYSTAL DISPLAY)
MICROCONTROLLER BASED LCD DISPLAY ,this project is an embedded
project . Embedded is the combination of software and hardware before
designing any embedded project it is the first step to design the proper
hardware for the desired application. Here we are interfacing the LCD,
LIQUID CRYSTAL DISPLAY with the Microcontroller, we are using ATMEL
series 51 controller 89c51 controller. It is a 40 pin IC, the first step while
designing hardware is to design the required power supply as the
controller operates on +5 v supply so first we have to design the
regulated supply with the help of transformer, regulator and filtering
capacitor.
Next step is the necessary connections of the controller like reset and
the crystal oscillator for resetting and speed respectively.
Then comes the LCD interfacing ,we are using 16x2 LCD for display, pin
no. 7 to 14 are the data lines of the LCD which has to be interfaced with
the microcontroller input/output pins. Port p0 has been used for the
interfacing of data lines.
Since the display becomes very easy when we use microcontroller hence
we have made this project and we have tried to show different display
using the switch.

RELAY SECTION:

RELAY is an isolator and an electrical switch. The relay used


is 12V-5A.To control the operation of relay an NPN transistor
BC547 has been used. Whenever high signal comes at the
base of NPN transistor it is switched on and whenever low
arrives it is switched off. Base of the transistor is connected
with the I/O pin of the microcontroller. Base resistance of 1k5
is connected at the base of the transistor. Whenever low is
sensed at the pin of microcontroller transistor gets off and
the output of the collector becomes high and the relay which
is connected at the output of the collector becomes off. The
reverse action of it takes place when high is sensed at the
pin of microcontroller.

This section also consists of pull up & pull down resistance.


A 2k2 resistance is used as pull up. In any case when more
than 5v comes then pull up resistance sinks the excess
voltage & maintains 5v. If pull up is not used then the 12v of
relay can damage the processor when the transistor BC547
is on. A pull down resistor of value 2k2 is also used.

PCB LAYOUT
Attach the hard
copy of the
component
layout

Attach the hard


copy of the pcb
layout
STEPS FOR
MAKING PCB
Prepare the layout of the circuit (positive).

Cut the photofilm (slightly bigger) of the size of the layout.

Place the layout in the photoprinter machine with the


photofilm above it. Make sure that the bromide (dark) side of
the film is in contact with the layout.

Switch on the machine by pressing the push button for 5 sec.

Dip the film in the solution prepared (developer) by mixing the


chemicals A & B in equal quantities in water.

Now clean the film by placing it in the tray containing water for
1 min.

After this, dip the film in the fixer solution for 1 min. now the
negative of the
Circuit is ready.

Now wash it under the flowing water.

Dry the negative in the photocure machine.

Take the PCB board of the size of the layout and clean it with
steel wool to make the surface smooth.

Now dip the PCB in the liquid photoresist, with the help of dip
coat machine.

Now clip the PCB next to the negative in the photo cure
machine, drying for approximate 10-12 minute.
Now place the negative on the top of the PCB in the UV
machine, set the timer for about 2.5 minute and switch on the
UV light at the top.

Take the LPR developer in a container and rigorously move the


PCB in it.

After this, wash it with water very gently.

Then apply LPR dye on it with the help of a dropper so that it is


completely covered by it.

Now clamp the PCB in the etching machine that contains ferric
chloride solution for about 10 minutes.

After etching, wash the PCB with water, wipe it a dry cloth
softly.

Finally rub the PCB with a steel wool, and the PCB is ready.
Programming
Attach hard
copy of
programming
SENSING UNIT
DESCRIPTION
Laser transmitter

Laser receiver
A laser diode is a laser where the active medium is a semiconductor similar
to that found in a light-emitting diode. The most common and practical type
of laser diode is formed from a p-n junction and powered by injected electric
current. These devices are sometimes referred to as injection laser diodes to
distinguish them from (optically) pumped laser diodes, which are more
easily manufactured in the laboratory.

Theory of operation

A laser diode, like many other semiconductor devices, is formed by doping a


very thin layer on the surface of a crystal wafer. The crystal is doped to
produce an n-type region and a p-type region, one above the other, resulting
in a p-n junction, or diode.

Laser diodes form a subset of the larger classification of semiconductor p-n


junction diodes. As with any semiconductor p-n junction diode, forward
electrical bias causes the two species of charge carrier holes and electrons
to be "injected" from opposite sides of the p-n junction into the depletion
region, situated at its heart. Holes are injected from the p-doped, and
electrons from the n-doped, semiconductor. (A depletion region, devoid of
any charge carriers, forms automatically and unavoidably as a result of the
difference in chemical potential between n- and p-type semiconductors
wherever they are in physical contact.)

As charge injection is a distinguishing feature of diode lasers as compared to


all other lasers, diode lasers are traditionally and more formally called
"injection lasers." (This terminology differentiates diode lasers, e.g., from
flashlamp-pumped solid state lasers, such as the ruby laser. Interestingly,
whereas the term "solid-state" was extremely apt in differentiating 1950s-era
semiconductor electronics from earlier generations of vacuum electronics, it
would not have been adequate to convey unambiguously the unique
characteristics defining 1960s-era semiconductor lasers.) When an electron
and a hole are present in the same region, they may recombine or
"annihilate" with the result being spontaneous emission i.e., the electron
may re-occupy the energy state of the hole, emitting a photon with energy
equal to the difference between the electron and hole states involved. (In a
conventional semiconductor junction diode, the energy released from the
recombination of electrons and holes is carried away as phonons, i.e., lattice
vibrations, rather than as photons.) Spontaneous emission gives the laser
diode below lasing threshold similar properties to an LED. Spontaneous
emission is necessary to initiate laser oscillation, but it is one among several
sources of inefficiency once the laser is oscillating.

The difference between the photon-emitting semiconductor laser and


conventional phonon-emitting (non-light-emitting) semiconductor junction
diodes lies in the use of a different type of semiconductor, one whose
physical and atomic structure confers the possibility for photon emission.
These photon-emitting semiconductors are the so-called "direct bandgap"
semiconductors. The properties of silicon and germanium, which are single-
element semiconductors, have bandgaps that do not align in the way needed
to allow photon emission and are not considered "direct." Other materials,
the so-called compound semiconductors, have virtually identical crystalline
structures as silicon or germanium but use alternating arrangements of two
different atomic species in a checkerboard-like pattern to break the
symmetry. The transition between the materials in the alternating pattern
creates the critical "direct bandgap" property. Gallium arsenide, indium
phosphide, gallium antimonide, and gallium nitride are all examples of
compound semiconductor materials that can be used to create junction
diodes that emit light.

Diagram (not to scale) of a simple laser diode, such as shown above.

In the absence of stimulated emission (e.g., lasing) conditions, electrons and


holes may coexist in proximity to one another, without recombining, for a
certain time, termed the "upper-state lifetime" or "recombination time"
(about a nanosecond for typical diode laser materials), before they
recombine. Then a nearby photon with energy equal to the recombination
energy can cause recombination by stimulated emission. This generates
another photon of the same frequency, travelling in the same direction, with
the same polarization and phase as the first photon. This means that
stimulated emission causes gain in an optical wave (of the correct
wavelength) in the injection region, and the gain increases as the number of
electrons and holes injected across the junction increases. The spontaneous
and stimulated emission processes are vastly more efficient in direct
bandgap semiconductors than in indirect bandgap semiconductors; therefore
silicon is not a common material for laser diodes.

As in other lasers, the gain region is surrounded with an optical cavity to


form a laser. In the simplest form of laser diode, an optical waveguide is
made on that crystal surface, such that the light is confined to a relatively
narrow line. The two ends of the crystal are cleaved to form perfectly
smooth, parallel edges, forming a FabryProt resonator. Photons emitted
into a mode of the waveguide will travel along the waveguide and be
reflected several times from each end face before they are emitted. As a light
wave passes through the cavity, it is amplified by stimulated emission, but
light is also lost due to absorption and by incomplete reflection from the end
facets. Finally, if there is more amplification than loss, the diode begins to
"lase".

Some important properties of laser diodes are determined by the geometry of


the optical cavity. Generally, in the vertical direction, the light is contained
in a very thin layer, and the structure supports only a single optical mode in
the direction perpendicular to the layers. In the lateral direction, if the
waveguide is wide compared to the wavelength of light, then the waveguide
can support multiple lateral optical modes, and the laser is known as "multi-
mode". These laterally multi-mode lasers are adequate in cases where one
needs a very large amount of power, but not a small diffraction-limited
beam; for example in printing, activating chemicals, or pumping other types
of lasers.

In applications where a small focused beam is needed, the waveguide must


be made narrow, on the order of the optical wavelength. This way, only a
single lateral mode is supported and one ends up with a diffraction-limited
beam. Such single spatial mode devices are used for optical storage, laser
pointers, and fiber optics. Note that these lasers may still support multiple
longitudinal modes, and thus can lase at multiple wavelengths
simultaneously.

The wavelength emitted is a function of the band-gap of the semiconductor


and the modes of the optical cavity. In general, the maximum gain will occur
for photons with energy slightly above the band-gap energy, and the modes
nearest the gain peak will lase most strongly. If the diode is driven strongly
enough, additional side modes may also lase. Some laser diodes, such as
most visible lasers, operate at a single wavelength, but that wavelength is
unstable and changes due to fluctuations in current or temperature.

Due to diffraction, the beam diverges (expands) rapidly after leaving the
chip, typically at 30 degrees vertically by 10 degrees laterally. A lens must
be used in order to form a collimated beam like that produced by a laser
pointer. If a circular beam is required, cylindrical lenses and other optics are
used. For single spatial mode lasers, using symmetrical lenses, the
collimated beam ends up being elliptical in shape, due to the difference in
the vertical and lateral divergences. This is easily observable with a red laser
pointer.

The simple diode described above has been heavily modified in recent years
to accommodate modern technology, resulting in a variety of types of laser
diodes, as described below.
MICROCONTROLLER AT89C51

Features

Compatible with MCS-51 Products


8K Bytes of In-System Re programmable Flash Memory
Endurance: 1,000 Write/Erase Cycles
Fully Static Operation: 0 Hz to 24 MHz
Three-level Program Memory Lock
256 x 8-bit Internal RAM
32 Programmable I/O Lines
Three 16-bit Timer/Counters
Eight Interrupt Sources
Programmable Serial Channel
Low-power Idle and Power-down Modes
DESCRIPTION

The AT89C52 is a low-power, high-performance CMOS 8-bit microcomputer 8Kbytes of

Flash programmable and erasable read only memory (PEROM). The device is

manufactured using Atmel s high-density nonvolatile memory technology and is

compatible with the industry standard 80C51 and 80C52 instruction set and pin out.

The on-chip Flash allows the program memory to be reprogrammed


in-system or by a Conventional nonvolatile memory programmer. By
combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel
AT89C52 is a powerful microcomputer that provides a highly flexible and
cost-effective solution to many embedded control application.

The AT89C52 provides the following standard features: 8K bytes of Flash, 256
bytes of RAM, 32 I/O lines, three 16-bit timer/counters, a six-vector two-level
interrupt architecture, a full-duplex serial port, on-chip oscillator, and clock
circuitry. In addition, the AT89C52 is designed with static logic for operation down
to zero frequency and supports two software selectable power saving modes. The
Idle Mode tops the CPU while allowing the RAM; timer/counters, serial port, and
interrupt system to continue functioning.

The Power-down mode saves the RAM contents but Freezes the
oscillator, disabling all other chip functions until the next hardware reset
.
Pin Description

VCC
Supply voltage.

GND
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 internal 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.

In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input
(P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown in the
following table.

Port 1 also receives the low-order address bytes during


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 internal 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 pull-ups when
emitting 1s. During accesses to external data memory that use 8-bit
addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special
Function Register. Port 2 also receives the high-order address bits and some
control signals during Flash programming and verification.

Port 3

Port 3 is an 8-bit 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 internal pull-ups and can be used as
inputs. As inputs, Port 3 pins that are externally being pulled low will source
current (IIL) because of the pull-ups. Port 3 also serves the functions of
various special features of the AT89C51, as shown in the following table.
Port 3 also receives some control signals for Flash programming.
RST

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

ALE/PROG

Address Latch Enable 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 micro controller is in external
execution mode.

PSEN

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

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 when 12-volt programming is selected.

XTAL1

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

XTAL2

Output from the inverting oscillator amplifier .


Special Function Registers

A map of the on-chip memory area called the Special Function Register
(SFR) space is shown in Table 1.

Note that not all of the addresses are occupied, and unoccupied addresses may not
be implemented on the chip. Read accesses to these addresses will in general return
random data, and write accesses will have an indeterminate effect. User software
should not write 1s to these unlisted locations, since they may be used in future prod
new features. In that case, the reset or inactive values of the new bits will always be
0.

Timer 2 Registers

Control and status bits are contained in registers T2CON (shown in Table 2)
and T2MOD (shown in Table 4) for Timer 2. The register pair (RCAP2H,
RCAP2L) are the Capture/Reload registers for Timer 2 in 16-bit capture
mode or 16-bit auto-reload mode.

Interrupt Registers

The individual interrupt enable bits are in the IE register. Two priorities can be set for each
of the six interrupt sources in the IP register. Instructions that use indirect addressing
access the upper 128 bytes of RAM. For example, the following indirect addressing
instruction, where R0 contains 0A0H, accesses the data byte at address 0A0H, rather than
P2 (whose address is 0A0H).
MOV @R0, #data
Note that stack operations are examples of indirect addressing, so the upper 128 bytes of
data RAM are avail available as stack space.
Timer 0 and 1

Timer 0 and Timer 1 in the AT89C52 operate the same way as Timer 0 and Timer 1 in the
T89C51.

Timer 2

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


event counter. The type of operation is selected by bit C/T2 in the SFR
T2CON (shown in Table 2).Timer 2 has three operating modes: capture,
auto-reload (up or down counting), and baud rate generator. The modes are
selected by bits in T2CON, as shown in Table 3.Timer 2 consists of two 8-
bit registers, TH2 and TL2. In the Timer function, the TL2 register is
incremented every machine cycle. Since a machine cycle consists of 12
oscillator periods, the count rate is 1/12 of the oscillator input pin, T2. In this
function, the external input is sampled during S5P2 of every machine cycle.
When the samples show a high in one cycle and a low in the next cycle, the
count is incremented. The new count value appears in the register during
S3P1 of the cycle following the one in which
the transition was detected. Since two machine cycles (24 oscillator periods)
are required to recognize a 1-to-0 transition, the maximum count rate is 1/24
of the oscillator frequency. To ensure that a given level is sampled at least
once before it changes, the level should be held for at least one full machine
cycle.

Capture Mode

In the capture mode, two options are selected by bit EXEN2 in T2CON. If EXEN2 = 0,
Timer 2 is a 16-bit timer or counter which upon overflow sets bit TF2 in T2CON.This bit
can then be used to generate an interrupt. If EXEN2 = 1, Timer 2 performs the same
operation, but a 1-to-0 transition at external input T2EX also causes the current value in
TH2 and TL2 to be captured into CAP2H and RCAP2L, respectively. In addition, the
transition at T2EX causes bit EXF2 in T2CON to be set. The EXF2 bit, like TF2, can
generate an interrupt. The capture mode is illustrated in Figure 1.
Auto-reload (Up or Down Counter)

Timer 2 can be programmed to count up or down when configured in its 16-bit auto-reload
mode. This feature is invoked by theDCEN (Down Counter Enable) bit located in the SFR
T2MOD (see Table 4). Upon reset, the DCEN bit is set to 0 so that timer 2 will default to
count up. When DCEN is set, Timer 2 can count up or down, depending on the value of the
T2EX pin.

Figure 2 shows Timer 2 automatically counting up when DCEN = 0. In this mode, two
options are selected by bitEXEN2 in T2CON. If EXEN2 = 0, Timer 2 counts up to
0FFFFH and then sets the TF2 bit upon overflow. The overflow also causes the timer
registers to be reloaded with the 16-bit value in RCAP2H and RCAP2L. The values in
Timer in Capture ModeRCAP2H and RCAP2L are preset by software. If EXEN2 = 1, a 16-
bit reload can be triggered either by an overflow or by a 1-to-0 transition at external input
T2EX. This transition also sets the EXF2 bit. Both the TF2 and EXF2 bits can generate an
interrupt if enabled. Setting the DCEN bit enables Timer 2 to count up or down, as shown
in Figure 3. In this mode, the T2EX pin controls

the direction of the count. A logic 1 at T2EX makes Timer 2 count up. The
timer will overflow at 0FFFFH and set the TF2 bit. This overflow also
causes the 16-bit value in RCAP2H and RCAP2L to be reloaded into the
timer registers, TH2 and TL2, respectively. A Logic 0 at T2EX makes Timer
2 count down. The timer underflows when TH2 and TL2 equal the values
stored in RCAP2H and RCAP2L. The underflow sets the TF2 bit and causes
0FFFFH to be reloaded into the timer Registers. The EXF2 bit toggles
whenever Timer 2 overflows or underflows and can be used as a 17th bit of
resolution. In this operating mode, EXF2 does not flag an interrupt.
Baud Rate Generator

Timer 2 is selected as the baud rate generator by setting TCLK and/or RCLK
in T2CON (Table 2). Note that the baud rates for transmit and receive can be
different if Timer 2 is used for the receiver or transmitter and Timer 1 is
used for the other function. Setting RCLK and/or TCLK puts Timer 2 into
its baud rate generator mode, as shown in Figure4. The baud rate generator
mode is similar to the auto-reload mode, in that a rollover in TH2 causes the
Timer 2 registers to be reloaded with the 16-bit value in registers RCAP2H
and RCAP2L, which are preset by software.
The baud rates in Modes 1 and 3 are determined by Timer2s overflow rate according to
the following equation.

The Timer can be configured for either timer or counter operation. In most applications, it
is configured for timer operation (CP/T2 = 0). The timer operation is different for Timer 2
when it is used as a baud rate generator. Normally, as a timer, it increments every machine
cycle (at 1/12 the oscillator frequency). As a baud rate generator, however, it increments
every state time (at 1/2 the oscillator frequency). The baud rate formula is given below.

where (RCAP2H, RCAP2L) is the content of RCAP2H and RCAP2L taken as a 16-bit
unsigned integer. Timer 2 as a baud rate generator is shown in Figure 4. This figure is valid
only if RCLK or TCLK = 1 in T2CON. Note that a rollover in TH2 does not set TF2 and
will not generate an interrupt. Note too, that if EXEN2 is set, a 1-to-0 transition in T2EX
will set EXF2 but will not cause a reload from (RCAP2H, RCAP2L) to (TH2, TL2). Thus
when Timer 2 is in use as a baud rate generator, T2EX can be used as an extra external
interrupt.

Note that when Timer 2 is running (TR2 = 1) as a timer in the baud rate
generator mode, TH2 or TL2 should not be read from or written to. Under
these conditions, the Timer is incremented every state time, and the results
of a read or write may not be accurate. The RCAP2 registers may be read
but should not be written to, because a write might overlap a reload and
cause write and/or reload errors. The timer should be turned off (clear TR2)
before accessing the Timer 2 or RCAP2 registers.
Programmable Clock Out

A 50% duty cycle clock can be programmed to come out on P1.0, as shown
in Figure 5. This pin, besides being a regular I/O pin, has two alternate
functions. It can be programmed to input the external clock for
Timer/Counter 2 or to output a 50% duty cycle clock ranging from 61 Hz to
4 MHz at a 16 MHz operating frequency. To configure the Timer/Counter 2
as a clock generator, bit C/T2 (T2CON.1) must be cleared and bit T2OE
(T2MOD.1) must be set. Bit TR2 (T2CON.2) starts and stops the timer. The
clock-out frequency depends on the oscillator frequency and the reload value
of Timer 2 capture registers (RCAP2H, RCAP2L), as shown in the
following equation.

In the clock-out mode, Timer 2 roll-overs will not generate an interrupt. This
behavior is similar to when Timer 2 is used as a baud-rate generator. It is
possible to use Timer 2 as a baud-rate generator and a clock generator
simultaneously. Note, however, that the baud-rate and clock-out
Frequencies cannot be determined independently from one another since
they both use RCAP2H and RCAP2L.
UART

The UART in the AT89C52 operates the same way as the UART in the AT89C51.

Interrupts

The AT89C52 has a total of six interrupt vectors: two external interrupts (INT0 and INT1),
three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt. These interrupts are
all shown in Figure 6.Each of these interrupt sources can be individually enabled or
disabled by setting or clearing a bit in Special Function Register IE. IE also contains a
global disable bit, EA, which disables all interrupts at once.
Note that Table shows that bit position IE.6 is unimplemented. In the
AT89C51, bit position IE.5 is also unimplemented. User software should not
write 1s to these bit positions, since they may be used in future AT89
products. Timer 2 interrupt is generated by the logical OR of bits TF2 and
EXF2 in register T2CON. Neither of these flags is cleared by hardware
when the service routine is vectored to. In fact, the service routine may have
to determine whether it was TF2 or EXF2 that generated the interrupt, and
that bit will have to be cleared in software. The Timer 0 and Timer 1 flags,
TF0 and TF1, are set at S5P2 of the cycle in which the timers overflow. The
values are then polled by the circuitry in the next cycle. However, the Timer
2 flag, TF2, is set at S2P2 and is polled in the same cycle in which the timer
overflows.
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, as shown in Figure 7. Either
a quartz crystal or ceramic resonator may be used. To drive the device from an
external clock source, XTAL2 should be left
Un connected while XTAL1 is driven, as shown in Figure 8.There are no requirements on
the duty cycle of the external clock signal, since the input to the internal clocking circuitry
is through a divide-by-two flip-flop, but minimum and maximum voltage high and low
time specifications must be observed.

Idle Mode

In idle mode, the CPU puts itself to sleep while all the on chip peripherals
remain active. The mode is invoked by software. The content of the on-chip
RAM and all the special functions registers remain unchanged during this
mode. The idle mode can be terminated by any enabled interrupt or by a
hardware reset.

Note that when idle mode is terminated by a hardware reset, the device
normally resumes program execution from where it left off, up to two
machine cycles before the internal reset algorithm takes control. On-chip
hardware inhibits access to internal RAM in this event, but access to the port
pins is not inhibited. To eliminate the possibility of an unexpected write to a
port pin when idle mode is terminated by a reset, the instruction following
the one that invokes idle mode should not write to a port pin or to external
memory.

Power-down Mode

In the power-down mode, the oscillator is stopped, and the instruction that
invokes power-down is the last instruction executed. The on-chip RAM and
Special Function Registers retain their values until the power-down mode is
terminated. The only exit from power-down is a hardware reset. Reset
redefines the SFR s but does not change the on-chip RAM. The reset should
not be cultivated before VCC is restored to its normal operating level and
must be held active long enough to allow the oscillator to restart and
stabilize.
AC Characteristics

Under operating conditions, load capacitance for Port 0, ALE/PROG, and


PSEN = 100 pF; load capacitance for all other
outputs = 80 pF.
Note: 1. AC Inputs during testing are driven at VCC - 0.5V
for a logic 1 and 0.45V for a logic 0. Timing measurements
are made at VIH min. for a logic 1 and VIL max.
for a logic 0.

Float Waveforms(1)

Note: 1. For timing purposes, a port pin is no longer floating


when a 100 mV change from load voltage occurs. A
port pin begins to float when a 100 mV change from
the loaded VOH/VOL level occurs.
Component description
Transformers

A transformer is a device that transfers electrical energy from one circuit to


another by magnetic coupling without requiring relative motion between its
parts. It usually comprises two or more coupled windings, and, in most
cases, a core to concentrate magnetic flux. A transformer operates from the
application of an alternating voltage to one winding, which creates a time-
varying magnetic flux in the core. This varying flux induces a voltage in the
other windings. Varying the relative number of turns between primary and
secondary windings determines the ratio of the input and output voltages,
thus transforming the voltage by stepping it up or down between circuits.

2.8.1Basic principle

The principles of the transformer are illustrated by consideration of a


hypothetical ideal transformer consisting of two windings of zero resistance
around a core of negligible reluctance. A voltage applied to the primary
winding causes a current, which develops a magnetomotive force (MMF) in
the core. The current required to create the MMF is termed the magnetising
current; in the ideal transformer it is considered to be negligible. The MMF
drives flux around the magnetic circuit of the core.

Figure 26: The ideal transformer as a circuit element


An electromotive force (EMF) is induced across each winding, an effect
known as mutual inductance. The windings in the ideal transformer have no
resistance and so the EMFs are equal in magnitude to the measured terminal
voltages. In accordance with Faraday's law of induction, they are
proportional to the rate of change of flux:

and

Equation 7: EMF induced in primary and secondary windings

where:

and are the induced EMFs across primary and secondary windings,

and are the numbers of turns in the primary and secondary windings,

and are the time derivatives of the flux linking the primary and
secondary windings.

In the ideal transformer, all flux produced by the primary winding also links
the secondary, and so , from which the well-known transformer
equation follows:

Equation 8: Transformer Equation

The ratio of primary to secondary voltage is therefore the same as the ratio
of the number of turns; alternatively, that the volts-per-turn is the same in
both windings. The conditions that determine Transformer working in STEP
UP or STEP DOWN mode are:

Ns > Np

Equation 9: Conditon for STEP UP


Ns < Np

Equation 10: Conditon for STEP DOWN

Rectifier

A bridge rectifier is an arrangement of four diodes connected in a bridge


circuit as shown below, that provides the same polarity of output voltage for
any polarity of the input voltage. When used in its most common
application, for conversion of alternating current (AC) input into direct
current (DC) output, it is known as a bridge rectifier. The bridge rectifier
provides full wave rectification from a two wire AC input (saving the cost of
a center tapped transformer) but has two diode drops rather than one
reducing efficiency over a center tap based design for the same output
voltage.

Figure 9: Schematic of a bridge rectifier

The essential feature of this arrangement is that for both polarities of the
voltage at the bridge input, the polarity of the output is constant.

2.2.1 Basic Operation

When the input connected at the left corner of the diamond is positive with
respect to the one connected at the right hand corner, current flows to the
right along the upper colored path to the output, and returns to the input
supply via the lower one.
When the right hand corner is positive relative to the left hand corner,
current flows along the upper colored path and returns to the supply via the
lower colored path.
Figure 10: AC, half-wave and full wave rectified signals

In each case, the upper right output remains positive with


respect to the lower right one. Since this is true whether the
input is AC or DC, this circuit not only produces DC power
when supplied with AC power: it also can provide what is
sometimes called "reverse polarity protection". That is, it
permits normal functioning when batteries are installed
backwards or DC input-power supply wiring "has its wires
crossed" (and protects the circuitry it powers against
damage that might occur without this circuit in place).
Prior to availability of integrated electronics, such a bridge
rectifier was always constructed from discrete components.
Since about 1950, a single four-terminal component
containing the four diodes connected in the bridge
configuration became a standard commercial component
and is now available with various voltage and current
ratings.

2.2.2 Output Smoothing

For many applications, especially with single phase AC


where the full-wave bridge serves to convert an AC input
into a DC output, the addition of a capacitor may be
important because the bridge alone supplies an output
voltage of fixed polarity but pulsating magnitude.

Figure 11: Bridge Rectifier with smoothen output

The function of this capacitor, known as a 'smoothing


capacitor' (see also filter capacitor) is to lessen the variation
in (or 'smooth') the raw output voltage waveform from the
bridge. One explanation of 'smoothing' is that the capacitor
provides a low impedance path to the AC component of the
output, reducing the AC voltage across, and AC current
through, the resistive load. In less technical terms, any drop
in the output voltage and current of the bridge tends to be
cancelled by loss of charge in the capacitor. This charge
flows out as additional current through the load. Thus the
change of load current and voltage is reduced relative to
what would occur without the capacitor. Increases of voltage
correspondingly store excess charge in the capacitor, thus
moderating the change in output voltage / current.

The capacitor and the load resistance have a typical time


constant = RC where C and R are the capacitance and load
resistance respectively. As long as the load resistor is large
enough so that this time constant is much longer than the
time of one ripple cycle, the above configuration will produce
a well smoothed DC voltage across the load resistance. In
some designs, a series resistor at the load side of the
capacitor is added. The smoothing can then be improved by
adding additional stages of capacitorresistor pairs, often
done only for sub-supplies to critical high-gain circuits that
tend to be sensitive to supply voltage noise.
Voltage Regulators

A voltage regulator is an electrical regulator designed to


automatically maintain a constant voltage level. It may use
an electromechanical mechanism, or passive or active
electronic components. Depending on the design, it may be
used to regulate one or more AC or DC voltages. With the
exception of shunt regulators, all voltage regulators operate
by comparing the actual output voltage to some internal
fixed reference voltage. Any difference is amplified and used
to control the regulation element. This forms a negative
feedback servo control loop. If the output voltage is too low,
the regulation element is commanded to produce a higher
voltage. For some regulators if the output voltage is too
high, the regulation element is commanded to produce a
lower voltage; however, many just stop sourcing current and
depend on the current draw of whatever it is driving to pull
the voltage back down. In this way, the output voltage is
held roughly constant. The control loop must be carefully
designed to produce the desired tradeoff between stability
and speed of response.

2.4.1 LM317 (3-Terminal Adjustable Regulator)

Description
The LM317 is an adjustable three-terminal positive-voltage
regulator capable of supplying more than 1.5 A over an
output-voltage range of 1.2 V to 37 V. It is exceptionally easy
to use and requires only two external resistors to set the
output voltage. Furthermore, both line and load regulation
are better than standard fixed
regulators. The LM317 is packaged in the KC (TO-220AB) and
KTE packages, which are easy to handle and use. In addition
to having higher performance than fixed regulators, this
device includes on-chip current limiting, thermal overload
protection, and safe-operating-area protection. All overload
protection remains fully functional, even if the ADJUST
terminal is disconnected.

Figure 16: TOP IC view of LM 317

The LM317 is versatile in its applications, including uses in


programmable output regulation and local on-card
regulation. Or, by connecting a fixed resistor between the
ADJUST and OUTPUT terminals, the LM317 can function as a
precision current regulator. An optional output capacitor can
be added to improve transient response. The ADJUST
terminal can be bypassed to achieve very high ripple-
rejection ratios, which are difficult to achieve with standard
three-terminal regulators. The LM317 is characterized for
operation over the
virtual junction temperature range of 0C to 125C.
Figure 17: Adjustable Voltage Regulator

2.4.2 LM7805 (3-Terminal Fixed Voltage Regulator)

The MC78XX/LM78XX/MC78XXA series of three terminal


positive regulators are available in the
TO-220/D-PAK package and with several fixed output
voltages, making them useful in a wide range of
applications. Each type employs internal current limiting,
thermal shut down and safe operating area protection,
making it essentially indestructible. If adequate heat sinking
is provided, they can deliver over 1A output current.
Although designed primarily as fixed voltage regulators,
these devices can be used with external components to
obtain adjustable voltages and currents.

Figure 18: Internal block Diagram


Figure 19 : Fixed Output Regulator

Features

Output Current up to 1A
Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24V
Thermal Overload Protection
Short Circuit Protection
Output Transistor Safe Operating Area Protection
Liquid crystal display(LCD)

A liquid crystal display (commonly abbreviated LCD) is a thin, flat display


device made up of any number of color or monochrome pixels arrayed in
front of a light source or reflector. It is prized by engineers because it uses
very small amounts of electric power, and is therefore suitable for use in
battery-powered electronic devices. Each pixel of an LCD consists of a layer
of perpendicular molecules aligned between two transparent electrodes, and
two polarizing filters, the axes of polarity of which are perpendicular to each
other. With no liquid crystal between the polarizing filters, light passing
through one filter would be blocked by the electrodes. The surfaces of the
electrodes that are in contact with the liquid crystal material are treated so as
to align the liquid crystal molecules in a particular direction. This treatment
typically consists of a thin polymer layer that is unidirectionally rubbed
using a cloth (the direction of the liquid crystal alignment is defined by the
direction of rubbing). Before applying an electric field, the orientation of the
liquid crystal molecules is determined by the alignment at the surfaces. In a
twisted nematic device (the most common liquid crystal device), the surface
alignment directions at the two electrodes are perpendicular, and so the
molecules arrange themselves in a helical structure, or twist. Because the
liquid crystal material is birefringent, light passing through one polarizing
filter is rotated by the liquid crystal helix as it passes through the liquid
crystal layer, allowing it to pass through the second polarized filter. Half of
the light is absorbed by the first polarizing filter, but otherwise the entire
assembly is transparent. When a voltage is applied across the electrodes, a
torque acts to align the liquid crystal molecules parallel to the electric field,
distorting the helical structure (this is resisted by elastic forces since the
molecules are constrained at the surfaces). This reduces the rotation of the
polarization of the incident light, and the device appears gray. If the applied
voltage is large enough, the liquid crystal molecules are completely
untwisted and the polarization of the incident light is not rotated at all as it
passes through the liquid crystal layer. This light will then be polarized
perpendicular to the second filter, and thus be completely blocked and the
pixel will appear black. By controlling the voltage applied across the liquid
crystal layer in each pixel, light can be allowed to pass through in varying
amounts, correspondingly illuminating the pixel. With a twisted nematic
liquid crystal device it is usual to operate the device between crossed
polarizers, such that it appears bright with no applied voltage. With this
setup, the dark voltage-on state is uniform. The device can be operated
between parallel polarizers, in which case the bright and dark states are
reversed.

Both the liquid crystal material and the alignment layer material contain
ionic compounds. If an electric field of one particular polarity is applied for
a long period of time, this ionic material is attracted to the surfaces and
degrades the device performance. This is avoided by applying either an
alternating current, or by reversing the polarity of the electric field as the
device is addressed (the response of the liquid crystal layer is identical,
regardless of the polarity of the applied field). When a large number of
pixels is required in a display, it is not feasible to drive each directly since
then each pixel would require independent electrodes. Instead, the display is
multiplexed. In a multiplexed display, electrodes on one side of the display
are grouped and wired together (typically in columns), and each group gets
its own voltage source. On the other side, the electrodes are also grouped
(typically in rows), with each group getting a voltage sink. The groups are
designed so each pixel has a unique, unshared combination of source and
sink. The electronics or the software driving the electronics then turns on
sinks in sequence, and drives sources for the pixels of each sink.
Figure 20:LCD Pictorial View

2.5.1 LCD Standards

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.

2.5.2 44780 Standard

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 make
sure this line is low (0) and then set the other two control lines and/or put
data on the data bus. When the other lines are completely ready, bring EN
high (1) and wait for the minimum amount of time required by the LCD
datasheet (this varies from LCD to LCD), and end by bringing it low (0)
again.
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
sould 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.

2.5.3 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.A sample psuedo-schematic of how the LCD will be connected to the
8051.

Figure 21: Schematic Of LCD interfacing with microcontroller

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 insutrction:
SETB RW

2.5.4 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.
Thus, before we interact in any way with the LCD we will always bring the
EN line low with the following instruction:
CLR 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 high:
SETB EN

The line must be left high for the amount of time required by the LCD as
specified in its datasheet. This is normally on the order of about 250
nanoseconds, but check the datasheet. In the case of a typical 8051 running
at 12 MHz, an instruction requires 1.08 microseconds to execute so the EN
line can be brought low the very next instruction. However, faster
microcontrollers (such as the DS89C420 which executes an instruction in 90
nanoseconds given an 11.0592 Mhz crystal) will require a number of NOPs
to create a delay while EN is held high. The number of NOPs that must be
inserted depends on the microcontroller you are using and the crystal you
have selected. The instruction is executed by the LCD at the moment the EN
line is brought low with a final CLR EN instruction.
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.

2.5.5 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:


WAIT_LCD:
CLR 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
SETB EN ; Clock out command to LCD
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.

2.5.6 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 8-bit 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:
CLR RS
MOV DATA, #38h
SETB EN
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 the next code segment is:


CLR RS
MOV DATA, #0Eh
SETB EN
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.
CLR RS
MOV DATA, #06h
SETB EN
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:
CLR RS
MOV DATA, #38h
SETB EN
CLR EN
LCALL WAIT_LCD
CLR RS
MOV DATA, #0Eh
SETB EN
CLR EN
LCALL WAIT_LCD
CLR RS
MOV DATA, #06h
SETB EN
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.

2.5.7 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 opreation
after the LCD has been initialiezd.

An LCD command exists to accomplish this function. Not suprisingly, 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:
CLR RS
MOV DATA, #01h
SETB EN
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.
2.5.8 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 RS
MOV DATA, A
SETB EN
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?

2.5.9 A Program: "HELLO WORLD"

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'
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.
2.5.10 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 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 display the text on the LCD itself.
This memory can be represented with the following "memory map":

Figure 22: Memory Mapping in LCD

In the above memory map, the area shaded in blue is the visible display. As
you can see, it measures 16 characters per line by 2 lines. The numbers in
each box is the memory address that corresponds to that screen position.
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 = CAh. Thus sending the command CAh to the LCD will
position the cursor on the second line at the tenth character position:

CLR RS
MOV DATA,#0CAh
SETB EN
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
CLR RS
MOV DATA,#0CAh
SETB EN
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

Circuit symbol for a relay

RELAYS

Relays
Photographs Rapid Electronics
A relay is an electrically operated switch. Current flowing through the coil
of the relay creates a magnetic field, which attracts a lever and changes the
switch contacts. The coil current can be on or off so relays have two switch
positions and they are double throw (changeover) switches.
Relays allow one circuit to switch a second circuit that can be completely
separate from the first. For example a low voltage battery circuit can use a
relay to switch a 230V AC mains circuit. There is no electrical connection
inside the relay between the two circuits, the link is magnetic and
mechanical.
The coil of a relay passes a relatively large current, typically 30mA for a
12V relay, but it can be as much as 100mA for relays designed to operate
from lower voltages. Most ICs (chips) cannot provide this current and a
transistor is usually used to amplify the small IC current to the larger value
required for the relay coil. The maximum output current for the popular 555
timer IC is 200mA so these devices can supply relay coils directly without
amplification.
Relays are usually SPDT or DPDT but they can have many more sets
of switch contacts, for example relays with 4 sets of changeover contacts are
readily available. For further information about switch contacts and the
terms used to describe them please see the page on switches.
Most relays are designed for PCB mounting but you can solder wires
directly to the pins providing you take care to avoid melting the plastic case
of the relay.
The supplier's catalogue should show you the relay's connections. The coil
will be obvious and it may be connected either way round. Relay coils
produce brief high voltage 'spikes' when they are switched off and this can
destroy transistors and ICs in the circuit. To prevent damage you must
connect a protection diode across the relay coil.
The animated picture shows a working relay with its coil and switch
contacts. You can see a lever on the left being attracted by magnetism when
the coil is switched on. This lever moves the switch contacts. There is one
set of contacts (SPDT) in the foreground and another behind them, making
the relay DPDT.

The relay's switch connections are usually labeled COM, NC and NO:
COM = Common, always connect to this, it is the moving part of the
switch.
NC = Normally Closed, COM is connected to this when the relay coil
is off.
NO = Normally Open, COM is connected to this when the relay coil is
on.
Connect to COM and NO if you want the switched circuit to be on
when the relay coil is on.
Connect to COM and NC if you want the switched circuit to be on
when the relay coil is off.
Choosing a relay

You need to consider several features when choosing a relay:

1. Physical size and pin arrangement


If you are choosing a relay for an existing PCB you will need to
ensure that its dimensions and pin arrangement are suitable. You
should find this information in the supplier's catalogue.

2. Coil voltage
The relay's coil voltage rating and resistance must suit the circuit
powering the relay coil. Many relays have a coil rated for a 12V
supply but 5V and 24V relays are also readily available. Some relays
operate perfectly well with a supply voltage which is a little lower
than their rated value.

3. Coil resistance
The circuit must be able to supply the current required by the relay
coil. You can use Ohm's law to calculate the current:
Supply voltage
Relay coil current =
Coil resistance
For example: A 12V supply relay with a coil resistance of 400 passes a
current of 30mA. This is OK for a 555 timer IC (maximum output current
200mA), but it is too much for most ICs and they will require a transistor to
amplify the current.

4. Switch ratings (voltage and current)


The relay's switch contacts must be suitable for the circuit they are to
control. You will need to check the voltage and current ratings. Note
that the voltage rating is usually higher for AC, for example: "5A at
24V DC or 125V AC".

5. Switch contact arrangement (SPDT, DPDT etc)


Most relays are SPDT or DPDT which are often described as "single
pole changeover" (SPCO) or "double pole changeover" (DPCO).
COMPARISON BETWEEN TRANSISTORS & RELAYS

Advantages of relays:

Relays can switch AC and DC, transistors can only switch DC.
Relays can switch high voltages, transistors cannot.
Relays are a better choice for switching large currents (> 5A).
Relays can switch many contacts at once.

Disadvantages of relays:

Relays are bulkier than transistors for switching small currents.


Relays cannot switch rapidly (except reed relays), transistors can
switch many times per second.
Relays use more power due to the current flowing through their coil.
Relays require more current than many chips can provide, so a low power
transistor may be needed to switch the current for the relay's coil.

Crystal Oscillator

It is often required to produce a signal whose frequency or pulse rate is very


stable and exactly known. This is important in any application where
anything to do with time or exact measurement is
crucial. It is relatively simple to make an oscillator that produces some sort
of a signal, but another matter to produce one of relatively precise frequency
and stability. AM radio stations must have a carrier frequency accurate
within 10Hz of its assigned frequency, which may be from 530 to 1710 kHz.
SSB radio systems used in the HF range (2-30 MHz) must be within 50 Hz
of channel frequency for acceptable voice quality, and within 10 Hz for best
results. Some digital modes used in weak signal communication may require
frequency stability of less than 1 Hz within a period of several minutes. The
carrier frequency must be known to fractions of a hertz in some cases. An
ordinary quartz watch must have an oscillator accurate to better than a few
parts per million. One part per million will result in an error of slightly less
than one half second a day, which would be about 3 minutes a year. This
might not sound like much, but an error of 10 parts per million would result
in an error of about a half an hour per year. A clock such as this would need
resetting about once a month, and more often if you are the punctual type. A
programmed VCR with a clock this far off could miss the recording of part
of a TV show. Narrow band SSB communications at VHF and UHF
frequencies still need 50 Hz frequency accuracy. At 440 MHz, this is
slightly more than 0.1 part per million.
Ordinary L-C oscillators using conventional inductors and capacitors can
achieve typically 0.01 to 0.1 percent frequency stability, about 100 to 1000
Hz at 1 MHz. This is OK for AM and FM broadcast receiver applications
and in other low-end analog receivers not requiring high tuning accuracy. By
careful design and component selection, and with rugged mechanical
construction, .01 to 0.001%, or even better (.0005%) stability can be
achieved. The better figures will undoubtedly employ temperature
compensation components and regulated power supplies, together with
environmental control (good ventilation and ambient temperature regulation)
and battleship mechanical construction. This has been done in some
communications receivers used by the military and commercial HF
communication receivers built in the 1950-1965 era, before the widespread
use of digital frequency synthesis. But these receivers were extremely
expensive, large, and heavy. Many modern consumer grade AM, FM, and
shortwave receivers employing crystal controlled digital frequency synthesis
will do as well or better from a frequency stability standpoint.
An oscillator is basically an amplifier and a frequency selective feedback
network (Fig 1). When, at a particular frequency, the loop gain is unity or
more, and the total phaseshift at this frequency is zero, or some multiple of
360 degrees, the condition for oscillation is satisfied, and the circuit will
produce a periodic waveform of this frequency. This is usually a sine wave,
or square wave, but triangles, impulses, or other waveforms can be
produced. In fact, several different waveforms often are simultaneously
produced by the same circuit, at different points. It is also possible to have
several frequencies produced as well, although this is generally undesirable.

CAPACITOR

A capacitor or condenser is a passive electronic component consisting of a


pair of conductors separated by a dielectric (insulator). When a potential
difference (voltage) exists across the conductors, an electric field is present
in the dielectric. This field stores energy and produces a mechanical force
between the conductors. The effect is greatest when there is a narrow
separation between large areas of conductor, hence capacitor conductors are
often called plates.

An ideal capacitor is characterized by a single constant value, capacitance,


which is measured in farads. This is the ratio of the electric charge on each
conductor to the potential difference between them. In practice, the dielectric
between the plates passes a small amount of leakage current. The conductors
and leads introduce an equivalent series resistance and the dielectric has an
electric field strength limit resulting in a breakdown voltage.
Capacitors are widely used in electronic circuits to block the flow of direct
current while allowing alternating current to pass, to filter out interference,
to smooth the output of power supplies, and for many other purposes. They
are used in resonant circuits in radio frequency equipment to select particular
frequencies from a signal with many frequencies.

Theory of operation
Main article: Capacitance

Charge separation in a parallel-plate capacitor causes an internal electric


field. A dielectric (orange) reduces the field and increases the capacitance.

A simple demonstration of a parallel-plate capacitor

A capacitor consists of two conductors separated by a non-conductive


region.The non-conductive substance is called the dielectric medium,
although this may also mean a vacuum or a semiconductor depletion region
chemically identical to the conductors. A capacitor is assumed to be self-
contained and isolated, with no net electric charge and no influence from an
external electric field. The conductors thus contain equal and opposite
charges on their facing surfaces, and the dielectric contains an electric field.
The capacitor is a reasonably general model for electric fields within electric
circuits.

An ideal capacitor is wholly characterized by a constant capacitance C,


defined as the ratio of charge Q on each conductor to the voltage V between
them

Sometimes charge buildup affects the mechanics of the capacitor, causing


the capacitance to vary. In this case, capacitance is defined in terms of
incremental changes:

In SI units, a capacitance of one farad means that one coulomb of charge on


each conductor causes a voltage of one volt across the device.

Energy storage

Work must be done by an external influence to move charge between the


conductors in a capacitor. When the external influence is removed, the
charge separation persists and energy is stored in the electric field. If charge
is later allowed to return to its equilibrium position, the energy is released.
The work done in establishing the electric field, and hence the amount of
energy stored, is given by:

Current-voltage relation

The current i(t) through a component in an electric circuit is defined as the


rate of change of the charge q(t) that has passed through it. Physical charges
cannot pass through the dielectric layer of a capacitor, but rather build up in
equal and opposite quantities on the electrodes: as each electron accumulates
on the negative plate, one leaves the positive plate. Thus the accumulated
charge on the electrodes is equal to the integral of the current, as well as
being proportional to the voltage (as discussed above). As with any
antiderivative, a constant of integration is added to represent the initial
voltage v (t0). This is the integral form of the capacitor equation,

Taking the derivative of this, and multiplying by C, yields the derivative


form,[12]

The dual of the capacitor is the inductor, which stores energy in the
magnetic field rather than the electric field. Its current-voltage relation is
obtained by exchanging current and voltage in the capacitor equations and
replacing C with the inductance L.

DC circuits

A simple resistor-capacitor circuit demonstrates charging of a capacitor.

A series circuit containing only a resistor, a capacitor, a switch and a


constant DC source of voltage V0 is known as a charging circuit. If the
capacitor is initially uncharged while the switch is open, and the switch is
closed at t = 0, it follows from Kirchhoff's voltage law that

Taking the derivative and multiplying by C, gives a first-order differential


equation,
At t = 0, the voltage across the capacitor is zero and the voltage
across the resistor is V0. The initial current is then i (0) =V0 /R. With this
assumption, the differential equation yields

where 0 = RC is the time constant of the system.

As the capacitor reaches equilibrium with the source voltage, the voltage
across the resistor and the current through the entire circuit decay
exponentially. The case of discharging a charged capacitor likewise
demonstrates exponential decay, but with the initial capacitor voltage
replacing V0 and the final voltage being zero.

RESISTOR
Resistors are used to limit the value of current in a circuit. Resistors offer
opposition to the flow of current. They are expressed in ohms for which the
symbol is . Resistors are broadly classified as
(1) Fixed Resistors
(2) Variable Resistors

Fixed Resistors :

The most common of low wattage, fixed type resistors is the molded-carbon
composition resistor. The resistive material is of carbon clay composition.
The leads are made of tinned copper. Resistors of this type are readily
available in value ranging from few ohms to about 20M, having a
tolerance range of 5 to 20%. They are quite inexpensive. The relative size of
all fixed resistors changes with the wattage rating.
Another variety of carbon composition resistors is the metalized
type. It is made by deposition a homogeneous film of pure carbon over a
glass, ceramic or other insulating core. This type of film-resistor is
sometimes called the precision type, since it can be obtained with an
accuracy of 1%.

Lead Tinned Copper Material

Colour Coding Molded Carbon Clay Composition

Fixed Resistor

A Wire Wound Resistor :

It uses a length of resistance wire, such as nichrome. This wire is wounded


on to a round hollow porcelain core. The ends of the winding are attached to
these metal pieces inserted in the core. Tinned copper wire leads are attached
to these metal pieces. This assembly is coated with an enamel coating
powdered glass. This coating is very smooth and gives mechanical
protection to winding. Commonly available wire wound resistors have
resistance values ranging from 1 to 100K, and wattage rating up to about
200W.

Coding Of Resistor :

Some resistors are large enough in size to have their resistance printed on
the body. However there are some resistors that are too small in size to have
numbers printed on them. Therefore, a system of colour coding is used to
indicate their values. For fixed, moulded composition resistor four colour
bands are printed on one end of the outer casing. The colour bands are
always read left to right from the end that has the bands closest to it. The
first and second band represents the first and second significant digits, of the
resistance value. The third band is for the number of zeros that follow the
second digit. In case the third band is gold or silver, it represents a
multiplying factor of 0.1to 0.01. The fourth band represents the
manufactures tolerance.
RESISTOR COLOUR CHART

0 black 0 black 0 black 0 black


1 brown 1 brown 1 brown 1 brown
2 red 2 red 2 red 2 red
3 orange 3 orange 3 orange 3 orange
4 yellow 4 yellow
5 green 4 yellow 4 yellow
5 green 5 green 5 green
6 blue 6 blue 6 blue 6 blue
7 purple 7 purple 7 purple 7 purple
8 silver 8 silver 8 silver 8 silver
9 white 9 white 9 white 9 white

For example, if a resistor has a colour band sequence: yellow, violet, orange
and gold

Then its range will be

Yellow=4, violet=7, orange=10, gold=5% =47K 5% =2.35K

Most resistors have 4 bands:


The first band gives the first digit.
The second band gives the second digit.
The third band indicates the number of zeros.
The fourth band is used to show the tolerance (precision) of the
resistor.
This resistor has red (2), violet (7), yellow (4 zeros) and gold bands.
So its value is 270000 = 270 k .

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

For example:

red, violet, gold bands represent 27 0.1 = 2.7


blue, green, silver bands represent 56 0.01 = 0.56

The fourth band of the colour code shows the tolerance of a resistor.
Tolerance is the precision of the resistor and it is given as a percentage. For
example a 390 resistor with a tolerance of 10% will have a value within
10% of 390 , between 390 - 39 = 351 and 390 + 39 = 429 (39 is 10% of
390).

A special colour code is used for the fourth band tolerance:


silver 10%, gold 5%, red 2%, brown 1%.
If no fourth band is shown the tolerance is 20%.

VARIABLE RESISTOR:In electronic circuits, sometimes it becomes


necessary to adjust the values of currents and voltages. For n example it is
often desired to change the volume of sound, the brightness of a television
picture etc. Such adjustments can be done by using variable resistors.
Although the variable resistors are usually called rheostats in
other applications, the smaller variable resistors commonly used in
electronic circuits are called potentiometers.

Resistor shorthand:
Resistor values are often written on circuit diagrams using a code system
which avoids using a decimal point because it is easy to miss the small dot.
Instead the letters R, K and M are used in place of the decimal point. To read
the code: replace the letter with a decimal point, then multiply the value by
1000 if the letter was K, or 1000000 if the letter was M. The letter R means
multiply by 1.
For example:
560R means 560
2K7 means 2.7 k = 2700
39K means 39 k
1M0 means 1.0 M = 1000 k
Power Ratings of Resistors

Electrical energy is converted to heat


when current flows through a resistor.
Usually the effect is negligible, but if
the resistance is low (or the voltage
High power resistors
across the resistor high) a large
(5W top, 25W bottom)
current may pass making the resistor
Photographs Rapid Electronics
become noticeably warm. The resistor
must be able to withstand the heating effect and resistors have power
ratings to show this.
Power ratings of resistors are rarely quoted in parts lists because for most
circuits the standard power ratings of 0.25W or 0.5W are suitable. For the
rare cases where a higher power is required it should be clearly specified in
the parts list, these will be circuits using low value resistors (less than about
300 ) or high voltages (more than 15V).
The power, P, developed in a resistor is given by:
P = I R where: P = power developed in the resistor in watts (W)
or I = current through the resistor in amps (A)
P = V / R R = resistance of the resistor in ohms ( )
V = voltage across the resistor in volts (V)

Examples:

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

TRANSISTORS

A transistor is an active device. It consists of two PN junctions formed by


sandwiching either p-type or n-type semiconductor between a pair of
opposite types.
There are two types of transistor:
1. n-p-n transistor
2. p-n-p transistor

An n-p-n transistor is composed of two n-type semiconductors


separated by a thin section of p-type. However a p-n-p type semiconductor is
formed by two p-sections separated by a thin section of n-type.
Transistor has two pn junctions one junction is forward biased and
other is reversed biased. The forward junction has a low resistance path
whereas a reverse biased junction has a high resistance path.
The weak signal is introduced in the low resistance circuit and output
is taken from the high resistance circuit. Therefore a transistor transfers a
signal from a low resistance to high resistance.
Transistor has three sections of doped semiconductors. The section on
one side is emitter and section on the opposite side is collector. The middle
section is base.

Emitter : The section on one side that supplies charge carriers is called
emitter. The emitter is always forward biased w.r.t. base.

Collector : The section on the other side that collects the charge is called
collector. The collector is always reversed biased.
Base : The middle section which forms two pn-junctions between the
emitter and collector is called base.

A transistor raises the strength of a weak signal and thus acts as an


amplifier. The weak signal is applied between emitter-base junction and
output is taken across the load Rc connected in the collector circuit. The
collector current flowing through a high load resistance Rc produces a large
voltage across it. Thus a weak signal applied in the input appears in the
amplified form in the collector circuit.

Heat sink

Waste heat is produced in transistors due to the current flowing through


them. Heat sinks are needed for power transistors because they pass large
currents. If you find that a transistor is becoming too hot to touch it certainly
needs a heat sink! The heat sink helps to dissipate (remove) the heat by
transferring it to the surrounding air.
CONNECTORS

Connectors are basically used for interface between two. Here we


use connectors for having interface between PCB and 8051
Microprocessor Kit.
There are two types of connectors they are male and female. The one,
which is with pins inside, is female and other is male.
These connectors are having bus wires with them for connection.
For high frequency operation the average circumference of a coaxial cable
must be limited to about one wavelength, in order to reduce multimodal
propagation and eliminate erratic reflection coefficients, power losses, and
signal distortion. The standardization of coaxial connectors during World
War II was mandatory for microwave operation to maintain a low reflection
coefficient or a low voltage standing wave ratio.
Seven types of microwave coaxial connectors are as follows:
1.APC-3.5
2.APC-7
3.BNC
4.SMA
5.SMC
6.TNC
7.Type N

LED (LIGHT EMITTING DIODE)

A junction diode, such as LED, can emit light or exhibit electro


luminescence. Electro luminescence is obtained by injecting minority
carriers into the region of a pn junction where radiative transition takes
place. In radiative transition, there is a transition of electron from the
conduction band to the valence band, which is made possibly by emission of
a photon. Thus, emitted light comes from the hole electron recombination.
What is required is that electrons should make a transition from higher
energy level to lower energy level releasing photon of wavelength
corresponding to the energy difference associated with this transition. In
LED the supply of high-energy electron is provided by forward biasing the
diode, thus injecting electrons into the n-region and holes into p-region.
The pn junction of LED is made from heavily doped material. On
forward bias condition, majority carriers from both sides of the junction
cross the potential barrier and enter the opposite side where they are then
minority carrier and cause local minority carrier population to be larger than
normal. This is termed as minority injection. These excess minority carrier
diffuse away from the junction and recombine with majority carriers.
In LED, every injected electron takes part in a radiative recombination
and hence gives rise to an emitted photon. Under reverse bias no carrier
injection takes place and consequently no photon is emitted. For direct
transition from conduction band to valence band the emission wavelength.
In practice, every electron does not take part in radiative recombination
and hence, the efficiency of the device may be described in terms of the
quantum efficiency which is defined as the rate of emission of photons
divided by the rate of supply of electrons. The number of radiative
recombination, that take place, is usually proportional to the carrier injection
rate and hence to the total current flowing.

LED Materials:

One of the first materials used for LED is GaAs. This is a direct band
gap material, i.e., it exhibits very high probability of direct transition
of electron from conduction band to valence band. GaAs has E= 1.44
eV. This works in the infrared region.
GaP and GaAsP are higher band gap materials. Gallium phosphide is an
indirect band gap semiconductor and has poor efficiency because band to
band transitions are not normally observed.
Gallium Arsenide Phosphide is a tertiary alloy. This material has a special
feature in that it changes from being direct band gap material.
Blue LEDs are of recent origin. The wide band gap materials such as GaN
are one of the most promising LEDs for blue and green emission. Infrared
LEDs are suitable for optical coupler applications.

ADVANTAGES OF LEDs:

1. Low operating voltage, current, and power consumption makes


Leds compatible with electronic drive circuits. This also makes
easier interfacing as compared to filament incandescent and
electric discharge lamps.
2. The rugged, sealed packages developed for LEDs exhibit high
resistance to mechanical shock and vibration and allow LEDs to be
used in severe environmental conditions where other light sources
would fail.
3. LED fabrication from solid-state materials ensures a longer operating
lifetime, thereby improving overall reliability and lowering
maintenance costs of the equipment in which they are installed.
4. The range of available LED colours-from red to orange, yellow, and
green-provides the designer with added versatility.
5. LEDs have low inherent noise levels and also high immunity to
externally generated noise.
6. Circuit response of LEDs is fast and stable, without surge currents or
the prior warm-up, period required by filament light sources.
7. LEDs exhibit linearity of radiant power output with forward current
over a wide range.

LEDs have certain limitations such as:

1. Temperature dependence of radiant output power and wave


length.
2. Sensitivity to damages by over voltage or over current.
3. Theoretical overall efficiency is not achieved except in special
cooled or pulsed conditions.
Buzzer

It is an electronic signaling device which produces buzzing sound. It is


commonly used in automobiles, phone alarm systems and household
appliances. Buzzers work in the same manner as an alarm works. They are
generally equipped with sensors or switches connected to a control unit and
the control unit illuminates a light on the appropriate button or control panel,
and sound a warning in the form of a continuous or intermittent buzzing or
beeping sound.
The word "buzzer" comes from the rasping noise that buzzers made when
they were electromechanical devices, operated from stepped-down AC line
voltage at 50 or 60 cycles.

Typical uses of buzzers and beepers include alarms, timers and confirmation
of user input such as a mouse click or keystroke.

2.9.1Types of Buzzers
The different types of buzzers are electric buzzers, electronic buzzers,
mechanical buzzers, electromechanical, magnetic buzzers, piezoelectric
buzzers and piezo buzzers.

(i) Electric buzzers


A basic model of electric buzzer usually consists of simple circuit
components such as resistors, a capacitor and 555 timer IC or an integrated
circuit with a range of timer and multi-vibrator functions. It works through
small bits of electricity vibrating together which causes sound.

(ii) Electronic buzzers


An electronic buzzer comprises an acoustic vibrator comprised of a circular
metal plate having its entire periphery rigidly secured to a support, and a
piezoelectric element adhered to one face of the metal plate. A driving
circuit applies electric driving signals to the vibrator to vibrationally drive it
at a 1/N multiple of its natural frequency, where N is an integer, so that the
vibrator emits an audible buzzing sound. The metal plate is preferably
mounted to undergo vibration in a natural vibration mode having only one
nodal circle. The drive circuit includes an inductor connected in a closed
loop with the vibrator, which functions as a capacitor, and the circuit applies
signals at a selectively variable frequency to the closed loop to accordingly
vary the inductance of the inductor to thereby vary the period of oscillation
of the acoustic vibrator and the resultant frequency of the buzzing sound.

(iii) Mechanical Buzzer-


A joy buzzer is an example of a purely mechanical buzzer.

(iv) Piezo Buzzers/ Piezoelectric Buzzers

A piezo buzzer is made from two conductors that are separated by Piezo
crystals. When a voltage is applied to these crystals, they push on one
conductor and pull on the other. The result of this push and pull is a sound
wave. These buzzers can be used for many things, like signaling when a
period of time is up or making a sound when a particular button has been
pushed. The process can also be reversed to use as a guitar pickup. When a
sound wave is passed, they create an electric signal that is passed on to an
audio amplifier.
Piezo buzzers are small electronic devices that emit sounds when driven by
low voltages and currents. They are also called piezoelectric buzzers. They
usually have two electrodes and a diaphragm. The diaphragm is made from a
metal plate and piezoelectric material such as a ceramic plate.

(v) Magnetic Buzzers


Magnetic buzzers are magnetic audible signal devices with built-in
oscillating circuits. The construction combines an oscillation circuit unit
with a detection coil, a drive coil and a magnetic transducer. Transistors,
resistors, diodes and other small devices act as circuit devices for driving
sound generators. With the application of voltage, current flows to the drive
coil on primary side and to the detection coil on the secondary side. The
amplification circuit, including the transistor and the feedback circuit, causes
vibration. The oscillation current excites the coil and the unit generates an
AC magnetic field corresponding to an oscillation frequency. This AC
magnetic field magnetizes the yoke comprising the magnetic circuit. The
oscillation from the intermittent magnetization prompts the vibration
diaphragm to vibrate up and down, generating buzzer sounds through the
resonator.

In this project, a magnetic buzzer has been used.


2.9.2 Circuit of buzzer

2.9.3 Role of buzzer in this project


Buzzer in this system gives the beep when car moves inside cutting the
infrared light. Basically it generates the signal to indicate that car has entered
in the parking space.
2.10 Pressure Sensor/Switch
A pressure sensor or switch measures pressure. Pressure is usually expressed
in terms of force per unit area. A pressure sensor usually acts as a
transducer; it generates a signal as a function of the pressure imposed.

Pressure sensors can be classified in term of pressure ranges they measure, temperature
ranges of operation, and most importantly the type of pressure they measure. In terms of
pressure type, pressure sensors can be divided into five categories:
1) Absolute pressure sensor
This sensor measures the pressure relative to perfect vaccum pressure.

2) Gauge pressure sensor


This sensor is used in different applications because it can be calibrated to measure the
pressure relative to a given atmospheric pressure at a given location.

3)Vaccum pressure sensor

This sensor is used to measure pressure less than the atmospheric pressure at a given
location.
4) Differential pressure sensor
This sensor measures the difference between two or more pressures introduced as inputs to
the sensing unit.

5) Sealed pressure sensor


This sensor is the same as the gauge pressure sensor except that it is previously calibrated
by manufacturers to measure pressure relative to sea level pressure.

Fig: Operation of pressure switch

1.10.1 Pressure Sensing Technology


There are two basic categories of analog pressure sensors:
(i) Force collector types - These types of electronic pressure sensors generally use a force
collector (such a diaphragm, piston, bourdon tube, or bellows) to measure strain (or
deflection) due to applied force (pressure) over an area.
(ii) Other types - These types of electronic pressure sensors use other properties (such as
density) to infer pressure of a gas, or liquid.
Here well discuss only about Force collector type of pressure sensors. Force collecting
pressure sensors are of following types:
Piezoresistive Strain Gauge-
Uses the piezoresistive effect of bonded or formed strain gauges to detect strain due to
applied pressure. Generally, the strain gauges are connected to form a wheat stone bridge
circuit to maximize the output of the sensor. This is the most commonly employed sensing
technology for general purpose pressure measurement.
Capacitive - Uses a diaphragm and pressure cavity to create a variable capacitor to detect
strain due to applied pressure. Common technologies use metal, ceramic, and silicon
diaphragms. Generally, these technologies are most applied to low pressures (Absolute,
Differential and Gauge)
Electromagnetic - Measures the displacement of a diaphragm by means of changes in
inductance (reluctance), LVDT, Hall Effect, or by eddy current principal.
Piezoelectric - Uses the piezoelectric effect in certain materials such as quartz to measure
the strain upon the sensing mechanism due to pressure. This technology is commonly
employed for the measurement of highly dynamic pressures.
Optical - Uses the physical change of an optical fiber to detect strain due to applied
pressure.
Potentiometric - Uses the motion of a wiper along a resistive mechanism to detect the
strain caused by applied pressure .
DIODE
ACTIVE COMPONENT-

Active component are those component for not any other component
are used its operation. I used in this project only function diode, these
component description are described as bellow.

SEMICONDUCTOR DIODE-

A PN junctions is known as a semiconductor or crystal diode.A


crystal diode has two terminal when it is connected in a circuit one thing is
decide is weather a diode is forward or reversed biased. There is a easy rule
to ascertain it. If the external CKT is trying to push the conventional current
in the direction of error, the diode is forward biased. One the other hand if
the conventional current is trying is trying to flow opposite the error head,
the diode is reversed biased putting in simple words.

1. If arrowhead of diode symbol is positive W.R.T Bar of the


symbol, the diode is forward biased.
2.The arrowhead of diode symbol is negative W.R.T bar , the diode is
the reverse bias.
When we used crystal diode it is often necessary to know
that which end is arrowhead and which end is bar. So
following method are available.

1.Some manufactures actually point the symbol on the


body of the diode e. g By127 by 11 4 crystal diode
manufacture by b e b.

2. Sometimes red and blue marks are on the body of the crystal
diode. Red mark do not arrow wheres blue mark indicates bar e .g
oa80 crystal diode.

ZENER DIODE-
It has been already discussed that when the reverse bias on a crystal diode is
increased a critical voltage, called break down voltage. The break down or
zener voltage depends upon the amount of doping. If the diode is heavily
doped depletion layer will be thin and consequently the break down of he
junction will occur at a lower reverse voltage. On the other hand, a lightly
doped diode has a higher break down voltage, it is called zener diode
A properly doped crystal diode, which has a sharped break down voltage, is
known as a zenor diode.
APPLICATION:
Laser data transfer is used to transfer the data successfully
via two microcontrollers while displaying the data using the
LCD screen so anywhere where data is to be transfer we can
use this technology

But due to its range limitation we cannot send the data for a
long
range , only when receiver and transmitter are close to each
other
then only data can be transmitted.
CONCLUSION:
This project gave us the understanding of microcontroller and made
us realize the power of microcontroller and help us understand how
to use the laser.
The developing of this project has been a learning experience for all team
members and would prove as a milestone in their academic career. The
achievement of this project are

i. The project has achieved its set target well in Time and
Budget.

ii. Based on cutting edge technology called Embedded development


which is niche in the market today and its future is much bright.

iii. The product developed is ready for implementation and can bring
financial benefits too by sale in the market.

So, we conclude that the LASER communicationis still far away from the
perfect, but we believe we have laid the groundwork to enable it to improve
out of sight.
References

1. Mazedi, The 8051 Microcontroller and Embedded Systems, Prentice

Hall, 1ST Edition

2. Kenneth J. Ayala, The 8051 Microcontroller, Penram International

Publishing,1996, 2nd Edition

3. Some Websites :

www.alldatasheets.com

www.datasheetcatalog.com

www.electronicscircuits.com

www.scielectronics.com

www.parallax.com