Numerical control machine tool space position calculation method based on BP neural network correction

By training a model using a BP neural network and combining it with the motion coordinate system and error measurement trajectory of the CNC machine tool, the nonlinear error fitting problem in the spatial accuracy detection of the CNC machine tool was solved, achieving high-precision error compensation and dynamic adaptation, thereby improving the machining performance and accuracy of the machine tool.

CN121956804APending Publication Date: 2026-05-01CHENGDU AIRCRAFT INDUSTRY GROUP
View PDF 0 Cites 1 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHENGDU AIRCRAFT INDUSTRY GROUP
Filing Date
2026-01-16
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Existing methods for detecting the spatial accuracy of CNC machine tools suffer from insufficient fitting of nonlinear errors, leading to overfitting or underfitting, which affects machining accuracy and machine tool performance, especially when the machine tool accuracy fluctuates, resulting in poor compensation effects.

Method used

By employing a BP neural network-based approach, a motion coordinate system for machine tool components is constructed, error measurement trajectories are planned, and a BP neural network-trained model is used to achieve accurate fitting and dynamic compensation of nonlinear errors. Combined with geometric modeling, error sources are decoupled, thereby improving the accuracy of error identification.

Benefits of technology

It achieves nonlinear mapping capability for machine tool spatial accuracy, dynamically adapts to error components, improves global error prediction accuracy, reduces measurement costs and operational complexity, and enhances machining performance and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121956804A_ABST
    Figure CN121956804A_ABST
Patent Text Reader

Abstract

The invention discloses a numerical control machine tool spatial position calculation method based on BP neural network correction. The method comprises the following steps: establishing a spatial error geometrical relationship model; planning a measurement track and measurement points, presetting theoretical position coordinate data of each measurement point, and obtaining actual measurement position data; geometric error parameters are obtained based on actual measurement position data and substituted into the space error geometric relation model, and a machine tool space error model is obtained; obtaining error calculation coordinate data in combination with the theoretical position coordinate data and a machine tool space error model; the theoretical / actual measurement / error calculation position coordinate data are used for BP neural network training, and a neural network correction model is obtained; and correcting the position coordinate data of the machine tool space points by using the neural network correction model to obtain corresponding actual position coordinate data. According to the method, a technical path of decoupling an error source through geometric modeling, fitting nonlinear features through a BP neural network and optimizing a model through data driving is adopted, and a solution with theoretical preciseness and engineering practicability is provided for high-precision machining of the machine tool.
Need to check novelty before this filing date? Find Prior Art

Description

A method for calculating the spatial position of CNC machine tools based on BP neural network correction Technical Field

[0001] This invention relates to the field of CNC machine tool machining technology, and in particular to a method for calculating the spatial position of CNC machine tools based on BP neural network correction. Background Technology

[0002] As core equipment in modern manufacturing, CNC machine tools' spatial geometric accuracy directly determines the precision and quality of machined parts, making it a key indicator for evaluating machine tool performance. Accurately obtaining and effectively compensating for the spatial accuracy of CNC machine tools is crucial for improving machining accuracy, extending machine tool lifespan, and enhancing the overall level of the manufacturing industry. Current research on CNC machine tool spatial geometric accuracy detection primarily employs two methods. One is the direct measurement method, which uses a combination of one or more measuring instruments to obtain various geometric errors of the CNC machine tool. For example, precision instruments such as laser interferometers and ballbars are used to directly measure geometric errors such as straightness, perpendicularity, and positioning accuracy. This method provides relatively intuitive data on various geometric errors, but requires multiple instruments, is complex to operate, has high costs, and is time-consuming. The other method is the indirect measurement method, which typically involves detecting the error vector of the CNC machine tool's tool tip on a fixed detection trajectory, and then using various methods such as machine tool geometric structure analysis, error sensitivity analysis, and error weight allocation to decouple and identify various geometric errors. This method simplifies the measurement process to some extent by inferring the geometric errors from the error vector at the tool tip, rather than directly measuring all geometric errors. However, both methods have significant limitations in evaluating the spatial accuracy of CNC machine tools. They both measure the errors at a finite number of detection points within the machine tool's motion space and use traditional mathematical methods such as least squares or polynomial fitting to calculate the spatial accuracy at any point. Since the spatial accuracy of a machine tool is affected by various factors, such as the complexity of the machine tool structure, wear of moving parts, and thermal deformation, its variation exhibits nonlinear characteristics. Traditional fitting methods, based on linear assumptions or simple nonlinear models, struggle to accurately describe the nonlinear changes in machine tool spatial accuracy, easily leading to overfitting and underfitting. Overfitting results in an overly complex model that excessively fits the noisy data at the detection points, reducing the model's predictive ability for new data in practical applications. Underfitting, on the other hand, results in an overly simplistic model that fails to capture the true trend of changes in machine tool spatial accuracy, leading to significant deviations between the fitted results and actual conditions. Using these fitted results to compensate for CNC machine tool errors can result in unstable machine tool movement and overcompensation, severely impacting the machine tool's machining performance and accuracy. Furthermore, existing fitting methods can only provide approximate solutions for the spatial accuracy of the machine tool within its motion space, resulting in low accuracy. When the accuracy of the machine tool fluctuates significantly, such as after prolonged machining due to temperature changes causing structural deformation or severe wear of machine tool components, the compensation effect of traditional fitting methods often fails to meet the expected requirements and cannot satisfy the demands of high-precision machining. Summary of the Invention

[0003] The purpose of this invention is to further improve the fitting accuracy of CNC machine tool spatial precision and reduce nonlinear and random errors during machine tool movement. It proposes a CNC machine tool spatial position calculation method based on BP neural network correction. Through a technical approach of geometric modeling to decouple error sources, BP neural network fitting of nonlinear features, and data-driven optimization model, this method overcomes the limitations of traditional methods in nonlinear error fitting, global precision compensation, and anti-interference capabilities. It provides a solution for high-precision machining of CNC machine tools that combines theoretical rigor with engineering practicality.

[0004] This application achieves the above objective through the following technical solution: a method for calculating the spatial position of a CNC machine tool based on BP neural network correction, characterized by the following steps: S1, constructing a motion coordinate system for machine tool components according to the CNC machine tool configuration, and establishing a spatial error geometric relationship model of the CNC machine tool based on the motion coordinate system for machine tool components; S2, planning a spatial error measurement trajectory, setting up measurement points along the spatial error measurement trajectory, and pre-setting theoretical position coordinate data for each measurement point to obtain a theoretical position coordinate dataset; S3, detecting the position coordinate data of each measurement point on the spatial error measurement trajectory to obtain an original measured position dataset; S4, based on the position of the measurement points in the original measured position dataset... S5. Spatial error identification is performed on the coordinate data to obtain geometric error parameters; S6. The geometric error parameters are substituted into the spatial error geometric relationship model of the CNC machine tool to obtain the machine tool spatial error model; S7. The theoretical position coordinate data of the measured points in the theoretical position coordinate dataset are input into the machine tool spatial error model to obtain the error calculation coordinate dataset; S8. The theoretical position coordinate data and error calculation coordinate data are used as input values, and the original measured position data is used as the target value to train a BP neural network to obtain a neural network correction model; S9. Based on the theoretical position coordinate data of any point in the CNC machine tool space, the neural network correction model is used to perform correction to obtain the actual position coordinate data of that point.

[0005] Preferably, in step S1, constructing the motion coordinate system of the machine tool components includes: establishing a basic coordinate system S based on the mechanical origin of the CNC machine tool; establishing a dedicated coordinate system X for machine tool components moving along the X-axis of the machine tool coordinate system; establishing a dedicated coordinate system Y for machine tool components moving along the Y-axis of the machine tool coordinate system; establishing a dedicated coordinate system Z for machine tool components moving along the Z-axis of the machine tool coordinate system; establishing a workpiece coordinate system W for the machine tool worktable; establishing a spindle coordinate system S for the machine tool spindle; and establishing a tool coordinate system T for the machining tools on the machine tool spindle.

