Academic Journal of Science and Technology ISSN: 2771-3032 | Vol. 13, No. 2, 2024 173 Design of Automatic Drilling Fluid Configuration System Based on PLC Shenghu Pan1, 2, Xinglong Ni1 1School of Mechatronic Engineering, Southwest Petroleum University, Chengdu, 610500, China 2Oil and Gas Equipment Technology, Sharing and Service Platform of Sichuan Province, China Abstract: With the rapid advancements in the drilling industry, drilling fluid serves as a crucial circulating medium, significantly influencing both efficiency and safety through precise dispensing. This paper introduces an automatic configuration system for drilling fluids based on a Programmable Logic Controller (PLC), addressing health risks, dosage instability, and high costs associated with traditional manual preparation methods. The system employs a modular design comprising components such as human-machine interaction, powder and liquid material addition, mixing and stirring, storage of drilling fluids, heating, and cleaning. By integrating a C#-developed human-machine interface with PLC control circuits, full process automation is achieved—including formula importation, system reset functions, raw material addition procedures, transfer to storage of drilling fluids and cleaning operations. Experimental results demonstrate that the system maintains an average error below 0.1g in powder feeding experiments—indicating high precision and consistency in formulating drilling fluids. This study not only enhances automation in preparing drilling fluids but also significantly supports technological advancement within the industry. Keywords: Drilling Fluid; Control System; PLC; High-Precision Formulation. 1. Introduction Drilling fluid is a crucial circulating medium in the drilling process, performing functions such as cleaning the well bottom, cooling and lubricating the drill bit, balancing formation pressure, and aiding in rock fragmentation. These roles significantly enhance both drilling efficiency and safety. To address increasingly complex exploration tasks and achieve production goals of high efficiency, cost- effectiveness, and safety, it is essential to select appropriate additives for drilling fluids based on specific geological and reservoir conditions [1–3]. Consequently, the development of drilling fluid systems tailored to the requirements of various formations has become an inevitable trend in the industry's evolution. However, the current process for developing and formulating drilling fluids primarily relies on manual operations. This reliance not only poses potential health risks to operators but also exhibits significant shortcomings in dosage accuracy stability, formulation efficiency, and cost- effectiveness. Moreover, most advanced drilling fluid configuration equipment, such as the automated offshore demonstration system developed by NOV for Seawell, the automated mixing and dosing system by OFFSHORESYSTEM and NOV in the United States, and CAMERON of Schlumberger, is designed for large-scale field operations. These systems typically measure configuration precision in kilograms [4–8], rendering them unsuitable for laboratory research and development. In contrast to field applications, experimental R&D of drilling fluids demands specific requirements such as low-dose additions, precise dosage ratios, and capabilities to measure performance parameters. Therefore, it necessitates formulating drilling fluids with exceptionally high precision and efficiency. To address the current challenges in drilling fluid formulation, this paper presents an automatic drilling fluid configuration system centered around a programmable logic controller (PLC). This system is equipped with functionalities for powder addition, liquid addition, precise weighing, additive transfer, mixing and stirring, additive heating, storage of drilling fluid, and automatic cleaning. It enables the complete automation of drilling fluid configuration based on imported formulas. Compared to manual methods, this system significantly enhances the efficiency of drilling fluid configuration, accuracy in additive dosing, and stability in performance. Furthermore, it reduces uncontrollable variables in the research and development process of drilling fluids and plays a crucial role in achieving automation and unmanned operation in laboratory settings. 2. Overall Design of the System 2.1. System Components and Principles In order to realize the complete process of drilling fluid configuration, this system adopts modular design, including human-computer interaction module, PLC control circuit module, powder raw material adding module, liquid raw material adding module, mixing and stirring module, drilling fluid storage module, heating module, and cleaning module, etc. The overall structure of the system is schematically shown in Figure 1. The Human-Computer Interaction (HCI) module is developed using the C# language within the Winform framework and communicates with the PLC via the Modbus TCP protocol. Its primary function is to offer an intuitive user interface that facilitates user command input and real-time system status display, enabling operators to efficiently monitor and control the entire system's operation. The HCI module is organized into different operational interfaces, which include four main sections: login interface, main interface, parameter setting interface, and historical configuration record interface. 174 Figure 1. Schematic diagram of the overall system structure The PLC control circuit module is centered around the PLC and integrates electrical components such as the power supply circuit, relay, and motor driver. It manages the entire system's process and logic by controlling the power supply to each component, sending pulses for motor operation, and facilitating communication with upper computers, viscometers, sensors, along with other communication and control devices via Modbus 485. This configuration ensures efficient and stable system operation. The powder additive adding module primarily consists of the powder discharging module and the powder weighing module. The powder discharging module includes components such as a stepper motor, a powder canister, and a discharging screw. During operation, the stepper motor drives the rotation of the discharging screw, allowing the powder to be dispensed evenly and slowly from the canister to maintain a stable discharge rate. Key components of the powder weighing module include a receiving bin, a linear motor with its pushing mechanism, and a critical load cell. The receiving bin and linear motor's pushing mechanism are mounted atop the load cell via a mounting plate. Together with a rotating servo motor, these form part of the rotating mechanism for handling powdered additives. The liquid raw material addition module achieves precise dosing of liquid additives using micro-injection pumps, transportation pipelines, and related equipment. Each micro syringe pump is equipped with an input and an output line. Check valves regulate the flow of liquids within these lines, ensuring both the efficiency and accuracy of liquid additive addition. The heating module comprises a heating jacket and a temperature controller, which are responsible for maintaining the liquid's temperature during the configuration process. The temperature controller communicates with the PLC via a communication module to precisely regulate the heating temperature, ensuring consistent performance of the final product. The mixing module consists of a frequency conversion high-speed mixer and corresponding mixing cups. It communicates with the mixer via the Modbus 485 serial port of the PLC controller to issue commands such as speed adjustments, start, and stop. This setup enables automated control, ensuring that raw materials are evenly and thoroughly mixed during the process, thereby enhancing product quality and production efficiency. The primary function of the drilling fluid storage module is to transfer the prepared product from the mixing cup to a storage container using three high-precision peristaltic pumps and a comprehensive set of liquid transportation pipelines, facilitating subsequent experiments. The cleaning module integrates a solenoid valve, tap water source, freshwater transportation pipeline, and other equipment to perform cleaning tasks in conjunction with the finished product transfer module. This ensures system cleanliness and long-term stable operation. 2.2. Overall workflow design of the system To implement the comprehensive steps involved in drilling fluid configuration—such as recipe and parameter import, system reset and initialization, raw material addition and configuration, drilling fluid transfer and storage, along with the cleaning process—the overall workflow of the system is 175 designed based on the various functional modules described in Section 1.1. This design is illustrated in Fig. 2. Figure 2. Overall system workflow diagram The auto-configuration program begins by importing the set recipe into the host computer and simultaneously setting parameters for this configuration, such as mixing temperature and time, to ensure precise adherence to the recipe. Subsequently, a system reset is performed, including register reset and mechanism zero return, to guarantee accuracy in subsequent configurations. Concurrently, the substrate is added to the liquid mixing cup while activating the heating module to raise it to the specified temperature. Following this setup, agent configuration modules are activated according to recipe instructions. For powder addition tasks: corresponding stepping motors are initiated for downward rotation; powders fall into a weighing module that collects weight data transmitted back for filtering; based on filtered data from PLC instructions adjust motor operations until desired weight is achieved before stopping material flow — thereafter transferring powdered materials directly into mixer cups where they undergo thorough blending processes. For liquid additions: micro-volume syringes pumps engage by converting volumes via algorithmic pulse counts enabling precise liquid delivery—discharged fully through pipelines ensuring comprehensive integration within mixers thus producing drill fluids aligned precisely with formulated requirements. Once the drilling fluid is configured, it is transferred from the mixing cup to the storage container using the drilling fluid 176 finished product transfer module. Subsequently, water is added to clean both the mixing cup and associated pipelines through repeated rinsing cycles until they are thoroughly cleaned. After cleaning, waste liquid is directed into a waste liquid bucket for temporary storage. 3. System Control Circuit Design The control circuit of the water-based drilling fluid automatic configuration system is modularized in alignment with the overall system's structural modules. Centered around a PLC, each module is equipped with an independent circuit tailored to its functional requirements and component layout, enabling precise execution of its designated process. This modular design enhances both flexibility and expandability while significantly simplifying troubleshooting and maintenance tasks. Through inter-module communication interfaces, the PLC can monitor and manage each module's status in real time, ensuring efficient and precise operation of the drilling fluid configuration process. Moreover, advanced sensors and actuators are employed to further improve control accuracy and response speed. The following sections detail the control circuit design for key modules. 3.1. Raw material addition module 3.1.1. Powder addition control circuit The solid-phase components of the drilling fluid formulation, such as barite, ammonium salts, and soda ash [9], are stored in a conical powder tank operated by a stepper motor. The addition of these powders is managed by the PLC, which sequentially activates the stepper motors based on recipe instructions. This ensures that powder chemicals are dispensed slowly and uniformly into the staging mechanism below and halted immediately upon reaching the specified weight. Taking powder motor 1 as an example: The control circuit must enable the PLC's pulse output port Y0 to transmit pulse signals at an appropriate frequency to drive its corresponding stepping motor driver—ensuring consistent and gradual dispensing of powders. Additionally, port Y5 sends signals to control relay K1 for selective activation of each stepper motor. The driver utilizes a common anode connection method. Furthermore, as the stepper motor does not require steering and operates under low load conditions, the configuration for direction and enable signals is simplified. The control circuit diagram is presented in Figure 3. Figure 3. Powder addition control circuit 3.1.2. Liquid addition control circuit The drilling fluid configuration includes liquid-phase components such as water, bentonite slurry, and FA367 solution. These liquids generally exhibit high viscosity [10], making precise extraction with a conventional plunger pump ineffective. To address the challenges of both extraction and accurate additive control, a piston pump driven by a stepper motor is utilized for precise dispensing of liquid additives. The piston pump facilitates liquid addition through hoses and check valves due to its dual pumping and pushing actions. In the case of piston pump 1: Based on the powder control circuit, adjustments are made where the motor selection port for liquid addition is designated as Y30, with an additional directional control port at Y35; this design also employs a common anode connection method. Figure 4 presents this control circuit. 177 Figure 4. Liquid Addition Control Circuit 3.2. Powder transfer mechanism In this system, the powder transfer mechanism serves as an essential component of the powder addition module. It is tasked with precise weighing and transferring of the powder, necessitating high-precision load cells and servo motors with position loop control. These components ensure both the accurate measurement of added powder and precise alignment between the transfer bin and discharge port of the powder tank. This accuracy directly influences the qualification rate of performance parameters in drilling fluid configuration outcomes. The control circuit of the powder transit mechanism primarily consists of PLC, servo motor, RS485 hub, digital transmitter, load cell, photoelectric sensor, and various other electrical components. The servo motor is configured using a common anode connection method in position control mode and rotates via pulse control. To maintain a locked position and prevent external interference during configuration processes, the drive's enable port DI1 is directly linked to a 24V power supply. Pulse signals are input to the drive by the PLC through pulse output port Y0; port Y12 sends signals to manage relay K3 for selecting the servo motor; while Y17 manages its direction signal. The load cell component conducts digital-to-analog conversion via a digital transmitter and employs an RS485 hub as an intermediary for data exchange with the PLC's RS485 communication port—this ensures real-time feedback on powder quality for precise addition. Figure 5 illustrates this circuit diagram. Figure 5. Circuit of the powder transfer mechanism 178 3.3. Powder transfer mechanism The heating module is essential for water-based drilling fluid autoconfigurators, as it ensures that fluids are maintained at the appropriate temperature to preserve their rheological properties and chemical stability. This maintenance enhances both drilling efficiency and safety. Furthermore, the heating module improves the dissolution efficiency of additives, thereby optimizing drilling fluid performance. Thus, designing an effective control circuit for the heating module is crucial; it must facilitate a rapid increase in temperature while also ensuring both its accuracy and adjustability. The heating module in the system comprises a PLC, an RS485 hub, temperature controllers, and heating mantles. Taking the stirring section's heating module as an example, a 220V high-power heating mantle and temperature controller are employed to achieve rapid heating. The PLC controls relay K4 through port Y24 to indirectly manage the activation of the temperature controller. Temperature settings are communicated between the RS485 hub and the temperature controller. The OP1 output port of the temperature controller manages power to the heating mantle by controlling relay K5's coil operation. A built-in fuzzy PID algorithm in the temperature controller allows real-time feedback on heater temperatures via sensors within each mantle; thus allowing for adjustments through intermittent switching at OP1 based on actual conditions observed during use or measurement cycles depicted diagrammatically. The control circuit of the heating module is shown in Figure 6. Figure 6. Heating module control circuit 4. System Software Module Design The system's software modules are categorized into two primary types: the human-computer interaction module and the PLC logic control module. The human-computer interaction module is developed using C# and leverages the Winform framework to offer an intuitive user interface that facilitates user command input and real-time system status display, enabling operators to monitor and manage overall system operations efficiently. In contrast, the PLC logic control module utilizes Delta PLC's ISPSoft software for implementing control logic via ladder programming. This module primarily handles real-time data processing, execution of operational commands, and automation of configuration processes. 4.1. Human-Computer interaction module design The human-computer interaction module is divided into several operation interfaces, comprising four primary interfaces: the login interface, main interface, parameter setting interface, and historical configuration record interface. (1) The login interface utilizes a MySQL database for user authentication. It handles user login verification, new user registration, and account logout functions. (2) The main interface is designed to display key monitoring data in real-time. This includes temperature and load sensor readings as well as current recipe information. Additionally, it allows users to switch between automatic and manual modes while providing control buttons for necessary operations. (3) The parameter setting interface enables the configuration of parameters such as timing for each stage of the process, target temperature settings, mixer speeds, and drilling fluid formulations. Its purpose is to allow customization and optimization of control parameters to achieve precise management and expected performance in drilling fluid configurations. (4) The historical configuration record interface integrates with the MySQL database primarily to log and present historical recipes alongside corresponding drilling fluid performance data. This feature offers an intuitive platform for users to view past data while facilitating effective analysis by allowing comparisons across different formulations concerning their impact on drilling fluid performance. 4.2. PLC logic control module design The PLC logic control flow for this system is illustrated in Figure 7. Upon receiving the startup configuration command, the system initiates its operations by performing initialization 179 and subsequently adding the base slurry. The process then advances to an automatic dosing stage, which is executed through a primary control program integrated with several modular sub-programs. Each dosing motor or pump operates independently, with separate programming and distinct interfaces for individual invocation. The main control program sequentially reads chemical identifiers according to the formula order specified by the host computer, invokes corresponding dosing programs via dedicated interfaces, and accurately introduces chemicals as dictated by this sequence. Once configuration concludes, drilling fluid is conveyed to an aging tank for storage while ensuring mixer cleanliness through three rounds of cleaning; this guarantees precision and reliability in subsequent drilling configurations and test outcomes. Figure 7. PLC Logic control flowchart 5. Experimental verification The drilling fluid configuration experiment platform is depicted in Fig. 8. The powder tank is actuated by a stepper motor, specifically the DM420 model driver. Under the control of this stepper motor, the internal screw rotates uniformly to ensure consistent powder discharge. Through preliminary experiments, it was established that optimal powder falling speed occurs when the stepper motor operates at 100–120 rpm; therefore, the pulse circle ratio is set to 1600 pulses per revolution using a dip switch setting. With an operational pulse frequency of 3000 pulses per second, this results in a stepper motor speed of approximately 112.5 rpm. A load cell with a maximum range of 3 kg and accuracy class C3 (sensitivity: 2.0 mV/V) is positioned beneath the hopper for precise weight measurement during operation. To mimic real-world conditions more accurately during testing phases when powder falls into mixers running at high speeds--specifically around or exactly reaching up-to ten- thousand revolutions-per-minute --the mixer will be activated throughout these processes as well. Figure 8. Experimental platform To assess the accuracy of this system in drilling fluid formulation, three distinct powders were incorporated into the formula for a powder discharging experiment. The resulting 180 weighing signal data were then compared with both the required formula quality and the actual weight of each powder, thereby evaluating the system's capability and precision in configuring drilling fluids. To ensure the accuracy of the experiment and reduce random errors, multiple trials were conducted, and an average value was calculated from the results. The average weight obtained was compared with the formula weight to determine the mean error. The experimental procedure is illustrated in Figures 9-11. Figure 9. Experimental Process of Powder 1 Figure 10. Experiment Process of Powder 2 Figure 11. Experiment Process of Powder 3 181 Table 1. Three Powders comparison Powder Formula Weight Average Weight Mean Error 1 5.60g 5.58g 0.02g 2 5.50g 5.44g 0.06g 3 6.00g 6.04g 0.04g Based on the experimental data presented in Table 1, the theoretical weight of Powder 1 is calculated at 5.60 g, while the average measured weight is observed to be 5.58 g, resulting in a minimal error of 0.02 g. This indicates excellent consistency and reliability. For Powder 2, the theoretical weight is specified as 5.50 g, with an average measurement recorded at 5.44 g and an error margin of 0.06 g; despite being slightly larger, this error remains within a controllable range and implies satisfactory weighing repeatability. Conversely, Powder 3 has a theoretical weight of 6.00 g with an average measured value of 6.04 g, yielding an error of just 0.04 g; this again confirms high precision and material stability. Overall analysis shows that all powders demonstrate accurate and consistent performance in the weighing process across multiple experiments with an average error less than 0.1 g per powder sample—this underscores the system’s high precision and consistency for drilling fluid configuration tasks. These findings affirm that our weighing mechanism and data processing protocols are highly reliable while satisfying laboratory standards for drilling fluid configuration accuracy requirements comprehensively by offering robust data support along with technical assurance for enhancing quality control measures. 6. Conclusion A PLC-based automatic configuration system for drilling fluids was designed and validated in this study, significantly enhancing the efficiency, precision, and stability of the preparation process. The system employs a modular design and integrates functions ranging from powder addition to automatic cleaning, achieving fully automated operation. This approach not only simplifies operational procedures but also mitigates health risks for personnel. Regarding control accuracy, precise regulation of key parameters such as mixing temperature and time has been achieved through accurate control circuits and advanced sensor technology, ensuring consistent performance of the drilling fluid. Experimental results indicate that the average error in powder discharging is less than 0.1g, fully complying with stringent laboratory standards. The system provides reliable data support for drilling fluid quality control and demonstrates broad application prospects by contributing to increased industry automation levels, cost reduction, and enhanced safety. Future efforts will focus on optimizing system functions further and promoting its implementation in actual drilling operations. References [1] Jin J, Dong X, Wang W, et al. Drilling Fluid Technology for Complex Deep Cambrian Formations in Tarim Basin[J]. Petroleum Drilling Techniques, 2024, 52(2): 165-173. [2] Chen X, Guo J, Wang L, et al. Advances in synthetic-based drilling fluids[J]. Applied Chemical Industry, 2024, 53(6): 1383-1387. [3] Jiang G, Dong T, Cui K, et al. Research status and development directions of intelligent drilling fluid technologies[J]. Petroleum Exploration and Development, 2022, 49(3): 660- 670. [4] Fode R, Hara T O. Operational Experiences With Automated Mud Mixing Systems: SPE 16066[R]. SPE 16066, 1987. [5] Kvame O, Blom-Jensen B, Bastesen Y. Automation of the Drilling Fluid Mixing Process, Field Experiences and Development from North Sea Operations: SPE 139943[R]. SPE 139943, 2011. [6] Information on: https://offshore-systems.no/wp- content/uploads/2014/11/08_mudmixing_v4.pdf [7] Information on: https://www.products.slb.com/rig- equipment/mud-pumps-mixing-processing/mud-mix-ing- system [8] Information on: https://www.nov.com/products/drilling-fluid- processing-system [9] FANG Y, ZHOU S, YAN J. Research Progress on Reservoir Protection Technology of Water Based Drilling Fluid[J]. Chemical Industry Management, 2024(2): 69-71. [10] GENG T, QIU Z, TANG Z, et al. Development and Application of High Temperature Resistant and Strongly Inhibitive Water- Based Drilling Fluid for Deepwater Drilling[J]. Petroleum Drilling Techniques, 2019, 47(3): 82-88.