You are on page 1of 41

1 | P a g e

CHAPTER 1 INTRODUCTION

1.1 INTRODUCTION:
This project is very much different from other water level indicators, many water level
indicators are available in the market, they are cost efficient & reliable also, but the main
disadvantage of this type of W.L.I is that the readings are observed by going close to the
tank. This is because each LED is connected to the wire which senses the level. Now if 5
level indicators are used then the no. of wire used is 5, so the LED indicator is placed very
close to the tank. If we want to observe the output at some distance place,we should extend
all the 5 wires connected to the LEDs, which is hectic & costly job. To overcome the above
disadvantages instead of using analog ICs we use 8051 Microcontrollers. It is programmed
to sense the level & transmit the level data serially and to receive the serial level data & show
the level position on port 1 connected to the LED indicator.
Water level controller is an equipment used to control the water level. This is done by
switching ON or OFF the motor. The level of water is controlled by using 8051
microcontroller. Micro controller produces the control signal to drive the motor. If there is no
water in the tank, micro controller gives the control signal to start the motor and if there is
sufficient water in the tank and micro controller gives the control signal to stop the motor.
The level sensor probes are used for the tank are interfaced to the microcontroller through
transistors.. A positive voltage supply probe goes to the down bottom of the tank. The probes
for sensing 1/4, 1/2, 3/4 and FULL levels are placed with equal spacing one by one above the
bottom positive probe. These levels are indicated by the LEDs and is displayed at the LCD
board.
1.2 OBJECTIVE
To observe the water level of tank
To control motor automatically
To save energy and natural resources
1.3 PROBLEM STATEMENT
2 | P a g e

Most of the people in the context of our country, they are still using manual process for water
pumping and motor control that used in home, office and industries. Manual controlling
process is difficult when the water tank is located at higher buildings and controlling from
ground level. Due to more time consuming on manual operation it is total loss of our valuable
time. If we are unable to continuous monitoring there are loss of energy sources for pumping
water as well as loss of natural resources by overflowing water from tank.
With invention of different technology and automatic system, people want to do such a task
without touching it. For fulfilment of people desire we have design this system which control
the motor used to pump. Motor is automatically started and stops as our requirement. Our
system is not only motor controlling system it also check the condition of water tank and
display the present status.
The proposed approach for this system is based on microcontroller controlling system with
simple self-made water level sensor. Microcontroller reads the status of system and give
desired output by switching motor and displaying LCD and LED.











3 | P a g e

CHAPTER 2 LITERATURE REVIEW

This project is based on the embedded systems technology using microcontroller. The
objective of this project is to control the motor used in home and office for water pumping
with the help of switching function of microcontroller with observing status by simple self-
made sensor. In this project we interface LCD and Microcontroller to show the status of
whole system. When water tank is empty motor is automatically start and when tank is full
motor is stop and all condition in you are system will be display in LCD.
The Microcontroller is the embedded device which has on chip program memory in which
the machine control program is stored. Suppose if sensor send signal to turn on the motor,
then the Microcontroller activates the relay which is connected to motor. Now the Motor is
switched ON by relay.

2.1 BLOCK DIAGRAM:
The figure shown below is the simple block diagram of our project. It is a simple illustration
of how we have implemented our project and the various parts involved in it. From the
below representation, the transistors are used as sensors to read status of water level and
sends different signal to the microcontroller. Block diagram of the project is given below :


FIG 2.1: Water level controller using 8051
4 | P a g e


2.2 BASIC BLOCKS OF THE SYSTEM:
2.2.1 Water level sensor:
In market, different water level sensor are available but in this project we have used self-
made sensor. Water level sensor is the simply group of wire. Separate wire conducts voltage
from where the level of water is reached and this voltage is supplied to the transistor and
further to the specific port of the microcontroller.
2.2.2 Microcontroller:
Important features and applications of 8051:
8051 architecture provides many functions (ROM, RAM, CPU, I/O, interrupt logic, timer.
Etc.) in a single package.
8-bit ALU, Accumulator, 8-bit Registers and 8-bit data bus; hence it is an 8-bit
microcontroller
Boolean processor
Multiply, divide and compare instructions
4 register banks (memory mapped)
Fast interrupt with register bank switching
Interrupts with selectable priority
Dual 16-bit address bus It can access 2 x 216 memory locations 64 KB (65536
locations) each of RAM and ROM
128 bytes of on-chip RAM (IRAM)
4 KB of on-chip ROM, with a 16-bit (64 KB) address space (PMEM)
Four byte bi-directional input/output port
5 | P a g e

UART (serial port)
Two 16-bit Counter/timers
Power saving mode (on some derivatives)


2.2.2.1 Pin diagram:

Fig 2.2: Pin diagram of 8051
2.2.3 Relay:
A relay is an electrical switch that opens and closes under the control of another electrical
circuit. In the original form, the switch is operated by an electromagnet to open or close one
or many sets of contacts. It was invented by Joseph Henry in 1835. Because a relay is able to
control an output circuit of higher power than the input circuit, it can be considered to be, in a
broad sense, a form of an electrical amplifier.
6 | P a g e


