Modeling and Predictive Analysis of Small Internal Leakage of Hydraulic Cylinder Based on Neural Network

: The internal leakage of a hydraulic cylinder is an inevitable hydraulic system failure that seriously affects the working efﬁciency of the hydraulic system. Therefore, it is very important to accurately identify and predict leakage data in the hydraulic cylinder. In this paper, a model is proposed to simulate a small internal leakage of hydraulic cylinders, to convert the amount of leakage of hydraulic oil into strain signals through high-precision strain gauges and to train the collected strain signals using various neural networks to form a computational model and obtain prediction results from the model. The neural networks applied in this paper are convolutional neural networks, BP neural networks, T-S neural networks and Elman neural networks. The predicted results of the neural network are compared with the actual leakage amount. The results show that the prediction accuracy of the above four kinds of neural networks are all above 90%, of which the convolutional neural network is the most accurate. This research provides scientiﬁc and technical support for measuring and predicting small leaks.


Introduction
As a hydraulic mechanism that has a linear reciprocating motion and swings, the hydraulic cylinder has a simple structure, reliable performance and strong load capacity. It is the main executive element that is widely used in hydraulic systems [1]. Due to its frequent heavy load and immersion in the working environment, the failure rate is also high; of the possible failures, leakage is the most important and unavoidable form of failure of the hydraulic cylinder. This failure directly affects the efficiency and service life of the system. The common leakage types of hydraulic cylinders are mainly external leakage and internal leakage [2]. External leakage mainly refers to the leakage of hydraulic oil from the hydraulic cylinder into the environment, such as rod seal failure leakage. The main reasons for this leakage are damage to the piston rod or seal guide sleeve, contaminated hydraulic oil, extreme working temperature and chemical substances. The internal leakage refers to the existence of a pressure difference between the high and low pressure chambers and the failure of the internal seals of the cylinder, causing the hydraulic oil to flow from the high-pressure side to the low-pressure side in the cylinder system [3]. For example, an internal leakage is caused by the wear of the sealing ring in the relevant part of the cylinder or the wear of the inner wall of the cylinder. Both internal leakage and external leakage reduce the working efficiency of the hydraulic cylinder. Leaks in pressure pipes are easy to observe directly. However, because an internal leakage occurs inside the hydraulic cylinder, it is difficult to detect at the initial stage and then becomes increasingly serious, which is likely to cause larger industrial production accidents. At present, the detection and analysis methods used for hydraulic cylinders mainly include the measuring cup measurement method, pressure holding method and hydraulic cylinder settlement method [4]. Of these, the pressure holding method is only used in the qualitative judgment of whether there is a leakage in the hydraulic cylinder, and it is impossible to perform further leakage analysis on the hydraulic cylinder that has leaked. The measuring cylinder settlement method is obtained by calculating the piston area and the actual movement distance of the cylinder. The disadvantage of this method is that there is a large error in the calculation result. Therefore, most manufacturers usually do not use this method at present, and the measuring cup measurement method is mainly used to analyze the leakage problem in hydraulic cylinders.
The above hydraulic cylinder leakage detection method is a traditional method for hydraulic cylinder leakage detection, and different leakage data are obtained from this detection method under different conditions (oil temperature, pressure). Therefore, the traditional detection method still remains in the experimental detection stage during nonworking periods. It is suitable for phased detection and cannot provide continuous and normal daily detection [5]. The leakage detection methods in hydraulic cylinders can be split into three categories from the perspective of common mechanical fault diagnosis technology: model-based diagnosis, signal processing-based diagnosis and artificial intelligence-based diagnosis. The model-based fault diagnosis method is used to establish accurate mathematical and physical models by analyzing the research object and using standardized mathematical and physical methods; such mathematical and physical models have also been used successfully to describe leaks in motors and hydraulic pumps [6]. However, most of the objects to be studied are nonlinear problems in actual production work. For nonlinear hydraulic systems, it is very difficult to establish mathematical models with precise parameters. In [7], the authors studied related issues for the real-time leak detection of non-linear multi-box flow devices. The document also showed that model-based detection methods are prone to sensor noise, which leads to the inability of mathematical models to determine precise parameters. In [8], a Kalman filter is used to identify leakage faults in hydraulic actuators; however, this method can only determine the type of leakage. Diagnosis methods based on signal processing include detection methods such as wavelet analysis, spectrum analysis and Fourier transform. The main principle of this type of method is to compare the characteristic values of the normal signal and the fault signal by analyzing and processing the output signal of the system to judge whether there is a fault. In [9,10], the authors use a wavelet transform and fast Fourier transform to extract signal features and accurately recognize the leakage pattern. Diagnosis methods based on artificial intelligence include the expert system [11], neural network [12], fuzzy inference [13] and support vector machine [14] methods. This type of method can use the powerful self-learning characteristics of computers to quickly identify and classify the abstract features of a large amount of data, greatly improving the efficiency and accuracy of real-time leakage detection in the hydraulic system. Based on the study of small internal leakages in hydraulic cylinders, this paper adds multiple neural network types to analyze and predict the same leakage data. Additionally, the traditional pressure signal is transformed into a strain signal through a strain gauge, which reduces the absolute threshold of detection.

