Research on Thermal Error Modeling Method of Machine Tool Spindle Based on Optimized BP Neural Network

Addressing the limitations of the single-temperature measurement point monitoring for detecting the temperature changes in the CNC machine tool spindle, and the shortcomings of the thermal error model based on back propagation neural network (BP) in accuracy, convergence and robustness. This paper studies the thermal error identification model and method of spindle based on multiple temperature sensors. An Adaptive particle swarm algorithm-back-propagation neural network (IAPSO-BP) model for thermal error identification of principal axes is proposed. To enhance modeling accuracy and comprehensively monitor the temperature information of the machine tool spindle, the input of this model is generated by processing the data collected through five temperature sensors. The IAPSO algorithm is employed for the automatic identification of BP parameters, reduce manual intervention, and enhancing the model’s capacity for generalization.


Introduction
Numerous studies indicate that thermal errors exert a substantial influence on the machining accuracy of machine tool, with the resulting processing errors contributing to 40% to 70% of the overall machine tool errors [1,2].
Zhang Yi et al. [3] proposed IGNN model by adding gray layer in the input layer and white layer in the output layer of the traditional BP model.On the basis of predicting the thermal error respectively by grey model and neural network, he proposed PGNN model by using linear combination method and adjusting the model's weight coefficients based on the target prediction accuracy.The thermal error prediction test was conducted.Both prediction models can at least improve the machining accuracy by roughly 70%.Wei Xiaoling et al. [4] aimed to mitigate the impact of thermal error on the machining accuracy of CNC machine tool, the thermal error models of GA-BP and BP neural network are constructed respectively.The simulation and comparative analysis of the two models were conducted using MATLAB software.The findings demonstrate that, the GA-BP model showed reductions of 2.4610 μm in MSE and 0.8615 μm in residual error average.Ma et al. [5] built PSO-BP, GA-BP, MLRA and BP thermal error models respectively to solve the problem of low accuracy in the BP neural networkbased thermal error compensation model.Experimental findings reveal that the machining precision of the GA-BP model and PSO-BP model has risen from 67% to 89% and 78%, respectively.Numerous research endeavors have explored the integration of BP neural networks with advanced optimization algorithms to establish models for thermal errors [6,7].
All the above methods use intelligent optimization algorithm to enhance the performance of machine tool thermal error models.However, if the parameters in the algorithm are set to fixed values, there may be problems such as slow convergence and poor model robustness.For the purpose of achieving better performance and optimization efficiency of the model, the adaptive parameters of the PSO algorithm are fine-tuned for adjustment.Using the global search capability of PSO algorithm to prevent getting stuck in local optimal solution, a mixed encoding for BP neural network weights and biases was designed, and the parameter synchronization identification is carried out by PSO algorithm.On this basis, the IAPSO-BP spindle thermal error model is proposed.

Theoretical Basis of Model
BP neural Network (Back-Propagation Network) is a neural network that transmits errors in reverse direction, usually composed of three levels of neurons, namely the input layer, the intermediate layer and the output layer [8][9][10].Its structure is illustrated in figure 1.The input signal is transmitted to the intermediate layer after weighted operation, and then transmitted to the output layer after activation function processing.The network output is evaluated against the actual value, the weights and biases are updated by repeating iterations until the prediction error of the network reaches a preset threshold or the number of training times reaches a preset upper limit.Although BP neural network have certain advantages in constructing thermal error model of machine tool spindle, it has a tendency to get stuck in local optima and may suffer from overfitting.PSO algorithm facilitates the convergence of particles toward the global optimal solution through continuous updates to their positions and velocities.The updates of particle velocity and position are shown in equation ( 1) respectively.
where  is the inertia weight,  1 and  2 represent individual social learning factors, with  1 and  2 being random numbers within the range [0,1] ,  represents the current iteration number,    represents the optimal solution of the  iteration of the  particle,   represents the global optimal solution of the  iteration.

IAPSO-BP Spindle Thermal Error Identification Model
In order to overcome the limitation imposed by fixed weights in the PSO algorithm and enhance the model's performance and efficiency, adaptive weights were introduced to construct adaptive PSO.The modeling process for spindle thermal error based on IAPSO-BP is illustrated in figure 2.  Step 1: Design the structure of BP network; The quantity of intermediate layer nodes can be determined based on the equation ( 2): ℎ represents the quantity of intermediate layer nodes,  and  represent the quantity of input and output layer nodes, respectively.α is a random number ranging from 0 to 10.According to the data collected by 5 temperature sensors in the input model and 1 thermal error distortion in the output, then  = 5,  = 1.The neural network designed in this paper contains two intermediate layers.According to equation (2), after many tests, the network structure is determined to be 5-4-3-1, the model prediction accuracy is the highest.
Step 2: Initialize the particle swarm and specification of particle encoding; Set the number of particle swarm to 1000, randomly initialize the speed and position of each particle, if the overall count of weights and biases in the network is denoted as , representing a D-dimensional search space, then the position of the  th particle in the t generation population can be expressed as    = ( 1  ,  2  , …    )。 Step 3: Train PSO-BP; • Calculate the fitness of particles.As shown in Equation (3). the current fitness value is lower than the individual's best fitness value, then the current position is considered the individual's best position.For all particles, if an individual's optimal position has a lower fitness than the global optimal position, the particle's optimal position will be regarded as the global optimal position; • Update particle weights.If the fitness of a particle is above the average fitness, alter the weight according to Equation (4); if the fitness is below the average fitness, adjust the weight with Equation ( 5); where, the upper and lower limits of inertia weight are set as   = 0.9    = 0.4,    is the fitness of the current particle,  ()

