You are on page 1of 65

Water Level Controller Using Microcontroller and Buzzer

A
Project Report
Submitted in Partial Fulfillment for the award of the Degree of

Bachelor of Technology
In

ELECTRONICS & COMMUNICATION ENGINEERING


By

Ashutosh Kumar (1103331043)


Chandrakant

(0903331042)

Chandan Kumar Kharwar (1003331026)

Under the Guidance of


Dr. Amit Kumar Panday

RAJ KUMAR GOEL INSTITUTE OF TECHNOLOGY


GHAZIABAD
UTTAR PRADESH TECHNICAL UNIVERSITY
LUCKNOW

ABSTRACT
As we know that the water level controller is used at our homes and many industries.
It is the most important for the higher buildings because it is very difficult to control
the pump manually to avoid the over flow of the water tank. So the water level
controller is introduced to control the over flow of the water tank.
Water Level Controller is an automatic controller which controls the water level
in the water tank.
This project describes the water level controller unit on the basis of the requirement of
the components used in this controller. This project is implemented using AT89s52
microcontroller (ATMEL 8051 MCU), a 162 LCD, BC547 NPN transistor as the
major components. In this project the microcontroller is used to control and process
the signals obtained from the sensors (wires) in the water tank. The wires are used for
different levels of the water in the tank. These wires detect the water level in the tank
and produce a signal to the microcontroller through the transistors.
The water level controller is based on the principle that the water conducts
electricity. As the wire is dipped in to the tank for the water level detection and a
dc power supply is also connected at the base of the water tank. When the water
is in contact with the wires then the signal is activated through the transistor and
the microcontroller executes the instructions as per requirement. Hence this is
fully automatic controller which also drives the motor.
The water level controller is also designed to produce an output to the display and a
sound which is produced by the device known as buzzer. The buzzer acts as the alarm
when the required task is completed then microcontroller enables the buzzer to
produce the sounds of different frequencies for different tasks. Hence this can be a
process for a person to know what is happening at the particular time instant.
Finally we can say that it is most important for general purpose and industrial purpose
both. This can be installed at homes, in buildings and in industry also. At last, we are
very happy that this project has been completed by us under the guidance of
DR. AMIT KUMAR PANDAY who has helped us at every instant of time.
Group Members
Ashutosh Kumar
Chandrakant
Chandan Kumar Kharwar

ACKNOWLEDGEMENT
All praises be to GOD for blessing me with opportunities abound and showering upon me his mercy
and guidance all through the life. I pray that He continues the same the rest of my life.

We are indebted to our mentor, Dr. Amit Kumar Panday, Associate


Professor, Department of Electronics & Communication Engineering, for
giving us an opportunity to work under his guidance . Like a true mentor, he
motivated and inspired us throughout the entire duration of our work. So we take
this opportunity to express our gratitude and thanks with respect for him.

We
are
also
grateful
to
Prof. Puneet C. Srivastava, Professor,
Department of Electronics & Communication Engineering, for his valuable
suggestion in completing this project time to time.

Also, we would like to express our special thanks to Dr. Dheerendra Kumar,
Professor & Head, Department of Electronics & Communication Engineering,
for giving this opportunity to complete this project.

We would like to express our sincere thanks to Dr. Praveen Malik, Associate
Professor, Department of E&C and Prof. Ramendra Singh, Associate Professor,
Department of E&C, for their suggestions and motivation.
Finally, we would like to thank all the staff members of the department of E&C to
help us at every time during this project.
At last,we would like to express our unseen gratitude to our parents for their blessings
and support without which no work can never be completed.

Ashutosh Kumar
Chandrakant
Chandan Kumar Kharwar

CANDIDATE DECLARATION
The project entitled as Water Level Controller Using Microcontroller and Buzzer
has been completed by us.Our group members are Ashutosh Kumar, Chandrakant and
Chandan Kumar Kharwar.We are very happy to inform you that we have completed
this project under the guidance of Dr. Amit Kumar Panday, Associate Professor,
Department of Electronics & Communication Engineering at RKGIT. We were
very sincere during the project work.

Now, we would like to thanks heartily to persons who have helped us at every time
during our project. We are also in debt of all the faculty staff who have helped us in
our project.

Finally, we thanks to our group members to each other to support at every time to
complete this project.

We also thanks to our HOD sir for giving us full time to complete this project.

Ashutosh Kumar
Chandrakant
Chandan Kumar Kharwar

CERTIFICATE
This is to certify that the project titled as WATER LEVEL CONTROLLER
USING MICROCONTROLLER AND BUZZER is a bonafide record of
work done by Ashutosh Kumar, Chandrakant and Chandan Kumar
Kharwar in partial fulfillment of the requirements for the award of
the degree of Bachelor of Technology in Electronics & Communication
Engineering at the Raj Kumar Goel Institute of Technology,
Ghaziabad, under my supervision and guidance.

To the best of my knowledge the matter embodied in this project had not
been submitted to any other Institute / University for the award of any
degree or Diploma.

I wish them for their best of life in future.

Date: - 28/04/2015

Dr. Amit Kumar Panday


Associate Professor
Department of ECE
RKGIT, Ghaziabad.

List of Figures
1. Block diagram.14
2. Project block diagram ....16
3. Transformer circuit representation ........17
4. Diodes 1N4004 representation...18
5. DC motor performance table..19
6. Bridge rectifier circuit diagram..20
7. Voltage regulator IC table..20
8. Resistor figure and symbol ....21
9. Transistors figure22
10. Transistor symbol ...23
11. Relay circuit diagram .24
12. Power supply figure....26
13. Pin description LCD........27
14. Pin diagram LCD........27
15. LCD image..28
16. DC motor images28
17. 8051 pin configuration ...30
18. 8051 pin description table...31
19. Project circuit diagram ....32
20. 8051 image..33

DEDICATION

Dedicated to
God
And
Our Parents

CONTENTS
Cover Page 1
Abstract .2
Acknowledgement .....3
Candidate Declaration ...4
Certificate ..5
List of Figures ...6
Dedication .7

Chapter 1: Introduction .11-14


1.1 Water Level Controller Using Microcontroller and Buzzer ..11
1.2 Background 12
1.3 Aims and Objective. ...12
1.4 Scope of the Study ..13
1.5 Constrains13
1.6 Limitations of the Project ...13
1.7 Block diagram.14

Chapter 2: Methodology.15-28
2.1 Project Block Diagram.16
2.2 Water Level Detecting Probes..17
2.3 System Analysis ...17
2.4 Step-Down Transformer ...17
2.5 Transformer Circuit Representation..18

2.6 Diodes........18
2.7 DC Motor...19
2.8 Bridge Rectifier..19
2.9 Voltage Regulators.20
2.10 Resistors...21
2.11 Transistors ...22
2.12 Relays ..23
2.13 Piezzo Electric Buzzer..25
2.14 Hardware Component...25
2.15 Power Supply Unit....25
2.16 Display unit ..26
2.17 Pump Control Unit....28

Chapter 3: The Microcontroller 8051...29-49


3.1 Introduction.29
3.2 Pin Configuration31
3.3 Interfacing with LCD..31
3.4 Input / Output..31
3.5 Crystal Oscillator49
3.6 Diagram..49

