Abstract
With the continuous development of manufacturing industry, the application range of NC machining technology has been further expanded. The contour accuracy is strongly related to the NC machining quality as a key machine tool performance indicator. Its application efficiency is plainly low as the majority of offline compensation-based contour accuracy adjustments rely heavily on manual experience. Moreover, the isolated research on automatic error compensation and its combination with algorithms does not start with the characteristics of contour accuracy in data processing. Therefore, based on the advantages of strong the robustness of the fuzzy algorithm and the high effectiveness of parameter adjustment, an automatic compensation method for NC machining contour error based on fuzzy control is proposed. The contour error prediction model is designed according to the machining path, and then the automatic compensation strategy for contour error under fuzzy control is designed based on the feed speed. The results showed that under this method, the contour error can reach a maximum of 0.06 and a minimum of 0.025, which was 0.015 lower than the minimum contour error of genetic algorithm. This indicated that the method greatly reduced the CNC machining contour error and improved the contour accuracy, as well as reducing the time cost of contour error compensation, improving the efficiency of contour error compensation, and realizing the automation of error compensation control capability. This is helpful for advancing CNC machining automation technology and supporting the intelligent development of machinery manufacturing.
Introduction
China’s economy is based on the manufacturing of machinery, and the level of that industry’s development reflects both the country’s economic strength and its level of science and technology [36]. With the advent of the information age, machinery manufacturing technology automation has become the trend, CNC machine tools is one of its embodiment [7, 17, 23, 27]. Unlike ordinary machine tools, the core of CNC machine tools lies in computer numerical control technology, through the computer’s pre-stored control program for the operation of machine tools and equipment for logical control, so as to improve the precision and accuracy of machining, while saving labour costs and improving the efficiency of machinery manufacturing [31, 37]. Error compensation, which aims to reduce machining errors and correct errors by creating an original error in the opposite direction of the current CNC machine tool, is a crucial component of CNC machine tool operation [14]. This meets the demand for high precision machining. Automatic error compensation is a combination of automation technology and error compensation, using computer software to complete a series of operations such as the estimation and compensation of errors, combining efficiency and refinement to achieve full automation of CNC machining processes and improve the level of machinery manufacturing and processing [21]. However, in practice, due to the complexity of CNC machine tools and the diversity of errors and other factors, error automation compensation has poor error elimination effect and processing accuracy is not high [20, 40]. Fuzzy control is a kind of computer digital control based on fuzzy set theory, fuzzy language variables and fuzzy reasoning. From a linear and nonlinear perspective, fuzzy control belongs to the type of nonlinear control. Fuzzy control, which falls under the category of intelligent control from the viewpoint of the controller’s intelligence, has emerged as a popular strategy for achieving intelligence. The fuzzy set theory directly expresses human’s judgment and thinking process in relatively simple mathematical form, so it can deal with complex systems in line with reality and human’s thinking mode. A fuzzy logic system based on fuzzy sets is a good solution when the controlled object cannot be accurately described. Due to the dynamic nature of CNC machining, cutting parameters are constantly changing, making accurate control and optimization of cutting parameters very difficult. This issue can be successfully resolved, and adaptive control of the machining parameters can be attained, by using model control theory. It can effectively grasp and accomplish the machining accuracy and efficiency of the CNC system during the machining process by continually detecting various variable factors, modifying cutting parameters in real-time, and enhancing machining quality. The study suggests a fuzzy control-based automatic compensation approach for CNC machining contour mistakes to enhance the effect of automatic compensation of CNC machining errors. This would increase the accuracy of CNC machining contour and boost the competitiveness of machinery manufacture.
Related work
As an automated machine tool, CNC machine tools play an important role in machine building with their advantages of high accuracy, adaptability and productivity. The dynamic error of CNC machine tools is the main reason that affects the machining error of complex curved parts. Scholar Lyu [10] define the dynamic error as the error problem in the feed motion, and divide the dynamic error into internal error and external error according to the difference of its servo circuit. The formulation of error strategy is achieved by coordinating the single-axis dynamic error. The results showed that the formulation of dynamic error control strategy outside the servo loop played an important role. To realize five-axis machining processing, scholar Chen [22] suggested a novel generalized parameter interpolation approach. He also proposed an explicit analytical model while taking the influence of machine tool contour inaccuracy and feed speed into consideration. For the purpose of trying to realize the free derivation between path parameters and arc length, the error constraint problem is converted into a kinematic constraint problem and a new real-time interpolation algorithm is employed. The five-axis machining and complex part machining can be efficiently optimized using the feed rate interpolation approach. Machine numerical control is ineffective in computer-aided manufacturing due to the discontinuity of tool path motion. Li’s team [3] proposed a direct path smoothing method based on neural network to obtain the smooth path of motion. The motion feature and reward model are constructed to strengthen the learning and realize the training of neural network parameters, with high real-time numerical control efficiency. In order to reduce the heat-induced positioning error of the machine tool, Scholar Shi [15] proposed a thermal error modeling method based on Bayesian neural network, and realized the temperature control of the CNC machine tool with fuzzy c-means clustering. The results showed that it can predict and analyze under various working conditions, and make the maximum thermal error decrease by more than 70%. Ji [32] made the suggestion that big data analysis might be used to implement distributed process optimization while taking into account the choice of machine tool, machining condition, and tool choice, and resolving optimization problems using an artificial neural network model. The outcomes demonstrated the method’s great applicability and efficacy. Scholar Colasante [1] realized the recognition and analysis of fault condition data with the help of expert rules and fuzzy logic algorithms, and designed a fault system for the spindle of CNC machining center. The results showed that the system had high diagnosis efficiency and reduces the diagnosis time by 80%. Aiming at the problem of free-form curve contour tracking error in NC machining, Scholar Ji [33] proposed a fuzzy PID algorithm based on improved PSO algorithm. Based on the error Equation of the plane trajectory, the error estimation algorithm of the free curve contour is designed, and the parameter optimization of the fuzzy controller is realized by adjusting the learning factor. The results showed that this strategy can significantly improve the contour control accuracy. A temperature sensitive point selection approach based on k-mean s clustering was proposed by Fu et al. [13] to research the thermal error compensation of CNC machine tools. This method uses the k-mean s algorithm to calculate the temperature variable based on the division of the heat source region. It has been discovered through simulation trials that the method streamlines the computation process, increases the effectiveness of determining the best temperature point, and establishes the groundwork for thermal error compensation. Wang et al. [11] developed a ball screw drive system based on determining parameters such as inertia matching from a kinetic perspective for the limitations of insufficient stability of high-speed CNC machine tools. Experiments proved that the system ensured the stability of high-speed machine tools, while improving the productivity and quality of CNC machining and providing a technical basis for the development of machine building. Guo et al. [29] discussed the significance of the stiffness of CNC machine tools in the construction of machines and proposed a method for identifying weak parts in cantilever structures by combining finite elements and weak part identification. The finite element method is used to run simulations based on the suggested weakness indicators. According to the experimental study, the method is highly adaptable, increases the precision of weak part identification in difficult situations, and makes it easier to increase the stiffness of CNC machine tools.
Fuzzy algorithms are intelligent algorithms that are often combined with control for application in the field of intelligent control. In the current industrial processing problems, Scholar Lin [5] proposed a fuzzy control system based on curvature and curvature change to realize the planning of dynamic cutting feed rate. The experimental results showed that the dynamic fuzzy control system can achieve more than 40% of the cutting accuracy improvement, reduce the cutting time by more than 50%, and have good applicability. The input parameters in the problem were designed by Scholar Savkovic [4] as the objective function to solve the problem, and the artificial neural network, fuzzy logic, and genetic algorithm were designed to realize the mathematical processing of the cutting area. These models were used to realize the reliable intelligent model design of the milling process. The outcomes demonstrated the high applicability of the aforementioned strategies. Aimed at the selection of industrial servo system, Scholar Shamseldin [24] proposed a variable structure fuzzy PD controller scheme. The candidate models are obtained by means of linear least squares, nonlinear least squares and depth neural network (DNN). The results showed that the fuzzy PD control proposed in the study had better nonlinear behavior than the conventional control method and fixed structure control method, effectively reduced the adjustment test time, and has a minimum tracking error of 0.412. With the aid of neural networks and genetic algorithms, scholar “wi” [2] created three different types of hybrid controller models, realizing automation in the processing of control in terms of choosing multi-layer perceptrons and nonlinear regression networks and the optimal value of input parameters. At the same time, the training network is adjusted according to the actual test data, and the results show that the control method of low stiffness shaft turning is highly effective. To address issues such nozzle structure crosstalk and obstruction, Xu et al. [19] employed multi-material RP as a study object and suggested a fuzzy adaptive control electro-thermal response approach. They also built a physical model and control model. In addition to demonstrating the efficacy and viability of the technology, they discovered that physical characteristics like temperature variation all mirrored the electrothermal responsiveness, which is advantageous to the high quality of RP materials. Kien et al. [6] designed a T-S fuzzy controller and optimised it using the DE algorithm to improve the stability of the controller and enhance its self-adaptability In an experiment with an SMD benchmark system, compared to traditional control methods, the method improves the efficiency and accuracy of system control and can be promoted and applied in the field of control of nonlinear systems. At present, the optimization of machining process parameters is mainly focused on numerical simulation and physical model, which has high cost and low accuracy. Scholar In order to achieve multi-objective parameter optimization and the formulation of pertinent strategies, Wu [25] presented data-driven genetic algorithms and TOPSIS based on deep learning. The TOPSIS algorithm can find the optimal processing parameters, while the genetic algorithm can integrate optimization objectives and produce Pareto sets. The results showed that the parameter selection method was effective and can achieve the balance between different conflicting targets. Simulated annealing algorithm can realize the maintenance and detection of manufacturing equipment through algorithm simulation training, and it has good applicability. To reduce the machining error of near-net blades, Wu’s team [12] proposed adaptive NC machining technology, built the necessary machining error transfer flow model, and conducted experimental analysis on three aspects of positioning reference error, machining position error, and machining contour error. The results showed that the adaptive CNC machining algorithm had a 60% application effect in reducing the final deviation of the blade body, and can effectively control the blade error position, showing a good processing ability.
The aforementioned results demonstrated that a key element in raising the system’s application accuracy was enhancing the dynamic error control of CNC machine tools. In order to achieve the optimization of the machining route and control of machine tool error, several scholars have presented generalized parameter interpolation, neural network, Bayesian neural network, and other methods, with a primary focus on the stability and accuracy of CNC machine tools. For the contour error problem in NC machining, some scholars combine fuzzy control theory with particle swarm optimization algorithm and neural network to achieve parameter control and multi-objective optimization, but less focus on automatic error compensation. To increase the accuracy of NC machine tool processing and advance the level of mechanical manufacturing automation, the research proposes an automatic compensation technique of NC machining contour error based on fuzzy control, starting with the contour error model.
Automatic compensation method for CNC machining contour errors based on fuzzy control
Contour error prediction model
Currently, the majority of primary CNC machining uses an offline method to change the contour accuracy compensation. This method is inefficient and is improved based on manual experience. The error automatic compensation method based on fuzzy control is established after examining the contributing factors to the contour error of CNC machining and creating the model. A fuzzy algorithm is used to control the feed speed, and a fuzzy rule is constructed. When analyzing the error compensation effect of different algorithms, the analysis of the generalization performance and precision effect of the algorithm should be concentrated, the error compensation effect and prediction accuracy of the algorithm in the application effect should be emphasized. Therefore, the application performance is analyzed in this section. The core idea is that the CNC system plans the movement path of the CNC machine based on the reference tool information, including tracking accuracy, speed and acceleration, and transmits this planning information to the drive axis, generating reference position information containing position and time. The control module reads the relevant position information and then drives the servo-electric movement to complete the CNC machining [28, 35, 38]. In this process, the distance in the vertical direction between the machining tool tip point and the target motion trajectory is the contour error, which is the error between the machine tool input trajectory and the output trajectory. It reflects not only the accuracy of the part machining contour, but also other errors in the CNC machining process, which directly affects the level and quality of CNC machining control. The ability to accurately predict contour error is helpful for timely CNC machining control adjustments, reducing the cost of additional adjustments while lowering the contour error of CNC machining, and increasing the productivity of CNC machine tools [8, 34, 39]. The drive axis is where the contour error originates from. As the feedback control system for CNC machine tools, the servo system’s primary duty is to adjust the drive axis to the planned target position. However, during the actual control process, a lag between the operating trajectory and the intended trajectory occurs due to the servo system’s own delay and other factors. The contouring error generation process is shown in Fig. 1.

