You are on page 1of 60

ABSTRACT

Security is primary concern for every one. This Project describes a design of
effective security alarm system that can monitor the predefined area with different
sensors. Unauthorized access, Fire accident, wall braking, IR detection, and fire
detection can be monitored by the status of each individual sensor and is indicated
with an LED. This security system works perfectly all the time i.e., whether some one
is present in the area or not.
The burglar alarm is built around the 8051 micro controller from Atmel. This
micro controller provides all the functionality of the burglar alarm. A maximum of 8
sensors can be connected to the burglar alarm. A power supply voltage of +5 VDC is
available for each sensor at the corresponding wiring terminals.
When the alarm has been activated, the LED of the sensor that caused the
alarm will light up, or flash in the event of a cable failure. LCD display is provided in
this project so as to give the information about the sensor triggered.

SOFTWARE AND HARDWARE TOOLS:


Software Tools:
1. Keil compiler
2. Micro Flash.

Hardware Tools:
1. Microcontroller AT89S52.
2. Sensors- LM35, LDR, IR sensor, panic switch
3. Buzzer
4. LCD
5. Auto-dialer

BLOCK DIAGRAM

1. INTRODUCTION TO EMBEDDED SYSTEMS


An embedded system can be defined as a computing device that does a
specific focused job. Appliances such as the air-conditioner, VCD player, DVD
player, Printer, fax machine, mobile phone etc. are examples of embedded systems.
Each of these appliances will have a processor and special hardware to meet the
specific requirement of the application along with the embedded software that is
executed by the processor for meeting that specific requirement. The embedded
software is also called firm ware. The desktop/laptop computer is a general purpose
computer. You can use it for a variety of applications such as playing games, word
processing, accounting, software development and so on. In contrast, the software in
the embedded systems is always fixed listed below:
Embedded systems do a very specific task, they cannot be programmed to do
different things. Embedded systems have very limited resources, particularly the
memory. Generally, they do not have secondary storage devices such as the CDROM
or the floppy disk. Embedded systems have to work against some deadlines. A
specific job has to be completed within a specific time. In some embedded systems,
called real-time systems, the deadlines are stringent. Missing a deadline may cause a
catastrophe-loss of life or damage to property. Embedded systems are constrained for
power. As many embedded systems operate through a battery, the power consumption
has to be very low.
Some embedded systems have to operate in extreme environmental conditions
such as very high temperatures and humidity.

Application Areas
Nearly 99 per cent of the processors manufactured end up in embedded
systems. The embedded system market is one of the highest growth areas as these
systems are used in very market segment- consumer electronics, office automation,

industrial automation, biomedical engineering, wireless communication, data


communication, telecommunications, transportation, military and so on.
Consumer appliances: At home we use a number of embedded systems which
include digital camera, digital diary, DVD player, electronic toys, microwave oven,
remote controls for TV and air-conditioner, VCO player, video game consoles, video
recorders etc. Todays high-tech car has about 20 embedded systems for transmission
control, engine spark control, air-conditioning, navigation etc. Even wristwatches are
now becoming embedded systems. The palmtops are powerful embedded systems
using which we can carry out many general-purpose tasks such as playing games and
word processing.
Office automation: The office automation products using em embedded
systems are copying machine, fax machine, key telephone, modem, printer, scanner
etc.
Industrial automation: Today a lot of industries use embedded systems for
process control. These include pharmaceutical, cement, sugar, oil exploration, nuclear
energy, electricity generation and transmission. The embedded systems for industrial
use are designed to carry out specific tasks such as monitoring the temperature,
pressure, humidity, voltage, current etc., and then take appropriate action based on the
monitored levels to control other devices or to send information to a centralized
monitoring station. In hazardous industrial environment, where human presence has to
be avoided, robots are used, which are programmed to do specific jobs. The robots are
now becoming very powerful and carry out many interesting and complicated tasks
such as hardware assembly.
Medical electronics: Almost every medical equipment in the hospital is an
embedded system. These equipments include diagnostic aids such as ECG, EEG,
blood pressure measuring devices, X-ray scanners; equipment used in blood analysis,
radiation, colonscopy, endoscopy etc. Developments in medical electronics have
paved way for more accurate diagnosis of diseases.
Computer networking: Computer networking products such as bridges,
routers, Integrated Services Digital Networks (ISDN), Asynchronous Transfer Mode

(ATM), X.25 and frame relay switches are embedded systems which implement the
necessary data communication protocols. For example, a router interconnects two
networks. The two networks may be running different protocol stacks. The routers
function is to obtain the data packets from incoming pores, analyze the packets and
send them towards the destination after doing necessary protocol conversion. Most
networking equipments, other than the end systems (desktop computers) we use to
access the networks, are embedded systems
.
Telecommunications: In the field of telecommunications, the embedded
systems can be categorized as subscriber terminals and network equipment. The
subscriber terminals such as key telephones, ISDN phones, terminal adapters, web
cameras are embedded systems. The network equipment includes multiplexers,
multiple access systems, Packet Assemblers Dissemblers (PADs), sate11ite modems
etc. IP phone, IP gateway, IP gatekeeper etc. are the latest embedded systems that
provide very low-cost voice communication over the Internet.
Wireless technologies: Advances in mobile communications are paving way
for many interesting applications using embedded systems. The mobile phone is one
of the marvels of the last decade of the 20h century. It is a very powerful embedded
system that provides voice communication while we are on the move. The Personal
Digital Assistants and the palmtops can now be used to access multimedia services
over

the Internet. Mobile communication infrastructure such as base station

controllers, mobile switching centers are also powerful embedded systems.


Insemination: Testing and measurement are the fundamental requirements in
all scientific and engineering activities. The measuring equipment we use in
laboratories to measure parameters such as weight, temperature, pressure, humidity,
voltage, current etc. are all embedded systems. Test equipment such as oscilloscope,
spectrum analyzer, logic analyzer, protocol analyzer, radio communication test set etc.
are embedded systems built around powerful processors. Thank to miniaturization, the
test and measuring equipment are now becoming portable facilitating easy testing and
measurement in the field by field-personnel.

