You are on page 1of 30

Microcontroller based fluid level monitoring system

INTRODUCTION

Microcontroller based fluid level controller is a device designed for


maintaining fluid at the required level, which IN TURN SWITCH off OR
switch on the motor used to pump the liquid depending on the different
conditions.

In this monitoring system sensors are used to sense the level of the
liquid. The whole operation is programmed using PIC 16C72
Microcontroller. Which activates and deactivates the mechanical device
called RELAY. In turn controls the motor/pump. The controller has got
both the Audio and Visual indication. LEDs are used for Visual indication
and Buzzer is used for the Audio indication. We have named the circuit of
our project as LIQUICON. This performs the function of controlling the
flow of the liquid both at sub-tank and the main tank.

Liquicon:

Liqui Main task


Con

Motor
M

Sub-tank

IASE University, Rajasthan 1


Microcontroller based fluid level monitoring system

The sensors are fixed both at sub-tank and main-tank liquid levels and
maintain the required level. Whenever the level at the main-tank goes low
the liquid needs to be pumped in using sump motor M and M needs to be put-
off when the level reaches high.

• In the same way whenever these is no liquid in the sub-tank the motor
should not switch, to avoid dry run.
• Whenever there is blockage or breakage in the pipeline, the liquid does
not reach the main-tank ad the sump motor should be OFF
• High/low cut-off; Generally acceptable voltage range is 170V-230V if
the input voltage is beyond this range we have to stop the supply to the
sump motor.
BLOCK DIAGRAM
Switch
Input Step-down Control ON/switch
0-230V transformer circuit OFF the
pump

Pre- AC
conditions 240V

High- Control circuit:


Level
sensor
Signal Relay
conditioner ADC PIC micro
contoller

Low-
Level Motor&
sensor Pump

IASE University, Rajasthan 2


Microcontroller based fluid level monitoring system

The above Block diagram represents the control circuit for the Fluid
level Controller. The fluid level in the container is sensed initially by two
kinds of sensors i.e., High level and Low level sensors. The output of the
sensors is driven to Analog to Digital converter through the Signal
conditioner. Then the digital output is controlled by the controller and fed to
the output driver. When the fluid level reaches the maximum preset level,
the pump will switch off. If the input voltage is beyond the range of 170V—
240V, do not activate the relay, in turn the pump.

IASE University, Rajasthan 3


Microcontroller based fluid level monitoring system

PIC Microcontroller

The term PIC –Peripheral Interface Controller has been coined by Microchip
technology to identify its single chip microcontrollers. These devices have
been phenomenally successful in the market place.

Core Features:

* High-Performance RISC CPU


* Only 35 single word Instructions
* Operating Speed : DC -20 MHZ clock input
DC -200 ns instruction cycle
* 2K x 14 words of program memory, 128 x 8 Bytes of data memory
(RAM)

* Interrupt Capability
* Direct, Indirect and Relative Addressing modes
* Power –on-Reset (POR)
* Power-up Timer (PWRT)
* Oscillator Start –up Timer (OST)
* Watchdog Timer (WDT)
* Low power, high speed CMOS Technology
* Wide operating voltage range 2.5V to 6.0V

IASE University, Rajasthan 4


Microcontroller based fluid level monitoring system

Peripheral Features:

* Timer 0: 8 –bit Timer or Counter with 8-bit prescaler


* Timer 1: 16 –bit Timer or Counter with prescaler
* Timer 2. 8 –bit Timer or Counter with 8-bit period register,
Prescaler and postscaler.
* Capture, Compare, PWM (CCP) MODULE
 Capture is 16-bit, maximum resolution is 12.5 ns.
 Capture is 16-bit, maximum resolution is 200 ns.
 PWM maximum resolution is 10-bit

* 8 –bit 5-channel analog –to-digital converter


* Brown-out detection circuitry for Brown-Out Reset (BOR)

IASE University, Rajasthan 5


Microcontroller based fluid level monitoring system

Pin Configuration of PIC 16C72

MCLR RB7
1 28

2 27

3 26
P

4 I 25

5 C 24

1
6 23
6
7 22
C
8 21
7 20
9 2

10 19

11 18

17
12

13 16

14 15

IASE University, Rajasthan 6


Microcontroller based fluid level monitoring system