Introduction to the Principle of Measuring Small Internal Leakages of Hydraulic Cylinders
An innovative embedded leakage measurement system to detect a small internal leakage in hydraulic cylinders is proposed here. The entire measurement system mainly includes the following modules: a hydraulic cylinder leakage measurement device, signal conversion device, data receiver, data display and storage module and prediction module. The flow chart of the measurement principle is shown in Figure 1.
After the system starts running, the device for measuring the leakage in the hydraulic cylinder starts to simulate an internal leakage. At this time, the hydraulic oil flow signal is continuously generated; the signal conversion device converts the flow signal into a strain signal in real time and transmits the strain signal to the strain signal receiver for signal amplification and filter processing. Then, the computer's measurement and control software displays and saves the processed strain signal, and finally the data are input into the neural network for training and prediction.

Simulation of an Internal Leakage: Measurement Device
The definition of a small internal leakage depends on the specifications of the hydraulic cylinder. The measuring device designed in this paper was applied to a hydraulic cylinder with an inner diameter of 125 mm. The experimental results show that the leakage flow in the hydraulic cylinder of this specification was between 100 mL/min and 200 mL/min. The oil measuring device is shown in Figure 2. The function of this device was to collect the leaking hydraulic oil, and the maximum measuring flow could be up to 300 mL/min. We placed the device in the piston; then, the leaked hydraulic oil entered the oil-collecting groove on the side of the piston and flowed through the device, and the oil inlet of the device was equipped with a one-way valve, so that the leaked hydraulic oil could only enter from one side. The influence of the oil pressure flow direction caused by the bidirectional movement of the piston was avoided. The installation position is shown in Figure 3. As shown in Figure 2, a high-sensitivity resistance strain gauge was installed in the place marked 2. The deformation of the strain gauge caused the strain gauge-sensitive grid to bend and deform, which caused the resistance value to change. The generated deformation signal was expressed by the amount of resistance change; that is, the amount of strain was expressed by the amount of resistance change. At the same time, the strain gauge was fixed on the copper plate marked 3 to prevent the strain gauge from being damaged or falling off due to the long-term impact of hydraulic oil, ensuring the sustainability of the experiment.

