The spindle axial time-varying thermal error compensation method for horizontal boring and milling machine tool based on edge computing

The time-varying thermal error of the horizontal boring and milling machine tool (HBMMT) directly affects the performance of high-end parts. The time-varying thermal error is in the axial direction due to the radial symmetry of the spindle box being good. The spindle axial time-varying thermal error compensation method based on edge computing was studied for reducing the effect of the spindle axial time-varying thermal error of HBMMT on the accuracy consistency of parts. The spindle axial time-varying thermal error model was established based on the speed and acceleration of spindle temperature change. The error compensation value was acquired by edge computing, and the error was compensated based on the principle of coordinate origin offset. The error fluctuation range with compensation was reduced, and the accuracy stability of HBMMT was greatly improved.


Introduction
Horizontal boring and milling machine tool (HBMMT) is the main machining equipment for the advanced manufacturing industry. The accuracy stability of the machine tool will affect the accuracy consistency of high-end parts directly. Due to the internal frictional heat, motor excitation heat, and external environmental temperature changes, thermal deformation over time will occur, which leads to timevarying thermal errors. The time-varying thermal error is a critical factor affecting the accuracy stability of the HBMMT. It has been shown that the time-varying thermal error of the spindle accounts for 50~80% of the total thermal error of the machine tool [1,2], and its impact on the accuracy stability of the machine tool cannot be ignored. The spindle timevarying thermal error includes axial thermal elongation error and radial thermal drift error. The structures of HBMMT include bench type (fixed column and movable worktable), floor type (moving column and fixed worktable), and planer type (moving column and movable worktable) [3]. The radial symmetry of the spindle box (X-direction and Y-direction) is good for the above three types. Therefore, the time-varying thermal error caused by spindle thermal deformation is in the axial direction. And the larger the spindle axial size, the larger the time-varying thermal error is.
Error compensation is an effective means to reduce the time-varying thermal errors of machine tools. The error compensation has the advantages of low cost and flexible application, and it is used for in-service machine tools easily. The thermal error compensation method includes embedded compensation and external compensation. Embedded compensation is to embed the thermal error model into the underlying algorithm of the CNC system and regard thermal error compensation as a functional module. For example, Chen et al. [4] developed the embedded thermal error compensation module of the CNC system. The thermal error compensation module can share data with the main module and compensate for errors by correcting the coordinate commands of the interpolation process. Embedded compensation is realized based on mastering the underlying algorithm of the CNC system. However, many CNC systems are not completely open to the user. For the users, the embedded error compensation method is considerably difficult.
The external compensation is that the error compensation value is calculated by a time-varying thermal error model and is written in the position control loop by feedback interruption or coordinate origin offset [5][6][7]. Edge computing is an effective means of external time-varying error compensation, which is close to the physical entity and fast network service response. Yee et al. [8] compensated the thermal error by the feedback interruption which can truncate the position feedback signal and increase or decrease the number of feedback pulses by an external compensator. But it must add the compensation signal to the servo control loop with a special device, and the motion feedback signals easily interfered with the compensation signals, which is very difficult to implement. The coordinate origin offset is the method in which the error compensation values are written into the internal register depending on the secondary development interface of the CNC system, and the errors of the machine tool are compensated. This method has good real-time performance and is more flexible for the optimization of the error model.
It is the key to compensating for the time-varying thermal error of the machine tool spindle effectively establishing an accurate spindle axial time-varying thermal error model. Currently, the spindle axial time-varying thermal error models are mainly divided into two types: the thermal error-spindle speed model and the thermal error-spindle temperature model. The compensation by the thermal error-spindle speed model requires only the spindle speed that is read from the CNC system without additional sensors. However, the robustness of the model is not easily guaranteed because the model does not contain spindle temperature information and is susceptible to spindle cooling system and load change. The thermal errorspindle temperature model is mostly established by data-driven methods, such as multiple regression [9], time series [10], neural network [11], and so on. The method requires a large amount of test data to ensure model generalization capability, which takes up a long time.
The spindle temperature changes exponentially during nonstationary processes such as temperature rise and temperature drop. Focus on improving the accuracy stability of HBMMT in this paper. The spindle axial time-varying thermal error model will be established based on the speed and acceleration of spindle temperature change. The spindle axial time-varying error compensation value will be acquired by the edge calculation, and the error will be compensated based on the principle of coordinate origin offset.

Modeling of axial time-varying thermal error for horizontal boring and milling machine spindle
The symmetry of the spindle radial structure is good for HBMMT, and the spindle accuracy is less affected by radial thermal deformation. The time-varying thermal error of the spindle is mainly reflected in the axial direction due to the slender structure of the spindle for HBMMT. The larger the spindle axial size, the larger the axial time-varying thermal error is. The model was established for the relationship between the spindle axial thermal error and the temperature of HBMMT in this section. The key temperature measurement points were selected, and the model parameters were optimized.

