Sunteți pe pagina 1din 32

Chapter 5

Flow Measurement and Control System

5.1 Introduction
The industrial application of flow rate measurement and control is very important
and essential especially in petroleum refineries, pharmaceutical and chemical
process industries. Flow control is very important in medical appliances also. For
maintaining the saline and blood flow rate is play a very crucial role in hospitals. In
pharmaceutical and chemical process industries also the flow rate maintenance is
essential for perfectness of medicine composition [1]. The flow rate is measured and
control is developed by implementing software programming FPID.

The performance of flow meters is also influenced by a dimensionless unit called the
Reynolds Number. It is defined as the ratio of the liquid's inertial forces to its drag
forces. The Reynolds number is used for determined whether a flow is laminar or
turbulent. Laminar flow within pipes will occur when the Reynolds number is below
the critical Reynolds number of 2300 and turbulent flow when it is above 2300[2][3].
The value of 2300 has been determined experimentally and a certain range around
this value is considered the transition region between laminar and turbulent flow.

Where
ѵs = Mean Fluid Velocity,
η - (Absolute) Dynamic fluid Viscosity
v = Kinematics Fluid Viscosity (ν = η/ρ)
ρ = Fluid Density
L = Characteristic Length (Equal to diameter, 2r if a Cross Section is Circular)

1
Basic Requirements for Flow Measurement

Ability to Calibrate
Ability to Integrate Flow Fluctuation
Easy Integration with Piping System
High Accuracy
High Turn-Down Ratio
Low Cost
Low Sensitivity to Dirt Particles
Low Pressure Loss
No Moving Parts
Resistant to Corrosion and Erosion

Figure 5.1(a) Types of flow

Definition of Quantities to be measured Volume Flow Rate


The definition of volume flow rate is the volume of fluid that flows past a given cross
sectional area per second. Therefore,

Where V = Volume Flow Rate,


A = Cross Section Area and Ѵ = Velocity of Fluid

Standard SI Unit is m3/hr and Other Common Units are


• 1L/s = 103 cm3/s = 10-3 m3/s
• 1gal/s = 3.788 L/s = 0.003788 m3/s
• 1cf/min = 4.719x10-4 m3/s

2
The definition of mass flow rate is the number of kilograms of mass flow that flows
past a given cross sectional area per second. Therefore,

where m = Mass Flow Rate


ρ = Specific Density
V = Volume Flow Rate
A = Cross Section Area
Ѵ = Velocity of Fluid
Standard SI Unit is kg/hr

5.2 Methods of Flow measurement

Direct Flow rate Measurement


Direct Flow rate Measurement required large device if the volume rates are high.
And in case a smaller device is used then the measured values will not be accurate
[5]. Fluctuations in the measuring values due to the opening/closing of valves during
start/stop of the measurements. Devices that measure the volume/mass of the fluid
and the timing may not be concurrent.

Figure 5.1(b) Direct Flow rate Measurement

Indirect Flow rate Measurement


For many practical applications, indirect measuring techniques are employed using
various kinds of principles. There are some of the basic working principles:
• Differential Pressure
• Force on Bodies in the Flow
• Heat Transfer
• Coriolis Force

3
• Magneto-Inductive
• Frequency of Vortices
• Ultrasonic

Type of Flow meters


1) Orifices ,Flow Nozzles, Venturi Tube
2) Thermal Dispersion
3) Electro-Magnetic type
4) Corriolis
5) Positive Displacement type
6) Vortex
7) Turbine
8) Ultrasonic

Figure 5.1(c) Usage of Flow meter in Industries

5.2.1 Orifice, Nozzle & Venturi based on “Differential Pressure” principle

Figure 5.1(d): Differential Pressure


The Orifice, Nozzle & Venturi flow meters use the Bernoulli’s Equation to calculate by
using the pressure difference between an obstruction in the flow.

4
Figure 5.1(e): Differential Pressure
5.2.2 Thermal Dispersion