Profile error generation process.
Figure 1 illustrates that the contour error in the servo system is directly related to the error brought on by the motion of the drive shaft. On the one hand, it is challenging for the drive shaft’s command reaction speed and other capabilities to satisfy the high-precision requirements of the actual NC machining, which causes the workpiece contour error; On the other hand, parts in the servo system, such as amplifiers and guides, will inevitably affect the machine tool during the NC machining process, further expanding the contour error.
In accordance to the CNC machine tool machining trajectory for the contour error prediction, for the circular trajectory of the machining trajectory, assume that the center of the circular trajectory is P, its coordinates are (m0, n0), the radius of this trajectory is r, then the current moment under the calculation of the contour error as shown in Equation (1).
In Equation (1), (q a , q b ) represents the coordinates of the actual position Q point at the current moment. The location of the circle’s center in the circular trajectory is difficult to predict because of the uncertainties and disruptions that arise throughout the actual machining process. Based on conditions such as the tracking error c at the current moment, the coordinates of the centre of the circle are calculated and the operation is shown in Equation (2).
In Equation (2), (w a , w b ) represents the coordinates of the target position W at this moment, and c a and c b represent the tracking error components in the direction of the drive axes a and b, respectively. The contour error after circular adjustment is calculated as shown in Equation (3).
In Equation (3), θ represents the angle between the tangent line at W and the a axis for a circular trajectory at this point. For linear trajectories, the contour error is calculated in Equation (4).
In Equation (4), e
a
and e
b
represent the projection of the tracking error in the direction of the drive axes a and b respectively, and θ represents the angle between the a axis and the linear trajectory. For free curve type machining trajectories, the contour error can be calculated in a variety of ways, such as by setting interpolation points and utilizing the line between the interpolation points to determine the contour error, as indicated in Equation (5).
In Equation (5), u indicates the actual position of the tool at this moment. In addition, the contour error under a free-curve machining trajectory can also be calculated by closely circling to approximate a circular trajectory, which is shown in Equation (6).
In Equation (6), ɛ indicates the degree of curve bending change of the close circle, and α indicates the angle between the tangent vector and the command target position at the current moment. The study employs data such as tracking error projection to build a real-time prediction model of contour error in order to improve the efficacy of contour error prediction. This will decrease the number of operations, improve the accuracy of contour error prediction of free-curve type machining trajectories, and make up for the shortcomings of the prediction method based on interpolation points and close circles. Assuming that the target position and the actual position under the current moment are y1 and y2 respectively, the calculation of the contour error is shown in Equation (7).
In Equation (7), β represents the angle between the a axis and the line where the projection point and the target position are located, which is calculated as shown in Equation (8).
In Equation (8),