[0006] Preferably, in step S1, establishing the spatial error geometric relationship model of the CNC machine tool includes the following steps: S11, establishing a homogeneous transformation matrix system based on the motion coordinate system of the machine tool components, including: a homogeneous transformation matrix from the basic coordinate system R to the axis-specific coordinate system X. The homogeneous transformation matrix from the axis-specific coordinate system X to the axis-specific coordinate system Y. The homogeneous transformation matrix from the axis-specific coordinate system Y to the axis-specific coordinate system Z. The homogeneous transformation matrix from the axis-specific coordinate system Z to the principal axis coordinate system S. The homogeneous transformation matrix from the principal axis coordinate system S to the tool coordinate system T The homogeneous transformation matrix from the workpiece coordinate system W to the base coordinate system R. S12, Establish a homogeneous transformation matrix from the workpiece coordinate system W to the tool coordinate system T based on the homogeneous transformation matrix system. ,Right now S13, based on homogeneous transformation matrix By combining the small error assumption, the spatial error geometric relationship model of the CNC machine tool is obtained through calculation. .

[0007] Preferably, in the homogeneous transformation matrix system of step S11, the homogeneous transformation matrix... Homogeneous transformation matrix and homogeneous transformation matrix Both are fourth-order identity matrices; the theoretical position coordinates of the tool tip in the basic coordinate system R are set as follows: Then: homogeneous transformation matrix Homogeneous transformation matrix Homogeneous transformation matrix ; This represents the perpendicularity error between the X-axis and Y-axis in the basic coordinate system R. This represents the perpendicularity error between the X-axis and Z-axis in the basic coordinate system R. This represents the perpendicularity error between the Y-axis and Z-axis in the basic coordinate system R. This represents the tilt error in the X-axis direction of the basic coordinate system R; This represents the pitch error in the X-axis direction of the base coordinate system R; This represents the yaw error in the X-axis direction of the basic coordinate system R; This represents the yaw error in the Y-axis direction of the basic coordinate system R; This represents the tilt error in the Y-axis direction of the basic coordinate system R; This represents the pitch error in the Y-axis direction of the base coordinate system R; This represents the pitch error in the Z-axis direction of the base coordinate system R; This represents the yaw error in the Z-axis direction of the basic coordinate system R; This represents the tilt error in the Z-axis direction of the basic coordinate system R; This represents the positioning error in the X-axis direction of the base coordinate system R; This represents the straightness error in the Y-axis direction when moving along the X-axis in the base coordinate system R; This represents the straightness error in the Z-axis direction when moving along the X-axis in the base coordinate system R; This represents the straightness error in the X-axis direction when moving along the Y-axis in the base coordinate system R; This represents the positioning error in the Y-axis direction of the base coordinate system R; This represents the straightness error in the Z-axis direction when moving along the Y-axis in the base coordinate system R; This represents the straightness error in the X-axis direction when moving along the Z-axis in the base coordinate system R; This represents the straightness error in the Y-axis direction when moving along the Z-axis in the base coordinate system R; This represents the positioning error in the Z-axis direction of the basic coordinate system R.

[0008] Preferably, in step S13, the small error assumption is that, under ideal conditions, the homogeneous coordinate transformation matrix from the workpiece coordinate system W to the tool coordinate system T... Then there is By simultaneously solving the homogeneous coordinate transformation matrices, the spatial error geometric relationship model can be obtained, namely: .

[0009] Preferably, in step S2, the spatial error measurement trajectory is planned based on the basic coordinate system R, which plans nine measurement trajectory lines, including: taking three parallel straight lines with respect to the X-axis, namely... , and ;in: It intersects the Z-axis and Y-axis perpendicularly at the origin O; Perpendicular to and intersecting the Y-axis; Perpendicular to and intersecting the Z-axis; take three parallel lines with respect to the Z-axis, namely... , and ;in: and The origin O is perpendicular to the Y-axis; and It intersects the Y-axis perpendicularly at one point; respectively with and Perpendicular and intersecting; take three parallel lines with respect to the Y-axis, namely... , and ;in: and and They intersect perpendicularly at the origin O; respectively with and Perpendicular and intersecting; and and They intersect perpendicularly at one point.

[0010] Preferably, in step S2, the measurement points are set up by taking points at intervals along the measurement trajectory line, with a custom spacing between the points, to ensure that there are at least 5 measurement points per meter.

[0011] Preferably, in step S3, obtaining the original measured location dataset includes the following steps: S31, using a laser measuring device to detect the position coordinate data of each measurement point on the spatial error measurement trajectory; S32, based on the error normal distribution verification method, statistically analyzing the errors of the position coordinate data of each measurement point in the X-axis, Y-axis, and Z-axis directions of the basic coordinate system R to determine whether they conform to a normal distribution; if yes, proceed to step S33; if no, return to step S31; S33, perform linear normalization processing on the position coordinate data of each measurement point; S34, randomly divide the processed position coordinate data into two groups to obtain a training set and a validation set, which together constitute the original measured location dataset.

[0012] Preferably, in step S34, the ratio of the amount of data in the training set to the amount of data in the validation set is 3:1.

[0013] Preferably, in step S4, spatial error identification includes: obtaining the perpendicularity error of the CNC machine tool based on the position coordinate data of the central measurement points in the original measured position dataset, combined with the spatial least squares fitting method, including: the perpendicularity error between the X-axis and Y-axis in the basic coordinate system R. Perpendicularity error between the X-axis and Z-axis in the basic coordinate system R Perpendicularity error between the Y-axis and Z-axis in the basic coordinate system R Based on the nine-line method, 18 errors corresponding to the X-axis, Y-axis and Z-axis in the basic coordinate system R are obtained, including: 3 tilt errors, 3 pitch errors, 3 yaw errors, 3 positioning errors and 6 straightness errors.

[0014] Preferably, in step S5, during the process of obtaining the machine tool spatial error model, model preprocessing is first performed. The model preprocessing includes the following steps: S51, determining the error vector parameters in the spatial error geometric relationship model, that is, the error vectors generated by the tool tip in the X-axis, Y-axis and Z-axis directions of the basic coordinate system R during the operation of the CNC machine tool. , and ;in: ; ; S52, based on the perpendicularity error of the CNC machine tool, the error vector in the spatial error geometric relationship model is preprocessed to remove the influence of perpendicularity error on positioning accuracy, that is: ; ; ; This represents the error vector corresponding to the X-axis direction after preprocessing. This represents the error vector corresponding to the Y-axis direction after preprocessing. This represents the error vector corresponding to the Z-axis direction after preprocessing.

[0015] Preferably, in step S7, the BP neural network training includes the following steps: S71, inputting the training set from the theoretical position coordinate dataset, the error calculation coordinate dataset, and the original measured position dataset into the BP neural network for BP neural network training; S72, determining whether the preset number of iterations or the preset termination accuracy requirement is met; if yes, proceed to step S73; if no, after adjusting and optimizing the neural network structure, return to step S71; S73, inputting the validation set from the theoretical position coordinate dataset, the error calculation coordinate dataset, and the original measured position dataset into the BP neural network for neural network validation, obtaining the average deviation between the validation output parameter and the validation target value; S74, determining whether the average deviation meets the preset requirement; if no, after adjusting and optimizing the neural network structure, return to step S71; if yes, obtain the neural network correction model.

[0016] Preferably, step S72, determining whether the preset termination accuracy requirement is met includes the following steps: S721, obtaining corresponding position coordinate data from the verification set in the theoretical position coordinate dataset, the error calculation coordinate dataset, and the original measured position dataset, inputting the data into the BP neural network, and obtaining the deviation value between the verification output parameter and the verification target value; S722, determining whether the deviation value is less than 0.0001; if yes, it is determined that the preset termination accuracy requirement is met; if no, it is determined that the preset termination accuracy requirement is not met.

[0017] Preferably, in step S74, the preset requirement for the mean deviation is less than 0.0001.

[0018] Preferably, in step S8, obtaining the actual position coordinate data includes the following steps: S81, obtaining the theoretical position coordinate data of any point M in the CNC machine tool space; S82, inputting the theoretical position coordinate data into the machine tool space error model to obtain error calculation coordinate data; S83, inputting the theoretical position coordinate data and error calculation coordinate data of point M into the neural network correction model to obtain the actual coordinate value of point M.

