Using Ultrasonic Sensors to Develop a Wireless Level Control in Reservoirs with Liquid Chemical Products

http://www.revistadechimie.ro 365 In general, the storage tanks hold various liquids such as oil, oil derived products, chemicals and process plant liquids. They are in widespread use and need detection and monitoring methods of liquid level. Most of the processes in which the level of a liquid is the controlled parameter take place in open or closed tanks, having a constant or variable section and containing pipes and valves. Usually, in level control systems the liquid is supposed to be incompressible; however, if a fluid is transported over long distances at high speed and pressure the fluid compressibility should be taken into consideration as well as the tanks shape, the pipelines route and the inertial effects opposing to the flow variations [1]. Inside a tank, the level of liquids contained in and the flow rates they cross through are not independent variables [2,3]. The pressure or overpressure conditions, as well as the liquid column height entail automatically flow rate variations at the tank inlet and outlet; certainly, these variations generate level variation in open tanks, and level/ pressure variation in the closed tanks. Usually, the level in tank is controlled in fill-and-drain processes, through connecting pipes and valves, with the purpose of keeping the level within a narrow range (e.g., a phase separator) and adjusting the level in wide limits (buffer tanks). It is necessary to control the liquid level from the outside and within wide range (e.g., buffer tanks in which the input flow rate has wide range fluctuations while the output flow rate should be almost constant). In practice, the liquids flow through connecting pipes is turbulent most of the times (Reynolds number higher than 4000). The liquid flow rate (q) passing through a pipe is [4]:

In general, the storage tanks hold various liquids such as oil, oil derived products, chemicals and process plant liquids. They are in widespread use and need detection and monitoring methods of liquid level. Most of the processes in which the level of a liquid is the controlled parameter take place in open or closed tanks, having a constant or variable section and containing pipes and valves. Usually, in level control systems the liquid is supposed to be incompressible; however, if a fluid is transported over long distances at high speed and pressure the fluid compressibility should be taken into consideration as well as the tanks shape, the pipelines route and the inertial effects opposing to the flow variations [1]. Inside a tank, the level of liquids contained in and the flow rates they cross through are not independent variables [2,3]. The pressure or overpressure conditions, as well as the liquid column height entail automatically flow rate variations at the tank inlet and outlet; certainly, these variations generate level variation in open tanks, and level/ pressure variation in the closed tanks.
Usually, the level in tank is controlled in fill-and-drain processes, through connecting pipes and valves, with the purpose of keeping the level within a narrow range (e.g., a phase separator) and adjusting the level in wide limits (buffer tanks). It is necessary to control the liquid level from the outside and within wide range (e.g., buffer tanks in which the input flow rate has wide range fluctuations while the output flow rate should be almost constant).
In practice, the liquids flow through connecting pipes is turbulent most of the times (Reynolds number higher than 4000). The liquid flow rate (q) passing through a pipe is [4]: (1) where S is the pipe section, Q is the volumetric flow, K is a no dimensional flow coefficient, g is the gravitational acceleration; h 1 and h 2 represent the heights of the liquid columns at the inlet and outlet of the pipes. For a laminar flow (Reynolds lower than 2000), which is rare in practice, the flow rate is proportional to the pressure drop h 1 -h 2 , the flow resistance being constant. In the case of a pipe, the flow resistance R can be calculated by using equation (2): (2)  The purpose of this paper is to show the research results for improving the quality of a level control system by using an ultrasonic level sensor. By using an ultrasonic sensor in a liquid level control loop, the authors wanted to experiment the use of this new class of sensors, which are working without contact with the liquid surface or volume. In industry, using this type of transducer is becoming more and more useful, having large scale applications, from dangerous liquids reservoirs level monitoring, to waste water level monitoring in treatment plants, and to level control systems for a wide class chemical products. The research also demonstrated the efficiency of the system remote control by using a dual-loop PID controller.
Keywords: liquid tank, liquid level control, ultrasonic sensor, mathematical modeling.
The flow resistance can be experimentally determined by drawing the pressure drop variation versus the flow rate for a certain pipe length and then measuring this curve slope in the chosen operating point [2].
Usually, the measurements of liquids level are done using various sensors which need physical contact with the liquid. A method is using level sensor inside the tank, mounted on the arm of floater. But this approach can have less accuracy since it only has a single sensor. Because remote monitoring and data collection systems are necessary to collect information from the tanks, it is necessary to build a system which can be accurate, fast in level measurement and simple to install and handle [5][6][7]. Ultrasonic sensors are most commonly used due to their simplicity and low cost. The data acquisition is done by the sensors which are used to sense the changes in the liquid level of the tank and are stored in the system's memory. A server collects the information sent from the onboard micro-controller. From the server, the data will be processed and the output is displayed in a web browser. It will display a map and show the location of the liquid tank and the liquid volume. Some recent publications are devoted to the level monitoring using ultrasonic sensors [8][9][10][11][12][13][14][15][16].
In the following we take into consideration a tank having the cross section area A, filling it up with a flowing freely liquid at the flow rate Q i (the pipe does not touch the tank liquid). The liquid flows out of the tank at the flow rate Q e . The mathematical model and the transfer function for this process can be obtained by using the material balance equation: the volume of accumulated liquid is the difference between the liquid volume entering the tank Q i dt and the leak Q e dt within the dt timescale: (3) The output flow Q e varies by modifying the cross section V e of a valve; the input flow Q i can be modified by other valve with cross section V i . In level control systems the actuator can be either for V i or for V e [10], according to the process and equipment characteristics.
For the case developed by the authors in this paper, the actuator is V i while the process input is the flow rate Q i . In open tanks with atmospheric opening, the liquid flows under its own weight, no other pressure to influence it. In this case, for this kind of turbulent flow, according to equation (1): (4) where α is a coefficient depending on the dimensions of the runoff pipe, respectively of strangulation for the tap V e and the nature of the liquid; the initial equation (3) shall be rewritten as: (5) As above mentioned, an ultrasonic sensor can be used to measure and control the level of liquids in the tank. The operational principle of an ultrasonic sensor is based on generating acoustic waves and detecting them after they are reflected by an object [17]. An ultrasonic generator is activated for a short period and high frequency waves (over 20 kHz) are sent out to the environment, which are reflected back when they strike the liquid surface [18]. The time span between the transmitting and reflecting waves is measured by the microcontroller. This time of flight is used to determine the distance travelled by the waves, and extrapolate the depth of the liquid in the tank from the point where sensor is placed. The microcontroller sends a pulse through the software code, to the ultrasonic sensors which in turn transmits a wave form. Simultaneously, a timer in the software code is activated and runs until the waveform is received back. Once the waveform is received, the sensor sends a signal to the microcontroller and the timer value is counted and the distance from the bottom of tank is determined. Thus, the sensor gives the information about the depth which can use to set minimum and maximum level in real time and also can evaluate the variation of liquid levels over a period of time. If the reflecting object has a smooth surface, the generated ultrasonic wave should be perpendicular to that surface. The ultrasound based technology is limited however in practice by the forms and the density of the material which produce the reflection and other special features of the process. For example, in a tank filled with a liquid, the foam appeared on the surface of the liquid can be an error source for the level measurements.
In practice, the ultrasonic transducers for liquids can be used to measure level, as well as volume or flow rate. They offer a low cost solution for individual applications or park tanks. Concerning the transducers architecture, all equipment has the same electronics, the difference being only the sensing part. Models with the same frequency but with a 2, 3 or 4 wires connection appear to be identical, but they have only different connection styles.
Due to the narrow angle of the ultrasonic beam, the transmitted signals have a high penetration power through various types of gases, vapors, etc. Installing the transducer on the container where the measurements will be done and its position in relation to the bottom of the container, the supply pipe of the container and with the measured liquid must meet certain requirements [19]: (a) the sensor surface must be parallel with the surface of the liquid within the limit of ±2°; (b) no obstacles should be placed between the beam and the liquid surface; (c) the optimal position is in a range of 0.2-0.4 meters out of the tank diameter.
Programming the transducer operation can be done either after it was installed in the final position on the container or by using a flat surface and measuring the minimum and maximum distance between the sensor and the surface. Programming all of the operating parameters can be done only via an interface working with a software or a process control unit [20].
The main objective of this paper is to demonstrate how a level control system can be built by using a modern ultrasonic transducer, which is widely used in industrial applications. The presentation is focused on the description of the procedure from the modeling and simulation to the adaptive control of model of the tank filled with liquid. First, the mathematical model is presented. In experimental work, the authors used a configuration software [21] to program the transducer operating parameters while it was connected in a control loop.