Structure of contour error prediction model.
Contour error reflects the error of simultaneous motion between multi-axes in NC machining. In accordance to the definition of contour error, its calculation process can be seen as the process of calculating the shortest distance from a point outside the track to the track from a geometric angle. However, the motion path between multi-axes does not necessarily follow a straight line, and the different directions of the path make the different machining error paths. Linear and circular trajectory error models are built according to their geometric characteristics. The error model under the free curve trajectory is measured by the approximation state of straight line and circle. From Fig. 2, the core of the contour error prediction model lies in the CNC machine tool machining trajectory. The contour error prediction model is divided into three calculation models based on the various machining trajectories: circular, linear, and free curve. The three calculation models’ respective cores are the circular center position, tracking error projection, and real-time prediction. By calculating and predicting each type of trajectory, it is beneficial to have a comprehensive grasp of the contour error situation and effectively reduce the error of contour error prediction. In other words, the type identification and division of contour motion path in the NC machining process can effectively improve the accuracy of its identification, and thus improve the pertinence and effectiveness of error control.
While some relatively complex control systems in engineering practice are difficult to mathematically model and cannot be controlled with the aid of conventional control methods, the problems resulting from them can be controlled with the aid of language operation rules condensed from experience. Fuzzy control is a method of expressing human’s natural language as a control strategy, which transforms into numbers or digital functions through fuzzy sets and fuzzy logic reasoning, and then realizes predetermined control with the help of computers. As a non-traditional model algorithm, fuzzy algorithm is often used in the control of complex systems due to its fuzzy processing characteristics. To achieve the control of systems like time-varying and lagging, fuzzy control integrates the theory of linguistic variables with fuzzy set theory to build language control rules by summarizing the experiences and lessons acquired by system operators, etc. [9, 18, 30]. Fuzzy control is free from the reliance on mathematical models of precise objects and enhances the ability to control objects with non-linearities and uncertainties, and has strong robustness and applicability. With the goal to improve the accuracy of contour error compensation and accelerate the efficiency of error compensation in order to improve the performance of CNC machine tools, it is applied to the automatic correction of contour errors [16, 26]. This corrects for the shortcomings of contour error compensation by controlling the feed rate. To improve the effectiveness of contour error compensation, a real-time contour error compensation method is used to predict and compensate the contour error of the command target path at the next moment, obtain the interpolation point at the next moment and form a new interpolation path to achieve compensation of the contour error during the real-time motion. Assuming that the foot point of the contour error is T, the actual position of the servo control system is calculated using the transfer function and the transfer function is presented in a discrete form, the expression of which is shown in Equation (9).
In Equation (9), O (z-1) represents the z transformation operation, h and g represent the z transformation parameters and n represents the number of CNC machine system input positions. On this basis, the z transformation of the drive axes is calculated as shown in Equation (10).
In Equation (10), O
a
(z-1) and O
b
(z-1) represent the discrete transfer functions after transformation of the a and b axes z, respectively. The actual position at the next moment can be obtained by calculation, the operation of which is shown in Equation (11).
In Equation (11), v represents the current moment and R represents the command position at the current moment. The real-time contour error compensation flow is shown in Fig. 3.