Thermal Dispersion flow meters generally use combinations of heated elements and
temperature sensors to measure the difference between static and flowing heat
transfer to a fluid and infer its flow with knowledge of the fluid's specific heat and
density. The fluid temperature is also measured and compensated for. If the density
and specific heat characteristics of the fluid are constant, the meter can provide a
direct mass flow readout, and does not need any additional pressure temperature
compensation over their specified range.

Figure 5.1(f): Thermal Dispersion

Figure 5.1(g): Thermal Dispersion

5.2.3 Electromagnetic type

The operation of magnetic flow meters is based on Faraday's law of electromagnetic


induction. Magnetic flow meters can detect the flow of conductive fluids only. The

5
magnetic flow meter’s coil can be powered by either alternating or direct current. In
AC excitation, line voltage is applied to the magnetic coils and as a result, the flow
signal (at constant flow) will also look like a sine wave[6]. The amplitude of the wave
is proportional to velocity. In addition to the flow signal, noise voltages can be
induced in the electrode loop. Out-of-phase noise is easily filtered, but in-phase
noise requires that the flow be stopped (with the pipe full) and the transmitter
output set to zero. The main problem with ac magflow meter designs is that noise
can vary with process conditions and frequent re-zeroing is required to maintain
accuracy. And as for DC excitation designs, a low frequency (7-30 Hz) dc pulse is used
to excite the magnetic coils. When the coils are pulsed on the transmitter reads both
the flow and noise signals. In between pulses, the transmitter sees only the noise
signal. Therefore, the noise can be continuously eliminated after each cycle.

Figure 5.1(h): Electromagnetic type


5.2.4 Coriolis type
The principle of angular momentum can be best described by Newton’s 2nd Law of
angular motion. Using the Coriolis effect that causes a laterally vibrating tube to
distort, a direct measurement of mass flow can be obtained in a coriolis flow meter.
Furthermore, a direct measure of the density of the fluid is obtained. Coriolis
measurement can be very accurate irrespective of the type of gas or liquid that is
measured; the same measurement tube can be used for hydrogen gas and bitumen
without recalibration.

6
Figure 5.1(i): Corriolis type

5.2.5 Positive Displacement type

Positive displacement meters provide high accuracy, ±0.1% of actual flow rate in
some cases and good repeatability as high as 0.05% of reading. Accuracy is not
affected by pulsating flow unless it entrains air or gas in the fluid. PD meters do not
require a power supply for their operation and do not require straight upstream and
downstream pipe runs for their installation [7]. Typically, PD meters are available 1”
up to 12” in size and can operate with turndowns as high as 100:1, although ranges
of 15:1 or lower are much more common. Slippage in the flow meter is reduced and
metering accuracy is therefore increased as the viscosity of the process fluid
increases. The process fluid must be clean. Particles greater than 100 microns in size
must be removed by filtering. PD meters operate with small clearances between
their precision-machined parts; wear rapidly destroys their accuracy. For this
reason, PD meters are generally not recommended for measuring slurries or abrasive
fluids. In clean fluid services, however, their precision and wide range ability make
them ideal for custody transfer and batch charging. They are most widely used as
household water meters. In industrial and petrochemical applications, PD meters are
commonly used for batch charging of both liquids and gases.

Figure 5.1(j): Positive Displacement type


7
5.2.6 Vortex type

Figure 5.1(k): Vortex type

Vortex shedding frequency is directly proportional to the velocity of the fluid in the
pipe and therefore to volumetric flow rate[]8[9]. The shedding frequency is
independent of fluid properties such as density, viscosity, conductivity, etc., except
that the flow must be turbulent for vortex shedding to occur.

Types of Working Principles


1. Vortex Shedding
2. Vortex Precession
3. Fluidic Oscillation (Coanda Effect)

Figure 5.1(l): Vortex Shedding

Figure 5.1(m): Vortex Precession type

8
Figure 5.1(n): Fluidic Oscillation (Coanda Effect) type

5.2.7 Ultrasonic type


