(Shengquan Yang) Research of Virtual Classroom’s Collaborative Mechanism Based on Petri Net 2018 International Conference on Sensor Network and Computer Engineering (ICSNCE 2018) 48 Research of Distributed Control System for Oilfield Oil Pump Based on PLC and LAN Shengquan Yang School of Computer Science and Engineering Xi'an Technological University Xi'an, China e-mail: xaitysq@163.com Chen Gong School of Computer Science and Engineering Xi'an Technological University Xi'an, China e-mail: 1395861613@qq.com Abstract—In order to change the current bad situation such as the high cost of manpower, the failure to deal with the fault in time and the low management efficiency, etc. in oilfield oil pump measure and control, this paper puts forward the research and development of oilfield oil pump distributed control system based on PLC and LAN. Firstly this paper describes the operation principle of oil pump equipment and gives its network topology model. Secondly it designs the system macro distributed structure framework with 4 layers: Pump layer, PLC layer, IPC layer and RCC layer in detail. Finally the paper discusses the design of the software system including the PLC on-site field measure and control software subsystem, the IPC local session software subsystem and the RCC remote management software subsystem. Keywords-Oil Pump; PLC; LAN; Distributed Control I. INTRODUCTION Oil pump is an important core production power equipment for oil pipeline of oilfield enterprises. The traditional oil pump adopts manual inspection or computer combined with gauges and instruments, and local single- point auxiliary measurement and control [1]. Most of the oil pumps are arranged in unhindered and wild mountains and are huge in number. The traditional way of measurement and control will inevitably cause the high cost of manpower and low management efficiency of the oil field enterprises, Equipment oil transport failures often occur while the pump equipment can not work normally because maintenance personnel are far from the workplace of the malfunction and it can not be processed in time, which causes crude oil leaks or production stagnation. Programmable Logic Controller (PLC) is a microelectronic program control device which has strong anti-jamming performance and high stability and supports complex logic, data processing and network communication. Industry Personal Computer (IPC) is a full-fledged computer that supports industrial production process control, data storage, graphic display, dynamic curve and other functions under harsh industrial environment [2]. Because the production site is extremely dispersed irregularly, usually away from the site management office. With the help of Local Area Net (LAN), we can transmit the control pictures of IPC in the oil pump field at the same time to the oil pump equipment operating engineer's office to achieve real-time view and control. The local oil pump can be unattended, and can be found immediately and promptly sent to the site if there is a fault alarm. Therefore, the study adopts field PLC, IPC and LAN on local enterprise to achieve the local and remote joint measurement and control of multi oil pump. The local oil pump firstly can be controlled initially by autonomous operation, and the remote center can control the multi spot on the spot in real time. This is a distributed control structure which can achieve the advantages of highly centralized management and decentralized control. This is of great significance for the oil field enterprises which can make the global oil pipeline equipment run safely, facilitate the remote management operation, reduce the manpower cost and improve the operation efficiency. II. OPERATION PRINCIPLE OF OIL PUMP EQUIPMENT Figure 1. Oil pump operating process diagram The oil delivery pump system is mainly composed of a mechanical base, an oil delivery main pump, an oil delivery backup pump, a switch two position valve, an analog regulating valve, a three way switcher, an accident buffer tank, a mechanical pipeline, a frequency converter and various sensors [1]. Its function is to filter, heat up, buffer The general organ imports crude oil The failure accident temporary cache tank The three-way switch The oil delivery main pump The oil delivery backup pump The external output oil pipeline The site crude oil depot The crude oil filter 2018 International Conference on Sensor Network and Computer Engineering (ICSNCE 2018) 49 and pressurized the crude mixture which is sent from the general authority (or the wellhead) through the pipeline, and then transport it to the site oil depot according to the suitable flow rate. Its operation principle of oil transportation is shown in Figure 1. First of all the crude oil mixture which sent by the general organ or the pumping unit, through the mechanical pipeline to the crude oil filter to filter out the granular impurities, such as soil, slag, and so on. Then according to the set of oil transportation process, the three-way switch is sent to the main oil pump or the oil backup pump, and the crude oil is regulated to the appropriate outlet pressure through the oil pump, and then transported to the original oil depot through the external output oil pipeline. Because the flow and pressure of the total mechanism fluctuate greatly, the system needs intelligent control through the algorithm to the main pump or the pump frequency converter, to ensure the constant pressure of external transmission. If the external transmission pressure is too small, the external distance will not have motive force to run. Otherwise the pressure is too high, which will cause the ecological disaster, such as the leakage of the oil pipeline and other ecological disasters. If the pressure of oil which come from the total mechanism is too high beyond the tolerance range of pump or filter clogging. Then it need to cut off the entrance to the oil pump, and make oil tank failure directly into the cache. The crude oil level fault tank inside the cache reaches a certain height and then through the oil pump output out. III. NETWORK TOPOLOGY AND MACRO STRUCTURE OF DISTRIBUTED MEASUREMENT AND CONTROL SYSTEM FOR OIL PUMP According to surveying the distribution of oil pump in Changqing oil field, Daqing oilfield and Yanchang oil field, they are most regularly distributed in the wilderness. No matter the size of the oil field, their physical equipment and technology are basically the same, and an oil field generally is made up of several 1#, 2#... N# oil pump. In the follow-up article content the network topology is designed firstly, and the overall macro structure is further designed. A. Topology design of system network According to the characteristics of the operation process of the oil pump and the objective reality of the dispersion distribution of the multi-pump, a network topology of the oil pump remote measurement and control system as shown in Figure 2 is designed. This system is a typical star topology. All peripheral terminals IPC are connected to a Remote Control Center (RCC) computer through an enterprise LAN router. This central node manages the access and control of multiple distributed terminal nodes, and forms a distributed control system based on the network (NDCS), which is an extended application of the traditional DCS theory [2]. NDCS adopts the basic design idea of centralized management, centralized operation, dispersive measurement and decentralized control, and adopts the structure form of multi-layer classification and network communication. Figure 2. Oil pump distributed measurement and control network topology B. Overall macro structure of system remote measurement and control According to the characteristics of the network topology and the detailed requirements for the measurement and control of the oil pump, and following the principle of top- down and gradual subdivision, we have designed the overall macrostructure of the system NDCS as shown in Figure 3. The whole system is designed in a hierarchical way. There are four levels. The whole system is Pump layer (sensor layer), PLC layer (control layer), IPC layer (conversation layer) and RCC layer (management layer) from below [5]. The specific description is as follows: 1) The bottom of the system is the oil pump layer, that is, the Pump layer is also known as the sensing layer. Oil pump is the measure and control object of the whole system, composed of various sensors and actuators, including pressure, temperature, liquid level, flow rate, switch and other sensing signal input, main pump and standby pump start and stop switch output, three-way valve regulating opening size, analog output and digital frequency control of oil pump frequency converter. 2) The middle and lower layer of the system is the PLC layer, also known as the control layer. PLC consists of CPU, RS485, RJ45, and extension modules. The extension module includes the switch quantity I/O unit, the analog input A/D unit, the analog output D/A unit, all of which are connected with the CPU through the internal bus. RS485 is embedded in the external communication bus on the CPU unit. It is based on the standard Modbus RTU and inverter to control the serial communication [3]. RJ45 is the standard Ethernet port on the CPU unit, which is connected to the upper middle IPC mainly through the FINS NET protocol. 3) The upper and middle layer of the system are 1#, 2#, …N# IPC layer which consists of local IPC of the oil pump. On the one hand, the IPC layer carries on the local measurement and control through the FINS NET to PLC's conversation. On the other hand, it transfers the local data or accepts the RCC remote control instruction through the 2018 International Conference on Sensor Network and Computer Engineering (ICSNCE 2018) 50 conversation between the enterprise LAN and the top RCC, so it is also called the conversation layer. Figure 3. Oil pump control system hardware macro structure 4) The top layer of the system is the RCC level. It can perform data acquisition, curve display, early warning analysis, dynamic process picture, parameter setting and other functions for all oil pumps, it realizes the remote centralized operation and management of the oil pump group through the network, so it is also called the management layer. Designing the remote distributed centralized control of the oil pump into different arrangements, each layer requires a different software subsystem to implement separately, the upper and lower layers connect through the hardware circuit and the software API interface function, software subsystems of different layers can be studied and developed in parallel. This not only reduces the complexity of the overall system, but reduces the development cycle. IV. DISTRIBUTED CONTROL SYSTEM SOFTWARE FOR OIL PUMP In the hardware layering of the system besides the Pump layer sensor has a standard circuit interface, so it does not require programming. The other layers need to design the corresponding software subsystems separately, which includes: the field PLC field measurement and control software subsystem, the IPC local session software subsystem and the RCC remote management software subsystem. A. The field PLC field measurement and control software subsystem This system uses CJ2M-31 PLC as the field oil pump controller which comes from a famous Omron company in the field of automation, of which software development uses the CX-Program V9.3 integrated development environment. Using the ladder graph LAD that follows the IEC standard and compiling the SCL-ST language, five cyclic control SCL-ST subroutines are designed, and its PLC main ladder LAD program is shown in Figure 4. Figure 4. PLC main ladder diagram LAD program Each cycle control subprograms are executed periodically under main control scheduling that implements the management of their start-up, concurrency, synchronization, and stop. The detailed description of the content is as follows: 1) Data collection circular subroutine AnalogWork: Completing acquisition of module data such as multiple analog AD081-V1, switch quantity ID231 and so on. These data acquisition needs to be filtered and Remove the interfering data and store it in the DM area. The system uses external serial communication TCP / IP remote access N# pump local IPC (local HMI) Oil pump remote control center computer (RCC) LAN N # pump local programmable logic controller (CPU) PLC external FINS NET communication A/D unit D/A unit I/O unit In le t o u tle t p re ssu re se n so r P u m p te m p e ra tu re se n so r O u te r o u tle t flo w se n so r A c c id e n t b u ffe r le v e l se n so r M a in th re e -w a y sw itc h B a c k u p th re e -w a y sw itc h P u m p s O n /O F F O p e ra tio n S o le n o id v a lv e o u tp u t sw itc h P u m p s O n /O F F S ta te In p u t PLC internal bus PLC internal bus M a in p u m p fre q u e n c y B a c k u p p u m p fre q u e n c y RS485 RJ45 1# pump local IPC (local HMI) …… 1# oil pump PLC 2018 International Conference on Sensor Network and Computer Engineering (ICSNCE 2018) 51 the RC low pass filter for smoothing the data, and its mathematical transfer function is: 1 1 )( )( )(   f S TsX sY G , Tf=RC is the time constant of the filter, dispersing the mathematical function to obtain the PLC, the difference algorithm formula for its implementation is: Y(n)= α Y(n-1)+(1- α )X(n), TT T f f  α ,T is the sampling period, X (n) is the current nth sample, Y (n) is the current filter result data of the nth. 2) Logic control loop processing subroutine LogicModule: Completing all the internal logic control functions of the system, It has a raw rule library inside. Written by the PLC ST language, the rule form is the former condition (the execution condition) A - the following condition B (regular body), condition A and B can also be compound logical expressions composed of operators such as NOT, AND, OR, XOR and so on. A represents the logical operation conditions, and B represents processing. For example: IF MainPumpRun AND OilPressureHigh THEN SetAlarmOn AND SetPause On, of which expression means that when the main pump is running and the pressure is too high, PLC immediately outputs the alarm and pause the system. 3) Pressure PID control loop subroutine PIDWork: Completing the frequency PID control of the frequency converter , that is to use the PID algorithm to control the speed of the main pump or the pump to achieve the outlet pressure in line with the pressure curve set by the oil pump process. The differential equation of the PID control algorithm in PLC is [6]:         t D I P dt tde Tdtte T teKtmv 0 )( )( 1 )()( In the formula, )()()( tPVtSVte  is a deviation, it represents the running time of the controller, the TI is the integral coefficient, the TD is the differential coefficient, and the KP is the ratio coefficient, mv(t) indicates the output of the output t time of the algorithm. This subsystem uses SCL- ST code programming to achieve incremental PID control in Omron PLC, when running, select the appropriate proportion P, integral I, differential D parameters, and of course you can also call PLC built-in PID instructions to achieve. 4) Three - way switcher control loop subroutine DAValveCtl: Completing flow control of oil pump, on the one hand it controls the DA output of the three - way valve, on the other hand it controls the oil pump to be executed automatically according to the selected process. The main control processes are varied. According to time plan TimePlan to performs the main standby pump in turn, and it performs pump according to the flow plan FluxPlan, and executes pumps in turn according to the oil pump temperature plan TempPlan and so on. 5) Communication response loop subroutine CommWork: On the one hand, the RS485 communication is done to the transducer of the sensing layer, and on the other hand, the RJ45 communication for the upper IPC is prepared. PLC and frequency converter communication follow the standard Modbus RTU protocol, its command frame format as shown in Table 1. TABLE I. RTU TRANSMISSION MODE COMMAND FRAME FORMAT Pump slave address Function code Data Checksum 8bits(01-02) 8bits(01-19) N*8bits 16bits(CRC 16) It complies with the FINS TCP Industrial Ethernet communication standard when PLC and IPC carry out RJ45 network communications. It is compatible with any Ethernet, Controller Link and SYSMAC LINK network system [4]. Its protocol format adds a FINS header to the traditional TCP / IP. B. IPC local session software subsystem The oil pump IPC local session software subsystem is developed based on the object-oriented (OOP) integrated environment and completed by the programming mechanism of multi thread (Multi-Thread). According to the function of the system, the multithreading workflow of the IPC local session subsystem is designed as shown in Figure 5. Considering that the oil pump is a special key equipment in the oilfield enterprises, the users of the system have oil pump technicians, equipment safety personnel, ordinary operation workers, system administrators, etc., and they have different tasks in the oil pump operation, so subsystem design uses role based access mechanisms, in which different roles have different permissions when accessing the system. The thread is managed by the user role, and then the thread is selected by the role permission interface to produce different running interfaces. The other threads run in parallel, and they all have their own CRunTimeData space that does not interfere with each other, concurrently completing: downlink and PLC real-time carry out RJ45 FINS communication, the uplink and remote RCC complete the TCP/IP communication, the oil pump data processing record storage, the oil pump dynamic curve display and the PLC operation parameter view setting and so on function. 2018 International Conference on Sensor Network and Computer Engineering (ICSNCE 2018) 52 Figure 5. Oil Pump IPC Local conversation subsystem multithreading design After IPC collecting of PLC data, it should be stored after operation, for example, in the "oil pump data processing record storage thread", by collecting the oil flow rate f (T), the calculation of oil transmission tired measurement needs to be completed by the digital integration algorithm, and its mathematical expression is:  Tb Ta dttf )(Q , among them, Q indicates the accumulation of oil, Ta indicates the beginning time, Tb is the end time, and f (T) is the function of oil flow collection. When the programming is realized, the solution is solved by the complex Simpson algorithm, and its discrete formula is as follows:     1 1 )(2)()([ 6 )(V n k kba Tb Ta XfTfTf h dttf ])(4 1 1 2 1     n k kXf Among: hkTa XX X kk k )2/1( 2 1 2 1      Illustration:[Ta, Tb] is divided into n parts, taking equidistant nodes. C. RCC remote management software subsystem The RCC remote management software subsystem is based on the real-time requirements and special requirements of the oilfield LAN, and its design uses the classic industrial control C/S architecture. The human-machine interface of the subsystem proceeds from the whole situation of the management of all oil transport pumps in the oil field enterprises. It is more than the IPC local subsystem to manage and dispatch the threads of the production and operation of all oil transport pumps and the thread of the remote safety decision analysis of the global oil transmission equipment, and the other is similar to the IPC local subsystem, which is limited to the length of the text. The RCC remote management software subsystem focuses on the global remote control management function, then it can collect all the data of the oil pump, and then carry out large data analysis and process data mining, adopts a data mining algorithm based on classical Apriori algorithm for association rules. The main code is as follows: Procedue OilPumpApriori(Lk); Begin L1={large 1-itemsets}; For (k=2; Lk-1<>; k++) do begin Ck=apriori_gen(Lk-1); For all transactions tD do begin Ct=subset(Ck,t); for all candiates cCt do c.count= c.count+1; end Lk={ cCk|c.countmin_sup } end; L= kk L ; End. V. CONCLUSION By using an object-oriented integrated development environment in the Windows 7 operating system, Embarcadero RAD Studio XE、CX-Program V9.3 and open source network database MySQL 5.6, the distributed measurement and control system of oil delivery pump based on PLC and LAN is successfully developed. The system has been successfully applied in a Chinese oil field enterprise, and the actual development of RCC remotely the human- machine interface of one of the stations in which the oil pump operates as shown in Figure 6. After a year of feedback from the company, it shows that the system has high information level, reduced the difficulty of multi pump collaborative management, improved the efficiency of equipment safety management, and greatly reduced the operation cost of oil production. This article putted forward the remote control system which uses LAN and PLC to design in a hierarchical manner, and it simplifies the problem of complex equipment measurement and control. So it provides a better design method and model for remote control of similar equipment and has a strong practical application and promotion value. Oil pump IPC user role management thread PLC operating parameters view set thread Select interface thread based on role Pump dynamic trend curve show thread Pump dynamic process screen show thread Pump data processing records stored thread Uplink TCP / IP communication processing thread Downlink RJ45 communication processing thread 2018 International Conference on Sensor Network and Computer Engineering (ICSNCE 2018) 53 Figure 6. RCC remote site oil pump process operation interface ACKNOWLEDGMENT The Research is supported by the new network and detection control national and local joint engineering laboratory. (Financing projects No. GSYSJ2016014). REFERENCES [1] CUI Hai-Li, ZHAO Hai-jun, CHEN Peng, “Oil Pump Performance Detection and Fault Analysis,” Petro-Chemical Equipment, vol. 41, pp. 106-108, April 2012 [2] WANG Li-Wen, CHEN Yuan-jun, CHEN Bin, “Aircraft ground deicing monitoring system based on GPRS and PLC,” Computer Engineering And Design, vol. 37, pp. 2062-2066, Aguest 2016 [3] ZHANG Nai-lu, LI Yong-jin, ZHANG Yu-xiang, “Gas station integrated information monitoring system based on internet of things,” Microelectronics & Computer, vol. 33, pp. 130-134, February 2016 [4] QI Lei, HAN Zhe, CHEN Shuang, CHEN Zhao, “Design and realization of the measuring and controlling system of vacuum making wave machine based on S7-1200 Ethernet communication,” Industrial Instrumentation & Automation, vol. 3, pp. 31-34, March 2016 [5] WU Qiu-yang, LI Tian-ping, “Improvement and Application of DCS Gas-Fried Oven Temperature Control System,” Journal of Shandong Normal University(Natural Science), vol. 31, pp. 60-63, March 2016 [6] E.B.Priyanka, C.Maheswari, B.Meenakshipriya, “Parameter monitoring and control during petrol transportation using PLC based PID controller,” Journal of Applied Research and Technology, vol. 14, pp. 125-131, February 2016