The spindle axial time-varying thermal error model
A large number of previous studies have found that the axial time-varying thermal error of the spindle increases and decreases exponentially during both warming and cooling [12][13][14], as shown in Fig. 1. During the actual operation, the thermal deformation of the spindle is easily affected by load changes and the cooling system start-stop, which causes a great challenge to the accuracy of the time-varying thermal error model. In order to ensure the good robustness of the spindle thermal error model, the steady-state value of the axial timevarying thermal error of the spindle is calculated using the speed and the acceleration of the temperature change [13]: where E st (t) is the steady-state value of axial time-varying thermal error at time t, β v is the coefficient related to the temperature change speed of spindle, β a is the coefficient related to the temperature change acceleration of spindle, T(t) is the increment of spindle temperature at time t, and its equation is as follows: where T s (0) and T s (t) are the measured values of the spindle temperature measurement point at the initial moment and Fig. 1 The axial time-varying thermal error of spindle time t, respectively; T e (0) and T e (t) are the measured values of the ambient temperature measurement point at the initial moment and time t, respectively. Therefore, the equation of axial time-varying thermal error can be written as follows: where E(t) is the spindle time-varying thermal error value at time t; λ is the spindle thermal inertia coefficient.

The identification of model parameters
The parameters in the spindle axial time-varying thermal error model include the coefficient β v related to the spindle temperature variation speed, the coefficient β a related to the spindle temperature variation acceleration, and the spindle thermal inertia coefficient λ. The nonlinear quadratic programming algorithm (NLPQL) was used to identify these parameters. The objective function of the NLPQL is as follows: where E t (t) is the measured value of spindle axial time-varying thermal error at t, E(t) is the predicted value of spindle axial time-varying thermal error at t, λ min , β vmin , and β amin are the lower limits of the constraints of parameters λ, β v , and β a , respectively; λ max , β vmax , and β amax are the upper limits of the constraints of coefficients λ, β v , and β a , respectively.

Thermal error testing and temperature measurement point optimization
According to the reasons for spindle thermal error, six temperature sensors were arranged near the internal heat sources (front bearing, rear bearing, and motor) of the spindle to obtain the spindle temperature for determining the key temperature measurement points of the HBMMT's spindle. A temperature sensor was arranged on the body away from the spindle to obtain the environment temperature of the machine tool. The distribution of the temperature measurement points is shown in Fig. 2. The temperature sensor was self-developed with a TSic506F chip, and its accuracy is ±0.1 °C (5 °C ~ 45 °C). The temperature acquisition module has 8 data channels, and it can collect the temperature data from 8 channels synchronously.
The eddy current displacement sensors were used to obtain the spindle axial time-varying thermal error. The type of eddy current displacement sensor is the Micro-Epsilon DT3005-U1-M-C1 with data acquisition card NI-USB6281. Its linear measurement range is 1mm. The resolution is 0.5μm. The sensitivity value is 111μm/V. The test site of spindle axial timevarying thermal error for HBMMT is shown in Fig. 3.

Bottom surface of spindle box
The temperature threshold value of the spindle cooling system was set at 25°C. The spindle had been running at 1300r/min for 4h, then stopped for 5h. The test result of the spindle axial time-varying thermal error is shown in Fig. 4, and the temperature measurement results are shown in Fig.5.
The test results of each temperature measurement point of the spindle were combined with the ambient temperature and the axial time-varying thermal error, respectively. The values of temperature and the error were substituted into the model of the spindle in Section 2.1. The parameters of the model corresponding to each temperature test point of the spindle were identified based on the method in Section 2.2. The timevarying thermal error prediction results corresponding to each temperature measurement point of the spindle were compared with the error test results in Fig. 4, and the residuals are shown in Fig. 6. It can be seen that the residual corresponding to measurement point 1 is the smallest. Therefore, temperature measurement point 1 was selected as the spindle temperature measurement point.

Thermal error compensation based on edge calculation
The compensation value of spindle axial time-varying thermal error can be calculated with the temperature of the spindle and environment by the model in Section 2. Semi-closed or closed commercial CNC systems usually provide only user data interaction interfaces. Therefore, the external thermal error compensation method based on edge calculation was adopted in this paper. The time-varying thermal error model ran in the edge controller. The thermal error compensation value was written into the CNC controller by the I/O interface, and the spindle axial time-varying thermal error was compensated based on the principle of coordinate origin offset by offsetting the Z-axis origin.

The coordinate origin offset
The coordinate origin offset will make the CNC machine tool work in the new coordinate system by changing the relative distance between the mechanical coordinate origin Therefore, the actual positions of the workpiece and tool can be controlled by changing the relative distance between the machine coordinate origin and the reference point without changing the CNC machining program. The principle of the machine coordinate origin offset is shown in Fig. 7. For example, the target position of the tool is at (0, 0, 100). But the actual position of the tool will be at (0, 0, 100.07) due to the spindle axial thermal deformation, and there is 0.07mm of spindle axial timevarying thermal error at this time. The thermal error will be compensated by offsetting the machine coordinate origin, that is, the error compensation value −0.07mm will be written into the CNC system, and the machine coordinate origin of the Z-axis will also be shifted 0.07 mm in the direction of −Z. The actual distance between the tool and the coordinate origin of the Z-axis after compensation will be the same as the actual distance before compensation. At this moment, the actual position of the tool in the machine tool can reach the target position required by the machining program control instruction.
It should be especially noted that the corresponding mechanical coordinate value displayed in the system interface will fluctuate rapidly when the compensation value is written into the CNC system. The reason is that the distance between the tool and the mechanical coordinate origin will change when the mechanical coordinate origin offsets and the system interface will show the current position of the tool at this time. Meanwhile, the distance  Fig. 7 The principle of coordinate origin offset between the tool and the mechanical coordinate origin will immediately return to that before compensation due to the coordinate position feedback, and the position value displayed in the system interface will recover.