Ultrasonic waves travel in the same manner as light or microwaves however being an
Elastic waves, they can propagates through any substance like solid, liquid and
gases[10]. And by utilizing the properties of ultrasonic waves, clamp on flow meters
with unique feature of being able to measure fluid flow in the pipe externally was
developed.
Generally, ultrasonic flowmeters works in 2 different kind of principles:
1) Doppler Effect Ultrasonic Flowmeter
The Doppler Effect Ultrasonic Flowmeter uses reflected ultrasonic sound to
measure the fluid velocity. By measuring the frequency shift between the ultrasonic
frequency source, the receiver and the fluid carrier. In this the relative motion are
measured. The resulting frequency shift is named the ”Doppler Effect”.
2) Transit Time Difference Ultrasonic Flowmeter
With the Time of Flight Ultrasonic Flowmeter the time for the sound to travel
between a transmitter and a receiver is measured. This method is not dependable on
the particles in the fluid.

Figure 5.1(o): Ultrasonic type

9
5.2.8 Turbine type

Reluctance
The coil is a permanent magnet and the turbine blades are made of a material
attracted to magnets[11]. As each blade passes the coil, a voltage is generated in the
coil. Each pulse represents a discrete volume of liquid. The number of pulses per
unit volume is called the meter's K-factor.
Inductance
A permanent magnet is embedded in the rotor, or the blades of the rotor are made
of permanently magnetized material. As each blade passes the coil, it generates a
voltage pulse. In some designs, only one blade is magnetic and the pulse represents
a complete revolution of the rotor.
Capacitive
Capacitive sensors produce a sine wave by generating an RF signal that is amplitude-
modulated by the movement of the rotor blades.
Hall-Effect
Hall-effect transistors also can be used. These transistors change their state when
they are in the presence of a very low strength (on the order of 25 gauss) magnetic
field.

Figure 5.1(p): Turbine type


The aim of the flow control is to control the flow rate and level of the tank in a
system up to delimitated value, afterward hold this it at that level and flow rate of
liquid of pipe in insured manner. Fuzzy with PID controller (FPID) is the best way in
which this type of control can be accomplished by controller. Here we have
developed flow control system using FPID. The desired response of the output can
be guaranteed by the feedback controller.

10
5.3 Hardware Development

The total system can be developed by implementing software FPID; mainly it reduces
the hardware complexity. In this system, set point of the flow is given by the
programmer using GUI. YF-S201 flow sensor sense the liquid flow rate of pipe which
controls the total system using Arduino mega2560 microcontroller.

The flow measurement and control system is developed by using flow sensor,the
output of sensor which is in the form of pulses is given to the Arduino Mega2560
microcontroller implementing FPID logic the PWM of the controller is given the
signal to DC water pumping motor through ULN2003 current driver. The hardware
system consists of different units and explanation for each unit is given in detail.
They are

1. YF-S201 Flow sensor


2. Arduino MEGA2560 Microcontroller
3. ULN 2003 Relay driver
4. DC motor
5. Personal computer as display unit

Figure 5.2: Block diagram of embedded based flow measurement and control

11
12
Figure 5.3: Schematic diagrams of Flow rate measurement and control

Figure 5.4: Photograph of total setup for flow control

13
5.3.1 YF-S201 Hall Effect Water Flow Meter / Sensor

This YF-S201 Hall Effect Water Flow sensor placed in line with the water line and
contains any simple level sensor to measure how much liquid has pumped through
it. There is an integrated magnetic Hall Effect sensor that outputs an electrical pulse
with every revolution. The Hall Effect sensor is sealed from the water pipe and allows
the sensor to stay safe and dry. The sensor comes with three wires: red (5-24VDC
power), black (ground) and yellow (Hall Effect pulse output). By counting the pulses
from the output of the sensor can easily calculate water flow[12].