FIG 2.3: Diagram of sugar cube relays
Despite the speed of technological developments, some products prove so popular that their
key parameters and design features remain virtually unchanged for years. One such product is
the sugar cube relay, shown in the figure above, which has proved useful to many designers
who needed to switch up to 10A, whilst using relatively little PCB area Since relays are
switches, the terminology applied to switches is also applied to relays. A relay will switch
one or more poles, each of whose contacts can be thrown by energizing the coil in one of
three ways:
Normally open pins: contacts connect the circuit when the relay is activated; the
circuit is disconnected when the relay is inactive. It is also called a FORM A contact or
make contact.
Normally closed pins: contacts disconnect the circuit when the relay is activated, the
circuit is connected when relay is inactive. It is also called FORM B contact or break contact
Change over or double through: contacts control two circuits ; one normally open
contact and one normally closed contact with a common terminal. It is also called a form C
transfer contact.
2.2.4 Buzzer
Piezo buzzer is an electronic device commonly used to produce sound. Light weight, simple
construction and low price make it usable in various applications like car/truck reversing
indicator, computers, call bells etc. Piezo buzzer is based on the inverse principle of piezo
7 | P a g e

electricity discovered in 1880 by Jacques and Pierre Curie. It is the phenomena of generating
electricity when mechanical pressure is applied to certain materials and the vice versa is also
true. Such materials are called piezo electric materials. Piezo electric materials are either
naturally available or manmade. Piezoceramic is class of manmade material, which poses
piezo electric effect and is widely used to make disc, the heart of piezo buzzer. When
subjected to an alternating electric field they stretch or compress, in accordance with the
frequency of the signal thereby producing sound
2.2.5 Power supply:
Power supply provides all necessary voltage and current for our system to operate. Power
supply used in this projects convert 220v AC supply in to 5v and 12v dc supply using
transformer, diodes, capacitor and regulator IC. A power supply can by broken down into a
series of blocks, each of which performs a particular function. The unregulated voltage is
supplied a transformer whose output is fed to the bridge rectifier which has capacitor -
2200f/25V across its output terminals to eliminate any ripples. The series combination of
LED - Green and resistor 1K are set across the capacitor to indicate the on state of circuit.
Further, this output of voltage regulator LM7805 has capacitor 0.1f (ceramic) as load across
output terminal to eliminate any remaining ripples. The transformer used is 220V/50Hz to 0-
12V/500mA which is a step down transformer.
2.2.5.1. Voltage regulator:
A voltage regulator is designed to automatically maintain a constant voltage level. A voltage
regulator may be a simple "feed-forward" design or may include negative feedback control
loops. It may use an electromechanical mechanism, or electronic components. Depending on
the design, it may be used to regulate one or more AC or DC voltages.
8 | P a g e


Fig 2.4: Schematic View of Voltage regulator
Electronic voltage regulators are found in devices such as computer power supplies where
they stabilize the DC voltages used by the processor and other elements. In automobile
alternators and central power station generator plants, voltage regulators control the output of
the plant. In an electric power distribution system, voltage regulators may be installed at a
substation or along distribution lines so that all customers receive steady voltage independent
of how much power is drawn from the line.
As our IC i.e 8051 microcontroller works on 5volt, so we have to regulate supply around 5
volts so that it will not harm our IC, otherwise IC may burn

Fig2.5: Internal circuit of voltage regulator
A simple voltage regulator can be made from a resistor in series with a diode (or series of
diodes). Due to the logarithmic shape of diode V-I curves, the voltage across the diode
9 | P a g e

changes only slightly due to changes in current drawn or changes in the input. When precise
voltage control and efficiency are not important, this design may work fine.
The Zener Diode is used in its "reverse bias". From the I-V Characteristics curve we can
study that the zener diode has a region in its reverse bias characteristics of almost a constant
negative voltage regardless of the value of the current flowing through the diode and remains
nearly constant even with large changes in current as long as the zener diodes current remains
between the breakdown current IZ(min) and the maximum current rating IZ(max)

Fig 2.6: working of zener diode
Feedback voltage regulators operate by comparing the actual output voltage to some fixed
reference voltage. Any difference is amplified and used to control the regulation element in
such a way as to reduce the voltage error. This forms a negative feedback control loop;
increasing the open-loop gain tends to increase regulation accuracy but reduce stability
(avoidance of oscillation, or ringing during step changes).
10 | P a g e


FIG 2.7: Block diagram of power supply
2.2.6 LCD Display

FIG 2.8: LCD Display
LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of
applications. A 16x2 LCD display is very basic module and is very commonly used in
various devices and circuits. These modules are preferred over seven segments and other
multi segment LEDs. The reasons being: LCDs are economical; easily programmable; have
no limitation of displaying special & even custom characters (unlike in seven segments),
animations and so on.
A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this
LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers, namely,
Command and Data.The command register stores the command instructions given to the
LCD. A command is an instruction given to LCD to do a predefined task like initializing it,
clearing its screen, setting the cursor position, controlling display etc. The data register stores
11 | P a g e

the data to be displayed on the LCD. The data is the ASCII value of the character to be
displayed on the LCD.