Principle of Strain Signal and Flow Conversion
Most hydraulic cylinders are developing in the direction of lighter weight and convenience. Therefore, the internal leakages of small and medium-sized hydraulic cylinders are very small, which leads to a relatively long time span and poor time continuity for these leaks. Being able to accurately and quickly detect such a small flow change is very important for the selection of the detection device. In this research, we selected high-sensitivity resistance strain gauges with a Wheatstone single-arm bridge with a simple structure, high accuracy and high sensitivity. The specific strain-flow conversion principle is as follows: the leaking hydraulic oil impacts and presses against the strain gauge, which causes the strain gauge to deform. The strain gauge consists of a lead wire connected to an external fixed equivalent resistance, forming a Wheatstone bridge and a dynamic strain gauge. The small pressure signal is transmitted to the dynamic strain gauge through the lead wire, and the dynamic strain gauge amplifies the strain signal and inputs it into the computer. The Wheatstone bridge consists of four bridge arms with the same resistance value, of which three bridge arms have a fixed resistance value and the other one is a varistor composed of strain gauges. The strain gauge supplies voltage to the input of the bridge. When the strain gauge is not deformed, the bridge is balanced and the output voltage is 0; the strain gauge is deformed after being impacted by hydraulic oil, the resistance value changes, and the balance of the bridge is destroyed. The voltage change signal is amplified and transmitted to the computer, and then the strain signal is collected, stored and processed by the computer, as shown in Figure 4.

Data Collection and Processing
The data collection was mainly completed by the data receiver, data display and storage module. The DC-204R dynamic strain gauge was responsible for collecting, receiving and amplifying the strain data, and the PC terminal was responsible for displaying and saving the strain data. At the same time, the PC used the DC-7204 measurement and control software to visualize the data and record the maximum/minimum value of the data. The measurement and control software was also able to display strain data in real-time in the form of waveform graphs, and experimenters were able to monitor the trend of the data at all times. The measurement and control software window is shown in Figure 5. According to the experimentally measured leaking hydraulic oil volume and strain value, as shown in Figure 6, a curve could be obtained from the actual measured strain value and each internal leakage data point. The mathematical model of the curve could be described as a polynomial: From this formula, it can be seen that the relationship between internal leakage and strain value is nonlinear. A neural network has a strong nonlinear mapping ability. It can be seen that the overall trend of the strain value was similar to a step curve, and there was a peak value from the beginning of the leakage to the continuous leakage. This was because, when the hydraulic oil impacted the strain gauge, there was a short-term inertia effect from static to deformation, causing the strain. The sheet had a short-term deformation increase, and then the hydraulic oil continued to be output stably and the deformation of the strain gauge tended to be stable.

Principles of Neural Network Prediction
From the MP neuron and Hebb learning rules in 1940 to the Hodykin-Huxley equation, perceptron model and adaptive filter in 1950 and to the self-organizing mapping network, neurocognitive machine and adaptive resonance network in 1960, neural computing models have penetrated into various fields, such as signal processing, computer vision, natural language processing and optimized calculations, and have had significant achievements in these fields. At present, hundreds of models of neural networks have been developed, and these have had very successful applications in technical fields such as handwriting recognition, image annotation, semantic understanding and speech recognition and equipment fault diagnosis.