YF-S201 Water Flow Sensor can be used to measure the flow of liquids in both
industrial and domestic applications. This sensor basically consists of a plastic valve
body, a rotor and a Hall Effect sensor. The pinwheel rotor rotates when liquid flows
through the valve and its speed will be directly proportional to the flow rate.

Specifications

• Working Voltage: 5 to 18V DC (min tested working voltage 4.5V)


• Max current draw: 15mA @ 5V
• Output Type: 5V TTL
• Working Flow Rate: 1 to 30 Liters/Minute
• Working Temperature range: -25 to +80℃
• Working Humidity Range: 35%-80% RH
• Accuracy: ±10%

Figure 5.5(a): YF-S201 Hall Effect Flow Sensor

Figure 5.5(b): Connection for YF-S201 Flow Sensor

14
Hall-effect transistors change their state when they are in the presence of a very low
strength (on the order of 25 gauss) magnetic field. By counting the pulses from the
output of the sensor can be easily calculate water flow. Each pulse gives
approximately in milliliters and the pulse rate does vary a bit depending on the flow
rate, fluid pressure and sensor orientation. It will need careful calibration if better
than 10% precision is required.YF-S201 Water Flow Sensor can be used to measure
the liquid flow in both industrial and domestic applications. This sensor basically
consists of a plastic valve body, a rotor, a Hall Effect sensor, inlet and outlet. The
pinwheel rotor rotates when water or liquid flows through the valve and the speed
of sensor will be directly proportional to the flow rate. The Hall Effect sensor will
provide an electrical pulse with every revolution of the pinwheel rotor. The rate of
water flow will be directly proportional to the number of pulses counted [15]. The
pulse signal is a simple square wave so it’s quite easy to log and convert into liters
per minute using the following formula.

5.3.2 Arduino Mega2560 microcontroller

It is the heart of the module of the entire system. It is controlled total parameter
value and provides a communication between client and server by interfacing this to
the PC. The YF-S201 water flow sensor module can be easily interfaced with Arduino
Mega2560 microcontroller Connect the PWM output of this module to interrupt pin
of microcontroller unit and count the number of pulses or interrupt per unit time.
The rate of water flow will be directly proportional to the number of pulses counted.
Based on the pulses, derive an expression for flow rate in milliliter (ml). The signal
which is connected to the PWM as an output signal which fed to DC pumping motor
which is attached to the flow sensor through the ULN 2003 driver.

5.3.3 DC MOTOR

A water pumping DC Motor which operates with +12V / 1Amp power supply for
pumping the liquid. It consists of one inlet and one outlet for maintaining the Flow

15
rate in a tank by pumping water. In this work the motor controlled by a controller line
of PWM which operates with +5V/+12V by using Fuzzy with PID software. The
application software for the present work developed through communication
interfacing with PC and USB .One advantage of it is, its operating voltage is +5V
same as controller.

5.3.4 ULN 2003 Relay Driver

The ULN2003A devices are high-voltage, high-current Darlington transistor arrays.


Each consists of seven NPN Darlington pairs that feature high-voltage outputs with
common-cathode clamp diodes for switching inductive loads. It has a 2.7-kΩseries
base resistor for each Darlington pair for operation directly with TTL or 5-V CMOS
devices. The controlled signal which is followed by PWM of microcontroller is given
to the input pin of the ULN 2003 driver. The output pin of it is connected to the
water pumping DC motor.

5.3.5 Personal Computer

The computer is the most important and integral part of the entire control system as
it plays a vital role in data acquisition, display, record, and generate graphs. The
predominant interfaces between personal computer and microcontroller are USB
and Ethernet. In this contest USB communication is implemented to transfer data to
and from controller to PC to display and store in database. Computer is loaded with
windows 2008 operating system, Arduino and Processing software.

For providing flexibility and storability GUI software has been developed in
Processing using java programming language, which will provide a graphical
visualization for the user to monitor the status of the signal and stores the data for
future study. In the present study industrial process parameters are measured,
controlled and displayed on GUI window. Select the Flow parameter from first GUI
window and then control the parameter through the set points using either
increment or decrement buttons.