2.2.6.1 Pin Description:
Pin No Function Name
1 Ground (0V) Ground
2 Supply voltage; 5V (4.7V
5.3V)
Vcc
3 Contrast adjustment; through
a variable resistor
VEE
4 Selects command register
when low; and data register
when- high
Register select
5 Low to write to the register;
High to read from the register

Read/write
6 Sends data to data pins when
a high to low pulse is given
Enable
7 8-bit data pins DBO
8 DB1
9 DB2
10 DB3
11 DB4
12 DB5
13 DB6
14 DB7
15 Backlight VCC (5V) LED+
16 Backlight Ground (0V) LED-
TABLE 2.1: Pin description of LCD display






12 | P a g e

CHAPTER 3 COMPONENTS USED

3.1 RESISTORS

FIG 3.1: Resistors

Resistors are "Passive Devices", that is they contain no source of power or amplification but
only attenuate or reduce the voltage or current signal passing through them. This attenuation
results in electrical energy being lost in the form of heat as the resistor resists the flow of
electrons through it.
Then a potential difference is required between the two terminals of a resistor for current to
flow. This potential difference balances out the energy lost. When used in DC circuits the
potential difference, also known as a resistors voltage drop, is measured across the terminals
as the circuit current flows through the resistor.
Most resistors are linear devices that produce a voltage drop across themselves when an
electrical current flows through them because they obey Ohm's Law, and different values of
resistance produces different values of current or voltage. This can be very useful in
Electronic circuits by controlling or reducing either the current flow or voltage produced
across them..
In all Electrical and Electronic circuit diagrams and schematics, the most commonly used
symbol for a fixed value resistor is that of a "zig-zag" type line with the value of its resistance
given in Ohms, . Resistors have fixed resistance values from less than one ohm, ( <1 ) to
well over tens of millions of ohms, ( >10M ) in value. Fixed resistors have only one single
value of resistance, for example 100'sbut variable resistors (potentiometers) can provide an
infinite number of resistance values between zero and their maximum value.
Standard Resistor Symbols

The symbol used in schematic and electrical drawings for a Resistor can either be a "zig-zag"
type line or a rectangular box.
13 | P a g e


All modern fixed value resistors can be classified into four broad groups;
Carbon Composition Resistor - Made of carbon dust or graphite paste, low wattage values
Film or Cermet Resistor - Made from conductive metal oxide paste, very low wattage values
Wire-wound Resistor - Metallic bodies for heatsink mounting, very high wattage ratings
Semiconductor Resistor - High frequency/precision surface mount thin film technology.
Resistor Colour Code
The resistance value, tolerance, and wattage rating are generally printed onto the body of the
resistor as numbers or letters when the resistors body is big enough to read the print, such as
large power resistors. But when the resistor is small such as a 1/4W carbon or film type, these
specifications must be shown in some other manner as the print would be too small to read.
So to overcome this, small resistors use coloured painted bands to indicate both their resistive
value and their tolerance with the physical size of the resistor indicating its wattage rating.
These coloured painted bands produce a system of identification generally known as
a Resistors Colour Code.
A resistors colour code markings are always read one band at a time starting from the left to
the right, with the larger width tolerance band oriented to the right side indicating its
tolerance. By matching the colour of the first band with its associated number in the digit
column of the colour chart below the first digit is identified and this represents the first digit
of the resistance value. Again, by matching the colour of the second band with its associated
number in the digit column of the colour chart we get the second digit of the resistance value
and so on as illustrated below:

Colour Digit Multiplier Tolerance
Black 0 1
Brown 1 10 1%
Red 2 100 2%
Orange 3 1,000
Yellow 4 10,000
Green 5 100,000 0.5%
Blue 6 1,000,000 0.25%
14 | P a g e

Violet 7 10,000,000 0.1%
Grey 8
White 9
Gold 0.1 5%
Silver 0.01 10%
None 20%

Fig 3.2: The Resistor Colour Code.
Calculating Resistor Values
The Resistor Colour Code system is all well and good but we need to understand how to
apply it in order to get the correct value of the resistor. The "left-hand" or the most significant
coloured band is the band which is nearest to a connecting lead with the colour coded bands
being read from left-to-right as follows;Digit, Digit, Multiplier = Colour, Colour x 10
colour
in
Ohm's ('s). For example, a resistor has the following coloured markings;
Yellow Violet Red = 4 7 2 = 4 7 x 10
2
= 4700 or 4k7.
The fourth and fifth bands are used to determine the percentage tolerance of the resistor.
Resistor tolerance is a measure of the resistors variation from the specified resistive value and
is a consequence of the manufacturing process and is expressed as a percentage of its
"nominal" or preferred value.
Typical resistor tolerances for film resistors range from 1% to 10% while carbon resistors
have tolerances up to 20%. Resistors with tolerances lower than 2% are called precision
resistors with the or lower tolerance resistors being more expensive. Most five band resistors
are precision resistors with tolerances of either 1% or 2% while most of the four band
resistors have tolerances of 5%, 10% and 20%. The colour code used to denote the tolerance
rating of a resistor is given as;Brown = 1%, Red = 2%, Gold = 5%, Silver = 10 %. If resistor
has no fourth tolerance band then the default tolerance would be at 20%.