Principles and Models of Convolutional Neural Networks
The theory of convolutional neural networks was first proposed by Fukushima in 1980, and the theoretical model at that time was called Neocognitron [15]. It can be regarded as the first realization of the convolutional neural network. In the 1990s, convolutional neural networks gradually developed into the fields of speech recognition, object detection and face recognition. The convolutional neural network is a deep neural network with a convolutional structure that can effectively reduce the amount of memory in an operation. The three most representative core ideas are the local receptive field, weight sharing and pooling, which can greatly reduce the number of network parameters and alleviate the over-fitting problem of the model [16]. The most typical example is lenet-5, which is used to recognize handwritten digits on most bank checks in the United States [17]. A convolutional neural network is mainly composed of an input layer, hidden layer (convolutional layer, pooling layer, fully connected layer) and output layer, as shown in Figure 7: The input layer is responsible for receiving a large amount of non-linear input information. The hidden layer is a layer composed of many neurons and links between the input layer and the output layer. There can be one or more hidden layers. The convolutional layer is composed of a parameter learnable volume. The product core (the length and width are variable, and the depth needs to be the same as the number of channels in the input layer) mainly performs convolution operations and can enhance the characteristics of the original information and reduce noise. The mathematical model of a convolution that is in operation to obtain a feature map is shown in Formulas (1) and (2) [18]: where X l j is the jth feature map of the lth convolutional layer, and Z l−1 j is the net activation of the jth channel on the jth convolutional layer. The calculation method is that each feature map Z l−1 j of the previous layer is convolved by a learnable convolution kernel, and then the overall sum is added with an offset, and finally the feature map is output through the activation function. K l ij is the convolution kernel, b l j is the bias, and f (·) is the activation function.
The pooling layer (down-sampling layer) mainly performs the down-sampling of features. This process can extract the largest feature of the information, ignoring the positional relationship of its features, which can effectively reduce the amount of data in the network and achieve the goal of dimensionality reduction and time saving. At the same time, the over-fitting effect is controlled to a certain extent. In the fully connected layer, neurons are completely connected to the input variables and play the role of the "classifier" in the entire convolutional neural network.
Minimizing the loss function L(W, b) is the ultimate goal of training the neural network. After the input X 0 is processed through the forward channel, the difference between the expected value and the loss function calculated by the loss function is called the "residual".
The commonly used optimization method of a convolutional neural network in the training process is the gradient descent method. The residual error is back-propagated in the neural network through the gradient descent method, and the trainable parameters (W and b) of each layer are updated. The learning rate parameter (η ) is used to control the strength of the residual backpropagation, and the updated Formulas (3) and (4) for the weights W and b are as follows [19]:

BP Neural Network Principle and Model
The BP (back propagation) neural network is a concept proposed by a group of scientists led by Rumelhart and McClelland in 1986. The neural network is an algorithm trained according for error back propagation (referred to as the BP algorithm) [20] . The BP network is a forward-feedback network and is currently the most widely used network. The BP neural network mainly includes an input layer, an output layer and several (one or more) hidden layers. The learning process is mainly divided into two stages: the first process is the forward propagation process, in which the input signal passes through the input layer pass to the hidden layer, a series of calculations is performed in the hidden layer, and finally the obtained value is passed out through the output layer. In the forward propagation process, the weight is fixed, and the second process is the back propagation process. If there is a difference (that is, an error) between the actual output value and the expected output value, the corresponding difference is calculated using the layer-by-layer recursive method, and the weight is continuously adjusted according to the difference. The neural network continuously corrects the weights through continuous training, the final error becomes increasingly small, and the output value moves increasingly close to the expected value to achieve the purpose of prediction. A multi-layer feedforward network structure based on the BP neural network algorithm is shown in Figure 8 [21].
The mathematical model of this approach is as shown in Formula (5): This function f (x) is a simple sigmoid function, as follows: Combining the above two formulas can result in Formula (7): The training of the BP neural network is divided into the multi-layer forward propagation stage and back propagation stage. Multi-layer forward propagation calculates the output value of each layer of nodes, while back propagation uses the error of the output layer to estimate the error of its direct predecessor layer and uses this new error to calculate the error of the previous layer, so that the error estimates for all layers can be obtained. The weight update reduces the error. The weight update formula is as follows: where δ is the learning rate, E is the error between the network output and the expected output, and t is the number of network layers..

T-S Fuzzy Neural Network Principle and Model
The T-S fuzzy neural network is composed of two parts: the antecedent network and the subsequent network [22]. The antecedent network is used to match fuzzy rules, and the subsequent network is used to generate fuzzy rules. An antecedent network includes an input layer, fuzzification layer, fuzzy rule calculation layer and normalization layer. The subsequent network is composed of r parallel sub-networks with the same structure, and each sub-network can produce an output. The third layer of the sub-network has only one output node, which represents the final network output [23]. The network structure diagram is shown in Figure 9.
The principle of the algorithm is shown below. The error calculation model is shown in Formula (9): where y d is the expected output and y c is the actual output.
The coefficient correction is shown in Formula (10): where P i j is the network coefficient, α is the learning rate, X j is the input parameter, ω i is the product of the membership degree of the input parameter, and t is the number of network layers.
The parameter correction is shown in Formulas (11) and (12): where P i j is the network coefficient, α is the learning rate, C i j is the center of the membership function, b i j is the width of the membership function, and t is the number of network layers. Figure 9. T-S fuzzy neural network structure diagram.