16
5.4 software development

In the present research work, the software development of Fuzzy with PID control
logic can be developed and implemented by program using the embedded ‘C’ in
Arduino and the communication for controlling the process parameter Flow rate
through Internet of Things (IoT) using Java programming language for Processing
and analysis. The program developed in such a way that the GUI window includes
with set value, measured value, graph of time versus selected parameter value,
buttons which are used for setting the set value of the flow rate, slides, present time
and the photograph for total setup for selected Flow parameter.The first GUI
window by selecting the Flow parameter which to be control and then control the
parameter through IoT which includes two individual programs of server and client.
Depending on requirement of system the number of clients can be given
authenticate through ID for safety and security purpose. The clients control the
selected Flow parameter which sends the signal to server and then the data
transferred to microcontroller i.e., develop the communication between Arduino
and Processing through the port to control the set value of parameter.

The Constrained Application Protocol (CoAP) is used which employs based on the
User Datagram Protocol (UDP). The protocol CoAP was specifically developed to
allow resource-constrained devices to communicate over the Internet using UDP
instead of TCP. CoAP is particularly useful for communicating with low-power
sensors and devices that need to be controlled via the Internet. It uses the data in
binary form. CoAP packets use bit fields to maximize memory efficiency and makes
use of Datagram Transport Layer Security (DTLS) which is analogous to the TCP
version of TLS. The default level of encryption is equivalent to a 3072-bit RSA key.
The communication that develop transport the data with security by entering the IP
address of the server in the first GUI window which is displayed when the client is
executed and also the IP addresses of all the clients are stored and saved in server.
Client controlled the selected set value of the Flow rate with security implementing
software programming of FPID with Arduino and control the parameter value from
the client through IoT .The algorithm and flowchart is shown in figure 5.6.

17
Algorithm

Initialization of the microcontroller and Flow sensor


Count the number of pulses
Calculate the flow rate based on pulses
By using ULN 2003 through PWM driver controller control the motors for
pumping of the liquid for controlling the flow rate of the pipe.
If the flow rate is greater than or less than the set point, the DC motor
controlled by the PWM of microcontroller which is depending on the FPID
signal.
If flow rate reached set point the motor will be in stable state
Stop

Figure 5.6 Flowchart for Flow rate measurement and control using Hall Effect sensor
implemented with FPID control logic

18
Table 5.1 Matrix arrangement of flow

Flow in Low Medium High Very high

milliliter/sec

Low No Pumping Pumping IN Pumping IN Pumping IN

Medium Pumping OUT NO Pumping Pumping IN Pumping IN

High Pumping OUT Pumping OUT NO Pumping Pumping IN

Very high Pumping OUT Pumping OUT Pumping OUT No Pumping

Figure 5.7: Membership Functions for F (flow) = {Low, Medium, High, Very high}

Table 5.2 Input linguistic Variables

S.NO Crisp input range Fuzzy variable

(error=set value-measured value)

1 40 to 60 Low (L)

2 20 to40 Medium (M)

3 10 to 20 Veryhigh (VH)

4 0 to 10 High (H)

19
Table 5.3 Output linguistic Variables

S.NO Fuzzy variable range Corresponding Fuzzy variable


output interms of digital
data
Kp Ki Kd

1 200 to 255 High Medium Low Low (L)

2 120 to 200 Medium High Low Medium (M)

3 50 to 120 Medium Medium High Hhigh (H)

4 50 to 0 Low High High Very high (VH)

Defuzzification
The procedure of producing a output variable in fuzzy logic given rule set of fuzzy
and respective membership values can be described as term “Defuzzification”. It
requires basically fuzzy control matrix arrangement. It contains large number of
conditions which will convert the linguistic variables of a final result taken from the
fuzzy logic. To understand this, rule set of the fuzzy logic is to be determining how
much PWM drive can be applied to the motor.

Table 5.4 Deffuzification Implementing the FPID