Real-time contour error compensation process.
In accordance to Fig. 3, real-time contour error compensation determines the preliminary contour error by examining the commanded target trajectory and applying the transfer function to determine the actual position point at any given time. The filter shaping process is then applied to increase the stability of the contour error compensation. Through contour error compensation to form a new target trajectory path, improve the consistency between the machining trajectory and the target trajectory, so as to reduce the contour error of CNC machining.
During real-time contour error compensation, the generation of new target trajectories and the instability of free curve-type motion trajectories can interfere with the contour error compensation and fail to meet the contour accuracy of the workpiece machining. To improve these deficiencies, the study uses a fuzzy algorithm to control the feed rate with a view to limiting the displacement of the workpiece and the prop in the feed direction and further improving the accuracy of contour error compensation. In the fuzzy controller, the contour error and the corresponding change amount at the next moment are taken as input variables, denoted as d and d′, respectively, and the feed speed change amount is taken as output variable, denoted as e, with fuzzy variables as D, DK and E, whose fuzzy subsets are expressed as shown in Equation (12).
In Equation (12), the value range of the fuzzy variable D is [0, 1], and the domain value range of the fuzzy subset of DK and E is [– 1, 1]. The quantization factor is set to complete the conversion of the input variables to the defined set of fuzzy variables to achieve the fuzzification of the input variables. The quantization factor is calculated in Equation (13).
In Equation (13), K d and Kd′ represent the quantization factors of the input variables d and d′ respectively; l and j represent the input quantities of the two variables respectively, f d and fd′ represent the maximum values of the fundamental domain of the two variables.
The fuzziness of the output input variables is described using the triangular subordinate function, and fuzzy control rules are built using the if-then rule based on the characteristics of a servo fuzzy control system with multiple inputs and single outputs, which summarizes and generalizes the expertise and relevant experience of the language experts. On this basis, the advantages of independent processing of Mandani inference algorithm components, strong linguistic information carrying capacity and high applicability are utilised for fuzzy inference of feed rate regulation, the formulation of which is shown in Equation (14).
In Equation (14), γ
C
(e) represents the affiliation of the output variable, x and y represent the input variables, and i and j represent the contour error and the amount of variation. The resulting fuzzy output variables are defuzzified to obtain the exact feedrate output values, the operation of which is shown in Equation (15).
In Equation (15), v represents the first v output quantity and its total quantity is n. The automated compensation process for contour errors based on fuzzy control of feed rate is shown in Fig. 4.