Security: Security of persons and information has always been a major issue.
We need to protect our homes and offices; and also the information we transmit and
store. Developing embedded systems for security applications is one of the most
lucrative businesses nowadays. Security devices at homes, offices, airports etc. for
authentication and verification are embedded systems. Encryption devices are nearly
99 per cent of the processors that are manufactured end up in~ embedded systems.
Embedded systems find applications in . every industrial segment- consumer
electronics, transportation, avionics, biomedical engineering, manufacturing, process
control and industrial automation, data communication, telecommunication, defense,
security etc. Used to encrypt the data/voice being transmitted on communication links
such as telephone lines. Biometric systems using fingerprint and face recognition are
now being extensively used for user authentication in banking applications as well as
for access control in high security buildings.
Finance: Financial dealing through cash and cheques are now slowly paving
way for transactions using smart cards and ATM (Automatic Teller Machine, also
expanded as Any Time Money) machines. Smart card, of the size of a credit card, has
a small micro-controller and memory; and it interacts with the smart card reader!
ATM machine and acts as an electronic wallet. Smart card technology has the
capability of ushering in a cashless society. Well, the list goes on. It is no exaggeration
to say that eyes wherever you go, you can see, or at least feel, the work of an
embedded system!

Advantages:
Highly sensitive
Fit and Forget system
Night Day mode sensing
Low cost and reliable circuit
Complete elimination of manpower

APPLICATIONS:
1. Infrared remote control units with high power requirements.
2. Free air transmission systems.
3. Infrared source for optical counters and card readers.
4. IR source for smoke detectors.

1.

INTRODUCTION TO MICROCONTROLLER

Microcontrollers as the name suggests are small controllers. They are like
single chip computers that are often embedded into other systems to function as
processing/controlling unit. For example the remote control you are using probably
has microcontrollers inside that do decoding and other controlling functions. They are
also used in automobiles, washing machines, microwave ovens, toys ... etc, where
automation is needed.
Micro-controllers

are

useful

to

the

extent

that

they

communicate with other devices, such as sensors, motors, switches, keypads, displays,
memory and even other micro-controllers. Many interface methods have been
developed over the years to solve the complex problem of balancing circuit design
criteria such as features, cost, size, weight, power consumption, reliability,
availability, manufacturability. Many microcontroller designs typically mix multiple
interfacing methods. In a very simplistic form, a micro-controller system can be
viewed as a system that reads from (monitors) inputs, performs processing and writes
to (controls) outputs.
Embedded system means the processor is embedded into the required
application. An embedded product uses a microprocessor or microcontroller to do one
task only. In an embedded system, there is only one application software that is
typically burned into ROM. Example: printer, keyboard, video game player
Microprocessor - A single chip that contains the CPU or most of the computer
Microcontroller - A single chip used to control other devices
Microcontroller differs from a microprocessor in many ways. First and the
most important is its functionality. In order for a microprocessor to be used, other
components such as memory, or components for receiving and sending data must be
added to it. In short that means that microprocessor is the very heart of the computer.
On the other hand, microcontroller is designed to be all of that in one. No other

external components are needed for its application because all necessary peripherals
are already built into it. Thus, we save the time and space needed to construct devices.
MICROPROCESSOR VS MICROCONTROLLER:

Microprocessor:

CPU is stand-alone, RAM, ROM, I/O, timer are separate

Designer can decide on the amount of ROM, RAM and I/O ports.

expensive

versatility general-purpose

Microcontroller:

CPU, RAM, ROM, I/O and timer are all on a single chip

fix amount of on-chip ROM, RAM, I/O ports

for applications in which cost, power and space are critical

single-purpose

MICROCONTROLLER 89S52

FEATURES:

8K Bytes of In-System Reprogrammable Flash Memory


Endurance: 1,000 Write/Erase Cycles
Fully Static Operation: 0 Hz to 24 MHz
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 with
8Kbytes of Flash programmable and erasable read only memory (PEROM). The onchip 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,
which provides a highly flexible and cost-effective solution to many embedded
control applications.

