1. Introduction
Water and fertilizer integration technology is widely used in agricultural production, in which the concentration ratio and proper application of water and fertilizer are crucial to the growth of crops [
1]. Currently, fertilizer and irrigation water use has gradually increased worldwide without a proportional increase in crop yields [
2]. A qualitative analysis of fertilizer application methods shows that the main cause of this situation is the improper distribution of fertilizers, which affects the efficiency of fertilizer uptake and the normal growth of the crop at all stages. Excessive fertilizer application can also damage soil structure, affecting the growing environment and survival of crops [
3,
4,
5,
6]. Therefore, in order to enhance the rationality of crop growth and the utilization rate of water and fertilizer resources, and to ensure the normal development and application of agricultural resources, more accurate and reasonable water and fertilizer blending integration technology should be adopted to realize the transformation of agricultural technology from being crude to intensive.
The root systems of different crops require different levels of acidity and alkalinity, and most mono-textured fertilizers are alkaline; thus, the pH of the fertilizer needs to be explicitly adjusted at the fertilizer blending stage [
7,
8]. However, the process of blending liquid fertilizer for pH is often affected by factors such as time lag and nonuniformity of fertilizer delivery, and the variation in liquid fertilizer pH is also nonlinear in nature. Therefore, fast and accurate adjustment of liquid fertilizer pH to set requirements is an important research area in precision agriculture [
9,
10]. The research on pH values mainly includes algorithm optimization research and fertilizer system pH model building research. The current modeling research on pH process regulation mainly includes linear and nonlinear models and artificial intelligence models [
11]. In the study of optimization of nonlinear control, methods such as adaptive regulation, feedback linearized transformation control and sliding mode control are generally used. Considering that the traditional PID control strategy has difficulty dealing with the complex nonlinearity and time lag in the control of water and fertilizer environments, more intelligent algorithms for optimal control need to be investigated [
12].
At this stage, most water and fertilizer controllers use conventional PID control algorithms internally. However, in the actual fertilizer application process, the fertilizer concentration and flow rate have a complex impact on the water–fertilizer mixing system, which leads to problems such as time-varying and lagging system control objects always existing. The use of PID control algorithms is usually not effective for regulation [
13,
14]. In view of this, the authors in [
15] used the application of a fuzzy adaptive control to regulate the water–fertilizer system. The simulation results show that the fuzzy PID adaptive control method is able to track and regulate the dynamic changes of the nutrient preparation process more accurately than the traditional PID method. In [
16], a single-neuron PID learning algorithm based on quadratic optimization was proposed for the strongly nonlinear pH process. The effectiveness of the algorithm was verified by the simulation control results of the strongly nonlinear pH process. In [
17], a self-tuning fuzzy PID control algorithm was introduced into the control system to regulate the frequency of the fertilizer pump, and hence, the water and fertilizer through the fuzzy PID control algorithm. An expert system PID control was developed by the authors in [
18]. The parameters of the controller can be adjusted according to the deviation of the pH value and the deviation rate. Simulation experiments showed that the expert PID control has good control performance. The authors in [
19] studied and established a grey prediction model for water and fertilizer irrigation and used MATLAB software to simulate fuzzy PID control in irrigation and fertilizer application, which effectively improved the accuracy of water and fertilizer concentration according to experimental verification. The authors in [
20] used quantitative feedback theory, a particle swarm optimization algorithm and a genetic algorithm to optimize PID control. The nonlinear problem of pH control was optimized. Additionally, the control performance was verified by simulation experiments. A wavelet-BP neural network-based method for accurate fertilizer application to maize was proposed in [
21]. The accuracy of the optimal fertilizer amount was improved by establishing a wavelet-BP neural network to calculate the nonlinear problem of fertilizer application. The authors in [
22] used an incremental PID algorithm to control the water and fertilizer ratios and constructed a simulation model with online parameter settings using RBF neural networks. According to the experimental verification, the RBF-PID model was more accurate and stable than the incremental PID model. The authors in [
23] proposed a nonlinear model predictive control method based on an elastic BP neural network and hybrid grey wolf optimizer. Simulation results showed that the proposed controller performed well and could reduce the disturbance caused by nonlinearity.
In summary, the main work carried out in this paper to improve the accuracy and rapidity of fertilizer pH regulation, based on water and fertilizer integration, is as follows: (a) An improved neural network controller is proposed which improves control by fuzzifying the inputs and optimizing the network parameters. (b) Particle swarm algorithms are applied for the optimization of two-layer weight parameters of neural networks. (c) PID control, fuzzy control, fuzzy neural network PID control and the control proposed in this paper are simulated and verified on the MATLAB/Simulink platform, and it is concluded that the algorithm proposed in this study is better than other control algorithms. (d) In order to verify the practicality and reliability of the proposed algorithm, the experimental verification of the data acquisition, the transfer function, and the upper computer reading and decision controls are designed in this paper, and the results prove that the control algorithm proposed in this paper has better results and performance compared with other control methods.
The paper is structured as follows. The first portion of this paper analyses the pH regulation process and develops a mathematical model of water and fertilization through the equilibrium equation. In the second part, a fuzzy preprocessing controller and a neural network controller are constructed, and the neural net controller is optimized using a particle swarm algorithm. The second part firstly constructs the controller that fuzzily preprocesses the input signal, then constructs the neural network controller, and finally uses the particle swarm algorithm to optimize the neural network controller. The third part compares the control effects of the four control algorithms through software simulation and experimental verification, and finally obtains the verification results based on the water and fertilizer system in this study.
4. Improved PSO-Optimized Fuzzy-BPNN Control Algorithm
The learning process of a BP neural network consists of continuously adjusting the weighting parameters of each layer of the network and then using the weighting coefficients to calculate the optimal control parameters. Therefore, the BP neural network needs to learn and continuously update the weighting coefficient matrix of each layer of the network.
4.1. BP Neural Network Weight Coefficient Update
According to the BP learning algorithm, first define the objective cost function
:
After determining the target cost function
, perform a negative gradient direction search with the objective of minimizing the target function
, with an additional inertia term that accelerates the convergence of the search to a global minimum as follows:
where
is the learning rate;
is the inertia coefficient.
The correction formula for the weighting coefficient of the output layer of the BP neural network is further obtained as:
Based on the above derivation, the correction formula for the implied layer weighting factor can be obtained as follows:
which sets up:
;
.
Therefore, the workflow of the Fuzzy-BPNN-PID controller can be summarized as follows: Set the initial values of the network parameters of each layer of the BPNN, as well as the learning rate and inertia coefficient of the network; use the fuzzy controller to fuzz the acquired
e and
ec; input the fuzzified output
v(
k) to the BPNN; then, calculate the input and output of each layer of neurons through the BPNN; and finally, calculate the three adjustable parameters
,
and
of the PID controller, which are calculated by Equation (5). The output control signal is
u(
k). The system continuously updates
u(
k) and the network weight parameters according to the updates of
e and
ec. The control schematic is shown in
Figure 9.
4.2. Improved Particle Swarm Algorithm
The optimization search process of the Fuzzy-BPNN-PID controller is as follows: firstly, the fuzzy rules are used to preprocess the two input signals
e and
ec; then, the fuzzy processed and normalized signals are fed into the neural network for training and learning; and finally, the optimal output control signal and the corresponding network weight parameters are obtained. However, the initial weight parameters for each layer of the BP neural network are usually chosen as random numbers of [−1, 1], and choosing random numbers as the initial values causes the algorithm to converge slowly, greatly affecting the training efficiency of the network and causing the algorithm to converge to local extremes [
29]. Therefore, in order to obtain better network training accuracy, this paper used the particle swarm algorithm to calculate and find the optimal parameters as the initial network weights of the BP neural network, as to improve the iterative convergence speed of the network and the efficiency of finding the optimal control signal.
4.2.1. Standard Particle Swarm Algorithm
The particle swarm algorithm (PSO) is an algorithm for population intelligence optimization. It works by constructing a population of M particles in a D-dimensional space, where each particle represents a potential optimal solution to the desired value. The system sets each particle (
i = 1, 2, …, M) to have a position parameter
and a velocity parameter
, as well as a fitness value obtained according to the objective function. The particle evaluates the individual optimal position
and the population optimal position
of the particle based on the fitness value, and each time the particle is updated, it obtains a new fitness value as well as
and
, thus gradually finding the historical optimal position
of the particle and the historical optimal position
of the particle population [
30]. The updated iterative equation is calculated as:
where
is the inertia weight;
= 1, 2, …, D;
= 1, 2, …, M;
is the velocity of the particle;
and
are acceleration factors; and
and
are random numbers in the interval [0, 1].
When using the PSO algorithm for parameter optimization, the performance evaluation index of the fitness function needs to be specified. The purpose of the algorithm in this paper is to reduce the value of deviation; therefore, this paper selected the time multiplied by the absolute value error integral criterion index as the fitness function
of the particle swarm algorithm, and the calculation formula is:
where
is the total number of iterative steps of the particle swarm.
4.2.2. Improved Particle Swarm Algorithm
The inertia weight
has a balanced role in the global search for the optimal and development direction of the particle swarm algorithm and has an important impact on the performance of the algorithm. The adjustment of the inertia weight has a strong correlation with the number of iterations of the algorithm, and the inertia weight tends to decrement nonlinearly with the increase in the number of iterations; if the particles enter the optimal solution range during the iteration but the inertia coefficient does not reach the expected value due to the decrement, the particles deviate from the optimal. If the particle enters the optimal solution range during the iteration but the inertia coefficient does not reach the expected value due to decreasing, the particle deviates from the limit of the solution [
31]. In order to make up for the shortcomings of the inertia weight parameter adjustment strategy, this paper improves the inertia weights of the particles with the expression:
where
is the maximum value of the set inertia weight;
is the minimum value of the set inertia weight d;
is the current fitness value of the ith particle;
is the average fitness value of the population particles; and
is the optimal fitness value of the current particle.
Equation (13) shows that the value of is dynamically adjusted according to the difference between the particle runtime fitness value and the optimal fitness, thus improving the performance of the algorithm.
4.3. Fuzzy-BPNN Optimal Control Algorithm Based on Improved Particle Swarm
The main principle of the improved particle swarm-based Fuzzy-BPNN-PID control algorithm is that the initial weights of the BP neural network can be optimized accurately and quickly by introducing an improved particle swarm algorithm with an inertia weight adjustment strategy to improve the search efficiency of the network. At the same time, the state variables at the input of the neural network are fuzzily preprocessed to reduce the output of the network, which is insensitive to the input and easy to saturate. The steps are as follows:
- (1)
Initialization of particle swarm, where parameters such as population size, particle dimension, number of iteration steps, initial inertia weight and learning factor are set according to neural network factors.
- (2)
Using the global search capability of the particle swarm algorithm, the approximate optimal solution of the network weight parameters is preferentially obtained, and the particles are updated according to the particle fitness. If the particle swarm meets the requirements of the optimal fitness value, the corresponding network parameters are transmitted to the BP network.
- (3)
The BP neural network uses the network weights of the improved particle swarm optimization to process the fuzzy preprocessed signal, updates the network parameters through back propagation, and finally, outputs the optimal
,
and
, which are calculated according to the incremental PID formula that also calculates the control signal
u(
k). Its control principle diagram is shown in
Figure 10.
When the IPSO algorithm is used to obtain the network weight parameter matrix, the particle swarm population size is M = 20, the number of iteration steps is N = 100, the learning factor is = = 2, the initial inertia weight is = 0.9, the particle velocity interval is set to [−5, 5], the structure of the neural network in this paper is 3-9-3 and the number of adjustable network parameters is 2 × 3 × 9 = 54; therefore, the particle dimension D = 54 is set, and each dimension represents a variable-adjusted parameter.
5. Simulation Experiment of pH Control of Fertilizer Solution
In order to verify the performance of the composite control scheme, the Simulink simulation interface of the fuzzy controller was first designed through MATLAB, and then the BP-PID control algorithm based on PSO optimization was written using the S-function module of the Simulink module. PID control, fuzzy control, BPNN-PID control with fuzzy preprocessing and BPNN-PID control system models based on improved PSO and fuzzy preprocessing were established in MATLAB/Simulink, as shown in
Figure 11. The workflow of the model running is shown in
Figure 12. The pH value of pure water was 8, the acid used to adjust pH was dilute hydrochloric acid with a concentration of 0.2 mol/L, the flow rate of water entering the mixing tank was 1.1 L/s and the system delay time was 4 s.
The pH value of the fertilizer solution was tracked with a simulation time of 1000 s; the tracking curves of different control algorithms are shown in
Figure 13. According to
Figure 13, it was found that the PID controller has a fast response but a large overshoot, the fuzzy control has a small overshoot but a slow rise time, the fuzzy neural network controller has a faster response time but there is still a certain amount of overshoot, and the IPSO-Fuzzy-BPNN-PID controller has a faster response time with a small overshoot and can respond to changes in the set pH value in a short time. Compared with the other three control algorithms, it is more conducive to improving the accuracy of the fertilization process. In theory, this composite controller could optimize the pH regulation of fertilizers and water. In order to further analyze the optimization performance of the controller in this paper, the process of adjusting the pH value of the water and fertilizer mixture from 7.5 to 6.5 was simulated according to the actual situation. The simulation time was 500 s. The control curves of several control algorithms are shown in
Figure 14. According to
Figure 14, the fuzzy control and PID control have the largest response time and overshoot, respectively, and the fuzzy neural network response is faster, but there is a certain amount of overshoot over a period of time. The performance parameters of the four algorithms are shown in
Table 2. From
Table 2, it was found that in terms of overshoot amount, it is reduced by 7.0, 2.0 and 1.7 percentage points compared to the first three algorithms. The steady times are reduced by 60 s, 235 s and 88 s. The IPSO-Fuzzy-BPNN-PID controller performed well in terms of overshoot and response time, and was able to reach the set pH value in a short time. In the next phase, the algorithm is tested.
6. Tests and Analysis
In order to confirm the stability of the algorithm, intelligent fertilization trials were carried out. The schematic diagram of the test device structure is shown in
Figure 15 and
Figure 16. The test system structure mainly consisted of a main control module, a signal transmission module, a sensor monitoring module and a drive module. The main control module was mainly composed of a computer, PLC controller and touch screen configuration interface. The signals were transmitted via an RS485 bus. The drive control module was divided into the fertilizer-proportioning drive module and irrigation control drive module. The tests took the set pH value as input value and used PLC as the control core to receive the actual feedback signal from the pH sensor and perform calculations. When blending the fertilizer, the system master control module controlled the fertilizer output frequency of the fertilizer-proportioning drive module by changing the analogue voltage signal, controlled the input volume of the regulating liquid as it was added to the mixing tank according to the calculated volume and completed the mixing, and the system maintained a stable state when the pH reached the set value.
The control algorithm used float accuracy with a sampling period of 2 s. Two groups of pH adjustment processes were set up; the initial pH values of the two water and fertilizer regulation tests were 7.1 and 6.9, respectively, the target pH values of the water and fertilizer regulations were adjusted to 6.3 and 5.3, respectively, and an electromagnetic flow meter was selected to determine the instantaneous flow rate. The variable control test was read by sensors and data acquisition cards to test and compare different control strategies, setting the system flow rate to 4 m
3/h. The purpose of conducting this test was to regulate the accuracy of fertilizer pH control by the four controllers. The results of the test comparison are shown in
Figure 17 and
Figure 18. The indicator performance of the four controllers is shown in
Table 3 and
Table 4. As can be seen from
Figure 17 and
Figure 18, as the fertilizer flow rate increased, the performance of all four controllers gradually improved. Although the PID controller rose faster, it had the highest overshoot and a longer oscillation time, with a larger difference to the set pH value in a short time. The fuzzy controller had a smaller overshoot, but the response time was slow and could not keep track of the set pH value in time. The fuzzy neural network controller was considerably higher in rise time, overshoot and adjustment time compared to the first two controllers, but it had a significantly higher overshoot than the controller proposed in this paper, with the performance parameters tabulated as shown in
Table 3. When the pH value was reduced from 7.1 to 6.3, the control proposed in this paper was the smallest in both overshoot and steady-state time. In terms of overshoot, the reductions compared to the first three algorithms were 8.1, 4.6 and 1.5 percentage points. In terms of steady time, the reductions were 39 s, 120 s and 34 s.
The pH value was reduced from 6.9 to 5.3, with the performance parameters shown in
Table 4. Compared to the first three algorithms, the controller in this paper reduced the amount of overshoot by 13.8, 5.4 and 3.3 percentage points. The IPSO-FBPNN-PID controller can, therefore, respond to the set pH value in a short time with minimal overshoot and can meet the control requirements.
7. Conclusions
In this study, a neural network PID controller with improved particle swarm optimization network parameters and fuzzy preprocessed input signals was proposed to achieve a better response to the problems of nonlinearity and hysteresis of the fertilizer system and, thus, improve the accuracy of pH regulation of the fertilizer solution.
Through the simulation and practical application of pH control in the aqueous fertilizer solution, the excellent dynamic performance of the controller in this paper was verified step by step by comparing the data of response time, regulation time, rise time and overshoot of the four controllers with the current common control methods (PID control, fuzzy control) and fuzzy preprocessed neural network PID control.
The experimental results showed that the BP neural network PID algorithm based on improved particle swarm and fuzzy preprocessing optimization had better dynamic performance. Compared to the other three algorithms, the IPSO-FBPNN-PID control algorithm was significantly better in terms of overshoot and steady-state time. Additionally, the steady-state performance was also better. This controller is able to reduce the effects of time lag and nonlinearity in the actual fertilizer application process, which can produce better satisfying results in the work of fertilizer pH-worthy regulation within the fertilizer application system. In the future, the optimization of other intelligent algorithms and the combination of advantages with each other will also be further considered to greatly adapt to more complex regulation processes.