## Abstract

This paper demonstrates the development of a thermal error model that is applied on the feed axis of machine tools and based on the neural network. This model can accurately predict the value of the axial thermal error that appears on machine feed axis. In principle, there is the generalized regression neural network (GRNN), which has the good nonlinear mapping ability and serves to construct the error model. About variables, the data of temperature and axial thermal error of machine feed axis are the inputs and outputs, respectively. The particle swarm optimization (PSO) is a component of this model, which serves to optimize the smoothing factor in GRNN, and the particle swarm optimization-based generalized regression neural network (PSO-GRNN) model is built. From experiment, the datum is acquired from a machining centre in four different feed rates. Thereafter, the back propagation (BP) neural network model, the traditional GRNN model, and the PSO-GRNN model were established, and the data collected from the experimentation are input in three models for prediction. Compared with the other two models used in this paper, the PSO-GRNN model can maintain higher prediction accuracy at different feed speed, and the prediction accuracy of it changes less in different feed rates. The proposed model solved the problem of generalization ability of the neural network at different feed rate, which shows good performance and lays a good foundation for further research like thermal error compensation.

## 1 Introduction

With the advancement of manufacturing and technology, the machining accuracy of machine tools is becoming more and more important since mechanical components with high-precision are required in various fields. In the process of machining, there are many factors that influence the machining accuracy, and the most important one is the thermal error. As research shows, thermal error accounts for 40–70% of the total in machine tools [1,2]. During the machining process of the parts, the thermal deformation of the moving parts in machine tools occurs due to the operation of the servo motor and the heat generated by the relative motion of each pair of motions, which affects the machining accuracy because of tool offset. Since the machine tool is a complex system, the thermal expansion coefficient, the structure of the machine parts, and the processing conditions all have a measure of influence on the thermal error, so that the goal of error modeling cannot be achieved by a simple linear mathematical model with traditional methods [3]. Establishing a high-precision model to achieve the goal of thermal error compensation is one of the critical problems in the precision manufacturing technology of computer numerical control (CNC) machine tools [4].

According to the long-term research, there are two major ways of reducing the thermal error: (1) error prevention and (2) error compensation [5]. Error prevention is usually used to predict and suppress thermal errors during the machining process by improving the structure of machine parts, precision manufacturing, and assembling levels, which aimed at the source that causes the thermal error. But in fact, the application of prevention methods is relatively small due to the timeliness of thermal errors and the constraints of cost and time [6]. The error compensation, which has the characteristics of good economy and small limitations [7,8], is widely used by establishing the error model. With the prediction results, the goal of error compensation is achieved. The performance is directly related to the accuracy and the generalization ability of the established model. Currently, the multiple regression [9,10], the neural network [11–13], the least-square method [14,15], the grey theory modeling [16,17], and the time series method [18] are commonly used to achieve the goal of the thermal error compensation modeling. Back propagation (BP) neural network is a classical method that usually serves to build error models. As an example, the thermal error modeling using the BP neural network is analyzed in Ref. [19]. The BP neural network model can implement nonlinear mapping [20], but there is a problem that the threshold of weight is randomly generated and easily falls into the local minimum [21]. Therefore, in some cases, the BP neural network may not show a good performance. This paper uses the generalized regression neural network (GRNN) to analyze the modeling of thermal error.

GRNN, which was presented first by Specht [22], is an improved neural network compared with the radial basis neural network. It has a strong nonlinear mapping ability, and at the same time, its robustness and fault tolerance are high. GRNN can handle the unstable data, and it also has a good predictive effect when the size of samples is small. The predictive performance of GRNN is directly related to its parameter, the smoothing factor [23,24]. The fitting value can be very close to the average value of all dependent variables in the samples if the smoothing factor is large. On the contrary, the fitting result would be closer to the training sample when the value is close to zero. Traditional GRNN has strong subjectivity in the value of the smoothing factor, which tends to reduce the generalization ability. Thus, it requires an optimization algorithm to optimize the GRNN.