[0019] The beneficial technical effects of this invention are as follows: First, it overcomes the limitations of traditional linear fitting and accurately characterizes nonlinear errors through nonlinear mapping: Compared to traditional methods (least squares method, polynomial fitting), which are based on linear assumptions and cannot capture the nonlinear changes in machine tool spatial accuracy (such as errors caused by thermal deformation and component wear), this technical solution establishes a nonlinear mapping relationship between theoretical position, geometric error model output, and measured error through multi-layer nonlinear transformation of a BP neural network (three-layer network structure) (step S7). This accurately fits the nonlinear characteristics of machine tool spatial accuracy, avoiding overfitting and underfitting problems. For example, as shown in Figure 5-7, the dispersion of the error value after correction by the BP neural network is significantly reduced, and it is closer to the true value.

[0020] Dynamic error adaptability: When machine tool accuracy fluctuates significantly (such as thermal deformation after prolonged processing), traditional compensation methods are ineffective. This technical solution, however, uses neural network training (steps S71-S74) to dynamically optimize the error model using measured data, adaptively correcting nonlinear error components. For example, in Example 10, the training termination accuracy is set to 0.0001 to ensure the model's adaptability in high-precision scenarios.

[0021] II. Integrating Geometric Modeling and Data-Driven Approaches to Improve Error Decoupling and Identification Accuracy: Layered Error Modeling and Preprocessing: Based on multibody system theory, a coordinate system is constructed (step S1) to decouple machine tool errors into independent components such as positioning error, straightness error, and perpendicularity error, avoiding identification deviations caused by error coupling in traditional methods. Perpendicularity error preprocessing (step S52) removes the influence of inter-axis orthogonality errors on positioning accuracy, improving the baseline accuracy of the error model. For example, in Example 8, the perpendicularity error is separated using spatial least squares, and the error vector is then preprocessed to reduce the interference of position-independent errors.

[0022] The nine-line method is combined with data-driven approaches: The nine-line method is used to plan the measurement trajectory (steps S2 and S6), covering key areas of the machine tool's workspace. Combined with data-driven optimization using a BP neural network (step S7), this upgrades the system from "limited-point measurement" to "global error prediction." Compared to traditional methods that only fit limited points, this invention improves the global prediction accuracy of the error model through the generalization ability of neural networks (such as the 3:1 partitioning of the training and validation sets in Example 7).

[0023] III. Optimize data acquisition and model training processes to enhance robustness and engineering applicability. Data quality control and standardization: Measurement point layout follows the high-density sampling principle of at least 5 points per meter (step S2) to ensure the spatial resolution of error signals; abnormal data is eliminated through normal distribution verification (step S32) to avoid noise interference. Linear normalization processing (step S33) eliminates the difference in error dimensions across different axes, improving the stability of neural network training.

[0024] Anti-overfitting mechanism and model self-optimization: Independent evaluation using a validation set (steps S73-S74). When the mean deviation is greater than 0.0001, the network structure is adjusted to prevent overfitting to noise in the measured data (as in Example 10, iterative training and validation set monitoring ensure the model's generalization ability). Neural network parameters (such as the number of hidden layer neurons and learning rate) are dynamically adjusted to balance fitting accuracy and computational efficiency, suitable for real-time machine tool compensation scenarios (such as the real-time correction process in step S8).

[0025] IV. Achieving high-precision spatial error compensation and improving processing performance: A multi-level error correction architecture is established. First, the systematic error is calculated using a geometric error model (step S5), and then the nonlinear residual is corrected using a BP neural network (steps S7-S8), forming a two-layer compensation mechanism of "physical modeling + data optimization". Compared with the traditional single fitting method, this invention can improve the error compensation accuracy to the micrometer level (such as the training termination accuracy of 0.0001mm in Example 10).

[0026] Full-domain dynamic compensation capability: Based on the trained neural network correction model (step S8), the theoretical coordinates of any point in the machine tool space can be corrected in real time to adapt to different machining trajectories and working conditions (such as long-term machining, after component wear), avoiding the overcompensation or motion instability problems caused by insufficient model generalization ability of traditional methods.

[0027] V. Engineering Advantages: Simplified Measurement Process and Cost Control, Reduced Dependence on Testing Instruments: The indirect measurement method, combined with a BP neural network, eliminates the need for multiple precision instruments (laser interferometers, ballbars, etc.) as traditional direct measurement methods do. Geometric errors are inferred from the tool tip error, reducing measurement costs and operational complexity.

[0028] The model has strong transferability: the coordinate system and error modeling method (steps S1-S5) are universal and the transformation matrix parameters can be adjusted for different configuration CNC machine tools. The neural network training process (step S7) can realize model iteration through data updates, adapting to the accuracy management of the entire life cycle of the machine tool. Attached Figure Description

[0029] Figure 1 is a block diagram illustrating the implementation principle of a preferred method for calculating the spatial position of a CNC machine tool; Figure 2 is a flowchart illustrating a preferred BP neural network training process; Figure 3 is a schematic diagram illustrating a spatial error measurement trajectory; Figure 4 is a schematic diagram illustrating the point selection for X-axis error measurement during the spatial error identification process; Figure 5 is a comparison diagram of spatial accuracy fitting correction error values ​​in the X-axis direction; Figure 6 is a comparison diagram of spatial accuracy fitting correction error values ​​in the Y-axis direction; Figure 7 is a comparison diagram of spatial accuracy fitting correction error values ​​in the Z-axis direction. Detailed Implementation

[0030] To make the purpose, technical solution and advantages of the invention clearer, the technical solution of the invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are some embodiments of the invention, but not all embodiments.

[0031] Therefore, the following detailed description of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0032] Example 1 This example discloses a method for calculating the spatial position of a CNC machine tool based on a BP neural network correction. As a preferred embodiment of the present invention, as shown in Figure 1, it includes the following implementation steps: S1, constructing a coordinate system of machine tool components based on the CNC machine tool configuration, and establishing a spatial error geometric relationship model of the CNC machine tool based on the coordinate system of machine tool components. The purpose of this step is to establish a mathematical representation of the machine tool motion, providing a theoretical framework for subsequent error modeling, so that spatial errors can be quantitatively expressed through geometric parameters. Based on kinematic theory (such as the Denavit-Hartenberg parameter method), the relative motion relationship between the machine tool components can be described through a homogeneous transformation matrix, transforming the mechanical structure into a mathematical model. The error geometric relationship model corrects the ideal kinematic equations by introducing error terms (such as straightness, perpendicularity, yaw angle, etc.), and uses a low-order volume array to describe the error propagation path based on multibody system theory.

[0033] S2. Plan the spatial error measurement trajectory, set up measurement points along the trajectory, and pre-set theoretical position coordinate data for each measurement point to obtain a theoretical position coordinate dataset. The purpose of this step is to obtain a representative theoretical position dataset to provide a benchmark for error detection and ensure the applicability and generalization ability of the subsequent error model. Based on the spatial sampling theorem and following standards such as ISO230-2, grid points and diagonal trajectories can be used to cover the machine tool workspace to ensure that the distribution of measurement points meets the spatial resolution requirements for error identification. Global error data is obtained by traversing key motion paths.

[0034] S3 involves detecting the position coordinates of each measurement point on the spatial error measurement trajectory to obtain the original measured position dataset. The purpose of this step is to acquire raw data reflecting the actual motion deviation of the machine tool, providing accurate input for error identification and ensuring that subsequent analysis is based on actual operating conditions. High-precision measuring equipment such as laser interferometers and ballbars can be used, based on principles such as photoelectric interferometry and grating rulers, to collect the actual position coordinates of each measurement point, and the original measured values ​​are recorded through a data acquisition system.

[0035] S4. Based on the position coordinate data of the centralized measurement points in the original measured position dataset, spatial error identification is performed to obtain geometric error parameters. The purpose of this step is to extract independent error sources from complex measured data, clarify the geometric error contribution of each axis of the machine tool, and provide specific parameters for error modeling. Optimization algorithms such as least squares or genetic algorithms can be used to compare the measured position data with the theoretical model, iteratively calculate and separate each geometric error parameter, and then use the linearization approximation of the error model to solve for the optimal solution of the parameters.

[0036] S5, substitute the geometric error parameters into the spatial error geometric relationship model of the CNC machine tool to obtain the machine tool spatial error model. The purpose of this step is to establish a computable error prediction model, so that the error value at any theoretical position can be directly solved through the model, providing a computational basis for error compensation. The identified geometric error parameters can be substituted into the error geometric relationship model established in step S1, and error terms can be superimposed through homogeneous transformation matrices to form a mathematical model containing the position-error mapping relationship, realizing the mapping from parameters to spatial error.

