1. Introduction
The growing demand for enhanced dimensional accuracy in machining processes creates the need to develop cost-effective and efficient methods to improve the performance of CNC machines tools (MT). Dimensional accuracy is one of the most crucial factors in determining this performance. Typically, errors affecting MT are defined as the deviations between the real and measured positions and orientations of the cutting tool with respect to a reference system associated with the machined part. Most recent MT are equipped with a positioning resolution of 1 µm. Under challenging machining conditions—such as prolonged operation, thermal fluctuations, or hard material cutting—machine accuracy can degrade significantly, leading to notable deviations in dimensional accuracy. To maintain the MT performances at acceptable levels, these deviations need to be detected, identified, and removed. Modern CNC systems provide a foundation for such correction through software-based compensation mechanisms, often using geometric models such as the Homogeneous Transformation Matrix (HTM) framework. Based on principles such as those of Abbé and Bryan, these models enable systematic correction of geometric errors, aligning measurement systems with motion or mathematically accounting for angular deviations when direct alignment is impractical [
1,
2,
3].
Machine tools are affected by various sources of error, including geometric [
4,
5], thermal-induced [
6], dynamic [
7,
8], structural [
9], and assembly-related deviations [
10,
11]. Geometric and thermal-induced errors are responsible for a substantial portion of the observed inaccuracies, accounting for approximately 70% of the total volumetric error [
12]. These two categories, which vary gradually over time, are associated with inherent geometric imperfections resulting from manufacturing defects, misalignments during assembly and installation, as well as thermally driven distortions caused by internal and external heat sources [
13]. Other error sources include dynamic deviations generated by spindle movement, cutting force variations, and inertial-induced deflections. Although their individual effects may be comparatively limited, the influence of these errors remains significant due to their interactions with primary error sources. Moreover, while certain errors directly impact machining accuracy, others manifest through coupled mechanisms, producing variable, active, and difficult-to-predict deviations. Consequently, the characterization and mitigation of these error sources have been the focus of extensive research efforts aimed at enhancing dimensional precision and performance in advanced manufacturing systems.
Historically, error mitigation in CNC machine tools relied on structural improvements to enhance geometric and thermal stability, but this approach becomes prohibitively expensive as precision demands increase. Modern strategies now focus on compensation-based methods, which are more cost-effective and adaptable [
14]. These are broadly divided into suppression and active compensation techniques. Suppression methods reduce thermal effects through coolant systems, thermally stable materials, or thermal balancing, yet they often raise system complexity and remain limited under variable operational conditions [
15]. In contrast, active compensation employs physical or data-driven models to predict and correct thermal deformation in real time [
16]. This requires the optimal selection of temperature-sensitive points (TSPs), identified using finite element analysis, statistical correlation, or machine learning algorithms [
15]. Recent advancements emphasize sensor integration and predictive control to sustain machining accuracy without altering machine structure.
Recent studies have proposed a range of predictive models to improve thermal compensation in CNC machining systems. These methods aim to predict and correct thermally induced deviations to sustain dimensional accuracy during operation [
17]. Statistical modeling approaches—such as Least Squares, Multivariable Regression, and gray System Theory—provide interpretable and efficient solutions for basic thermal behavior but often fall short under complex or nonlinear conditions [
18]. For instance, Shi et al. [
19] applied multiple linear regression to model origin and position-related thermal errors in CNC lathes, achieving a 92.5% reduction in positioning error, while Liu et al. [
20] improved model robustness by combining ridge regression and principal component regression with temperature interval segmentation. Mareš et al. [
21] employed transfer function modeling, calibrated through thermal cycling experiments, and implemented real-time compensation via embedded Python scripts. However, the adaptability of these methods remains limited under highly nonlinear, time-varying, or data-sparse operating conditions.
To address these limitations, data-driven and AI-integrated techniques have been extensively explored. Machine learning approaches—such as Support Vector Machines, Gaussian Process Regression (GPR), and ensemble methods like XGBoost—demonstrate enhanced modeling capacity and resilience. Wei et al. [
22] proposed a novel GPR-based thermal error modeling and compensation framework for CNC machine tools, which incorporates interval prediction to reflect the stochastic nature of thermal behavior and introduces an adaptive mechanism for selecting temperature-sensitive points (TSPs) during model training. Their method, validated on a three-axis vertical machining center, significantly outperformed conventional techniques—including Ridge Regression, Principal Component Regression, ARX, and LSTM—in both accuracy and robustness, and achieved substantial reductions in thermal and angular machining errors during real-time compensation experiments. Similarly, Ye et al. [
23] developed the ALIX model, which integrates adaptive LASSO with XGBoost to improve prediction accuracy and variable interpretability. Assessed on 23 experimental batches from a Vcenter-55 vertical machining center, ALIX outperformed baseline models such as OLS, LASSO-SVM, and Random Forests in terms of prediction robustness, worst-case deviation, and percentage error. Real-time validation confirmed ALIX’s capacity to maintain thermal deviation within 10 µm under varying operating conditions, thereby demonstrating its practical utility in industrial settings. Neural networks further broaden this landscape. Farias et al. [
24] implemented a radial basis function neural network directly into the programmable logic controller of a legacy three-axis CNC milling machine. Trained on temperature data from six RTD sensors and axis position feedback, the model achieved up to 77.8% error reduction on the Y-axis during real-time operation, validated on 1080 distinct data points, and offered a cost-effective, retrofittable solution for older systems. Shen et al. [
25] introduced an intelligent CNC control scheme featuring a back-propagation neural network (BPNN) with adaptive learning, integrated with an Online Temperature Measurement System (OTMS). Using gray correlation analysis to associate temperature variation with thermal deformation, the model enabled dynamic error compensation. Deployed on a Leaderway V-450 machine, the system outperformed traditional predictors in both convergence speed and accuracy, with OTMS providing over 95% temperature measurement accuracy within 2 s. The enhanced TECM achieved a minimum contour machining error of 0.02 × 10
−3 mm, confirming its efficacy in improving thermal precision and aligning with intelligent manufacturing paradigms.
Recent work has also advanced deep learning architecture and intelligent control frameworks. Nguyen et al. [
26] developed a Long Short-Term Memory (LSTM) neural network using data from 32 PT-100 temperature sensors, applying Pearson correlation to identify the seven most influential temperature points. This enabled accurate prediction of thermal errors across X, Y, and Z axes, with real-time compensation reducing errors from 7 µm to 3 µm in X, 74 µm to 21 µm in Y, and −64 µm to −20 µm in Z. Du et al. [
27] proposed a 12-layer Convolutional Neural Network (CNN) that processes raw temperature data converted into thermal images, eliminating manual temperature-sensitive point selection and integrating depthwise separable convolutions and dropout regularization to optimize computational efficiency. Embedded in an STM32F4 microprocessor, this system achieved an 80% reduction in radial thermal error on a CNC grinder, lowering error from 35 µm to 7 µm. Zimmermann et al. [
28] introduced the Thermal Adaptive Learning Control (TALC) framework, which combines phenomenological models with one-class Support Vector Machines (SVMs) for novelty detection, enabling autonomous, on-demand thermal state measurements. TALC reduced state-triggered measurement updates by 78%, increased machine productivity by 3%, and maintained high compensation accuracy during 5-axis machining. Li et al. [
29] proposed the Unit Adaptive Thermal Network (UATN), a model dynamically adjusting thermal units to capture stochastic, time-varying thermal behaviors. Integrating thermal imager and thermocouple data with machine state parameters, the UATN compensates axial thermal deformation in feed screw and spindle systems, achieving sub-micrometer accuracy and stable performance under variable conditions Huang et al. [
30] developed a dynamic compensation strategy integrating multiple thermal models within an embedded control architecture on a VMC655H vertical machining center. Utilizing Kalman filtering, clustering, and gray correlation analysis for temperature-sensitive point selection, their method achieved a 53.11% improvement in X-axis positioning accuracy, effectively mitigating thermal deformation, and maintaining machining precision under varying conditions. Also, studies have explored advanced data-driven approaches, including attention-based LSTM networks for predictive modeling under complex conditions and generalized errors-in-variables models for pose estimation, highlighting the ongoing development of intelligent compensation systems [
31,
32].
Despite notable advancements, current compensation models exhibit key limitations that restrict their deployment in industrial scenarios. Statistical methods are often constrained by their linear assumptions and lack of robustness under dynamic thermal conditions. AI-based models, while more adaptable, frequently overlook the physical structure of machine behavior and are difficult to interpret. Moreover, most compensation strategies either target uniaxial errors or function offline, limiting their responsiveness and real-world applicability. To bridge this gap, the present study proposes a real-time compensation strategy for geometric and thermally induced errors based on a simplified experimental approach integrated with simultaneous and dynamic prediction of error components. These components are categorized into position-dependent and position-independent errors: the former are modeled as a function of both nominal axis positions and temperatures at multiple locations, while the latter are driven solely by thermal inputs. At each sampling instance, total volumetric errors are computed using a hybrid model that integrates a physically grounded HTM with a neural network predictor. This dual-layered framework enables interpretable, accurate, and real-time error correction, directly implemented within the CNC control loop.
3. Model Building and Simulation
To develop an effective prediction model for geometric and thermal-induced errors aimed at active error compensation, error components are categorized into three groups based on similar characteristics, measurement procedures, and instrumentation. These groups include thermal drift at the origins of the machine tool (MT) axes, position-dependent error components, and spindle thermal drift. Specialized devices are necessary to measure temperature variations at various locations within the MT structure, simultaneously capturing the thermal deformation reflected in the positioning errors of the spindle and along the machine axes.
While the HTM-based formulation provides a complete and interpretable physical model of the geometric and thermal errors, the real-time application of such a model requires the continuous estimation of multiple error components that are highly nonlinear, time-dependent, and sensitive to thermal dynamics. Direct measurement of these components is often impractical, and analytical modeling under variable thermal states becomes computationally intensive. To address this challenge, we adopt a hybrid approach where individual error components are estimated in real time using ANNs. These data-driven models are trained to learn the complex relationships between machine positions, temperature sensor inputs, and error behaviors. The predicted error components are then integrated back into the HTM-based volumetric error equations to compute real-time compensation values. This hybrid structure preserves the physical interpretability of the kinematic framework while leveraging the predictive strength and adaptability of neural networks.
3.1. Measurement of Error Components
As illustrated in
Figure 4, the used devices for error components measurement are: (i) 16 thermistors with measuring range from −20 °C to 120 °C and resolution of 0.0625 °C to track the temperature distribution in the most sensitive areas of the MT (ii) an API XD laser interferometer system to assess the positioning error in X and Z directions, in accordance with the ISO230-2 standard [
33], and the machine axes origins thermal drifts, and (iii) a simplified five displacement traditional non-contact sensors method to evaluate the spindle thermal drifts (two transitional drifts and angular inclination of the spindle axis), according to the ISO230-3 standard [
34]. Temperatures and various geometric and thermal error components must be measured concurrently to ensure that each set of thermal errors corresponds to a specific temperature distribution.
Thermal sensor location is crucial in any thermal error modeling and compensation strategy. If possible, the temperature sensors must be located near the structural elements which endure most of the thermal distortions. In this case, 16 thermistors are carefully positioned to track the temperature distribution in the most sensitive areas of the MT. Preliminary experimental investigation results suggest that some machine components only have small temperature variations, and the temperature variation in other components are not consistently interrelated to the thermally induced errors. The experimental exploration also indicates a powerful connection between average temperature growth along the spindle axis and thermal errors, which is strongly correlated to the spindle speed. Therefore, only 10 temperature sensor locations are retained as relevant variables to investigate in this application. The proposed locations are explicitly identified in
Table 2.
Environmental temperature fluctuations can result in an increase in thermally induced errors. It is therefore necessary to evaluate the effects of time-varying environmental temperature on the growth of thermal errors. For this purpose, some samples of environmental temperature and thermal error are collected for 24 h without machine operation. The results reveal that the effect of environmental temperature is small (1 to 2 µm). The correlation between the temperature and thermal errors is insignificant (less than 1%). This is attributed to the irregular growth of thermal drifts within a typical temperature range. Therefore, the contribution of environmental temperature to thermal error variation can be considered negligible. To characterize the thermally induced changes in the machine errors, the measurements are taken over representative temperature spectrum of the machine.
Figure 5 shows a typical temperature evolution, where the MT operates at specific federate speed and spindle rotation speed for 4 h, then stops for 4 h. This figure shows a clear distinction between the average temperature around the spindle (31 °C) and the temperature along the axes (26 °C). It can be observed also that the maximum temperature around the spindle is recorded at the bottom of the spindle end. Along the axes, the maximum temperature is recorded at the backside of X-slide drive mechanism, nevertheless the difference with the other locations around does not exceed 1 °C. During similar warm-up and cold-down cycle, the observed thermal expansion of the MT frame expressed in the form of machine axes origins thermal drifts error is illustrated in
Figure 6.
Measurements of positioning error in X and Z directions are carried out at displacement intervals of 20 and 30 mm, respectively. Results of the geometrical error measurements at a temperature of 20 °C approximately, illustrated in
Figure 7, show that the linear displacement error of the X-axis (more than 8 µm for a 300 mm travel) and the Z-axis (more than 18 µm for a 450 mm travel) are larger than the specified MT accuracy of ±5 µm. The straightness errors vary within intervals 3–6 and 2–5.5 µm, respectively, over X and Z directions. The angular errors measured at the same positions and the same thermal conditions are similarly presented. The angular errors vary within intervals 2–6 arcsec and 1–3 arcsec, respectively, over X and Z directions.
Observations from error measurement under mixed thermal conditions show that although errors varied with the average temperature, their basic appearances along the axes did not fundamentally change, as shown in
Figure 8. This observation concerns both translational errors and angular errors. The position-dependent errors can be expressed as the summation of the stationary parts (geometric errors) and time-variant parts. The stationary errors are active under cold machine starting conditions. During the machine operation, the time-variant errors (thermally induced errors) are added to the geometric errors.
Three initial investigations reveal a strong relationship between spindle thermal drifts and the rise in the average temperature increase along the spindle, as well as the spindle speed. For the spindle thermal drifts measurement (two transitional drifts and angular inclination of the spindle axis), the spindle rotates at selected rotating speeds for 4 h and then remains stopped for 4 h. During this time, the spindle thermal drifts and the temperature history are continuously monitored. The results outlined in
Figure 9 show that the thermal drifts and the average temperature profiles do not increase proportionally with the speeds. However, it is noteworthy that the growth of thermal drifts closely follows the variations in temperature. This characteristic offers significance in the modeling process providing the option to avoid including the spindle rotation speed as a variable in the prediction model.
3.2. Error Modeling and Simulation
The prediction of the resultant error components (E
cx and E
cz) at any location in the machine workspace and any machine thermal conditions requires the prediction of all the error components identified in Equations (16) and (17). The position-dependent error components are considered as a combination of axis nominal positions and temperatures at various locations. The position-independent error components depend only on temperatures at various locations. Considering that, four ANNs models are needed to predict all the error components (X-axis, Z-axis, coordinate system thermal drift and spindle thermal drift). The algorithmic framework to implement these models is schematically illustrated in
Figure 10. The nominal positions of the machine slides and the temperature sensors installed on the MT structure are scanned at a constant sampling rate. For every sample, each error component is predicted using the appropriate ANN model and integrated via Equations (16) and (17) for the prediction of the resultant error components.
The hybrid modeling framework integrates the HTM approach with data-driven ANN predictions to compute the total volumetric errors. The ANN models are trained to predict individual error components—both position-dependent and position-independent—using machine axis positions and temperature inputs. Once these individual components are estimated by the ANN models in real time, they are substituted into the HTM-based equations (Equations (16) and (17)), which represent the analytical formulation of the volumetric error vectors Ecx and Ecz. The HTM framework functions as a structured kinematic model that synthesizes the ANN outputs into physically meaningful error correction vectors. These vectors are then applied via the CNC’s compensation interface to correct the actual tool tip position.
The X-axis ANN model is based on the X position and four temperature sensors (XFS, XBS, ENV and WA) as inputs and error components (δxx, δyx, δzx, and εxx, εyx, εyx) as outputs while the Z-axis ANN model is based on the Z position and four temperature sensors (ZRS, ZLS, ENV and WA) as inputs and error components (δxz, δyz, δzz, and εxz, εyz, εyz) as outputs. The coordinate system drift model is built using XFS, XBS, ZRS, ZLS, ENV and WA as input and (δxOD and δzOD) as outputs. The spindle drift model uses SSN, BSN, SSE, BSE, ENV and WA as inputs and δzs, δxs, and εys as outputs.
To assess the performance of the proposed ANN models, many statistical measures such as Mean absolute deviation (MAD), Mean absolute percent error (MAPE), Root mean square error (RMSE) and Coefficient of determination R
2 are adopted. These metrics are explicitly expressed in Equations (17)–(20).
The performances of the four models are particularly good and present an important advantage for predicting the resultant error components both in terms of precision and reliability as well as in terms of robustness. The summary of modeling performance is presented in
Table 3. These results reveal that despite the intuitive choice of the temperature sensors included in each model, the quality of the predictions is beyond expectations. This confirms overall that each individual error component depends strongly on the temperature sensors distributed along its generative axis. A systematic procedure addressing the best selection of sensors to be considered in each model will be presented in a future paper.
Once the four predictive models are established, the compensation values E
cx and E
cz are synthesized using the algorithm illustrated in
Figure 10. The simulation tests conducted for various MT thermal conditions indicate the effectiveness of the adopted prediction approach.
Figure 11 illustrates the spatial-variant error components at environmental temperature (average temperature of 20.27 °C) and the difference between measured and predicted resultant error components in the X-Z-plane. It can be seen that the model fits very well the geometric position-dependent error components. Maximum errors without compensation reached 13 µm in the x-direction and 23 µm in the Z-direction. The residual errors show that the error can be reduced to within a 3 µm range after compensation.
Figure 12 and
Figure 13 illustrate the spatial-variant error components and compare measured and predicted errors in the X-Z-plane at average temperatures of 23.31 and 26.23 °C, respectively. In these two cases, maximum errors without compensation varied around 15 µm in the x-direction and around 28 µm in the Z-direction. The residual errors are reduced to less than 4 µm range after compensation. The quality of the prediction of the geometric-thermal errors is also confirmed at arbitrary average temperature between 20 and 30 °C. The predictive modeling approach provided a good prediction of the volumetric error under various machine thermal conditions, with an average error less than 4 µm.
Table 4 summarizes the statistical tests conducted to evaluate the predictive model’s accuracy for the two resultant error components (Ex and Ez) according to three different thermal cycles. Results show that the model performs very well. Despite maximum deviations reaching 15 µm in X and 28 µm in Z, the model maintains a mean absolute deviation below 1 µm, a mean absolute percentage error under 15%, and a small root mean square error. Coefficients of determination (R
2) range from 94% to 98% depending on the axis. Performance at 20.27 °C slightly exceeds that at 23.31 °C and 26.23 °C, suggesting minor challenges in capturing temperature-induced errors. Overall, predictive accuracy remains high enough to effectively drive error compensation.
To assess the actual performance of the model and its predictive accuracy under operating conditions not included in the training and testing datasets, additional tests are conducted under new thermal cycles. Since it is not possible to conduct the experiments with and without compensation using a single test, two separate tests are performed: one without compensation and the other with compensation. For this evaluation, an external error compensation system is implemented using the “external mechanical origin offset” function available in CNC systems. This method avoids modifications to CNC commands, ensuring that the workpiece coordinates would not be influenced.
The proposed evaluation procedure consists of assessing the model capacity during combined axis movements using the well-known diagonal test. Resultant error components, Ex and Ez, along the diagonals in the XZ plane, are derived from both measured and predicted error components under identical thermal conditions. Data are sampled at consistent intervals of 20 mm along the X-axis and 30 mm along the Z-axis. Throughout both tests, the average temperature remained relatively stable, fluctuating between 24.30 and 24.56 °C.
To evaluate the performance of the proposed predictive model, measured and predicted error components along selected diagonals are compared.
Table 5 and
Figure 14 present the results with and without compensation. These results demonstrate that the model maintains strong accuracy and robustness, even under varying temperature conditions. The residual errors are significantly reduced—from approximately 7 µm to less than 2.2 µm in the X direction, and from around 18 µm to below 4.5 µm in the Z direction—corresponding to accuracy improvements of 68% and 75%, respectively. This indicates the model’s effectiveness and confirms that the mapping between temperature variation and positioning errors remains consistent.
Although this study focuses on a two-axis turning center, the proposed hybrid methodology is extendable to multi-axis machines. The HTM formulation is inherently scalable to additional kinematic chains, and the ANN models can be retrained to capture more complex error behavior in milling or 5-axis systems, given sufficient sensor data and calibration.