Automatic compensation process of contour error based on fuzzy control of feed speed.
In accordance with Fig. 4, the automatic correction of contour error based on fuzzy control of feed speed is divided into two parts: real-time error correction and fuzzy control correction. The former uses the actual position points to correct the contour error, and the latter uses feed speed as an intermediary to correct the contour error by using operations like fuzzification, logical inference, and defuzzification. The automatic compensation process of CNC machining contour error based on fuzzy control is shown in Fig. 5.

Automatic compensation process of NC machining contour error based on fuzzy control.
From Fig. 5, in the CNC machining contour error automation compensation method based on fuzzy control, the contour error prediction model is a clear grasp of the machining trajectory, which can lay a good foundation for error automation compensation. For the purpose to overcome the drawbacks of real-time automation error correction and advance its accuracy and effectiveness, fuzzy control then adjusts the feed rate using fuzzy theory.
Algorithm performance analysis
With the use of the Matlab workspace, the command position data is transmitted to the simulation model during the experimental simulation process. The discovered transfer function predicts the real position, and the contour error estimation model predicts it. The two-axis XY motion control platform used in this experiment mainly includes upper computer part, servo drive control part (Trio motion control card), mechanical transmission part and sensor feedback part (encoder of AC servo motor). Repeat the experimental operation on the experimental platform to obtain the error data of different measuring elements after operation, and divide the data set into data set A (large sample volume) and data set B (small sample volume) according to the size of error data.. In both datasets, 80% were selected as the test set, 10% as the validation set and 10% as the training set respectively. In the experiments, Genetic Algorithm (GA) and Simulated Annealing (SA) were added as experimental comparisons. The parameter setting of genetic algorithm is mainly in reference 22, and the simulated annealing algorithm is mainly in reference 31. The accuracy and Area under Curve (AUC) values were used as judgement criteria to compare and analyse the performance of the algorithms. The comparison of accuracy under different methods is shown in Fig. 6.