[0037] S6: Input the theoretical position coordinates of the measured points in the theoretical position coordinate dataset into the machine tool spatial error model to obtain the error calculation coordinate dataset. The purpose of this step is to generate the input data required for training the BP neural network, construct a mapping pair between theoretical position and predicted error, and provide samples for neural network learning. The theoretical position coordinates can be input into the machine tool spatial error model in step S5, and the error offset of each point can be solved through matrix operations. The result is then superimposed onto the theoretical coordinates to obtain the error calculation coordinates. Essentially, this is an error pre-calculation based on inverse kinematics.

[0038] S7 involves training a backpropagation (BP) neural network using theoretical position coordinates and error calculation coordinates as inputs, and raw measured position data as the target value, to obtain a corrected neural network model. The purpose of this step is to optimize the error correction model through a data-driven approach, overcoming the linearization assumptions of traditional geometric models and improving error prediction accuracy. The backpropagation mechanism of the BP algorithm can be utilized to adjust network weights via gradient descent, minimizing the mean square error between the network output and the target value. This leverages the nonlinear mapping capability of the neural network to fit complex error models.

[0039] S8. Based on the theoretical position coordinates of any point within the CNC machine tool space, a neural network correction model is used to correct the position, obtaining the actual position coordinates of that point. The purpose of this step is to achieve real-time error correction during machine tool machining, improve spatial positioning accuracy, and meet the requirements of high-precision machining. The theoretical position coordinates of any point can be input into a trained neural network. Through the nonlinear transformation of the hidden layers, the output error compensation amount is obtained, which is superimposed with the theoretical coordinates to obtain the corrected actual position. The generalization ability of the neural network is used to achieve global error compensation.

[0040] Example 2 This example discloses a method for calculating the spatial position of a CNC machine tool based on BP neural network correction. As a preferred embodiment of the present invention, based on Example 1, step S1, constructing the motion coordinate system of the machine tool components, includes: establishing a basic coordinate system S: using the mechanical origin of the CNC machine tool as a reference, and following the right-hand rule of the Cartesian coordinate system, an absolute reference system is established as the reference origin for the transformation of the entire machine tool coordinate system. Its coordinate transformation follows the principles of rigid body kinematics, and through a homogeneous transformation matrix, a mapping relationship is formed with other coordinate systems, providing a unified spatial reference for each moving component.

[0041] Establish dedicated coordinate systems (X / Y / Z): For each linear axis moving component, the kinematic decomposition method is used to decompose the overall machine tool motion into translational motions of independent axes. This includes: establishing a dedicated coordinate system X for machine tool components moving along the X-axis of the machine tool coordinate system; establishing a dedicated coordinate system Y for machine tool components moving along the Y-axis of the machine tool coordinate system; and establishing a dedicated coordinate system Z for machine tool components moving along the Z-axis of the machine tool coordinate system. Each axis coordinate system uses the motion direction of the corresponding axis as the reference axis. The pose transformation of the axis component relative to the base coordinate system R can be described using the DH parameter method. An error propagation chain is constructed using low-order volume array theory, allowing errors such as straightness and perpendicularity of each axis to be modeled independently.

[0042] Establish the workpiece coordinate system W: Based on the machining process requirements, a floating coordinate system is established with the workpiece clamping position as the origin. It can be associated with the basic coordinate system R through a coordinate transformation matrix, conforming to the ISO10579 machine tool coordinate system standard. It allows adjustment of the coordinate origin according to the workpiece clamping posture, meeting the programming requirements of different workpieces. Its transformation matrix includes positioning error parameters caused by workpiece clamping.

[0043] Establish the spindle coordinate system S and the tool coordinate system T: Using the tool coordinate system (TCP) calibration method, the spindle coordinate system S, with the spindle rotation center as its origin, describes the rotational motion of the spindle relative to the base coordinate system R. The tool coordinate system T, through parameters such as tool length compensation and tool tip radius compensation, establishes the transformation relationship between the tool cutting point and the spindle coordinate system T. The two coordinate systems can be superimposed using a homogeneous transformation matrix to include dynamic error terms such as spindle runout error and tool installation error.

[0044] The core purpose of establishing the aforementioned machine tool component motion coordinate system is to: 1) Achieve hierarchical decoupling of error sources: Decompose the overall machine tool error into independent components such as basic coordinate system error, motion errors of each axis, workpiece clamping error, spindle rotation error, and tool installation error. Utilize the hierarchical structure of multibody system theory, so that each coordinate system corresponds to a specific error source, facilitating the independent identification and quantitative analysis of subsequent error parameters. 2) Improve the accuracy of complex motion modeling: By establishing dedicated coordinate systems for each axis, the problem of coupling errors in multi-axis linkage that traditional single coordinate systems cannot easily describe is solved. For example, the X-axis coordinate system can model the straightness error of that axis independently, and the Y-axis coordinate system can model the perpendicularity error. The errors of each coordinate system are cascaded through transformation matrices to more realistically reflect the spatial kinematic characteristics of the machine tool. 3) Adapt to dynamic changes in machining processes: The independent setting of the workpiece coordinate system and the tool coordinate system decouples the programming coordinate system from the machine tool physical coordinate system. When changing the workpiece or tool, only the transformation parameters of the corresponding coordinate system need to be recalibrated, without modifying the overall error model, improving the model's adaptability to different machining scenarios and meeting the needs of flexible manufacturing. Example 3 This example discloses a method for calculating the spatial position of a CNC machine tool based on BP neural network correction. As a preferred embodiment of the present invention, based on Example 2, step S1, establishing the spatial error geometric relationship model of the CNC machine tool includes the following steps: S11, establishing a homogeneous transformation matrix system based on the motion coordinate system of the machine tool components, including: a homogeneous transformation matrix from the basic coordinate system R to the axis-specific coordinate system X. The homogeneous transformation matrix from the axis-specific coordinate system X to the axis-specific coordinate system Y. The homogeneous transformation matrix from the axis-specific coordinate system Y to the axis-specific coordinate system Z. The homogeneous transformation matrix from the axis-specific coordinate system Z to the principal axis coordinate system S. The homogeneous transformation matrix from the principal axis coordinate system S to the tool coordinate system T The homogeneous transformation matrix from the workpiece coordinate system W to the base coordinate system R. .

[0045] This technical solution uses a homogeneous transformation matrix (HTM) to describe the pose relationships (translation + rotation) between the coordinate systems of various machine tool components, following the Denavit-Hartenberg (DH) parameter method or an improved low-order volume array theory for multibody systems. Each homogeneous transformation matrix (e.g.) The transformation represents a change from one coordinate system (base coordinate system R) to another coordinate system (axis-specific coordinate system X), including the ideal motion parameters (such as displacement and angle) and error terms (such as straightness, perpendicularity, and runout) of that axis. By constructing a layered transformation matrix, the complex motion of the machine tool is decomposed into a cascade of independent motions of each axis, realizing modular modeling of error sources.

[0046] S12, Establish the homogeneous transformation matrix from the workpiece coordinate system W to the tool coordinate system T based on the homogeneous transformation matrix system. During machine tool processing, the position of the tool relative to the workpiece is determined by a multi-coordinate transformation chain, that is: This formula uses matrix multiplication to sequentially superimpose the motion errors (including ideal motion and error terms) of each component, ultimately obtaining the complete pose transformation of the tool relative to the workpiece. This transformation chain covers the entire process from the basic machine tool motion (X / Y / Z axes) to the spindle-tool dynamic error, and then to the workpiece clamping error, realizing the modeling of pose error at any point in the machining space. The error terms of each transformation matrix are calculated by linear approximation through matrix multiplication to accumulate the error, providing a mathematical basis for subsequent small error calculation (S13).

[0047] S13, based on homogeneous transformation matrix By combining the small error assumption, the spatial error geometric relationship model of the CNC machine tool is obtained through calculation. .

[0048] This embodiment establishes a spatial error geometric model that combines physical meaning and mathematical solvability by constructing a homogeneous transformation matrix system, cascading poses in multiple coordinate systems, and linearizing small errors. This provides a theoretical framework and error characteristic basis for subsequent BP neural network correction, achieving a balance between refined modeling of machine tool geometric errors and engineering applications.