Data communication between edge controller and Huazhong CNC system
Edge computing is an effective means of external time-varying error compensation, which is close to the physical entity and fast network service response. As shown in Fig. 8, the spindle axial time-varying thermal error model runs in the edge controller to calculate the thermal error compensation value using the temperature of the spindle and environment. The compensation value is inputted into the error compensation register of the CNC system to offset the coordinate origin. How to write the error compensation value into the CNC system is an important part of the spindle axial time-varying thermal error compensation. There is Huazhong 8-type CNC system in the horizontal boring and milling machine tool in this paper. The edge controller was connected to the CNC by a network cable, and the data communication is realized by network port: (1) Load the dynamic link library There are two versions of the dynamic link library in C# and C++ in Huazhong 8 CNC system. The C# version, that is, HncNetDllForCSharp.dll, was used in this paper. The call function of the dynamic link library is as follows: NET.addAssembly (path_dll) where path_dll is the storage path of the dynamic link library.

(B) Initialize the network of the adapter
The error compensator is the upper computer and is connected to the adapter. Therefore, the adapter needs to be turned on and the network needs to be initialized in advance. The corresponding function is nc_net. HNC_NetInit (ip_up, port_up, name) where ip_up is the IP address of the error compensator; port_up is the port number of the upper computer; the name is the program file name of the error compensation program running in the upper computer.

(C) Connect the error compensator to the CNC lower computer
The corresponding function is nc_net.HNC_NetConnect (ip_down, port_down) where ip_ down is the IP address of the CNC lower computer; port_ down is the port number of the lower computer.

(D) Read the information on the machine tool
The corresponding function is nc_net.HNC_AxisGetValue (read_information_type, ax, information_0) The temperature of environment The edge controller The system of thermal error acquisition Fig. 9 The time-varying thermal error compensation site of the spindle where ax is the axis number of X/Y/Z/A/B/C; read_ information_type is the data type; information_0 is the initial value.

(E) Write the error compensation value
The corresponding function is nc_net.HNC_RegSetValue (register_type, index, compensation) where register_type is the 32-bit register variable type; index is the index number of the axis; compensation is the error compensation value that should be written.

Verification of thermal error compensation effect on HBMMT
In this paper, a verification test of the spindle axial time-varying thermal error compensation was conducted on the NCT-180 CNC horizontal boring and milling machine tool. The edge controller for time-varying thermal error compensation was installed next to the CNC system. A temperature sensor for measuring the spindle temperature was installed at the location of measurement point 1 in Section 2.3, and a temperature sensor for measuring the ambient temperature was installed in the body of the machine tool. The residuals of the thermal error after compensation were obtained by eddy current displacement sensors. The test site is shown in Fig.9.
To verify the effect of spindle axial time-varying thermal error compensation, the spindle axial time-varying thermal error with compensation was tested at variable spindle speed and intermittent constant speed, respectively. In the test at variable spindle speed, the spindle speed was taken arbitrarily according to the maximum spindle speed. At this time, the fluctuation range of the spindle axial time-varying thermal error is −19.8μm~11.5μm with compensation, and the result is shown in Fig. 10.
In the test at an intermittent constant speed, the spindle speed was simulated for the daily working condition of the machine tool. At this time, the fluctuation range of the spindle axial time-varying thermal error is −11.9μm~7.7μm with compensation, and the result is shown in Fig. 11.
According to workers in the workshop, the size of the workpieces differed by more than 80μm after milling three workpieces without thermal error compensation. From the error curve in Fig. 10b and Fig. 11b, it can be seen that the spindle axial thermal error fluctuates around the error zero  value whether it is randomly variable speed or intermittent fixed speed operation. From the results above, it can be seen that the spindle axial accuracy fluctuation of the horizontal boring and milling machine tool is greatly reduced, and the accuracy stability is greatly improved.

Conclusion
In this paper, for the urgent need for spindle accuracy stability improvement for horizontal boring and milling machine tool, the method of spindle axial time-varying thermal error compensation based on edge computing was studied. The main points are summarized as follows: (a) The spindle axial time-varying thermal error model was established based on the speed and acceleration of spindle temperature change.
(b) The data communication between the edge controller and the Huazhong CNC system was realized by the dynamic link library. (c) The spindle axial time-varying error compensation value was acquired by edge computing, and the error was compensated based on the principle of coordinate origin offset.