15 | P a g e

3.2 CRYSTAL OSCILLATOR

FIG 3.3: Crystal oscillator
A crystal oscillator is an electronic oscillator circuit that uses the mechanical resonance of a
vibrating crystal of piezoelectric material to create an electrical signal with a very precise
frequency. This frequency is commonly used to keep track of time (as in quartz
wristwatches), to provide a stable clock signal for digital integrated circuits, and to stabilize
frequencies for radio transmitters and receivers. The most common type of piezoelectric
resonator used is the quartz crystal, so oscillator circuits incorporating them became known
as crystal oscillators, but other piezoelectric materials including polycrystalline ceramics are
used in similar circuits. Quartz crystals are manufactured for frequencies from a few tens of
kilohertz to tens of megahertz. More than two billion crystals are manufactured annually.
Most are used for consumer devices such as wristwatches, clocks, radios, computers, and
cellphones. Quartz crystals are also found inside test and measurement equipment, such as
counters, signal generators, and oscilloscopes.
3.3 IC BASE

FIG 3.4: IC Base
16 | P a g e


Using an IC base saves the IC from burning due to overheat if IC is soldered directly. Also,
changing an IC becomes very easy if the IC gets damaged due to some reason and once the
IC- base is soldered, the IC can be easily taken out and fitted back n number of times.
Before soldering the IC-Base it should be checked that all the pins have successfully pierced
the holes of the PCB and appeared on back side because sometimes the some pins are not
able to pierce and get damaged in the process. The IC-Base should be carefully installed
upright according to circuit, but if it gets soldered oppositely by mistake then there is no need
to de-solder the IC-Base, rather the IC should be fitted in the base keeping in mind the
orientation of the circuit.
3.4 DIODES
A diode is a semiconductor device which allows current to flow through it in only one
direction. Although a transistor is also a semiconductor device, it does not operate the way a
diode does. A diode is specifically made to allow current to flow through it in only one
direction. Some ways in which the diode can be used are listed here. A diode can be used as a
rectifier that converts AC (Alternating Current) to DC (Direct Current) for a power supply
device.
A diode is the simplest sort of semiconductor device. Broadly speaking, a semiconductor is a
material with a varying ability to conduct electrical current. Most semiconductors are made of
a poor conductor that has had impurities (atoms of another material) added to it. The process
of adding impurities is called doping.


FIG 3.5: Depletion zone of diode
17 | P a g e

A diode comprises a section of N-type material bonded to a section of P-type material, with
electrodes on each end. This arrangement conducts electricity in only one direction. When no
voltage is applied to the diode, electrons from the N-type material fill holes from the P-type
material along the junction between the layers, forming a depletion zone. In a depletion zone,
the semiconductor material is returned to its original insulating state -- all of the holes are
filled, so there are no free electrons or empty spaces for electrons, and charge can't flow.

At the junction, free electrons from the N-type material fill holes from the P-type material.
This creates an insulating layer in the middle of the diode called the depletion zone.

To get rid of the depletion zone, you have to get electrons moving from the N-type area to the
P-type area and holes moving in the reverse direction. To do this, you connect the N-type side
of the diode to the negative end of a circuit and the P-type side to the positive end. The free
electrons in the N-type material are repelled by the negative electrode and drawn to the
positive electrode. The holes in the P-type material move the other way. When the voltage
difference between the electrodes is high enough, the electrons in the depletion zone are
boosted out of their holes and begin moving freely again. The depletion zone disappears, and
charge moves across the diode.



FIG 3.6: Working of diode

When the negative end of the circuit is hooked up to the N-type layer and the positive end is
hooked up to P-type layer, electrons and holes start moving and the depletion zone
disappears.
18 | P a g e


If we try to run current the other way, with the P-type side connected to the negative end of
the circuit and the N-type side connected to the positive end, current will not flow. The
negative electrons in the N-type material are attracted to the positive electrode. The positive
holes in the P-type material are attracted to the negative electrode. No current flows across
the junction because the holes and the electrons are each moving in the wrong direction. The
depletion zone increases.
3.5 LED





FIG 3.7 LEDS

3.5.1 LED working principle:

Light emitting diodes, commonly called LEDs, are real unsung heroes in the electronics
world. They do dozens of different jobs and are found in all kinds of devices. Among other
things, they form the numbers on digital clocks, transmit information from remote controls,
light up watches and tell you when your appliances are turned on. Collected together, they
can form images on a jumbo television screen or illuminate a traffic light.

Basically, LEDs are just tiny light bulbs that fit easily into an electrical circuit. But unlike
ordinary incandescent bulbs, they don't have a filament that will burn out, and they don't get
especially hot. They are illuminated solely by the movement of electrons in a semiconductor
material, and they last just as long as a standard transistor.
In this article, we'll examine the simple principles behind these ubiquitous blinkers,
illuminating some cool principles of electricity and light in the process.

3.5.2 How Can a Diode Produce Light?
19 | P a g e