The PIC Microcontroller provides three timers namely timer 0, timer 1


and timer 2
The timer 0 module timer/counter has the following features:
* 8 bit timer/counter
* Readable and writable
* Internal or external clock select
* 8 – bit software programmable prescaler
* Interrupt on overflow from FFh to 00h.

The Timer 1 module timer/counter has the following features :


* 16-bit timer/counter
* (Two 8 –bit registers: TMR 1H and TMRIL)
* Readable and writable (Both registers)
* Internal or external clock select.
* Interrupt on overflow from FFFFh to 0000h.

The timer 2 module timer//counter has the following features :


* 8-bit timer
(TMR 2 register)
* 8-Bit period register (PR2)
* Readable and writable (Both registers)
* Software programmable prescaler
* Software programmable prescaler
* Interrupt on TMR 2 match of PR2

IASE University, Rajasthan 7


Microcontroller based fluid level monitoring system

CIRCUIT DESCRIPTION

The Fluid level monitoring system centers on the programmable PIC


Microcontroller 16C72. This system also consists of sensors to sense the
level of the fluid, Analog to Digital Converter, Output driver (RELAY) and
LED’s for indication.

Power Supply:
In our project we require different power supply voltages like + 5V
and unregulated 12V dc. +dc.+5V is applied to the 1st and 20th pins of the
Microcontroller. Unregulated 12V dc is used to energize the relay coil.

A regulator converts varying input voltage and produces a constant


“regulated” output voltage. A voltage regulator has only three legs and
appears to be a comparatively simple device but it is actually very complex
integrated circuit. Regulators are available in a variety of outputs, typically
5V, 9V and 12V. the last two digits in the name indicate the output voltage.

The circuit to generate different voltages mentioned above is shown in


the following diagram.

IASE University, Rajasthan 8


Microcontroller based fluid level monitoring system

Circuit diagram:

The input voltage is applied to the step-down transformer, which is


used to reduce or step-down the mains AC supply voltage to a low value.
The transformer drops the 240V mains voltage to 12V. the diode ‘bridge’
rectifies the 12V AC from the output side of the power transformer into DC.
The capacitor C helps to maintain a constant input in to the regulator. The
capacitor C2 is used to suppress the additional ripple. The rectified voltage is
given to the regulator 7805 to get + 5V. the capacitor Celiminates any high
frequency pulses that could otherwise interfere with the operation of
regulator.

IASE University, Rajasthan 9


Microcontroller based fluid level monitoring system

Sensors:
Sensor is a device, which tells the information about its environment
by creating an electrical signal. In general Sensors are used to sense the
change in physical quantities such as heat, weight level, light, humidity,
sound level and liquid level etc depending on these it will give corresponding
voltage.

Any non-corrosive metals can be used as sensors in case of water. The


metals such as aluminum, stainless steel can also be used. We have to fix
three sensors at the sub-tank and four sensors at the main tank. The sensors
at the sub-tank are fixed three levels LOW, HIGH and COMMON. For the
main tank, an additional sensor is used called DRYRUN.

In our project we consider the over head high OHHI as port A.

Consider OHLO and port B,


USHI as port C,
SULO as port D,
DRYOH as port E,
DRYSUMP as port F,
DRYRUN as port G

The sensors are fixed at the required levels both in the sub-tank and main
tank. Common point is connected to the power supply of 12V AC.

IASE University, Rajasthan 10


Microcontroller based fluid level monitoring system

We have tested for the water. As water is a pure conductor of


electricity, if water reaches a reserved level, the sensor circuit completes.
This in turn triggers the transistor T1 at the sensing points.

The remaining sensing circuits will works in the similar way as


explained above.

In case of other liquids, the Continuity sensors cannot be used. So we


can use the Magnetic float sensor as the liquids have high viscosity. A
unique magnetically actuated switching design given superior performance.
The free swinging float attracts a magnet within the solid metal switch body,
actuating a snap switch by means of a simple lever arm.
The circuit is shown below, which is same for all the ports. To PIC
Circuit D1 T
Sensor Output
D2

═C

The sensors are fixed at the required levels in both the Sub-tank and
Main-tank. Sensed output is fed to the input of the above circuit. The
transistor switches the sensing points as high or low, according to the base
voltage.