Particle swarm optimization (PSO) was presented first by Kennedy and Eberhart [25]. This method is commonly used to deal with optimization problems. This algorithm is inspired by the behavioral characteristics of the predatory biological population. PSO can globally optimize and automatically obtain a search space [26,27]. Mapping the particles to the value of the smoothing factor, the best value can be obtained as the global optimal solution.

In this paper, PSO is used to obtain the optimal smoothing factor to enhance the generalization ability and the predictive effect of this neural network. Thus, the goal of the thermal error modeling of the feed axis of a CNC machining center is achieved with the particle swarm optimization-based generalized regression neural network (PSO-GRNN). Through the experiment and analysis, the result shows that compared with the traditional GRNN and the BP neural network, the PSO-GRNN model has higher precision and has better generalization ability.

## 2 Particle Swarm Optimization-Based Generalized Regression Neural Network

### 2.1 Principle of GRNN.

*x*and

*y*. For these two variables, the joint probability density function is

*f*(

*x*,

*y*). When the regression

*X*of

*x*is known, the regression of

*y*to

*X*is as follows:

*n*denotes the sample size,

*p*denotes the dimension of the random variable

*x*,

*X*

_{i}and

*Y*

_{i}denote the sample observations of the random variables

*x*and

*y*, respectively, and

*σ*is the width coefficient of the Gaussian function, and in this problem, it is the smoothing factor in generalized regression neural network.

### 2.2 Structure and Algorithm of PSO-GRNN.

In the GRNN model, the predicted result is concerned directly with the smoothing factor *σ*. When the smoothing factor is large, the fitting value is close to the average of all dependent variables. By contrast, the fitting value is closer to the training sample when the value of the smoothing factor is close to zero. However, the prediction ability of the model may become very poor once it encounters the points that cannot be included in the sample, which leads to the low generalization ability of the model. For the traditional GRNN, the cross-validation [28,29] is often used to obtain the smoothing factor. This traditional method has problems such as large subjective influence and low training efficiency. Therefore, the PSO is used to optimize the smoothing factor in the new model, which is called PSO-GRNN, and the structure of it is shown in Fig. 1.

In Fig. 1, *m* is the current iteration number of the particle swarm algorithm and *M* is the upper limit of the iteration number of the PSO algorithm.

First, the experimental data are loaded in the PSO-GRNN model and put into two divisions, one for training and another for testing. In fact, the data are large that require to be normalized to improve the convergence speed.

*y*

_{i}corresponds to the actual value of the training result and $y^i$ corresponds to the predicted value of the training result.

*P*

_{i}of each particle and the optimal fitness

*P*

_{g}of the population, requires to be recorded. The update equation for particle velocity and position during each iteration is as follows:

*V*

_{id}represents the particle velocity,

*k*is the current itera tion number,

*ω*corresponds to the inertia weight, acceleration factors

*c*

_{1}and

*c*

_{2}correspond to nonnegative constants,

*r*

_{1}and

*r*

_{2}correspond to random numbers distributed between [0, 1],

*d*= 1, 2, …,

*D*,

*i*= 1, 2, …,

*n*,

*P*

_{i}corresponds to the individual extremum of each particle, and

*P*

_{g}corresponds to the global extremum of the population.

When the upper limit of iterations is achieved, the following step is that the global optimal solution of the PSO is output and generated as the best smoothing factor value to generate a new GRNN. The structure of GRNN comprises an input layer, a pattern layer, a summation layer, and an output layer. To facilitate intuitive understanding, the concrete construction of GRNN is shown in Fig. 2.

As this model is built for the prediction problem of thermal error modeling, it is considered that the input layer corresponds to the datum of temperature, which is measured from the experimentation, and the output layer corresponds to the thermal error.

*P*

_{i}is as follows:

*X*is the learning variable and

*X*