Light is a form of energy that can be released by an atom. It is made up of many small
particle-like packets that have energy and momentum but no mass. These particles, called
photons, are the most basic units of light.
Photons are released as a result of moving electrons. In an atom, electrons move in orbitals
around the nucleus. Electrons in different orbitals have different amounts of energy.
Generally speaking, electrons with greater energy move in orbitals farther away from the
nucleus.
For an electron to jump from a lower orbital to a higher orbital, something has to boost its
energy level. Conversely, an electron releases energy when it drops from a higher orbital to a
lower one. This energy is released in the form of a photon. A greater energy drop releases a
higher-energy photon, which is characterized by a higher frequency.

Free electrons moving across a diode can fall into empty holes from the P-type layer. This
involves a drop from the conduction band to a lower orbital, so the electrons release energy in
the form of photons. This happens in any diode, but you can only see the photons when the
diode is composed of certain material. The atoms in a standard silicon diode, for example, are
arranged in such a way that the electron drops a relatively short distance. As a result, the
photon's frequency is so low that it is invisible to the human eye -- it is in the infrared portion
of the light spectrum. This isn't necessarily a bad thing, of course: Infrared LEDs are ideal for
remote controls, among other things.

Visible light-emitting diodes (VLEDs), such as the ones that light up numbers in a digital
clock, are made of materials characterized by a wider gap between the conduction band and
the lower orbitals. The size of the gap determines the frequency of the photon -- in other
words, it determines the color of the light.

3.6 TRANSISTOR
A transistor is a semiconductor device, commonly used as an amplifier or an electrically
controlled switch. The transistor is the fundamental building block of the circuitry in
computers, cellular phones, and all other modern devices. Because of its fast response and
accuracy, the transistor is used in a wide variety of digital and analog functions, including
amplification, switching, voltage regulation, signal modulation, and oscillators. There are
20 | P a g e

mainly two groups of transistors the BJT & the FET. The BJT has both polarity carriers i.e.
Holes and Electrons, while the FET is a special transistor having only one type of carrier
responsible for conduction. Generally there are two types of transistors. They are the NPN &
the PNP. The NPN type has p-type material sandwiched between the n- type materials while
the PNP has n- type material sandwiched between the p- type materials. The transistor has
three terminals namely Base, Collector & Emitter.
3.6.1 BC 548 Transistor

FIG 3.8: BC548 Transistor
The pinout for the package used for the BC546 to BC560 has pin 1 (the leftmost pin in the
diagram above, i.e. when the flat face of the package faces the viewer with leads at the
bottom) attached to the collector, pin 2 connected to the base, and pin 3 connected to the
emitter.









21 | P a g e

CHAPTER 4 WORKING OF WATER LEVEL CONTROLLER

4.1 CIRCUIT DIAGRAM

FIG 4.1: Circuit diagram of water level controller
The figure shown above is the simple circuit diagram of our project. It is a simple illustration
of how we have implemented our project and the various parts involved in it. From the above
representation, the transistors are used as sensors to read status of water level and sends
different signal to the microcontroller.

4.2 WORKING
22 | P a g e

A water level controller based using 8051 is shown in circuit diagram. This water level
controller monitors the level of the over head tank and automatically switches on the water
pump whenever the level goes below a preset limit. The level of the over head tank is
indicated using 5 leds and the pump is switched of when the over head tank is filled. The
pump is not allowed to start if the water level in the sump tank is low and also the pump is
switched off when the level inside the sump tank goes low during a pumping cycle. The
circuit diagram of the water level controller is shown below.
The level sensor probes for the overhead tank are interfaced to the port 2 of the
microcontroller through transistors. Have a look at the sensor probe arrangement for the
overhead tank in Fig1. A positive voltage supply probe goes to the down bottom of the tank.
The probes for sensing 1/4, 1/2, 3/4 and FULL levels are placed with equal spacing one by
one above the bottom positive probe. Consider the topmost (full level) probe, its other end is
connected to the base of transistor Q4 through resistor R16. Whenever water rises to the full
level current flows into the base of transistor Q4 which makes it ON and so its collector
voltage goes low. The collector of Q4 is connected to P2.4 and a low voltage at P2.4 means
the over head tank is not FULL. When water level goes below the full level probe, the base of
Q2 becomes open making it OFF. Now it is collector voltage goes high and high at P2.4
means the tank is not full. The same applies to other sensor probes (3/4, 1/2, 1/4) and the
microprocessor understands the current level by scanning the port pins P2.4 ,P2.5, P2.6 and
P2.7. All these port pin are high (all sensor probes are open) means the tank is empty.
Port pin P0.5 is used to control the pump. Whenever it is required start pumping, the
controller makes P0.5 low which makes transistor Q6 ON which in turn activates the relay
K1 that switches the pump. Also the LED d6 glows indicating the motor is ON. LED D7 is
the low sump indicator. When the water level in the sump tank goes low, the controller makes
P0.7 low which makes LED D7 to glow.
4.3 PROGRAM
ORG 00H
MOV P2,#11111000B // INITIATES P2 AS SENSOR INPUT
MOV P0,#11111111B // INITIATES P0 AS THE OUTPUT PORT
23 | P a g e