[0049] Example 4 This example discloses a method for calculating the spatial position of a CNC machine tool based on a BP neural network correction. As a preferred embodiment of the present invention, based on Example 3, in the homogeneous transformation matrix system of step S11, the manufacturing error, assembly error, and thermal error of the workpiece are ignored, so that the homogeneous transformation matrix... Homogeneous transformation matrix and homogeneous transformation matrix Both are fourth-order identity matrices, that is: In other words, it is assumed that the spindle has no rotational error (radial runout and axial runout are 0), the tool and spindle have no installation error (the tool coordinate system and the spindle coordinate system are completely coincident), and the workpiece clamping has no error (the origin of the workpiece coordinate system coincides with the origin of the base coordinate system, with no rotational offset). These assumptions focus the model on the motion errors of the X / Y / Z axes, forming a direct mapping from "axis motion to tool pose," which facilitates error parameter identification and initial modeling.

[0050] Let the theoretical position coordinates of the tool tip in the basic coordinate system R be: Then we have: homogeneous transformation matrix Homogeneous transformation matrix Homogeneous transformation matrix .

[0051] The above homogeneous transformation matrix structure and error mapping are as follows: 1) Rotation error (attitude deviation) This represents the tilt error (XY plane tilt) in the X-axis direction of the basic coordinate system R. This represents the pitch error (YZ plane tilt) in the X-axis direction of the base coordinate system R. This represents the yaw error (XZ plane rotation) in the X-axis direction of the base coordinate system R. This represents the yaw error (YX plane rotation) in the Y-axis direction of the base coordinate system R. This represents the tilt error (YZ plane tilt) of the movement along the Y-axis in the base coordinate system R. This represents the pitch error (ZX plane tilt) in the Y-axis direction of the base coordinate system R. This represents the pitch error (XY plane tilt) in the Z-axis direction of the base coordinate system R. This represents the yaw error (ZY plane rotation) in the Z-axis direction of the base coordinate system R. This represents the tilt error (ZX plane tilt) in the Z-axis direction of the basic coordinate system R.

[0052] These rotational error parameters, approximated by small angles, linearize the attitude deviation of the shaft system motion and embed them into the rotation part of the HTM matrix.

[0053] 2) Straightness error (positional deviation) This represents the straightness error in the Y-axis direction when moving along the X-axis in the base coordinate system R (i.e., the offset in the Y-axis when moving along the X-axis). This represents the straightness error in the Z-axis direction when moving along the X-axis in the basic coordinate system R (i.e., the offset in the Z-axis direction when moving along the X-axis). This represents the straightness error in the X-axis direction when moving along the Y-axis in the basic coordinate system R (i.e., the offset in the X-axis direction when moving along the Y-axis). This represents the straightness error in the Z-axis direction when moving along the Y-axis in the base coordinate system R (i.e., the offset in the Z-axis direction when moving along the Y-axis). This represents the straightness error in the X-axis direction when moving along the Z-axis in the basic coordinate system R (i.e., the offset in the X-axis direction when moving along the Z-axis). This represents the straightness error in the Y-axis direction when moving along the Z-axis in the base coordinate system R (i.e., the offset in the Y-axis when moving along the Z-axis).

[0054] These straightness error parameters reflect the non-ideal straightness of the shaft system motion.

[0055] 3) Positioning error (displacement deviation) This represents the positioning error in the X-axis direction of the basic coordinate system R (the positioning error in the X-axis direction, the deviation between the actual displacement and the theoretical displacement). This represents the positioning error in the Y-axis direction of the basic coordinate system R (the positioning error in the Y-axis direction, the deviation between the actual displacement and the theoretical displacement). This represents the positioning error in the Z-axis direction of the basic coordinate system R (positioning error in the Y-axis direction, the deviation between the actual displacement and the theoretical displacement).

[0056] These positioning error parameters directly affect the positional accuracy of the shaft system.

[0057] 4) Perpendicularity error (interaxial orthogonality) It represents the perpendicularity error between the X-axis and Y-axis in the base coordinate system R, and describes the orthogonality deviation of the Y-axis relative to the X-axis; It represents the perpendicularity error between the X-axis and Z-axis in the basic coordinate system R, and describes the orthogonality deviation of the Z-axis relative to the X-axis; This represents the perpendicularity error between the Y-axis and Z-axis in the base coordinate system R, describing the orthogonality deviation of the Y-axis relative to the Z-axis.

[0058] This embodiment establishes a shaft motion error model that combines engineering practicality and mathematical rigor by simplifying error sources, constructing an HTM matrix, and defining error parameters. This model provides clear geometric error feature inputs for BP neural network correction, achieving an organic combination of quantitative modeling of mechanical motion errors and data-driven correction. It supports high-precision spatial position calculations for CNC machine tools and is particularly suitable for calibration and compensation scenarios involving machine tool body errors.

[0059] Example 5 This example discloses a method for calculating the spatial position of a CNC machine tool based on BP neural network correction. As a preferred embodiment of the present invention, based on Example 4, in step S13, the small error assumption is to introduce an ideal transformation matrix. , represents the pose without error (containing only theoretical coordinate translation), that is, the homogeneous coordinate transformation matrix from the workpiece coordinate system W to the tool coordinate system T under ideal conditions. Based on this, the actual transformation matrix will be... It can be decomposed into the product of the ideal part and the error part, that is... By simultaneously solving the homogeneous coordinate transformation matrices, the spatial error geometric relationship model can be obtained. ,Right now: .

[0060] The above spatial error geometric relationship model The matrix elements integrate the cross-effects of positioning, straightness, perpendicularity, and attitude errors (such as...). It represents the contribution of the Z coordinate to the XZ perpendicularity error, breaking through the independent modeling of a single axis and reflecting the global coupling characteristics of errors in actual motion (such as the influence of X-axis yaw on Y / Z straightness).

[0061] In summary, this embodiment establishes a high-precision and scalable spatial error geometric model through ideal-error matrix decomposition and coupled error modeling. This model not only quantifies the coupling relationship of multi-axis errors but also provides explicit error feature inputs for BP neural networks, achieving deep integration of geometric models and data-driven approaches. This supports real-time error correction in high-speed and high-precision CNC machine tool machining, representing a key technological upgrade from "theoretical modeling" to "engineering application."

[0062] Example 6 discloses a method for calculating the spatial position of a CNC machine tool based on BP neural network correction. As a preferred embodiment of the present invention, based on any of Examples 1 to 5, in step S2, as shown in Figure 3, the planned spatial error measurement trajectory uses orthogonal axis coverage. That is, nine measurement trajectory lines are planned based on the basic coordinate system R, with three parallel straight lines planned for the X, Y, and Z axes respectively, forming a three-dimensional orthogonal measurement grid that covers the key areas of the machine tool workspace (origin, inter-axis intersections, and travel segments of each axis). Through inter-axis cross-measurement, multi-axis error coupling is decoupled, ensuring independent identification of error parameters.

[0063] Take three parallel lines with respect to the X-axis, namely... , and ;in: It intersects the Z-axis and Y-axis perpendicularly at the origin O; Perpendicular to and intersecting the Y-axis; Perpendicular to and intersecting the Z-axis; take three parallel lines with respect to the Z-axis, namely... , and ;in: and The origin O is perpendicular to the Y-axis; and It intersects the Y-axis perpendicularly at one point; respectively with and Perpendicular and intersecting; take three parallel lines with respect to the Y-axis, namely... , and ;in: and and They intersect perpendicularly at the origin O; respectively with and Perpendicular and intersecting; and and They intersect perpendicularly at one point.

[0064] By using orthogonal axis trajectory planning, a standardized, high-resolution error measurement system was constructed, providing crucial data support for subsequent steps. Its design integrates mechanical precision testing theory with data-driven model requirements, achieving full-process optimization of error modeling, detection, and correction. This is a core engineering step for improving the spatial position calculation accuracy of CNC machine tools.

[0065] Based on this, in step S2, measurement points are set up along the spatial error measurement trajectory according to discrete signal processing theory. The spacing between the measurement points determines the sampling resolution of the machine tool motion error. The custom spacing can be flexibly adjusted according to the machine tool accuracy level and error frequency characteristics to ensure that the Nyquist-Shannon sampling theorem is satisfied and to avoid the aliasing and loss of error information.