_{i}corresponds to the sample corresponding to the

*i*th neuron.

*S*

_{D}and

*S*

_{Nj}. These calculation equations are as follows:

*y*

_{ij}corresponds to the

*j*th element in the

*i*th output sample $Yi=[yi1,yi2,\u2026,yik]T$.

Finally, the results of estimation should be denormalized, and the predicted results of the PSO-GRNN model are obtained.

## 3 Experimentation

### 3.1 Data Acquisition.

For the feed axis of the machine center, the main parts producing heat in the process of processing include the end motor heating, friction heating of screw nuts, and the bearing heating of both ends of the screw [30]. According to the preliminary work, the main components of the feed system heating in the machining center are the nut, the screw, the motor, and the front and rear bearings. From the structure of the feed axis, the lead screw of the feed axis is not convenient for mounting the temperature sensor, and the measuring point of temperature is set at a portion that is directly contacting the lead screw according to the heat transfer theory [31]. The temperature sensors are placed at six positions of those heat sources, and the signals of temperature are received by an acquisition board. Subsequently, the temperature signals are transmitted to the numerical control system, and the temperature data were observed and stored on the PC side. The experimentally collected temperature data include six sets, which are ambient temperature, temperature of the lower bearing housing, the motor, the upper bearing housing, the coupling, and the screw nut. The picture of equipment and sensor positions is shown in Fig. 3.

As research shows, the thermal error affecting the machining accuracy is mainly due to the axial thermal deformation but not the radial deformation of the lead screw [32]. For the actual ball screw, one end of it is connected to the driving motor, and the other end is swimming, which leads to poor steeliness, so it is easy to produce thermal deformation in the process of feeding. For the lead screw, the temperature field is both a function of position and a function of time [33]. Therefore, the radial deformation, which means the radial thermal error is not considered in the experiment. The portion of the lead screw in the range of the feed axis is divided into 12 segments, and each segment has a length of 50 mm, which means that 13 measuring points for the thermal error are set. The experiment used the laser interferometer to collect the datum of thermal error of these 13 points. The details of the equipment are shown in Table 1.

The feed rate of the machining center was set to 10,000 mm/min during the experiment. The data are acquired every 15 min, which took 195 min to obtain 14 sets of datum. Then, the feed rate was changed to 8000 mm/min, 12,000mm/min, and 16,000 mm/min, and the data are collected in the same way.

### 3.2 Model Preparation.

The experiment uses three neural network models for comparison, including the BP neural network model and the traditional GRNN model in addition to the PSO-GRNN model, which aims to analyze and compare the predicted effect of the proposed PSO-GRNN model. The temperature data measured are the input value of these models. In contrast, the datum of thermal error is taken as the output value. Thus, for these three models, the amount of neurons in the input layer is 6 and in the output layer is 13. Train these three models with 13 sets of data, and the 14th set of data is used to get the predicted result.

For the BP neural network model, nine hidden layers were set, which means constructing a BP neural network with the structure of 6-9-13. For the traditional GRNN model, the smoothing factor is obtained by the method of cross-validation, which is obtained as an optimal value with the PSO algorithm in the proposed PSO-GRNN model.

### 3.3 Results in the Feed Rate of 10,000 mm/min.

The first to analyze is the data collected when the feed rate is set to 10,000 mm/min. The datum of temperature and thermal error obtained with the equipment is shown in Fig. 4.

In Fig. 4, the *x*-axis corresponds to the samples measured 15 min apart. The figure shows the thermal error, and each line corresponds one measuring point which was set on the feed axis.

In Figs. 5–7, the samples represent 13 measuring points set on the full length of the feed axis. The ordinate represents the value of thermal error.

In this paper, the index for analysis of the prediction accuracy of these models is the residual of the predicted results. By comparing the residual range, residual mean, and standard deviation, the performance about accuracy of these models is analyzed. Table 2 presents the residual comparison of each prediction model when the feed rate is set to 10,000 mm/min.