IASE University, Rajasthan 11


Microcontroller based fluid level monitoring system

High/Low Cutoff voltage:

To switch off the pump/motor during the abnormal voltage condition,


LM 358 which is a low power dual operational amplifier is used. Generally
acceptable voltage range is 170V-230V. if the input voltage is beyond this
range, the circuit is helpful in stopping the supply to the motor.

LM 358 consists of two independent, high gain, internally frequency


compensated which were designed specifically to operator from a single
power supply over a wide range of voltages. In our case +5V Power is
supplied to LM 358

Out of two op-amps U1 and U2, U1 is used for sensing the low voltage
and the other one U2 is used for sensing the high voltage conditions.

The reference voltage is fed from the anode point of led (ldl) and the
unregulated voltage is tapped from the point after the rectification and
filtering. This voltage is fed to the pin numbers 5 and 3 of U1 and U2. this
will be treated as reference voltage for the comparators pin numbers 2 and 6
are fed through mid point of the potential divider circuit. Whenever the
voltage at pin number 2 or at the pin number 7 goes high it will in turn switch
on the LED (ld2), also to the Microcontroller Pin number 7 indicating that
there is an error in the input voltage.

IASE University, Rajasthan 12


Microcontroller based fluid level monitoring system

The input voltage to the transformer is set at 170V and at this


condition unregulated voltage will be low voltage and the preset pr1 is
adjusted such that pin number 6 of U2 reaches 5V.

In this condition, pin number 7 goes high and it will remain so. In this
same way the output is increased to 240V and present pr2 is varied till the
voltage at pin number 2 reaches 5V. Then the output of U1 i.e., pin number
1 goes high.

It is generally mentioned as Error. LED ld2 is provided to indicate this


error.The high voltage at pin number 7 will deactivates the whole circuit
irrespective of all the conditions by switching OFF the sump motor or the
alternate pump.

CIRCUIT:

IASE University, Rajasthan 13


Microcontroller based fluid level monitoring system

1 8

2 7
+

+++

+
-
3
L
M
3
4 5
8 6
5

+
-

Fig: Pin connections of LM 358

1- Output
2- Inverting input 1
3- Non- Inverting input 1

4- Vcc
5- Non-Inverting input 2
6- Inverting input 2
7- Output 2
8- Vcc

IASE University, Rajasthan 14


Microcontroller based fluid level monitoring system

RELAYS:

The voltage from the PIC Microcontrollers is in the range of 5V


which cannot drive the Relay circuit. The output driver amplifies this
voltage to a required voltage to Turn ON the Relay in turn MOTOR.
A Relay is an electrically operated switch. Current flowing through
the coil of t he relay creates a magnetic field which attracts a lever and
changes the switch contacts.
The Relay switch connections are usually labeled as COM, NC and
No.
NO

Coil COM

NC

Fig: Circuit symbol for a relay

• COM-Common, always connect to this, it is the moving part of the


switch.
• NC-Normally Closed, COM is connected to this when the relay coil if
OFF
• No-Normally Open, COM is connected to this when the relay coil is
ON.

IASE University, Rajasthan 15


Microcontroller based fluid level monitoring system

Circuit diagram:

In our project we used two relays; rly1 is to turn ON/OFF the motor of
the sump. Another relay rly2 is to switch ON/OFF the alternate Motor.
These relays are connected at pin number 16 and 17 respectively.