Accuracy comparison under different methods.
In Fig. 6, the experimental results of Research algorithm in both datasets are similar, with both methods stabilising after 100 iterations and reaching an accuracy of 0.7, and with the increase in the number of iterations, the change in stability is less volatile and more stable. GA has an accuracy of 0.5 in both datasets, but performs better in Dataset 1 with fewer iterations. In Dataset 1, SA’s accuracy is roughly 0.5. Compared to dataset 1, SA’s accuracy is roughly 0.5, an improvement of 0.1; nevertheless, SA’s convergence speed has slowed down. It is clear that the Research algorithm increases the operation’s efficiency and convergence speed while also increasing error prediction and error prediction accuracy. A comparison of the AUC values under the different methods is shown in Fig. 7.

The comparison of AUC values under different methods.
In Fig. 7, in the training and testing of dataset 1, the AUC values of Research algorithm, GA and SA are 0.849, which is an improvement of 0.076 compared to the AUC value of GA, and SA has the lowest AUC value of 0.740; in the training and testing of dataset 2, the AUC values of Research algorithm, GA and SA are 0.824, 0.764 and 0.736 respectively. The algorithm has the best performance and is conducive to increasing the accuracy of contour error prediction, lowering contour errors, laying the groundwork for automatic error compensation, and enhancing the accuracy of part contour machining, as can be seen from the fact that the AUC value of the Research algorithm is the highest in the experiments of both datasets.
Subsequently, the sensitivity of the three algorithms was analyzed, and the case size was selected for experimental analysis. The average of the experimental results was taken for analysis. During the experiment, the number of iterations was set to 300, with a minimum of 5 observations. The initial distance of the workpiece fixed on the spindle was 300 mm, and the initial axial force was 147 N. When the response time changes from 0.01 to 1.0, the error indicator results of the three algorithms are shown in Fig. 8.