PIN DIAGRAM - AT89S52:

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 pullups 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.
PORT PIN ALTERNATE FUNCTIONS:
P1.0 T2 (external count input to Timer/Counter 2), clock-out
P1.1 T2EX (Timer/Counter 2 capture/reload trigger and direction control
Port 2:
Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port
2output 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 (I IL) 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 uses 16bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal
pullups when emitting 1s. During accesses to external data memory that uses 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 pullups. The Port 3
output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins,
they are pulled high by the internal pullups and can be used as inputs. As inputs, Port
3 pins that are externally being pulled low will source current (I IL) because of the
pullups. Port 3 also serves the functions of various special features of the AT89C51.
Port 3 also receives some control signals for Flash programming and verification.
PORT PIN ALTERNATE FUNCTIONS:
P3.0 RXD (serial input port)
P3.1 TXD (serial output port)
P3.2 INT0 (external interrupt 0)
P3.3 INT1 (external interrupt 1)
P3.4 T0 (timer 0 external input)
P3.5 T1 (timer 1 external input)
P3.6 WR (external data memory write strobe)
P3.7 RD (external data memory read strobe).
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.
However, that one ALE pulse is skipped during each access to external data memory.

If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With
the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the
pin is weakly pulled high. Setting the ALE-disable bit has no effect if the
microcontroller is in external execution mode.

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 pro-gram memory locations starting at 0000H up to
FFFFH. However, 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 12V programming enable voltage (VPP) during Flash programming when 12V
programming is selected.
XTAL1:
input to the inverting oscillator amplifier and input to the internal clock operating
circuit.
XTAL2:
It is an output from the inverting oscillator amplifier
BLOCK DIAGRAM OF 89S52:

EXTERNAL
INTERRUPTS
INTERRUPT
CONTROL

ON-CHIP ROM
FOR
PROGRAM
CODE

TIMER/CO
UNTER

ON-CHIP
RAM

TIMER 1
TIMER 0

CPU

OSC

BUS
CONTROL

4 I/O
PORTS

P0 P1 P2 P3

SERIAL
PORT

TX

ARCHITECHTURE OF 8052 MICROCONTROLLER:

Rx

COUNTER
INPUTS

Architecture of 89S52

OSCILLATOR CHARACTERISTICS:
XTAL1 and XTAL2 are the input and output, respectively, of an
inverting amplifier, which can be configured for use as an on-chip oscillator. Either a
quartz crystal or ceramic resonator may be used. To drive the device from an external
clock source, XTAL2 should be left unconnected while XTAL1 is driven. There are
no requirements on the duty cycle of the external clock signal, since the input to the
internal 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. It should be noted
that when idle 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 is terminated by reset, the
instruction following the one that invokes Idle should not be one that writes to a port
pin or to external memory.
OSCILLATOR CONNECTIONS:

Note: C1, C2 = 30 pF 10 pF for Crystals


= 40 pF 10 pF for Ceramic Resonators

External Clock drives Configuration.

2. POWER SUPPLY SECTION

In-order to work with any components basic requirement is power supply. In


this section there is a requirement of two different voltage levels.
Those are
5V DC power supply.
9V DC power supply.
Now the aim is to design the power supply section which converts 230V AC in to 5V
DC. Since 230V AC is too high to reduce it to directly 5V DC, therefore we need a
step-down transformer that reduces the line voltage to certain voltage that will help us
to convert it in to a 5V DC. Considering the efficiency factor of the bridge rectifier,
we came to a conclusion to choose a transformer, whose secondary voltage is 3 to 4 V
higher than the required voltage i.e. 5V. For this application 0-9V transformers is
used, since it is easily available in the market.

The output of the transformer is 9V AC; it feed to rectifier that converts AC to


pulsating DC. As we all know that there are 3 kind of rectifiers that is
half wave
Full wave and
Bridge rectifier
Here we short listed to use Bridge rectifier, because half wave rectifier has we less in
efficiency. Even though the efficiency of full wave and bridge rectifier are the same,
since there is no requirement for any negative voltage for our application, we gone
with bridge rectifier.
Since the output voltage of the rectifier is pulsating DC, in order to convert it into
pure DC we use a high value (1000UF/1500UF) of capacitor in parallel that acts as a
filter. The most easy way to regulate this voltage is by using a 7805 voltage regulator,
whose output voltage is constant 5V DC irrespective of any fluctuation in line
voltage.

3. INTRODUCTION TO KIEL SOFTWARE

Many companies provide the 8051 assembler, some of them provide


shareware version of their product on the Web, Kiel is one of them. We can download
them from their Websites. However, the size of code for these shareware versions is
limited and we have to consider which assembler is suitable for our application.
KIEL U VISION2:
This is an IDE (Integrated Development Environment) that helps you
write, compile, and debug embedded programs. It encapsulates the following
components:
.

A project manager

A make facility

Tool configuration

Editor

A powerful debugger

To get start here are some several example programs


BUILDING AN APPLICATION IN UVISION2:
To build (compile, assemble, and link) an application in uVision2, you must:
.

Select ProjectOpen Project


(For example, \C166\EXAMPLES\HELLO\HELLO.UV2)

Select Project - Rebuild all target files or Build target. UVision2 compiles,

assembles, and links the files in your project.


CREATING YOUR OWN APPLICATION IN UVISION2:
To create a new project in uVision2, you must:
.

Select Project - New Project.

Select a directory and enter the name of the project file.

Select Project - Select Device and select an 8051, 251, or C16x/ST10 device

from the Device

Database

Create source files to add to the project.

Select Project - Targets, Groups, and Files. Add/Files, select Source Group1,

and add the source files to the project.


.

Select Project - Options and set the tool options. Note when you select the

target device from the Device Database all-special options are set automatically. You
only need to configure the memory map of your target hardware. Default memory
model settings are optimal for most.
APPLICATIONS:
.

Select Project - Rebuild all target files or Build target.

DEBUGGING AN APPLICATION IN UVISION2:


To debug an application created using uVision2, you must:
.

Select Debug - Start/Stop Debug Session.

Use the Step toolbar buttons to single-step through your program. You may

enter G, main in the Output Window to execute to the main C function.


.

Open the Serial Window using the Serial #1 button on the toolbar.

Debug your program using standard options like Step, Go, Break, and so on.

LIMITATIONS OF EVALUATION SOFTWARE:


The following limitations apply to the evaluation versions of the C51, C251,
or C166 tool chains. C51 Evaluation Software Limitations:
.

The compiler, assembler, linker, and debugger are limited to 2 Kbytes of

object code but source Code may be any size. Programs that generate more than 2
Kbytes of object code will not compile, assemble, or link the startup code generated
includes LJMP's and cannot be used in single-chip devices supporting Less than 2
Kbytes of program space like the Philips 750/751/752.
.

The debugger supports files that are 2 Kbytes and smaller.

Programs begin at offset 0x0800 and cannot be programmed into single-chip

devices.

No hardware support is available for multiple DPTR registers.

No support is available for user libraries or floating-point arithmetic.

EVALUATION SOFTWARE:
.

Code-Banking Linker/Locator

Library Manager.

RTX-51 Tiny Real-Time Operating System

PERIPHERAL SIMULATION:
The u vision2 debugger provides complete simulation for the CPU and on chip
peripherals of most embedded devices. To discover which peripherals of a device are
supported, in u vision2. Select the Simulated Peripherals item from the Help menu.
You may also use the web-based device database. We are constantly adding new
devices and simulation support for on-chip peripherals so be sure to check Device
Database often.

4. SCHEMATIC

5. CIRCUIT DESCRIPTION
Security is the condition of being protected against danger or loss. In the
general sense, security is a concept similar to safety. The nuance between the two is
an added emphasis on being protected from dangers that originate from outside.
Individuals or actions that encroach upon the condition of protection are responsible
for the breach of security. The word "security" in general usage is synonymous with
"safety," but as a technical term "security" means that something not only is secure
but that it has been secured. One of the best options for providing good security is by
using a technology named EMBEDDED SYSTEMS.
In this project we used fire sensor, LDR, IR and metal detector to
target mainly for fire accidents identification, unuthorised dperson entering into the
home, door opening intimation if opend by unauthorized person and theft alaram
indication using LDR if any of the events occur in the home, signal will be given to
the controller which will be displayed on to the LCD with a beep sound by the buzzer
and also makes a blank call to the number which will be entered during initialization.
All the sensors output is taken directly as two levels without using ADC. The working
of various sensors are described in the following sections.

6. FIRE SENSOR
This fire sensor circuit exploits the temperature sensing property of an
ordinary signal diode IN 34 to detect heat from fire. At the moment it senses heat, a
loud alarm simulating that of Fire brigade will be produced. The circuit is too
sensitive and can detect a rise in temperature of 10 degree or more in its vicinity.
Ordinary signal diodes like IN 34 and OA 71 exhibits this property and the internal
resistance of these devices will decrease when temperature rises.

The fire sensor circuit is too sensitive and can detect a rise in temperature of
10 degree or more in its vicinity. Ordinary signal diodes like IN 34 and OA 71
exhibits this property and the internal resistance of these devices will decrease when
temperature rises. In the reverse biased mode, this effect will be more significant.
Typically the diode can generate around 600 milli volts at 5 degree centigrade. For
each degree rise in temperature; the diode generates 2 mV output voltage. That is at 5
degree it is 10 mV and when the temperature rises to 50 degree, the diode will give
100 milli volts. This voltage is used to trigger the remaining circuit. Transistor T1 is a
temperature controlled switch and its base voltage depends on the voltage from the
diode and from VR and R1. Normally T1 conducts (due to the voltage set by VR) and
LED glows. This indicates normal temperature.
When T1 conducts, base pf T2 will be grounded and it remains off to inhibit
the Alarm generator. IC UM 3561 is used in the circuit to give a Fire force siren. This
ROM IC has an internal oscillator and can generate different tones based on its pin
connections. Here pin 6 is shorted with the Vcc pin 5 to get a fire force siren. When
the temperature near the diode increases above 50 degree, it conducts and ground the
base of T1. This makes T1 off and T2 on. Alarm generator then gets current from the
emitter of T2 which is regulated by ZD to 3.1 volt and buffered by C1.Resistor R4
( 220K) determines the frequency of oscillation and the value 220K is a must for
correct tone. To set the fire sensor circuit, keep a lighted candle near the diode and
wait for 1 minute. Slowly adjust VR till the alarm sounds. Remove the heat .After one
minute, alarm will turns off. VR can be used for further adjustments for particular
temperature levels.

7. LIGHT DEPENDENT RESISTOR


LDR, an acronym for light dependent resistor is a resistor whose resistance is
dependent on light. The resistance of LDR is of the order of Mega Ohms in the
absence of light and reduces to a few ohms in presence of light. In this circuit when
the light falls on LDR, the resistance of LDR becomes low and the entire voltage drop
takes place across the variable resistance VR1 (10K ). As a result the base of
transistor (T1) gets high input and it gets biased thereby glowing the LED. When no
light falls on LDR, the resistance of LDR becomes high so almost entire voltage drop
takes place across it and the base of transistor is at low potential. So transistor does
not gets biased nor it becomes conducting, hence switching off the LED. The
sensitivity of the circuit can be adjusted by varying the preset VR1.

An LDR (Light dependent resistor), as its name suggests, offers resistance in response
to the ambient light. The resistance decreases as the intensity of incident light
increases, and vice versa. In the absence of light, LDR exhibits a resistance of the
order of mega-ohms which decreases to few hundred ohms in the presence of light. It
can act as a sensor, since a varying voltage drop can be obtained in accordance with
the varying light. It is made up of cadmium sulphide (CdS).
An LDR has a zigzag cadmium sulphide track. It is a bilateral device, i.e., conducts in
both directions in same fashion.

8. MAGNETIC SENSOR

Magnetic proximity sensors are actuated by the presence of a permanent


magnet. Their operating principle is based on the use of reed con-tacts, whose thin
plates are hermetically sealed in a glass bulb with inert gas. The presences of a
magnetic field makes the thin plates flex and touch each other causing an electrical
contact. The plate's surface has been treated with a special material par-ticularly
suitable for low current or high inductive circuits. Magnetic sensors compared to
traditional mechanical switches have the following advantage:

Contacts are well protected against dust, oxidization and corrosion due to the
hermetic glass bulb and inert gas; contacts are activated by means of a
magnetic field rather than mechanical parts

Special surface treatment of contacts assures long contact life

Maintenance free

Easy operation

Reduced size

Outputs:
When using the NO (normally open) type the open reed contact closes as the
magnet approaches. NO Magnetic sensors are two wires. When using the NO+NC
type both NO (normally open) and NC (normally closed) functions are made available
by means of a single glass bulb. NO+NC Magnetic sensors are supplied with three
wires, one is in common, one is NO and one is NC

TYPICAL REED CONTACT PROTECTIONS


The lifespan of a magnetic sensor at low values of voltage and current depends on the
mechanical characteristics of the contact while for higher values the operating life
depends on the characteristics of the load. In these cases, it is suggested to apply some
form of external protection at the sensor output.

The reed switch is an electrical switch operated by an applied magnetic field.


The basic reed switch consists of two identical flattened ferromagnetic reeds, sealed
in a dry inert-gas atmosphere within a glass capsule, thereby protecting the contact
from contamination. The reeds are sealed in the capsule in such a way that their free
ends overlap and are separated by a small air gap.

Fig: Reed Switch


The contacts may be normally open, closing when a magnetic field is present,
or normally closed and opening when a magnetic field is applied.
A magnetic field from an electromagnet or a permanent magnet will cause the
contacts to pull together, thus completing an electrical circuit. The stiffness of the
reeds causes them to separate, and open the circuit, when the magnetic field ceases.
Good electrical contact is assured by plating a thin layer of precious metal over the
flat contact portions of the reeds.
Since the contacts of the reed switch are sealed away from the atmosphere,
they are protected against atmospheric corrosion. The hermetic sealing of a reed
switch makes them suitable for use in explosive atmospheres where tiny sparks from
conventional switches would constitute a hazard.
REED SENSOR:
A reed sensor is a device built using a reed switch with additional functionality
like ability to withstand higher shock, easier mounting, additional intelligent circuitry,
etc.
In production, a metal reed is inserted in each end of a glass tube and the end
of the tube heated so that it seals around a shank portion on the reed. Infraredabsorbing glass is used, so an infrared heat source can concentrate the heat in the
small sealing zone of the glass tube. The thermal coefficient of expansion of the glass
material and metal parts must be similar to prevent breaking the glass-to-metal seal.
The glass used must have a high electrical resistance and must not contain volatile
components such as lead oxide and fluorides. The leads of the switch must be handled
carefully to prevent breaking the glass envelope.
How does a reed switch work?
When a magnetic force is generated parallel to the reed switch, the reeds
become flux carriers in the magnetic circuit. The overlapping ends of the reeds
become opposite magnetic poles, which attract each other. If the magnetic force
between the poles is strong enough to overcome the restoring force of the reeds, the
reeds will be drawn together.
One important quality of the switch is its sensitivity, the amount of magnetic
energy necessary to actuate it. Sensitivity is measured in units of Ampere-turns,
corresponding to the current in a coil multiplied by the number of turns. Typical pullin sensitivities for commercial devices are in the 10 to 60 AT range.

Uses:
Reed switches are widely used for electrical circuit control, particularly in the
communications field. Reed switches are commonly used in mechanical systems as
proximity switches as well as in door and window sensors in burglar alarm systems
and tamper proofing methods. These were formerly used in the keyboards for
computer terminals, where each key had a magnet and a reed switch actuated by
depressing the key. Speed sensors on bicycles use a reed switch to detect when the
magnet on the wheel passes the sensor.
Advantages:
1. They are hermetically sealed in glass environment.
2. Free from contamination, and are safe to use in harsh industrial and explosive
environments.
3.

Reed switches are immune to electrostatic discharge (ESD) and do not require
any external ESD protection circuits. The isolation resistance between the
contacts is as high as 1015 ohms, and contact resistance is as low as 50
milliohms.

4. They can directly switch loads as low as a few microwatts without the help of
external amplification circuits, to as high as 120W.
5.

When the reed switches are combined with magnets and coils, they can be
used to form many different types of relays.

Six reed switches are used in our project to indicate different levels of the
petrochemical liquid in the process container. When the floating magnet comes in
contact with any of the reed switches, magnetic field will be generated and the reeds
are drawn together and thus the reed switch is triggered and this change is applied to
the microcontroller for further processing.

9. IR SECTION:
WHAT IS INFRARED?
Infrared is an energy radiation with a frequency below our eyes sensitivity, so we
cannot see it. Even that we can not "see" sound frequencies, we know that it exist, we
can listen them.

Even that we can not see or hear infrared, we can feel it at our skin temperature
sensors.
When you approach your hand to fire or warm element, you will "feel" the heat, but
you can't see it. You can see the fire because it emits other types of radiation, visible
to your eyes, but it also emits lots of infrared that you can only feel in your skin.
INFRARED IN ELECTRONICS
Infra-Red is interesting, because it is easily generated and doesn't suffer
electromagnetic interference, so it is nicely used to communication and control, but it
is not perfect, some other light emissions could contains infrared as well, and that can
interfere in this communication. The sun is an example, since it emits a wide spectrum
or radiation.
The adventure of using lots of infra-red in TV/VCR remote controls and other
applications, brought infra-red diodes (emitter and receivers) at very low cost at the
market.
From now on you should think as infrared as just a "red" light. This light can means
something to the receiver, the "on or off" radiation can transmit different
meanings.Lots of things can generate infrared, anything that radiate heat do it,
including out body, lamps, stove, oven, friction your hands together, even the hot
water at the faucet.

To allow a good communication using infra-red, and avoid those "fake" signals, it is
imperative to use a "key" that can tell the receiver what is the real data transmitted
and what is fake. As an analogy, looking eye naked to the night sky you can see
hundreds of stars, but you can spot easily a far away airplane just by its flashing
strobe light. That strobe light is the "key", the "coding" element that alerts us.
Similar to the airplane at the night sky, our TV room may have hundreds of tinny IR
sources, our body and the lamps around, even the hot cup of tea. A way to avoid all
those other sources, is generating a key, like the flashing airplane. So, remote controls
use to pulsate its infrared in a certain frequency. The IR receiver module at the TV,
VCR or stereo "tunes" to this certain frequency and ignores all other IR received. The
best frequency for the job is between 30 and 60 kHz, the most used is around 36 kHz
IR GENERATION
To generate a 36 kHz pulsating infrared is quite easy, more difficult is to receive
and identify this frequency. This is why some companies produce infrared receives,
that contains the filters, decoding circuits and the output shaper, that delivers a square
wave, meaning the existence or not of the 36kHz incoming pulsating infrared.
It means that those 3 dollars small units, have an output pin that goes high (+5V)
when there is a pulsating 36kHz infrared in front of it, and zero volts when there is not
this radiation.

A square wave of approximately 27uS (microseconds) injected at the base of a


transistor, can drive an infrared LED to transmit this pulsating light wave. Upon its
presence, the commercial receiver will switch its output to high level (+5V).If you can
turn on and off this frequency at the transmitter, your receiver's output will indicate
when the transmitter is on or off.

Those IR demodulators have inverted logic at its output, when a burst of IR is sensed
it drives its output to low level, meaning logic level = 1.
The TV, VCR, and Audio equipment manufacturers for long use infra-red at their
remote controls. To avoid a Philips remote control to change channels in a Panasonic
TV, they use different codification at the infrared, even that all of them use basically
the same transmitted frequency, from 36 to 50 kHz. So, all of them use a different
combination of bits or how to code the transmitted data to avoid interference.
RC-5
Various remote control systems are used in electronic equipment today. The
RC5 control protocol is one of the most popular and is widely used to control
numerous home appliances, entertainment systems and some industrial applications
including utility consumption remote meter reading, contact-less apparatus control,
telemetry data transmission, and car security systems. Philips originally invented this
protocol and virtually all Philips remotes use this protocol. Following is a description
of the RC5. When the user pushes a button on the hand-held remote, the device is
activated and sends modulated infrared light to transmit the command. The remote
separates command data into packets. Each data packet consists of a 14-bit data word,

which is repeated if the user continues to push the remote button. The data packet
structure is as follows:

2 start bits,

1 control bit,

5 address bits,

6 command bits.

The start bits are always logic 1 and intended to calibrate the optical receiver
automatic gain control loop. Next, is the control bit. This bit is inverted each time the
user releases the remote button and is intended to differentiate situations when the
user continues to hold the same button or presses it again. The next 5 bits are the
address bits and select the destination device. A number of devices can use RC5 at the
same time. To exclude possible interference, each must use a different address. The 6
command bits describe the actual command. As a result, a RC5 transmitter can send
the 2048 unique commands. The transmitter shifts the data word, applies Manchester
encoding and passes the created one-bit sequence to a control carrier frequency signal
amplitude modulator. The amplitude modulated carrier signal is sent to the optical
transmitter, which radiates the infrared light. In RC5 systems the carrier frequency has
been set to 36 kHz. Figure below displays the RC5 protocol.
The receiver performs the reverse function. The photo detector converts optical
transmission into electric signals, filters it and executes amplitude demodulation. The
receiver output bit stream can be used to decode the RC5 data word. This operation is
done by the microprocessor typically, but complete hardware implementations are
present on the market as well. Single-die optical receivers are being mass produced by
a number of companies such as Siemens, Temic, Sharp, Xiamen Hualian, Japanese
Electric and others. Please note that the receiver output is inverted (log. 1 corresponds
to illumination absence).
IR RECEIVER
Description

The TSOP17.. series are miniaturized receivers for infrared remote


control systems. PIN diode and preamplifier are assembled on lead frame,
the epoxy package is designed as IR filter.
The

demodulated

output

signal

can

directly

be

decoded

by

microprocessor. TSOP17.. is the standard IR remote control receiver series,


supporting all major transmission codes.
Features

Photo detector and preamplifier in one package

Internal filter for PCM frequency

Improved shielding against electrical field disturbance

TTL and CMOS compatibility

Output active low

Low power consumption

High immunity against ambient light

Continuous data transmission possible (up to 2400 bps)

Suitable burst length .10 cycles/burst

Suitable Data Format


The circuit of the TSOP17 is designed in that way that unexpected output
pulses due to noise or disturbance signals are avoided. A bandpassfilter,
an integrator stage and an automatic gain control are used to suppress
such disturbances. The distinguishing mark between data signal and
disturbance signal are carrier frequency, burst length and duty cycle. The

data signal should fullfill the following condition: Carrier frequency


should be close to center frequency of the bandpass (e.g. 38kHz).
Burst length should be 10 cycles/burst or longer.
After each burst which is between 10 cycles and 70 cycles a gap time of
at least 14 cycles is necessary.
For each burst which is longer than 1.8ms a corresponding gap time is
necessary at some time in the data stream. This gap time should have at
least same length as the burst.
Up to 1400 short bursts per second can be received continuously.

Some examples for suitable data format are: NEC Code, Toshiba Micom
Format, Sharp Code, RC5 Code, RC6 Code, R2000 Code, Sony Format
(SIRCS). When a disturbance signal is applied to the TSOP17.. it can still
receive the data signal. However the sensitivity is reduced to that level
that no unexpected pulses will occur. Some examples for such disturbance
signals which are suppressed by the TSOP17 are:
DC light (e.g. from tungsten bulb or sunlight)
Continuous signal at 38 kHz or at any other frequency
Signals from fluorescent lamps with electronic ballast (an example of the
signal modulation is in the figure below).

Infrared technology develpoping until now, already has been known to everyone, this
technology has been generally used in the application of modern science technology, national
defense and industrial and agricultural fields.

Infrared sensor system is by means of media to be a infared measurement


system.for the media, in accordance with the function can be divided into five
categories: (1) radiometer, apply to spectrum and radiation measurements; (2) search
and track system,for searching and tracting Infrared target to define its spatial location
as well as tracting its movement; (3) thermal imaging systems, can generate the
distribution chart of the target infrared radiation; (4) infrared distance measurement
and Communication systems; (5) hybrid system, is of the combination of two or more
systems above mentioned.
According to detection mechanism,Infrared sensors can be divided: photon
detectors(based on the photoelectric effect) and heat detectors(based on thermal
effects.)
We first look at the composition of infrared systems, the main optical system
and auxiliary optical system, on the basis of that we discuss the key components of IR
in detail. In fact, the infrared sensor Works is not complicated.
Infrared sensor work principle
(1) measured target. infrared radiation infrared system can be set according to the
peculiarity of IR radiation of measured target.
(2) atmosphere attenuation. infrared radiation of measured target will be attenuated
through the Earths atmosphere, due to the scattering and absorption of
gas molecules, a variety of gases and sol particles.
(3) optical receiver. It receives some infrared radiation of measured target and
transmittes to the infrared sensor. just like radar antenna.
(4) radiation modulator. it can modulates radiation into alternating radiation,providing
information of target location and filtering out a large area of
interference information.it known as the modulation drive or
chopper,which has avariety of structures.
(5) infrared detector. This is the core of IR systems. It is the use of the physical effects
of interaction between infrared radiation and matter to detct infrared
radiation. In most of cases it is the use of this electrical effects showing
in the interaction effect. Such detectors can be divided into sensitive
photon detectors and thermal detectors.
(6) detector cooler. Because some detectors must work at low temperature.By
refrigeration,the equipment can shorten responsetime to enhance
sensitivity.

(7) signal processing system. It could enlarge and tilter detacting signal to get
information. And then translates the information into required format
which is transfer to the control device or display at last.
(8) display device. This is the final device of infrared device. Display devices are
commonly used including oscilloscopes, cathode ray tubes, infraredsensitive materials, instructions and other instruments and recorder.
Infrared system could be able to complete the relevant physical measurement
in accordance with the process above mentioned.
The core of infrared system is infrared detectors which can be divided into
Thermal detectors and photon detectors according to the different detecting
mechanism. The following example of a thermal detector is used to analyze principle
of the detector.
Thermal detectors make use of radiant heat effect, so that make the
temperature of detecting component raise after receiving radiation energy, and thus
make the detector performance depends on the temperature performance change. The
radiation will be detated when detecting temperature performance change. In most
cases, to detect change through thermal radiation. When the device receives radiation
to cause non-electricity change that can be measured the power change by means of
appropriate transformation.

DRIVER CIRCUIT:
Digital systems and microcontroller pins lack sufficient current to drive the
circuits like relays, buzzer circuits etc. While these circuits require around 10milli
amps to be operated, the microcontrollers pin can provide a maximum of 1-2milli
amps current. For this reason, a driver such as a power transistor is placed in between
the microcontroller and the buzzer circuit.

Vcc

BUZZER

P1.0

GROUND

The operation of this circuit is as follows:


The input to the base of the transistor is applied from the microcontroller port
pin P1.0. The transistor will be switched on when the base to emitter voltage is greater
than 0.7V (cut-in voltage). Thus when the voltage applied to the pin P1.0 is high i.e.,
P1.0=1 (>0.7V), the transistor will be switched on and thus the buzzer will be ON.
When the voltage at the pin P1.0 is low i.e., P1.0=0 (<0.7V) the transistor will
be in off state and the buzzer will be OFF. Thus the transistor acts like a current driver
to operate the buzzer accordingly.

SWITCH AND LED INTERFACING

10.

WITH THE MICROCONTROLLER:


Switches and LEDs are the most widely used input/output
devices of the 8051.
SWITCH INTERFACING:
CPU accesses the switches through ports. Therefore these
switches are connected to a

microcontroller.

This

switch is

connected between the supply and ground terminals. A single


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

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

Vcc

R
P2.0

Gnd

Fig: Interfacing switch with the microcontroller

Thus now the two conditions are to be remembered:


1. When the switch is open, the total supply i.e., Vcc appears
at the port pin P2.0
P2.0 = 1
2. When the switch is closed i.e., when it is pressed, the total
supply path is provided to ground. Thus the voltage value
at the port pin P2.0 will be zero.
P2.0 = 0
By reading the pin status, the microcontroller identifies
whether the switch is pressed or not. When the switch is pressed,
the corresponding related to this switch press written in the program
will be executed.

LED INTERFACING:

LED stands for Light Emitting Diode.


Microcontroller port pins cannot drive these LEDs as these require
high currents to switch on. Thus the positive terminal of LED is
directly connected to Vcc, power supply and the negative terminal is
connected to port pin through a current limiting resistor.

This current limiting resistor is connected to protect the port


pins from sudden flow of high currents from the power supply.
Thus in order to glow the LED, first there should be a current
flow through the LED. In order to have a current flow, a voltage
difference should exist between the LED terminals. To ensure the
voltage difference between the terminals and as the positive
terminal of LED is connected to power supply Vcc, the negative
terminal has to be connected to ground. Thus this ground value is
provided by the microcontroller port pin. This can be achieved by
writing an instruction CLR P1.0. With this, the port pin P1.0 is
initialized to zero and thus now a voltage difference is established
between the LED terminals and accordingly, current flows and
therefore the LED glows. LED and switches can be connected to any
one of the four port pins.

Vcc

P1.0

Fig: LED Interfacing with the microcontroller


Light-emitting diode (LED)
Light-emitting diodes are elements for light signalization in electronics. They are
manufactured in different shapes, colors and sizes. For their low price, low
consumption and simple use, they have almost completely pushed aside other light
sources- bulbs at first place. They perform similar to common diodes with the
difference that they emit light when current flows through them.

It is important to know that each diode will be immediately destroyed unless its
current is limited. This means that a conductor must be connected in parallel to a
diode. In order to correctly determine
value of this conductor, it is necessary
to know diodes voltage drop in
forward direction, which depends on
what material a diode is made of and
what colour it is. Values typical for the
most frequently used diodes are shown
in table below: As seen, there are three
main types of LEDs. Standard ones get
ful brightness at current of 20mA. Low Current diodes get ful brightness at ten times
lower current while Super Bright diodes produce more intensive light than Standard
ones.

Since the 8051 microcontrollers can provide only low input current
and since their pins are configured as outputs when voltage level on
them is equal to 0, direct connectining to LEDs is carried out as it is
shown on figure (Low current LED, cathode is connected to output
pin).
Switches and Pushbuttons
There is nothing simpler than this! This is the simplest way of controlling appearance
of some voltage on microcontrollers input pin. There is also no need for additional
explanation of how these components operate.

Nevertheless, it is not so simple in practice... This is about something commonly


unnoticeable when using these components in everyday life. It is about contact
bounce- a common problem with m e c h a n i c a l switches. If contact switching does
not happen so quickly, several consecutive bounces can be noticed prior to maintain
stable state. The reasons for this are: vibrations, slight rough spots and dirt. Anyway,
whole this process does not last long (a few micro- or miliseconds), but long enough
to be registered by the microcontroller. Concerning pulse counter, error occurs in
almost 100% of cases!

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

11. Power Supply


The input to the circuit is applied from the regulated power supply. The a.c. input i.e.,
230V from the mains supply is step down by the transformer to 12V and is fed to a
rectifier. The output obtained from the rectifier is a pulsating d.c voltage. So in order
to get a pure d.c voltage, the output voltage from the rectifier is fed to a filter to
remove any a.c components present even after rectification. Now, this voltage is given
to a voltage regulator to obtain a pure constant dc voltage.

Transformer:
Usually, DC voltages are required to operate various electronic equipment and
these voltages are 5V, 9V or 12V. But these voltages cannot be obtained directly. Thus
the a.c input available at the mains supply i.e., 230V is to be brought down to the

required voltage level. This is done by a transformer. Thus, a step down transformer is
employed to decrease the voltage to a required level.

Rectifier:
The output from the transformer is fed to the rectifier. It converts A.C. into
pulsating D.C. The rectifier may be a half wave or a full wave rectifier. In this project,
a bridge rectifier is used because of its merits like good stability and full wave
rectification.
Filter:
Capacitive filter is used in this project. It removes the ripples from the output
of rectifier and smoothens the D.C. Output received from this filter is constant until
the mains voltage and load is maintained constant. However, if either of the two is
varied, D.C. voltage received at this point changes. Therefore a regulator is applied at
the output stage.

Voltage regulator:
As the name itself implies, it regulates the input applied to it. A voltage
regulator is an electrical regulator designed to automatically maintain a constant
voltage level. In this project, power supply of 5V and 12V are required. In order to
obtain these voltage levels, 7805 and 7812 voltage regulators are to be used. The first
number 78 represents positive supply and the numbers 05, 12 represent the required
output voltage levels.

12.

LIQUID CRYSTAL DISPLAY

LCD stands for Liquid Crystal Display. LCD is finding wide spread use replacing
LEDs (seven segment LEDs or other multi segment LEDs) because of the following
reasons:
1. The declining prices of LCDs.
2. The ability to display numbers, characters and graphics. This is in contrast to
LEDs, which are limited to numbers and a few characters.
3. Incorporation of a refreshing controller into the LCD, thereby relieving the
CPU of the task of refreshing the LCD. In contrast, the LED must be refreshed
by the CPU to keep displaying the data.
4. Ease of programming for characters and graphics.
These components are specialized for being used with the microcontrollers,
which means that they cannot be activated by standard IC circuits. They are used for
writing different messages on a miniature LCD.

A model described here is for its low price and great possibilities most
frequently used in practice. It is based on the HD44780 microcontroller (Hitachi) and
can display messages in two lines with 16 characters each. It displays all the
alphabets, Greek letters, punctuation marks, mathematical symbols etc. In addition, it
is possible to display symbols that user makes up on its own.

Automatic shifting message on display (shift left and right), appearance of the
pointer, backlight etc. are considered as useful characteristics.

Pins Functions

There are pins along one side of the small printed board used for connection to
the microcontroller. There are total of 14 pins marked with numbers (16 in case the
background light is built in). Their function is described in the table below:

Function

Pin
Number

Name

Logic
State

Description

Ground

Vss

0V

Power supply

Vdd

+5V

Contrast

Vee

0 Vdd

RS

0
1

D0 D7 are interpreted as
commands
D0 D7 are interpreted as
data

R/W

0
1

Write data (from controller


to LCD)
Read data (from LCD to
controller)

0
1
From 1
to 0

Access to LCD disabled


Normal operating
Data/commands are
transferred to LCD

D0

0/1

Bit 0 LSB

D1

0/1

Bit 1

D2

0/1

Bit 2

10

D3

0/1

Bit 3

11

D4

0/1

Bit 4

12

D5

0/1

Bit 5

13

D6

0/1

Bit 6

Control of
operating

Data /
commands

14

D7

0/1

Bit 7 MSB

LCD screen:

LCD screen consists of two lines with 16 characters each. Each character
consists of 5x7 dot matrix. Contrast on display depends on the power supply voltage
and whether messages are displayed in one or two lines. For that reason, variable
voltage 0-Vdd is applied on pin marked as Vee. Trimmer potentiometer is usually
used for that purpose. Some versions of displays have built in backlight (blue or green
diodes). When used during operating, a resistor for current limitation should be used
(like with any LE diode).

LCD Basic Commands


All data transferred to LCD through outputs D0-D7 will be interpreted as commands
or as data, which depends on logic state on pin RS:
RS = 1 - Bits D0 - D7 are addresses of characters that should be displayed. Built in
processor addresses built in map of characters and displays corresponding symbols.
Displaying position is determined by DDRAM address. This address is either

previously defined or the address of previously transferred character is automatically


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

R
D D D D
D D
RW
D3 D2
S
7 6 5 4
1 0

Clear display

0 0 0

1.64Ms

Cursor home

0 0 0

1.64mS

Entry mode set

0 0 0

1 I/D S

40uS

Display on/off control

0 0 0

40uS

Cursor/Display Shift

0 0 0

1 D/C R/L x

Function set

0 0 1 DL N

Set CGRAM address

0 1

Set DDRAM address

Read BUSY flag (BF)

1 BF

Write to CGRAM or
DDRAM

D D D
D
D4 D3 D2 D1
7 6 5
0

40uS

Read from CGRAM or


DDRAM

D D D
D
D4 D3 D2 D1
7 6 5
0

40uS

I/D 1 = Increment (by 1)


0 = Decrement (by 1)
S 1 = Display shift on
0 = Display shift off
D 1 = Display on
0 = Display off
U 1 = Cursor on
0 = Cursor off

Execution
Time

U B

40uS

40uS

CGRAM address

40uS

DDRAM address

40uS

DDRAM address

R/L 1 = Shift right


0 = Shift left
DL 1 = 8-bit interface
0 = 4-bit interface
N 1 = Display in two lines
0 = Display in one line
F 1 = Character format 5x10 dots
0 = Character format 5x7 dots

B 1 = Cursor blink on

D/C 1 = Display shift

0 = Cursor blink off

0 = Cursor shift

LCD Connection
Depending on how many lines are used for connection to the microcontroller,
there are 8-bit and 4-bit LCD modes. The appropriate mode is determined at the
beginning of the process in a phase called initialization. In the first case, the data
are transferred through outputs D0-D7 as it has been already explained. In case of 4bit LED mode, for the sake of saving valuable I/O pins of the microcontroller, there
are only 4 higher bits (D4-D7) used for communication, while other may be left
unconnected.
Consequently, each data is sent to LCD in two steps: four higher bits are sent
first (that normally would be sent through lines D4-D7), four lower bits are sent
afterwards. With the help of initialization, LCD will correctly connect and interpret
each data received. Besides, with regards to the fact that data are rarely read from
LCD (data mainly are transferred from microcontroller to LCD) one more I/O pin
may be saved by simple connecting R/W pin to the Ground. Such saving has its price.
Even though message displaying will be normally performed, it will not be
possible to read from busy flag since it is not possible to read from display.
LCD Initialization
Once the power supply is turned on, LCD is automatically cleared. This
process lasts for approximately 15mS. After that, display is ready to operate. The
mode of operating is set by default. This means that:
1. Display is cleared
2. Mode
DL = 1 Communication through 8-bit interface
N = 0 Messages are displayed in one line
F = 0 Character font 5 x 8 dots
3. Display/Cursor on/off

D = 0 Display off
U = 0 Cursor off
B = 0 Cursor blink off
4. Character entry
ID = 1 Addresses on display are automatically incremented by 1
S = 0 Display shift off
Automatic reset is mainly performed without any problems. If for any reason
power supply voltage does not reach full value in the course of 10mS, display will
start perform completely unpredictably.
If voltage supply unit cannot meet this condition or if it is needed to provide
completely safe operating, the process of initialization by which a new reset enabling
display to operate normally must be applied.
Algorithm according to the initialization is being performed depends on
whether connection to the microcontroller is through 4- or 8-bit interface. All left over
to be done after that is to give basic commands and of course- to display messages.

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

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

Presets
These are miniature versions of the standard variable resistor. They are
designed to be mounted directly onto the circuit board and adjusted only
when the circuit is built. For example, to set the frequency of an alarm
tone or the sensitivity of a light-sensitive circuit, a small screwdriver or
similar tool is required to adjust presets.
Presets are much cheaper than standard variable resistors so they are
sometimes used in projects where a standard variable resistor would
normally be used.

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

LCD Interfacing with 8051:

13. CODE
/*-------------------------------------------; security system with autodialler
--------------------------------------------*/

#include<reg51.h>
#include "lcddisplay.h"

sbit temp

= P2^0;

sbit read_switch
sbit ir

= P2^1;

= P2^2;

sbit ldr

= P3^0;

Sbit redial

=P2^4;

sbit credial

=P2^5;

sbit buz

=P2^3;

unsigned char i;
void dialling();
void main()
{
buz=1;
redial=0;
credial=0;
lcd_init();
delay(50);

lcdcmd(1);
msgdisplay("SECURITY SYSTEM");
lcdcmd(0xc0);
msgdisplay("USING AUTODIALER");
delay(1000);
while(1)

{
redial=0;
credial=0;
buz=1;
if(read_switch==1)
{
buz=0;
lcdcmd(1);
msgdisplay("DOOR OPENED");
dialling();
while(1);
}
if(temp==1)
{
buz=0;
lcdcmd(1);
msgdisplay("FIRE DTECTED");
dialling();
while(1);
}
if(ldr==1)
{
buz=0;
lcdcmd(1);

msgdisplay("LIGHT FALLEN");
dialling();
while(1);
}
if(ir==1)
{
buz=0;
lcdcmd(1);
msgdisplay("PERSON DETECTED");
dialling();
while(1);
}
}
}
void dialling()
{
credial=1;
delay(100);
redial=1;
delay(400);
redial=0;

You might also like