1. Overview Metrology stations are an important component of oilfields, each responsible for measuring the production of multiple oil wells. Measuring the production status of oil wells through these stations allows for timely and accurate understanding of the working conditions of each well, while also providing reservoir engineering data to the oilfield's geological department. However, many oilfields in China still rely on manual measurement methods, which are labor-intensive, inefficient, and result in infrequent and short-duration measurements with poor representativeness. To automate measurement and improve efficiency and accuracy, more and more PLCs and HMIs (Human-Machine Interfaces) are being used in the automatic control systems of metering stations. The PLC is installed at the metering station to perform daily automatic measurement and data transmission; the HMI can be placed at the metering station to directly receive data from the PLC, display it in real time, automatically record and generate relevant reports, and transmit the information to the plant's central control room; alternatively, the PLC can directly transmit measurement-related data wirelessly to the plant's central control room for real-time monitoring on the HMI, enabling unattended operation. Through the practical experience of engineers and technicians at Zhejiang University Zhongzi Company, SunyPLC250 and SunyTech industrial control application software (HMI) have been successfully applied to the control of metering stations in oil fields. The following example of a metering station illustrates the implementation of its automatic control system. 2. Process Flow This metering station can meter 11 oil wells via a separator. When a well needs metering, its corresponding three-way valve is switched to the metering position, and the well feeds liquid into the separator. Based on the time required for the liquid level in the separator to rise from the lower metering limit to the upper metering limit, the well's production rate can be calculated. Then, based on the oil sample analysis, the daily oil production is finally determined. Metering of each oil well can be achieved by sequentially feeding and discharging liquid through the pilot valve and separator. 3. System Composition 3.1 Product Introduction SunyPLC250 is a modular, small-to-medium-sized PLC launched by Zhejiang University Zhongzi Company, characterized by its flexible structure, simple maintenance, and high cost-effectiveness. The product uses a 32-bit embedded processor, with a logic instruction execution time of up to 0.50µs/step. The SunyPLC250 consists of various functional modules (CPU module, interface module, digital input module, digital output module, analog input module, analog output module, power supply module, etc.), a baseboard, a personal computer, the SunyTech industrial control application software, communication cables, and a human-machine interface. The SunyTech industrial control application software is a DCS system configuration software launched by Zhejiang University Zhongzi Company, and can also be used independently as HMI software. 3.2 System Structure The metering station control system mainly consists of a SunyPLC250 programmable logic controller, SunyTech industrial control application software (running on a host computer), sensors (liquid level, temperature, pressure), and actuators (electric three-way valve, electric ball valve). As shown in the figure below: The temperature sensor is installed on the single-well inlet pipe to monitor the inlet liquid temperature in real time; the liquid level sensor is installed on the separator to measure the metering liquid level and determine the metering stage; the pressure sensor is installed on the separator to measure the pressure inside the separator. An electric three-way valve is installed on the inlet pipeline and operates according to the output control of the SunyPLC250, thus controlling whether a single well is in metering or production mode. The SunyPLC250 programmable logic controller is the core of the entire metering station's automatic control system. Following its programmed settings, it automatically performs metering at set times each day, sequentially switching the three-way valve of each single well to the metering position, and then switching it back to the production position after metering is complete. The daily output of the metered single well is calculated based on the time required for the liquid to rise from the lower to the upper metering limit during its inlet flow into the separator. Simultaneously, the SunyPLC250 transmits the collected temperature, liquid level, and pressure signals, along with the metering results, to a host computer via the SNET network using the Modbus RTU protocol. The host computer displays and records the measured values in real time using SunyTech software, issues audible and visual alarms when signals are abnormal to alert operators, and can print production reports periodically as needed. 3.3 The system is equipped with a SunyPLC250 modular structure. According to the system design, the I/O points of this metering station's automatic control system are AI: 13, DI: 13, DO: 26. The system configuration is as follows: 4. Control Scheme The automatic metering control of the metering station mainly performs the following functions: Daily timed automatic metering of individual wells in sequence. The host computer can intervene to set which wells do not participate in metering, and when a single well is stopped, metering must skip this well and proceed to the next well. The host computer can manually designate a specific well for metering. When single-well metering is completed, the separator drain valve is automatically opened for drainage, and the separator gas outlet valve is closed according to the drainage situation. Unlike general PLC programming software, the SunyPLC250 programming software provides five programming languages conforming to the IEC61131-3 standard: FBD, LD, SFC, IL, and ST. Programmers can choose any one or more programming languages to implement their programming needs. 4.1 Automatic Metering: Metering begins automatically at 8:00 AM daily (time can be changed by the operator via the host computer). Metering starts from the first measurable well based on the default well number, assigned by the host computer. The PLC automatically performs valve switching, metering, and drainage operations according to a pre-set sequence. During metering, wells that do not grow by 1 cm within 30 minutes (this can be changed by the operator) are skipped, and metering continues to the next well. The operating steps are as follows: Switch the three-way valve corresponding to the well to be metered to the metering position. When the separator liquid level reaches the lower metering limit, start timing. When the upper metering limit is reached, record the metering time. Automatically open the drainage valve, close the separator gas outlet valve, and begin drainage. Switch the three-way valve of that well to the production position. When the liquid level reaches the low level, open the gas outlet valve again, close the drainage valve, and switch the three-way valve corresponding to the next well to be metered to the metering position to begin metering the next well. The program is configured using LD language, as shown in the figure below: 4.2 Designated metering of a single well is controlled by the host computer. The operator issues the well number of the designated well for metering. After the automatic metering of a single well is completed, the operator clicks the button of the desired metering well in the metering control table. After confirmation, the host computer issues a command, and the SunyPLC250 will automatically meter the well. During metering, the three-way valve is first switched to the metering position, and liquid is introduced into the separator. When the liquid level reaches the lower limit of metering, the timer starts. When the liquid level rises further and reaches the upper limit of metering, the metering time is recorded. Then, the drain valve is opened, the separator gas outlet valve is closed, and the liquid is drained. The three-way valve is then switched to the production position to complete the metering. The flowchart of the designated metering of a single well is shown in the figure. 5. Operation Management (HMI) The operation management of the host computer is mainly realized through the SunyTech industrial control application software to realize the human-machine interface function. By monitoring the operating conditions of the metering station, the operator can monitor the entire process of automatic metering, control which well participates in automatic metering, and designate a single well for designated metering. The HMI screen includes displays for the overall metering station overview, automatic metering selection, and single-well metering specification. The overall metering station overview screen monitors the real-time operation of the metering station (as shown in the figure below). The automatic metering screen is used to select and set the well numbers participating in automatic metering, and the single-well metering screen is used to set the single wells to be metered. The system can also generate daily metering data reports based on the daily metering data. 6. Conclusion The SunyPLC250 programmable logic controller is technologically advanced, feature-rich, and stable in operation. In its application in oilfield metering stations, it has improved the automation level of on-site control and ensured the accuracy and reliability of metering, achieving excellent results. It is worthy of promotion and use in similar industries such as pump stations and gas stations. Editor: He Shiping