S.NO Fuzzy variable range output Corresponding drive Fuzzy variable


interms of digital data
percentage

1 200 to 255 78.4% to 100% Low (L)

2 120 to 200 47% to 78.4% Medium (M)

3 50 to 120 39.2% to 47% High(H)

4 50 to 0 19.6% to 0% Veryhigh (VH)

Depending on the size of pumping pipe line which is placed in line with the flow
sensor, the number of electric pulses given by the sensor is varied. In this work, we
use the pipe line pumps the water or liquid 500ml of unit second. It means
approximately 10ml of liquid which moved through the sensor gives a single pulse as

20
output. By using software [4] Fuzzy with PID controller (FPID) the flow and level can
be controlled at a time. Fuzzification process, rule set of the variables and
defuzzification [5],[6] of flow control is same as which is applied to the level control
but the different units are used for individual specification. The PWM of controller
can be drive the pumping motor through ULN2003 driver.

Fuzzy Rule set


• If flow range is 40 to 60 ml/sec, the FPID 1 is applied i.e., the proportional
constants Kp,Ki ,Kd of set 1 will be executed in the program.
• If flow range is 20 to 40ml/sec, the FPID 2 is applied .i.e., the proportional
constants Kp,Ki ,Kd of set 2 will be executed in the program.
• If flow range is 10 to 20 ml/sec, the FPID 3 is applied .i.e., the proportional
constants Kp,Ki ,Kd of set 3 will be executed in the program.
• If flow range is 0 to 10 ml/sec, the FPID 4 is applied .i.e., the proportional
constants Kp,Ki ,Kd of set 4 will be executed in the program.

The total measurement and control system can be developed using Arduino and
processing software and the automation can be develop communication through
internet of things (IoT) by writing a program in processing software using java
programming language for server and client programs. The details of software are
presented in chapter 7.

21
Figure 5.8 Block diagram and circuit diagram of Flow measurement and control
through IoT

5.5 Results and Discussions

The results can be represented in the GUI window application using processing
software. GUI (a) shows the continuous maintenance of the fixed flow rate up to set
value of level is reached. GUI (b) shows the time response of flow rate implementing
FPID from 60ml to 5ml of flow rate successfully tested and controlled with an steady
state error of ± 1ml and the results includes with the different characteristics of Rise
time (RT), Settling time (ST), Controlled value (CV) by the system and Steady state
error (SSE) are presented in Table 5.5. Based on these characteristics is observed
that the performance of FPID control algorithm is the best from remaining
algorithms. The accuracy of the system is given by calculating average of the steady
state error.

22
GUI 5.1(a): Real time versus level at fixed flow rate 10ml/sec

GUI 5.1(b): Real time versus flow rate


Table 5.5 Comparison of different Characteristics
Set PID FUZZY FPID

Flow RT ST CV SSE RT ST CV SSE RT ST CV SSE

rate (sec) (sec) (ml) (ml) (sec) (sec) (ml) (ml) (sec) (sec) (ml) (ml)

(ml)

23
60 10 13 64 4 12 15 64 4 8 10 60 0

50 18 21 53 3 19 24 54 4 14 16 51 1

40 24 28 43 8 29 33 42 2 20 23 40 0

30 33 37 34 4 38 41 34 4 28 31 30 0

20 38 42 24 4 47 49 24 4 34 37 20 0

10 47 54 14 4 58 63 15 5 38 42 10 0

5 51 60 8 3 64 68 9 4 43 45 6 1

The present work is compared with the work of “Fuzzy Adaptive PID for Flow
Control System based on OPC” of R.Manjunathan and S.Janakiraman has published
in “IJCA Special Computational Issue Science on-New Dimensions & Perspectives” in
Chennai in India the flow controlled with overshoot using MATLAB.

5.6 Conclusion

