Academic Journal of Science and Technology ISSN: 2771-3032 | Vol. 13, No. 3, 2024 78 Online Prediction of Tool Life Based on Multi‐source Data Fusion Ling He1, Yun Xu1, *, Qi Li2 1School of Mechanical Engineering, Sichuan University of Science & Engineering, Yibin Sichuan 644000, China 2Sichuan Changzheng Machine Tool Group Co.,Ltd., Zigong Sichuan 643000, China *Corresponding author Abstract: To address the challenges of difficult data acquisition and low prediction accuracy in tool life prediction, a method for data collection from FANUC numerical control machine tools and prediction of tool life based on the SSA-BP neural network is proposed. Data such as tool running time, spindle load rate, spindle load, X-axis load rate, Y-axis load rate, Z-axis load rate, X-axis current, Y-axis current, and Z-axis current are collected. By optimizing the core parameters of the BP neural network with the SSA algorithm, a tool life prediction model is constructed. Compared with traditional BP neural networks and GWO-BP neural networks, experimental results show that this model has the closest tool life prediction values to the actual values and better network stability, making it more suitable for tool life prediction. Keywords: Tool Life Prediction; Data Acquisition; BP Neural Network; Sparrow Search Algorithm. 1. Introduction Cutting tools, as important executive components in CNC machining, directly affect the precision of the machined workpieces. Research indicates that the reasonable utilization rate of CNC machining tool life is only 50-80%, and if tools malfunction, the downtime of the machine tools can account for 10-40%, with processing costs as high as 30% [1]. Therefore, predicting the life of cutting tools is extremely important. Shen Yujie [2] and others, in response to the low accuracy of single sensor data, proposed a CNN-GRU neural network multi-source information fusion model for predicting the remaining life of cutting tools. The experimental results verified by the public tool dataset PHM2010 showed that the CNN-GRU model improved the prediction accuracy by 21% and 22% compared to LSTM and GRU models, respectively. Liu Sichen [3] and others, in order to improve the accuracy of tool wear prediction, proposed a multi-sensor fusion based on vibration and current, using a deep neural network model to predict the life of cutting tools. The prediction of the remaining life of cutting tools was verified through the public dataset of the "Empowerment and Intelligence" second industrial big data innovation competition guided by the Ministry of Industry and Information Technology, and the results were relatively accurate. Wang Yiwei [4] and others, in response to the low data utilization rate, proposed a multi- channel signal fusion and Bayesian updating method for predicting the remaining life of cutting tools. This method effectively avoids dependence on a large amount of data for training and has achieved good prediction accuracy verified by the PHM2010 public dataset. Chen Xiaokang [5] and others integrated a Gaussian process regression (GPR) model prediction method, which was verified by the PHM2010 public dataset and achieved good prediction accuracy. Feng Doudou [6] extracted features from the signals in the PHM2010 public dataset and used the Markov chain Monte Carlo sampling algorithm to iteratively predict the parameters of the tool life degradation model, predicting the remaining life of the tool at various times. Huang Xian Zhen [7] optimized the parameters of the SVR model through the random fractal search algorithm, and verified it with the PHM2010 public dataset, achieving prediction of the remaining service life of cutting tools in a small sample space. Li Tao [8] proposed a multi-scale recurrent convolutional neural network (MSRCNN) for predicting the remaining life of high-speed milling tools, verified by the PHM2010 public dataset, and the MSRCNN model has higher accuracy and faster convergence than the CNN and RNN models. Hou Chunming [9] and others proposed a multi-task joint learning model based on the Transformer encoder and custom gate control (TECGC) for simultaneously predicting the remaining life and wear of cutting tools. Using the PHM2010 public dataset, the accuracy of the remaining life and wear amount of the cutting tools was verified. Mu Quanlin [10] and others proposed establishing a non-linear relationship between high- dimensional feature vectors and tool wear based on the evolutionary connection system (ECOS), and real-time prediction of tool wear using incremental learning algorithms. Finally, the wear values predicted by ECOS were used as the hidden state sequence of the hidden semi-Markov model (HSMM), and the stability of the HSMM model for predicting the remaining life of cutting tools was verified by the PHM2010 public dataset. Chen Keyu [11] proposed a CNN- BiLSTM neural network for predicting the remaining service life of machining tools, and verified the cutting tool vibration signals in the public dataset of the "Empowerment and Intelligence" second industrial big data innovation competition guided by the Ministry of Industry and Information Technology, achieving high-precision prediction results for the remaining service life. Although the aforementioned studies mostly utilize deep learning methods for tool life prediction, they primarily focus on research using public datasets or rely on externally installed vibration sensors, cutting force sensors, acoustic emission sensors, and current sensors. This approach requires a higher investment and is less practical. In contrast, collecting data from built-in sensors of CNC machines can save costs and reduce the hassle associated with installation. Therefore, this paper proposes a method to collect multi- 79 source data during the machining process of CNC machines and employs the SSA-BP neural network to predict the remaining life of the tool. By comparing the GWO-BP and traditional BP neural networks, this model demonstrates better practicality and performs online data collection for tool life prediction. 2. Milling Experiment 2.1. Experimental Condition Plan Setup The experiment was conducted on an XH718 numerical control machine tool, with cast iron as the workpiece material and cemented carbide inserts APMT113504-H2 as the cutting tool material, as shown in the collection platform in Figure 1. The experiment was carried out on a three-axis numerical control FANUC-0i-MF machining center. The FOCAS function library provided by FANUC Corporation was utilized to collect data from the machining process, and TCP/IP was used for communication between the PC and the machine tool, as shown in the connection mechanism in Figure 2, to achieve real-time data collection. connection status indicator light network cable PC data acquisition Figure 1. Data Acquisition Experimental Platform for CNC Machine Tools Personal Computer Application FOCAS FWLIB64.DLL TCP/IP stack Ethernet Board CNC Data Window Functions OPEN CNC I/F TPC/IP Stack OPEN CNC I/F Personal Computer Proxy functions of data window functions Ethernet Board Bodies of data window functions Requst Packet R esponse Packet Ethernet Local Bus Figure 2. Connection Method between Machine Tool and PC The machining cutting parameters are as shown in Table 1. The acquisition of signal stages mainly includes nine data types: tool running time, spindle load rate, spindle load, X- axis load rate, Y-axis load rate, Z-axis load rate, X-axis current, Y-axis current, and Z-axis current, with a collection frequency of once every 5 seconds. Table 1. Milling Process Parameters milling parameters value Spindle speed 950r/min Feed rate 1500mm/min Milling depth 1mm Milling width 5mm 80 2.2. Data Preprocessing and Setting of Tool Life Labels Due to the fact that the data originates from actual industrial processing, there are numerous anomalies present in the data. As shown in Figure 3, this is the raw data for Tool A, with the red box highlighting the anomalous data. Anomalous values refer to signal points that have unreasonable assignments, which occur for the following reasons: (1) The current becomes very large at the moment the tool cuts into the workpiece and the moment the tool cuts past the workpiece. (2) During processing, the tool is not always in contact with the workpiece, resulting in the tool running empty, which makes the current very small. Anomalous data can significantly affect the overall distribution of the data, leading to the tool life prediction model learning incorrect information. Therefore, it is necessary to preprocess the originally collected data. In this paper, the method for handling anomalous values utilizes the 3𝜎 criterion and the setting of a spindle load threshold method [11]. The spindle load threshold method involves deleting data where the load is less than 500, indicating that the tool is running empty. The current signal after the anomalous value operation is shown in Figure 4. This current signal more accurately reflects the signal fluctuations during normal processing. a.X-axis servo current b.Y-axis servo current c.Z-axis servo current Figure 3. Data of Currents in Each Axis Before Data Processing a.X-axis servo current b.Y-axis servo current c.Z-axis servo current Figure 4. Data of Currents in Each Axis After Data Processing This paper takes the data collected from the entire machining process of a brand-new tool to the point of tool failure as the basis for tool life. The setting of tool life labels is done before the preprocessing of the tool data, where the life percentage is set as the life label. This method of label setting transforms the operational life of the equipment into a percentage, representing the process from a brand-new tool to one that is completely degraded. Since the service life of tools of exactly the same specification is not consistent, each tool's life data label is set as a value between 0-1, evenly distributed among each set of data [12]. 3. Tool Life Prediction Algorithm 3.1. BP Neural Network Prediction Algorithm The BP (Backpropagation) neural network [13] is a multi- layer feedforward artificial neural network that is trained through a supervised learning algorithm known as backpropagation. The BP neural network mainly consists of an input layer, hidden layers, and an output layer, with each layer comprising multiple neurons. Each neuron can receive input from the previous layer, transform the input signals through an activation function, and then pass them to the next layer. The characteristics are: signals are propagated forward, while errors are propagated backward. It has strong nonlinear mapping capabilities and a flexible network structure, exhibiting strong generalization and fault tolerance, allowing for significant errors or even individual mistakes in input samples. The BP neural network does not require any prior formulas and can automatically summarize the functional relationships between data through learning, making this modeling method very effective. However, there are issues such as the training process of the BP neural network being potentially very time-consuming, especially when dealing with large-scale datasets, which may take hours or even days to achieve satisfactory results. It is also prone to getting stuck in local optima. Since the BP algorithm essentially uses gradient descent, the objective function to be optimized is 81 very complex, leading to low training efficiency and a lack of global search capability, which can easily result in the training being trapped in local areas, leading to local optima and significant model bias. The BP neural network used in this paper is shown in Figure 5. spindle load spindle load ratio tool running time X-axis current Y-axis current Z-axis current Input layer hidden layer output layer . . . tool life. . . . . . hidden layer Figure 5. Tool Life Prediction Based on BP Neural Network 3.2. Sparrow Search Algorithm To enhance the global search capability and improve the accuracy of the BP neural network algorithm, the Sparrow Search Algorithm (SSA) [14] is utilized to optimize the weights and biases. The SSA is a novel swarm intelligence optimization algorithm that simulates the foraging behavior and anti-predation behavior of sparrows. The basic principle is as follows: In SSA, the position of each sparrow corresponds to one solution. During the foraging process, sparrows exhibit three types of behaviors: acting as discoverers to search for food; the position update of discoverers can be represented by the following formula: where 1 ,X t i j  is the position information of the i sparrow in the population at the t iteration in the search space of dimension j; ii is the sparrow index; maxiter is the maximum number of iterations; δ is a random number between (0, 1]; Q is a random number following a normal distribution; 2R is an alert value [0,1]; S is a safety value [0.5, 1]. L is a 1×d matrix with internal elements being 1, and d is the dimension. When R2n/2, the ii-th follower, unable to acquire food and with a low energy level, needs to move to another area to forage; when i≤2n, the i follower will follow the foraging center of the discoverers and forage randomly near the center. Usually, the proportion of sentinels in the sparrow population is only 10% to 20%, and their position update is as follows:   best , , , 1 , t t t i j best i g t t i j wrostt i j i g i w X X X f ft i j X X X K f f f f X                      In the formula: t bestX represents the current global best position; β is a random number following a standard normal distribution, K is the direction of sparrow movement, and both β and K are step size control parameters; ε is a constant used to prevent division by zero; if is the fitness value of the i sparrow; gf and wf are the current best and worst fitness values, respectively. When if > gf , the sparrow is at the edge of the population and is more susceptible to predators; when if = gf , the sparrow is at the center of the population and randomly moves closer to other sparrows; when if < gf , the scout remains inactive. 3.3. Construction of Tool Remaining Life Prediction Model Based on SSA-BP The specific steps for constructing the tool life prediction model based on the SSA-BP neural network are as follows: Step 1: Load the dataset, dividing it into a training set (2/3) and a testing set (1/3). That is, use the data from the first two tools for training and the data from the last tool for testing. Normalize the features of the training and testing sets to eliminate the impact of different scales. Step 2: Define the structure of the BP neural network and the settings for learning parameters. This paper uses a BP neural network structure that includes 2 hidden layers and 1 output layer. The parameter settings are as follows: the first hidden layer has 32 neurons with the Sigmoid activation function, the number of neurons in the second layer is determined by the optimization algorithm, also with the Sigmoid activation function, and the output layer includes 1 neuron representing the model's output. The model learning rate is 0.001. Step 3: Train the BP neural network. During the training process, the network continuously adjusts the weights and thresholds between layers to minimize the prediction error. The training process will continue until the maximum number of training iterations is reached or other preset stopping 82 conditions are met. Step 4: Output prediction results: After completing the training, use the testing set data to make predictions with the BP neural network. The prediction results need to be de- normalized to restore the original data values. Step 5: Set the parameters for the SSA algorithm. Determine the sparrow population size to be 14, the number of information exchanges between sparrows to be 30, the proportion of discoverers to the total sparrow population to be 0.20, and set the alert value and the number of sentinels. Step 6: Invoke the SSA algorithm to optimize the neural network parameters. Step 7: Use the optimized BP neural network for training and stop the computation to output the results. The algorithm flow is shown in Figure 6. SSA-BP neural network training Determine the structure of the BP neural network algorithm Weights and thresholds of the BP neural network after SSA optimization Initialize the weights and thresholds of the BP neural network structure SSA parameter initializationnormalize the input data update the discoverer's position update the follower's position update the sentinel's position Satisfy the stopping criteria? predicted remaining life of the tool start end Y N SSA part BP neural network part Figure 6. SSA-BP Algorithm Flowchart 3.4. Model Performance Validation In practical applications, multiple metrics are often combined to assess model performance in order to obtain a comprehensive evaluation. Therefore, in this paper, five main evaluation indicators are used to assess the model: Coefficient of Determination (R²), Explained Variance Score (EVS), Mean Squared Error (MSE), Mean Absolute Error (MAE), and Mean Absolute Percentage Error (MAPE). In the formula: n is the number of samples, iy is the i observed value, iy  is the i predicted value, and y is the average value of the parameters. When evaluating the performance indicators, the closer R² and EVS are to 1, the better, while the closer MSE, MAE, and MAPE are to 0, the better. 4. Prediction Experiment Results and Analysis of Tool Remaining Life Three brand-new tools of the same specification were sequentially started for normal machining operations, and data collection was stopped when the tool life ended. The working life of Tool A was 167.5 minutes, Tool B was 205.3 minutes, and Tool C was 210.8 minutes. The preprocessed data of Tools B and C were used as the training set, and the preprocessed data of Tool A were used as the testing set. To verify the characteristics of the SSA-BP neural network tool remaining life prediction model, the GWO-BP neural network prediction model and the BP neural network prediction model were selected for simulation experiments. The mean squared error (MSE) output by the neural network models was used as the fitness function for comparison. The BP neural network is a neural network model with strong complex model analysis capabilities. In this paper, the number of input layer neurons is 9 features, which are cutting time, spindle load rate, spindle load, X-axis load rate, Y-axis load rate, Z-axis load rate, X-axis current, Y-axis current, and Z-axis current. For the hidden layer, there are 2 hidden layers with 32 neurons each; the output layer outputs the tool life prediction value. The training number is 100 times, the learning rate is 0.001, and all other values are default. The fitness curve is shown in Figure 7a. The parameter settings for the GWO-BP neural network prediction model are: 10 grey wolves, with a maximum of 20 iterations. The fitness curve is shown in Figure 7b. The parameter settings for the SSA-BP neural network prediction model are: a sparrow population size of 14, a maximum of 30 iterations, 20% discoverers in the population, and a maximum safety threshold of 0.7. The fitness curve is shown in Figure 7c. 83 a.BP model b.GWO-BP model c.SSA-BP model Figure 7. Fitness Curves of Various Models The relative errors of the three prediction models and the comparison between predicted values and actual values are shown in Figures 8 and 9. From Figures 8 and 9, it can be seen that the GWO-BP model has the largest error fluctuation range, followed by the BP model, while the SSA-BP model has the smallest error fluctuation range. Therefore, the SSA- BP model's prediction performance is significantly better; its predicted values are closer to the actual values, with a smaller error fluctuation range and higher prediction accuracy, resulting in a better fitting effect. Figure 8. Prediction Errors of Various Models a.BP model b.GWO-BP model c.SSA-BP model Figure 9. Prediction Errors of Various Models 84 Figure 10. Tool Condition Table 2 presents a comparison of five evaluation indicators for the BP neural network, SSA-BP neural network, and GWO-BP neural network. Therefore, the SSA-BP neural network prediction model has higher predictive accuracy than the BP neural network prediction model and the GWO-BP neural network prediction model. Specifically, the coefficient of determination of the SSA-BP model increased by 4.32% and 6.18%; the explained variance score increased by 0.22% and 3.13%; the mean squared error decreased by 63% and 71%; the mean absolute error decreased by 44.26% and 44.5%; the mean absolute percentage error decreased by 0.1097% and 0.0826%. From the above data, it is evident that the SSA-BP model has higher precision than the BP model and the GWO-BP model. The coefficient of determination of the SSA-BP neural network model reached 0.9756, which is closer to 1 than the other two models, indicating that this model has a better fitting effect. The actual state of the tool is shown in Figure 11. Figure 11. Accuracy Comparison of Various Models Table 2. Evaluation Metrics Model R2 EVS MES MAE MAPE BP 0.9335 0.9804 0.006 0.0671 0.2056% SSA-BP 0.9756 0.9826 0.0022 0.0374 0.0959% GWO-BP 0.9153 0.9518 0.0076 0.0674 0.1785% 5. Conclusion (1) This paper starts from the data source of the machine tool, connects to the numerical control machine tool through communication protocols to achieve real-time data acquisition, mainly collecting the cutting time of machine tool tools, spindle load, spindle load rate, X-axis current information, Y-axis current information, Z-axis current information, X-axis load rate, Y-axis load rate, and Z-axis load rate to provide data for the tool life prediction model. (2) The initially collected data is preprocessed and labeled to construct an SSA-BP tool life prediction model, which optimizes the parameters of the BP neural network model through the Sparrow Search Algorithm (SSA). To explore the accuracy of the SSA-BP model, BP and GWO-BP are used as comparison models. The experimental results show that compared to BP and GWO-BP, the neural network prediction accuracy is increased by 4.32% and 6.18%, and the mean square root error is reduced by an average of 63% and 71%, respectively. The SSA-BP prediction model's five performance indicators (R², EVS, MSE, MAE, MAPE) are superior to other prediction models, and the method is significantly effective in all indicators. Clearly, the SSA-BP model can achieve better prediction performance and has certain application value in tool life prediction. Acknowledgments Fund project: Zigong City Science and technology Bureau school-local cooperation project: Development of aviation five-axis bridge gantry processing equipment (self-study [2022]43 References [1] Liu C Q, Li Y G, Hua J Q, et al. Real-time cutting tool state recognition approach based on machining features in NC machining process of complex structural parts[J]. International Journal of Advanced Manufacturing Technology, 2018, 97(2): 229-241. [2] Shen Yujie, Sun Xiangbin, Liu Lunming, et al. Tool remaining life prediction based on multi-source information fusion[J]. Combined Machine Tools and Automatic Machining Technology, 2022, (09): 143-146+150. 85 [3] Liu Sichen, Yang Frain, Yang Jun. Tool remaining life prediction based on multi-sensor fusion[J]. Vibration and Shock, 2021, 40(17): 47-54. [4] Wang Yiwei, Deng Lei, Zheng Lianyu, et al. Tool remaining life prediction method based on multi-channel fusion and Bayesian theory[J]. Journal of Mechanical Engineering, 2021, 57(13): 214-224. [5] Chen Xiaokang, Tu Xuan, Xu Vidong, et al. Tool life prediction based on Bagging ensemble Gaussian process regression model[J]. Manufacturing Technology and Machine Tool, 2020, (12): 110-115+121. [6] Feng Doudou. Research on tool wear and remaining life prediction method based on multi-source information fusion[D]. Xi'an University of Technology, 2023. [7] Huang Xian Zhen, Sun Liang Shi, Gao Wei, et al. High-speed milling tool remaining service life prediction based on SFS- SVR[J]. Journal of Northeastern University (Natural Science), 2023, 44(06): 824-831. [8] Li Tao. Research on tool wear status monitoring and remaining life prediction[D]. East China Jiaotong University, 2022. [9] Hou C, Zheng L. A Multi-Task Joint Learning Model Based on Transformer and Customized Gate Control for Predicting Remaining Useful Life and Health Status of Tools[J]. Sensors, 2024, 24(13): 4117. [10] Lin M, Wanqing S, Chen D, et al. Evolving connectionist system and hidden semi-Markov model for learning-based tool wear monitoring and remaining useful life prediction[J]. IEEE Access, 2022, 10: 82469-82482. [11] Chen Keyu. Method for predicting the remaining service life of machining tools based on integrated CNN-BiLSTM[D]. Hunan University of Technology, 2023. [12] Liu Rui, Wang Mei, Chen Yong. Research on milling tool wear monitoring and remaining life prediction method[J]. Modern Manufacturing Engineering, 2010, (06): 102-105. [13] Ding Yi, He Weiping, Zhang Wei, et al. Tool life prediction model based on BP neural network[J]. Aeronautical Manufacturing Technology, 2010, (08): 93-96. [14] Wang Ershen, Wang Huan, Lei Hong, et al. Optimization algorithm for ARAIM fault subset based on sparrow search algorithm[J]. Journal of Beijing University of Aeronautics and Astronautics, 2024, 50(07): 2066-2073.