Numerical control machine tool control method and system for complex curved surface machining
By reconstructing the kinematic chain model of CNC machine tools and predicting inter-axis phase lag, a synchronized command flow is generated, which solves the problem of poor synchronization in multi-axis cooperative motion and realizes high-precision machining of complex curved surfaces.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NANJING KAITONG AUTOMATION TECH CO LTD
- Filing Date
- 2026-03-11
- Publication Date
- 2026-06-05
Smart Images

Figure CN122151708A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of CNC machine tool control, and more specifically to CNC machine tool control methods and systems for machining complex curved surfaces. Background Technology
[0002] As the core equipment for machining complex curved surfaces, the multi-axis collaborative control accuracy of CNC machine tools directly determines the machining quality of parts.
[0003] In existing multi-axis collaborative CNC machine tool control systems, instruction reconstruction is not performed in conjunction with the machine tool's kinematic chain model, resulting in insufficient compatibility between instructions and the machine tool's mechanical structural characteristics. This leads to an inability to accurately predict phase lag, resulting in insufficient timeliness and accuracy in compensation; the contour error calculation does not fully consider phase lag, ultimately causing poor synchronization of multi-axis collaborative motion, low prediction accuracy, and poor compatibility between instructions and the machine tool's mechanical structural characteristics.
[0004] In summary, there is an urgent need for a CNC machine tool control method that can achieve multi-axis synchronous precise control, accurate error prediction, and dynamic compensation. Summary of the Invention
[0005] This application provides a control method and system for CNC machine tools for machining complex curved surfaces, aiming to solve the problems of poor synchronization of multi-axis cooperative motion, low prediction accuracy, and low compatibility between commands and machine tool mechanical structure characteristics in the prior art.
[0006] In view of the above problems, this application provides a CNC machine tool control method and system for machining complex curved surfaces.
[0007] In a first aspect, this application provides a CNC machine tool control method for machining complex curved surfaces, including:
[0008] The CNC machining program used for machining complex curved surfaces is analyzed, the original G-code instruction streams driving each motion axis are extracted, and the ideal position instruction sequence and ideal speed instruction sequence of each motion axis are reconstructed based on the machine tool kinematic chain model.
[0009] Based on the ideal speed command sequence and the historical following error data of each axis servo system, the command phase lag of each motion axis relative to a virtual spindle is estimated by the inter-axis phase lag predictor when executing the current machining segment. The virtual spindle is defined by the tangential feed motion of the machining path.
[0010] Based on the command phase lag of each motion axis and the geometric curvature and tangent direction of the machining path at the current interpolation point, the estimated contour error vector caused by phase asynchrony is calculated through the contour error coupling mapping model.
[0011] Based on the estimated contour error vector, combined with the contour accuracy requirement constraint predefined in the current processing area of the surface to be processed, and the axis contribution weight matrix, a compensation optimization model with the goal of minimizing the weighted comprehensive contour error is constructed and solved.
[0012] Based on the solution of the compensation optimization model, a set of inter-axis phase compensation instructions are generated, and the inter-axis phase compensation instructions are fused with the original G-code instruction stream in the CNC machining program to generate a synchronized instruction stream that drives the movement of each axis of the machine tool.
[0013] Secondly, this application provides a CNC machine tool control system for machining complex curved surfaces, including:
[0014] The instruction sequence reconstruction module is used to parse CNC machining programs for complex surface machining, extract the original G-code instruction streams driving each motion axis, and reconstruct the ideal position instruction sequence and ideal speed instruction sequence of each motion axis according to the machine tool kinematic chain model.
[0015] The command phase lag prediction module is used to predict the command phase lag of each motion axis relative to a virtual spindle when executing the current machining segment, based on the ideal speed command sequence and the historical following error data of each axis servo system, through an inter-axis phase lag predictor. The virtual spindle is defined by the tangential feed motion of the machining path.
[0016] The contour error prediction module is used to calculate the predicted contour error vector caused by phase asynchrony based on the command phase lag of each motion axis and the geometric curvature and tangent direction of the machining path at the current interpolation point, through the contour error coupling mapping model.
[0017] The compensation optimization model construction module is used to construct and solve a compensation optimization model with the goal of minimizing the weighted comprehensive contour error, based on the estimated contour error vector, combined with the contour accuracy requirement constraint predefined in the current processing area of the surface to be processed, and the axis contribution weight matrix.
[0018] The instruction generation module is used to generate a set of inter-axis phase compensation instructions based on the solution of the compensation optimization model, and to fuse the inter-axis phase compensation instructions with the original G-code instruction stream in the CNC machining program to generate a synchronized instruction stream to drive the movement of each axis of the machine tool.
[0019] One or more technical solutions provided in this application have at least the following technical effects or advantages:
[0020] This application first extracts the original G-code instruction stream by analyzing the CNC machining program for complex curved surfaces, and reconstructs the ideal position instruction sequence and ideal speed instruction sequence for each motion axis by combining the machine tool kinematic chain model. This effectively solves the problem of insufficient adaptability of traditional G-code instructions to the mechanical structure characteristics of the machine tool when executed directly, ensuring that the instruction reference is accurately matched with the kinematic laws of the machine tool. Second, based on the ideal speed instruction sequence and the historical following error data of each axis servo system, the inter-axis phase lag predictor estimates the instruction phase lag of each motion axis relative to the virtual spindle in the current machining segment, achieving accurate prediction of phase lag and improving prediction accuracy, thus providing a reliable basis for subsequent error compensation.
[0021] Furthermore, by combining the phase lag of each motion axis command with the geometric curvature and tangent direction, a contour error vector is calculated using a contour error coupling mapping model to achieve accurate prediction of contour errors and improve the completeness and accuracy of error prediction. Simultaneously, based on the predicted contour error vector, a compensation optimization model is constructed by integrating the contour accuracy requirement constraints of the current region of the surface to be processed and the axis contribution weight matrix. This enables differentiated allocation of compensation resources, reducing the weighted comprehensive contour error and meeting the differentiated accuracy requirements of different processing areas. Finally, an inter-axis phase compensation command is generated based on the optimal solution of the compensation optimization model and merged with the original G-code command stream to generate a synchronized command stream that drives the movement of each axis of the machine tool. This solves the problem of insufficient synchronization caused by the disconnect between traditional compensation commands and processing commands.
[0022] In summary, the seamless integration of compensation and machining commands has been achieved, reducing inter-axis coordination errors and ultimately ensuring improved contour accuracy and reduced surface roughness in the machining of complex curved surfaces, thus fully meeting the high-precision machining needs of high-end manufacturing fields such as aerospace and precision molds. Attached Figure Description
[0023] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 A flowchart illustrating the control method for CNC machine tools designed for machining complex curved surfaces;
[0025] Figure 2 This is a schematic diagram of the structure of a CNC machine tool control system for machining complex curved surfaces.
[0026] The labels in the attached diagram are explained as follows:
[0027] Instruction sequence reconstruction module 11; instruction phase lag prediction module 12; profile error prediction module 13; compensation optimization model construction module 14; instruction generation module 15. Detailed Implementation
[0028] This application provides a CNC machine tool control method and system for machining complex curved surfaces, which addresses the problems of poor synchronization of multi-axis cooperative motion, low prediction accuracy, and low compatibility between commands and machine tool mechanical structure characteristics in the prior art.
[0029] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0030] It should be noted that the terms "comprising" and "having" are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or modules that are not explicitly listed or that are inherent to these processes, methods, products, or devices.
[0031] Example 1, as Figure 1 As shown, this application provides a CNC machine tool control method for machining complex curved surfaces, the method comprising:
[0032] S10: Analyze the CNC machining program used for machining complex curved surfaces, extract the original G-code instruction stream that drives each motion axis, and reconstruct the ideal position instruction sequence and ideal speed instruction sequence of each motion axis based on the machine tool kinematic chain model;
[0033] In this embodiment of the application, the CNC machining program refers to a standardized code set containing machine tool motion instructions written to realize the machining of complex curved surfaces, and is the core basis for the CNC machine tool to perform machining tasks; the original G code instruction stream is a continuous instruction sequence in the CNC machining program that directly drives the motion of each motion axis, and contains basic control information such as position, speed, and feed rate.
[0034] The kinematic chain model of a machine tool is a mathematical model describing the position and velocity transmission relationships between the various motion axes of a machine tool. It needs to be constructed in conjunction with the machine tool's mechanical structure and motion constraints to accurately map the correspondence between commands and axis motions. The ideal position command sequence is the sequence of position changes that each motion axis should theoretically follow, extracted and reconstructed from the original G-code based on the kinematic chain model. The ideal velocity command sequence is the sequence of velocity changes that each motion axis should theoretically maintain, corresponding to the ideal position command sequence. It is obtained by differentiating the position sequence with respect to time or directly parsing from the G-code.
[0035] First, the CNC machining program used for machining complex surfaces undergoes syntax parsing and semantic extraction to filter out the original G-code instruction streams driving each motion axis (X, Y, Z), removing irrelevant information such as comments and program segment identifiers. Then, a pre-established machine tool kinematic chain model is invoked. Based on parameters such as the machine tool's mechanical transmission ratio and inter-axis coupling relationships, inverse kinematics is used to transform the Cartesian space path coordinates in the original G-code into joint space coordinates for each motion axis. Finally, using a joint space continuous trajectory function, the joint space coordinates are discretized according to the machine tool interpolation cycle to generate ideal position and speed command sequences for each motion axis.
[0036] The ideal position command sequence can be continuous data where the X-axis position is X1 at time t1 and X2 at time t2, and the ideal velocity command sequence can be the velocity v of the X-axis during the time interval t1-t2. X1 .
[0037] Furthermore, inverse kinematics (IK) is the process of solving for the vector composed of all joint variables given the pose of the end effector. Through numerical methods of IK, the Cartesian path coordinates in the original G-code are solved to obtain the joint space coordinates of each motion axis. The Cartesian coordinate system is a general term for both rectangular and oblique coordinate systems. Two number axes intersecting at the origin constitute a planar affine coordinate system.
[0038] For example, the original G-code instruction stream driving the X / Y / Z axes and rotary axes is extracted: [G01 X0 Y0 Z0 F50; G01 X10 Y8 Z5 F50; ...]. Subsequently, the kinematic chain model matching the machine tool model to be controlled is retrieved: the DH parameter model of the five-axis machine tool. Through inverse kinematics calculation, and discretization of the joint space coordinates according to a machine tool interpolation cycle of 0.1ms, the ideal position instruction sequence for each motion axis is generated. X-axis: [(t0,0),(t1,0.01),...,(t...] n [,10)], Unit: mm, Ideal speed command sequence, X-axis: [(t0,0),(t1,100),...,(t n[,100)], Unit: mm / s.
[0039] In this embodiment, the original G-code command stream of each motion axis is extracted by analyzing the CNC machining program for complex curved surface machining, and the ideal position and velocity command sequence is reconstructed by combining it with the machine tool kinematic chain model. Reconstructing the ideal command sequence through the machine tool kinematic chain model solves the problem of mismatch between the original G-code command stream and the actual motion characteristics of the machine tool, laying a data foundation for subsequent accurate compensation and avoiding machining deviations caused by missing command information.
[0040] S20: Based on the ideal speed command sequence and the historical following error data of each axis servo system, the command phase lag of each motion axis relative to a virtual spindle is estimated by the inter-axis phase lag predictor when executing the current machining segment, wherein the virtual spindle is defined by the tangential feed motion of the machining path;
[0041] In this embodiment, the following error data refers to the deviation data between the actual movement position of the machine tool axis and the ideal position command, reflecting the degree of matching between the servo system response speed and the command requirements; the inter-axis phase lag predictor is a prediction tool built on a machine learning model, used to estimate the phase delay of each axis relative to the reference reference in advance. The core is to learn the mapping relationship between speed, following error and phase lag through historical data.
[0042] The virtual spindle is a virtual reference axis defined by the tangential feed motion of the machining path. Its motion state is synchronized with the tangential feed speed of the machining path, serving as a benchmark for phase synchronization of each motion axis and solving the problem of no unified reference for multi-axis motion. The command phase lag is the time difference between the actual execution time of the command of each motion axis and the corresponding phase of the virtual spindle. That is, when the virtual spindle reaches a certain phase position, the motion axis has not yet reached the corresponding position due to the response delay.
[0043] First, after obtaining the ideal speed command sequence for each axis, historical following error data of the machine tool under similar machining scenarios is retrieved, and both are used as input data to the inter-axis phase lag predictor. Second, the inter-axis phase lag predictor learns the correlation between speed, following error, and phase lag in the historical data, and combines this with the speed characteristics of the current machining segment to predict the command phase lag of each motion axis relative to the virtual spindle when executing the current machining segment. The phase signal of the virtual spindle is generated by the tangential feed motion of the machining path, ensuring that the phase reference is directly related to the machining path.
[0044] Step S20 in the method provided in this application embodiment includes:
[0045] Based on the model of the CNC machine tool to be controlled, a set of machine tool test paths covering typical working ranges are planned, and test CNC programs are generated based on the machine tool test paths;
[0046] The CNC machine tool under control is driven to execute the test CNC program, and the actual position and ideal position command of each motion axis are collected in real time through the encoder built into the servo system. The historical following error sequence of each motion axis during the test process is calculated.
[0047] Based on the tangential feed motion of the machine tool test path, a virtual spindle phase signal is generated, and the command phase lag sequence of the actual position sequence of each motion axis relative to the virtual spindle phase signal is calculated.
[0048] Using the ideal speed command sequence and the corresponding historical following error sequence of each motion axis as the input sample set, and the calculated phase lag sequence of each motion axis command as the output label set, a network architecture for an inter-axis phase lag predictor is constructed based on a recurrent neural network.
[0049] The inter-axis phase lag predictor is trained under supervised supervision using the input sample set and the output label set until the error between the predicted output command phase lag and the true label converges to within a preset error threshold, thus completing the model construction.
[0050] In this embodiment, a set of machine tool test paths covering typical working ranges is first planned according to the model of the CNC machine tool to be controlled, and a test CNC program is generated based on the machine tool test paths.
[0051] The typical working range is the rated motion range of the CNC machine tool to be controlled, covering common machining scenarios; the machine tool test path is a standardized path designed for collecting training samples, including typical trajectories such as straight lines, arcs, and high curvature curves to ensure sample diversity; the test CNC program is a G-code program generated based on the test path, used to drive the machine tool to perform test movements and collect data.
[0052] Based on the model and rated parameters of the CNC machine tool to be controlled, a set of test paths covering typical working ranges is planned, including trajectories such as straight lines, arcs, and spirals with different feed speeds and curvatures. Based on each test path, a corresponding test CNC program is generated, and each program includes parameters such as path coordinates, feed speed, and spindle speed.
[0053] For example, the typical working range is 0-500mm on the X-axis and 0-300mm on the Y-axis. Based on the model and rated parameters of the CNC machine tool to be controlled, a set of test paths covering the typical working range is planned: different feed speeds: 50-500mm / min, different curvatures: 0-0.5mm⁻¹. A certain test path is obtained as follows: straight segment: X0-Y0-Z0 to X100-Y0-Z0, F100; arc segment: radius 50mm, F200; spiral segment: pitch 5mm, F150. The corresponding test CNC program contains 300 G-code instructions.
[0054] Secondly, the CNC machine tool under control is driven to execute the test CNC program, and the actual position and ideal position commands of each motion axis are collected in real time through the encoder built into the servo system. The historical following error sequence of each motion axis during the test is calculated. The encoder built into the servo system is a sensor used to collect the actual position of the motion axis in real time, with an accuracy of up to 0.1μm. It is the core component for acquiring actual motion data. The actual position is the real position of the motion axis during the machining process. The following error is obtained by comparing it with the ideal position. The historical following error sequence is the time sequence set of the following error at each moment during the test, reflecting the dynamic response characteristics of the servo system.
[0055] The system drives the CNC machine tool under test to execute various test CNC programs, while simultaneously configuring the sampling parameters of the servo system encoder. During the machine tool's movement, the actual position and ideal position commands of each motion axis are collected in real time, and the following error at each moment is calculated using a formula. The following errors of all test paths are then organized in chronological order to form a historical following error sequence for each axis. The formula for the following error at each moment is: Following Error = Ideal Position - Actual Position.
[0056] Next, a virtual spindle phase signal is generated based on the tangential feed motion of the machine tool test path, and the command phase lag sequence of the actual position sequence of each motion axis relative to the virtual spindle phase signal is calculated.
[0057] Based on the reconstructed ideal position command sequence, the test path is discretized and sampled to obtain a discrete position point sequence. Then, the displacement vectors of adjacent position points are calculated, and the direction of the displacement vectors is taken as the tangential direction. The ideal velocity commands for each axis are projected and synthesized in the tangential direction to obtain the tangential ideal feed velocity. The tangential ideal feed velocity is integrated to obtain the virtual master axis phase position, generating a virtual master axis phase signal. By comparing the actual position sequence of each axis with the virtual master axis phase signal, the command phase lag at each moment is calculated, ultimately forming the X-axis phase lag sequence.
[0058] For example, based on the ideal position command sequence, the test path is discretized and sampled at a sampling interval of 0.1ms. The phase position of the virtual principal axis is calculated to be 10mm at t=0.1s. By comparing the actual position sequence of each axis with the phase signal of the virtual principal axis, the actual phase of the X-axis at t=0.1s corresponds to the phase of the virtual principal axis at t=0.112s. Therefore, the phase lag is 0.112-0.1=0.012s, and finally the X-axis phase lag sequence [(t0,0.01s),(t1,0.012s),...].
[0059] Meanwhile, the ideal speed command sequence of each motion axis and the corresponding historical following error sequence are used as the input sample set, and the calculated phase lag sequence of each motion axis command is used as the output label set. The network architecture of the inter-axis phase lag predictor is constructed based on the recurrent neural network.
[0060] Recurrent Neural Networks (RNNs) are deep learning models that excel at processing time-series data. They retain historical information through memory units and are suitable for time-series prediction of phase lag. The input sample set is a training data set consisting of ideal velocity command sequences for each axis and historical following error sequences. The output label set consists of the command phase lag sequence for each axis, which corresponds one-to-one with the input sample set. The network architecture is a hierarchical structure similar to an input layer, hidden layer, and output layer.
[0061] Model data: The sample dataset is constructed by using the ideal speed command sequence and historical following error sequence of each axis as input samples and the corresponding command phase lag sequence as output labels.
[0062] Model Architecture: The activation functions are set to ReLU and Linear, and the loss function is mean squared error. A predictor architecture based on a recurrent neural network is designed: an input layer, hidden layers, and an output layer. The input layer receives the input sequence and passes it to the hidden layers. The hidden layers construct recurrent connections between hidden layers, enabling the recurrent neural network to maintain a memory state and understand the contextual information in the sequence. The output layer provides an output at each time step in the sequence generation task, used to output the prediction result.
[0063] For example, the input samples are the velocity [100, 120, ...] and error [0.001, 0.002, ...] of the X-axis over a certain period of time, and the output label is the corresponding phase lag [0.01, 0.012, ...].
[0064] Finally, using the input sample set and output label set, the inter-axis phase lag predictor is trained under supervised supervision until the error between the predicted output command phase lag and the true label converges to within a preset error threshold, thus completing the model construction. Supervised training uses labeled samples to train the model, adjusting network parameters through backpropagation to make the predicted output approximate the true label. The preset error threshold is the termination condition for model training, ensuring that the model's prediction accuracy meets practical requirements. Parameter convergence is achieved through multiple rounds of iterative training, where the model parameters gradually stabilize, and the prediction error decreases below the threshold.
[0065] Model Training: The sample dataset is divided into training and validation sets in a 7:3 ratio. The training set is used to update model parameters, and the validation set is used to evaluate prediction accuracy. The Adam optimizer with a learning rate of 0.001 is used for supervised training of the inter-axis phase lag predictor: the training set is input into the model, the loss function between the predicted output and the true label is calculated, and the network parameters are adjusted using the backpropagation algorithm. Every 10 training epochs, the model accuracy is evaluated using the validation set until the validation set loss function converges to a preset error threshold, MSE ≤ 1 × 10⁻. 6 Once the model converges, training stops, and the inter-axis phase lag predictor is constructed.
[0066] For example, after 500 training rounds, the average error between the model's predicted phase lag and the true label is 0.0005s, which meets the accuracy requirements and completes the model construction.
[0067] In step S20 of the method provided in this application embodiment, generating a virtual spindle phase signal based on the tangential feed motion of the machine tool test path includes:
[0068] Based on the ideal position command sequence of each motion axis reconstructed when executing the test CNC program, the machine tool test path is discretized and sampled to obtain a discrete position point sequence of the test path;
[0069] Calculate the displacement vector between adjacent points in the discrete position point sequence of the test path, and take the direction of the displacement vector as the tangential direction of the corresponding test path segment;
[0070] Based on the tangential direction of each test path segment, the ideal speed command sequence of each motion axis obtained by reconstruction is synthesized and projected in the tangential direction to calculate the ideal feed speed along the tangential direction of the test path;
[0071] The ideal feed rate is integrated along discrete sampling time points to obtain the phase position of the virtual spindle at the corresponding sampling time point, and a virtual spindle phase signal is generated for phase synchronization comparison with each motion axis.
[0072] In this embodiment, the machine tool test path is first discretized based on the ideal position command sequence of each motion axis reconstructed during the execution of the test CNC program, to obtain a discrete position point sequence of the test path. Discretization sampling is the process of dividing a continuous test path into discrete position points at fixed time intervals, which facilitates subsequent calculations; the discrete position point sequence of the test path is the set of path coordinates at each time point obtained after sampling, which is the basis for calculating the tangential direction.
[0073] Based on the reconstructed ideal position command sequence for each axis during the execution of the test CNC program, the sampling time interval is determined, and the continuous test path is uniformly sampled according to the sampling time interval. The path coordinates (X,Y,Z) at each sampling moment are extracted to form a discrete position point sequence of the test path as [(t0,X0,Y0,Z0),(t1,X1,Y1,Z1),...]. The sampling time interval can be consistent with the machine tool interpolation cycle.
[0074] For example, a straight test path is X0-Y0-Z0 to X10-Y0-Z0, with a feed speed of 100 mm / s and a sampling time interval of 0.1 ms. After sampling, 1000 discrete position points are obtained, where the coordinates of the 10th point are (0.1,0,0) and the coordinates of the 20th point are (0.2,0,0). Similarly, the path coordinates at each sampling time are extracted to obtain the sequence of discrete position points of the test path.
[0075] Secondly, the displacement vectors between adjacent points in the discrete position sequence of the test path are calculated, and the direction of the displacement vectors is taken as the tangential direction of the corresponding test path segment. The displacement vector is the coordinate difference between two adjacent discrete position points, reflecting the direction and length of the path segment; the tangential direction is the normalized direction of the displacement vector, that is, the instantaneous travel direction of the path segment.
[0076] For the discrete position point sequence of the test path, take two adjacent position points in chronological order, point k and point (k+1), and calculate the displacement vector of each adjacent position point. Then, divide the displacement vector by the vector magnitude to reduce it and normalize it to obtain the unit vector of the tangential direction of the corresponding test path segment. The displacement vector is equal to the difference between the final position vector and the initial position vector. In the coordinate system, this is calculated by subtracting the initial position vector from the final position vector, i.e., subtracting the two vectors. For a three-dimensional coordinate vector, the displacement vector is (Δx=x...). k +1-x k ,Δy=y k +1-y k ,Δz=z k +1-z k ).
[0077] The obtained displacement vector is then normalized, meaning its length is changed to 1 while its direction remains unchanged. Specifically, for a vector, the unit vector is the ratio of the vector length to its magnitude. For a three-dimensional displacement vector (Δx, Δy, Δz), the corresponding tangential direction unit vector (u) of the test path segment is obtained. x ,u y ,u z ) is (Δx / modulus, Δy / modulus, Δz / modulus).
[0078] For example, the coordinates of adjacent points are (0.1,0,0) and (0.2,0,0), the displacement vector is (0.1,0,0), and the normalized tangential direction is (1,0,0); if the coordinates are (0.1,0,0) and (0.18,0.06,0), the displacement vector is (0.08,0.06,0), the modulus is 0.1, and the normalized tangential direction is (0.8,0.6,0).
[0079] Next, based on the tangential direction of each test path segment, the reconstructed ideal velocity command sequences of each motion axis are synthesized and projected along the tangential direction to calculate the ideal feed rate along the tangential direction of the test path. The ideal velocity command sequence is the target velocity timing data of each motion axis; the synthesized projection involves projecting the ideal velocity vectors of each axis onto the tangential direction and then summing them to obtain the resultant velocity along the tangential direction of the path; the tangential ideal feed rate is the target feed rate along the tangential direction of the test path and is the core parameter for calculating the virtual master axis phase.
[0080] Retrieve the ideal velocity command sequence for each motion axis obtained from the reconstruction, and extract the axis velocity vector at each moment of the current path segment, including the X-axis velocity v. x Y-axis velocity v y Z-axis velocity v z The axial velocity vector (v) is obtained. x ,v y ,v z The velocity vectors of each axis are compared with the unit vector (u) of the tangential direction of the current path segment. x ,u y ,u z Dot product yields the projected velocities (v) of each axis in the tangential direction. x ·u x v y ·uy、v z ·u z Then sum the projected velocities of each axis to obtain the ideal feed rate along the tangential direction of the test path.
[0081] For example, the X-axis velocity v x =80mm / s, Y-axis speed v y =60mm / s, Z-axis velocity v Z =0mm / s, the axis velocity vector is (80,60,0), and the tangential direction is (0.8,0.6,0). Then the ideal tangential feed rate is 80×0.8+60×0.6=64+36=100mm / s.
[0082] Finally, the ideal feed rate is integrated along discrete sampling time points to obtain the phase position of the virtual spindle at the corresponding sampling time point, and a virtual spindle phase signal is generated for phase synchronization comparison with each motion axis. The discrete sampling time point is the time series corresponding to the discretized sampling; the phase position is the cumulative feed distance of the virtual spindle; the virtual spindle phase signal is a time-series signal in which the phase position changes over time, used for phase synchronization comparison with each axis.
[0083] Using discrete sampling time points as the time axis, the trapezoidal rule is employed to numerically integrate the tangential ideal feed rate. The initial phase position is set to 0, and the phase position at each sampling moment equals the phase position of the previous moment plus the current tangential ideal feed rate multiplied by the sampling time interval. The phase positions at each sampling moment are then arranged in chronological order to generate a virtual master axis phase signal.
[0084] The trapezoidal rule is used to estimate the value of a definite integral. It involves dividing the interval of the definite integral into several smaller trapezoids to approximate the area under the curve, thus obtaining an approximate value of the definite integral. The integration interval [a, b] is divided into n equal parts, each with a length h = (ba) / n. Then, the function values corresponding to the two endpoints (a and b) in each sub-interval are taken as the height of the interval's endpoints. Multiplying this height by h yields the area of the trapezoid within the sub-interval. Summing the areas of all the trapezoids in the sub-intervals gives an approximate value of the area under the entire integration interval [a, b]. Similarly, using the discrete sampling time as the time axis, numerical integration is performed on the ideal tangential feed rate to obtain a single phase signal of the virtual principal axis.
[0085] For example, with a sampling interval of 0.1ms and an ideal tangential feed speed of 100mm / s, when t0=0s, the phase is 0mm; when t1=0.0001s, the phase is 0+100×0.0001=0.01mm; when t2=0.0002s, the phase is 0.01+100×0.0001=0.02mm, ultimately forming a phase signal sequence [(0,0),(0.0001,0.01),(0.0002,0.02),...].
[0086] In this embodiment, a virtual spindle phase signal is generated based on the tangential feed motion of the test path. The command phase lag sequence is calculated, and an inter-axis phase lag predictor network architecture is constructed. Subsequently, a sequence of discrete position points along the test path is obtained, and the displacement vectors between adjacent position points and the ideal tangential feed speed of the test path are calculated to generate the virtual spindle phase signal. Because the response speeds of the servo systems of each axis of a CNC machine tool differ, directly executing ideal commands will lead to inter-axis phase asynchrony, resulting in contour errors. By predicting the phase lag, the synchronization deviation of each axis can be known in advance, avoiding the blindness of subsequent error compensation. This achieves early prediction of inter-axis phase lag, providing crucial input for subsequent contour error calculation.
[0087] S30: Based on the command phase lag of each motion axis and the geometric curvature and tangent direction of the machining path at the current interpolation point, the estimated contour error vector caused by phase asynchrony is calculated through the contour error coupling mapping model.
[0088] In this embodiment, the geometric curvature of the machining path is the degree of curvature of the machining path at the current interpolation point. The greater the curvature, the steeper the path, which is a key geometric parameter affecting the sensitivity of contour error. The tangent direction is the direction of the tangent of the machining path at the current interpolation point, which determines the instantaneous direction of the feed motion and, together with the curvature, constitutes the local geometric features of the path.
[0089] The contour error coupling mapping model is a mathematical model built based on supervised learning. It is used to map the inter-axis phase lag and path geometric parameters into contour error vectors, taking into account the coupling effect of multi-axis errors. The predicted contour error vector is three-dimensional error data containing magnitude and direction, which characterizes the deviation between the machining contour and the ideal contour caused by the phase asynchrony between the axes.
[0090] In this embodiment, firstly, based on the ideal position command sequence, the key parameters of the current processing segment are obtained through geometric calculation: the geometric curvature of the current interpolation point and the tangential direction of the processing path at that point; then, the phase lag of each motion axis command output by the inter-axis phase lag predictor is extracted; the geometric parameters and phase lag are combined according to a preset format to form the current error mapping input data; finally, the input data is fed into the pre-trained contour error coupling mapping model, and the model calculates and outputs the estimated contour error vector of the current interpolation point through the learned mapping rules.
[0091] Step S30 in the method provided in this application embodiment includes:
[0092] Based on the ideal position command sequence, the machining path geometric parameters corresponding to the current machining segment are determined, wherein the geometric parameters include the geometric curvature of the current interpolation point and the tangential direction of the machining path at the current interpolation point;
[0093] Obtain the command phase lag amount of each motion axis corresponding to the current interpolation point, which is estimated by the inter-axis phase lag predictor.
[0094] The geometric curvature, tangent direction, and command phase lag of each motion axis at the current interpolation point are combined according to a predefined input format to form the current error mapping input data.
[0095] The current error mapping input data is input into the pre-constructed contour error coupling mapping model, and the estimated contour error vector corresponding to the current interpolation point is calculated and output.
[0096] In this embodiment, the machining path geometric parameters corresponding to the current machining segment are first determined based on the ideal position command sequence. These geometric parameters include the geometric curvature of the current interpolation point and the tangent direction of the machining path at that point. The machining path geometric parameters are key parameters describing the shape of the current machining segment path, with the geometric curvature and tangent direction being the core components, directly affecting the degree to which synchronization error influences contour accuracy.
[0097] Based on the reconstructed ideal position command sequence, the path geometric parameters of the current processing segment are determined. For the current interpolation point, the geometric curvature is calculated using the three-point numerical method: the interpolation point and its two adjacent discrete position points are selected, a circle equation is constructed, and the radius is solved; curvature = 1 / radius. Simultaneously, the displacement vectors between the current and next interpolation points are calculated, and after normalization, the tangent direction unit vector is obtained.
[0098] Among them, the three-point curvature calculation uses the curvature of the quadratic curve at three known points as the estimated curvature.
[0099] For example, the coordinates of three points (10,0,0), (10.1,0.05,0), and (10.2,0.1,0) are used to calculate a radius of 100mm and a curvature of 0.01mm⁻¹. At the same time, the displacement vector between the current interpolation point and the next interpolation point (0.1,0.05,0) is calculated, and after normalization, the unit vector of the tangent direction is (0.894,0.447,0).
[0100] Secondly, the command phase lag of each motion axis corresponding to the current interpolation point is obtained by the inter-axis phase lag predictor. The phase lag of the corresponding interpolation point is the predicted phase lag of each axis synchronized with the execution time of the current interpolation point.
[0101] The output of the inter-axis phase lag predictor is retrieved and used as the command phase lag sequence for each motion axis. Each data point in the sequence corresponds one-to-one with the interpolation point of the ideal position command sequence. Based on the timestamp of the current interpolation point, the corresponding value is extracted from the phase lag sequence and used as the command phase lag for each axis at the current interpolation point.
[0102] For example, the timestamp of the current interpolation point is t=0.01s. The command phase lag corresponding to t=0.01s is extracted from the X-axis phase lag sequence as 0.012s, the command phase lag of the Y-axis is 0.009s, and the command phase lag of the Z-axis is 0.006s.
[0103] Next, the geometric curvature, tangent direction, and command phase lag of each motion axis at the current interpolation point are combined according to a predefined input format to form the current error mapping input data. The predefined input format is the input data organization structure agreed upon during model training to ensure that the input data matches the dimension of the model input layer; the current error mapping input data is a single sample data constructed for the current interpolation point that conforms to the model input format, containing geometric parameters and phase lag information.
[0104] According to the predefined input format, the geometric curvature of the current interpolation point, the unit vector of the tangent direction, and the phase lag of each axis command are arranged sequentially to form the input data vector, which constitutes the current error mapping input data. The input data organization structure is: [Geometric curvature, tangent direction x, tangent direction y, tangent direction z, X-axis phase lag, Y-axis phase lag, ...].
[0105] For example, with a geometric curvature of 0.01mm⁻¹, tangent direction (0.894, 0.447, 0), X-axis phase lag of 0.012s, Y-axis of 0.009s, and Z-axis of 0.006s, the input data vector is [0.01, 0.894, 0.447, 0, 0.012, 0.009, 0.006]. If it is a five-axis machine tool, the A / C axis phase lag needs to be added, and the dimension of the input vector will increase accordingly.
[0106] Finally, the current error mapping input data is fed into the pre-built contour error coupling mapping model, which calculates and outputs the estimated contour error vector corresponding to the current interpolation point. The contour error coupling mapping model is a trained and converged supervised learning model that can map input parameters to contour error vectors. The mapping calculation is the process by which the model transforms the input data into the output result through internal weight parameter operations, that is, the transformation from geometric parameters and phase hysteresis to contour error vectors.
[0107] By calling a pre-built contour error coupling mapping model, the current error mapping input data is input into the model. The model performs feature extraction and nonlinear mapping on the input data through forward propagation, and finally outputs the predicted contour error vector of the current interpolation point.
[0108] In step S30 of the method provided in this application embodiment, the pre-construction step of the contour error coupling mapping model includes:
[0109] Based on the model of the CNC machine tool to be controlled, a set of test machining paths with different geometric curvatures and tangent directions are planned, and corresponding test CNC programs are generated based on each test machining path;
[0110] The CNC machine tool under control is driven to execute each test CNC program, and a pre-built inter-axis phase lag predictor is used to obtain the sequence of phase lag values of each motion axis command when executing each test machining path;
[0111] Obtain the actual contour error vector sequence generated when executing each test processing path;
[0112] The set of input samples is the geometric curvature, tangent direction and corresponding phase lag of each motion axis command at the current interpolation point of each test processing path, and the set of output labels is the actual contour error vector.
[0113] The mathematical architecture of the contour error coupling mapping model is constructed based on the supervised learning algorithm;
[0114] The contour error coupling mapping model is trained under supervision using the input sample set and the output label set until the error between the predicted contour error vector output by the model and the real label converges to within a preset accuracy threshold, thus completing the pre-construction of the model.
[0115] In this embodiment, firstly, based on the model of the CNC machine tool to be controlled, a set of test machining paths containing different geometric curvatures and tangent directions is planned, and corresponding test CNC programs are generated based on each test machining path. The path set designed to cover diverse working conditions includes low curvature, medium curvature, and high curvature paths, as well as test machining paths with tangents in different directions, to ensure that the samples cover typical working conditions of complex surface machining. Specifically, curvature 0-0.05mm⁻¹ is a low curvature path, curvature 0.05-0.2mm⁻¹ is a medium curvature path, curvature 0.2-0.5mm⁻¹ is a high curvature path, and test machining paths with tangents in different directions (X, Y, or oblique) are also included to ensure that the samples cover typical working conditions of complex surface machining.
[0116] Based on the machining capabilities of the CNC machine tool under test, a set of test machining paths with diverse geometric characteristics is planned, including straight lines, arcs with varying curvatures and radii, freeform surface segments, and dynamic changes in tangent direction. Based on each test machining path, a corresponding test CNC program is generated. Each program includes parameters such as path coordinates and feed rate, ensuring that the testing process covers the range of commonly used machining parameters of the machine tool.
[0117] For example, a certain test path set includes 10 paths such as an X-direction straight line, an arc with a curvature of 0 and a radius of 50mm, an arc with a curvature of 0.02mm⁻¹ and a radius of 2mm, an oblique straight line with a curvature of 0.5mm⁻¹ and a tangent direction (0.707,0.707,0), which correspond to generating 10 test CNC programs.
[0118] Secondly, the CNC machine tool under control is driven to execute each test CNC program. Using a pre-built inter-axis phase lag predictor, the phase lag sequence of each motion axis command is obtained when executing each test machining path. The phase lag sequence is the timing data of the phase lag of each axis output by the model for each test path, which is synchronized with the machining process of the test path.
[0119] The CNC machine tool under control is driven to execute each test CNC program sequentially, and during the execution of each program, a pre-constructed inter-axis phase lag predictor is retrieved in real time. The ideal speed command sequence of the current test path and the historical following error sequence of each axis are then input into the inter-axis phase lag predictor, which outputs the command phase lag of each motion axis in real time. The phase lag at each moment is recorded in chronological order to form the command phase lag sequence for each axis corresponding to each test path.
[0120] The inter-axis phase lag predictor provides one of the accurate input samples for model training and synchronizes the phase lag sequence with the geometric characteristics of the test path to ensure that the input samples can reflect the synchronization deviation state under different geometric conditions.
[0121] For example, when executing a test program for a circular arc with a radius of 50mm, the X-axis phase lag sequence is [(t0,0.008s),(t1,0.009s),...], and the Y-axis sequence is [(t0,0.007s),(t1,0.008s),...].
[0122] Next, the actual contour error vector sequence generated during the execution of each test processing path is obtained. The actual contour error vector sequence is the time-series data of the deviation between the actual contour and the ideal contour after the test path processing is completed, collected by high-precision measurement equipment, and serves as the true label for model training.
[0123] After each test CNC program is executed, a high-precision measuring device is used to perform contour measurement on the machined test piece. Following the discrete sampling point sequence of the test path, the three-dimensional deviation (ΔEx, ΔEy, ΔEz) between the actual contour and the ideal contour at each sampling point is calculated, forming the actual contour error vector. Contour measurement refers to acquiring contour information of an object's surface through measuring instruments to quantify its shape, roughness, and other surface characteristics, helping to ensure that the product meets design standards and tolerance requirements. High-precision measuring equipment can include laser interferometers, coordinate measuring machines, profilometers, and other measuring devices.
[0124] Through contour measurement, the actual and ideal contours of the sampling points are obtained, and the three-dimensional deviation between the actual and ideal contours is calculated. The actual contour error vector is obtained by subtracting the three-dimensional data of the ideal contour from the actual contour's three-dimensional data. The error vectors of each sampling point are then arranged in chronological order to form an actual contour error vector sequence, which corresponds one-to-one with the phase lag sequence. The actual contour error vector sequence accurately reflects the true error state under different geometric conditions coupled with phase lag, providing a reliable basis for supervised model training.
[0125] For example, the actual contour error vector sequence of a 50mm radius circular arc test piece is [(t0,0.0015mm,0.001mm,0),(t1,0.0018mm,0.0012mm,0),...].
[0126] Meanwhile, the geometric curvature, tangent direction, and corresponding phase lag of each motion axis command at the current interpolation point of each test processing path are used as the input sample set, and the actual contour error vector is used as the output label set.
[0127] Model Data: For each test path, extract the geometric curvature, tangent direction unit vector, and phase hysteresis of each axis command at each interpolation point, and combine them into input samples according to a predefined input format. Use the actual contour error vector corresponding to each interpolation point as the output label. Summarize the input samples and output labels of all test paths to construct the model training dataset; divide it into a training set and a validation set in a 7:3 ratio. The training set is used for model parameter updates, and the validation set is used to evaluate model accuracy.
[0128] For example, a sample dataset contains 10,000 samples. The input of each sample is [curvature, tangent x, tangent y, tangent z, X-axis lag, Y-axis lag, ...], and the output is [ΔEx, ΔEy, ΔEz].
[0129] In addition, a mathematical framework for a contour error coupling mapping model is constructed based on a supervised learning algorithm.
[0130] Model Structure: A contour error coupling mapping model is constructed based on a backpropagation (BP) neural network. The model structure includes an input layer, hidden layers, and an output layer. The input layer has the dimension of geometric parameters plus the dimension of phase hysteresis; the hidden layer has three layers, which undergo nonlinear transformation through activation functions; the output layer has a three-dimensional dimension and is used to output the contour errors of the X / Y / Z axes. The activation functions are ReLU and Linear, the loss function is mean squared error (MSE), and the optimizer is Adam.
[0131] Finally, using the input sample set and the output label set, the contour error coupling mapping model is trained under supervision until the error between the model's output predicted contour error vector and the true label converges to within a preset accuracy threshold, thus completing the model's pre-construction. The preset accuracy threshold is the termination condition for model training, ensuring that the model's prediction accuracy meets the actual processing requirements.
[0132] Model Training: Input the training set into the constructed model and iteratively update the model parameters using supervised training: calculate the loss function between the model's predicted output and the true label, generate it through forward propagation, and adjust the weights and biases of each layer using the backpropagation algorithm; every 10 training epochs, evaluate the model's prediction accuracy using the validation set, and calculate the mean squared error between the prediction error and the true label; continue training until the mean squared error of the validation set converges to a preset accuracy threshold ≤ 5 × 10⁻ 7 Stop training and save the model parameters.
[0133] For example, after 80 training rounds, the mean squared error of the validation set decreased to 4.2 × 10⁻ 7 ≤5×10⁻ 7 If the preset threshold is met, a contour error coupling mapping model is pre-constructed, which can accurately learn the mapping relationship between input and output, so that the deviation between the estimated contour error vector and the true value is ≤3%.
[0134] In this embodiment, compared with traditional error prediction methods, the accuracy and reliability of contour error prediction are improved. Especially in the machining of complex curved surfaces, it can effectively capture complex errors caused by high curvature regions and poor multi-axis phase synchronization, providing a reliable decision basis for the compensation optimization model, making subsequent compensation operations more targeted and effective, thereby significantly improving the machining accuracy and surface quality of complex curved surfaces, reducing over-compensation or under-compensation caused by inaccurate error prediction, and improving machining efficiency and product qualification rate.
[0135] S40: Based on the estimated contour error vector, combined with the contour accuracy requirement constraint predefined in the current processing area of the surface to be processed, and the axis contribution weight matrix, construct and solve a compensation optimization model with the goal of minimizing the weighted comprehensive contour error;
[0136] In this embodiment, the contour accuracy requirement constraint is a preset accuracy standard for the surface to be processed in the current processing area, which is determined by the part design drawings or processing specifications; the axis contribution weight matrix is a diagonal matrix pre-configured based on the machine tool mechanical structure and kinematic characteristics, where each element represents the influence weight of the corresponding motion axis on the contour error; the weighted comprehensive contour error is a comprehensive error index that takes into account the contribution weight of each axis, and is used to balance the influence of each axis error on the overall accuracy.
[0137] The compensation optimization model is a mathematical optimization model that aims to minimize the weighted comprehensive contour error, constrains the contour accuracy requirements, and uses the phase compensation parameters of each axis as decision variables. Its core is to find the optimal compensation scheme under the premise of meeting the accuracy requirements.
[0138] First, matrix operations are performed on the estimated contour error vector and the axis contribution weight matrix to calculate the weighted comprehensive contour error index. Then, the contour accuracy requirement constraint of the current processing area is obtained, and minimizing the weighted comprehensive contour error is used as the objective function and the weighted comprehensive contour error as the constraint condition. Next, the phase compensation amount of each motion axis is set as the decision variable to be optimized, and a complete compensation optimization model is constructed. Finally, the model is solved using a sequential quadratic programming algorithm to find the optimal phase compensation parameters that minimize the weighted comprehensive contour error and satisfy the accuracy constraint.
[0139] Step S40 in the method provided in this application embodiment includes:
[0140] Based on the estimated contour error vector output by the contour error coupling mapping model, and combined with the axis contribution weight matrix, a weighted comprehensive contour error index is calculated. The axis contribution weight matrix is a diagonal matrix pre-configured based on the mechanical structure and kinematic characteristics of the CNC machine tool to be controlled.
[0141] Obtain the contour accuracy requirement constraint of the surface to be processed in the current processing area, and use the weighted comprehensive contour error index and the contour accuracy requirement constraint as the objective function and constraint conditions.
[0142] Set the phase compensation parameters to be optimized for each motion axis, and use the phase compensation parameters to be optimized as decision variables to construct a compensation optimization model that includes the objective function and the constraints.
[0143] The compensation optimization model is solved by using a sequential quadratic programming optimization algorithm to obtain a set of optimal phase compensation parameters that minimize the weighted comprehensive contour error index while meeting the contour accuracy requirement constraint. These parameters serve as the solution to the compensation optimization model.
[0144] In this embodiment, the weighted comprehensive contour error index is first calculated based on the estimated contour error vector output by the contour error coupling mapping model and the axis contribution weight matrix. The axis contribution weight matrix is a pre-configured diagonal matrix based on the mechanical structure and kinematic characteristics of the CNC machine tool to be controlled. The weighted comprehensive contour error index is a scalar value obtained by weighting and summing the contour errors of each axis according to their contribution weights, used to quantify the overall contour accuracy loss. The diagonal matrix is the matrix type of the axis contribution weight matrix, with only diagonal elements being non-zero and off-diagonal elements being 0, ensuring that the weights of each axis are independent and only affect the weighting ratio of its own error.
[0145] Retrieve the estimated profile error vector ΔE=[ΔE x ,ΔE y ,ΔE z ,ΔE A ,ΔE C The axis contribution weight matrix W, which is pre-configured based on the mechanical structure characteristics of the machine tool, is retrieved. The weight coefficients are determined according to the degree of influence of each axis on the contour accuracy. The weighted comprehensive contour error index J = ΔE × W is calculated by matrix multiplication.
[0146] For example, the estimated profile error vector is: [0.0025mm, 0.0015mm, 0.001mm, 0.0008mm, 0.0007mm], and the axis contribution weight matrix W is W=diag(0.4, 0.3, 0.2, 0.05, 0.05) for a five-axis machine tool. Substituting the data, we can obtain the weighted comprehensive profile error index J=0.0025×0.4+0.0015×0.3+0.001×0.2+0.0008×0.05+0.0007×0.05=0.001725mm.
[0147] Secondly, the contour accuracy requirement constraint of the surface to be processed in the current processing area is obtained, and the weighted comprehensive contour error index and the contour accuracy requirement constraint are used as the objective function and constraint conditions. The objective function is the optimization objective expression of the compensation optimization model, that is, minimizing the weighted comprehensive contour error; the constraint conditions are the limiting conditions in the optimization process, which can ensure that the optimization result meets the processing accuracy requirements and avoid overcompensation in pursuit of minimizing error; the contour accuracy requirement constraint of the surface to be processed is the upper limit of accuracy determined according to the part design standard, which is the core basis of the constraint conditions.
[0148] The weighted composite contour error index J is used as the optimization objective, and the objective function is constructed as: minJ = min(ΔE × W), where ΔE is determined by the phase compensation amount of each axis; the larger the compensation amount, the smaller ΔE. The constraint condition for the contour accuracy of the current machining area of the surface to be machined is obtained from the contour accuracy of the current machining area of the surface to be machined, which is a predefined condition, where J ≤ J0. maxAs a constraint, ensure that the optimized overall profile error does not exceed the design accuracy requirements.
[0149] For example, the critical region J of an aero-engine blade max =0.003mm, non-critical area J max =0.005mm, the current processing area is the critical area, the constraint condition is J≤0.003mm, the objective function is to minimize J, forming an optimization framework from objective function to constraint condition.
[0150] Next, we define the phase compensation parameters to be optimized for each motion axis, and use these parameters as decision variables to construct a compensation optimization model that includes the objective function and constraints. The phase compensation parameters to be optimized are the decision variables of the model, i.e., the phase compensation amount of each motion axis; the compensation optimization model is a complete mathematical model containing decision variables, objective function, and constraints, and is the core of solving for the optimal compensation parameters.
[0151] Set the phase compensation values τ = [τx, τy, τz, τA, τC] for each motion axis as decision variables, and specify the range of variable values as 0 ≤ τi ≤ 0.05s. Then, set the objective function and constraint condition: J ≤ J max Integrating τi∈[0,0.05s], the complete compensation optimization model includes minJ=min(ΔE×W), with the constraint: J≤J max ,τi∈[0,0.05s].
[0152] For example, the compensation optimization model for a five-axis machine tool is: minJ = 0.4 × ΔE x ²+0.3×ΔE y ²+0.2×ΔE z ²+0.05×ΔE A ²+0.05×ΔE C ², Constraints: J≤0.003mm, 0≤τx,τy,τz,τA,τC≤0.05s, where ΔEx=f(τx), ΔEy=f(τy), etc., that is, there is a functional relationship between the weighted comprehensive profile error index and the phase compensation amount. The larger the compensation amount, the smaller the error.
[0153] For example, the phase compensation value of each motion axis is in the range of [0, 0.05s], which is determined according to the machine tool servo response speed.
[0154] Finally, a sequential quadratic programming (SQP) optimization algorithm is employed to solve the compensation optimization model, obtaining a set of optimal phase compensation parameters that minimize the weighted comprehensive contour error index while meeting the contour accuracy requirements. This set serves as the solution to the compensation optimization model. The sequential quadratic programming algorithm is an efficient algorithm for solving nonlinear constrained optimization problems. It transforms the nonlinear problem into a series of quadratic programming subproblems for iterative solving, resulting in fast convergence and high accuracy. The optimal phase compensation parameters are the values of the decision variables obtained from the model solution; they represent the optimal solution that minimizes the objective function and satisfies the constraints. Specifically, the quadratic programming optimization algorithm (SQP) addresses a class of optimization problems with a quadratic objective function and linear constraints. In each iteration, a quadratic programming subproblem is constructed using the second-order approximation of the current point—the Hessian matrix of the Lagrange function or a quasi-Newton approximation—and the search direction is obtained by solving this subproblem.
[0155] The sequential quadratic programming algorithm is selected as the solver, and the algorithm parameters, namely convergence accuracy and maximum number of iterations, are set. The constructed compensation optimization model is input into the solver, and iterative calculation is performed: first, the nonlinear objective function and constraints are linearized at the current iteration point, a quadratic programming subproblem is constructed, the subproblem is solved to obtain the search direction and step size, and the decision variables are updated; the process is repeated until the objective function converges to the minimum value and satisfies the constraints, and the optimal phase compensation parameters are output.
[0156] For example, the convergence accuracy is 1×10⁻ 6 The maximum number of iterations is 100. After solving, the optimal parameters are obtained: τx=0.012s, τy=0.009s, τz=0.006s, τA=0.003s, and τC=0.004s. The weighted comprehensive profile error J=0.0017mm≤0.003mm, which meets the accuracy constraint.
[0157] In this embodiment, an axis contribution weight matrix is introduced to prioritize compensation for axes that significantly impact accuracy based on machine tool characteristics. Simultaneously, accuracy constraints ensure that the compensated machining accuracy meets design requirements. The optimal phase compensation parameters are obtained by solving the optimization model, reducing the weighted composite contour error. This satisfies accuracy constraints while avoiding overcompensation that could lead to decreased machining efficiency. This achieves precise optimization of the compensation scheme, avoiding the simplistic selection required by traditional compensation methods.
[0158] S50: Based on the solution of the compensation optimization model, generate a set of inter-axis phase compensation instructions, and fuse the inter-axis phase compensation instructions with the original G-code instruction stream in the CNC machining program to generate a synchronized instruction stream to drive the movement of each axis of the machine tool.
[0159] In this embodiment, the inter-axis phase compensation command is generated based on the optimal phase compensation parameters of the optimization model and is used to adjust the command execution time of each motion axis to compensate for phase lag. The synchronization command stream is a unified command sequence after fusing the original G-code command and the phase compensation command, ensuring that each motion axis is executed synchronously according to the compensated time base and eliminating the inter-axis phase difference. Command fusion is to embed the phase compensation command into the corresponding position of the original G-code command stream to achieve an organic combination of time axis adjustment and motion command.
[0160] First, the optimal phase compensation parameters for each motion axis are extracted from the solution of the compensation optimization model. Then, based on the optimal phase compensation parameters, the command time offset required for each motion axis in each interpolation cycle is calculated. Next, the ideal position command sequence is time-axis shifted and adjusted according to the time offset to generate the phase-compensated position command sequence for each axis. Then, the compensated position command sequences for each axis are synchronized and aligned according to a unified time base, merging to form a synchronized command stream. Finally, the synchronized command stream is sent to the servo systems of each motion axis of the machine tool, driving each axis to move collaboratively according to the synchronized commands to complete the machining of complex curved surfaces.
[0161] Step S50 in the method provided in this application embodiment includes:
[0162] Obtain the optimal phase compensation parameters obtained by solving the compensation optimization model, wherein the optimal phase compensation parameters include the phase compensation amount corresponding to each motion axis;
[0163] Based on the phase compensation amount of each motion axis, the command time offset required to be applied to each motion axis in the corresponding interpolation cycle is calculated respectively.
[0164] Based on the calculated time offset of each motion axis command, the ideal position command sequence is adjusted by corresponding time axis translation to generate the phase-compensated position command sequence of each motion axis.
[0165] The phase-compensated position command sequences of each motion axis are synchronized, aligned, and merged according to a unified time base to generate a synchronized command stream.
[0166] The synchronized command stream is sent to the servo systems of each motion axis of the machine tool to drive the coordinated motion of each axis.
[0167] In this embodiment, the optimal phase compensation parameters obtained from solving the compensation optimization model are first obtained. These optimal phase compensation parameters include the phase compensation amount corresponding to each motion axis. The optimal phase compensation parameters are the optimal solution of the decision variables obtained from the solution, containing the phase compensation amount for each motion axis, and are the core basis for correcting phase deviations between axes. The phase compensation amount is the time length during which each motion axis needs to execute instructions earlier or later; earlier execution is positive, and later execution is negative, used to compensate for phase lag.
[0168] The solution results from the compensation optimization model are retrieved, resulting in a set of phase compensation parameters that satisfy accuracy constraints and minimize the weighted composite profile error. The phase compensation values corresponding to each motion axis are extracted from the solution results to form a parameter set.
[0169] For example, the optimal phase compensation parameter set for a five-axis machine tool is [τx=0.012s, τy=0.009s, τz=0.006s, τA=0.003s, τC=0.004s]. Among them, the phase compensation amount of the X-axis is the largest, with a phase compensation amount of 0.012s, corresponding to its largest phase lag; the phase compensation amount of the A-axis is the smallest, with a phase compensation amount of 0.003s, and its contribution weight to the contour accuracy is relatively low.
[0170] Secondly, based on the phase compensation amount of each motion axis, the required command time offset for each motion axis within the corresponding interpolation cycle is calculated. The command time offset is the adjustment value of the command time that the phase compensation amount can be converted into an executable command time for the machine tool. That is, the time by which the ideal position command of each axis needs to be advanced or delayed on the time axis, which corresponds one-to-one with the phase compensation amount. The interpolation cycle is the smallest time unit for the CNC machine tool to execute commands, which determines the accuracy of the command adjustment. The time offset must be an integer multiple of the interpolation cycle or the subdivision accuracy of the adaptation cycle.
[0171] First, the interpolation cycle T of the CNC machine tool to be controlled is determined based on the hardware performance and machining accuracy requirements of the CNC system. Then, the command time offset is calculated based on the phase compensation of each motion axis: if the phase compensation is τᵢ, then the time offset Δtᵢ = τᵢ. If the compensation exceeds an integer multiple of the interpolation cycle, rounding or linear interpolation is required. For rotary axes, the time offset is corrected by considering the relationship between their angular velocity and phase lag, using the formula Δtᵢ. A =τ A ×(ω A / ω0), where ω A ω0 is the current angular velocity of axis A, and ω0 is the reference angular velocity, ensuring that the rotational motion and linear motion are synchronized in time.
[0172] For example, with an X-axis phase compensation of 0.012s and an interpolation period of 0.1ms, the time offset Δt is calculated. x =0.012s=120μs, which is 120 times the interpolation period; Y-axis τᵧ=0.009s, Δtᵧ=90μs, both of which can be accurately identified and executed by the machine tool CNC system.
[0173] Next, based on the calculated time offset of each motion axis command, the ideal position command sequence is adjusted by corresponding time axis translation to generate the phase-compensated position command sequence for each motion axis. The ideal position command sequence is the set of theoretical position data for each motion axis obtained from reconstruction, which is the reference command for machine tool motion and has no compensation or correction. The time axis translation adjustment advances or delays the ideal position command sequence as a whole by Δtᵢ time in the time dimension. After adjustment, the position commands at each moment remain unchanged, and only the execution time is offset to compensate for the phase lag. The compensated position command sequence is the set of position commands after time axis translation adjustment, which includes the coordinate values of each motion axis under the adjusted time reference and the corresponding execution time. It is the basic data for synchronizing the command flow.
[0174] First, retrieve the ideal position command sequence for each motion axis obtained from the reconstruction, where t k =k×T, k=0,1,...,n, T is the interpolation period, x k For t k The ideal coordinates at time; then, based on the time offset Δtᵢ, normal execution is performed, and the time axis is shifted for the instruction sequence at the ideal position: if Δtᵢ is positive, then the adjusted instruction sequence for the X-axis is [(t0-Δtᵢ). x ,x0),(t1-Δt x ,x1),...,(t n -Δt x ,x n [], that is, the execution time of each position instruction is advanced by Δt. x If Δtᵢ is negative, then execution is delayed, and the execution time is shifted backward by |Δtᵢ|. For multi-axis collaborative scenarios, it is necessary to ensure that the translation adjustment of each axis is based on a unified time reference to avoid new time deviations.
[0175] For example, the ideal X-axis command (t0=0s, x0=0mm) and (t1=0.0001s, x1=0.01mm) have a time offset Δt. x =0.012s, the adjusted sequence is [(t0'=-0.012s,x0=0mm),(t1'=-0.0119s,x1=0.01mm)], to ensure that the X-axis command is executed in advance to compensate for the 0.012s phase lag.
[0176] Simultaneously, the phase-compensated position command sequences of each motion axis are synchronized, aligned, and merged according to a unified time reference to generate a synchronized command stream. The unified time reference is a global time reference based on the phase time of the virtual spindle, ensuring that the command execution time of all motion axes is aligned with this reference, avoiding synchronization errors caused by inconsistencies in the time references between axes. The synchronized command stream is a standardized command set that merges the compensated position command sequences of each motion axis according to the unified time reference. It contains the position commands of each axis at the same point in time and can directly drive the coordinated movement of each axis of the machine tool.
[0177] Establish a unified time reference: taking the phase position θ of the virtual principal axis as the core, and assigning the time t corresponding to each phase position. θ This serves as a global reference time. Subsequently, the compensated position command sequence for each motion axis is mapped to this unified time base: for the X-axis, the compensated command (t...) k ',x k Find the corresponding virtual principal axis phase time t. θ , will x k As t θ The X-axis position command is processed simultaneously. Compensated commands for the Y and Z axes are also processed concurrently to ensure that the same position is achieved at the same time. θ At any given time, all axes have corresponding position commands. Finally, the commands for each axis are arranged in chronological order and merged into a synchronized command stream, with a format conforming to the command specifications of the machine tool CNC system.
[0178] For example, with a unified time base of t=0.01s, the X-axis compensation command is x=1.2mm, the Y-axis is y=0.8mm, and the Z-axis is z=0.3mm. The merged synchronization command is G01 X1.2 Y0.8 Z0.3 T0.01, which specifies the target position of each axis at t=0.01s.
[0179] Finally, the synchronized command stream is sent to the servo systems of each motion axis of the machine tool, driving the axes to move in tandem. The servo system is the execution unit of the CNC machine tool, containing servo drivers and servo motors. It is responsible for receiving position commands and driving the motion axes to move precisely; its response speed and positioning accuracy directly affect the machining effect. Coordinated motion, under the control of the servo system, requires each motion axis to reach its target position simultaneously according to the synchronized command stream, achieving precise reproduction of the machining path. This is the core motion mode for machining complex curved surfaces.
[0180] The generated synchronized command stream is sent to the servo systems of each motion axis via the CNC system's bus interface. Subsequently, upon receiving the commands, the servo systems drive the servo motors through a three-loop control system: position loop, speed loop, and current loop. The position loop compares the commanded position with the actual position fed back by the motor encoder to generate a speed command. The speed loop adjusts the motor speed to make the actual speed approximate the commanded speed. The current loop controls the motor current to ensure smooth motion. During the motion, the servo system collects the actual position data in real time and feeds it back to the CNC system for subsequent model adaptive correction.
[0181] For example, the synchronized command stream sends position commands of 1.2mm on the X-axis, 0.8mm on the Y-axis, and 0.3mm on the Z-axis. The servo system drives the motors of each axis to move at the command speed and reach the target position within a specified time, thereby achieving precise positioning of the spatial point.
[0182] In step S50 of the method provided in this application embodiment, based on the phase compensation amount of each motion axis, the command time offset to be applied to each motion axis within the corresponding interpolation cycle is calculated, including:
[0183] The phase compensation amount of each motion axis is combined with the weight coefficient of each motion axis in the axis contribution weight matrix to calculate the weighted base time offset of each motion axis.
[0184] Obtain the contour accuracy requirement constraint corresponding to the current processing area, and calculate the accuracy requirement adjustment coefficient, wherein the accuracy requirement adjustment coefficient is determined by the first ratio of the weighted comprehensive contour error index to the allowable upper limit value of the contour accuracy requirement constraint.
[0185] Based on the geometric curvature and tangent direction of the machining path at the current interpolation point, and combined with the basic time offset and the accuracy requirement adjustment coefficient, the final command time offset to be applied to each motion axis within the corresponding interpolation cycle is calculated.
[0186] In this embodiment, the phase compensation amount of each motion axis is first combined with the weight coefficients corresponding to each motion axis in the axis contribution weight matrix to calculate the weighted base time offset of each motion axis. The axis contribution weight matrix is a diagonal matrix pre-configured based on the mechanical structure stiffness of the CNC machine tool, the efficiency of the kinematic chain transmission, and the priority of the machining task. The core motion axis has a higher weight, reflecting the differentiated impact of each axis on the contour accuracy.
[0187] Based on the optimal phase compensation parameters, the pre-configured axis contribution weight matrix is then obtained. Finally, the base time offset is calculated using the weighted formula: Δtᵢ=τᵢ×wᵢ (i is the motion axis number). Substituting the data, the base time offset of each motion axis can be obtained.
[0188] For example, when machining ordinary mechanical parts, the weight matrix of a five-axis machine tool is adjusted to W=diag(0.45,0.45,0.1,0,0), and the optimal phase compensation parameter of the five-axis machine tool is τ=[τ x =0.012s,τᵧ=0.009s,τ z =0.006s,τ A =0.003s,τ C =0.004s] to ensure that the compensation weight of the core cutting axis accounts for 90%, and the base time offset is obtained as [0.0054,0.0041,0.0006,0,0].
[0189] Secondly, the contour accuracy requirement constraint corresponding to the current processing area is obtained, and the accuracy requirement adjustment coefficient is calculated. This adjustment coefficient is determined by the first ratio of the weighted comprehensive contour error index to the allowable upper limit value of the contour accuracy requirement constraint. The accuracy requirement constraint is the preset upper limit of the contour accuracy for the current region of the surface to be processed, determined by the workpiece design standards. The weighted comprehensive contour error index is the calculated comprehensive contour error, quantifying the overall accuracy loss caused by the current inter-axis synchronization deviation. The accuracy requirement adjustment coefficient is a dimensionless coefficient reflecting the degree of matching between the current error and the accuracy constraint, used to dynamically adjust the compensation intensity.
[0190] First, obtain the contour accuracy requirement constraint for the current machining area. Then, retrieve the weighted comprehensive contour error index. Finally, calculate the accuracy requirement adjustment coefficient by dividing the estimated weighted comprehensive contour error index by the allowable upper limit of the contour accuracy requirement constraint to obtain the first ratio. If the first ratio is greater than or equal to 1, the accuracy requirement adjustment coefficient is set to 1, and full-strength compensation is initiated to ensure that the accuracy does not exceed the constraint upper limit, avoiding overcompensation. If the first ratio is less than 1, the larger value between the first ratio and the minimum compensation strength threshold is taken. The minimum compensation strength threshold is greater than 0 to avoid excessively low compensation affecting inter-axis synchronization, ensuring basic compensation strength, and preventing compensation failure caused by extreme values of the coefficient. Ultimately, ensure that the accuracy requirement adjustment coefficient is within a reasonable range of 0.5 to 1.
[0191] As a preferred option, the preset minimum compensation intensity threshold is set to 0.5. Experimental verification shows that when the compensation intensity is less than 50% of the ideal compensation amount, the improvement effect on inter-axis synchronization significantly decreases, and low-frequency oscillations may occur. Therefore, 0.5 is selected as an empirical threshold to ensure the dynamic stability and synchronization of the system, ultimately ensuring that the accuracy requirement adjustment coefficient is limited to a reasonable range of 0.5 to 1, effectively maintaining the coordination of multi-axis motion while meeting contour accuracy constraints.
[0192] Exemplarily, the allowable upper limit value of the contour accuracy requirement constraint is 0.003 mm, and the weighted comprehensive contour error J = 0.0017 mm. Then the first ratio is 0.003 / 0.0017 ≈ 1.76, and the accuracy requirement adjustment coefficient ≈ 1.76.
[0193] Finally, based on the geometric curvature and tangent direction of the machining path at the current interpolation point, combined with the basic time offset and the accuracy requirement adjustment coefficient, the final command time offset to be applied to each motion axis within the corresponding interpolation cycle is calculated. Geometric curvature is the degree of bending of the path at the current interpolation point. The greater the curvature, the more sensitive the error is to the synchronization deviation. The tangent direction is the instantaneous traveling direction of the path, which determines the spatial direction of error generation, and together with the curvature, constitutes the error sensitivity characteristics of the path; the final command time offset is the machine tool executable time adjustment value after synthesizing the basic offset, accuracy requirement coefficient, and geometric characteristics, and is the final execution basis for compensation commands.
[0194] According to the basic time offset and the accuracy requirement adjustment coefficient, set the curvature coefficient according to the geometric curvature of the current interpolation point. If the low curvature k < 30, set the curvature coefficient to 1.0, which is the basic compensation without additional strengthening; if the medium curvature 30 < k < 70, set the curvature coefficient to 1.2, which is a moderately strengthened compensation; if the high curvature k > 70, set the curvature coefficient to 1.4, which is a key strengthened compensation. Subsequently, calculate the axis weight according to the angle between the tangent and the axis: μ = max(|cosθ|, 0.5) (θ is the angle between the tangent direction of the machining path and each motion axis). The smaller the angle, the closer the weight is to 1. The lower limit of 0.5 is used to maintain system coordination and prevent inter-axis out-of-step, and calculate the command time offset. Finally, calculate the final command time offset = basic time offset × accuracy requirement adjustment coefficient × curvature coefficient × axis weight.
[0195] Exemplarily, the angles between the tangent direction of the machining path of the five-axis machine tool and each motion axis are 30°, 45°, 60°, 60°, and 30° respectively, and the obtained weights are 0.87, 0.71, 0.5, 0.5, and 0.87 respectively. Calculate the weights of the axes respectively as the angles between the tangent and the axes. The basic time offset is [0.0054, 0.0041, 0.0006, 0, 0], and the accuracy requirement adjustment coefficient ≈ 1.76. Substitute into the formula for the final command time offset to obtain the final command time offset.
[0196] Step S50 in the method provided by the embodiment of the present application further includes:
[0197] Real-time collect the actual position feedback of each motion axis of the machine tool, and calculate the actual phase of the virtual spindle according to the tangential feed motion of the machining path;
[0198] Based on the actual phase of the virtual spindle and the actual position feedback of each motion axis, the real-time phase lag and real-time actual contour error of each motion axis during the machining process are calculated.
[0199] The real-time phase lag is used as a new training sample, and the inter-axis phase lag predictor is incrementally trained using a time series sliding window and gradient descent method.
[0200] By utilizing the deviation between the real-time actual contour error and the estimated contour error vector, the internal weight parameters of the contour error coupling mapping model are updated through the backpropagation algorithm to perform adaptive model correction.
[0201] In this embodiment, the actual position feedback of each motion axis of the machine tool is first collected in real time, and the actual phase of the virtual spindle is calculated based on the tangential feed motion of the machining path. The actual position feedback is the core data reflecting the true state of the axis motion, which is the actual motion position data collected in real time by the encoder built into the servo system during the machining process. The X-axis actual position sequence [(t0,x0'),(t1,x1'),...,(t...]] is... n ,x n ')].
[0202] The virtual spindle actual phase is the phase position calculated based on the actual tangential feed motion of the machining path, and it is a unified benchmark for measuring the synchronization of the actual motion of each axis; the tangential feed motion is the actual feed action of the machine tool along the tangential direction of the machining path, and its speed is obtained by synthesizing the actual motion of each axis.
[0203] Configure the servo system encoder sampling parameters: set the sampling frequency to 1kHz, i.e., collect data once every 1ms to ensure that dynamic changes in axis motion can be captured. During the machine tool's execution of synchronized command flow machining, the actual position feedback of each motion axis is collected in real time. Subsequently, the actual tangential feed rate of the machining path is calculated: based on the actual position feedback at adjacent sampling times, the displacement vector is calculated, the displacement vector is projected onto the tangential direction of the path, and then divided by the sampling time interval to obtain the actual tangential feed rate; finally, the actual tangential feed rate is integrated along the sampling time.
[0204] For example, the actual positions of the X-axis at t0=0s, t1=0.001s, and t2=0.002s are x0'=0.0001mm, x1'=0.0102mm, and x2'=0.0201mm, respectively, and the corresponding positions of the Y-axis are y0'=0.00008mm, y1'=0.0081mm, and y2'=0.0162mm; the X-axis displacement during the t0-t1 time period... Given Δx = 0.0101mm, Y-axis displacement Δy = 0.00802mm, and the current tangential direction unit vector u = (0.8, 0.6), we obtain the tangential displacement Δs = Δx × 0.8 + Δy × 0.6 = 0.0101 × 0.8 + 0.00802 × 0.6 = 0.01289mm, v' = 0.01289mm / 0.001s = 12.89mm / s. With a sampling time interval of 0.001s, we obtain the actual phase of the virtual principal axis: at time t1, phase θ1 ≈ 12.89 × 0.001 = 0.01289mm; at time t2, phase θ2 ≈ 0.01289 + 13.01 × 0.001 = 0.0259mm.
[0205] Secondly, based on the actual phase of the virtual spindle and the actual position feedback of each motion axis, the real-time phase lag and real-time actual contour error of each motion axis during the machining process are calculated. The real-time phase lag is the time difference between the actual phase of each motion axis and the actual phase of the virtual spindle, reflecting the dynamic change of the synchronization deviation between axes during the machining process; the real-time actual contour error is the three-dimensional deviation vector between the actual machining contour and the ideal contour at the current interpolation point, and is a direct indicator for measuring machining accuracy.
[0206] For example, the real-time phase lag τ of the X-axis x '=t x '-t θ , t x 't' represents the time it takes for the X-axis to reach the target phase. θ This represents the time it takes for the virtual principal axis to reach this phase. ΔE' = (ΔE x ',ΔEᵧ',ΔE z' ), where ΔE x '=x 理想 -x 实际 .
[0207] Calculate the real-time phase lag: For the actual phase θᵏ of the virtual master axis at each sampling moment, find the actual time tᵢᵏ for each motion axis to reach that phase; similarly, the time for the Y-axis to reach θ1 is tᵧ¹=0.00103s, and the real-time phase lag τᵧ¹=0.00003s. Then, calculate the real-time actual contour error: based on the ideal and actual position feedback of the current interpolation point. Kalman filtering with a coefficient of 0.1-0.3 is required during the calculation to eliminate encoder acquisition noise and ensure the stability of the error data.
[0208] For example, the time t for the X-axis to reach θ1 = 0.01289 mm x ¹=0.00105s, the time t for the virtual principal axis to reach θ1 θ¹ =0.001s, therefore the real-time phase lag τ of the X-axis is... x ¹=0.00105-0.001=0.00005s, feedback between the ideal and actual positions of the current interpolation point, x 理想 =0.01mm, y 理想 =0.008mm. Calculate the deviation component ΔE. x =0.01-0.0102=-0.0002mm, ΔEᵧ'=0.008-0.0081=-0.0001mm. If it is three-dimensional machining, supplement the Z-axis deviation ΔE. z' The real-time actual contour error vector ΔE'=(-0.0002,-0.0001,0.00005)mm is formed.
[0209] Next, the real-time phase lag is used as a new training sample, and the inter-axis phase lag predictor is incrementally trained using a time-series sliding window and gradient descent. The time-series sliding window is the time window used to select new training samples; incremental training updates the model parameters using only the new samples on the basis of the original trained model, without retraining the entire model, thus balancing training efficiency and model accuracy; gradient descent is an optimization algorithm used to update the model parameters. By calculating the gradient of the loss function with respect to the parameters, the parameters are adjusted along the negative gradient direction to make the model's predicted values approximate the true values.
[0210] Model data: Configure time series sliding window parameters to ensure the samples contain sufficient temporal information. Use the real-time phase lag as a new output label, and combine it with the corresponding ideal velocity command sequence and historical following error data to form new input samples.
[0211] For example, configure the time series sliding window parameters: window size N=100, sliding step size=1, ensuring the samples contain sufficient temporal information. Use the real-time phase lag as a new output label. Extract the latest 100 samples from the sliding window and input them into the inter-axis phase lag predictor. Update the model parameters using gradient descent. The original model predicts an X-axis phase lag of 0.00004s, a real-time value of 0.00005s, and a loss function value of 1×10⁻¹. 0 The predicted value was corrected to 0.000048s, improving prediction accuracy. The above process was repeated, with incremental training performed for each new set of samples to ensure real-time updates to the model parameters.
[0212] Finally, the real-time phase lag was used as a new training sample, and the inter-axis phase lag predictor was incrementally trained using a time-series sliding window and gradient descent method. Error deviation, the difference between the actual real-time contour error and the predicted contour error vector, is a core indicator for measuring the model's prediction accuracy; a larger deviation indicates a worse fit between the model and actual working conditions. The backpropagation algorithm updates the network parameters by calculating the gradient of the error deviation with respect to the model's weight parameters. It is a core method for neural network model correction and can accurately locate the parameters causing prediction deviations. Adaptive correction automatically adjusts the model's internal parameters based on the error deviation, gradually bringing the predicted output closer to the actual value without manual intervention, ensuring the model's long-term adaptability to actual processing conditions.
[0213] Model Training: Error Deviation Calculation: Obtain the estimated contour error vector of the contour error coupling mapping model, calculate the real-time actual contour error, and obtain the error deviation. Subsequently, the backpropagation algorithm is used to update the model parameters: the error deviation is used as a loss signal and backpropagated from the output layer to the input layer. The gradient of the weight parameters of each layer is calculated, and the weights are adjusted according to the learning rate. The parameter update process is repeated until the root mean square (RMSE) of the error deviation drops below a preset threshold. A centralized correction is performed every 10 sampling periods to balance the correction frequency and computational resource consumption, and finally the trained inter-axis phase lag predictor is obtained.
[0214] For example, the latest 100 samples (including 99 historical samples + 1 new sample) are extracted from the sliding window and input into the inter-axis phase lag predictor; the model parameters are updated using gradient descent: the loss function (MSE) of the predicted phase lag and the real-time phase lag is calculated, the parameter gradient is calculated through backpropagation, and the weights and biases of the recurrent neural network are adjusted along the negative gradient direction. The estimated contour error vector ΔE = (0.00015, 0.00008, 0.00003) mm of the contour error coupling mapping model is obtained, and the real-time actual contour error ΔE' = (-0.0002, -0.0001, 0.00005) mm, therefore the error deviation ΔE_dev = (-0.00035, -0.00018, 0.00002) mm. The model parameters are updated using the backpropagation algorithm: the error deviation is used as the loss signal and backpropagated from the output layer to the input layer to calculate the gradient of the weight parameters of each layer; the parameter update process is repeated until the root mean square error deviation (RMSE) drops to a preset threshold of 1×10⁻⁻⁻⁶. 5 Below mm; a centralized correction is performed every 10 sampling periods to balance the correction frequency and computational resource consumption.
[0215] In this embodiment, by integrating instructions and synchronizing alignment, the optimized compensation scheme is transformed into machine tool executable instructions, achieving inter-axis motion synchronization. This completely solves the contour error problem caused by inter-axis phase lag in traditional CNC machine tools, meeting high-precision machining requirements and ultimately improving machining accuracy. The weighted basic time offset is calculated using an axis contribution weight matrix, avoiding the insufficient compensation accuracy caused by traditional equalization of time offset. For motion axes that significantly impact contour error, the adjustment range of their time offset is amplified through weighting coefficients, effectively improving the phase synchronization accuracy of critical axes, thereby reducing overall contour error. This achieves dynamic matching between time offset and machining accuracy requirements, overcoming the limitation of fixed time offsets being unable to adapt to different accuracy needs, and realizing a dynamic balance between accuracy and efficiency.
[0216] The embodiments of this application, through the above specific implementation methods, achieve the following technical effects:
[0217] In this embodiment, the original G-code command streams for each motion axis are first extracted by analyzing the CNC machining program for complex curved surfaces. Then, the ideal position and velocity command sequences are reconstructed using the machine tool kinematics chain model. Reconstructing the ideal command sequence using the machine tool kinematics chain model solves the problem of mismatch between the original G-code command streams and the actual motion characteristics of the machine tool, laying a data foundation for subsequent accurate compensation and avoiding machining deviations caused by missing command information.
[0218] Secondly, based on the model of the CNC machine tool to be controlled, the machine tool test path is planned and a test CNC program is generated. The historical following error sequence is calculated, and a virtual spindle phase signal is generated based on the tangential feed motion of the test path. The command phase lag sequence is calculated, and an inter-axis phase lag predictor network architecture is constructed using a recurrent neural network. The discrete position point sequence of the test path is obtained, the displacement vector is calculated, and the ideal tangential feed speed of the test path is determined, generating a virtual spindle phase signal for phase synchronization comparison. By predicting the phase lag, the synchronization deviation of each axis is understood, avoiding blindness in subsequent error compensation. This achieves early prediction of inter-axis phase lag, providing crucial input for subsequent contour error calculation.
[0219] Next, based on the ideal position command sequence, the machining path geometric parameters are determined, and the command phase lag amount estimated by the inter-axis phase lag predictor is obtained. Through the contour error coupling mapping model, the estimated contour error vector of the current interpolation point is output. Using the pre-constructed inter-axis phase lag predictor, the command phase lag amount sequence for each motion axis is obtained, and the actual contour error vector sequence is obtained. Based on a supervised learning algorithm, the mathematical framework of the contour error coupling mapping model is constructed.
[0220] Compared to traditional error prediction methods, this method improves the accuracy and reliability of contour error prediction. Especially in the machining of complex curved surfaces, it can effectively capture complex errors caused by high curvature regions and poor multi-axis phase synchronization, providing a reliable decision basis for the compensation optimization model. This makes subsequent compensation operations more targeted and effective, thereby significantly improving the machining accuracy and surface quality of complex curved surfaces and reducing the problems of over-compensation or under-compensation caused by inaccurate error prediction.
[0221] Meanwhile, by introducing an axis contribution weight matrix, compensation is prioritized for axes that significantly impact accuracy based on machine tool characteristics. The optimal phase compensation parameters are obtained by solving the optimization model, reducing the weighted composite contour error. This satisfies accuracy constraints while avoiding the decrease in machining efficiency caused by over-compensation. This achieves precise optimization of the compensation scheme, avoiding the simplistic selection required by traditional compensation methods.
[0222] Ultimately, through instruction fusion and synchronization alignment, the optimized compensation scheme is transformed into machine tool executable instructions, achieving inter-axis motion synchronization. This completely solves the contour error problem caused by inter-axis phase lag in traditional CNC machine tools, meeting the requirements of high-precision machining and improving machining accuracy. Compared to existing CNC machine tool control technologies for complex surface machining, combining an inter-axis phase lag predictor based on a recurrent neural network with a contour error coupling mapping model improves phase lag prediction accuracy and reduces contour error prediction deviation.
[0223] In summary, by utilizing instruction time offset calculation and fusion with synchronized instruction streams, inter-axis cooperative errors are reduced, significantly improving the contour accuracy and motion stability of complex surface machining, and reducing the accuracy fluctuation amplitude of long-term continuous machining. Compared with existing technologies, this application improves machining contour accuracy, reduces surface roughness, and can adapt to different types of machine tools and complex machining paths without manual intervention, greatly improving the stability and adaptability of precision machining, and constructing a CNC machine tool control system that meets the high-precision machining needs of high-end manufacturing fields such as aerospace and precision molds.
[0224] Example 2, as Figure 2 As shown, this application provides a CNC machine tool control system for machining complex curved surfaces, the system comprising:
[0225] The instruction sequence reconstruction module 11 is used to parse the CNC machining program for complex surface machining, extract the original G-code instruction stream that drives each motion axis, and reconstruct the ideal position instruction sequence and ideal speed instruction sequence of each motion axis according to the machine tool kinematic chain model.
[0226] The command phase lag prediction module 12 is used to predict the command phase lag of each motion axis relative to a virtual spindle when executing the current machining segment based on the ideal speed command sequence and the historical following error data of each axis servo system, through an inter-axis phase lag predictor. The virtual spindle is defined by the tangential feed motion of the machining path.
[0227] The contour error prediction module 13 is used to calculate the predicted contour error vector caused by phase asynchrony based on the command phase lag of each motion axis and the geometric curvature and tangent direction of the machining path at the current interpolation point through the contour error coupling mapping model.
[0228] The compensation optimization model construction module 14 is used to construct and solve a compensation optimization model with the goal of minimizing the weighted comprehensive contour error, based on the estimated contour error vector, combined with the contour accuracy requirement constraint predefined in the current processing area of the surface to be processed, and the axis contribution weight matrix.
[0229] The instruction generation module 15 is used to generate a set of inter-axis phase compensation instructions based on the solution of the compensation optimization model, and to fuse the inter-axis phase compensation instructions with the original G-code instruction stream in the CNC machining program to generate a synchronized instruction stream to drive the movement of each axis of the machine tool.
[0230] In one embodiment, the instruction phase lag prediction module 12 is used to:
[0231] Based on the model of the CNC machine tool to be controlled, a set of machine tool test paths covering typical working ranges are planned, and test CNC programs are generated based on the machine tool test paths;
[0232] The CNC machine tool under control is driven to execute the test CNC program, and the actual position and ideal position command of each motion axis are collected in real time through the encoder built into the servo system. The historical following error sequence of each motion axis during the test process is calculated.
[0233] Based on the tangential feed motion of the machine tool test path, a virtual spindle phase signal is generated, and the command phase lag sequence of the actual position sequence of each motion axis relative to the virtual spindle phase signal is calculated.
[0234] Using the ideal speed command sequence and the corresponding historical following error sequence of each motion axis as the input sample set, and the calculated phase lag sequence of each motion axis command as the output label set, a network architecture for an inter-axis phase lag predictor is constructed based on a recurrent neural network.
[0235] The inter-axis phase lag predictor is trained under supervised supervision using the input sample set and the output label set until the error between the predicted output command phase lag and the true label converges to within a preset error threshold, thus completing the model construction.
[0236] In one embodiment, the instruction phase lag prediction module 12 is further configured to:
[0237] Based on the ideal position command sequence of each motion axis reconstructed when executing the test CNC program, the machine tool test path is discretized and sampled to obtain a discrete position point sequence of the test path;
[0238] Calculate the displacement vector between adjacent points in the discrete position point sequence of the test path, and take the direction of the displacement vector as the tangential direction of the corresponding test path segment;
[0239] Based on the tangential direction of each test path segment, the ideal speed command sequence of each motion axis obtained by reconstruction is synthesized and projected in the tangential direction to calculate the ideal feed speed along the tangential direction of the test path;
[0240] The ideal feed rate is integrated along discrete sampling time points to obtain the phase position of the virtual spindle at the corresponding sampling time point, and a virtual spindle phase signal is generated for phase synchronization comparison with each motion axis.
[0241] In one embodiment, the contour error prediction module 13 is used for:
[0242] Based on the ideal position command sequence, the machining path geometric parameters corresponding to the current machining segment are determined, wherein the geometric parameters include the geometric curvature of the current interpolation point and the tangential direction of the machining path at the current interpolation point;
[0243] Obtain the command phase lag amount of each motion axis corresponding to the current interpolation point, which is estimated by the inter-axis phase lag predictor.
[0244] The geometric curvature, tangent direction, and command phase lag of each motion axis at the current interpolation point are combined according to a predefined input format to form the current error mapping input data.
[0245] The current error mapping input data is input into the pre-constructed contour error coupling mapping model, and the estimated contour error vector corresponding to the current interpolation point is calculated and output.
[0246] The pre-construction step of the contour error coupling mapping model includes:
[0247] Based on the model of the CNC machine tool to be controlled, a set of test machining paths with different geometric curvatures and tangent directions are planned, and corresponding test CNC programs are generated based on each test machining path;
[0248] The CNC machine tool under control is driven to execute each test CNC program, and a pre-built inter-axis phase lag predictor is used to obtain the sequence of phase lag values of each motion axis command when executing each test machining path;
[0249] Obtain the actual contour error vector sequence generated when executing each test processing path;
[0250] The set of input samples is the geometric curvature, tangent direction and corresponding phase lag of each motion axis command at the current interpolation point of each test processing path, and the set of output labels is the actual contour error vector.
[0251] The mathematical architecture of the contour error coupling mapping model is constructed based on the supervised learning algorithm;
[0252] The contour error coupling mapping model is trained under supervision using the input sample set and the output label set until the error between the predicted contour error vector output by the model and the real label converges to within a preset accuracy threshold, thus completing the pre-construction of the model.
[0253] In one embodiment, the compensation optimization model construction module 14 is used for:
[0254] Based on the estimated contour error vector output by the contour error coupling mapping model, and combined with the axis contribution weight matrix, a weighted comprehensive contour error index is calculated. The axis contribution weight matrix is a diagonal matrix pre-configured based on the mechanical structure and kinematic characteristics of the CNC machine tool to be controlled.
[0255] Obtain the contour accuracy requirement constraint of the surface to be processed in the current processing area, and use the weighted comprehensive contour error index and the contour accuracy requirement constraint as the objective function and constraint conditions.
[0256] Set the phase compensation parameters to be optimized for each motion axis, and use the phase compensation parameters to be optimized as decision variables to construct a compensation optimization model that includes the objective function and the constraints.
[0257] The compensation optimization model is solved by using a sequential quadratic programming optimization algorithm to obtain a set of optimal phase compensation parameters that minimize the weighted comprehensive contour error index while meeting the contour accuracy requirement constraint. These parameters serve as the solution to the compensation optimization model.
[0258] In one embodiment, the instruction generation module 15 is used for:
[0259] Obtain the optimal phase compensation parameters obtained by solving the compensation optimization model, wherein the optimal phase compensation parameters include the phase compensation amount corresponding to each motion axis;
[0260] Based on the phase compensation amount of each motion axis, the command time offset required to be applied to each motion axis in the corresponding interpolation cycle is calculated respectively.
[0261] Based on the calculated time offset of each motion axis command, the ideal position command sequence is adjusted by corresponding time axis translation to generate the phase-compensated position command sequence of each motion axis.
[0262] The phase-compensated position command sequences of each motion axis are synchronized, aligned, and merged according to a unified time base to generate a synchronized command stream.
[0263] The synchronized command stream is sent to the servo systems of each motion axis of the machine tool to drive the coordinated motion of each axis.
[0264] Specifically, based on the phase compensation amount of each motion axis, the required command time offset for each motion axis within the corresponding interpolation cycle is calculated, including:
[0265] The phase compensation amount of each motion axis is combined with the weight coefficient of each motion axis in the axis contribution weight matrix to calculate the weighted base time offset of each motion axis.
[0266] Obtain the contour accuracy requirement constraint corresponding to the current processing area, and calculate the accuracy requirement adjustment coefficient, wherein the accuracy requirement adjustment coefficient is determined by the first ratio of the weighted comprehensive contour error index to the allowable upper limit value of the contour accuracy requirement constraint.
[0267] Based on the geometric curvature and tangent direction of the machining path at the current interpolation point, and combined with the basic time offset and the accuracy requirement adjustment coefficient, the final command time offset to be applied to each motion axis within the corresponding interpolation cycle is calculated.
[0268] In one embodiment, the instruction generation module 15 is further configured to:
[0269] The actual position feedback of each motion axis of the machine tool is collected in real time, and the actual phase of the virtual spindle is calculated based on the tangential feed motion of the machining path;
[0270] Based on the actual phase of the virtual spindle and the actual position feedback of each motion axis, the real-time phase lag and real-time actual contour error of each motion axis during the machining process are calculated.
[0271] The real-time phase lag is used as a new training sample, and the inter-axis phase lag predictor is incrementally trained using a time series sliding window and gradient descent method.
[0272] By utilizing the deviation between the real-time actual contour error and the estimated contour error vector, the internal weight parameters of the contour error coupling mapping model are updated through the backpropagation algorithm to perform adaptive model correction.
[0273] The embodiments of this application, through the above specific implementation methods, achieve the following technical effects:
[0274] In this embodiment, the CNC machining program for complex surface machining is first analyzed by the instruction sequence reconstruction module 11, the original G-code instruction streams of each motion axis are extracted, and the ideal position and velocity instruction sequence is reconstructed by combining the machine tool kinematic chain model. Reconstructing the ideal instruction sequence through the machine tool kinematic chain model solves the problem of mismatch between the original G-code instruction stream and the actual motion characteristics of the machine tool, laying a data foundation for subsequent accurate compensation and avoiding machining deviations caused by missing instruction information.
[0275] Secondly, the command phase lag prediction module 12 generates a virtual spindle phase signal based on the tangential feed motion of the test path, calculates the command phase lag sequence, and constructs an inter-axis phase lag predictor network architecture. Subsequently, the ideal position command sequence for each motion axis is used to obtain a discrete position point sequence on the test path. The displacement vector between adjacent position points and the ideal feed speed along the tangential direction of the test path are calculated to generate a virtual spindle phase signal for phase synchronization comparison. By predicting the phase lag, the synchronization deviation of each axis can be understood in advance, avoiding the blindness of subsequent error compensation. This achieves early prediction of inter-axis phase lag, providing crucial input for subsequent contour error calculation.
[0276] Next, the contour error prediction module 13 obtains the command phase lag amount predicted by the inter-axis phase lag predictor. A contour error coupling mapping model is constructed to calculate the predicted contour error vector, obtaining the command phase lag sequence for each motion axis and the actual contour error vector sequence. Simultaneously, the mathematical framework of the contour error coupling mapping model is constructed to overcome the limitation of traditional error calculation relying on positional deviation. Combining the prediction results of the inter-axis phase lag predictor, error vector calculation is performed for phase asynchrony in multi-axis collaborative machining, overcoming the deficiency of traditional linear error models in representing nonlinear coupling effects. This achieves accurate mapping from multiple input parameters to the contour error vector, reducing overcompensation or undercompensation problems caused by inaccurate error prediction.
[0277] Meanwhile, through the compensation optimization model construction module 14, an axis contribution weight matrix is introduced to focus on compensating axes that have a significant impact on accuracy based on machine tool characteristics. Simultaneously, accuracy constraints are applied to ensure that the compensated machining accuracy meets design requirements. By solving the optimization model, the optimal phase compensation parameters are obtained, reducing the weighted composite contour error. This satisfies accuracy constraints while avoiding the decrease in machining efficiency caused by over-compensation. This achieves precise optimization of the compensation scheme, avoiding the single-selection approach of traditional compensation methods.
[0278] Finally, through the instruction generation module 15, instruction fusion and synchronization alignment are performed, transforming the optimized compensation scheme into machine tool executable instructions, achieving inter-axis motion synchronization, and completely solving the contour error problem caused by inter-axis phase lag in traditional CNC machine tools. Compared with existing CNC machine tool control technologies for complex surface machining, this application combines an inter-axis phase lag predictor based on a recurrent neural network with a contour error coupling mapping model, improving phase lag prediction accuracy and reducing contour error prediction deviation. The compensation optimization model constructed through the axis contribution weight matrix and a sequential quadratic programming algorithm achieves differentiated compensation resource allocation, reducing the weighted comprehensive contour error compared to traditional equal-weight compensation methods.
[0279] It should be noted that the order of the embodiments described above is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, the above description focuses on specific embodiments of this specification. Additionally, the processes depicted in the accompanying drawings do not necessarily require a specific or sequential order to achieve the desired results. In some implementations, multitasking and parallel processing are possible or may be advantageous.
[0280] The above description is only a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A CNC machine tool control method for machining complex curved surfaces, characterized in that, The method includes: The CNC machining program used for machining complex curved surfaces is analyzed, the original G-code instruction streams driving each motion axis are extracted, and the ideal position instruction sequence and ideal speed instruction sequence of each motion axis are reconstructed based on the machine tool kinematic chain model. Based on the ideal speed command sequence and the historical following error data of each axis servo system, the command phase lag of each motion axis relative to a virtual spindle is estimated by the inter-axis phase lag predictor when executing the current machining segment. The virtual spindle is defined by the tangential feed motion of the machining path. Based on the command phase lag of each motion axis and the geometric curvature and tangent direction of the machining path at the current interpolation point, the estimated contour error vector caused by phase asynchrony is calculated through the contour error coupling mapping model. Based on the estimated contour error vector, combined with the contour accuracy requirement constraint predefined in the current processing area of the surface to be processed, and the axis contribution weight matrix, a compensation optimization model with the goal of minimizing the weighted comprehensive contour error is constructed and solved. Based on the solution of the compensation optimization model, a set of inter-axis phase compensation instructions are generated, and the inter-axis phase compensation instructions are fused with the original G-code instruction stream in the CNC machining program to generate a synchronized instruction stream that drives the movement of each axis of the machine tool.
2. The CNC machine tool control method for machining complex curved surfaces according to claim 1, characterized in that, The construction steps of the inter-axis phase lag predictor include: Based on the model of the CNC machine tool to be controlled, a set of machine tool test paths covering typical working ranges are planned, and test CNC programs are generated based on the machine tool test paths; The CNC machine tool under control is driven to execute the test CNC program, and the actual position and ideal position command of each motion axis are collected in real time through the encoder built into the servo system. The historical following error sequence of each motion axis during the test process is calculated. Based on the tangential feed motion of the machine tool test path, a virtual spindle phase signal is generated, and the command phase lag sequence of the actual position sequence of each motion axis relative to the virtual spindle phase signal is calculated. Using the ideal speed command sequence and the corresponding historical following error sequence of each motion axis as the input sample set, and the calculated phase lag sequence of each motion axis command as the output label set, a network architecture for an inter-axis phase lag predictor is constructed based on a recurrent neural network. The inter-axis phase lag predictor is trained under supervised supervision using the input sample set and the output label set until the error between the predicted output command phase lag and the true label converges to within a preset error threshold, thus completing the model construction.
3. The CNC machine tool control method for machining complex curved surfaces according to claim 2, characterized in that, Based on the tangential feed motion of the machine tool test path, a virtual spindle phase signal is generated, including: Based on the ideal position command sequence of each motion axis reconstructed when executing the test CNC program, the machine tool test path is discretized and sampled to obtain a discrete position point sequence of the test path; Calculate the displacement vector between adjacent points in the discrete position point sequence of the test path, and take the direction of the displacement vector as the tangential direction of the corresponding test path segment; Based on the tangential direction of each test path segment, the ideal speed command sequence of each motion axis obtained by reconstruction is synthesized and projected in the tangential direction to calculate the ideal feed speed along the tangential direction of the test path; The ideal feed rate is integrated along discrete sampling time points to obtain the phase position of the virtual spindle at the corresponding sampling time point, and a virtual spindle phase signal is generated for phase synchronization comparison with each motion axis.
4. The CNC machine tool control method for machining complex curved surfaces according to claim 1, characterized in that, Based on the command phase lag of each motion axis and the geometric curvature and tangent direction of the machining path at the current interpolation point, the estimated contour error vector caused by phase asynchrony is calculated using the contour error coupling mapping model, including: Based on the ideal position command sequence, the machining path geometric parameters corresponding to the current machining segment are determined, wherein the geometric parameters include the geometric curvature of the current interpolation point and the tangential direction of the machining path at the current interpolation point; Obtain the command phase lag amount of each motion axis corresponding to the current interpolation point, which is estimated by the inter-axis phase lag predictor. The geometric curvature, tangent direction, and command phase lag of each motion axis at the current interpolation point are combined according to a predefined input format to form the current error mapping input data. The current error mapping input data is input into the pre-constructed contour error coupling mapping model, and the estimated contour error vector corresponding to the current interpolation point is calculated and output.
5. The CNC machine tool control method for machining complex curved surfaces according to claim 4, characterized in that, The pre-construction steps of the contour error coupling mapping model include: Based on the model of the CNC machine tool to be controlled, a set of test machining paths containing different geometric curvatures and tangent directions are planned, and corresponding test CNC programs are generated based on each test machining path; The CNC machine tool under control is driven to execute each test CNC program, and a pre-built inter-axis phase lag predictor is used to obtain the sequence of phase lag values of each motion axis command when executing each test machining path; Obtain the actual contour error vector sequence generated when executing each test processing path; The set of input samples is the geometric curvature, tangent direction and corresponding phase lag of each motion axis command at the current interpolation point of each test processing path, and the set of output labels is the actual contour error vector. Based on the supervised learning algorithm, the mathematical architecture of the contour error coupling mapping model is constructed; The contour error coupling mapping model is trained under supervision using the input sample set and the output label set until the error between the predicted contour error vector output by the model and the real label converges to within a preset accuracy threshold, thus completing the pre-construction of the model.
6. The CNC machine tool control method for machining complex curved surfaces according to claim 1, characterized in that, Based on the estimated contour error vector, combined with the predefined contour accuracy requirement constraint of the surface to be processed in the current processing area, and the axis contribution weight matrix, a compensation optimization model aimed at minimizing the weighted comprehensive contour error is constructed and solved, including: Based on the estimated contour error vector output by the contour error coupling mapping model, and combined with the axis contribution weight matrix, a weighted comprehensive contour error index is calculated. The axis contribution weight matrix is a diagonal matrix pre-configured based on the mechanical structure and kinematic characteristics of the CNC machine tool to be controlled. Obtain the contour accuracy requirement constraint of the surface to be processed in the current processing area, and use the weighted comprehensive contour error index and the contour accuracy requirement constraint as the objective function and constraint conditions. Set the phase compensation parameters to be optimized for each motion axis, and use the phase compensation parameters to be optimized as decision variables to construct a compensation optimization model that includes the objective function and the constraints. The compensation optimization model is solved by using a sequential quadratic programming optimization algorithm to obtain a set of optimal phase compensation parameters that minimize the weighted comprehensive contour error index while meeting the contour accuracy requirement constraint. These parameters serve as the solution to the compensation optimization model.
7. The CNC machine tool control method for machining complex curved surfaces according to claim 1, characterized in that, Based on the solution of the compensation optimization model, a set of inter-axis phase compensation instructions is generated, and these instructions are fused with the original G-code instruction stream in the CNC machining program to generate a synchronized instruction stream that drives the movement of each axis of the machine tool, including: Obtain the optimal phase compensation parameters obtained by solving the compensation optimization model, wherein the optimal phase compensation parameters include the phase compensation amount corresponding to each motion axis; Based on the phase compensation amount of each motion axis, the command time offset required to be applied to each motion axis in the corresponding interpolation cycle is calculated respectively. Based on the calculated time offset of each motion axis command, the ideal position command sequence is adjusted by corresponding time axis translation to generate the phase-compensated position command sequence of each motion axis. The phase-compensated position command sequences of each motion axis are synchronized, aligned, and merged according to a unified time base to generate a synchronized command stream. The synchronized command stream is sent to the servo systems of each motion axis of the machine tool to drive the coordinated motion of each axis.
8. The CNC machine tool control method for machining complex curved surfaces according to claim 7, characterized in that, Based on the phase compensation amount of each motion axis, the required command time offset for each motion axis within the corresponding interpolation cycle is calculated, including: The phase compensation amount of each motion axis is combined with the weight coefficient of each motion axis in the axis contribution weight matrix to calculate the weighted base time offset of each motion axis. Obtain the contour accuracy requirement constraint corresponding to the current processing area, and calculate the accuracy requirement adjustment coefficient, wherein the accuracy requirement adjustment coefficient is determined by the first ratio of the weighted comprehensive contour error index to the allowable upper limit value of the contour accuracy requirement constraint. Based on the geometric curvature and tangent direction of the machining path at the current interpolation point, and combined with the basic time offset and the accuracy requirement adjustment coefficient, the final command time offset to be applied to each motion axis within the corresponding interpolation cycle is calculated.
9. The CNC machine tool control method for machining complex curved surfaces according to claim 1, characterized in that, Based on the solution of the compensation optimization model, a set of inter-axis phase compensation commands is generated, and these commands are fused with the original G-code command stream in the CNC machining program to generate a synchronized command stream. After driving the movement of each axis of the machine tool, the program further includes: The actual position feedback of each motion axis of the machine tool is collected in real time, and the actual phase of the virtual spindle is calculated based on the tangential feed motion of the machining path; Based on the actual phase of the virtual spindle and the actual position feedback of each motion axis, the real-time phase lag and real-time actual contour error of each motion axis during the machining process are calculated. The real-time phase lag is used as a new training sample, and the inter-axis phase lag predictor is incrementally trained using a time series sliding window and gradient descent method. By utilizing the deviation between the real-time actual contour error and the estimated contour error vector, the internal weight parameters of the contour error coupling mapping model are updated through the backpropagation algorithm to perform adaptive model correction.
10. A CNC machine tool control system for machining complex curved surfaces, characterized in that, The system is used to implement the CNC machine tool control method for machining complex curved surfaces according to any one of claims 1-9, the system comprising: The instruction sequence reconstruction module is used to parse CNC machining programs for complex surface machining, extract the original G-code instruction streams driving each motion axis, and reconstruct the ideal position instruction sequence and ideal speed instruction sequence of each motion axis according to the machine tool kinematic chain model. The command phase lag prediction module is used to predict the command phase lag of each motion axis relative to a virtual spindle when executing the current machining segment, based on the ideal speed command sequence and the historical following error data of each axis servo system, through an inter-axis phase lag predictor. The virtual spindle is defined by the tangential feed motion of the machining path. The contour error prediction module is used to calculate the predicted contour error vector caused by phase asynchrony based on the command phase lag of each motion axis and the geometric curvature and tangent direction of the machining path at the current interpolation point, through the contour error coupling mapping model. The compensation optimization model construction module is used to construct and solve a compensation optimization model with the goal of minimizing the weighted comprehensive contour error, based on the estimated contour error vector, combined with the contour accuracy requirement constraint predefined in the current processing area of the surface to be processed, and the axis contribution weight matrix. The instruction generation module is used to generate a set of inter-axis phase compensation instructions based on the solution of the compensation optimization model, and to fuse the inter-axis phase compensation instructions with the original G-code instruction stream in the CNC machining program to generate a synchronized instruction stream to drive the movement of each axis of the machine tool.