PLC-BASED PID CONTROLLER FOR REAL-TIME pH NEUTRALIZATION PROCESS USING PALM OIL MILL EFFLUENT

: The pH neutralization process is a highly non-linear process and time delay system that is difficult to control and to accurately model mathematically. Therefore, the empirical method, which needs reliable experimental data to represent the process dynamics, is often used. In this paper, the performance of the PLC-based PID controller was studied using a different adjustment of the acid dosing pump stroke rate in the pH neutralization process. The pH neutralization process is a single-input, single-output system where the manipulated variable is the alkali dosing pump stroke rate, the controlled variable is pH, and the acid dosing pump stroke rate is set as a constant. The acid dosing pump stroke rate was adjusted to 10%, 15% and 25%. The results showed that the best performance of the PID controller was based on setpoint tracking when the setting of the acid dosing pump stroke rate was set at 10%, which could be used as experimental data in the empirical method. In addition, the real-time control system was integrated between PLC and MATLAB using National Instruments OPC server to access the experimental data in real-time, conduct simulation, and to develop the advanced control in the future.


INTRODUCTION
The palm oil plantation and processing industry is dominated by countries such as Malaysia, Indonesia, and Thailand. Treating palm oil mill effluent (POME) in accordance with regulations and standards from environmental agencies is a major problem in the palm oil industry [1,2]. The discharge POME in Malaysia must meet the standard requirements of Standards A and B of the Environmental Quality (Industrial Effluents) Regulations 2009. The direct discharge of POME has an impact on the environment.
Fresh POME from the palm oil mills is acidic (pH [4][5], hot (80-90 o C), non-toxic, with high organic content (chemical oxygen demand, COD 50,000 mg/L, biochemical oxygen demand, BOD 25,000 mg/L) and contains significant amounts of plant nutrients [3]. In addition, the discharge of dark brown colored POME into rivers inhibits the growth of aquatic organisms by reducing the penetration of sunlight and impairing photosynthetic activity. The ponding system is a common conventional method of treating POME. Most palm oil mills use anaerobic digestion as their primary treatment for POME. In Malaysia, more than 85% of the palm oil mills use the ponding system for POME treatment, and others use an open digestion tank [4]. Anaerobic digestion is the process of breaking down complex organic substances without oxygen. The process takes longer as the bacterial consortia must adapt to the new environment before using the organic matter to grow [5].
The major factors that affect the performance of the POME treatment digester are pH, mixing process, operating temperature, and organic loading rates into the digester. Operating temperature and pH are important to maximize microbial community performance in an aerobic digester [6]. In Malaysia, the pH of the POME discharge standard according to Standard B of the Environmental Quality (Industrial Effluents) Regulations 2009 is 5.5-9.0 [7]. However, pH control is a highly non-linear process and time delay system that is difficult to control. The dynamics of the pH neutralization process led to the difficulty of obtaining an accurate mathematical model [8]. Therefore, the empirical model of the pH process is the most suitable method to use for solving this problem [9,10]. Reliable experimental data are required to represent the dynamics of process, which only can be obtained with correct experimental setup.
PC-based supervisory control and data acquisition systems (SCADA) are typically used in POME treatment plants to collect, store, and analyze the process data. The system uses a controller, usually a PLC system with embedded PID controller algorithm, to adjust the parameters. The pH neutralization is one of the non-linear processes that requires advanced process control. In this study, the pH neutralization plant system is built from a SIMATIC S7-1200 controller with CPU firmware V4.0 and used TIA Portal V13 software with PLC PID compact block V2.2 for the PID controller control system. However, this system architecture does not support the performance of any simulation with SIMATIC PLCSIM software [11]. In addition, the challenges of the PLC system are that the PLC does not allow for real-time simulation or changes unless the system is under maintenance, and it is difficult to implement the mathematical model and advanced control algorithm in the PLC system. Therefore, the MATLAB platform can be used to design advanced process control, run simulations, and test the controller. The results obtained in MATLAB through simulation can be directly applied to the process plant through the PLC. In industrial automation, this requires a standard method for communicating and exchanging data with multiple types of data tags. The limitation of MATLAB is the difficulty of connecting to the rest of the real-time application system. To overcome this limitation, OPC Data Access (DA) servers can be implemented for real-time data exchange between The contribution of this paper is described as follows: (1) Developing the real-time system integration between the PLC with MATLAB software through NI OPC servers to ensure data exchange and ability to develop advanced controller in the future. (2) Determining the performance of the PID controller with PLC PID_compact using different settings of the acid pump dosing stroke rate.

The pH Neutralization Pilot Plant
The pilot plant for pH neutralization is installed in the Industrial Process Control Warehouse D1 of the Malaysian Institute of Industrial Technology, Universiti Kuala Lumpur. Figure 1 shows the schematic representation of the pH neutralization plant. The plant consists of three main tanks, namely the acid tank (T-81), alkali tank (T-82), and analysis tank (T-83). The tank volume of the analysis tank is regulated to 30 liters. The volume of the acid and alkali tanks are 40 liters each. The dosing pumps P-801 and P-802 are used to provide the required amount of acid and alkali for the pH neutralization process. The P-803A pump is used to circulate the liquid and mix it with the acid and alkali. Table 1 shows the list of instruments used in the pilot plant development.

Development of the PLC Based Process Application
The pilot plant design for pH neutralization consists of hardware and software components. The Siemens Simatic S7-1200 controller is used as the system hardware. Rack 1 is the PLC CPU module which is CPU 1214C DC/DC/Rly. Rack 2 is for the analog input/output module (AI 4x13BIT/AQ 2x14BIT_1). Rack 3 and 4 house the digital output module (DQ 8xRelay_1). The pH transmitter is connected to the analog output module channel 0. The acid and base dosing pumps are connected to the analog input module channel 0 and 1, respectively. The PLC controller is programmed with the Totally Integrated Automation Portal (TIA Portal) software from Siemens. The PLC receives the input signals from the sensor and controls the output device by sending an output signal to achieve the desired operation in a system. Table 2 shows the relationships between the PLC input/output types of tag name -data type. The pH sensor supplies electrical signals in the range from 4 to 20 mA to the analog input module. The analog input module converts 4 to 20 mA electrical signals to 0 to 27648 decimal values (digital signal), which can be read by the PLC. The acid and alkali dosing pumps receive electrical signals in the range of 4 to 20 mA from the analog output module. The analog output module converts 0 to 27648 decimal values (digital signal) into 4 to 20 mA electrical signals. Therefore, the tag with the data type integer is required to save the values from the analog input/output devices. Figure 2 shows the PLC ladder diagram for scaling analog values for a pH sensor. The electrical signal from the pH sensor memory address %IW96 is normalized to an integer value with the NORM_X Normalize block and then stored in the temporary memory #TEMP1. Then the integer value is scaled to the physical value (pH value 0 -14) with the SCALE_X Scale block and saved in % MD200 memory address. The same method is used to program the PLC ladder diagram to scale analog values for an analog outputs, acid, and alkali dosing pump. The physical value of the memory address %MD236 is normalized to an integer value with the NORM_X Normalize block and held in the temporary memory #TEMP2. Then, the physical value is scaled to the integer value with the SCALE_X Scale block and sent to the memory address % QW96 or %QW98 of the acid and alkali metering pump.  Figure 3 shows the built-in PID function in the PLC PID_compact function block, which provides a continuous PID controller. The PLC PID_compact continuously acquires the measured process value within a control loop and compares it with the required setpoint. The technology object PLC PID_compact has the function of tuning, whereby the P, I and D parameters can be calculated automatically depending on the control system.

NI OPC Server
A robust and established system is required to ensure the data acquisition between the device and the system. Automation devices that come from different manufacturers require a common communication platform for integration into the overall system. Object Linking and Embedding for process control technology (OPC) can thus be used as a solution that can offer interoperability between the various device manufacturers for safe and efficient data acquisition. Fig. 4 shows the components of the network diagram for PLC based real-time pH neutralization process control with MATLAB Simulink. The PLC is connected to the OPC DA server via OPC Server 2016 from National Instruments. By configuring the OPC server software, the input and output parameters of the PLC can be recorded in real time in the OPC server. The MATLAB OPC Toolbox is used to connect the MATLAB Simulink to the OPC server. The toolbox consists of OPC Configuration, OPC Read, and OPC Write blocks that are used to receive and transfer the data from the OPC DA Server to MATLAB Simulink. MATLAB Simulink acts as a client for the OPC DA Server. The communication between PLC and OPC DA server takes place via PROFINET/Industrial Ethernet (PN/IE) with specific IP address configuration. The NI OPC server is configured and defines the channel, the group and the tags with the appropriate data type as shown in Table 2. The OPC Quick Client is used to read/write data, run a structured text suite, and test the server performance. It can generate error reports that contain detailed feedback on all OPC errors from the server and help to diagnose problems from common OPC clients/servers.

LABVIEW Configuration
The next step is the configuration to set up the data acquisition between the NI OPC Server with LABVIEW. The purpose is that MATLAB cannot directly detect the communication with the NI OPC server. First, the new project must be created in LABVIEW. Then it finds the new I/O server. The NI OPC server is successfully registered when the OPC1 icon is displayed. Next, it selects National Instrument NIOPC Servers V5 option under Registered OPC Server in the OPC Client. In the next step, it clicks Create Bound Variables to find the registered variables in NI OPC Server. The variables are important for data acquisition and must be added to the LABVIEW program to establish communication. Then the variables can be used in the LABVIEW program.

MATLAB Simulink Configuration
The final step is to configure the MATLAB OPC Toolbox in Simulink. The MATLAB OPC Toolbox is the source of real-time and historical OPC data that was accessed directly from MATLAB. It can also read, write, and log OPC data from field devices via the PLC. The blocks named OPC Configuration, OPC Read, and OPC Write are used in the model. The OPC configuration block is used to configure pseudo real-time options, OPC clients for use in the model, and behavior in response to OPC errors and events. The required server National Instruments.Variable Engine.1 must be selected under the OPC Configuration block to set up the data acquisition from the pH neutralization plant via the NI OPC Server. Fig. 5 shows the Simulink model of a pH neutralization plant. The value of the stroke rate of the acid and alkali dosing pumps can be set directly with this model. The real-time data is stored in the MATLAB workspace. The next step is the configuration for the OPC Read block, which is used to read data from the OPC Server. In this project, the controlled variable pH value is read synchronously by the pH sensor in a pH neutralization plant. The function of the OPC Write block is to write data to the OPC server. The manipulated variables for this project are acid and alkali dosing pumps, which send an appropriate signal to the field device.

Experimental setup
In this study, the controlled value is pH, and the manipulated variable is the alkali dosing pump stroke rate while the acid dosing pump stroke rate is set constant. The aim of the experiment is to determine the most suitable setting for the acid dosing pump stroke rate, at which the PID controller can work at an optimum level. The experiment was divided into three data sets with the acid dosing pump stroke rate set at 10% (Set A), 15% (Set B) and 25% (Set C). The hydrochloric acid, 0.1M HCl and sodium hydroxide, 0.1M NaOH as acid and alkali are prepared. 1 liter of POME is diluted with 29 liters of 0.1M HCl, and then poured into analysis tank, T-83. The initial value of POME after dilution is 3.8. The POME is supplied by Sedenak Palm Oil Mill Sdn. Bhd. in Johor, Malaysia. The final discharged standard of the POME pH value under the Environmental Quality Act 1974 (Department of Environment, Malaysia) must be in the range of 5.5 to 9.0 [19].
The closed-loop experiment was performed using the built-in PID function in the S7-1200 PLC controller. The PLC PID_Compact function block (refer to Fig. 3) is used, which was specially developed for the control of proportional actuators.
Eq. (1) describes the PID algorithm for the PID_Compact [11], where y is the output value of the PID algorithm, w is the set point, Td is the derivative action time, Ti is the integral action time and Kp is the proportional gain. For the parameters, a is the derivative delay coefficient, which delays the effect of the derivative action, b is the proportional action weighting which represents the proportional action with setpoint changes, and c is the derivative action weighting which represents the derivative action with setpoint changes.
The PLC PID_compact auto tuning is divided into two stages, where the proportional, integral and derivative parameters are calculated during pre-tuning and the parameters are tuned further during fine tuning. However, for this process, the initial pH value is 3.8 and the setpoint is 7. Pre-tuning is therefore not required since the difference between the set point and the pH value is less than 30% of the difference between the pH value minimum and maximum limit, which is 0 and 14. For the requirements of the fine tuning, the setpoint and the pH value must be within the configured limits. During fine tuning, the PLC PID_compact generates an oscillation of the pH value with periodic changes in the manipulated value and alkali dosing stroke rate and calculates the PID parameters for the pH neutralization process. After the fine tuning is complete, the pH setpoint is changed with a positive step from 7.0 to 8.0 at t = 200 s.

Results and Discussion
With PLC PID_compact pH value fine tuning, an attempt was made to reach the setpoint with the minimum or maximum of alkali dosing stroke rate, which can lead to increased overshoot. Fine tuning begins when the setpoint is reached. The PLC PID_compact is switched to automatic mode and uses the tuned parameters when the fine tuning is completed. Table 3 shows the fine tuning parameters of the PID controller. For set A, the value of the derivative delay coefficient is greater than 1.0, which means the effect of the derivative action is delayed longer. However, for set B and set C, the derivative delay coefficient value is approximately 0, which means that the derivative action is effective for only one cycle and therefore almost not effective. Although the acid dosing stroke rate is set to constant, the amount of acid dosing on the process will affect the fine tuning performance of the PID controller. The fine tuning results show that set A performs well compared to set B and set C.  8 show the corresponding responses of the closed-loop systems to a step reference signal, where the setpoint is changed from 7 to 8. The wavelet transform is used for data preprocessing to remove the disturbance signals. The disturbance signals are due to the on-and-off state of the SV801, which was used to maintain the liquid level in the analysis tank. The total duration of the collected data for each set is 1426 s with a sampling time of 1 s. The acid dosing pump starts dosing according to the setting, and the unit step is changed at t=200 sec. For set A, the alkali dosing pump stroke rate is gradually increased based on the pH value, and then after the setpoint changes, increases to 20% and gradually decreases the value until the setpoint is reached.
The performance indexes of the PID controller are given in Table 4, where tr, tp and ts denote the rise time, peak time and 5% settling time, respectively and the overshoot percentage of the control signal. In Fig. 6 for set A, although the step response of the closed loop system has a high percentage of overshoot, it is able to reach the steady state at 1423.5 sec. Note that in Fig. 7 for set B and 8 for set C, the step response of the closed loop system is more oscillatory, has a higher percent overshoot and is unable to reach and remain stable within the specified range of 5% of its setpoint.    The process model is identified with FOPDT (first order plus dead time) using the System Identification MATLAB Toolbox. 50% of the data sets are used to estimate the models and 50% of the datasets are used to validate the models. The performance of each data set is evaluated based on the quality of fit, or error norm between the measured and estimated outputs. The cost function used is the normalized root mean square error (NRMSE), which is given by Eq. (2).  A fit percentage of 100% indicates a perfect match between reference and estimated outputs. The fit percentage for each data set is shown in Table 5. Set A shows the best fit percentage result, which is 54.22%. From the transient response indexes and the FOPDT model fit percentage, it can therefore be concluded that set A performs better than set B and set C. In addition to the controller tuning, the adjustment of the stroke rate of the acid dosing stroke rate is also important, which can affect the controller performance.

CONCLUSIONS
The paper described the use of OPC DA servers for developing real-time process control between MATLAB and PLC. The OPC server enables secure and reliable data acquisition between the various device manufacturers. Instead of the hardware modification, the control system software modification is more effective based on the test result showing the efficient data exchange between the PLC and MATLAB. The PLC-PID controller was tuned using the integrated auto tuning function in the PLC Siemens TIA software. For the pH neutralization process of POME, although the acid dosing stroke rate is set to constant, the parameter value needs to be properly studied because it will affect the controller performance. Based on the transient response results of PLC PID controller, further work is required to develop an advanced process controller that can overcome the nonlinear dynamic response of pH neutralization process.