[0066] In this technical solution, at least 5 measurement points are guaranteed per meter. From a linear algebra perspective, error identification requires establishing an overdetermined system of equations (number of equations > number of unknowns). Five points per trajectory provide five sets of constraints, and the least squares method is used to achieve optimal fitting of the error parameters, improving the stability and accuracy of parameter identification (and reducing the impact of measurement noise).

[0067] Example 7 This example discloses a method for calculating the spatial position of a CNC machine tool based on BP neural network correction. As a preferred embodiment of the present invention, based on any of the examples 1 to 6, it is assumed that the measurement error is composed of a large number of independent and small factors (such as fluctuations in ambient temperature and humidity, laser interferometer noise, machine tool vibration, etc.). According to the central limit theorem, the error should approximately follow a normal distribution. If the actual error distribution deviates significantly from normal (such as exhibiting bimodal, long-tailed, or other non-normal characteristics), it indicates the existence of a systematic deviation (such as measurement equipment failure, improper installation, or sudden environmental changes). Therefore, in step S3, obtaining the original measured position dataset includes the following steps: S31, using a laser measuring device to detect the position coordinate data of each measurement point on the spatial error measurement trajectory.

[0068] S32. After the measurement is completed, the validity and quality of the measurement data need to be verified. This technical solution adopts the error normal distribution verification method. Based on the error normal distribution verification method, the errors of the position coordinate data of each measurement point in the X-axis, Y-axis and Z-axis directions of the basic coordinate system R are statistically analyzed to determine whether they conform to a normal distribution. If they conform to a normal distribution, the data is valid and proceed to step S33; if they do not conform to a normal distribution, the measurement result is invalid and the data needs to be measured again, i.e., return to step S31.

[0069] S33 performs linear normalization on the position coordinate data of each measurement point.

[0070] S34. The processed position coordinate data is randomly divided into two groups to obtain a training set and a validation set. The training set and the validation set together constitute the original measured position dataset. Training set (75%): used for learning the parameters of the BP neural network (adjusting weights and biases) and fitting the mapping relationship between measurement error and theoretical position; Validation set (25%): independent of the training process, used to evaluate the model's generalization ability and prevent overfitting (e.g., the training error continues to decrease, but the validation error increases).

[0071] Example 8 This example discloses a method for calculating the spatial position of a CNC machine tool based on a BP neural network correction. As a preferred embodiment of the present invention, considering that the traditional nine-line identification and separation algorithm does not preprocess the position-independent error of the CNC machine tool, the position-independent error has an influence on the identification and separation of the linear axis movement error and rotation error. In order to weaken the influence of the position-independent error on the identification accuracy and improve the error decoupling accuracy, this example is based on any one of Examples 5 to 7. In step S4, the spatial error identification includes: obtaining the perpendicularity error of the CNC machine tool based on the position coordinate data of the central measurement points in the original measured position dataset, combined with the spatial least squares fitting method. That is, according to the actual position of each measurement point on the spatial error measurement trajectory shown in Figure 2 detected by the laser measuring device in the machine tool coordinate system, the spatial vector of the detection point in the three directions of X, Y and Z axes is fitted using the spatial least squares fitting method, including: calculating the angle COY of the projection of the XY spatial vector onto the XOY plane, that is, the perpendicularity error between the X axis and the Y axis in the basic coordinate system R. ; Calculate the angle XOZ between the projections of the XZ space vector onto the XOZ plane, i.e., the perpendicularity error between the X-axis and Z-axis in the basic coordinate system R. The angle between the projections of the YZ space vectors onto the YOZ plane is the YOZ angle, which represents the perpendicularity error between the Y-axis and Z-axis in the base coordinate system R. .

[0072] Based on this, in step S5, during the process of obtaining the machine tool spatial error model, model preprocessing is first performed. Model preprocessing includes the following steps: S51, determining the error vector parameters in the spatial error geometric relationship model, that is, the error vectors generated by the tool tip in the X-axis, Y-axis and Z-axis directions of the basic coordinate system R during the operation of the CNC machine tool. , and ;in: ; ; S52, based on the perpendicularity error of the CNC machine tool, the error vector in the spatial error geometric relationship model is preprocessed to remove the influence of perpendicularity error on positioning accuracy, that is: ; ; ; This represents the error vector corresponding to the X-axis direction after preprocessing. This represents the error vector corresponding to the Y-axis direction after preprocessing. This represents the error vector corresponding to the Z-axis direction after preprocessing.

[0073] Example 9 This example discloses a method for calculating the spatial position of a CNC machine tool based on BP neural network correction. As a preferred embodiment of the present invention, based on any of the embodiments in Examples 5 to 7, the spatial error identification in step S4 further includes: obtaining 18 errors corresponding to the X-axis, Y-axis and Z-axis in the basic coordinate system R based on the nine-line method, including: 3 tilt errors, 3 pitch errors, 3 yaw errors, 3 positioning errors and 6 straightness errors.

[0074] Taking the X-axis as an example, as shown in Figure 4, in its , and Let's take three points, A, B, and C, respectively. Based on the geometric relationship between the three points, we can construct the following error calculation formula: ; ; ; ; ; Parameters obtained through measurement: , and These are the positioning errors measured when points A, B, and C move along the X direction of the base coordinate system R; and These are the straightness errors measured in the Y direction when points A and B move in the X direction of the basic coordinate system R; This represents the straightness error measured in the Z direction when point A moves in the X direction of the base coordinate system R. , and Let A be the actual coordinates of the measured position of point A in the base coordinate system R; , and The actual coordinates of point B measured in the base coordinate system R; , and The coordinates of point C are the actual position coordinates measured in the base coordinate system.

[0075] The parameters obtained through calculation (6 items): This represents the positioning error of the corresponding point moving along the X-axis in the base coordinate system R; This represents the straightness error in the Y-axis direction when the corresponding point moves along the X-axis in the base coordinate system R; This represents the straightness error in the Z-axis direction when the corresponding point moves along the X-axis in the base coordinate system R; The tilt error about the X-axis when moving in the X direction of the base coordinate system R; The pitch error is the pitch error when moving in the X direction of the base coordinate system R. This represents the yaw error when moving in the X direction of the base coordinate system R.

[0076] The identification principle for the corresponding geometric error parameters (6 items in each direction) of motion in the Y-axis and Z-axis directions is the same as above.

[0077] Example 10 This example discloses a method for calculating the spatial position of a CNC machine tool based on a BP neural network correction, as a preferred embodiment of the present invention, based on any one of Examples 7-9. A BP neural network is a multi-layer feedforward neural network, whose structure includes an input layer, hidden layers, and an output layer. Each layer's neurons are connected to the next layer's neurons through weights. In forward propagation, the input layer's data is weighted and activated before reaching the output layer. In backward propagation, the gradient descent method is used to adjust the neural network's bias and weights based on the deviation between the output value and the theoretical value. Step S7 of this technical solution uses a three-layer BP neural network for training: the input layer has six neurons, representing the theoretical position coordinates of the measurement points. And coordinates calculated based on error The hidden layer has 12 neurons; the output layer has 3 neurons, each corresponding to the actual position coordinates of the measurement point. The input layer transfer function is a tangent sigmoid transfer function, the output layer transfer function is a linear function, the training function is a Levenberg-Marquardt type training function, the learning rate is 0.01, the number of training iterations is 1000, and the training termination precision is 0.0001.

[0078] Therefore, in step S7, as shown in Figure 2, the BP neural network training includes the following steps: S71, inputting the training sets from the theoretical position coordinate dataset, the error calculation coordinate dataset, and the original measured position dataset into the BP neural network for training. The purpose of this step is to construct a high-precision error correction model, combining the linear error prediction of the geometric model with the nonlinear error correction of the measured data, providing error prediction capability for subsequent real-time compensation (S8). In this process: theoretical position coordinates (ideal input), error calculation coordinates (error compensation values ​​predicted by the geometric model), and original measured coordinates (real target) constitute a three-dimensional input-output pair. The BP neural network learns the nonlinear mapping between the three through backpropagation, where the error calculation coordinates provide prior error features (such as linear error components), and the measured data supplements the nonlinear residuals (such as thermal deformation, unmodeled coupling errors), improving the model's ability to fit complex errors. Theoretical coordinates describe spatial position, error calculation coordinates quantify the prediction error of the geometric model, and measured coordinates reflect the actual deviation. The combination of the three enables the network to simultaneously learn the physical laws of position-error (geometric model) and the dynamic deviation of actual working conditions (measured data), enhancing generalization.