According to the data in Table 2, the residual value of the PSO-GRNN model is −1.7 *µ*m, the mean is −0.9538 *µ*m, and the standard deviation is 0.6603. These indicators of the results of the PSO-GRNN model are smaller than the predicted results of the BP neural network model and the traditional GRNN model, indicating that PSO-GRNN model has the highest prediction accuracy in these three models. In fact, from Figs. 5–7, it can be intuitively found which model has the highest accuracy. For the proposed PSO-GRNN model, the prediction result is significantly closer to actual values. The prediction accuracy is secondly the result of GRNN model, but the predicted results are quite different from actual values when the model is built with BP neural network.

### 3.4 Results in Different Feed Rates.

The data collected in the feed rate of 8000 mm/min, 12,000 mm/min, and 16,000 mm/min were trained with the three models with the same parameters, and the result is shown in Figs. 8–10.

In Figs. 8–10, the samples represent 13 measuring points set on the full length of the feed axis, and the ordinate represents the value of the thermal error.

The results for the residual comparison of each prediction model when the feed rate is set to 8000 mm/min, 12,000 mm/min, and 16,000 mm/min are presented in Tables 3–5.

Combined with the predicted result when the feed rate is set to 10,000 mm/min, the residual of the predicted results of these neural network models increases while the feed rate increases. Generally, the training result of the PSO-GRNN model can always maintain a high accuracy, and the extreme value of the residual error can be kept to a small value, while the predicted values of the other two models have obvious errors compared with actual values. According to the comparison between the residuals under four different working conditions, the prediction accuracy of each neural network model has changed when the working conditions are changed, and the degree of decline in prediction accuracy from large to small is the BP neural network model, the traditional GRNN model, and the PSO-GRNN model. Therefore, it can be considered that the PSO-GRNN model can keep a good precision for prediction at different feed rates. At the same time, the PSO-GRNN model can be considered to have better generalization ability since the predicted temperature data are outside the training data.

## 4 Conclusions

In this paper, to achieve the goal of thermal error prediction that is applied to the feed axis in machine tools, the thermal error modeling is studied with the method of neural network. Compared with the traditional way, because the smoothing factor of traditional GRNN has strong subjectivity and other problems, the PSO algorithm is used to obtain the optimal value of the smoothing factor. Thus, the method of thermal error modeling for feed axis using PSO-GRNN is proposed. The datum of temperature and thermal error was acquired at four feed speeds of 8000 mm/min, 10,000 mm/min, 12,000 mm/min, and 16,000 mm/min, and these data were input into the BP neural network model, traditional GRNN model, and PSO-GRNN model for training and prediction. The thermal error predicted results of three neural network models are compared and analyzed. The result shows:

Under the condition of the feed rate of 10,000 mm/min, the prediction residual result of the PSO-GRNN model is closest to actual values, which has higher accuracy than the other two models. Thus, there is a higher prediction accuracy of the proposed PSO-GRNN model.

At the other three feed rates, the prediction residual of the PSO-GRNN model can also be kept in a small range, indicating that if feed rate changes, the PSO-GRNN model can maintain high prediction accuracy. On the other hand, the predicted temperature data are outside the training data. Thus, the proposed PSO-GRNN model owns higher generalization ability than the other two models.

From the industrial perspective, the proposed PSO-GRNN prediction model solves the problems of the other two models such as parameter randomness of BP neural network model and the optimal smoothing factor in the traditional GRNN model. The research shows that the PSO-GRNN model can keep high prediction accuracy under different working conditions, which means the feed rate, and it has high generalization ability. It lays a better foundation for error compensation, so that improving machining accuracy with the PSO-GRNN model is promising. In this paper, the considered factor that affects the thermal error is temperature. In the future, more factors affecting thermal error would be considered to improve the model, and the research on thermal error compensation based on the PSO-GRNN model would be carried out.