Chapter 4: Circuit Analysis..50-54


4.1 Project Circuit Diagram.50
9

4.2 Circuit Connections Review..50


4.3 Additional Requirements of the Circuit.50
4.5 Circuit Elements.51
4.6 Soldering52

Chapter 5: Software Design.55-57


5.1 Language Selection55
5.2 Programming..55
5.3 Debugging..56
5.4 Software Testing57

Chapter 6: Testing and Implementation..58-64


6.1 Assembling of Project....58
6.1.0 PCB Designing.....59
6.2 Implementation..59
6.3 Testing...59
6.3.0 Components Testing59
6.3.1 Transformer Testing63
6.3.2 Other Testing.. 63
6.4 Errors Encountered... 64
6.5 Removing Errors... 64
6.6 Packaging (Casing)64
6.7 Conclusion.64
6.8 References.64
6.9 Bibliography. 65

10

Chapter 1: Introduction

1.1 Water Level Controller Using Microcontroller and Buzzer


As we know that the water level controller is used at our homes and many
industries. I t is the most important for the higher buildings because it is very
difficult to control the pump manually to avoid the over flow of the water tank
So the water level controller is introduced to control the over flow of the water
tank.
Water Level Controller is an automatic controller which controls the water level
in the water tank.
This project describes the water level controller unit on the basis of the
requirement of the components used in this controller. This project is
implemented using AT80c51 microcontroller (ATMEL 8051 MCU), a 162
LCD, BC547 NPN transistor as the major components . In this project the
microcontroller is used to control and process the signals obtained from the
sensors (wires) in the water tank. The wires are used for different levels of the
water in the tank. These wires detect the water level in the tank and produce a
signal to the microcontroller through the transistors.
The water level controller is based on the principle that the water conducts
electricity. As the wire is dipped in to the tank for the water level detection and a
dc power supply is also connected at the base of the water tank. When the water is
in contact with the wires then the signal is activated through the transistor and the
microcontroller executes the instructions as per requirement. Hence this is fully
automatic controller which also drives the motor.
The water level controller is also designed to produce an output to the display
and a sound which is produced by the device known as buzzer. The buzzer acts as
the alarm when the required task is completed then microcontroller enables
the buzzer to produce the sounds of different frequencies for different tasks.
Hence this can be a process for a person to know what is happening at the
particular time instant.
Finally we can say that it is most important for general purpose and industrial
purpose both. This can be installed at homes, in buildings and in industry also.

11

1.2 Background
The project automatic water level controller using microcontroller and buzzer is
a design to monitor the level of water in the tank. The system has an automatic
pumping system attached to it so as to refill the tank once the water gets to the
lower threshold level, while offing the pump once the liquid gets to the higher
threshold level. Sustainability of available water resource in many reason of the
world is now a dominant issue. This problem is quietly related to poor water
allocation, inefficient use, and lack of adequate and integrated water management.
Water is commonly used for agriculture, industry, and domestic consumption.
Therefore, efficient use and water monitoring are potential constraint for home or
office water management system. Moreover, the common method of level control
for home appliance is simply to start the feed pump at a low level and allow it to
run until a higher water level is reached in the water tank. This water level control,
controls monitor and maintain the water level in the overhead tank and ensures the
continuous flow of water round the clock without the stress of going to switch the
pump ON or OFF there by saving time, energy, water, and prevent the pump from
overworking. Besides this, water/liquid level control systems are widely used for
monitoring of liquid levels in reservoirs, silos. Proper monitoring is needed to
ensure water sustainability is actually being reached with disbursement linked to
sensing and automation, such programmatic approach entails microcontroller based
automated water level sensing and controlling or using 555 timer IC.

1.3 Aims and Objective


The goal or objectives of which the designed device is expected to accomplish is to
build an automatic water level control with automatic control system. In this
project sensors(probes/wires) are place at different level of the tank and with the
aid of these sensors, the micro-controller monitor the level of the water at any
particular point in time, some of the objectives are1. To design an automatic water monitoring system
2. To incorporate an interactive medium between the end user and the machine
3. To prevent over labour of the pumping machine and prevent it from getting bad
4. To avoid wastage of water
12

5. Since the demand of electricity is very high, automatic water level control the
over use of electricity and saves energy at a large amount.

1.4 Scope of the Project


The project was designed to automatically control the pump which ensures
constant reserve of water level in the tank. The scope of the design was keep
concise and simple to in other not to introduce unnecessary complexities and
render it generally uncomfortable. The system does not have attached complex
peripheral device which though impossible for the detail printable information has
been excluded for reasons of affordability material of low range and less accurate
performances as opposed to a well-built automatic water pump was used to
achieve this aim, the automatic water level controller detect and control the water
in the tank.

1.5 Constrains
The biggest setback experience during the course of this project is difficulties in
finding the design of the project, secondly sourcing of material and component. I
used for the project were difficult to find like pump and programming.

1.6 Limitations of the Project


It is significant to know that this design is limited to 230V,50Hz electric pump
and cannot be used to control industrial water pump above 230V. It can also
be used to drive a dc motor.

13

1.7 Block diagram

DISPLAY

MOTOR/

CONTROL UNIT

INPUT

PUMP

OUTPUT

Block Diagram of Water level Controller Using Microcontroller and Buzzer

14

Chapter 2: Methodology
An automatic water level control detects the water level in the tank and also
ensures continuous water flow round the clock because of its automatic, this
automatic water control is made up of microcontroller written in C programming
language this program is burn into an IC called AT89C51 With 40 pins. The level
measurement consist of determining the distance from the upper surface of a liquid
in a reservoir or vessel or any arbitrarily chosen mark located above or below this
surface by itself the level is not an independent physical quantities describing the
state of a substance through direct and indirect level, some examples of direct level
measurement are dipstick, the bubbler, immersion electrode, capacitor type ,liquid
level radiation type liquid level measurement .for instance the dipstick, it is very
simple, the stick being dipped periodically through a hole and the hole and the
immersion mark is being read off with the aid of the calibration on the stick. Then,
the direct level measurement are sight glass , depending on the manometer
principle, the transparent tube is place in a convenient and its being connected to
the lower part of tank and graduated for safety reasons, the top the bright glass is
vented into the tank and the sight has isolation valve top and bottom while the
micro base; water level controller has the ability to switch on the pumping machine
when the water in the tank has gone below wire level automatically switches the
OFF the pumping machine when the water in the tank has reach its maximum
level. Electronics circuit has undergone tremendous changes since the invention of
a triode by LEE DE FOREST in 1907. In those days the active component like
resistors, inductors and capacitors etc. Of the circuit were separated and distinct
unite connected by soldered lead with the invention of a transistor in 1984 by W.H
Brattain and I.barden, the electronic circuit became considerably reduced in size.
IT was due to the fact that transistors were not only cheaper, more reliable and less
power consumption but was much smaller in size than an electronic tube. To take
advantage of small transistors size, the passive component too were reduce in size
there by making the entire circuit very small development of printed circuit
board(PCB) further reduce the size of electronics equipment by eliminating bulky
wiring and tie point. In the early 1960s a new field of micro-electronics was born
primarily to meet the requirement of the military which was to reduce the size of it
electronics equipment to approximately one tenth of it then existing volume.