MOV P1,#00000000B // INITIATES P1 AS LCD OUTPUT PORT
SETB P3.7 // BUZZER

MOV A,#38H
ACALL COMNWRT
ACALL DELAY
MOV A,#0EH
ACALL COMNWRT
ACALL DELAY
MOV A,#01H
ACALL COMNWRT
ACALL DELAY
MOV A,#06H
ACALL COMNWRT
ACALL DELAY
MOV A,#84H
ACALL COMNWRT
ACALL DELAY
MOV A,#00000000B //TO COMPARE ALL LEVELS

24 | P a g e

MAIN: ACALL SMPCK // CHECKS THE LEVEL OF THE SUMP TANK
MOV A,P2 // MOVES THE CURRENT STATUS OF P2 TP A
ACALL ABC
CJNE A,#00001000B,LABEL1 // CHECKS WHETHER TANK IS FULL
SETB P0.1// SWITCH OFF OTHER LED'S
SETB P0.2
SETB P0.3
SETB P0.4
CLR P0.0 // GLOWS FULL LEVEL LED
MOV A,#'f'
ACALL DATAWRT
ACALL DELAY
MOV A,#'u'
ACALL DATAWRT
ACALL DELAY
MOV A,#'l'
ACALL DATAWRT
ACALL DELAY
MOV A,#'l'
ACALL DATAWRT
25 | P a g e

ACALL DELAY
MOV A,#01H
ACALL COMNWRT
ACALL DELAY
SETB P0.5// SWITCH OFF PUMP
LABEL1:MOV A,P2
ACALL ABC
CJNE A,#00011000B,LABEL2 // CHECKS WHETHER TANK IS 3/4
SETB P0.0
SETB P0.2
SETB P0.3
SETB P0.4
CLR P0.1 // GLOWS 3/4 LEVEL LED
MOV A,#'t'
ACALL DATAWRT
ACALL DELAY
MOV A,#'h'
ACALL DATAWRT
ACALL DELAY
MOV A,#'i'
26 | P a g e

ACALL DATAWRT
ACALL DELAY
MOV A,#'r'
SJMP MAIN4
MAIN3:SJMP MAIN
MAIN4:ACALL DATAWRT
ACALL DELAY
MOV A,#'d'
ACALL DATAWRT
ACALL DELAY
MOV A,#'f'
ACALL DATAWRT
ACALL DELAY
MOV A,#'o'
ACALL DATAWRT
ACALL DELAY
MOV A,#'u'
ACALL DATAWRT
ACALL DELAY
MOV A,#'r'
27 | P a g e

ACALL DATAWRT
ACALL DELAY
MOV A,#'t'
ACALL DATAWRT
ACALL DELAY
MOV A,#'h'
ACALL DATAWRT
ACALL DELAY
MOV A,#01H
ACALL COMNWRT
ACALL DELAY
LABEL2:MOV A,P2
ACALL ABC
CJNE A,#00111000B,LABEL3 // CHECKS WHETHER TANK IS 1/2
SETB P0.0
SETB P0.1
SETB P0.3
SETB P0.4
CLR P0.2 // GLOWS 1/2 LEVEL LED
MOV A,#'h'
28 | P a g e

ACALL DATAWRT
ACALL DELAY
MOV A,#'a'
ACALL DATAWRT
ACALL DELAY
MOV A,#'l'
ACALL DATAWRT
ACALL DELAY
MOV A,#'f'
ACALL DATAWRT
ACALL DELAY
MOV A,#01H
ACALL COMNWRT
ACALL DELAY
LABEL3:MOV A,P2
ACALL ABC
CJNE A,#01111000B,LABEL4 // CHECKS WHETHER TANK IS 1/4
SETB P0.0
SETB P0.1
SETB P0.2
29 | P a g e

SETB P0.4
CLR P0.3 // GLOWS 1/4 LEVEL LED
SJMP MAIN2
MAIN1:SJMP MAIN3
MAIN2:MOV A,#'o'
ACALL DATAWRT
ACALL DELAY
MOV A,#'n'
ACALL DATAWRT
ACALL DELAY
MOV A,#'e'
ACALL DATAWRT
ACALL DELAY
MOV A,#'f'
ACALL DATAWRT
ACALL DELAY
MOV A,#'o'
ACALL DATAWRT
ACALL DELAY
MOV A,#'u'
30 | P a g e

ACALL DATAWRT
ACALL DELAY
MOV A,#'r'
ACALL DATAWRT
ACALL DELAY
MOV A,#'t'
ACALL DATAWRT
ACALL DELAY
MOV A,#'h'
ACALL DATAWRT
ACALL DELAY
MOV A,#01H
ACALL COMNWRT
ACALL DELAY
JB P0.6,LABEL4
CLR P0.5 // SWITCHES MOTOR ON
LABEL4:MOV A,P2
ACALL ABC
CJNE A,#11111000B,MAIN1 // CHECKS WHETHER TANK IS EMPTY
SETB P0.0
31 | P a g e

