Real-time monitoring and control of flow rate in transportation pipelines using matlab-based interactive GUI and PID controller

In this paper, a Matlab based GUI and Propotinal Integral Dervative (PID) controller is designed to automatically regulate the flow-rate of the circulating fluid. When fluids are transported over long distances, the pressure and flow rate have to be monitored remotely in a control room. Using an HMI or Control Panels the flow rate can be increased or decreased to compensate for pressure drops or disturbances. This paper attempts to demonstrate such an Industrial Control Operation in a scaled-down environment. A Graphical User Interface or GUI is constructed which enables the Operator to monitor, as well as control an electronically actuated Control Valve which can efficiently regulate the flow-rate. Automatic operations have also been implemented using a PID controller algorithm, which tries to track the Set-point in Real-time.


INTRODUCTION
Globally when transporting large volumes of fluids over long distances, pipeline provides the most commercially and economically sustainable solution for transportation. They find widespread adoption across all industries, from petroleum and fuels, to sewage and slurry, as well as clean water for irrigation or drinking purposes. Only requiring a pump for providing the pressure at one end, effortless transportation from remote locations become possible with very little additional manpower and monitoring. Thus, pipeline transportation beats traditional options such as trucks, or the railroad, with prices of the former being 2-3 times lesser. The only downside with pipelines is detecting the location of leaks, which are often very small and hard to trackdown. But with the current generation of highly precise sensing equipment, and machine-learning aided tools, even that problem is being effectively tackled. An ultrasonic type flow meter is used along with linear array transducer for metal pipe sytem [1]. However, concentration of bubble has an effect due to ultrasonic. Proportional integral derivative (PID) is used to control flow of liquid and verified with lypanpuu stability analysis [2]. Comprehensive control for micro fluid is implemented using fabrication techniques [3]. An analytical numerical method is developed for finding error in flow of fluid when it crosses the bends for dufferent diameters of pipe [4]. Outlet pressure of pipe is controlled with PID controller using LabView software tool [5]. Time dependent method for different porous material for transportation of fluid is presented [6]. A reduction algorithm is introduced for ultrasound detection of flow rate [7]. PID controller is used for oil pipe line control and the flow conrol is monitored [8]. A macro distributed control system using Pump, PLC and RCC layers are designed to control the pressure oil in Centrifugal Pumps [8]. Review is conducted on micropaper fluid controls which are easy to control the fluid flow [10]. Centrifugal pump is designed using Hardware -In -Loop (HIL) is developed. Pressure inside the Pipe is controlled using HIL during static and dynamic mode [11]. Fuzzy Logic Controller (FLC) and PID controller monitors and controls the flow rate of petrol [12]. Vector matrix control based pressure control is applied variable speed drives [13]. In [14] a least cost sizing is adopted for reducing pipe size.
The cost of transportation through pipelines decreases drastically as the flow-rate is increased which are illustrated in the Figure 1. Companies in the pipeline transportation business thus try to maintain the shighest possible flow-rates, and invest in pipes of larger diameter as that helps to reduce costs. But increase in flow-rate pressure too increases quite dramatically, especially if the diameter of the pipeline is smalleras shown in Figure 2. This increases the chances of leakages, or in worst cases explosions which might damage large portions of the pipeline network. To remedy this, systems are installed that monitor the flow-rate in real time and regulate it when the pressure values reach unsafe limits, and to reduce large fluctuations in the flowrate from the source end. Regulation of the flow-rate parameter is usually done using electronically actuated control valves [15][16][17]. PID controller provides the effective flow control therby increase the performance the system [18][19][20][21][22][23]. This gives the operator the benefits of both manual as well as automatic operations. Since the actual equipments are located remotely, they are interfaced using computer based systems. An HMI or Human Machine Interface is a type of touch-screen device which runs a GUI in real time and allows control and monitoring operations. The GUI can also directly be run on a computer. The GUI is constructed in Matlab with virtual dials and knobs and buttons that are interfaced with field equipments [24,25].

PID CONTROLER
One of the most commonly used closed-loop control algorithms used for Industrial Automation worldwide is the PID algorithm [25]. A PID controller is implemented by basically calculating three separate parameters such as the Proportional, the Integral and the Derivative gain constants in real time, and generating a Control signal which a function of these gain values. The controller measures the value of a system variable, known as the Process Variable (PV), and compares it with the desired value, known as the Set Point (SP). The difference between the two is the error signal, denoted by e(t). This error term is multiplied with the path gain constants (K p , K d and K i ) to determine the Output Response.
The task of the Controls Engineer is to tune the controller, so as to get the most suitable performance from the system. The Proportional Gain k p determines how aggressively, or conservatively the controller with respond to an input. A large k p makes the system faster, but with increased Overshoot. And a P-controller with only Proportional Gain will always have a large non-zero steady state error. This means the System can never fully reach the Set point (SP) value. This is where the Integral gain comes in. Working alone it is very slow and unusable, but a PI -controller with properly tuned k p and k p value is incredibly robust, and will ensure zero steady state error. But this improved performance comes at a price of increased overshoot and system oscillations. Thus the derivative Gain k d is required, which doesn't actually consider the value of the error signal, and instead works on the Rate of change of the e(t) term. It provides minimal impetus, when PV = SP, and the derivative of the e(t) term is almost zero. But during initial operations, when PV is lesser than SP, the Derivative Controller tries to flatten the e(t) curve by damping the force applied. This essentially eliminates the overshoot, which is but a decaying Sinusoid function as shown in Figure 3. Figure 4 shows block diagram of PID controller. In certain systems where the Plant Model is known, traditional lead-lag compensators are known to provide much better performance, when compared to poorly tuned PID controllers. Since the controller focuses on the feedback loop, and no strict knowledge of the system is required, from a Control Systems standpoint, the performance remains strictly reactive, and that is a big compromise in certain critical applications. Poorly tuned controllers are known for high overshoot, slow reaction times, or even horrible oscillations that can actually damage the actuating member.