Elman Neural Network Principle and Model
In 1990, JL Elman proposed the Elman neural network for speech processing problems [24]. This is a typical partial regression network. The basic Elman neural network consists of an input layer, a hidden layer, a connection layer and an output layer. Com-pared with the BP network, it has one more connection layer in the structure to form local feedback. The transfer function of the connection layer is a linear function, but there is an extra delay unit, so the connection layer can memorize the past state, such as related data, operators, etc.; at the next moment, it is used as the input of the hidden layer together with the input of the network to give the network the function of dynamic memory. The hidden layer unit has two types of activation functions: linear and non-linear. Usually, the activation function is a Sigmoid non-linear function. The network structure is shown in Figure 10.
The mathematical model of the neural network is shown in Formulas (13)- (15): where u(·) represents the input vector, x(t) is the middle layer node unit vector, y(t) is the output node vector, x c (t) is the feedback state vector, t is the number of network layers, the subscript c corresponds to the number of hidden layers, g(·) is the transfer function of the output neuron, and f (·) is the transfer function of the middle layer neuron. The S-function is used often.

Experimental Data Analysis and Simulation
A total of five sets of data were obtained in this experiment. Each set of data contained about 100,000 strain values. The five experiments produced nearly 570,000 strain values. Of these, the fifth experiment was the least affected by the outside world, and the strain curve was the smoothest. The 5000 strain values generated at the intermediate moment were used as the data set, and the training set, test set and verification set were given 4000, 500 and 500 values at a ratio of 8:1:1.
In terms of hardware, a laptop equipped with an Intel(R)Core(TM)i7-9750H CPU was selected. In terms of software, MATLAB2018a was selected for the neural network creation and prediction. To collect data statistics, Excel software was selected for processing. The Origin 2018 64 bit software was selected for the curve drawing part, and the four neural network simulation prediction and actual leakage curves are shown in Figure 11 below.

Convolutional Neural Network Simulation
Strain data were collected as input values. Due to the excessive data, 4096 continuous strain values were taken as sample data. Of these, the training set and the test set were given values according to a ratio of 5 to 1. Since the input of the convolutional neural network is a two-dimensional matrix, the one-dimensional strain value was converted into a two-dimensional matrix, which was used as the input of the convolutional neural network.
The convolution kernel of the convolution layer had a size of 3 × 3, the convolution kernel of the sampling layer had a size of 2 × 2, and the selected activation function was the Relu function. During training, the learning rate was set to 1, the batch number was 80, and the training stopped when the error was less than 0.005. Finally, the test set was input to the trained neural network, and the predicted internal leakage could be obtained.

Simulation of BP Neural Network
We created five samples, where each sample contained 1000 strain data, for a total of 5000 strain data; then, we solved the eigenvalues of each sample (maximum, minimum, average and mean square value). Finally, 100 four-dimensional feature matrices were used as the input value of the BP neural network; the output value was 1, which iswasthe amount of internal leakage.
We randomly divided the data in the sample into a training set and a test set, created a BP neural network, set the maximum number of iterations to 200 and stopped the training when the error was less than 0.001. The data of the training set were input into the neural network for training. After each training, the error between the simulated output value of the network and the expected output value was calculated; the weights were continuously updated to reduce the error, and the error was minimized through repeated training. Finally, the data of the test set were input into the trained neural network to obtain the final internal leakage prediction value.