The main advantage of the water level controller that it can be handeled easily.The
water level controller is an important device that is used to control the water level.

15

2.1 Project Block Diagram

INPUT TRAN

LCD AND
ALARM

IC 89C51
SISTOR

5V POWER SUPPLY

RELAY

MOTOR/PUM
P

FIG.2 BLOCK DIAGRM OF THE PROJECT WATER LEVEL CONTROLLER


USING MICROCONTROLLER AND BUZZER

16

2.2 Water Level Detecting Probes


The water level detecting probes are used to detect the water level in the tank.
Here we have used water level probes wires to detect the water level in the tank
these wires detect the water level in the tank and sends the signal to the
microcontroller then it checks the input and produces the output as the input.
Hence these are the probes used in the water level controller.

2.3 System Analysis


This project design automatic water level controller for both over head and
underground tank with switching device is to ensure a higher rate of water
monitoring the major component used in the project design are fund level detection
sensors, micro-controller IC AT89C51, the power supply unit, relays switch and
motor.

2.4 Step-Down Transformer


A transformer is a device consisting of two closely coupled coils called primary
and secondary coils. An AC voltages applied to the primary appears across the
secondary with a voltage multiplication proportional to the to primary appears
across the secondary with a voltage multiplication proportion to the turn ratio of
the transformer and a current multiplication inversely proportional to the turn ratio
power is,
Vp/Vs = Np/Ns
Np = number of turns in primary coil
Ip = primary input current
Vs = Secondary output voltage
Ns = number of turns on secondary coil

2.5 Transformer Circuit Representation

17

2.6 Diodes
A diode is a two terminal electronic component with asymmetric conductance, it
has low ( ideally zero ) resistance to current in one direction, and high
(ideally infinite) resistance in the other. A semiconductor diode, the most
common type today, is a crystalline piece of semiconductor material with a p-n
junction connected to two electrical terminals. A vacuum tube diode has
two electrodes, aplate (anode) and a heated cathode. Semiconductor diodes were
the first semiconductor electronic devices. The disc. of crystals'rectifying abilities
was made by German physicist Ferdinand Braun in 1874. The first semiconductor
diodes, called cat's whisker diodes, developed around 1906, were made of mineral
crystals such as galena. Today, most diodes are made of silicon, but other
semiconductors such as selenium or germanium are sometimes used.

The diodes used in this project are general purpose diodes 1N4004.

The 1N4001 series (or 1N4000 series) is a family of popular 1.0 A general
purpose silicon rectifier diodes commonly used inAC adapters for common
household appliances. Blocking voltage varies from 50 to 1000
volts. This
diode is made in an axial-lead DO-41plastic package.
18

2.7 DC Motor
The dc motor used in this project is 200 RPM Side Shaft Heavy Duty DC
Gear Motor is suitable for large robots / automation systems. It has sturdy
construction with gear box built to handle stall torque produced by the motor.
Drive shaft is supported from both sides with metal bushes. Motor runs smoothly
from 4V to 12V and gives 200 RPM at 12V. Motor has 8mm diameter, 17.5mm
length drive shaft with D shape for excellent coupling.
Table below gives fairly good idea of the motors performance in terms of RPM vs
voltage at no load and that of stall torque at different voltages.

Voltage (V)

RPM (No Load)

2
4
6
8
10
12

32.1
65.6
107.2
145.7
190.2
228.2

Stall torque Stall Current


(Kg/cm)
(A)
1.95
6.29
7.9
8.19
9.36
14.82

0.5
1.2
1.7
2.9
3.3
4.0

2.8 Bridge Rectifier


A bridge rectifier can be made using four individual diodes, but it is also
available in special packages containing the four diodes required. It is called fullwave rectifier because it uses the entire AC waves (both positive and negative
section) 1.4v is used up in the bridge rectifier because each diode uses 0.7v when
diodes conducting as shown in the figure below. The maximum current they can
pass rates bridge rectifiers and the maximum reverse voltage they can withstand
this must be of least three times the supply RMs voltages so the rectifier can
withstands the peak voltage.

Alternate pairs of diode conduct changing over the connections so the alternating
directions of AC are converted to the direction of DC.

19

2.9 Voltage Regulators


A voltage regulator also called a regulator has only three legs and appears to
be a comparatively simple device but it is actually a very complex in integrated
circuit. A regulator converts varying input voltages and produces a constant
regulated output voltage. Voltage regulators are available in a variety of output.
Last two digits in the name indicate the output voltages in the table below.

IC NAME

OUTPUT VOLTAGE

IC 7805
IC 7806
IC 7809
IC 7812
IC 7905
IC 7906
IC 7909
IC 7912

+5V
+6V
+9V
+12V
-5V
-6V
-9V
-12V

20

2.10 Resistors
Resistors are the most commonly used component in electronics and their
purpose is to create specified values of current and voltage in a circuit. A number
of different resistors are shown in the below. (The resistors are on millimeter
paper, with 1cm spacing to give some idea of the dimensions). Figure
2.10a shows some low-power resistors, while figure 2.10b shows some higherpower resistors. Resistors with power dissipation below 5 watt (most commonly
used types) are cylindrical in shape, with a wire protruding from each end for
connecting to a circuit (figure2.10-a). Resistors with power dissipation above 5
watt are shown below (figure 2.10-b).

Fig. 2.10a: Some low-power resistors

Fig. 2.10b: High-power resistors and


rheostats

The symbol for a resistor is shown in the following diagram (upper: American
symbol, lower: European symbol.)

Fig. 2.10C: Resistor symbols

The unit for measuring resistance is the OHM. ( the Greek letter - called
Omega). Higher resistance values are represented by "k"(kilo-ohms) and M (meg
ohms). For example, 120 000 is represented as 120k, while 1 200 000 is
represented as 1M2. The dot is generally omitted as it can easily be lost in the
printing process. In some circuit diagrams, a value such as 8 or 120 represents a
resistance in ohms. Anothercommon practice is to use the letter E for resistance in

21

ohms. The letter R can also be used. For example, 120E (120R) stands for 120 ,
1E2 stands for 1R2 etc.

2.11 Transistors
A transistor is a semiconductor device, commonly used as an amplifier or an
electrically control switch. The transistor is the fundamental building block of the
circuitry in computers, cellular phones, and all other modern electronics 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. Transistors may be packaged individually or as part of
an integrated circuit, some with over a billion transistors in a very small area. They
are contain to electronics and there are two main types, NPN and PNP.

The letter refers to the layer of semiconductor material used to make the transistor,
must transistors used today are NPN because this is the easiest type to make from
silicon. This page is mostly about NPN transistors the lead are labeled based (B)
collector (C) and emitter (E) these terms refer to the internal operation of a
transistor but they are not much in understanding how a transistor is used.
Here we have BC547,which is used in the circuit, is a common purpose
transistor.BC547 is an NPN bi-polar junction transistor. A transistor, stands for
transfer of resistance, is commonly used to amplify current. A small current at its
base controls a larger current at collector & emitter terminals.

22

BC547 is mainly used for amplification and switching purposes. It has a maximum
current gain of 800. Its equivalent transistors are BC548 and BC549.

The transistor terminals require a fixed DC voltage to operate in the desired region
of

its characteristic curves. This is known as the biasing. For amplification