The design of Fuzzy with PID flow controller with active rule selection mechanism.
The proposed system is tested in real time environment and the output
performances are evaluated. In this system which is key point to reduce the cost by
implementing software algorithm. We have successfully experiment this system in
lab and therefore proposed a web based flow monitoring and controlling network
with flexibility, further extension of this system is to control from any place via
internet even with different type of devices. This could have a substantial benefit
from this research work for efficient management of liquid flow.

24
Advantages

Reduce the hardware complexity


Easy-to-use
Easy setup and simple installation
High accuracy with flexibility
Increased system reliability
Improved the quality

Applications

Process industries
House hold appliances
Air conditioning
Petrochemical processing
Medical appliances

25
REFERENCES

[1] “Level Measurements Systems”. Omega Complete Flow and Level Measurement
Handbook and Encyclopedia Vo.29, Stanford, CT, Omega Engineering Inc, 1995.

[2] “Flow measurements”, Fuzi Technology September 2004.

[3] Furness, Richard A. (1989). Fluid flow measurement. Harlow: Longman in


association with the Institute of Measurement and Control. p. 21.
ISBN 0582031656.

[4] Holman, J. Alan (2001). Experimental methods for engineers. Boston: McGraw-
Hill. ISBN 978-0-07-366055-4.

[5] American Gas Association Report Number 3 and 7

[6] Arregui, Cabrera, Cobacho, Integrated Water Meter Management, p. 33

[7] Miller, Richard W. (1996). Flow Measurement Engineering Handbook (3rd ed.).
Mcgraw Hill. p. 6.16-6.18. ISBN 0070423660.

[8] Bean, Howard S., ed. (1971). Fluid Meters, Their Theory and Application (6th
ed.). New York: The American Society of Mechanical Engineers. pp. 77–78.

[9] Severn, Richard. "Environment Agency Field Test Report – TIENet 360
LaserFlow" (PDF). RS Hydro. RS Hydro-Environment Agency. Retrieved 3
August 2015.

[10] Drost, CJ (1978). "Vessel Diameter-Independent Volume Flow Measurements


Using Ultrasound". Proceedings of San Diego Biomedical Symposium 17: 299–
302.

[11] American Gas Association Report Number 9 and 11

26
[12] Adrian, R. J., editor (1993); Selected on Laser Doppler Velocimetry, S.P.I.E.
Milestone Series, ISBN 978-0-8194-1297-3.

[13] Roger C.Baker. Flow Measurement Handbook.Cambridge university press. ISBN


978-0-521-01765-7

[14] Arduino MEGA 2560 souce: "Arduino - ArduinoBoardMega2560". arduino.cc.

[15] Sea Model YF –S201 source : YF-S201 Datasheet

[16] Texas, Instruments. "ULN2003A Datasheet".

[17] R.Arulmozhiyal and K.Baskaran, “Implementation of Fuzzy PI Controller for


Speed Control of Induction Motor Using FPGA”, Journal of Power Electronics,
Vol.10, No.1, Jan 2010, pp.65-71

[18] FarhadAslam and GagandeepKaur, March 2011 "Comparative Analysis of


Conventional, P, PI, PID and Fuzzy Logic Controllers for the Efficient Control of
Concentration in CSTR", International Journal of Computer Applications, Vol.17,
No.6, pp.12-16.

[19] N.R Kolhare, P.R Thorat,(2013) “An Approach of Flow Measurement In Solar
Water Heater Using Turbine Flow Meter,” International Journal of Engineering
Research & Technology (IJERT), Vol. 2, pp. 1-4.

[20] Rodriguez,(1997) “Design and fabrication of a low cost water flow meter”, IEEE
International Conference on Solid-State Sensors and Actuators, Vol. 5, pp. 159-
162. Digital Object Identifier: 10.1109/SENSOR.1997.613607

27
/************************************/
//Develop the program for Flow control in Arduino software
//Using Embedded C
/******** declare the Constants***********/
/************************************/

long Counter = 0; // counter for the number of button presses

int State= 0; // current state of the button

int lastStatef= 0; // previous state of the button

float SensorValuef = 0, Watter_Flow_in_ml = 0,FlowConstant = 10;