T-S Fuzzy Neural Network Simulation
We constructed a T-S fuzzy neural network model, set the maximum number of iterations to 200, set the error to 0.005, input the training set into the model for training and selected tramf as the training membership function. The number of network nodes was up to 35 and the number of fuzzy rules was 9, while the training speed was slow. After the training was completed, we saved the model and used the evalfis function to import the test data into the model, and then finally output the prediction results of internal leakage.

Elman Neural Network Simulation
We used the Elmannet function provided by the MATLAB Neural Network Toolbox to create an Elman neural network. The maximum number of iterations was 200, the error was set to 0.005 and the maximum number of verification failures was set to 5. As the training function, we selected the tradingdx function. Input the samples of the above training set into the neural network for training and finally input the data of the test set into the trained neural network to obtain the final internal leakage prediction value.
The prediction results of the four neural networks are shown in Table 1.

Model Evaluation Indicators
The neural network model used in this simulation mainly solved the linear regression problem for continuous variables; that is, our approach was based on a large number of data sets for the adjustment of parameters in a specific problem to establish a reliable prediction model. The model brought the predicted value closer to the real value. The evaluation method of the regression model was mainly based on the indicators RMSE, RAE and R 2 , as shown in Formulas (16)- (18): Of these, P i is the predicted target and a i is the actual target.ā is the average of the true values. Both RMSE and RAE are error calculation formulas: the smaller the value, the higher the accuracy of the model. The range of R 2 is between 0-1; the closer to 1, the higher the accuracy of the model. Table 2 lists the comparison results of the RMSE, RAE and R 2 values of the four models. Figure 12 shows the predicted leakage of the four models.

Comparison of Simulation Results
According to the data in Table 2 and Figure 11, the four neural network models had predictive functions and were able to better fit the preset target leakage curve. It can be seen that CNN and BPNN had the highest prediction accuracy. The R 2 of CNN was equal to 1, the R 2 of BPNN was 0.9973, and the R 2 values of the T-S fuzzy neural network and Elman neural network were 0.7848 and 0.7015, respectively. It can also be seen from the prediction curve that CNN had the highest degree of fit.
In summary, in terms of predicting internal leakage, CNN and BPNN can be used as the main models of internal leakage prediction modules, as they can reflect the relationship between the strain value of the strain gauge and the leakage in the hydraulic cylinder well.

Conclusions
In this work, the measurement, modeling and simulation of a small amount of internal leakage in a hydraulic cylinder are studied, and the following conclusions are obtained: (1) A system for measuring a small internal leakage in hydraulic cylinders was constructed, which was embedded and has high measurement accuracy and could perform measurement in real time in the operation of the hydraulic cylinder, breaking the traditional static measurement method. Four kinds of neural networks were used for simulation prediction. Compared with other papers, this plays a role in strengthening the demonstration effect and further verifies the difference and accuracy of various neural networks for internal leakage prediction; (2) By simulating a small internal leakage in a hydraulic cylinder, a small leakage flow signal was converted into a deformation signal and analyzed, and the mathematical model of the strain value and flow was established. Through the training of neural network and deep learning, the purpose of predicting the actual small leakage flow was achieved; (3) A device for measuring small flow was developed and can be widely used in various equipment for measuring small flow; (4) The results show that CNN and BPNN neural networks can be used to predict the amount of small leaks quickly and accurately and also provide technical theoretical support for the intelligent testing of other small flow components; (5) In an actual industrial production process, the problem of leakages in hydraulic cylinders is unavoidable. The approach developed in this study can reflect the internal leakage status of a hydraulic system in real time. The operator can determine a leakage in a hydraulic cylinder in a timely manner, greatly reducing the occurrence of production accidents and improving productivity.
Author Contributions: Conceptualization, Y.G.; methodology, Y.G. and G.X.; software, G.X.; resources, L.Z.; writing-original draft preparation, G.X. and Q.L.; writing-review and editing, Y.G.; data curation, Q.L. All authors have read and agreed to the published version of the manuscript.
Funding: This research was funded by National Natural Science Foundation of China grant number 51975425.