[0079] S72, determine whether the preset number of iterations or preset termination accuracy requirement is met; if yes, proceed to step S73; if no, perform neural network structure adjustment and optimization (adjust the number of hidden layers, weight coefficients between layers, learning rate, etc.) and return to step S71. The purpose of this step is to achieve model self-optimization, balance fitting accuracy and computational efficiency, and ensure that the corrected model can quickly respond and output error compensation during real-time machine tool operation, supporting high-speed and high-precision machining. Therefore, determining whether the preset termination accuracy requirement is met includes the following steps: S721, obtain the corresponding position coordinate data from the validation set in the theoretical position coordinate dataset, error calculation coordinate dataset, and original measured position dataset, input them into the BP neural network, and then obtain the deviation value between the validation output parameter (the value calculated by the neural network) and the validation target value (the actual measured coordinate value of the validation set) (obtained through comparison calculation); S722, determine whether the deviation value is less than 0.0001; if yes, it is determined that the preset termination accuracy requirement is met; if no, it is determined that the preset termination accuracy requirement is not met.

[0080] S73, input the validation set from the theoretical position coordinate dataset, the error calculation coordinate dataset, and the original measured position dataset into the BP neural network for neural network validation, and obtain the mean deviation between the validation output parameter and the validation target value.

[0081] S74, determine whether the mean deviation meets the preset requirement; if not, perform neural network structure adjustment and optimization (adjust the number of hidden layers, the weight coefficients between layers, the learning rate, etc.) and return to step S71; if yes, obtain the corrected neural network model. More specifically, the preset requirement for the mean deviation is less than 0.0001.

[0082] The trained neural network (neural network correction model) can correct the calculation results of the ideal spatial error model (i.e., the machine tool spatial error model of this technical solution) to calculate the spatial accuracy at any position in space, thereby evaluating the accuracy status of the CNC machine tool. The simulation results of the spatial accuracy fitting and correction error value are shown in Figures 5, 6 and 7. The simulation results show that the error value after fitting and correction by the BP neural network has a smaller degree of dispersion than the result calculated directly by the machine tool spatial error model, and is closer to the true position value of the CNC machine tool. This provides effective data support for the optimization of CNC machine tool compensation data, adjustment of machine tool measurement step distance, measurement path planning, and evaluation of the machining accuracy status of the parts to be processed by the CNC machine tool.

[0083] Example 11 This example discloses a method for calculating the spatial position of a CNC machine tool based on BP neural network correction, as a preferred embodiment of the present invention, namely based on any one of Examples 1-10. Step S8, obtaining the actual position coordinate data includes the following steps: S81, obtaining the theoretical position coordinate data of any point M within the CNC machine tool space. This serves as the input starting point for error compensation, synchronizing the correction process with the actual motion trajectory of the machine tool, supporting real-time, point-by-point error compensation, ensuring that every point on the machining path can be accurately corrected, and improving overall machining accuracy. The theoretical position coordinates can be generated by the CNC system according to machining instructions (such as G-code), and coordinate mapping is performed based on the machine tool coordinate system to ensure consistency with the coordinate system of the machine tool kinematic model. The theoretical coordinates of any machining point M are calculated using interpolation algorithms (such as linear interpolation and circular interpolation), providing a spatial position reference for subsequent error calculation.

[0084] S82 inputs theoretical position coordinate data into the machine tool spatial error model to obtain error calculation coordinate data. Its purpose is to provide systematic error compensation based on the machine tool's geometry, covering modelable error sources (such as shaft positioning errors, straightness errors, perpendicularity errors, etc.), forming a foundational layer for error compensation, and providing input for fine-tuning of the neural network. Using the spatial error geometric relationship model established in this technical solution, the theoretical position coordinates can be substituted, and the geometric error compensation value at that point can be calculated through matrix operations or solving linear equations. This process, based on the physical laws of machine tool kinematics, quickly solves the error, providing initial error prediction for subsequent neural network correction.

[0085] S83, input the theoretical position coordinates and error calculation coordinates of point M into the neural network correction model to obtain the actual coordinates of point M.

[0086] This embodiment constructs a high-precision, real-time spatial position error compensation mechanism through a three-step process: theoretical coordinate acquisition, geometric error calculation, and neural network correction. Its core lies in integrating physical modeling of machine tool kinematics with data-driven machine learning, solving the accuracy bottleneck and adaptability problems of traditional error compensation methods, and providing key technical support for ultra-precision machining of CNC machine tools.

Claims

1. A method for calculating the spatial position of a CNC machine tool based on BP neural network correction, characterized in that, Includes the following steps: S1. Construct a motion coordinate system for machine tool components based on the configuration of the CNC machine tool, and establish a spatial error geometric relationship model for the CNC machine tool based on the motion coordinate system for machine tool components. S2, plan the spatial error measurement trajectory, set up measurement points along the spatial error measurement trajectory, and preset theoretical position coordinate data for each measurement point to obtain a theoretical position coordinate dataset; S3, detect the position coordinate data of each measurement point on the spatial error measurement trajectory to obtain the original measured position dataset; S4, perform spatial error identification based on the position coordinate data of the measurement points in the original measured position dataset to obtain geometric error parameters; S5, Substitute the geometric error parameters into the spatial error geometric relationship model of the CNC machine tool to obtain the machine tool spatial error model; S6, Input the theoretical position coordinate data of the measured points in the theoretical position coordinate dataset into the machine tool spatial error model to obtain the error calculation coordinate dataset; S7, Use the theoretical position coordinate data and error calculation coordinate data as input values ​​and the original measured position data as target values ​​to train the BP neural network to obtain the neural network correction model; S8, based on the theoretical position coordinate data of any point in the space of the CNC machine tool, uses a neural network correction model to perform correction and obtain the actual position coordinate data of that point.

2. The method for calculating the spatial position of a CNC machine tool based on BP neural network correction as described in claim 1, characterized in that, In step S1, constructing the motion coordinate system of the machine tool components includes: establishing a basic coordinate system S based on the mechanical origin of the CNC machine tool; establishing a dedicated coordinate system X for machine tool components moving along the X-axis of the machine tool coordinate system; establishing a dedicated coordinate system Y for machine tool components moving along the Y-axis of the machine tool coordinate system; establishing a dedicated coordinate system Z for machine tool components moving along the Z-axis of the machine tool coordinate system; establishing a workpiece coordinate system W for the machine tool worktable; establishing a spindle coordinate system S for the machine tool spindle; and establishing a tool coordinate system T for the machining tools on the machine tool spindle.