Analysis of parameter sensitivity results of three algorithms for CNC products with different parts.
The results in the figure indicate that the error indicators exhibited by the three algorithms vary significantly with the response time parameters under different parts of CNC products. On small part products, when the response time changes from 0.01 to 1.0, the GA algorithm and SA algorithm exhibit significant oscillations. The maximum error values of the two algorithms occur at the response time of 0.01 s (0.445) and 0.015 s (0.447), respectively, and the error indicators of the two algorithms show a reciprocating change of first increasing and then decreasing. The largest error value occurs when the response time is 0.01 seconds (0.442), and the overall error findings of the algorithm suggested in the study indicate a curve trend with minor oscillations. The SA algorithm and GA algorithm produced different results in the short response procedure for large CNC parts. The overall error index curve of the proposed algorithm showed a decreasing trend, with its maximum value appearing in the response time of 0.005 s. The error results of SA algorithm and GA algorithm show significant differences from those in Fig. 8(a), indicating that these two algorithms are more susceptible to parameter changes during the calculation process.
A CNC machining workshop was selected for the application of the method, and the contour error value, error positioning time and positioning times after compensation were analysed, and Mean Absolute Error (MAE), Root Mean Square Error (RMSE) and Mean Absolute Percentage Error (MAPE) were used as error judgement indicators. Percentage Error (MAPE) were used as error judgement indicators. In this process, GA and SA are still added as experimental comparisons. Before the experiment, the machine tool trajectory and other parameters are planned and set, as shown in Table 1.
NC machine tool and machining path parameter setting
NC machine tool and machining path parameter setting
From Table 1, the CNC machine tool drive mechanism uses ball screw nut sub, the AC servo motor model is MSMD012G1U, the interpolation cycle is 3 T/(ms), the maximum feed speed is 60 mm/s respectively, the maximum acceleration is 1200 mm/s2, the number of control points is 130, the total length of the machining path is 360 mm, the planning positions of A axis and B axis are A comparison of the contour error compensation effect is shown in Fig. 9.