SETB P0.1
SETB P0.2
SETB P0.3
CLR P0.4 // GLOWS EMPTY LED
MOV A,#'e'
ACALL DATAWRT
ACALL DELAY
MOV A,#'m'
ACALL DATAWRT
ACALL DELAY
MOV A,#'p'
ACALL DATAWRT
ACALL DELAY
MOV A,#'t'
ACALL DATAWRT
ACALL DELAY
MOV A,#'y'
ACALL DATAWRT
ACALL DELAY
CLR P3.7 //BUZZER
32 | P a g e

ACALL DELAY
ACALL DELAY
ACALL DELAY
ACALL DELAY
ACALL DELAY
MOV A,#01H
ACALL COMNWRT
ACALL DELAY
SETB P3.7 // BUZZER

JB P0.6,MAIN9 // CHECKS WHETHER SUMP IS LOW
CLR P0.5 // SWITCHES MOTOR ON
MAIN9:AJMP MAIN1

SMPCK:JB P0.6,LABEL5 // CHECKS WHETHER SUMP IS LOW
SETB P0.7 // EXTINGUISHES THE SUMP LOW INDICATOR LED
SJMP LABEL6
LABEL5:SETB P0.5 // SWITCHES THE PUMP OFF
CLR P0.7 // GLOWS SUMP LOW INDICATOR LED
LABEL6:RET
33 | P a g e

COMNWRT: MOV P1,A
CLR P2.2 //RS
CLR P2.1 //RW
SETB P2.0 //EN
ACALL DELAY
CLR P2.0 //EN
RET
DATAWRT: MOV P1,A
SETB P2.2 //RS
CLR P2.1 //RW
SETB P2.0 // EN
ACALL DELAY
CLR P2.0 //EN
RET

DELAY: MOV R3,#120
HERE2: MOV R4,#255
HERE: DJNZ R4,HERE
DJNZ R3,HERE2
RET
34 | P a g e


ABC:CLR P2.0
CLR P2.2
CLR P2.1
RET

END

35 | P a g e

CHAPTER 5 RESULTS AND DISCUSSIONS

5.1 KEIL SOFTWARE
5.1.1 Introduction to KEIL
Keil MicroVision is an integrated development environment used to create software to be run
on embedded systems (like a microcontroller). It allows for such software to be written either
in assembly or C programming languages and for that software to be simulated on a computer
before being loaded onto the microcontroller.
Vision3 is an IDE (Integrated Development Environment) that helps write, compile, and
debug embedded programs. It encapsulates the following components:
A project manager.
Make facility.
Tool configuration
Editor
A powerful debugger.

5.1.2 To create a new project in Uvision3:
1. Select Project - New Project.
2. Select a directory and enter the name of the project file.
3. Select Project = Select Device and select a device from Device Database.
4. Create source files to add to the project
36 | P a g e

5. Select Project - Targets, Groups, and Files. Add/Files, select Source Group1, and add the
source files to the project.
6. Select Project - Options and set the tool options. Note that when the target device is
selected from the Device Database all-special options are set automatically. Default memory
model settings are optimal for most applications.
7. Select Project - Rebuild all target files or Build target.
To create a new project, simply start MicroVision and select Project=>New Project from the
pull down menus. In the file dialog that appears, choose a name and directory for the project.
It is recommended that a new directory be created for each project, as several files will be
generated. Once the project has been named, the dialog shown in the figure below will
appear, prompting the user to select a target device. In this lab, the chip being used is the
AT89C52, which is listed under the heading Atmel.
Window for choosing target device.
Next, Micro Vision must be instructed to generate a HEX file upon program compilation. A
HEX file is a standard file format for storing executable code that is to be loaded onto the
microcontroller. In the Project Workspace pane at the left, right click on Target 1 and select
Options for 1 .Under the Output tab of the resulting options dialog, ensure that both the
Create Executable and Create HEX File options are checked. Then click OK.
Project Options Dialog
Next, a file must be added to the project that will contain the project code. To do this, expand
the Target 1 heading, right click on the Source Group 1 folder, and select Add files. Create a
new blank file (the file name should end in .asm), select it, and click Add. The new file
should now appear in the Project Workspace pane under the Source Group 1 folder. Double-
click on the newly created file to open it in the editor. All code for this lab will go in this file.
To compile the program, first save all source files by clicking on the Save All button, and
then click on the Rebuild All Target Files to compile the program as shown in the figure
below. If any errors or warnings occur during compilation, they will be displayed in the
output window at the bottom of the screen. All errors and warnings will reference the line and
column number in which they occur along with a description of the problem so that they can
37 | P a g e