3. The method for calculating the spatial position of a CNC machine tool based on BP neural network correction as described in claim 2, characterized in that, In step S1, establishing the spatial error geometric relationship model of the CNC machine tool includes the following steps: S11, establishing a homogeneous transformation matrix system based on the motion coordinate system of the machine tool components, including: the homogeneous transformation matrix from the basic coordinate system R to the axis-specific coordinate system X. The homogeneous transformation matrix from the axis-specific coordinate system X to the axis-specific coordinate system Y. The homogeneous transformation matrix from the axis-specific coordinate system Y to the axis-specific coordinate system Z. The homogeneous transformation matrix from the axis-specific coordinate system Z to the principal axis coordinate system S. The homogeneous transformation matrix from the principal axis coordinate system S to the tool coordinate system T The homogeneous transformation matrix from the workpiece coordinate system W to the base coordinate system R. S12, Establish a homogeneous transformation matrix from the workpiece coordinate system W to the tool coordinate system T based on the homogeneous transformation matrix system. ,Right now S13, based on homogeneous transformation matrix By combining the small error assumption, the spatial error geometric relationship model of the CNC machine tool is obtained through calculation. 。 4. The method for calculating the spatial position of a CNC machine tool based on BP neural network correction as described in claim 3, characterized in that, In the homogeneous transformation matrix system of step S11, the homogeneous transformation matrix Homogeneous transformation matrix and homogeneous transformation matrix Both are fourth-order identity matrices; Let the theoretical position coordinates of the tool tip in the basic coordinate system R be: Then: homogeneous transformation matrix Homogeneous transformation matrix Homogeneous transformation matrix ; This represents the perpendicularity error between the X-axis and Y-axis in the basic coordinate system R. This represents the perpendicularity error between the X-axis and Z-axis in the basic coordinate system R. This represents the perpendicularity error between the Y-axis and Z-axis in the basic coordinate system R. This represents the tilt error in the X-axis direction of the basic coordinate system R; This represents the pitch error in the X-axis direction of the base coordinate system R; This represents the yaw error in the X-axis direction of the basic coordinate system R; This represents the yaw error in the Y-axis direction of the basic coordinate system R; This represents the tilt error in the Y-axis direction of the basic coordinate system R; This represents the pitch error in the Y-axis direction of the base coordinate system R; This represents the pitch error in the Z-axis direction of the base coordinate system R; This represents the yaw error in the Z-axis direction of the basic coordinate system R; This represents the tilt error in the Z-axis direction of the basic coordinate system R; This represents the positioning error in the X-axis direction of the base coordinate system R; This represents the straightness error in the Y-axis direction when moving along the X-axis in the base coordinate system R; This represents the straightness error in the Z-axis direction when moving along the X-axis in the base coordinate system R; This represents the straightness error in the X-axis direction when moving along the Y-axis in the base coordinate system R; This represents the positioning error in the Y-axis direction of the base coordinate system R; This represents the straightness error in the Z-axis direction when moving along the Y-axis in the base coordinate system R; This represents the straightness error in the X-axis direction when moving along the Z-axis in the base coordinate system R; This represents the straightness error in the Y-axis direction when moving along the Z-axis in the base coordinate system R; This represents the positioning error in the Z-axis direction of the basic coordinate system R.

5. The method for calculating the spatial position of a CNC machine tool based on BP neural network correction as described in claim 4, characterized in that, In step S13, the small error assumption is that, under ideal conditions, the homogeneous coordinate transformation matrix from the workpiece coordinate system W to the tool coordinate system T is assumed to be... Then there is By simultaneously solving the homogeneous coordinate transformation matrices, the spatial error geometric relationship model can be obtained, namely: 。 6. The method for calculating the spatial position of a CNC machine tool based on BP neural network correction as described in claim 1, characterized in that, In step S2, the spatial error measurement trajectory is planned based on the basic coordinate system R, which plans nine measurement trajectory lines, including: taking three parallel straight lines with respect to the X-axis, namely... 、 and ;in: It intersects the Z-axis and Y-axis perpendicularly at the origin O; Perpendicular to and intersecting the Y-axis; Perpendicular to and intersecting the Z-axis; take three parallel lines with respect to the Z-axis, namely... 、 and ;in: and The origin O is perpendicular to the Y-axis; and It intersects the Y-axis perpendicularly at one point; respectively with and Perpendicular and intersecting; take three parallel lines with respect to the Y-axis, namely... 、 and ;in: and and They intersect perpendicularly at the origin O; respectively with and Perpendicular and intersecting; and and They intersect perpendicularly at one point.

7. The method for calculating the spatial position of a CNC machine tool based on BP neural network correction as described in claim 6, characterized in that, In step S2, the measurement points are set up by taking points at intervals along the measurement trajectory line, with a custom spacing between the points to ensure that there are at least 5 measurement points per meter.

8. The method for calculating the spatial position of a CNC machine tool based on BP neural network correction as described in claim 1, characterized in that, In step S3, the original measured location dataset is obtained. The process includes the following steps: S31, using a laser measuring device to detect the position coordinate data of each measurement point on the spatial error measurement trajectory; S32, based on the error normal distribution verification method, statistically analyzing the errors of the position coordinate data of each measurement point in the X-axis, Y-axis and Z-axis directions of the basic coordinate system R to determine whether they conform to a normal distribution; if yes, proceed to step S33; if no, return to step S31; S33, perform linear normalization processing on the position coordinate data of each measurement point; S34, randomly divide the processed position coordinate data into two groups to obtain a training set and a validation set, which together constitute the original measured position dataset.

9. The method for calculating the spatial position of a CNC machine tool based on BP neural network correction as described in claim 8, characterized in that, In step S34, the ratio of the amount of data in the training set to the amount of data in the validation set is 3:

1.

10. The method for calculating the spatial position of a CNC machine tool based on BP neural network correction as described in claim 5, characterized in that, In step S4, spatial error identification includes: obtaining the perpendicularity error of the CNC machine tool based on the position coordinate data of the measurement points in the original measured position dataset, combined with the spatial least squares fitting method, including: the perpendicularity error between the X-axis and Y-axis in the basic coordinate system R. Perpendicularity error between the X-axis and Z-axis in the basic coordinate system R Perpendicularity error between the Y-axis and Z-axis in the basic coordinate system R Based on the nine-line method, 18 errors corresponding to the X-axis, Y-axis and Z-axis in the basic coordinate system R are obtained, including: 3 tilt errors, 3 pitch errors, 3 yaw errors, 3 positioning errors and 6 straightness errors.

11. The method for calculating the spatial position of a CNC machine tool based on BP neural network correction as described in claim 10, characterized in that, In step S5, during the process of obtaining the machine tool space error model, model preprocessing is first performed. The steps include: S51, determining the error vector parameters in the spatial error geometric relationship model, that is, the error vectors generated by the tool tip in the X, Y, and Z directions of the basic coordinate system R during the operation of the CNC machine tool. 、 and ;in: ; ; S52, based on the perpendicularity error of the CNC machine tool, the error vector in the spatial error geometric relationship model is preprocessed to remove the influence of perpendicularity error on positioning accuracy, that is: ; ; ; This represents the error vector corresponding to the X-axis direction after preprocessing. This represents the error vector corresponding to the Y-axis direction after preprocessing. This represents the error vector corresponding to the Z-axis direction after preprocessing.

12. The method for calculating the spatial position of a CNC machine tool based on BP neural network correction as described in claim 8, characterized in that, In step S7, the BP neural network training includes the following steps: S71, inputting the training set from the theoretical position coordinate dataset, the error calculation coordinate dataset, and the original measured position dataset into the BP neural network for BP neural network training; S72, determining whether the preset number of iterations or the preset termination accuracy requirement is met; if yes, proceed to step S73; if no, after adjusting and optimizing the neural network structure, return to step S71; S73, inputting the validation set from the theoretical position coordinate dataset, the error calculation coordinate dataset, and the original measured position dataset into the BP neural network for neural network validation, obtaining the average deviation between the validation output parameter and the validation target value; S74, determining whether the average deviation meets the preset requirement; if no, after adjusting and optimizing the neural network structure, return to step S71; if yes, obtain the neural network correction model.

13. The method for calculating the spatial position of a CNC machine tool based on BP neural network correction as described in claim 12, characterized in that, In step S72, determining whether the preset termination accuracy requirement is met includes the following steps: S721, obtaining the corresponding position coordinate data from the verification set in the theoretical position coordinate dataset, the error calculation coordinate dataset, and the original measured position dataset, inputting it into the BP neural network, and obtaining the deviation value between the verification output parameter and the verification target value; S722, determining whether the deviation value is less than 0.0001; if yes, it is determined that the preset termination accuracy requirement is met; if no, it is determined that the preset termination accuracy requirement is not met.

14. The method for calculating the spatial position of a CNC machine tool based on BP neural network correction as described in claim 12, characterized in that, In step S74, the preset requirement for the mean deviation is less than 0.0001.

15. The method for calculating the spatial position of a CNC machine tool based on BP neural network correction as described in claim 1, characterized in that, In step S8, obtaining the actual position coordinate data includes the following steps: S81, obtaining the theoretical position coordinate data of any point M in the CNC machine tool space; S82, inputting the theoretical position coordinate data into the machine tool space error model to obtain error calculation coordinate data; S83, inputting the theoretical position coordinate data and error calculation coordinate data of point M into the neural network correction model to obtain the actual coordinate value of point M.

Citation Information

Cited By

  • An error compensation method for grating interferometer measurements

    CN122329129A