applications, the transistor is biased such that it is partly on for all input conditions.
The input signal at base is amplified and taken at the emitter. BC547 is used in
common emitter configuration for amplifiers. The voltage divider is the commonly
used biasing mode. For switching applications, transistor is biased so that it
remains fully on if there is a signal at its base. In the absence of base signal, it gets
completely

off.
C

G
G
E
E

PNP
TRANSISTOR

NPN
TRANSISTOR

So the NPN transistors are used most widely in all electronic circuits. The NPN
transistor has wide use for all commercial use. It consists of three terminals GATE (G),
EMITTER (E),COLLECTOR(C).The gate is called the input junction of the transistor
23

And the current flows through the from collector to emitter.

2.12 Relays
A relay is an electrically operated switch current flowing through the coil of the
relay creates a magnetic field, which attracts a lever and changes the switch
contacts. The coil current can be on or off so relay have two switch position and
they are double throw (change over) switches. Relays allow one circuit to switch a
second circuit, which can be completely separated from the first. There is no
electrical connection inside the relay between the two circuits; the link is magnetic
and mechanical.

Ciruit diagram and practical SPDT relay switch


24

The coils of a relay passes a relatively large current. Typically 30mn for a 12v
relay but it can be as much as 100mn lower voltages. Most ICs (chips) cannot
provide this current and a transistor is usually used to amplify the small IC current
to the larger value required for the relay coil. The maximum output current for the
popular 555 timer FC is 200mn so these devices can supply relay coil directly
without amplification.

2.13 Piezzo Electric Buzzer


Piezzo electric ceramic buzzer element have a simple structure in which piezo
ceramic element is glued to vibration plates. When alternating voltage is applied
to piezo ceramic element, the element expands or shrinks diametrically. This
characteristic is utilized to make vibration plate bend to generate sounds. The
acoustic generating method can be roughly divided into self-drive oscillation
method and external-drives oscillation method. The former shows the lowest
impedance on the acoustic generator, and produces the sound by the positive
feedback oscillation circuit to make ensconce there by big sound pressure can be
obtained by a simple circuit.

2.14 Hardware Component


This project is made up of five modules namely1. Sensor unit
2. Display unit
3. Control unit
4. Power supply unit
5. Pump/Motor control unit

2.15 Power Supply Unit


There are main types of power supply some are designed to convert high
voltage AC mains electricity to a suitable low DC voltage supply for electronic
circuits and other devices. A power supply can be broken down into a series of
blocks, each of them perform a particular function.
25

Typical 5V power supplly unit