int timef = 0,Ltimef = 0,Dtimef = 0;

int flowf = 0,Lflowf = 0,Dflowf = 0,setf=0;

/*****************************************/
/**************Declaration of PID constants**********/
/*************Initialize the Values to PID constants***********/
float Errorf[4] = {0, 0, 0, 0,};
//*************************************************************
/*************Initialize the Values to Propotionality constants***********/

float Kp[4] = { 24.6, 15.6, 2.6, 1.6};


//***************************************************************
/*************Initialize the Values to Integrity constants****************

float Ki[4] = {20.1, 0.24, 0.66};


//*****************************************************************
/*************Initialize the Values to Derivative constants***********/

float Kd[4] = {30.14, 0.24, 0.64, 0.89};


/***********************************************************/
/*****************Declare variable for fetching serial data******/

char data, info;

28
//******************************
// the setup routine runs once when you press reset
void setup(){

Setf = 5;

//******************************
// initialize serial communication at 9600 bits per second:
Serial.begin (9600);

//Declare the pins are used in output mode

pinMode(8, OUTPUT);}

// the loop routine runs over and over again forever


void loop(){

//******************************
// If Serial port data is availiable
if (Serial.available()) {

//******************************
//Serial port data assigned to the variable data
data = Serial.read();

info = data; }

if(info == '+') {

setl++;

info=' '; }

if(info == '-') {

setl--;

info=' '; }

SensorValuef = FlowSensor();

Watter_Flow_in_ml = SensorValuef*FlowConstant;

Serial.print("Watter Flow in ml is : ");

Serial.print(Watter_Flow_in_ml);

29
timef = millis()/1000;

Dtimef = abs(timef - Ltimef);

if(Dtimef > 0){

Dtimef = 0;

Ltimef = timef;

flowf = Watter_Flow_in_ml;

Dflowf = abs(flowf-Lflowf);

Lflowf = flowf;

Dflowf = 0;}

else{

Serial.print(" ");}

Errorf[Current] = Setf - Watter_Flow_in_ml;

// Calculate the present error


Error[Current] = SetPoint - level;
//PWM output is zero
Drive = 0; }
if (Error[Current] < 0) {
if (Error[Current] > 50) {
//PWM output is set based on PID constants of array[0]
fuzzy = 0; }
else if (Error[Current] >30 ) {
//******************************
//PWM output is set based on PID constants of array[1]
fuzzy = 1; }
else if (Error[Current] > 20) {
//******************************
//PWM output is set based on PID constants of array[2]
fuzzy = 2; }
else if (Error[Current] > 5)

30
{
//******************************
//PWM output is set based on PID constants of array[3]
fuzzy = 3;
}
//************************************************
//code for Fuzzy with PID control
//***********************************************
//Calculate Protionality of error
P = Error[Current] * Kp[fuzzy];
Error[Sum] = Error[Current] + Error[Last] + Error[SecondToLast];
//***********************************************
//Calculate Integrity of error
I = Error[Sum] * Ki[fuzzy];
Error[Delta] = Error[Current] - Error[Last];
//***********************************************
//Calculate Derivative of error
D = Error[Delta] * Kd[fuzzy];
//***********************************************
//Calculate the final output based on error
Drive = P + I + D;
Error[SecondToLast] = Error[Last];
Error[Last] = Error[Current];
}
//***********************************************
//If error is less than zero, the PWM output is zero
if (Error[Current] < 0) {
Drive = 0; }
//******************************
Drive = map(Drive,0,1000,0,255); }

long FlowSensor()

31
{

//**************************** Check button 1 State


****************************************

State = digitalRead(SensorPinNo);

// compare the present State to its previous state

if (Statef != lastStatef) {

// if the state has changed,

if (State == LOW) {

// if the current state is HIGH then the button

Counter++;

// Serial.println(Counter);

else {

// if the current state is LOW then the

lastState = State;

return Counter;

32

S-ar putea să vă placă și