Sudan University of
Science &Technology
College of Graduate Studies
‫التحكم فى مضخة ماء بواسطة المتحكم الدقيق وحساسات مستوى الماء‬
Water Pump Control Based on Microcontroller
and Water Level Sensors
A Thesis Submitted as a Partial Fulfillment of the requirements
for the degree of master in Mechatronic Engineering
By
HOZUIFA ABD ELKARIEM YAGOB BAKHEET
Supervisor
Dr. ZAKARIA ANWAR ZAKARIA
June 2016
1
2
3
4
‫بسم اهلل الرحمن الرحيم‬
Sudan University of Science & Technology
College of Graduate Studies
Water Pump Control Based on Microcontroller
and Water Level Sensors
A Thesis Submitted as a Partial Fulfillment of the requirements
for the degree of master in Mechatronic Engineering
By:
HOZUIFA ABD ELKARIEM YAGOB BAKHEET
Supervisor
Dr. ZAKARIA ANWAR ZAKARIA
June 2016
i
‫بسم اهلل الرحمن الرحيم‬
‫اآلية‬
‫قال تعالى ‪:‬‬
‫ُ‬
‫ون ُكلٌّ آ َم َن بِ ّ‬
‫نز َل إِلَ ْي ِه ِمن َّربِّ ِه َو ْال ُم ْؤ ِمنُ َ‬
‫اللِ‬
‫(آ َم َن ال َّرسُو ُل بِ َما أ ِ‬
‫ق بَي َْن أَ َح ٍد ِّمن رُّ ُسلِ ِه َوقَالُ ْ‬
‫َو َمآلئِ َكتِ ِه َو ُكتُبِ ِه َو ُر ُسلِ ِه الَ نُفَ ِّر ُ‬
‫وا َس ِم ْعنَا َوأَطَ ْعنَا‬
‫ف ّ‬
‫صي ُر{‪ }282‬الَ يُ َكلِّ ُ‬
‫ّللاُ نَ ْفسا ً إِالَّ ُو ْس َعهَا لَهَا َما‬
‫ك َربَّنَا َوإِلَ ْي َ‬
‫ُغ ْف َرانَ َ‬
‫ك ْال َم ِ‬
‫ت َو َعلَ ْيهَا َما ا ْكتَ َسبَ ْ‬
‫َك َسبَ ْ‬
‫ت َربَّنَا الَ تُ َؤا ِخ ْذنَا إِن نَّ ِسينَا أَ ْو أَ ْخطَأْنَا َربَّنَا َوالَ‬
‫ين ِمن قَ ْبلِنَا َربَّنَا َوالَ تُ َح ِّم ْلنَا َما الَ طَاقَةَ‬
‫تَحْ ِملْ َعلَ ْينَا إِصْ راً َك َما َح َم ْلتَهُ َعلَى الَّ ِذ َ‬
‫لَنَا بِ ِه َوا ْع ُ‬
‫ف َعنَّا َوا ْغفِرْ لَنَا َوارْ َح ْمنَا أَ َ‬
‫نت َم ْوالَنَا فَانصُرْ نَا َعلَى ْالقَ ْو ِم‬
‫ين{‪)}282‬‬
‫ْال َكافِ ِر َ‬
‫صدق ّللا العظيم البقرة (‪)282, 282‬‬
‫‪ii‬‬
Dedication
I dedicate my dissertation work to my family, my friends, and to
all who have supported me throughout the implementation of this
research.
iii
Acknowledgement
Praise be to God who helped me to complete this study, then I
would like to extend my gratitude to my supervisor Dr. Zakaria Anwar
Zakaria, for his constant guidance and the encouragement throughout the
endeavor, his support, motivation and innovative ideas that helped me
tremendously whenever I met a roadblock.
iv
Abstract
Pump control system is designed to monitor the level of water in
the overhead and underground tank through water level sensors, and run
the pump only when the water level in the underground tank is up to the
position of the water level sensor as long as the overhead tank is empty
and automatically turn off the pump after the fullness of the overhead
tank where its has two water level sensors. The circuit is made up of
(microcontroller Atmega16), three sensors for water level (Float Switch),
display (LCD 16), Driver (ULN2003A), alarm (buzzer), three light
emitting diodes (LED) and Relay (5 V).Where the microcontroller keeps
track of the exact level of water in the tanks and display it in the LCD
display as well as running pump or shutdown it through the driver and
relay, And according to the water level it is turned the suitable LED, and
when the water level in the underground tank is less than the sensor level
the buzzer is turned on.
v
‫المستخلص‬
‫تم تصميم نظام التحكم فى المضخة ليقوم بعملية مراقبة مستوى الماء فى الخزانين‬
‫العلوى واالرضى عن طريق حساسات مستوى الماء وتشغيل المضخة فقط عندما يكون مستوى‬
‫الماء فى الخزان االرضى يصل لموضع حساس الماء طالما الخزان العلوى فارغاً وايقاف‬
‫المضخة تلقائياً بعد امتالء الخزان العلوى حيث يوجد به حساسان لمستوى الماء‪,‬وتتكون الدائرة‬
‫من متحكم‬
‫)‪Switch‬‬
‫دقيق) ‪ ,) Microcontroller Atmega16‬ثالث حساسات‬
‫‪(Float‬‬
‫شاشة‬
‫عرض)‪(LCD16‬‬
‫لمستوى الماء‬
‫‪,‬القائد)‪,(ULN2003A‬‬
‫صفارة‬
‫إنذار)‪ ,(Buzzer‬ثالث صمامات ثنائية باعثة للضوء)‪ (LED‬والمرحل )‪.(5V‬حيث يقوم‬
‫المتحكم الدقيق بتتبع مستوى الماء فى الخزانين وعرضه فى الشاشة وكذلك عملية تشغيل‬
‫المضخة وايقافها عن طريق القائد والمرحل‪.‬ووفقاً لمستوى الماء يتم تشغيل الصمام الثنائى‬
‫الباعث للضوء ذو اللون المناسب وعندما يكون مستوى الماء فى الخزان االرضى أقل من‬
‫موضع الحساس يتم تشغيل صفارة االنذار‪.‬‬
‫‪vi‬‬
Table of Contents
‫ اآلية‬............................................................................................................. ii
Dedication ................................................................................................ iii
Acknowledgement ................................................................................... iv
Abstract ..................................................................................................... v
‫ المستخلص‬.................................................................................................... vi
Table of Contents .................................................................................... vii
List of Tables ............................................................................................ x
List of Figures .......................................................................................... xi
List of Abbreviations .............................................................................. xii
List of Symbols ...................................................................................... xiv
List of Appendices .................................................................................. xv
(CHAPTER ONE) ......................................... 1
Introduction.................................................... 1
1.1 Background ......................................................................................... 1
1.2 Importance .......................................................................................... 3
1.3 Methodology ....................................................................................... 4
1.4 Objectives............................................................................................ 4
1.5 Overview of The Thesis ...................................................................... 4
(CHAPTER TWO) .................................... 6
Literature Review .......................................... 6
2.1 Pump Control System ......................................................................... 6
2.2 Control Architectures .......................................................................... 9
2.2.1 Analog Circuits ........................................................................... 10
2.2.2 Digital Circuits............................................................................ 10
2.2.3 Programmable Logic Controller ................................................. 11
2.2.4 Single-Board Computer .............................................................. 13
2.2.5 Personal Computer (PC) ............................................................. 13
vii
2.2.6 Digital Signal Processing (DSP) ................................................ 14
2.2.7 Microcontrollers ......................................................................... 14
2.3 Pumps ................................................................................................ 29
2.3.1Positive Displacement Pumps ..................................................... 30
2.3.2 Centrifugal Pumps ...................................................................... 30
2.4 Level Sensor ...................................................................................... 31
2.4.1 Continuous level Measurement .................................................. 31
2.4.2 Detection of Threshold Values (limits) ...................................... 35
2.5 ULN2003A driver ............................................................................. 36
2.6 The Relay .......................................................................................... 37
(CHAPTER THREE) ............................. 39
Case Study .................................................... 39
3.1 Introduction: ...................................................................................... 39
3.2 Components Used ............................................................................. 39
3.2.1 Solder Board ............................................................................... 40
3.2.2 Float Switch ................................................................................ 40
3.2.3 Atmega16 Microcontroller ......................................................... 40
3.2.4 ULN 2003 Driver........................................................................ 40
3.2.5 5v Relay ...................................................................................... 40
3.2.6 Buzzer ......................................................................................... 40
3.2.7 LCD16 Display ........................................................................... 40
3.2.8 Various Resistors (3K ,330) Ω ................................................... 42
3.2.9 Various LED (red , yellow , green) ............................................ 42
3.2.10 Variable Resistance 1K ............................................................ 42
3.2.11 Wires ......................................................................................... 42
3.3 Welding Process................................................................................ 43
3.3.1 Microcontroller Welding ............................................................ 43
3.3.2 LCD Display Welding ................................................................ 43
3.3.3 ULN 2003 Welding .................................................................... 43
viii
3.3.4 Relay Welding ............................................................................ 44
3.3.5 Pump Welding ............................................................................ 44
3.3.6 Variable Resistance .................................................................... 44
3.3.7 Buzzer Welding .......................................................................... 44
3.4 Welding Test .................................................................................... 44
3.5 Programming Process ....................................................................... 46
3.6 Software Design ................................................................................ 47
3.6.1 Text Editor .................................................................................. 48
3.6.2 Translator .................................................................................... 48
3.6.3 Linker/Locator ............................................................................ 48
3.6.4 Loader ......................................................................................... 48
3.6.5 Testing ........................................................................................ 49
3.6.6 Debugging................................................................................... 49
3.7 Development Process ........................................................................ 49
3.8 Choice of Programming Language ................................................... 49
3.9 Pump Control System Program Steps ............................................... 49
(CHAPTER FOUR) ................................ 52
The Results ................................................... 52
4.1 Results ............................................................................................... 52
(CHAPTER FIVE) ................................. 58
Conclusion and Recommendation.............. 58
5.1 Conclusion ........................................................................................ 58
5.2 Recommendations ............................................................................. 59
REFERANCES ....................................................................................... 60
ix
List of Tables
TABLE NO
Table (4.1)
TITLE
PAGE NO
The experimental results of the system
x
52
List of Figures
FIGURE NO
TITLE
PAGE NO
Figure(2.1)
The block diagram of pump control system
8
Figure(2.2)
ATmega16 microcontroller architecture
17
Figure(2.3)
The various types of microcontrollers
20
Figure(2.4)
The pin configuration of ATmega16
27
Figure(2.5)
The submersible pump
31
Figure(2.6)
The capacitive sensor with planar electrodes
32
Figure(2.7)
The capacitive sensor with electrodes
33
Figure(2.8)
The ultrasonic sensors level
34
Figure(2.9)
The float switch
36
Figure(2.10)
ULN2003A driver
37
Figure(2.11)
5V relay
38
Figure(3.1)
The LCD16 display pins
41
Figure(3.2)
Pump control system circuit
45
Figure(3.3)
The flow chart of the Pump Control System
50
Figure(4.1)
The status of the LCD display and the red LED
53
Figure(4.2)
The status of the LCD display and the LED
54
Figure(4.3)
The status of the LCD display and the yellow LED 55
Figure(4.4)
The status of the LCD display and the LED
Figure(4.5)
The status of the LCD display and the green LED 57
xi
56
List of Abbreviations
LED
Light Emit Diode
IC
Integrated Circuit
PAL
Programmable Array Logic
PLA
Programmable Logic Array
FPGA
Field Programmable Gate Array
I/O
Input /Output
VHSIC Very High Speed Integrated Circuit
VHDL
VHSIC Hardware Description Language
ASIC
Application Specific Integrated Circuit
PLC
Programmable Logic controller
NEMA National Electrical Manufacturers Association
RAM
Random Access Memory
ROM
Read Only Memory
C
High Level Language
PC
Personal Computer
R&D
Research and Development
DSP
Digital Signal Processing
VDU
Visual Display Unit
CPU
Central Process Unit
EEPROM Electrically Erasable Programmable Read Only Memory
EPROM
Erasable Programmable Read Only Memory
PROM Programmable Read Only Memory
UV
Ultra Volatile
ADC
Analog-to-Digital Converter
ALU
Arithmetic Logic Unit
CISC
Complex Instruction Set Computer
RISC
Reduced Instruction Set Computer
xii
SISC
Specific Instruction Set Computer
IDE
Integrated Development Environment
CAN
Controller Area Network
USB
Universal Serial Bus
RF
Radio Frequency
SRAM Static Read Access Memory
USART Universal Synchronous Asynchronous Receiver Transmitter
SPI
Serial Peripheral Interface
JTAG
Joint Test Action Group
VCR
Video Cassette Recorder
H2S
Ahydrogen Sulfide
FMCW Frequency Modulated Continuous Wave
COM
Common
NC
Normally Closed
NO
Normally Open
DC
Direct Current
AC
Alternating Current
SPST
Single pole, single throw
SPDT
Single pole, double throw
DPDT
Double Pole, Double Throw
LCD
Liquid Crystal Display
MDS
Micro-controller Development Systems
BASIC
Beginners All-purpose Symbolic Instruction Code
xiii
List of Symbols
h
Fluid level
hmax
Sensor level
D
Tank diameter
d
Sensor diameter
C1
Air capacitive
C2
Fluid capacitive
tf
Time of travel
sensor L
Sensor at the low level of the overhead tank
sensor H
Sensor at the high level of the overhead tank
sensor U
Sensor at the low level of the underground tank
xiv
List of Appendices
Appendix NO
1
TITLE
The pump control system programme steps
xv
CHAPTER ONE
Introduction
1.1 Background
Throughout history mankind has tried to control the world in
which he lives. From the earliest days he realized that his puny strength
was no match for the creatures around him. He could only survive by
using his wits and cunning. His major asset over all other life from flint,
stone and bone and discovered that it was possible to train other animals
to do his bidding and so the earliest form of control system was
conceived. Before long the horse and ox were deployed to undertake a
variety of tasks, including transport. It took a long time before man
learned to replace animals with machines [1].
Automatic control is one of today’s most significant areas of
science and technology. This can be attributed to the fact that automation
is linked to the development of almost every form of technology. By its
very nature, automatic control is a multidisciplinary subject; it
constitutes a core course in many engineering departments, such as
electrical, electronic, mechanical, chemical, and aeronautical. Automatic
control requires both a rather strong mathematical foundation, and
implementation skills to work with controllers in practice.
Automatic control has developed rapidly over the last 60 years.
An impressive boost to this development was provided by the
technologies that grew out of space exploration and the second World
War. In the last 20 years, automatic control has undergone a significant
and rapid development due mainly to digital computers. Indeed, recent
1
developments in digital computers especially their increasingly low cost
facilitate their use in controlling complex systems and processes.
Automatic control is a vast technological area whose central aim is
to develop control strategies that improve performance when they are
applied to a system or a process. The results reported thus far on control
design techniques are significant from both a theoretical and a practical
perspective. From the theoretical perspective, these results are presented
in great depth, covering a wide variety of modern control problems, such
as optimal and stochastic control, adaptive and robust control, and
system identification. From the practical point of view, these results have
been successfully implemented in numerous practical systems. And
processes—for example, in controlling temperature, pressure, and fluid
level; in electrical energy plants; in industrial plants producing paper,
cement, steel, sugar, plastics, clothes, and food; in nuclear and chemical
reactors; in ground, sea, and air, transportation systems; and in robotics,
space applications, farming, biotechnology, and medicine.
A close examination of the various machines and apparatus that
are manufactured today leads to the conclusion that they are partially or
entirely automated; this lead to the conclusion that automatic control is
used in all facets of human technical activities and contributes to the
advancement of modern technology.
The distinct characteristic of automatic control is that it reduces,
as much as possible, the human participation in all the aforementioned
technical activities. This usually results in decreasing labor cost, which
in turn allows the production of more goods and the construction of more
works. Furthermore, automatic control reduces work hazards, while it
contributes in reducing working hours, thus offering to working people a
better quality of life (more free time to rest, develop hobbies, have
fun,etc.).
2
Control systems have been in existence since ancient times. A
well-known ancient automatic control system is the regulator of Heron
of Alexandria this control system was designed to open the doors of a
temple automatically when a fire was lit at the altar located outside the
temple and to close the doors when the fire was put out.
Until about the middle of the 18th century, automatic control has
no particular progress to show. The use of control started to advance in
the second half of the 18th century, due to James Watt, who, in 1769,
invented the first centrifugal speed regulator. In particular, this regulator
was used to control the speed of the steam engine.
The period until about the middle of the 19 th century is
characterized by developments based on intuition, i.e., there was no
mathematical background for control design [2].
1.2 Importance
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. Last few decades several monitoring system integrated with
water level detection have become accepted. Measuring water level is an
essential task for government and residence perspective. In this way, it
would be possible to track the actual implementation of such initiatives
with integration of various controlling activities. Therefore, water
controlling system implementation makes potential significance in many
applications. The existing automated method of level detection is
described and that can be used to make a device on/off. Moreover, the
3
common method of level control for underground tank 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 is not properly
supported for adequate controlling system. Besides this, liquid level
control systems are widely used for monitoring of liquid levels,
reservoirs, silos, and dams etc. Usually, this kind of systems provides
visual multi level as well as continuous level indication. Audio visual
alarms at desired levels and automatic control of pumps based on user’s
requirements can be included in this management system. Proper
monitoring is needed to ensure water sustainability is actually being
reached, with disbursement linked to sensing and automation [3].
1.3 Methodology
The programmatic approach entails microcontroller based
automated water level sensing and controlling have been used .
1.4 Objectives
Main objective is to design device that for control the submersible
pump by monitoring the water level in the tanks through water level
sensors, which are placed in three places in the tanks using a
microcontroller, and the objectives are:
1. To Design an automatic pump control and water monitoring system.
2. To Reduce the user effort and increasing safety.
3. To Prevent over labor of the pumping machine (dry running).
1.5 Overview of The Thesis
This chapter has presented an introduction of automatic control
and background, importance, methodology, objectives and overview of
the thesis, chapter two presents a literature review of the problem,
4
chapter three presents a case study, chapter four presents a result and
discussion, chapter five presents a conclusion and recommendations.
2
CHAPTER TWO
Literature Review
2.1 Pump Control System
The development of automation and control processes in industrial
applications has increased significantly over the past decades.
Involvement of human activities in industrial processes has caused so
many problems, like safety, health and industrial damages both to
humans and the developmental activities within the level of industrial
production and service delivery. The effect of automation and control
systems in recent production and service delivery development has
improved the safety and reliability in technology and most human
services in the developing countries.
Some of the industries involved in the development of automation
and control systems are the oil/gas industries, power generation
companies, water and sewage treatment plants, chemical industries,
pharmaceutical, food and beverage industries and some basic systems
used by service providers in small companies and homes.
Automation processes is now aiming to progress in the so called
complete automation which will remove all human machine interface
will not be needed but just to enter parameters of the process to be
controlled and the machine performs the rest of the designed activities.
A control system is an interconnection of components connected
or related in such a manner as to command, direct, or regulate itself or
another system. Automatic control systems enable to operate processes
in excellent and accurate manner. Considering some process applications
in the industries, the need of control systems to achieve industrial targets
and objectives by continually measuring process variables such as
2
temperature, pressure, level, flow and concentration, taking into actions
such as opening valves, slowing down pumps and turning up heaters in
order to maintain measured process variables at the operator's set point
values. With this idea for the future development in technology, software
applications like the microcontroller can help to achieve this aim for
complete automation processes.
The pump control system based on three main points are the
places where the sensors at the tanks, first sensor at top level of the
overhead tank and the second at a quarter level of the overhead tank and
the third sensor level at the suction level of the submersible pump in the
underground tank. The submersible pump cannot draw water from the
underground tank only if the water level in the underground tank reaches
water level sensor at the underground tank. The microcontroller controls
the implementation process according to the level of water in the
overhead tank and the underground tank and decides if the pump
working or not. The microcontroller stops the pump if the overhead tank
is full or the occurrence of any error in the sensor signals or if the
underground tank is empty. The microcontroller run the pump if the
water level in the underground tank is reaches the water sensor level of
the draw submersible pump and the water level in the overhead tank is
not touching any of these sensor (tank is empty) or touching the sensor at
the quarter of the overhead tank level (not full). Microcontroller signal
pass through the driver
then to relay for the implementation of the
process of turning on or off the submersible pump.
There are three Light Emit Diode (LED) indicators of the water
level .red Light Emit Diode (LED) indicates the water level in the
underground tank is less than suction level of the submersible pump,
yellow Light Emit Diode (LED) indicates the overhead tank is full, and
green Light Emit Diode (LED) indicates the water level reaches a quarter
7
level of the overhead tank or slightly more than this. Not only the Light
Emit Diode (LED) will switch on but also the buzzer when the fill of the
overhead tank. Figure (2.1) show the block diagram of pump control
system.
Fig (2.1) The block diagram of the pump control system.
There are some literatures that survey water level control and
pump control systems. Also, some papers that overview and compare the
current techniques in this area.(Sanjay et al., 2015; Muktha et al.,
2013; Khaled
et al., 2010) these different methods for water level
control or automatic pump. (Sanjay et al., 2015) The paper presents
smart water monitor system and by using transistor BC547 as switch
(level sensor) send an alert to the system for controlling using wireless
Zigbee with microcontroller is responsible for processing network
protocol and the modulates signal that has been collected and transmitted
8
the via a Zigbee antenna. The signal receives by Zigbee receiver then
accordingly main valve or motor control automatically
[4]
. The research
result was a flexible, low cost easy maintainable wireless system.
(Muktha et al.,2013) in this approach water level sensing and controlling
with wireless communication and radio frequency transceivers used for
send signal to microcontrollers placed at each tank to control the pump.
The setback in this approach the large number of circuit components,
which makes it high cost
[5]
. (Khaled et al., 2010) introduced the notion
of water level monitoring and management within the context of
electrical conductivity of the water. The motivated by the technological
affordances of mobile devices, investigated the microcontroller based
water level sensing and controlling in a wired and wireless environment.
The research result was a flexible, economical and easy configurable
system designed on a low cost PIC16F84A microcontroller.
2.2 Control Architectures
Control means measuring the value of the controlled variable of
the system and applying the control signal to the system to correct or
limit deviation of the measured value from a desired value
[6]
. Many
Mechatronics systems have multiple inputs and outputs related by
deterministic relationships that result in some form of control of the
outputs. A designer can choose from a wide spectrum of control
architectures, ranging from simple open loop control to complex
feedback control. Implementation of the control can be as simple as
using a single operational amplifier or as complicated as programming
massively parallel microprocessors.
The following describe a hierarchy of basic control approaches may
consider in the design of a Mechatronics system:-
9
2.2.1 Analog Circuits
Many simple Mechatronic designs require a specific actuator
output based on an analog input signal. In some cases, analog signal
processing circuits consisting of operational amplifier or and transistors
can be employed to effect the desired control. Operational amplifier can
be used to perform comparisons and mathematical operations such as
analog addition, subtraction, integration, and differentiation. They can
also be used in amplifiers for linear control of actuators. Analog
controllers are often simple to design and easy to implement and can be
less expensive than microprocessor-based systems.
2.2.2 Digital Circuits
If the input signals are digital or can be converted to a finite set of
states, then combinational or sequential logic controllers may be easy to
implement in Mechatronics design. The simplest designs use a few
digital chips to create a digital controller. To generate complex Boolean
functions on a single integrated circuit(IC), specialized digital devices
such as programmable array logic (PAL) controllers and programmable
logic arrays (PLAs) can be used to reduce design complexity.
Programmable array logics (PALs) and programmable logic arrays
(PLAs) contain many gates and a grid work of conductors that can be
custom connected using a programming Device. Once programmed, the
integrated circuits (ICs) implement the designed Boolean function
between the inputs and outputs. Programmable array logic (PALs) and
programmable logic arrays (PLAs) may offer an alternative to complex
sequential and combinational logic circuits that require many integrated
circuits (ICs).
Another type of programmable logic-gate-based device is the field
programmable gate array (FPGA).Like programmable array logics
11
(PALs) and programmable logic arrays (PLAs), an field programmable
gate array(FPGA) contains a large number of reconfigurable gates that
can be programmed to create a wide range of logic functions. Field
programmable gate arrays (FPGAs) are different from programmable
array logics (PALs) and programmable logic arrays (PLAs) because they
also can include memory, input/output (I/O) ports, arithmetic functions,
and other functionality found in microcontrollers. Furthermore, field
programmable gate arrays (FPGAs) are usually programmed with a highlevel software language (e.g., Very High Speed Integrated Circuit
(VHSIC) (VHDL Hardware Description Language) field programmable
gate array that allows for fairly sophisticated functionality.
Sometimes, it may be economically feasible to design an
application specific integrated circuit (ASIC) that provides unique
functionality on a single integrated circuit(IC).Logic functions, memory,
computation, signal processing, and other digital and analog features can
be custom built
onto a single application-specific integrated
circuit(ASIC). Design and setup for manufacturing can be expensive, but
in high volume manufacturing applications, an application specific
integrated circuit (ASIC) solution can be cheaper in the long run.
Application specific integrated circuits (ASICs) are also attractive
because the integrated solution will usually be smaller in size and
consume less power.
2.2.3 Programmable Logic Controller
Programmable logic controllers (PLCs) are specialized industrial
devices for interfacing to and controlling analog and digital devices.
They are designed with a small instruction set suitable for industrial
control applications. They are usually programmed with ladder logic,
which is a graphical method of laying out the connectivity and logic
11
between system inputs and outputs. Programmable logic controllers
(PLCs) are designed with industrial control and industrial environments
specifically in mind. Therefore, in addition to being flexible and easy to
program, they are robust and relatively immune to external interference.
The National Electrical Manufacturers Association (NEMA) has
defines a programmable logic controller as: A digitally operating
electronic apparatus which uses a programmable memory for the internal
storage of instructions for implementing specific functions such as logic,
sequencing, timing, counting, and arithmetic to control, through digital
or analog input/output modules, various types of machines or processes.”
In essence, the programmable logic controller consists of
computer hardware, which is programmed to simulate the operation of
the individual logic and sequence elements that might be contained in a
bank of relays, timers, counters, and other hard-wired components.
Early Programmable logic controllers (PLCs) that were developed
during the late 1960s were difficult to program. These early devices were
merely relay replacements and could do very little else, in recent years
rapidly developed into a sophisticated and highly versatile control
system component. Units today are capable of performing complex math
functions including numerical integration and differentiation and operate
at the fast microprocessor speeds now available. Today's systems can
accept and generate analog voltages and currents as well as a wide range
of voltage levels and pulsed signals, Programmable logic controllers
(PLCs) are also designed to be rugged. Unlike their personal computer
cousin, they can typically withstand vibration, shock, elevated
temperatures, and electrical noise to which manufacturing equipment is
exposed. As more manufacturers become involved in Programmable
logic controllers' production and development, and Programmable logic
12
controller capabilities expand, the programming language is also
expanding.
2.2.4 Single-Board Computer
When an application requires more features or a resource than can be
found on a typical microcontroller and size is not a major concern, a
single-board computer offers a good alternative. Most single board
computers have enough Random Access Memory (RAM) and offer
compilers to support programming in a high level language such as C.
Single board computers are also easily interfaced to a personal computer.
This is useful in the testing and debugging stages of design development
and for downloading software into the single-board computer’s memory.
The term mini controller refers to another class of device that falls
between a microcontroller and a single-board computer. Examples are
the Handy board, Basic Stamp, and Arduino. These boards contain
microcontrollers and other peripheral components that make it easier to
interface to external components.
2.2.5 Personal Computer (PC)
In the case of large sophisticated mechatronic systems, a desktop
or laptop personal computer may serve as an appropriate control
platform. Also, for those not experienced with microcontrollers and
single-board computers, the personal computer may be an attractive
alternative. The personal computer can be easily interfaced to sensors
and actuators using commercially available plug-in data acquisition
cards or modules.
These devices typically include software drivers that enable
programming with standard high-level language compilers and
development environments. Due to the ease and convenience of this
13
approach, personal computer controlled mechatronic systems are
especially common in Research and Development (R&D) testing and
product development laboratories, where fast prototyping is required but
where large-quantity production and miniaturization are not concerns.
2.2.6 Digital Signal Processing (DSP)
Digital signal processing is single microcomputer device .A digital
signal processor can have functionality similar to that of a
microcontroller, but digital signal processors are usually better suited to
high-speed floating point calculations. Digital signal processors are
useful in communication, audio/video, and control applications where
fast calculation of digital filters and weighted sums is important for fast
cycle times [7].
2.2.7 Microcontrollers
Microcontrollers were first considered at Intel in 1969 when a
Japanese company approached Intel to build some integrated circuits for
calculators. Marcian Huff used his previous experience on the
Programmed Data Processor PDP-8 to propose an alternate solution a
programmable integrated circuit(IC). Frederico Faggin transformed this
idea to reality and Intel bought the license from the Japanese company
(BUSICOM) to create the 4004 4-bit microprocessor capable of 6000
operations per second. This was soon followed by the 8-bit 8008 in
1972. Intel’s efforts were soon followed by Motorola with the 8-bit 6800
series and MOS Technology introduced the 6501 and 6502 for only $25
each. It was all downhill from there.
A single chip microcontroller and 900 MHz radio known as
(“Spec”) was designed by Jason Hill at UC Berkeley for a new field in
engineering known as “sensor networks.” Because microcontrollers and
14
radios are so cheap and easy to use today, you could fill a building with
thousands of them, all talking together over low power radios. By
sensing their environment, these small sensors could control lighting,
temperature, as well as numerous other environmental controls.
The needs of embedded control are very different from those of
the standard personal computers. For the life of the device, usually it will
run only one program, apart for the occasional program update. Because
there is little support hardware; Visual Display Unit (VDU), keyboard,
hard-drive or floppy disk there is little need for mass storage. Usermachine, machine-user interaction is also limited. They are often
required to operate in hostile environments such as high temperatures,
dust/corrosive atmospheres and perhaps both mechanically and
electrically noisy.
Microcontroller is a highly integrated chip that contains all the
components comprising a controller. Typically this includes a Central
Process Unit (CPU), Random Access Memory (RAM), some form of
Read Only Memory (ROM), input/output (I/O) ports, and timers. Unlike
a general purpose computer, which also includes all of these
components, a microcontroller is designed for a very specific task to
control a particular system. As a result, the parts can be simplified and
reduced, which cuts down on production costs.
Microcontrollers
are
sometimes
called
embedded
microcontrollers, which just mean that they are part of an embedded
system that is, one part of a larger device or system.
2.2.7.1 Microcontroller Advantages
Microcontrollers are widely used in today’s control systems for
the following reasons:
12
1. Design and Simulation
Because can programmed with software, detailed simulations may
be performed in advance to assure correctness of code and system
performance.
2. Flexibility
Ability
to
Programmable
reprogram
Read
Only
using
Memory
Flash,
Electrically Erasable
(EEPROM)
or
Erasable
Programmable Read Only Memory (EPROM) allows straightforward
changes in the control law used.
3. High Integration
Most microcontrollers are essentially single chip computers with
on-chip processing, memory, and input/output. Some contain peripherals
for serial communication and reading analog signals with (an analog to
digital converter or analog to digital converter). This differentiates a
microcontroller from a microprocessor. Microprocessors require that this
functionality be provided by added components.
4. Cost
Cost savings come from several locations. Development costs are
greatly decreased because of the design/flexibility advantages mentioned
previously. Because so many components are included on one integrated
circuit(IC), board area and component savings are often evident as well.
5. Easy to Use
Just program and go! While in the past, programming has often
involved tedious assembly code, today C compilers are available for
most microcontrollers. Microcontrollers often only require a single 5V
supply as well which makes them easier to power and use.
2.2.7.2 Microcontroller architecture
The Atmel ATmega16 microcontroller for example integrates
memory, clock, a central processing unit, input/output, timers, and an
12
analog to digital converter figure (2.2) show ATmega16 microcontroller
architecture.
Fig (2.2) ATmega16 microcontroller architecture
1- Memory
Memory on a microcontroller can be used to store data and/or the
program to be run. There are often several types of memory on a
microcontroller:
- Random Access Memory (RAM).
- Read Only Memory (ROM).
- Programmable Read Only Memory (PROM).
 Erasable Programmable Read Only Memory (EPROM).
 Electronically Erasable Programmable Read Only Memory
(EEPROM).
 Flash Memory a type of EEPROM.
17
Random Access Memory (RAM) can be either read or written,
and this usually happens quite fast. Data stored on a microcontroller is
often stored in Random Access Memory Random Access Memory
(RAM) However, the data stored in Random Access Memory (RAM) is
volatile which means that it is lost when power is turned off. Read Only
Memory (ROM) is non-volatile and therefore stored between power
cycles, but may not be written to.
Programmable Read Only Memory (PROM) is therefore a
compromise between these two types of memory. Programmable Read
Only Memory (PROM) is nonvolatile and also allows a user to program
it Ultra Volatile (UV) light, but more common today is Electronically
Erasable Programmable Read Only Memory (EEPROM). Erasable
Programmable Read Only Memory allows read and write access and is
also non volatile, but the sacrifice here is that data transfers take much
longer than with Read Only Memory.
Flash memory is a type of Erasable Programmable Read Only
Memory. Program memory (where the program is stored) on the
ATmega16 is Flash memory. This is also the same as the memory used
in digital cameras and cell phones. Data transfer using flash is much
faster than Erasable Programmable Read Only Memory because it works
in blocks of bytes instead of single bytes. This makes it perfect for
program memory in that case.
2- Clock
The ATmega16 is run off an 8 MHz crystal oscillator. The rate of
instruction execution is fixed and synchronized by this clock. However,
this does not mean that each instruction takes 125 nsec. Different
instructions require a different number of cycles.
18
3- Central Process Unit (CPU)
This is brains of the microcontroller – the Central Process Unit
(CPU) executes instructions such as add, move, jump, multiply, etc. To
do so, it must first fetch the instruction and any required data over its
data bus.
4- Input/Output (I/O)
The ATmega16 offers 32 programmable input/output (I/O) lines
with 4 8-bit ports. By programming specific registers on the ATmega16,
these lines may be set to input, output, or some secondary function. If a
pin is set as output, setting the corresponding bit in the output register to
1 will output Vdd on that pin and 0 will output ground. If the pin is set to
input, it is possible to read either a 1 or 0 on that pin. These pins act just
like memory locations so all that is required to output a value is setting a
bit in a memory register. To read a pin, all need to do is read a bit in a
register.
5- Timers
Timers are internal clocks (2 for 8-bit timers and 1 for 16-bit timer
is included in the ATmega16). Each timer can be scaled by some factor
from the system clock (8MHz). These timers can then give a sense of
time and duration information of great importance in digital control
systems. In most cases, just use a timer to count from 0 to 255 for an
8-bit timer, or 0 to 65536 for a 16-bit timer.
In addition, many interrupts can be triggered off of timers. An
interrupt is a piece of code triggered by a particular event. That event
might be a timer overflowing, or reaching a particular value.
6- Analog-to-Digital Converter (ADC)
In most cases, the real world gives analog signals. Reading light
levels from a photoresistor will give an analog voltage relating to the
19
current light falling on the photoresistor. For the microcontroller to deal
with this information, it must be converted to a digital format. An analog
to digital converter does exactly that.
The ATmega16 provides an 8-channel 10-bit analog-to-digital
converter. The number of channels is the number of pins supporting the
analog-to-digital converter functionality (this is one of the secondary
functions mentioned earlier in input/output). The number of bits tells us
the resolution with which can read the analog data.
2.2.7.3 Types of Microcontrollers
Microcontrollers can be classified on the basis of internal bus
width, architecture, memory and instruction set. Figure (2.3) shows the
various types of microcontrollers.
Fig (2.3) Types of microcontrollers
1- The 8,16 and 32 bit Microcontrollers
i- The 8- bit Microcontrollers
ii- The 16- bit Microcontrollers
iii- The 32- bit Microcontrollers
21
2- Embedded and external memory microcontrollers
i- Embedded microcontrollers
ii- External memory microcontrollers
3- Microcontrollers architecture Features
i- Von-Neuman architecture
ii- Harvard architecture
iii- Complex Instruction Set Computer (CISC) Architecture
microcontroller
iv-Reduced Instruction Set Computer (RISC) architecture
v-Specific Instruction Set Computer (SISC)
2.2.7.4 Microcontrollers Selection
Choosing a microcontroller from a number of different
microcontrollers is a very critical decision for the designers. Three are
the vital major criteria for selecting them. These are wide availability
and reliable sources, meeting the requirements efficiently and cost
effectively, availability of the software development tools like compilers,
Assemblers and debuggers etc. The main criteria in selecting a
microcontroller are given below in the order of importance.
1- System Requirement
Design should start with a blank sheet of paper specifying the
application needs, if the system requires a single chip microcontroller or
additional peripherals are to be used with it. Selection process starts with
a decision of choosing either the 4-bit, 8-bit, 16-bit or 32-bit
microcontroller required by the application. To develop code for 4-bit
architectures is harder and handling 4-bit instructions and data widths
can limit arithmetic capabilities. Most of the embedded applications are
implemented using 8-bit microcontroller as the technology has been
around a long time and huge number of controllers is available in the
21
market. They are used from low cost, low speed 4-bit micro replacement
to device which deliver tens of MIPS, such as Atmel’s AVR series which
achieves a 50 ns instruction cycle time when clocked from a 20 MHz
crystal. If the application needs more processing power the choice is
most likely to be 16-bit or 32-bit microcontroller. Vendors offer 32-bit
performance cost effectively. 32-bit devices come at virtually no cost to
the user. The on chip peripherals available exhibit heavy influence on
component selection. Check the availability of Timers, Serial interfaces,
Read Only Memory, Random Access Memory, analog to digital
converter, digital to analog converter sufficient number of input/output
(I/O) ports. Too many input/output (I/O) ports lead to bear excessive cost
but few cannot do the job.
2- Memory Architecture
This is very important factor while designing any microcontroller
based system. Three different types of memory play an important role in
the selection process are program memory i.e. (Flash, OTP, Read Only
Memory (ROM) and Read Only Memory (ROM) less components), Data
memory i.e.( on-chip SRAM or external SDRAM) and Non volatile
Memory i.e. Electronically Erasable Programmable Read Only Memory
(EEPROM) or Flash. Whether the memory is on-chip or off-chip and
how much the size is required may be a key factor defines cost of
building the system and speed of operation. For an example Atmel AVR
family include Flash memory of 1KB to 128KB, on chip SRAM for data
storage and for the storage of configuration information and serial
numbers a few bytes of Electronically Erasable Programmable Read
Only Memory (EEPROM) are reserved. These golden features make the
AVR family more popular in different applications. Flash gives the
flexibility to make code changes and provides facility to use In System
22
Programmed. Atmel 89C51 and Mega AVR families have the segmented
Flash blocks which allows reprogram one segment under control of
another segment, without removing the power. Lastly it is best to choose
a device from a family which provides sufficient or more memory space
than the expectation of need.
3- Availability
Before going to implement the system, the availability of the
device should be checked. The criteria in choosing microcontroller is its
ready availability in needed quantities both now and future. If sufficient
quantities are available with bright future then no need to be worried
about the failure of the project.
4- Size
If integrated circuit(IC) of 15 input/output (I/O) pins is required to
develop the system there is no need to use 40 pin integrated circuit (IC)
with 32 input/output (I/O) pins. In this way the size of the integrated
circuit(IC) can be reduced and thus physical space required to implement
the system is also reduced. So, physical size of integrated circuit(IC)
may well be critical factor for specific applications.
5- Compatibility
The function of a system can be changed or upgraded by changing
the software or replacing one integrated circuit(IC) with another one
without incurring heavy additional cost. The new one will be pin
compatible as well as function compatible.
6- Functionality Testing
To check the function of the implemented system correctly the
function of the microcontroller unit should be checked within the test
circuit designed earlier before going to develop the overall system.
23
7- Power Management
Power consumed by the system determines the lifetime of the
battery. Due to reduction in size of the devices the size of the
components are reduced and their placement within the design is very
compact. This phenomenon makes the devices to be sensitive to the heat
dissipated from the microcontroller unit and the other peripherals
connected with it. It is the duty of an engineer to look first at the power
required at the clock speed necessary to run the application. Read Only
Memory (ROM) based devices tolerate very low operating voltages
(around 0.9v). In case of Atmel AVR devices Flash based
microcontroller can be operated at the voltages down to 1.8V. Most
microcontrollers have the features of power down, idle & sleep modes
and consideration needs to be given to maximize the use of intelligent
power management systems to reduce power consumption.
8- Manufacturer’s Track Record
Manufacturers should ensure the stability, good performance,
better throughput, Reliability; better Serviceability, software support,
correctness, wide and timely availability of their products. For an
example product of Intel, Freescale, Zilog, and Microchip Technology
are stable, mature and single sourced. The points like design challenges,
on time delivery, performance, years in business and year of transaction,
financial report should be followed as the track record of the
manufacturers. They must provide the datasheet or user guide which
consists of characteristics, functionality, sample test circuit, electrical
characteristics and dimension etc. The documentation of maintenance of
the development system, the range of services and its associated software
must be available for the common user.
24
9- Manufacturer’s Support
During the step by step implementation of the system if the design
engineer faces any kind of problem he/she may communicate with the
marketing/sales, field application engineers. The manufacturers should
have some facilities like a help line, toll free number, fax number, aftersales support, sufficient knowledgeable and helpful expertise support
personnel who will give a prompt reply or they will follow through in a
regular manner when they promise to do something.
10- Availability of Development Support
Here the key consideration includes Assembler, Debugger, a code
efficient C compiler, emulator, technical support. Trend towards
programming in high level language like C is increasing day by day.
This language allows using of some portability of code and libraries.
This
provides
more
practical
consideration
using
different
microcontroller family. Choosing the appropriate Hardware and software
development tools is also important while selecting microcontroller unit.
An Integrated Development Environment (IDE) facilitates the
development efforts by providing the project management tools. IDE
enables to create source files and their organization in to a project,
creation of database for many devices. An example of IDE is Keil
uVision 2 which compiles to point out and correct the errors, assembles
and links the device datasheet, user guides and development tool
manuals. Another good example is MPLAB for PIC and dsPIC
microcontrollers from Microchip Technology. This is mainly used for
development of embedded systems.
11- Cost
This is the most important factor. If the system is to be
implemented within the limit of the budget calculated earlier the cost of
22
each and every component (selected microcontroller unit along with
supporting integrated circuits) used to build the system should be
minimized tactfully to fulfill the requirements. On chip features will
trade with inventory and assembly cost of using extra supporting
external components. They can also cut development time and effort by
providing a ready integrated solution. Design of special hardware
requires non recurring engineering cost and cost for manufacturing the
unit. Integration of some peripherals like 10/100 base T Ethernet MACs,
Controller Area Network (CAN bus) interfaces, Universal Serial Bus
(USB), Radio Frequency (RF) transmitter and graphics driver cuts the
system cost in some great extent. For high volume applications most
users prefer Read Only Memory (ROM) based devices due to their lower
cost and code security [8].
According to these criteria the microcontroller has been selected is
ATmega16 has the following features:The device is manufactured using Atmel’s Mega AVR family with
low power consumption an 8-bit high performance microcontroller four
8-bit ports designated as PORTA, PORTB, PORTC and PORTD.
Atmega16 is based on enhanced Reduced Instruction Set Computing
(RISC). Most of the instructions execute in one machine cycle.
Atmega16 can work on a maximum frequency of 16MHz and has 16 KB
programmable flash memory, Static Read Access Memory (SRAM) of 1
KB and Electronically Erasable Programmable Read Only Memory
(EEPROM) of 512 Bytes. ATmega16 is a 40 pin microcontroller. There
are 32 input/output (I/O) lines which are divided into in-built peripherals
like Universal Synchronous Asynchronous Receiver Transmitter
(USART) analog to digital converter, Analog Comparator, Serial
Peripheral Interface (SPI), Joint Test Action Group (JTAG) etc. Each
22
input/output pin has an alternative task related to in-built peripherals.
Figure (2.4) shows the pin configuration of ATmega16.
Fig (2.4) The pin configuration of ATmega16
2.2.7 .5 ATmega16 Microcontroller Pin Out Description
VCC : Digital supply voltage.
GND : Ground.
Port A :
serves as the analog inputs to the analog to digital converter. also
serves as an 8-bit bi- directional input/output (I/O) port, if the analog to
digital converter is not used. Port pins can provide internal pull-up
resistors (selected for each bit).
Port B :
is an 8-bit bi-directional input/output (I/O) port with internal pullup resistors (selected for each bit).
Port C :
is an 8-bit bi-directional input/output (I/O) port with internal pullup resistors (for each bit).If the interface is enabled, the pull-up resistors
27
on pins PC5(TDI), PC3(TMS) and PC2(TCK) will be activated even if a
reset occurs selected, also serves the functions of the interface and other
special features of the ATmega16,serves the functions of various special
features of the ATmega16.
Port D :
is an 8-bit bi-directional input/output (I/O) port with internal pullup resistors (selected for each bit). also serves the functions of various
special features of the ATmega16.
RESET:
Reset Input. A low level on this pin for longer than the minimum
pulse length will generate a reset, even if the clock is not running.
XTAL1 :
Input to the inverting oscillator amplifier and input to the internal
clock operating circuit.
XTAL2 :
Output from the inverting oscillator amplifier.
AVCC :
is the supply voltage pin for Port A and the analog to digital
converter. It should be externally connected to VCC, even if the analog
to digital converter is not used. If the analog to digital converter is used,
it should be connected to VCC through a low-pass filter.
AREF :
is the analog reference pin for the analog to digital converter [9].
2.2.7.6 Microcontroller Applications
In addition to control applications such as the home monitoring
system, microcontrollers are frequently found in embedded applications.
Among the many uses that can find one or more microcontrollers:
automotive applications, appliances (microwave oven, refrigerators,
television and Video Cassette Recorders VCRs, stereos), automobiles
28
(engine control, diagnostics, climate control), environmental control
(greenhouse, factory, home), instrumentation, aerospace, and thousands
of other uses. Microcontrollers are used extensively in robotics. In this
application, many specific tasks might be distributed among a large
number of microcontrollers in one system. Communications between
each microcontroller and a central, more powerful microcontroller (or
microcomputer, or even large computer) would enable information to be
processed by the central computer, or to be passed around to other
microcontrollers in the system.
A special application that microcontrollers are well suited for is
data logging. By stick one of these chips out in the middle of a corn field
or up in a balloon, one can monitor and record environmental parameters
(temperature, humidity, rain, etc). Small size, low power consumption,
and flexibility make these devices ideal for unattended data monitoring
and recording [10].
2.3 Pumps
The purpose of a hydraulic pump is to supply a flow of fluid to a
hydraulic system. The pump does not create system pressure, since
pressure can be created only by a resistance to the flow. As the pump
provides flow, it transmits a force to the fluid. As the flow encounters
resistance, this force is changed into a pressure. Resistance to the flow is
the result of a restriction or obstruction in the pass of the flow. This
restriction is the normally work accomplished by the hydraulic system,
but can also be restriction of lines, fittings, and valves within the system.
Thus, the pressure is controlled by the load imposed on the system or the
action of a pressure regulating device. Pumps are in general classified as
centrifugal pumps or positive displacement pumps.
29
2.3.1Positive Displacement Pumps
The positive displacement pump operates by alternating of filling
a cavity and then displacing a given volume of fluid. The positive
displacement pump delivers constants volume of liquid against varying
discharge pressure or head. The positive displacement pumps can be
classified as:
2.3.1.1 Reciprocating pumps
2.3.1.2 Power pumps
2.3.1.3 Rotary pump
2.3.1.4 Steam pumps
2.3.2 Centrifugal Pumps
The centrifugal pump produces ahead and a flow by increasing the
velocity of the liquid through the machine with the help of a rotating
vane impeller. The centrifugal pumps can be classified as:
2.3.2.1 End suction pump
2.3.2.2 In line pump
2.3.2.3 Multistage pump
2.3.2.4 Self-priming pump
2.3.2.5 Axial flow pumps
2.3.2.6 Regenerative (turbine) pumps
2.3.2.7 Submersible pumps
The centrifugal pump is commonly found inside a submersible
fountain pump and some air conditioning units. As the impeller inside it
turns, water is drawn in one side of the pump. It is then expelled out the
other end. The power and size of the impeller decide the amount of water
flow. More water can be pumped if we have a larger impeller. As the
impeller rotates, it moves water from the inlet (which is located near the
center of rotation of the impeller) along the surfaces of the impeller to
31
the outer portions of the volute by means of centrifugal force (thus, its
name centrifugal pump). As this water collects in the outer regions of the
volute, it is directed to the outlet. The water leaving the outlet causes the
water pressure to drop at the inlet. To match the rate with which water is
leaving the outlet, the pump sucks in new water at the inlet. These pumps
must be primed before starting, which in this case is already done
because of its underwater application. Figure (2.5) show the Submersible
pump.
Fig (2.5) The Submersible pump
2.4 Level Sensor
Sensor is the prime element or device that used to detect/measure
the magnitude of something. Sensors principle always based on a certain
phenomenon type. In principle there are two types of level
measurements:
2.4.1 Continuous level Measurement
Continuous level measurement provides information on the actual
level. The threshold detection provides information whether given
critical level(s) have been reached. A continuous level measurement
sensor provides a signal proportional to the level of the material.
31
2.4.1.1 Capacitive Sensors
Filling the space between electrodes with a material having a
relative permittivity more than one increases capacitance of the sensor
proportionally to the relative permittivity and the level figure (2.6) show
the capacitive sensor with planar electrodes for level measurement.
Fig (2.6) Capacitive sensor with planar electrodes for level measurement
The first expression corresponds to the capacity of the empty
container. Variation of the permittivity value causes systematic errors
which could be compensated for by using an additional capacitive sensor
which measures the permittivity. Capacitance of level sensor also
depends on density, concentration, temperature and humidity. There are
other type is capacitive level sensor with cylindrical coaxial electrodes
where the capacitance of the cylindrical coaxial capacitor is dependent
on the fluid level (h) ,tank diameter (D),and the sensor diameter (d)
figure (2.7) show the capacitive sensor with cylindrical coaxial
electrodes.
32
Fig (2.7) Capacitive sensor with cylindrical coaxial electrodes
2.4.1.2 Ultrasonic Sensors
The transducer emits pulses of ultrasonic waves which are then
reflected from interfaces between materials with different mechanical
properties (discontinuities of acoustical impedance). The piezoelectric
transducer can operate alternatively either as transmitter or a receiver.
The distance (d) between the transducer and the level is found from the
sound velocity and the travel time of the ultrasonic pulses. Compensation
of temperature effect on sound velocity is carried out using data from an
outside temperature sensor. The sensor axis must be perpendicular to the
reflecting surface and reflections from tubes and bracing have to be
avoided in order to produce an echo without disturbances (false echoes).
Installation of the sensor in the focus of a parabolic tank cap increases
the level of disturbing signals. The optimal position would generally be
at half of the container radius in the center. The principle of operation of
ultrasonic sensors is shown in Figure (2.8).
33
Fig (2.8) The principle of ultrasonic sensors for level measurement
2.4.1.3 Microwave Sensors (radar)
Regarding pulse-radar, the travel time of microwave signals is
measured. Due to the high value of light velocity c0, the duration of the
pulses is only 1 ns, otherwise the transmitted and received pulse would
overlap. Short pulses pose high requirements on time interval Δt
measurement. Therefore, most of the level sensors use Frequency
Modulated Continuous Wave (FMCW) principle .Microwave sensors are
used in cases of high temperature, mist or dust, for rapidly moving
objects or for long distance measurement. Their disadvantage is the
relative high cost of sensors compared to other types of level
measurement principles. The microwaves can penetrate non conducting
materials such as glass or nylon with low reflection, thus measurement
can be made through the nylon container side without contact with the
inner side of the container system. It is possible to choose the thickness
of the penetrated material, so that the reflection of waves entering and
leaving the material will cancel each other out. The resulting reflecting
disturbance will then be zero. This is called wave cancellation and is
based on the same principle as antireflection coating used for optical
components.
2.4.1.4 Pressure Difference (hydrostatic) Sensors
The pressure of a liquid is the difference between the hydrostatic
pressure in the liquid on the bottom of the container and in the space
34
above the liquid level is proportional to the specific weight and the
level(h).
2.4.2 Detection of Threshold Values (limits)
The sensors for level detection limits act as switches outputting a
logical signal when a certain level has been reached there are many type:
2.4.2.1 Capacitive level Switch
Whenever the bulk material has reached the position where the
sensor had been installed the value of the sensor capacitance is higher
than a preset value and switch is activated. The resolution of 0.01 mm
can be reached and therefore they can be used for leakage control in oil
tanks.
2.4.2.2 Ultrasonic Switch
In ultrasonic sensors the time of travel (tf) is evaluated and when
the value of (tf) reaches the set limit the output logical signal is
generated. The sensor can also identify the presence of an object within
the switch area.
2.4.2.3 Vibrational Switch
The vibrational sensor uses a vibrator (rod, tuning fork) driven by
a piezostrictive (or magnetostrictive) force and oscillates at its
mechanical resonant frequency. If the material is in contact with the
oscillating rod, its presence will dampen the oscillation amplitude which
is sensed mostly by a piezoelectric sensor. When the vibration amplitude
drops below a certain level, the switch is activated. The sediments of the
bulk material on the vibrating rod are removed by forced pulses of
vibrations.
2.4.2.4 Conductive Sensors
Conductive sensors consist of electrodes inserted into the
container which measures the resistance of the bulk material. A
32
conductive container can serve as a common electrode and in this case
the sensor consists of only one electrode.
2.4.2.5 Fiber Optics Level Switches
The function of these switches is based on the change of the
optical fiber properties when the level of a liquid with appropriate
refraction index reaches the end of the fiber immersed in the fluid
2.4.2.6 Floating Switch
Due to the higher fluid density, the float (buoy) floats on the
surface of the liquid. The float may carry a permanent magnet, which
produces a magnetic field strong enough to activate a reed switch located
at the position of the level being detected. Using two floats with different
buoyancy, it is possible to measure the respective level of immiscible
liquids such as water and oil in a storage tank
[11]
. Figure (2.9) show the
float switch.
Fig (2.9) The float switch
2.5 ULN2003A driver
Is high voltage, high current Darlington arrays each containing
seven open collector Darlington pairs with common emitters. Each
channel rated at 500mA and can withstand peak current of 600 mA .
Suppression diode are included for inductive load driving and the input
32
are pinned opposite the outputs to simplify board layout and the interface
use with is
commons (COMS) or 5V Transistor
Transistor
Logic (TTL)[12] . Figure (2.10) show ULN2003A driver.
Fig (2.10) ULN2003A driver
2.6 The Relay
Relay is an electromagnetic device which is used to isolate two
circuits electrically and connect them magnetically. They are very useful
devices and allow one circuit to switch another one while they are
completely separate. They are often used to interface an electronic circuit
(working at a low voltage) to an electrical circuit which works at very
high voltage. For example, a relay can make a 5V Direct Current (DC)
battery circuit to switch a 230V Alternating Current (AC) mains circuit.
Thus a small sensor circuit can drive say, a fan or an electric bulb.
A relay switch can be divided into two parts: input and output.
The input section has a coil which generates magnetic field when a small
voltage from an electronic circuit is applied to it. This voltage is called
the operating voltage. Commonly used relays are available in different
configuration of operating voltages like (5 V, 6V, 9V, 12V, 24V etc).
The output section consists of contactors which connect or disconnect
37
mechanically. In a basic relay there are three contactors: Normally Open
(NO), Normally Closed (NC) and common (COM). At no input state, the
COM is connected to NC. When the operating voltage is applied the
relay coil gets energized and the COM changes contact to NO. Different
relay configurations are available like Single pole, single throw(SPST),
Single
pole,
double
throw
(SPDT), Double
pole,
double
throw(DPDT) etc, which have different number of changeover contacts.
By using proper combination of contactors, the electrical circuit can be
switched on and off [13] . Figure (2.11) show 5V relay.
Fig (2.11) 5V relay
38
CHAPTER THREE
Case Study
3.1 Introduction:
There are many methods of designing an automatic water level
control system with switching device but all these methodologies require
human assistance. Pump control system is designed using electronic
control to refill the water without human intervention. The system design
was carefully arranged to refill the water overhead tank, when the water
arrive to certain level in the overhead tank if and only if the water level
in the underground tank is over than the submersible pump sensor level,
finally the system will automatically stop the submersible pump when
the overhead tank is full.
3.2 Components Used
The pump control system has the following main components: Solder breadboard
 Float switch
 Atmega16 microcontroller
 Uln2003 driver
 5v relay
 Buzzer
 LCD16 display
 Various resistances (3K ,330) Ω
 Variable resistance 1K
 Various LED (red,yallow,green)
 Wires
39
3.2.1 Solder Board
All the components of the circuit is connected by it to form
welding joint rugged and durable.
3.2.2 Float Switch
It is used to detect water level at the two tanks and send electrical
signal to the microcontroller.
3.2.3 Atmega16 Microcontroller
It is a highly integrated chip that contains all the components
comprising a controller. Play the main role in the control system through
receiving the sensors signal and take the appropriate decision not only to
turn pump on or stop it, but also control the status of the buzzer, a
various LED color and the LCD display.
3.2.4 ULN 2003 Driver
The driver amplifies the current to suit the relay or the buzzer.
3.2.5 5v Relay
The relay will act as a switch to control the pump.
3.2.6 Buzzer
Device that converts electrical energy into sound and is used in the
audio notification when the underground tank is empty. Buzzer model
works on 6-12 volts effort and carries a constant stream of approximately
25 mA.
3.2.7 LCD16 Display
LCD (Liquid Crystal Display) screen is an electronic display
module and find a wide range of applications. A 16x2 LCD display is
41
very basic module and is very commonly used in various devices and
circuits. LCDs are economical, easily programmable, have no limitation
of displaying special characters and animations.
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 LCD displays status of the pump and sensors as well as the
water level in the tanks according to the microcontroller signal. Figure
(3.1) shows the LCD16 display pins.
Fig (3.1) The LCD16 display pins
3.2.7.1 LCD16 Display Pins Description
D0 ~ D3: input/output 4 lines of low order data bus. Bi-directional
transfer of data between microcontroller unit and module is done through
these lines. In 4 bit operation, these are not used and should be grounded.
41
DB4 ~ DB7: input/output 4 lines of low order data bus. Bi-directional
transfer of data between microcontroller unit and module is done through
these lines. In 4 bit operation, these are not used and should be grounded
Vss: Power Supply 0V (GND)
Vcc: Power Supply +5V
Vee: Power Supply terminal for LCD drive power source.
RS : Input microcontroller unit Register Select.
R/W : Input microcontroller unit Signal to select Read or Write.
E : Input microcontroller unit Enable - Operation start signal for data
read/write
3.2.8 Various Resistors (3K ,330) Ω
Used to protect whether for microcontrollers or any other element
of the current and voltage changes.
3.2.9 Various LED (red , yellow , green)
LEDs work as indicator to water level for example red LED
explained that underground tank is empty. Yellow or green LED
indicates that overhead tank is empty or full respectively. There is
special case, occur when LEDs turned together as flash, this means an
error in the sensors signal.
3.2.10 Variable Resistance 1K
Used to control the intensity of LCD Lighting.
3.2.11 Wires
Used to connect the circuit components.
42
3.3 Welding Process
The welding process include two stage, first stage welding
elements on the board, this process will applied to the microcontroller
,driver, LCD display, constant or variable resistances, LEDs and the
relay. Taking into account the direction of the parties that will be
connected with other elements.
The second stage includes welding elements to each other by
connecting wires through the pins designed for that purpose.
3.3.1 Microcontroller Welding
The microcontroller is connected to the source (+5V) and the
ground through pins VCC and GND respectively. considering port A as
input port then PA.1,PA.2,PA.3 connected to the float switch through
the resistances 10KΩ,considering port B as output port then PB.2, PB.3
connected to the ULN2003driver,also port C then PC.0, PC.1, PC.2
connected to the LEDs through 330Ω resistances, even port D connected
to the LCD display except PD.0 and PD.7.
3.3.2 LCD Display Welding
The LCD display is connected with microcontrollers through
port D, so that pins D7, D6, D5, D4 connected to PD.6, PD.5, PD.4,
PD.3 as data line, while (E) and (R/S) are connected to PD.2, PD.1
respectively, also VDD and Anode connected to the source (+5V), but
VSS, R/W, and the Cathode are connected to the ground and (VE)
connected to the variable resistance.
3.3.3 ULN 2003 Welding
The ULN 2003 driver is connected to the source (+5V) and the
ground through pins COM and GND respectively. The input from the
43
microcontroller connected to IN4, IN5 so that the output pin OUT12
connected to the normal open of the rely pin and the output pin OUT13
connected to the buzzer.
3.3.4 Relay Welding
The input section has a coil which content two pins, one connected
to the source (+5V) and the other pin connected to the microcontroller,
the output section consists of contactors which connect the COM to the
power supply (220V) and NO connected to the pump.
3.3.5 Pump Welding
The pump is connected to the power supply (220V) and the NO
pin of the relay.
3.3.6 Variable Resistance
The variable resistance has three terminals connected to the source
and the ground, while the third terminal connected to the screen.
3.3.7 Buzzer Welding
The buzzer is connected to the source (+5V) and the OUT13 pin
of the driver.
3.4 Welding Test
After completion of the welding process, the welding must be test
to ensure that the welding process has the required image was done by
direct examination and ensure the safety of the circuit connections by
using test equipment such as a voltmeter to check the voltage difference
through the circuit elements. Figure (3.2) show the pump control system
circuit.
44
Fig (3.2) Pump control system circuit
42
3.5 Programming Process
Programming is the process of developing and implementing
various sets of instruction to enable a programmer device to do a certain
task. A sensitive automatic detector of water level
through
microcontroller as programmer device cans the design process
characterized by the following steps:
1. Definition of task.
2. Requirement.
3. Factor that influence choice.
In defining a task, every design comes from an idea or a problem
that require a solution. Questions may be generated on what exactly that
is required to be achieved and the feasibility of the ideas as regards to the
implementation. If these questions are analyzed critically with tangible
solutions to the problem, a development of this idea into a reality is the
next step. Requirement for design process have to be considered once an
idea has been establish. The need to determine whether or not the idea
require a computer or not depends on complexity of the circuitry, or
whether the circuit to be designed needs to make a complex data. The
compare of these factors with topic. Three float switch as the input point
to detect the water level at tanks, proportion to the cheap price and its
availability, a micro-controller will be the option base on the circuit to be
design with less hardware connection and flexibility. The adapter fed the
circle through (5V) voltage of which requires a broker to raise the
current in order to become enough to run the buzzer and relay for this
purpose ULN2003 driver been used. Also it is known that the relay and
driver voltages must be equal to the source voltage (5V). This requires
5V relay and ULN2003 driver also. Then the pump consume about 220V
42
this require not only other electric source but also a broker to connect the
circuits so that a relay must be used.
3.6 Software Design
A set of instructions written for the microcontroller to perform a
task is called a program, and a group of programs is called software.
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 software nor Application software, but contain elements of
both, are network software, which enables groups of computers to
communicate, 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 micro-controller base system without
depending on software. A typical Micro-controller Development
Systems (MDS) include, Visual display unit (VDU) registers, read
access memory (RAM) which serve as a stone for the Programmable
Read Only Memory (PROM) programmer. Software system is the term
use to describe a program. That is providing by the manufacturer to aid
the development of users (applications) programs. These include
programs that convert assembly language into machine code (assembler),
47
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.
3.6.1 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.
3.6.2 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
high-level language into machine code. An interpreter reads the source
code of the programs one line at a time and performs the specified
instructions contained in that line.
3.6.3 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.
3.6.4 Loader
The loader aids in loading an object code into RAM.
48
3.6.5 Testing
After the programs is written, it was tested, this involve executing
the programs with selected input called test cases, the result shows
whether or not the program is functioning as desired.
3.6.6 Debugging
This involves detecting out and removing errors in the program.
3.7 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
Basic Compiler BASCOM-AVR compiler was used to translate from the
source code into the object code. Universal IC programmer has been
used to the microcontroller programming.
3.8 Choice of Programming Language
In programming implementation for a microcontroller is BASIC
(Beginners All-purpose Symbolic Instruction Code) programming
language reasons being the fact that BASIC have several purposes, highlevel programming language, also professional language used to write
complex and high-level business programs, it is one of the most popular
languages and prevalent in addition the easy to use and learn.
3.9 Pump Control System Program Steps
Microcontroller monitor the water level at tanks through three
water level sensors, the first at the low level of the underground tank
(sensor U), the second at the low level of the overhead tank (sensor L)
and the third at the high level of the overhead tank (sensor H) then the
49
microcontroller decide to run the pump or stop it and display the status
of water at the two tanks, sensors, and the pump at the display unit,
also according to the water level the microcontroller switching the
appropriate LED and the buzzer alarm. The operation of pump control
system based on the micro-controller and water level sensors is
summarized as follows;
 When sensor U is 0 the LCD display (underground tank empty),
and the pump is off. With neglecting the status of sensor L and
sensor H this is the main condition. The buzzer and red LED will
turned on.
 When sensor H and sensor U are both 0 the LCD display
(overhead tank is empty), and the pump running.
 When sensor H is 0 and sensor U is 1 the LCD display (overhead
tank Quarter level), the pump is off, and yellow LED will turned
on.
 When sensor H is 1 and sensor U is 1 the LCD display (overhead
tank full), the pump is off, and green and yellow LED will turned
on.
 When sensor H is 1 and sensor U is 0 the LCD display (sensors
error), the pump is shut down, and all LED will turned on and off
for small time.
 Otherwise the pump is shut down. Figure (3.3) show the flow
chart that explains the Pump Control System Program Steps.
21
Fig (3.3) The flow chart of the Pump Control System Programming Steps.
CHAPTER FIVE
21
CHAPTER FOUR
The Results
4.1 Results
After the completion of the programming process and testing of
the program, comes stage of the overall test to the system to ensure that
there is no deviation in the results and then compatibility with the
expected design results. Table (4.1) shows the experimental results.
Table (4.1) the experimental results of the system
NO
Sensors
Status
U H L
Tanks Status
Head Ground
Yellow
LED
Green
LED
Red
LED
Buzzer
Status
Pump
Status
LCD
1
0
0
0
-
Empty
0
0
1
1
0
Underground
tank empty
2
0
0
1
-
Empty
0
0
1
1
0
Underground
tank empty
3
0
1
0
-
Empty
0
0
1
1
0
Underground
tank empty
4
0
1
1
-
Empty
0
0
1
1
0
Underground
tank empty
5
1
0
0
Empty
Full
0
0
0
0
1
6
1
0
1
Low
Full
1
0
0
0
1
7
1
1
0
-
Full
1
1
1
0
0
Sensors
Error
8
1
1
1
Full
Full
1
1
0
0
0
Over Head
Tank
Full
22
Over Head
Tank
Empty
Over Head
Tank Quarter
level
 According to the results table (4.1) in the first four columns when
the underground tank is empty (sensor U) is 0, ignored the case of
the over head tank as well as (sensor H, sensor L), the red LED
and the buzzer are switched on and stop the pump and the LCD
display (underground tank empty).figure (4.1) show the status of
the LCD display and the red LED.
Fig (4.1) show the status of the LCD display and the red LED
23
 In the fifth columns when the over head tank is empty the pump
will start running and the LCD display (over head tank empty),
and figure (4.2) show the status of the LCD display and the LED.
Fig (4.2) show the status of the LCD display and the LED
24
 In the sixth columns when the water reaches the low level of the
over head tank the pump will continue running and the yellow
LED is switched on the LCD display (over head tank quarter
level).figure (4.3) show the status of the LCD display and the
yellow LED.
Fig (4.3) show the status of the LCD display and the yellow LED
22
 In the seventh columns when the water reaches the high level of
the over head tank and the water don’t reaches the low level of the
over head tank the pump will stop running for un expected signal
and the all LED is switched on and off looks like flash the LCD
display (sensor error!! pump shut down) and the pump will shut
down. Figure (4.4) show the status of the LCD display and the
LED.
Fig (4.4) show the status of the LCD display and the LED
22
 In the eighth columns when the water reaches the high level of the
over head tank (full) the pump will shut down. And the yellow
LED is still on and the green LED is switched on the LCD display
(over head tank full) and the pump will shut down. Figure (4.5)
show the status of the LCD display and the green LED.
Fig (4.5) The status of the LCD display and the green LED
27
CHAPTER FIVE
Conclusion and Recommendation
5.1 Conclusion
Extensive growth of population development and technology has
leads to the need of proper utilization of the natural resources especially
water. Thus the proposed system and the review of all the possible
implementation of technology is the first step toward prevention and
proper utilization of water. Automatic water pump control system
employs the use of different technologies in its design, development, and
implementation. The system used microcontroller to automate the
process of water pumping, it is observed that domestic and offices are
one of the major areas of water polling. So implementing the low cost
easy maintainable system is one among the solutions.
The experimental model was made according to the circuit
diagram and the results were as expected. The submersible pump doesn't
start until water reaches a certain level in the underground tank, the
pump switched ON when the overhead tank was about to go quarter
level and switched OFF when the overhead tank is full. Since the pump
is not running when the underground tank is empty or the water level is
low and operated only in the case of the water reaching the sensor level
in the underground tank that leads to a lack of the dry running for the
pump thus avoiding the pump self heating, increasing its operating life.
And also the pump turned off when the overhead tank is filled or the
arrival of the water level in the overhead tank to the upper sensor, this
limiting the amount of water flowing from the reservoir after it is full
and provides amount of the power that had previously been wasted
because of the operation of the pump after the fullness of the overhead
28
tank, As long as the microcontroller operation is to process of the run
and stop the pump without the human intervention that reduces safety
risks, as well as the effort to process operation and monitoring.
5.2 Recommendations
1. The use of wireless sensors or sensor is suitable for operation of
centrifugal pumps.
2. The use of PLC
29
REFERANCES
1. Roland S. Burns (2001). Advanced Control Engineering,
Butterworth-Heinemann , Oxford, ISBN: 0750651008.
2. P. N. Paraskevopoulos(2002). Modern Control Engineering,
Marcel Dekker AG, Basel, ISBN: 0-8247-8981-4.
3. S. M. Khaled Reza, Shah Ahsanuzzaman Md Tariq, and S.M.
Mohsin Reza (2010). Microcontroller Based Automated Water
Level Sensing and Controlling, Design and Implementation Issue,
Proceedings of the World Congress on Engineering and Computer
Science, Vol 1, pp.1-7.
4. Sanjay M Gulhane, Nilesh R Patel, and Waheed M Khan (2015)
. Design and Implementation of Multi Tank Monitoring Based On
Low-Pow System Control er ZIGBEE and AVR for Automatic
Water, Special Issue of International Journal of Electronics,
Communication & Soft Computing Science and Engineering,
ISSN: 2277-9477.
5. Muktha Shankari, Jyothi K, Manu E , Naveen I P, and Harsha
Herle (April 2013). Wireless Automatic Water Level Control
using Radio Frequency Communication, International Journal of
Advanced Research in Electrical, Electronics and Instrumentation
Engineering Vol. 2, Issue 4, (Print) : 2320 – 3765 ISSN (Online):
2278 – 8875.
6. Katsuhiko Ogata (2010). Modern Control Engineering Fifth
Edition, Prentice Hall, New York, ISBN 13: 978-0-13-615673-4.
7. David G. Alciatore, Michael B. Histand (2012). Introduction To
Mechtranics And Measurement And Systems Four Edition,
McGraw-Hill, New York, ISBN 978-0-07-338023-0.
21
8. Manas Kumar Parai, Banasree Das, and Gautam Das, January
(2013). An Overview of Microcontroller Unit: From Proper
Selection to Specific Application, International Journal of Soft
Computing
and
Engineering,
Volume-2,
Issue-6,
ISSN: 2231-2307.
9. Atmega16 microcontroller data sheet
10. D.S. Yadav ,Arun Kumar Singh (2004). Microcontroller Features
and Applications, New Age, New Delhi, ISBN: 81-224-1569-5.
11. Jacob Fraden (2004). Hand Book of Modern Sensors Third
Edition, Springer -Verlag, New York, ISBN 0-387-00750-4.
12. ULN2003A driver data sheet.
13. Relay 5V data sheet.
21
Appendix (1)
The pump control system programme steps
$regfile = "m16def.dat"
$crystal = 8000000
Config Pina.1 = Input
'DANGER LEVEL
Config Pina.2 = Input
Config Pina.3 = Input
Config Portc.0 = Output
'green
Config Portc.1 = Output
'yellow
Config Portc.2 = Output
'red
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portd.3 , Db5 = Portd.4 , Db6 = Portd.5 ,
Db7 = Portd.6 , E = Portd.2 , Rs = Portd.1
Config Portb.2 = Output
'relay
Config Portb.3 = Output
'buzzer
Cls
Cursor Off
Locate 1 , 1
Lcd "PUMP CONTROL ..."
Wait 2
Cls
Portc.0 = 1
Portc.1 = 1
Portc.2 = 1
Wait 1
Portc.0 = 0
Portc.1 = 0
Portc.2 = 0
Do
22