RESULTS AND ANALYSIS
The first stage of this multi-disciplinary project involved using the tools available in Matlab/Simulink to create a simplified model of the system, and test the behaviour of the various parameters. Two sets of models were constructed and tested.
One was without the PI controller, and therefore no corrections to the position of the actuating member, and the other one with a proper controller implementation. The simulated output is depicted in Figure 5. In the first model there is no feedback controller to correct the position of the actuator when it deviates from the Set point value and thus the Output Response fails to accurately track the Set point. Also, there is a large overshoot at the middle of the curve, which is to be avoided as shown in Figure 6. Now a PID Controller is implemented.
It is obvious from the simulation results that the controller helps to eliminate errors and the system performs optimally as illustrated in the

Hardware design
The electronics is mounted on a panel that is physically separated from the pipeline, to protect them from any leaks. The motor is connected to the Control Valve using a simple gear-based coupling assembly. A dedicated AC to DC power adapter is also provided, which connects to the Motor Driver module which supplies the motor which has a full-load current draw of about 3 Amps. Figure 8 shows the hardware design of the system.
Water is chosen as the circulating fluid for the sake of simplicity. Its flowing through a pipeline and it passes through a digital flow-rate sensor that operates on the principle of Hall Effect. This sensor outputs the value to a Arduino microcontroller. The Arduino is interfaced with, and is programmed using the Matlab GUI backend platform. It enables us to control both the User Interface and also program the Arduino from the same set of rich tools. The Arduino also controls a high power Motor Driver Circuit that takes in 20 V of DC power and drives a high-torque geared-dc servo motor, which is shown in Figure 9.

Hardware results
Electronic hardware circuit is depicted in Figure 10. The operator interacts with the system by using this GUI Control Panel as shown in Figure 11. The Toggle switch puts the system in either open-loop or Manual Mode, where the Discrete Knob gives users direct control of the actuator, or Automatic or closedloop mode where the user has to only select the Set point using the Flow-rate Control Knob, and the PID algorithm does all the work. The Gauge displays the value, which is measured by the Flow Sensor. The two Arduinos communicate with each other to exchange Analog data using a basic RC filter based DAC that converts the PWM output of the Arduino to Analog signals. Figure 10. Electronics hardware frit zing circuit Figure 11. GUI implementation

3.2.1.Open Loop Response
The system is operated in open-loop or Manual Mode initially. Here the operator has direct control of the actuator, and controls the Percentage Opening of the Control Valve. But in open-loop mode the system cannot react to disturbances and the operator has to manually control the flow-rate which is illistrated in the Figure 12.
The operator can switch to the Automatic or closed loop control mode by flipping the Toggle switch in the GUI. The PID algorithm runs in the field side Arduino device and it receives the Setpoint value from the Remote side Arduino, and the real-time PV values from the Flow Sensor. Ten it does Setpoint Tracking and Disturbance Rejection in real-time. Figure 13 shows the closed loop response.
Initially it is established that the system performs as expected with a constant Set point value, set using the Matlab based GUI. It can even reject small disturbances in flow-rate introduced by varying the source pressure. After this a typical step input was given to the system by changing the Set point from about 11 L/min to 23 L/min, and even then the system performs as expected. The large overshoot is a result of imperfect tuning of the controller, and can be easily eliminated by even finer tuning which is depicted in the Figure 14. The true application of this easily scalable project lies in implementing a SCADA based GUI that can communicate with a PLC and associated analog IO components in the field. Figure 16 shows the setpoint tracking in PLC simulator.

CONCLUSION
A completely automated closed-loop flow-rate control system is implemented using open-source Arduino microcontroller, and a Matlab based GUI is built to interact with the system. A electro-mechanical actuator is designed that acts as a motorized flow-control valve and can regulate the flow-rate of pipelines in real-time, whilst providing remote Monitoring capabilities using the GUI. The scalable nature of the project makes it a desirable in a larger Industrial Setup. Also, this project has provided the involved students with great learning opportunities in a wide variety of topics, including Actuator Design, GUI backend programming, PID Controllers and tuning fundamentals, as well as basics of Global Pipeline Transportation.