2.16 Display unit


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 segment and other multi segment LEDs. The reasons being: LCDs are
economical; easily programmable; have no limitation of displaying special &
even special character (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 the data to be displayed on the LCD. The data is the ASCII value of
the character to be displayed on the LCD. Click to learn more about internal
structure of a LCD.

26

Pin Description:

Pin
No
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

Function

Name

Ground (0V)
Supply voltage; 5V (4.7V 5.3V)
Contrast adjustment; through a variable resistor
Selects command register when low; and data register
when high
Low to write to the register; High to read from the register
Sends data to data pins when a high to low pulse is given

Ground
Vcc
VEE
Register
Select
Read/write
Enable
DB0
DB1
DB2
DB3
DB4
DB5
DB6
DB7
Led+
Led-

8-bit data pins

Backlight VCC (5V)


Backlight Ground (0V)

Pin Diagram:

27

2.17 Motor Control Unit


Normally, the pump or motor (AC or DC) is connected to the relay, and
relay is connected to the transistor and a power supply. When the transistor is on
then the relay is in on state and drives the motor. The transistor is controlled by
the microcontroller.

28

Chapter 3: The Microcontroller 8051

Introduction to 8051 Microcontroller

AT89C51 is an 8-bit microcontroller and belongs to Atmel's 8051 family. ATMEL


89C51 has 4KB of Flash programmable and erasable read only memory (PEROM)
and 128 bytes of RAM. It can be erased and program to a maximum of 1000 times.

In 40 pin AT89C51, there are four ports designated as P1, P2, P3 and P0. All these
ports are 8-bit bi-directional ports, i.e., they can be used as both input and output
ports. Except P0 which needs external pull-ups, rest of the ports have internal pullups. When 1s are written to these port pins, they are pulled high by the internal
pull-ups and can be used as inputs. These ports are also bit addressable and so their
bits can also be accessed individually.

Port P0 and P2 are also used to provide low byte and high byte addresses,
respectively, when connected to an external memory. Port 3 has multiplexed pins
for special functions like serial communication, hardware interrupts, timer inputs
and read/write operation from external memory. AT89C51 has an inbuilt UART
for serial communication. It can be programmed to operate at different baud rates.
Including two timers & hardware interrupts, it has a total of six interrupts.

29

Pin Configuration

30

Pin Description:

Pin No
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

Function

Name
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
Reset

8 bit input/output port (P1) pins

Reset pin; Active high


Input (receiver) for serial
RxD
communication
Output (transmitter) for serial
TxD
communication
External interrupt 1
Int0
External interrupt 2
Int1
Timer1 external input
T0
Timer2 external input
T1
Write to external data memory
Write
Read from external data memory
Read

P3.0
P3.1
8 bit
input/output port
(P3) pins

Quartz crystal oscillator (up to 24 MHz)


Ground (0V)

8 bit input/output port (P2) pins


/
High-order address bits when interfacing with external memory

Program store enable; Read from external program memory


Address Latch Enable
Program pulse input during Flash programming
External Access Enable; Vcc for internal program executions
Programming enable voltage; 12V (during Flash programming)

8 bit input/output port (P0) pins


Low-order address bits when interfacing with external memory

Supply voltage; 5V (up to 6.6V)

31

P3.2
P3.3
P3.4
P3.5
P3.6
P3.7
Crystal 2
Crystal 1
Ground
P2.0/ A8
P2.1/ A9
P2.2/ A10
P2.3/ A11
P2.4/ A12
P2.5/ A13
P2.6/ A14
P2.7/ A15
PSEN
ALE
Prog
EA
Vpp
P0.7/ AD7
P0.6/ AD6
P0.5/ AD5
P0.4/ AD4
P0.3/ AD3
P0.2/ AD2
P0.1/ AD1
P0.0/ AD0
Vcc

32

32

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

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 highimpedance inputs.
Port 0 can also be configured to be the multiplexed loworder
address/data bus during accesses to external program and data memory. In this
mode, P0 has internal pullups.
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 pullups. 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 pullups 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 pullups.
In addition, P1.0 and P1.1 can be configured to be the timer/counter 2
external count input (P1.0/T2) and the timer/counter 2 trigger input
(P1.1/T2EX), respectively, as shown in the following table.
Port 1 also receives the low-order address bytes during Flash
programming and verification.

33

Port 2
Port 2 is an 8-bit bi-directional I/O port with internal pullups. The Port 2
output buffers can sink/source four TTL inputs. When 1s are written to Port 2
pins, they are pulled high by the internal pullups and can be used as inputs. As
inputs, Port 2 pins that are externally being pulled low will source current (IIL)
because of the internal pullups.
Port 2 emits the high-order address byte during fetches from external
program memory and during accesses to external data memory that use 16-bit
addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal
pull ups when emitting 1s. During accesses to external data memory that use 8bit 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 (IIL)
because of the pullups.
Port 3 also serves the functions of various special features of the
AT89C51, as shown in the following table.
Port 3 also receives some control signals for Flash programming and
verification.

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

34

ALE/PROG
Address Latch Enable is an output pulse for latching the low byte of the
address during accesses to external memory.
This pin is also the program pulse input (PROG) during Flash
programming. In normal operation, ALE is emitted at a constant rate of 1/6 the
oscillator frequency and may be used for external timing or clocking purposes.
Note, however, that one ALE pulse is skipped during each access to external
data memory.
If desired, ALE operation can be disabled by setting bit 0 of SFR
location 8EH. With the bit set, ALE is active only during a MOVX or MOVC
instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable
bit has no effect if the 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 program memory locations starting at
0000H up to FFFFH.
Note, however, that if lock bit 1 is programmed, EA will be internally
latched on reset. EA should be strapped to VCC for internal program
executions.
This pin also receives the 12-volt programming enable voltage (VPP)
during Flash programming when 12-volt programming is selected.

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

XTAL2
Output from the inverting oscillator amplifier.

Special Function Registers


A map of the on-chip memory area called the Special Function Register
(SFR) space is shown in Table 1. Note that not all of the addresses are
occupied, and unoccupied addresses may not be implemented on the chip. Read
accesses to these addresses will in general return random data, and write
accesses will have an indeterminate effect.
User software should not write 1s to these unlisted locations, since they
may be used in future products to invoke new features. In that case, the reset or
inactive values of the new bits will always be 0.
36

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

Interrupt Registers
The individual interrupt enable bits are in the IE register. Two priorities
can be set for each of the six interrupt sources in the IP register.

Data Memory
The AT89C52 implements 256 bytes of on-chip RAM. The upper 128
bytes occupy a parallel address space to the special Function Registers. That
means the upper 128 bytes have the same addresses as the SFR space but are
physically separate from SFR space.
37

When an instruction accesses an internal location above address 7FH,


the address mode used in the instruction specifies whether the CPU accesses
the upper 128 bytes of RAM or the SFR space. Instructions that use direct
addressing access SFR space.
For example, the following direct addressing instruction accesses the
SFR at location 0A0H (which is P2).
MOV 0A0H, #data
Instructions that use indirect addressing access the upper 128 bytes of
RAM. For example, the following indirect addressing instruction, where R0
contains 0A0H, accesses the data byte at address 0A0H, rather than P2 (whose
address is 0A0H).
MOV @R0, #data
Note that stack operations are examples of indirect addressing, so the
upper 128 bytes of data RAM are available as stack space.

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

Timer 2
Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an
event counter. The type of operation is selected by bit C/T2 in the SFR T2CON
(shown in Table 2).
Timer 2 has three operating modes: capture, auto-reload (up or down
counting), and baud rate generator. The modes are selected by bits in T2CON,
as shown in Table 3. Timer 2 consists of two 8-bit registers, TH2 and TL2. In

the Timer function, the TL2 register is incremented every machine cycle. Since
38

a machine cycle consists of 12 oscillator periods, the count rate is 1/12 of the
oscillator frequency.
In the Counter function, the register is incremented in response to a 1-to0 transition at its corresponding external input pin, T2. In this function, the
external input is sampled during S5P2 of every machine cycle. When the
samples show a high in one cycle and a low in the next cycle, the count is
incremented. The new count value appears in the register during S3P1 of the
cycle following the one in which the transition was detected. Since two
machine cycles (24 oscillator periods) are required to recognize a 1-to-0
transition, the maximum count rate is 1/24 of the oscillator frequency. To
ensure that a given level is sampled at least once before it changes, the level
should be held for at least one full machine cycle.

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

Auto-reload (Up or Down Counter)


Timer 2 can be programmed to count up or down when configured in its
16-bit auto-reload mode. This feature is invoked by the DCEN (Down Counter
Enable) bit located in the SFR T2MOD (see Table 4). Upon reset, the DCEN

39

bit is set to 0 so that timer 2 will default to count up. When DCEN is set, Timer
2 can count up or down, depending on the value of the T2EX pin.

Figure 2 shows Timer 2 automatically counting up when DCEN = 0. In


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

40

Setting the DCEN bit enables Timer 2 to count up or down, as shown in


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

Baud Rate Generator


Timer 2 is selected as the baud rate generator by setting TCLK and/or
RCLK in T2CON (Table 2). Note that the baud rates for transmit and receive
can be different if Timer 2 is used for the receiver or transmitter and Timer 1 is
used for the other function. Setting RCLK and/or TCLK puts Timer 2 into its
baud rate generator mode, as shown in Figure 4.

41

The baud rate generator mode is similar to the auto-reload mode, in that
a rollover in TH2 causes the Timer 2 registers to be reloaded with the 16-bit
value in registers RCAP2H and RCAP2L, which are preset by software. The
baud rates in Modes 1 and 3 are determined by Timer 2s overflow rate
according to the following equation.

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

where (RCAP2H, RCAP2L) is the content of RCAP2H and RCAP2L


taken as a 16-bit unsigned integer.

Timer 2 as a baud rate generator is shown in Figure 4. This figure is


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

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

42

Programmable Clock Out


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

In the clock-out mode, Timer 2 roll-overs will not generate an interrupt.


This behavior is similar to when Timer 2 is used as a baud-rate generator. It is
possible to use Timer 2 as a baud-rate generator and a clock generator
simultaneously. Note, however, that the baud-rate and clock-out frequencies
43

cannot be determined independently from one another since they both use
RCAP2H and RCAP2L.

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

Interrupts
The AT89C52 has a total of six interrupt vectors: two external interrupts
(INT0 and INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port
interrupt. These interrupts are all shown in Figure 6.
Each of these interrupt sources can be individually enabled or disabled
by setting or clearing a bit in Special Function Register IE. IE also contains a
global disable bit, EA, which disables all interrupts at once.
Note that Table shows that bit position IE.6 is unimplemented. In the
AT89C51, bit position IE.5 is also unimplemented. User software should not
write 1s to these bit positions, since they may be used in future AT89 products.
Timer 2 interrupt is generated by the logical OR of bits TF2 and EXF2 in
register T2CON. Neither of these flags is cleared by hardware when the service
routine is vectored to. In fact, the service routine may have to determine
whether it was TF2 or EXF2 that generated the interrupt, and that bit will have
to be cleared in software.
The Timer 0 and Timer 1 flags, TF0 and TF1, are set at S5P2 of the cycle in
which the timers overflow. The values are then polled by the circuitry in the
next cycle. However, the Timer 2 flag, TF2, is set at S2P2 and is polled in the
same cycle in which the timer overflows.

Oscillator Characteristics
XTAL1 and XTAL2 are the input and output, respectively, of an
inverting amplifier that can be configured for use as an on-chip oscillator, as
shown in Figure 7. Either a quartz crystal or ceramic resonator may be used. To
drive the device from an external clock source, XTAL2 should be left
unconnected while XTAL1 is driven, as shown in Figure 8. There are no
44

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 onchip peripherals
remain active. The mode is invoked by software. The content of the on-chip
RAM and all the special functions registers remain unchanged during this
mode. The idle mode can be terminated by any enabled interrupt or by a
hardware reset.
Note that when idle mode is terminated by a hardware reset, the device
normally resumes program execution from where it left off, up to two machine
cycles before the internal reset algorithm takes control. On-chip hardware
inhibits access to internal RAM in this event, but access to the port pins is not
inhibited. To eliminate the possibility of an unexpected write to a port pin when
idle mode is terminated by a reset, the instruction following the one that
invokes idle mode should not write to a port pin or to external memory.

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

45

Program Memory Lock Bits


The AT89C52 has three lock bits that can be left unprogrammed (U) or
can be programmed (P) to obtain the additional features listed in the following
table.
When lock bit 1 is programmed, the logic level at the EA pin is sampled
and latched during reset. If the device is powered up without a reset, the latch
initializes to a random value and holds that value until reset is activated. The
latched value of EA must agree with the current logic level at that pin in order
for the device to function properly.
Programming the Flash
The AT89C52 is normally shipped with the on-chip Flash memory array

in the erased state (that is, contents = FFH) and ready to be programmed. The
programming interface accepts either a high-voltage (12-volt) or a low-voltage
(VCC) program enable signal. The Low-voltage programming mode provides a
convenient way to program the AT89C52 inside the users system, while the
high-voltage programming mode is compatible with conventional thirdparty
Flash or EPROM programmers.
The AT89C52 is shipped with either the high-voltage or low-voltage
programming mode enabled. The respective top-side marking and device
signature codes are listed in the following table.

The AT89C52 code memory array is programmed byte-bybyte in either


programming mode. To program any nonblank byte in the on-chip Flash
Memory, the entire memory must be erased using the Chip Erase Mode.
46

Programming Algorithm
Before programming the T89C52, the address, data and control signals
should be set up according to the Flash programming mode table and Figure 9
and Figure 10. To program the AT89C52, take the following steps.
1. Input the desired memory location on the address lines.
2. Input the appropriate data byte on the data lines.
3. Activate the correct combination of control signals.
4. Raise EA/VPP to 12V for the high-voltage programming mode.
5. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits.
The byte-write cycle is self-timed and typically takes no more than 1.5 ms.
Repeat steps 1 through 5, changing the address
and data for the entire array or until the end of the object file is reached.

Data Polling
The AT89C52 features Data Polling to indicate the end of a write cycle.
During a write cycle, an attempted read of the last byte written will result in the
complement of the written data on PO.7. Once the write cycle has been
completed, true data is valid on all outputs, and the next cycle may begin. Data
Polling may begin any time after a write cycle has been initiated.

Ready/Busy
The progress of byte programming can also be monitored by the RDY/BSY
output signal. P3.4 is pulled low after ALE goes high during programming to
indicate BUSY. P3.4 is pulled high again when programming is done to
indicate READY.

Program Verify
If lock bits LB1 and LB2 have not been programmed, the programmed code
data can be read back via the address and data lines for verification. The lock
47

bits cannot be verified directly. Verification of the lock bits is achieved by


observing that their features are enabled.

Chip Erase
The entire Flash array is erased electrically by using the proper combination
of control signals and by holding ALE/PROG low for 10 ms. The code array is
written with all 1s. The chip erase operation must be executed before the code
memory can be reprogrammed.

Reading the Signature Bytes


The signature bytes are read by the same procedure as a normal verification of
locations 030H, 031H, and 032H, except that P3.6 and P3.7 must be pulled to a
logic low. The values returned are as follows.
(030H) = 1EH indicates manufactured by Atmel
(031H) = 52H indicates 89C52
(032H) = FFH indicates 12V programming
(032H) = 05H indicates 5V programming

Programming Interface
Every code byte in the Flash array can be written, and the entire array can
be erased, by using the appropriate combination of control signals. The write
operation cycle is selftimed and once initiated, will automatically time itself to
completion.
All major programming vendors offer worldwide support for the Atmel
microcontroller series. Please contact your local programming vendor for the
appropriate software.

48

What are crystal oscillators?


Crystal oscillators are oscillators where the primary frequency determining
element is a quartz crystal. Because of the inherent characteristics of the quartz
crystal the crystal oscillator may be held to extreme accuracy of frequency
stability. Temperature compensation may be applied to crystal oscillators to
improve thermal stability of the crystal oscillator.
Crystal oscillators are usually, fixed frequency oscillators where stability and
accuracy are the primary considerations. For example it is almost impossible to
design a stable and accurate LC oscillator for the upper HF and higher
frequencies without resorting to some sort of crystal control. Hence the reason
for crystal oscillators.
The frequency of older FT-243 crystals can be moved upward by crystal
grinding.
I won't be discussing frequency synthesizers and direct digital synthesis (DDS)
here. They are particularly interesting topics to be covered later.

A practical example of a Crystal Oscillator


This is a typical example of the type of crystal oscillators which may be used
for say converters. Some points of interest on crystal oscillators in relation to
figure 1.

Figure 1 - Schematic of a crystal oscillator


The transistor could be a general purpose type with a Ft of at least 150 MHz for
HF use. A typical example would be a 2N2222A.
The turns ratio on the tuned circuit depicts an anticipated nominal load of 50
ohms. This allows a theoretical 25K ohms on the collector. If it is followed by
a buffer amplifier (highly recommended) I would simply maintain the typical
7:1 turns ratio. I have included a formula for determining L and C in the tuned
circuits of crystal oscillators in case you have forgotten earlier tutorials.
49

Chapter 4: Circuit Analysis


4.1 Project Circuit Diagram

CIRCUIT DIAGRAM OF WATER LEVEL CONTROLLER USING


MICROCONTROLLER AND BUZZER

50

Circuit Elements
There are main components of the circuit shown below1.
2.
3.
4.
5.
6.
7.

Transistor
Resistor
Diodes
Motor
AT89c51 microcontroller
Relay
LCD etc.
All the components has been discussed above already.

51

PROCEDURE FOR MAKING PROJECT


Building project in the proper manner is really an art, something which
must be prectised and learned through trial and error, it is not all that difficult.
The main thing is to remember to take each step slowly and carefully according
to the instructions giving making since that everything at it should be before
proceeding further.

TOOLS: The electronics workbench is an


actual place of work with comfortably &
conveniently & should be supplied with
compliment of those tools must often use in
project building. Probably the most important
device is a soldering tool. Other tool which
should be at the electronic work bench
includes a pair of needle nose pliers, diagonal
wire cutter, a small knife, an assortment of
screw driver, nut driver, few nuts & bolts,
electrical tape, plucker etc. Diagonal wire
cutter will be used to cut away any excess lead length from copper side of
P.C.B. 7 to cut section of the board after the circuit is complete. The needle
nose pliers are most often using to bend wire leads & wrap them in order to
form a strong mechanical connection.
MOUNTING & SOLDERING: Soldering
is process of joining together two metallic
parts. It is actually a process of function in
which an alloy, the solder, with a
comparatively
low
melting
point
penetrates the surface of the metal being
joined & makes a firm joint between them
on cooling & solidifying.
THE SOLDERING KIT
1.SOLDERING IRON:
As soldering is a process of joining together two
metallic
parts, the instrument, which is used, for doing this job is known as soldering
Iron. Thus it is meant for melting the solder and to setup the metal parts being
52

joined. Soldering Iron is rated according to their wattage, which varies from 10200 watts.

2.

SOLDER:
The raw material used for soldering is solder. It is composition of lead &
tin. The good quality solder (a type of flexible naked wire) is 60% Tin +40%
Lead which will melt between 180 degree to 200 degree C temperature.
3.

FLUXES OR SOLDERING PASTE:


When the points to solder are heated, an oxide film forms. This must be
removed at once so that solder may get to the surface of the metal parts. This is
done by applying chemical substance called Flux, which boils under the heat of
the iron remove the oxide formation and enable the metal to receive the solder.
4.

BLADES OR KNIFE:
To clean the surface & leads of components to be soldered is done by
this common instrument.
5.

SAND PAPER:
The oxide formation may attack at the tip of your soldering iron & create
the problem. To prevent this, clean the tip with the help of sand paper time to
time or you may use blade for doing this job. Apart from all these tools, the
working bench for soldering also includes desoldering pump, wink wire (used
for desoldering purpose), file etc.
HOW TO SOLDER?
Mount components at their appropriate place; bend the leads slightly
outwards to prevent them from falling out when the board is turned over for
soldering. No cut the leads so that you may solder them easily. Apply a small
amount of flux at these components leads with the help of a screwdriver. Now
fix the bit or iron with a small amount of solder and flow freely at the point and
the P.C.B copper track at the same time. A good solder joint will appear
smooth & shiny. If all appear well, you may continue to the next solder
connections.

TIPS FOR GOOD SOLDERING


1. Use right type of soldering iron. A small efficient soldering iron (about 1025 watts with 1/8 or 1/4 inch tip) is ideal for this work.
53

2. Keep the hot tip of the soldering iron on a piece of metal so that excess heat
is dissipated.
3. Make sure that connection to the soldered is clean. Wax frayed insulation
and other substances cause poor soldering connection. Clean the leads,
wires, tags etc. before soldering.
4. Use just enough solder to cover the lead to be soldered. Excess solder can
cause a short circuit.
5. Use sufficient heat. This is the essence of good soldering. Apply enough
heat to the component lead. You are not using enough heat, if the solder
barely melts and forms a round ball of rough flaky solder. A good solder
joint will look smooth, shining and spread type. The difference between
good & bad soldering is just a few seconds extra with a hot iron applied
firmly.
PRECAUTIONS
1. Mount the components at the appropriate places before soldering. Follow
the circuit description and components details, leads identification etc. Do not
start soldering before making it confirm that all the components are mounted at
the right place.
2.

Do not use a spread solder on the board, it may cause short circuit.

3.

Do not sit under the fan while soldering.

4.

Position the board so that gravity tends to keep the solder where you want
it.

5.

Do not over heat the components at the board. Excess heat may damage
the components or board.

6.

The board should not vibrate while soldering otherwise you have a dry or
a cold joint.

7.

Do not put the kit under or over voltage source. Be sure about the voltage
either dc or ac while operating the gadget.

54

Chapter 5: Software Design


Software is computer program, instructions that cause the software, the machine to
do work. Software as whole can be divided into a number of categories base on the
type of work done. The two primary software are operating software (system
software), which controls the working of the computer, application software, which
addresses the multitude of task for which people use computer. Application
software, perform word processing, data base management, and the like. Two
additional categories that are either system.
Application software, and language software, which provide programmers with
tools they need to write programs. In addition to these task-based categories,
several types of software are described based on their application.
Software development involves series of steps or is a set of activities that are
necessary to be taken for the development of reliable and maintenance software, It
is of great importance because hardware design cannot be used with microcontroller base system without depending on software. A typical micro-controller
development systems (MDS) include, VDU registers, RAM which serve as a stone
for the PROM programmer. Software system is the term use to describe a program
that is provide by the manufacturer to aid the development of users (applications)
programs. These include programs that convert assembly language into machine
code (assembler), or high level language into machine code (interpreter or
compiler). It also include programs that facilitate modifications (edition), the
computer aided development methodology, which is essential for software
development is summarized below.

TEXT EDITOR
This is kind of word processing that is used. After keying in the used in programs
code using the input device and the programs is display on the VDU, the text
edition can be used to check and correct errors in the programs. In a nutshell, the
text edition is used to edit the programs after it has been written.

TRANSLATOR
There are two types of translators, assembler, interpreter and compiler. An
assembler translate assembly language in the form of ammonic (memory aids) into
machine code. A good feature of assembler is creating a list that shows the
machine code and the assembly language of the programs side by side. A compiler
on the other hand translates a

55

high-level language into machine code. An interpreter reads the source code of our
programs one line at a time and performs the specification instructions contained in
that line
LINKER/LOCATOR
This is used to join the different modules that make up the programs together in the
correct sequence and this is to be bound to addresses. The linker/locator pair works
together to co-ordinate between the separate modules for smooth programs
execution.
LOADER
The loader aids in loading an object code into RAM.

TESTING
After the programs is written ,it was tested, this involve executing the programs
with selected input called test cases, the result whether or not the program is
functioning as desired.

DEBUGGING
This involves detecting out and removing errors in the program.

DEVELOPMENT PROCESS
In writing the software for this project, a modular approach was employed. This
made it easier to check for errors and debug the program. Three major tools were
used in the development process; the C51 compiler was used to translate from the
source code into the object code. The SDCPP was employed to link the program
while the PACKIHX did the conversion from binary to hexadecimal.

CHOICE OF PROGRAMMING LANGUAGE


My implementation programming for this project is C programming language
reasons being the fact that C combines the element of high-level language with
functionalism of assembly language. C allows the manipulation of bits, bytes and
addresses. Also C codes are portable which means that it is possible to adapt
software written for one type of computer to another. Nevertheless, a special
feature of C is that it allows the direct manipulation of bite, byte, word and
pointers. This suite it to system level programming where these operation are
common. C has only 32 key word as compare with Q-basic for IBM pc which
contain 159 key words.

56

PROGRAM ENTRY AND EDITING


After the design of the software, a text editor is employed to enter the source into
the disk file. As noted earlier, the text editor also functions as error correcting in
the program. The text editor use is the CRIMSON text editor.

COMPILING AND LINKING

The small device C compiler comes with a lot of modules. It dose the task of
compilation, linking binary to hexadecimal conversion once the compilation
command is issued an object file, a hexadecimal and a binary file.

The program is to burn in the microcontroller. And the microprocessor will work
according to the instruction. The microcontroller is programmed using programmer
kit.

57

Chapter 6: Testing and Implementation


6.1 Assembling and Implementation
After the design and implementation phase, the system built has to be tested for
durability and effectiveness and also ascertain if there is need to modify the design
.the system was first assembled using breadboard .all the component were properly
soldered to the Vero board from whence some test were carried out at various stage
.to ensure proper functioning of component expected data, the component were
tested using a digital multimeter (DMM). Resistors were tested to ensure that there
within the tolerance value. Faulty resistor were discarded. The AT89c51 voltage
regulator, the resulting output was 5.02v which is just a deviation of 0.20v from the
expected result of 5.00v, the pump was also tested to ensure that it was working
properly. This chapter entail the overall system testing of integrated design of
voltage measurement device .the testing and integration is done to ensure that the
design is functioning properly as expected there by enabling one or even intended
users for which the project was targeted for, appreciate its implementation and
equally approaches used in the design and integration of various modules of the
project .however, this involves checks made to ensure that all the various unite and
subsystem function adequately also there has to be good interface existing between
the output /input unite subsystem. When the totality of the modules was integrated
together, the system was created and all modules and sections responded to as
specified in the design through the power supply delivering into the system
designed.

6.2 Testing
Component Test
Similar component like resistor were packed together. The other component
include capacitor, switch, transformer, resistor, Diodes (rectifier) LED, transistor
,voltage regulators etc Reference was made to colour coding data sheet to ascertain
the expected value of resistors used. Each resistor was tested and the value read
and recorded. Also for transistor test the DIMM was switched to the diode range.
The collector, base, emitter junctions were tested in the following order. The
collector, emitter and base pins were gotten from the data analysis on power
transistor.

58

MAKING PRINTED CIRCUIT BOARD (P.C.B.)

INTRODUCTION
Making a Printed Circuit Board is the first step towards
building electronic equipment by any electronic industry. A number
of methods are available for making P.C.B., the simplest method is of
drawing pattern on a copper clad board with acid resistant (etchants)
ink or paint or simple nail polish on a copper clad board and do the
etching process for dissolving the rest of copper pattern in acid
liquid.

MATERIAL REQUIRED
The apparatus needs for making a P.C.B. is :Copper Clad Sheet
Nail Polish or Paint
Ferric Chloride Powder. (Fecl)
Plastic Tray
Tap Water etc.

PROCEDURE
The first and foremost in the process is to clean all dirt from copper sheet
with say spirit or trichloro ethylene to remove traces grease or oil etc. and then

59

wash the board under running tap water. Dry the surface with forced warm air
or just leave the board to dry naturally for some time.
Making of the P.C.B. drawing involves some preliminary consideration such as
thickness of lines/ holes according to the components. Now draw the sketch of
P.C.B. design (tracks, rows, square) as per circuit diagram with the help of nail
polish or enamel paint or any other acid resistant liquid. Dry the point surface
in open air, when it is completely dried, the marked holes in P.C.B. may be
drilled using 1Mm drill bits. In case there is any shorting of lines due to spilling
of paint, these may be removed by scraping with a blade or a knife, after the
paint has dried.
After drying, 22-30 grams of ferric chloride in 75 ml of water may be heated to
about 60 degree and poured over the P.C.B. , placed with its copper side
upwards in a plastic tray of about 15*20 cm. Stirring the solution helps speedy
etching. The dissolution of unwanted copper would take about 45 minutes. If
etching takes longer, the solution may be heated again and the process repeated.
The paint on the pattern can be removed P.C.B. may then be washed and dried.
Put a coat of varnish to retain the shine. Your P.C.B. is ready.

REACTION
Fecl3 + Cu

CuCl3 + Fe

Fecl3 + 3H2O

Fe (OH)3 + 3HCL

PRECAUTION

1.

Add Ferric Chloride (Fecl3) carefully, without any splashing. Fecl3 is


irritating to the skin and will stain the clothes.

60

2.

Place the board in solution with copper side up.

3.

Try not to breathe the vapours. Stir the solution by giving see-saw
motion to the dish and solution in it.

4.

Occasionally warm if the solution over a heater-not to boiling. After


some time the unshaded parts change their colour continue to etch.
Gradually the base material will become visible. Etch for two minutes
more to get a neat pattern.

5.

Don't throw away the remaining Fecl3 solution. It can be used again for
next Printed Circuit Board P.C.B.

USES
Printed Circuit Board are used for housing components to make a circuit
for compactness, simplicity of servicing and case of interconnection. Thus we
can define the P.C.B. as : Prinked Circuit Boards is actually a sheet of bakelite
(an insulating material) on the one side of which copper patterns are made with
holes and from another side, leads of electronic components are inserted in the
proper holes and soldered to the copper points on the back. Thus leads of
electronic components terminals are joined to make electronic circuit.
In the boards copper cladding is done by pasting thin copper foil on the boards
during curing. The copper on the board is about 2 mm thick and weights an
ounce per square foot.
The process of making a Printed Circuit for any application has the following
steps (opted professionally):
*

Preparing the layout of the track.


61

Transferring this layout photographically M the copper.

Removing the copper in places which are not needed, by the process of
etching (chemical process)

Drilling holes for components mounting.

PRINTED CIRCUIT BOARD


Printed circuit boards are used for housing components to make a circuit,
for comactness, simplicity of servicing and ease of interconnection. Single
sided, double sided and double sided with plated-through-hold (PYH) types of
p.c boards are common today.
Boards are of two types of material (1) phenolic paper based material
(2) Glass epoxy material. Both materials are available as laminate sheets with
copper cladding.
Printed circuit boards have a copper cladding on one or both sides. In
both boards, pasting thin copper foil on the board during curing does this.
Boards are prepared in sizes of 1 to 5 metre wide and upto 2 metres long. The
thickness of the boards is 1.42 to 1.8mm. The copper on the boards is about 0.2
thick and weighs and ounce per square foot.

62

Transformer Test
Expectedly the transformer was rated 220v/12v, 1000mA. from the mains power
supply, the primary coil receives 220v input, the output was measure to be 16.75v
using a DMM. Test data on transformer has it that the resistance of the primary
windings for step down transformer is higher than that of the secondary side this
was ascertained.

Other Test

The bucket used as tank in my project was tested in other to make sure there was
no leakage, the hose or pipe conveying the water from the lower tank to the upper
tank was tested or checked for any kind of breakage or leakage.

PACKAGING
After the completion of the work, the circuitry was enclosed in a case to avoid
damage. This is very vitally to the packaging of any electronic equipment, the
enclosure provides protection as well as attraction that is, it add aesthetic value to
the work. The sizes of tank to be used for packaging was first of all determined
after considering the following factors
1. Easy input and removal of water from the tanks
2. Positions of the tanks
3. Space for future modifications, easy accessibility to circuit board
4. Easy mobility of the tanks.
63

PROBLEMS ENCOUNTERED
During the course of designing this system there were series of problems
encountered which came on the way of achieving the desired goals of this project.
Some parts require re-designing and the software debugging also created a bit of
the problem. After installing the pump, I noticed that the bucket was punched there
by making water to leak, this was so challenging because it leads to me changing
the tank which affected the budget.

Conclusion

Going through the planning, flow process, design and software implementation, the
system has been a tough one, the chapter one to four has actually tried as much as
possible to explain vividly almost all (if not all) what is involved in the
construction of this project. After the complete design of the system, the deviation
between the expected result and the actual result was very close. The performance
and efficiency was beyond expectation and from every ramification the design of
automatic water controller was successful.

References
1. Engineers Garage.com
2. www.wiki.com
3. Ramesh S. Gaonkar Microprocessor 8085 Programming.
4. Test

book

by

Subrata

Ghoshal

8051

Internals,Instructions,Programming & Interfacing.


5. www.google.com
6. www.electronics hub.com
7. Sedra smith Microelectronic circuits test book

8. Robert L. Boyalstad Fundamentals of Electronic Devices

64

Microcontroller-

You might also like