`The voltage from the microcontroller is in the range of 5V. so the


transistor Tr is used to amplify the voltage and which is given to the Relay.

When the transistor Tr is in OFF state, there is no voltage in the circuit.


In this position the relay coil will not energize and the relay contact will stay
in off condition. At this position Common terminal is in touch with the
Normally Connected terminal.

IASE University, Rajasthan 16


Microcontroller based fluid level monitoring system

When the transistor Tr is in ON state, the voltage will energized the coil
and the Common terminal comes into contact with the Normally Opened
terminal. This will activate the relay rly1, which is turn switch ON the motor
M1.
In the relay, a diode D15 is connected across the relay coil, which is used
to protect the transistors and IC2 (chips) from the brief high voltage ‘spike’

Indications:

LED: (Light Emitting Diode):


LED is a semi conductor device that emits incoherent narrow spectrum
light when electrically biased in forward direction of PN junction. LED has
very little resistance, so large amount of current will try to flow through it.
So a resistor with an LED is used to limit the current.
LED will light up very quickly. It is very small and it can be easily
populated onto the PCB.

Buzzer:
We can also use buzzers with different beep routines for indication of
different levels of fluid both at sub tank and main tank.

IASE University, Rajasthan 17


Microcontroller based fluid level monitoring system

IASE University, Rajasthan 18


Microcontroller based fluid level monitoring system

Fig: power supply circuit

IASE University, Rajasthan 19


Microcontroller based fluid level monitoring system

The major component used in our project is PIC microcontroller,


which controls the motors as per the requirements.

The pin number 12 is provided with a micro switch to select the mode
of working such as open loop and closed loop. Open loop is considered as
the mode A and the closed loop is considered as the Mode B.

In every mode of working, we have to check the supply voltage


repeatedly. The normal range of voltage is 170V-240V. If the voltage
reaches beyond this range then pin number 7 is activated. This in turn switch
of the all motors related to it.

The ports A, B, C, D, E, F and G are taken as the sensing points to sense the
levels in the overhead, sump and for dry run case of the liquid.

In the case of open loop, we consider only the sub-tank as the source
of the liquid. Here the three inputs sump high, sump low and overhead low
at ports, C,D and B respectively are triggered as per the transistor action.

If the liquid at the sump is sufficient, then ld6 and ld7 will be in ON
state. If the liquid at the over head tank is not sufficient, this is indicated by
the ld4. then liquid flow has to be taken place from sump to over head tank.
So the sump relay rly1 is activated. This is turn switch on the sump motor
which will remain in the ON state until the dry run at the port G is detected.
This case is indicated by the ld7.

IASE University, Rajasthan 20


Microcontroller based fluid level monitoring system

In this condition, the sump relay gets deactivated if the liquid does not
reach the over head tank within the specified time. The reasons fro dry run
may be any kind of breakage or the blockage in the pipe connecting the sump
and overhead tank.

As the liquid at the sump is motored to the overhead tank, it gets filled.
When the liquid level at this tank reaches a high level, is sensed by the sensor
provided at the port A. this will turn ON the ld3. then the sump relay is
deactivated and this in turn switches OFF the sump motor.

When the liquid at the sub-tank is not sufficient then the mode B
comes into picture. Here an alternate source of liquid is considered along
with the sub-tank. This can be done by pressing he mode switch provided to
change the mode.

If the liquid at the sub-tank is sufficient and at the overhead tank is not
sufficient then liquid flows from sub-tank to the overhead tank if there is no
dry run and the power supply is in the normal range.

The sump motor will turn off when the liquid at the main tank reaches
the reserved level. When the liquid at the sub-tank is not sufficient then we
have to switch for the alternate source of the liquid.

The alternate source of liquid is needed only when the sump becomes
dry or the liquid in the sub-tank goes below the low level. In this case the ld6
will be in the ON state.

IASE University, Rajasthan 21


Microcontroller based fluid level monitoring system

When this stage is reached, the alternate relay rly2 is activated and it
has to wait for some time to check whether the liquid is flowing or not. It is
sensed at the SUMP DRY fixed at sub-tank. If these is no flow of liquid,
after waiting for some time, the sump motor will get switched OFF.

When there is a flow of liquid, SUMP DRY sensor sense it and


automatically activates the alternate relay in turn the motor. Then the
alternate relay waits for some time. This is the time required for the liquid to
reach the high level at the sub-tank. Then the high level is reached, the
alternate pump will be in switched OFF state.

Once the sub-tank is filled, the mode of operation is same as that of the
mode A.

Auto/Manual switch:

A switch by name auto/manual is provided at the pin number 11.

In case of any breakdown in the complete circuit function, then this


particular switch is used. Since the power to the motor is routed through the
relays, they do not get activated if any power breakdown occurs. So there is
no chance of pumping the liquid to the main tank. At this time, the power
routed through the relays should be disconnected manually and connected to
the motor directrly which involves manual interactions and skilled
technicians.

IASE University, Rajasthan 22


Microcontroller based fluid level monitoring system

To avoid this case, an auto/manual switch is provided. By pressing


this switch and holding it for few seconds, this is indicated by the ld8. then
the complete control circuit gets by passed and the supply is directly
connected to the motor. Thus motor starts working normally. In this
condition, the user should put off the motor again after the use, manually.

Reset switch:

A reset switch is provided at the pin number 21, to deactivate the


whole circuitry in case of any problems with the motor.

Mode switch:

A mode switch is provided at the pin number 12, to switch on the


alternate source of the liquid. In case of the liquid insufficiency in the sub-
tank, by pressing this switch the normal work continues in mode B.

IASE University, Rajasthan 23


Microcontroller based fluid level monitoring system

ALGORITHM

i. The input power supply voltage should be checked once. If the input
Voltage is beyond the range of 170V-240V, relay should be inactivated
In turn it switches of the sump motor.

ii. Liquid at the sub-tank is sufficient and if the liquid at the main-tank is
Not sufficient, i.e., fluid level goes below a reserve level then the sump
Relay is activated and the sump motor will be switched ON.

iii. If the liquid does not reach the outlet at the main-tank within the
Specified time, then sump motor will remains in the switch OFF state.

iv. When the liquid reaches the maximum preset level in the main-tank,
Then the sump motor will switch OFF automatically.

v. If the liquid at the sub-tank is not sufficient then the alternate source is
Considered.

vi. If the liquid at the main-tank is not sufficient then the alternate motor is
. switched ON to fill the sub-tank. Then the sump motor the fluid flows
to the main-tank.

vii. If the liquid at the sub-tank reaches the reserved level then the motor
is switched OFF automatically.

IASE University, Rajasthan 24


Microcontroller based fluid level monitoring system

FLOWCHART

START

Voltage
Within the NO
Range170V
-240V

YES

Liquid at
Overhead
Tank is B
YES sufficient NO

Switch ON the
Motor M1
YES
NO
C

IASE University, Rajasthan 25


Microcontroller based fluid level monitoring system

Dry run YES


Detect
NO

Liquid flows until it


Reaches the high
level at the main tank
A

Switch OFF the


Motor M1

END

Alternate source of liquid

Voltage
Within the
Range
170V-
240V
E
NO
YES
gege

IASE University, Rajasthan 26


D
Microcontroller based fluid level monitoring system

Switch ON the motor


M2

Dry YES
run
Detect

NO

Liquid flows until it reaches


High level at the sub-tank

E
Switch OFF the motor
M2

IASE University, Rajasthan 27


Microcontroller based fluid level monitoring system

SIGNIFICANCE

In case of the apartments, hospitals, high-rise buildings, where the


overhead tank is situated at the highest point of the buildings, monitoring the
level at the overhead tank becomes very difficult. So it can be easily
monitored by the Microcontroller based fluid level controller.

And also in the case of Chemicals and Petroleum Products, which can
be automatically maintained at the main tank depending on the requirements.

SCOPE OF THE PROJECT

Some of the special features can be implemented to this project. They


are:

• Evening start
• Start delta
• Any fluid level can be monitored. Depending on the fluid, the sensors
are chosen. For example, to monitor the level of petroleum products
like petrol, diesel or kerosene, we can use magnetic float switches to
sense the fluid level.

IASE University, Rajasthan 28


Microcontroller based fluid level monitoring system

• Wireless sensors can also be implemented. These sensors work in the


radio frequencies.

System Requirements:
PIC 16C72 Microcontroller
System Frequency:-4MHz
Memory: - 2KB

Resistors
R = 4.7K ohms
R0 = 10K ohms
R1 = 1K ohms
R2 = 8.2K ohms
R3 = 1K ohms
R4 = 330 ohms

Presets
pr1 = pr2 = 2K ohms

Capacitors
C = 0.1 Micro Farads
C0 = 5.6 Pico Farads (crystal)
C1 = 4.7 Micro Farads (relays)
C2 = 0.1 Micro Farads

Diodes
D1 = D2 = 4148

IASE University, Rajasthan 29


Microcontroller based fluid level monitoring system

D = 4148
Transistors
T = 2N2222
Tr = SL100

BIBILOGRAPHY

1. Design with PIC Microcontrollers


• John B. Peatman
2. www.microchip.com

IASE University, Rajasthan 30

You might also like