Mathematical model of the liquid accumulation process
The mathematical model of a process is represented by a set of equations used to describe the process behavior. According to the characteristics of the control system, there are two cases: (1) systems where the level is the main parameter of the technological process and the control system is used to maintain a constant level, set by the plant; (2) systems where the level should be kept between two pre-defined limits.
In order to establish the structure and the parameters of the control system, it is necessary to determine the dynamic characteristic of the technological plant. The mathematical model of the plant may be determined either by finding the structure of the model followed by the calculation of the analytical function coefficients for transfer or by analytically developing the model structure and then, determining experimentally the coefficients. Whatever the chosen solution is, the purpose is the same: obtaining a model used to designing an automatic control system for the process taken into consideration. Therefore, the model must satisfy the two requirements, often contradictory: on one hand, to describe the process as accurately as possible, in order to obtain the best control performance and, on the other hand, to be as simple as possible, in order to make easier the control system design and implementation. To find the process model, we will assume the containers to be open, the pipes filled with liquid and accelerations to be small enough, so that the flow rate variations do not greatly influence the process.
In order to determine the mathematical model the law of mass conservation is applied, therefore: Q io -Q eo -for the stationary mode, where Q i [m 3 /s] is the input flow and Q e [m 3 /s] is the output flow. In the dynamic mode it results from eq. (5) that: (5a) A is the area of the cross section of the vessel [m 2 ] and H is the liquid level [m].
In the dynamic mode, the amount of liquid accumulated in the system is given by the difference between the amount of liquid introduced into the vessel and the amount of the discharged liquid: (6) where ρ is the liquid density and L(t) is the liquid level at time t. If we consider time variable quantities, we can write: (7) and, by substituting into eq. (6) the result is: (8) Then, eliminating the stationary mode: (9) Since the output flow Q e is directly determined by the level of liquid, this flow can be expressed according to the Bernoulli law, supposing a turbulent flow through the output valve, as: (10) A i is the area of the cross section of the output valve [m 2 ], α is the flow coefficient, and g is the gravitational acceleration [m/s 2 ] Developing in Taylor series the above equation around the stationary operating point, one can obtain: (11) Taking into consideration only the linear part, the result is: (12) This equation verifies for any L, at any time: (13) or (14) By substituting into eq. (9) we obtain: (15) We can use now the dimensionless quantities: -the controlled quantity (output), and -the actuating signal (quantity); therefore, we can write: (16) The process transfer function can be found from eq. (16): (17) where T p is the time constant of the process, and k p is the process gain (an amplifying factor).
The time constant of the process is proportional to the cross section area of the tank; it depends both on the height of the liquid column and on the coefficient which characterizes the flow on the output pipe. Since the time constant changes when the level of liquid changes, the control system will compensate this dependence. If the variation in the level is between 20-40%, relative to a reference value (frequently this met in practice), a value established for T p will be preserved even if the level will change.
The result obtained shows that the filling -emptying process, with free fall (variable output flow depending on the liquid level) acts as a first order aperiodic delay element. The output signal of the level transducer is affected by noise due to the turbulence associated with the fluids when entering the container. As a result, the current level measurements are rarely constant, fluctuations can reach 20-30 % of the whole scale. The fluid accumulation process of accumulation being slow, the control system perturbation is done by actuator successive closingsopenings.

Experimental part
The ultrasonic transducer EASY-TREK from NIVELCO company [21] was used in a liquid level control loop. Also, we used a software from EVIEW Technology company [22]. The main configured parameters were the currents for minimum level (4 mA) and maximum level (20 mA) as well as the alarm signal when an error occurred in the current loop. A configuration was made regarding the measurement characteristics (mode, measurement units, approximation, close and distant lock). The measurement optimization consisted in correction according to the tank shape, the tracking speed, estimating the rate of the level variation, excluding the objects that could affect the measurement, correction according to the speed of the ultrasonic wave.
A linearization table for 32 points and the information parameters (reflection, noise/signal ratio, etc.) were also used during the experiments. The controller taken into consideration was the Ethernet-based dual loop PID controller ADAM 6022 from ADVANTECH company [23], which allows to connect two independent control loops; it has four inputs (three analog and one digital) and two outputs (one analog and one be digital). This controller can work together with a personal computer connected to the same type of Ethernet or wireless network, by using a special control application to monitor the process. The reference parameters as well as the process current state can be monitored also by using a web page, opened by an Internet browser via the controller IP address.
The system for the control of level into a cylindrical tank had the following components ( fig. 1): the ultrasonic level transducer NIVELCO (LT), numeric controller ADAM 6022, a wireless router, an electro pneumatic converter with a control valve (RR), and a centrifugal pump that makes the liquid flow. For the installation to operate at optimal parameters, each specific function of each component has to be pre-programmed, so that they can operate as a full unit.