𝑡
and  ()  are the minimum and average fitness values of all particles at the  iteration, respectively.
• Update the position and velocity of particles based on the equation (1); • Renew fitness again; • Determine whether it falls into local optimal; When the global optimal position is iterated 50 times without updating, it falls into local optimal, and all particles are re-encoded.• Verify convergence; with an iteration count of 1000 times, if the iteration is done, take the current global optimum position (weights and biases) as the input for the BP neural network, generating the final result.

Experimental Scheme Design
This paper focuses on the T-7 3-axis CNC machine tool for the research.Utilizing clustering techniques, the positions of five temperature measurement points of the spindle were determined, namely, the nose end of the spindle, the tail end of the spindle, the Z-axis motor seat, the Z-axis nut seat and the Z-axis tail seat.Five temperature sensors were arranged to collect their temperature data, and the distribution of temperature sensors was shown in figure 3. The parts shown in figure 4 are actually cut.The workpiece has two grooves with a standard depth of 5mm and 7mm respectively.Employing an eddy current sensor for the measurement of thermal spindle deformation during machining, obtaining temperature and thermal deformation data during the machine tool's processing.Since the processing time of a groove is 3 minutes, a set of temperature point data and the thermal deformation of the spindle are recorded every 3 minutes, and a total of 43 data are collected.Two groups of experiments were carried out under the working conditions of machining 5mm grooves and 7mm grooves respectively.Selecting one set of data obtained during the processing of a 5mm groove as the training set, and the remaining three sets as the testing set.The data collected for the training set is shown in figure 5.The graph indicates that the temperature of the spindle tail end and the Z axis nut holder increased obviously with the progress of processing in the early stage, and rose gently in the late stage.The other three temperature measurement points changed steadily with the progress of processing.The thermal deformation of the main shaft increased from 10μm to 63μm and finally stabilized.

Comparison of IAPSO-BP and BP Neural Network Spindle Thermal Error Model Training
3.2.1.Evaluation Index.IAPSO-BP and BP neural network thermal error models were developed using the test set data collected in 2.1, and compared the predictive results of the two models.The mean square error (MSE), maximum absolute residual (MAX), and goodness of fit ( 2 ) were used to evaluate the two models, which were calculated as follows: where,   and   are the actual output and expected output of the  th sample, and  is the total number of samples.The smaller the MSE, the better the fit.
where {} is the set of absolute residuals.
where ̅ represents the average of the actual output of all sample points, and the closer  2 is to 1, the better the model fits the data.This reveal that the prediction accuracy of BP neural network model is relatively low, and the prediction effect is also unstable, that is, the robustness of the model is poor.

IAPSO-BP Spindle Thermal Error Model.
In the IAPSO-BP model, population size was set to 1000, evolution times to 1000, and adaptive weights were set.The prediction effects of the three sets of data were shown in figure 7(a)-(c).The comparison suggests that the IAPSO-BP model exhibits a considerable enhancement in predictive accuracy and stability compared to the BP neural network model, signifying increased robustness in the model.

Comparison of Evaluation Indexes of Two Models.
The evaluation indexes MSE, MAX and  2 mentioned in 4.3 were used to evaluate them.MSE, MAX and  2 respectively took the mean square error, maximum absolute residual and average goodness of fit of the three groups of data, and the results of the comparison are presented in table 1.Therefore, Therefore, IAPSO-BP model can realize more accurate prediction and compensation of thermal errors.(1) In this paper, the study focuses on the thermal error modeling method of the machine tool spindle, employing multiple temperature-sensitive points, and IAPSO-BP model is proposed.The hybrid coding composed of weights and biases.Utilize PSO algorithm to optimize the network's topology, avoiding local optima and enhancing model generalization.Introduce adaptive weights in the PSO algorithm to accelerate the modeling efficiency.(2) To assess the effectiveness of the IAPSO-BP model, three random experiments were designed, and the results indicated that the prediction indexes of the IAPSO-BP prediction model were far superior to BP neural network.Therefore, the prediction accuracy and robustness of the IAPSO-BP spindle thermal error prediction model were greatly improved.
The data of the temperature sensor and the actual thermal deformation of the main shaft are collected and the structure of the network is determined Design hybrid coding Calculate the fitness value of the particle (root mean square error of thermal deformation) Update individual historical and global optimal values of particles Adjust the velocity and position of the particles Is it trapped in local optimality?More than 1000 iterations?The optimized weights and thresholds of BP networks are obtained End of modeling Particle change renewal N Y Y Matching the position of particles in the particle swarm with the weights and biases of the BP neural network Start N BP neural network trained training samples and test samples respectively

Figure 2 .
Figure 2. Thermal error modeling flow chart of main shaft based on PSO-BP.
) where   is the fitness of the  th individual, represents the number of training samples, signifies the actual output of the  th training sample, and signifies the expected output of the  th training sample; • The  and  of an individual are updated based on the fitness.For each individual, if
Network Model.Establish two intermediate layers, featuring 4 nodes in the first intermediate layer and 3 nodes in the second intermediate layer, the training times are 1000 times.The predictive results for the three datasets are illustrated in figures 6(a)-(c).

Figure 6 .
Figure 6.Prediction effect of BP neural network model.

Table 1 .
Comparison of model evaluation indexes.As can be seen from the table, In comparison with the BP neural network model, the IAPSO-BP model exhibits a 67.45% reduction in MSE, a 69.62% reduction in MAX, and an increase of 0.041 in  2 .