be easily located. Note that only errors indicate that the compilation failed, warnings do not
(though it is generally a good idea to look into them anyway).
Project Workspace Pane
Save All and Build All Target Files Buttons
When the program has been successfully compiled, it can be simulated using the integrated
debugger in Keil MicroVision. To start the debugger, select Debug=>Start/Stop Debug
Session from the pull down menus.
At the left side of the debugger window, a table is displayed containing several key
parameters about the simulated microcontroller, most notably the elapsed time (circled in the
figure below). Just above that, there are several buttons that control code execution. The Run
button will cause the program to run continuously until a breakpoint is reached, whereas the
Step Into button will execute the next line of code and then pause (the current position in the
program is indicated by a yellow arrow to the left of the code).
5.2 PROGRAMMER
The programmer used is a powerful programmer for the Atmel 89 series of microcontrollers
that includes 89C51/52/55, 89S51/52/55 and many more.
It is simple to use & low cost, yet powerful flash microcontroller programmer for the Atmel
89 series. It will Program, Read and Verify Code Data, Write Lock Bits, Erase and Blank
Check. All fuse and lock bits are programmable. This programmer has intelligent onboard
firmware and connects to the serial port. It can be used with any type of computer and
requires no special hardware. All that is needed is a serial communication port which all
computers have.8051 to USB programmer is used here.

5.3 PCB LAYOUT
Layout designing to a generic strip board can be very inefficient due to human error in layout
and solder connections. Strip boards are also not aesthetically pleasing. A better solution,
which is both more professional When the development stage of a circuit board is complete
38 | P a g e

and working correctly, it is then necessary to take this breadboard prototype and create a
sharp looking finished product. A prototype can be moved to a strip board inexpensively and
fast, not to mention at basically no cost. However, this movement looking and more robust,
is to create a Printed Circuit Board.The design of a Printed Circuit Board (PCB) requires a
completed or near completed and functional breadboard circuit. In the best-case situation, the
full circuit will be laid out on the breadboard and can then be transferred to the PCB. The
PCB is where the connections and components must come together correctly to ensure proper
functionality. When transferring the design, the PCB will allow for a much smaller PCB then
the breadboard. The user can achieve this by closer interconnects and component placement
as well as some reduced some chip sizes. Another benefit to designing a PCB specific to the
product is that the PCB can be made any 2-dimensional size and shape. This allows the PCB
to fit into the design and not trying to fit the design around the PCB. Once a PCB has been
designed it can be produced hundred of times with exact precision. Therefore, the PCB
designer should take care when designing it to ensure it is correct, efficient, and as
inexpensive as possible.
Designing the Board
Start by installing the ExpressPCB freeware. The software can be found at
ExpressPCB.com.
Once the software has been installed, start by opening ExpressPCB. The program
defaults to a two-layer board.
ExpressPCB defaults to a PCB size of 3.8 inches by 2.50 inches. Selecting the View
tab then clicking on Options can easily change the units.
Placing Components
When placing components there are a few important steps that will make the design run
smoother. First, place all large components. Second, attempt to place components that are
connected to one another as close together as possible to eliminate excess traces. Third, keep
in mind that wireless or other components that are used for transmitting or receiving a signal
should be kept towards the perimeter of the board. By keeping these components as near to
the perimeter as possible the user can reduce the chance of interference. Keeping the above
39 | P a g e

listed suggestions in mind one can locate the per-existing components under the Components
tab by clicking the Component Manager link.
Placing Traces
Similar to placing components there are a few helpful hints for placing traces. First, avoid 90
degree traces. Right angle traces cause a decrease in impedance. A simple solution is to use
45 degree traces. Second, never cross power or ground traces. Third, keep traces as short as
possible this keeps them efficient. Fourth, keep trace width in mind. Depending on the
component and the connection, these will vary. Keeping these hints in mind, the user should
begin by supplying a voltage and ground trace to each component for which is it required.
Notice that the default thickness of the trace is 0.010 inches. Typically a ground trace is 0.025
inches wide.
Ordering a PCB
Take top view and bottom view printouts. Once the PCB has been created and verified the
user can place an order.










40 | P a g e

CHAPTER 6 APPLICATIONS , LIMITATIONS , CONCLUSION
________________________________________
6.1 APPLICATIONS
The automatic water level controller system can be used broadly over different fields. Some
of the major fields are listed below:
Personal use
Office use
Business
Education

6.2 LIMITATIONS
If the one wire of the sensor is broken system is halted
Sensor operated on the principle of water conduct electricity so sometimes it doesnt
work so we can change sensor type as our requirement.
System debugging is difficult for normal user

6.3 CONCLUSION
After analyzing and working in this project we concluded that project is very useful in daily
life of people .We faced few problems while doing this project till. We did a group work and
with the help of our supervisor and faculty members we are so close in success of our project.
Thus, the project we have undertaken has helped us gain a better perspective on various
aspects related to our course of study as well as practical knowledge of electronic equipment.
We became familiar with software analysis, designing, implementation, testing and
maintenance concerned with our project. we are developing a useful project that could
indicate levels of water and helping general public to avoid wastage of precious natural
resource water when not required or by switching motor on and off according to the display
on LCDs & LEDs.

41 | P a g e

REFERENCES
http://www.thefreedictionary.com/buzzer
www.datasheetarchive.com
www.alldatasheet.com
www.answers.com
www.google.com
The 8051Microcontroller by Kenneth J. Ayala
The 8051 Microcontroller and Embedded Systems by Muhammad Ali Mazidi.
http://www.electronicsforu.com/EFYLinux/efyhome/cover/February2010/Developing-
PCBs.pdf

You might also like