Results and discussions Setting up the control algorithm for level of liquid
In order to find the parameters of the level control system, the authors of this paper developed a method based on poles -zeros distribution, for obtaining typical closed loop systems. The desired configuration for the poles -zeros distribution of the transfer function for closed loop systems establishes those systems performance in relation to the class of exogenous quantities (references and perturbations).
Currently, the inertia of the level transducer and actuator are negligible when compared to the process inertia (T E <<T p ), so that the transfer function of the fixed part can be written as [24]: (18) In order for the system to work without error in stationary mode, a PI algorithm was used, which imposed a closed loop system having a standard second order transfer function [24]: (19) The corresponding transfer function for the open loop system is: (20) On another hand, we can write: (21) If the process delay is compensated by the integration time constant of the controller ( Then, the controller gain is: where ω n and ζ are imposed, while T p and k F are given (known).
Therefore, from the last equation, by choosing T i = T p , the tuning parameters of the PI algorithm for the closed loop system are found. The performances of the system are specified by the values of ω n and ζ parameters of override, i.e. the response time and stationary error, respectively. These performances are considered to be satisfactory if the level is maintained between the limits of ± 5% of the reference level. The phenomena of hydraulic resonance and noise, which are characteristic for the liquid surfaces, make inappropriate the derivative component in the control law.
In order to setup the transducer and process parameters, a controller configuration application was made, which was accessed by using a wireless or wired connection to the router and a computer having installed the specific application. After opening the application, it is necessary to configure the controller inputs: the used input number (3 -for the ultrasonic transducer), the type of the signal (current/voltage), the minimum and maximum values for the input signal (4-for 20 mA) as figures 2-4 show.
In order to be able to use the signal from the analog output of the controller to command the control valve, one should configure the output as: channel 1, control loop 1, and the output signal 4-20mA ( fig. 5).

Calculating the controller parameters
When the controller is tuned, the controlled quantity follows the reference as closed as possible, while perturbations are present. The stability of the process is ensured by maintaining a small error during the transient periods. The performances of a control system are considered to be good if the system response to an input step signal has a small transition period, the override is within the limit of the 10-20%, while the stationary error is zero. The error that appears between the current output value and the reference may be due to the perturbations, but also to a reference change which, in some cases, can be done by another device such as another controller from an upper hierarchical level or by process computer (e.g. cascade system control).
The command generated by the controller is sent to the process actuator (the control valve) which acts to reduce and eliminate the error in the shortest time. The time variation and the magnitude of the control signal depend on the controlled process dynamics. Ideally, the stationary error zero should be zero and this is obtained by having a smooth variation of the execution quantity. In practice this is not always possible, being necessary to carry out a compromise [2].
By using the mathematical model of the level control system described above the authors found the values below. (23) (24) where T p is the process time constant and k p represents the process gain.
The following values have been used: r reservoir =0.3 m -the reservoir radius; H max reservoir =0.8 m -the maximum height of the water column; The result was: For a good performance of the level control system it is necessary to maintain the override below an imposed value [9] σ < σ imposed For a second order system [10] an expression for the override can be used: where ζ -is the gain amplification factor: . Also, we have an inequality: , where ω n is the natural frequency.
If Ti mpuls answer =30s, then then From and using the numerical values shown, one can get a value: k R = 7.2. If T i = T ip , the controller integration time constant is T i =83.7s.

Practical verification (validation) of the calculated parameters
After starting the installation and after reaching a stationary regime [2], the controller parameters were set up to the values shown in table 1, i.e. P=7.2, I=0.023, and D=0. Then, the control system behavior has been verified for a step signal applied to the reference and the produced perturbation (figs. 6-8). The main parameters necessary for tuning the controller shall be determined as follows: -switching the controller in the AUTO mode with a specific factor of proportionality, without the integral or derivative component (I = 10, D = 0); -modifying gradually the factor of proportionality up to a value K 0 for which, if a step signal is applied to the reference   input, a small override (below 2%) appears in the system response. If T tr represents the time duration of the transient regime and t pw is dead time associated with this response (table 2), the following parameters for granting the controller will be calculated (figs. 9-12): K = 0.9 K 0 , T i = 6 (T tr + τ), T D = 0.  The shortest transient time and the smallest override have been found with the following values of the tuning parameters: K 0 =9, K = 0.9×9 = 8.1, and T i = 6×(36+4) = 240 s. With the above values, the calculated controller tuning parameters are: P = 8.1 and I = 0.66. After changing the parameters values, the system response to a step reference is the one shown in figure 14.
Since the system response is qualitatively superior to other measurements, the authors considered these values as being optimal for the tuning parameters of the controller. As it can be seen from the above, the calculated values and those experimentally determined for the numerical controller tuning parameters are different but they are close to one other. This means that the values which were analytically found should be verified and experimentally improved.

Conclusions
An ultrasonic sensor has been integrated into an automatic control system of the level of liquid by using additional components such as interfaces and programming facilities. A good characterization of the system behavior has been done by comparing the theoretical values of the controller tuning parameters with their experimental values. It was demonstrated that due to the possibilities to use a wireless or/and Internet connection to the controller, the process functional parameters can be permanently monitored or modified for/from different locations. Fig. 13 The system response with the optimal tuning controller parameters