Comparison of contour error compensation effect.
The MAE value of the contour error in Fig. 9 with the automatic Research algorithm adjustment continues in the region of 0.4–0.5, and the RMSE value is stable in the range of 0.15–0.3. Overall, both mistakes are less varied and quite steady. With the increase of machining trajectory, the MAPE value varies greatly, reaching the maximum value of 0.06 when the trajectory length is about 110 mm, and the minimum value of 0.025 when the trajectory length is 180 mm. The MAE value and RMSE value of the contour error of GA are similar, both stable in the range of 0.04–0.13, with large variations, the highest and lowest MAPE values reached 0.15 and 0.08 respectively. The three error effects of SA were similar, all varying in the range of 0.06–0.14. It is clear that the Research method dramatically increases the efficiency of automated contour error correction and lowers contour errors in CNC machining. A comparison of the compensation time and number of times under different methods is shown in Fig. 10.

Comparison of compensation time and times under different methods.
Figure 10 illustrates the stark contrast between the Research algorithm’s automatic adjustment time and the quantity of times the contour inaccuracy occurs compared to other approaches. SA has the highest number of compensations, 19, which is 12 times more than Research algorithm. The efficiency of error compensation is improved, personnel and time expenses are reduced, and the automation level of CNC machining contour error compensation is increased as a result of the research algorithm, which can be shown to considerably reduce the number of times and time required for error automation compensation. The results are displayed in Fig. 11 for the three algorithms’ predictions of the machining axis.

Machining axis prediction under three algorithms.
Figure 11 shows the accuracy prediction results of the three algorithms in the NC machining process. The measured value is drawn on the horizontal axis, and the total length of the machined axis is 300 mm. The findings in the figure demonstrate that the reference curve produced by the proposed control algorithm and the observed curve exhibit almost the same trend, with an overall error of less than 2%. When the machining axis length is between (0100) and (175270), the GA and SA algorithms’ prediction curves deviate by more than 2.5% from the reference value, and the objective function’s highest deviation values are 4.07% and 2.97%, respectively.
The mature development of intelligent technology promotes the development of mechanical processing and manufacturing in the direction of refinement and efficiency, and the traditional CNC processing efficiency is low. The contour error caused by the free parameter curve path has become an important factor affecting machining quality. Based on this, fuzzy control is proposed to realize automatic compensation of NC machining contour error, and improvement is realized through error analysis and the formulation of a feed speed strategy. The results showed that the proposed method tended to be stable after 100 iterations, and its accuracy reached 0.7, which was far greater than 0.5 of GA algorithm and SA algorithm, and the convergence speed had been significantly improved. In terms of the AUC index, the numerical values of the three methods under dataset 1 are: research method (0.849)>GA algorithm (0.773)>SA algorithm (0.740). In data set 2: research method (0.824)>GA algorithm (0.764)>SA algorithm (0.736). The suggested approach performs well in the performance analysis of the error compensation application and can more effectively reduce profile error. Specifically, its MAE value and RMSE value are stable in the range of 0.4–0.5 and 0.15–0.3, and the minimum MAPE value is 0.025. The errors of the GA algorithm and the SA algorithm vary greatly, and are significantly lower than the algorithm proposed in the study. Moreover, the proposed algorithm is significantly less than the GA algorithm (220 s, 11 times) and SA algorithm (230 s, 19 times) in compensation time (60 s) and compensation times (7 times). At the same time, the prediction accuracy deviation of the proposed algorithm is less than 2%, compared to less than 2.5% of the GA algorithm and the SA algorithm. The above results showed that the error compensation algorithm based on fuzzy control can effectively improve the contour accuracy of NC machining. Future research and focus should be directed toward expanding the analysis of contour error outcomes under abrupt trajectories and further optimizing the algorithm for nonlinear servo system challenges.
Funding
The research is supported by: Guangdong Provincial Key Construction Discipline Scientific Research Capacity Improvement Project, Research on reliability analysis and optimization method of complex mechanical system based on multiple intelligent extremum response surface, (2022ZDJS149); Guangdong University of Science and Technology “Innovation and University Strengthening Project” (research) project, Mechanical Engineering Discipline Improvement Plan, (GKY-2022CQXK-1).
