A method for calculating profile error of a numerically controlled machining apparatus
By combining Newton's iteration method and the bisection method to calculate contour error, the real-time and accuracy problems of contour error calculation in CNC machining are solved, achieving efficient and reliable contour error calculation, which is suitable for high curvature trajectories.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- JIANGNAN UNIV
- Filing Date
- 2025-11-12
- Publication Date
- 2026-06-23
AI Technical Summary
Existing technologies for calculating contour errors in CNC machining suffer from high costs, poor real-time performance, and low accuracy. In particular, the calculation accuracy deteriorates at high curvature trajectories, failing to meet the demands of high-end precision machining.
A method combining Newton's iteration method and the bisection method is adopted. The minimum value of the contour error evaluation function is determined by using the gradient descent method. By dynamically switching between Newton's iteration method and the bisection method, the target time point is updated iteratively within the potential time interval, and the contour error is calculated quickly and accurately.
It achieves high-precision, real-time calculation of contour errors, improves the reliability and robustness of calculation results, is suitable for high curvature trajectories, and provides a foundation for efficient precision control.
Smart Images

Figure CN121165618B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of CNC machining technology, and in particular to a method for calculating the contour error of CNC machining equipment. Background Technology
[0002] With the continuous development of the manufacturing industry, the new generation of CNC machining equipment requires performance indicators such as high precision, high efficiency, and high reliability. Given the current state of the CNC machining industry, how to effectively improve the precision and efficiency in the CNC machining process is a pressing issue that needs to be addressed in the field of machining technology.
[0003] Contour error is a core indicator for evaluating contour machining quality. It is defined as the shortest distance from the actual tool position near the desired point to the ideal contour trajectory. Contour tracking, as a crucial technical step in precision machining, significantly impacts machining accuracy and efficiency. Contour error estimation is a key engineering technology for ensuring high precision, aiming to accurately and quickly estimate contour errors to provide a good foundation for subsequent contour error compensation. The accuracy and speed of contour error calculation have a significant impact on the overall precision and efficiency of CNC machining operations and are prerequisites for achieving high-precision motion control of CNC machining equipment. Existing methods for obtaining contour errors are mainly divided into the following three categories:
[0004] 1. Contour Error Measurement Method: This method measures the contour error at the end of the tool by installing measuring devices such as laser interferometers, ballbars, coordinate measuring machines, vision cameras, or theodolites. This method is costly, and the measuring instruments have stringent requirements for the measurement environment and space. Furthermore, it cannot perform real-time measurements and is not suitable for continuous machining scenarios in automated CNC fields.
[0005] 2. Approximate estimation methods: such as the Task Coordinate System (TCF) method and the approximate circle estimation method, which project the error onto the normal direction through geometric approximation. This method is simple to calculate, but it can only meet the accuracy requirements at places with small curvature. At high curvature trajectories or inflection points, the accuracy estimation will deteriorate, resulting in significant errors, and it cannot meet the needs of high-end precision machining.
[0006] 3. Precise Calculation Method: This method primarily relies on numerical optimization techniques such as Newton's iteration method to solve for the shortest distance from a point to a curve. Theoretically, this method offers high accuracy. However, because Newton's iteration method is sensitive to initial values and has poor adaptability to non-convex curves, it can diverge or converge to undesirable local nearest points. This affects the stability and reliability of the contour error calculation, hindering its widespread adoption and application in practical machining environments. Summary of the Invention
[0007] This application addresses the aforementioned problems and technical requirements by proposing a method for calculating the contour error of CNC machining equipment. The technical solution of this application is as follows:
[0008] A method for calculating contour error in CNC machining equipment, the method comprising:
[0009] For the desired trajectory curve Any of the above Expected location points Determine the actual processing trajectory and the first The nearest actual location point to the desired location point ;in, Indicates a point in time and The expected trajectory curve at any time point The corresponding coordinates are , For the first The time points corresponding to the expected location points;
[0010] Given the initial values of Newton's iteration method The contour error evaluation function is determined using the gradient descent method. The potential time interval corresponding to the minimum value Among them, the contour error evaluation function Used to measure actual location points at any time point on the expected trajectory curve Corresponding coordinates The distance between them , , ;
[0011] Initialize target time point Based on the contour error evaluation function At the target time point Second derivative at The value of the variable is dynamically switched between Newton's iteration method and the bisection method to cover the potential time interval. Internal iterative update determines the target time point ;
[0012] Calculate the actual location point and the expected trajectory curve at the target time point Corresponding contour error points The deviation between them is used as the actual position point Contour error at the location.
[0013] Its further technical solution is, within the potential time interval Internal iterative update determines the target time point include:
[0014] In the potential time interval Within the range according to The value of the target time point is dynamically switched between Newton's iteration method and the binary search method. ;
[0015] Utilize the updated target time point Update potential time intervals And based on the updated target time point and potential time interval Continue iterating until the iteration termination condition is met to obtain the target time point. .
[0016] Its further technical solution is, according to The value of the target time point is dynamically switched between Newton's iteration method and the binary search method. include:
[0017] when Then, the reference time is calculated using Newton's iterative method. When reference time In the potential time interval When within the range, refer to the time. As the updated target time point ; when reference time Exceeding the potential time interval When the range is defined, the updated target time point is obtained using the binary search method. ;
[0018] when Then, the updated target time point is obtained using the binary search method. .
[0019] A further technical solution involves using a binary search method to obtain the updated target time point. include:
[0020] when At that time, according to Update target time point Otherwise, according to Update target time point .
[0021] Its further technical solution is to utilize the updated target time point. Update potential time intervals include:
[0022] Calculate the profile error evaluation function Updated target time point The first derivative at According to the first derivative The value of will determine the left boundary of the potential time interval. or right boundary Corrected to the updated target time point .
[0023] Its further technical solution is based on the first derivative. The value of will determine the left boundary of the potential time interval. or right boundary Corrected to the updated target time point include:
[0024] When the contour error evaluation function Updated target time point The first derivative at At that time, the left boundary of the potential time interval will be... Corrected to the updated target time point Otherwise, the right boundary of the potential time interval will be... Corrected to the updated target time point .
[0025] Its further technical solution is to determine the potential time interval. include:
[0026] Calculate the profile error evaluation function In the initial value The first derivative at ;
[0027] when At that time, As the left boundary of the potential time interval The value of, and in Determine the right boundary of the potential time interval within the range. The value of ;
[0028] when At that time, As the right boundary of the potential time interval The value of, and in Determine the left boundary of the potential time interval within the range. The value of .
[0029] Its further technical solution is to determine the potential time interval. Also includes:
[0030] exist At that time, initialize the reference boundary. ,when Directly As the right boundary of the potential time interval The value of ; when At that time, calculate the contour error evaluation function. At the reference boundary The first derivative at ,when When As the right boundary of the potential time interval The value of , when season And continue iterating;
[0031] exist At that time, initialize the reference boundary. ,when When 0 is directly used as the left boundary of the potential time interval, The value of ; when At that time, calculate the contour error evaluation function. At the reference boundary The first derivative at ,when When As the left boundary of the potential time interval The value of , when season And continue iterating;
[0032] in, It updates the step size.
[0033] Its further technical solution is, within the potential time interval Internal iterative update determines the target time point Also includes:
[0034] Target time points before and after the update The error is less than the convergence error. When the iteration count reaches the maximum number of iterations, the iteration termination condition is determined and the target time point is obtained. .
[0035] Its further technical solution is a contour error evaluation function. .
[0036] The beneficial technical effects of this application are:
[0037] This application discloses a method for calculating contour errors in CNC machining equipment. This method uses the time point corresponding to the desired position as the initial value for the Newton-Raphson iteration method. After determining the potential time interval containing the time point corresponding to the minimum value of the contour error evaluation function using the gradient descent method, it dynamically switches between the Newton-Raphson iteration method and the bisection method within this potential time interval to accurately solve for the target time point. This allows for rapid and reliable convergence to the local optimum closest to the desired position. This method combines the speed of the Newton-Raphson iteration method with the stability of the bisection method, improving the reliability and robustness of the contour error calculation results. It provides a highly efficient and stable computational foundation for subsequent contour accuracy control and real-time compensation. This method can achieve high-precision, real-time calculation of contour errors, with accuracy far exceeding that of approximation methods, and can reliably handle high-curvature trajectories. Attached Figure Description
[0038] Figure 1 This is a flowchart of a contour error calculation method in one embodiment of this application.
[0039] Figure 2 This is a schematic diagram illustrating the actual location point and contour error point corresponding to the desired location point in an example.
[0040] Figure 3 This is a flowchart of a method for determining a potential time interval in one embodiment of this application.
[0041] Figure 4 This is a flowchart of a method for targeting a specific time point in one embodiment of this application.
[0042] Figure 5 It is the expected trajectory curve in an instance.
[0043] Figure 6 It is calculated using the contour error calculation method of this application. Figure 5 The diagram shows a magnified view of the contour error of the desired trajectory curve at a local region 510.
[0044] Figure 7 It is calculated using the contour error calculation method of this application. Figure 5 The diagram shows a magnified view of the contour error of the desired trajectory curve at a local region of 520.
[0045] Figure 8 It is calculated using the contour error calculation method of this application. Figure 5 The actual position points corresponding to each expected position point on the expected trajectory curve and the corresponding contour error points are shown in the figure. Directional deviation.
[0046] Figure 9 It is calculated using the contour error calculation method of this application. Figure 5The actual position points corresponding to each expected position point on the expected trajectory curve and the corresponding contour error points are shown in the figure. Directional deviation. Detailed Implementation
[0047] The specific embodiments of this application will be further described below with reference to the accompanying drawings.
[0048] This application discloses a method for calculating the contour error of CNC machining equipment. The method includes the following steps, please refer to... Figure 1 The flowchart shown illustrates a predefined planar coordinate system for ease of location description. Any location can be determined using its coordinates within this planar coordinate system. To express.
[0049] Step 110: Obtain the desired trajectory curve of the CNC machining equipment during machining. and the desired trajectory curve Discretization is performed to obtain multiple desired location points.
[0050] CNC machining equipment needs to process sequentially according to the desired trajectory curve during machining; therefore, the desired trajectory curve... The positions on the screen are all related to the time points. Correlation, on the expected trajectory curve at any time point The corresponding position coordinates are: Time point The range of values is That is, the expected trajectory curve The time series interval is .
[0051] The continuous expected trajectory curve Discretize into multiple desired location points, each of which represents a desired trajectory curve. The position corresponding to the previous time point is denoted as any number in the processing order. The expected location point corresponds to the time point Then the first The position of each desired location point can be denoted as... Please refer to Figure 2 (a) in the middle.
[0052] Step 120: Iterate through each desired location point in sequence. For any point reached during the iteration... Expected location points Determine the actual processing trajectory and the first Expected location points nearest actual location point The actual location point is the first one. Expected location points Please refer to the corresponding actual location point. Figure 2 As shown in (b) of the diagram.
[0053] Step 130, Define the contour error evaluation function The contour error evaluation function Used to measure actual location points at any time point on the expected trajectory curve Corresponding coordinates The distance between them. This is to be calculated later. first derivative and second derivative To reduce computational load and speed up calculations, one embodiment does not directly use Euclidean distance to define the distance. Instead, it takes the contour error evaluation function. .
[0054] Step 140: Given the initial values for Newton's iteration method. That is, directly using the first Expected location points corresponding time point As initial values.
[0055] Step 150: Determine the profile error evaluation function using the gradient descent method. The potential time interval corresponding to the minimum value .
[0056] and These are two variable parameters representing points in time. and These correspond to two different positions on the desired trajectory curve, therefore the time points... and It is also within the time series interval of the expected trajectory curve, that is... .
[0057] and The specific value is determined by the gradient descent method to satisfy the contour error evaluation function. At the point of time The first derivative at And the contour error evaluation function At the point of time The first derivative at Requirements.
[0058] Please refer to Figure 3 The flowchart shown identifies the potential time intervals. The method includes the following steps:
[0059] (1) First, calculate the profile error evaluation function. Initial values for Newton's iteration method The first derivative at Then determine whether it satisfies .
[0060] (2) When At that time, As the left boundary of the potential time interval The value of, and in Determine the right boundary of the potential time interval within the range. The possible values are: Specifically:
[0061] Initialize reference boundary , here It updates the step size, which can be customized. Generally, a smaller value is chosen, for example, 100%. Then first determine whether it satisfies the condition. .
[0062] when When, it means The time series interval has been reached or exceeded. At this time, And As the right boundary of the potential time interval The value of , that is, directly taking As the right boundary of the potential time interval The value of is used to obtain the potential time interval. .
[0063] when When, it means Still in the time series interval Within the range, the contour error evaluation function is further calculated. At the reference boundary The first derivative at .when At this moment As the right boundary of the potential time interval The value of the potential time interval is obtained. .when season And continue iterating, that is, continue to judge the updated... Does it meet the requirements? And repeat the above process.
[0064] (3) When At that time, As the right boundary of the potential time interval The value of, and in Determine the left boundary of the potential time interval within the range. The possible values are: Specifically:
[0065] Initialize reference boundary Then determine whether it satisfies .
[0066] when Time indicates The time series interval has been reached or exceeded. At this time, And As the left boundary of the potential time interval The value of is taken as 0, which is directly used as the left boundary of the potential time interval. The value of is used to obtain the potential time interval. .
[0067] when When, it means Still in the time series interval Within the range, the contour error evaluation function is further calculated. At the reference boundary The first derivative at .when When As the left boundary of the potential time interval The value of the potential time interval is obtained. .when season And continue iterating, that is, continue to judge the updated... Does it meet the requirements? And repeat the above process.
[0068] For example in Figure 2 In the example, the potential time intervals are determined. , representing the contour error evaluation function The minimum value lies on the expected trajectory curve at time point. Corresponding position With the Expected location points On the line segment between, such as Figure 2 As shown in (c) in the figure.
[0069] Step 160, Initialize the target time point Based on the contour error evaluation function At the target time point Second derivative at The value of the variable is dynamically switched between Newton's iteration method and the bisection method to cover the potential time interval. Internal iterative update determines the target time point .
[0070] The objective of this application is to find the curve on the desired trajectory that corresponds to the first... Using the nearest local optimum to the desired location point as the contour error point, this approach of finding local optima is more engineering-effective than finding global optima. Therefore, the target time point is initialized... From the first The search begins at the desired location.
[0071] Newton's iteration method has good computational speed, but poor adaptability to non-convex curves. Therefore, this application combines Newton's iteration method and the bisection method to combine the computational speed of Newton's iteration method with the stability of the bisection method to determine the target time point. Please refer to the following process. Figure 4 The flowchart shown below:
[0072] 1. First, within the potential time interval Within the range according to The value of the target time point is dynamically switched between Newton's iteration method and the binary search method. Specifically:
[0073] (1) First, determine the contour error evaluation function. At the current target time point Second derivative at Does it meet the requirements? .
[0074] (2) When If the conditions for Newton's method are met, then the reference time can be calculated using Newton's method. .
[0075] When reference time In the potential time interval When within the range, refer to the time. As the updated target time point .
[0076] When reference time Exceeding the potential time interval When defining a range, reference time cannot be used. Then, the updated target time point is obtained again using the binary search method. Specifically:
[0077] Calculate the profile error evaluation function At the current target time point The first derivative at ,when At that time, according to Update target time point Otherwise, according to Update target time point .
[0078] (3) When If the conditions for Newton's iteration method are not met, then the updated target time point can be obtained directly using the bisection method. The specific procedures are the same as those described above, and will not be repeated here.
[0079] 2. Regardless of which of the above methods is used to update the target time point. After obtaining the updated target time point Next, it is first determined whether the iteration termination condition has been met. This iteration termination condition is custom-set; in one embodiment, it is based on the target time point. The convergence of the loop is used as the termination condition for the iteration, and a maximum number of iterations is set to avoid the inability to exit the loop.
[0080] Therefore, the first step is to detect the target time points before and after the update. Is the error less than the convergence error? At that time, convergence error It is a custom value set according to precision requirements, such as taking a value in an instance. When the target time points before and after the update The error is less than the convergence error. Time indicates the target time point The iteration has converged. We have determined that the current iteration has reached the termination condition and are outputting the target time point. Proceed to step 170.
[0081] And when the target time points before and after the update The error is not yet less than the convergence error. "Time" indicates the target time point. If convergence has not yet occurred, further determine whether the maximum number of iterations has been reached. If the maximum number of iterations is reached, determine that the iteration termination condition has been met and output the target time point. Proceed to step 170.
[0082] 3. At the target time point If the iteration fails to converge and the maximum number of iterations has not been reached, it is determined that the iteration termination condition has not been met, and the updated target time point is used. Update potential time intervals ,include:
[0083] Calculate the profile error evaluation function Updated target time point The first derivative at Then, based on the first derivative The value of will determine the left boundary of the potential time interval. or right boundary Corrected to the updated target time point Specifically:
[0084] When the contour error evaluation function Updated target time point The first derivative at At that time, the left boundary of the potential time interval will be... Corrected to the updated target time point Otherwise, the right boundary of the potential time interval will be... Corrected to the updated target time point .
[0085] Then based on the updated target time point and potential time interval Continue iterating within the potential time interval after the current update. Within the range based on the current The value is dynamically switched between Newton's iteration method and the binary search method to update the target time point again. This continues until the iteration terminates when the condition is met.
[0086] Step 170, calculate the actual location point and the expected trajectory curve at the target time point Corresponding contour error points The deviation between them is used as the actual position point The contour error at a given location can be calculated, including deviations from the actual position point. With contour error points exist direction and Coordinate deviation in direction, and actual location point With contour error points Euclidean distance between them, such as Figure 2 As shown in example (d).
[0087] By continuing to traverse other desired position points on the desired trajectory curve and through the above steps 120~170, the contour error at each actual position point can be obtained respectively.
[0088] In one example, experimental verification was conducted on an XY platform composed of ball screw modules. Both motors used GSHD-0032AGL2-LTLM drivers, connected to a GSN-024-LT-01 control card via a Glink-II bus. The control card was inserted into the host PCI-e slot. Secondary development was performed using Visual Studio to implement the method provided in this application on the host computer. Position data feedback was obtained through the Tamagawa protocol absolute encoder integrated into the servo motors. The control card acquired the encoder data with a sampling period of 250µs. The desired trajectory curve is as follows... Figure 5 Taking the heart-shaped trajectory shown as an example, considering the smoothness of the motion, the desired trajectory curve is designed in the form of a cubic spline curve, and its trajectory equation is:
[0089]
[0090] Considering the spatial limitations of the XY dual-axis platform, the amplitude is selected. The maximum value of the time series interval , It represents seconds.
[0091] Discretizing the above desired trajectory curve yields 1000 elements. For the desired position points, the desired position point data is input into the motion control card, and data acquisition begins. After the XY dual-axis platform completes its motion, the acquired encoder data from the two motors is saved to an array. Each desired position point is iterated sequentially. For any desired position point encountered, a traversal method is used to find the nearest data point and its location in the data array, i.e., to find the actual position point corresponding to the first desired position point. Since the time interval between two adjacent desired position points is T / 1000 = 2ms = 2000us, and the sampling period of the control card is 250us, the actual position point corresponding to each desired position point can be obtained from the sampled data.
[0092] Pick , The maximum number of iterations is 20, and the contour error is calculated according to the method of this application. Figure 5 A magnified view of the contour error of the expected trajectory curve at point 510 (dashed box) is shown below. Figure 6 As shown, Figure 5 A magnified view of the contour error of the expected trajectory curve at point 520 (dashed box) is shown below. Figure 7 As shown, in Figure 6 and Figure 7In the diagram, the blue trajectory represents the desired trajectory curve, and the black trajectory represents the actual machining trajectory curve. Blue dots represent desired position points, and purple dots near each desired position point are contour error points at the corresponding actual position point. The red line segments represent the distances between the actual position points corresponding to the desired position points and their corresponding contour error points. The actual position points and corresponding contour error points for each desired position point, arranged sequentially on the desired trajectory curve according to the machining order, are located at... directional deviation such as Figure 8 As shown, in directional deviation such as Figure 9 As shown. By Figures 6-9 It can be seen that the contour error calculated according to the method of this application meets the requirements and can still maintain good results at large curvature, providing a good premise for subsequent contour error compensation.
[0093] The above descriptions are merely preferred embodiments of this application, and this application is not limited to the above embodiments. It is understood that other improvements and variations that can be directly derived or conceived by those skilled in the art without departing from the spirit and concept of this application should be considered to be included within the protection scope of this application.
Claims
1. A method for calculating the contour error of CNC machining equipment, characterized in that, The contour error calculation method includes: For the desired trajectory curve Any of the above Expected location points Determine the actual processing trajectory and the first The nearest actual location point to the desired location point ;in, Indicates a point in time and The expected trajectory curve at any time point The corresponding coordinates are , For the first The time point corresponding to each expected location point Represents the maximum value within a time series interval; Given the initial values of Newton's iteration method The contour error evaluation function is determined using the gradient descent method. The potential time interval corresponding to the minimum value Among them, the contour error evaluation function Used to measure actual location points at any time point on the expected trajectory curve Corresponding coordinates The distance between them , , ; Initialize target time point When the contour error evaluation function At the target time point Second derivative at Then, the reference time is calculated using Newton's iterative method. When reference time In the potential time interval When within the range, refer to the time. As the updated target time point ; when reference time Exceeding the potential time interval When the range is defined, the updated target time point is obtained using the binary search method. ;when The updated target time point is obtained using the binary search method. ; Utilize the updated target time point Update potential time intervals And based on the updated target time point and potential time interval Continue iterating until the iteration termination condition is met to obtain the target time point. ; Calculate the actual location point and the expected trajectory curve at the target time point Corresponding contour error points The deviation between them is used as the actual position point Contour error at the location.
2. The contour error calculation method according to claim 1, characterized in that, The updated target time point is obtained using the binary search method. include: when At that time, according to Update target time point Otherwise, according to Update target time point .
3. The contour error calculation method according to claim 1, characterized in that, Utilize the updated target time point Update potential time intervals include: Calculate the profile error evaluation function Updated target time point The first derivative at According to the first derivative The value of will determine the left boundary of the potential time interval. or right boundary Corrected to the updated target time point .
4. The contour error calculation method according to claim 3, characterized in that, According to the first derivative The value of will determine the left boundary of the potential time interval. or right boundary Corrected to the updated target time point include: When the contour error evaluation function Updated target time point The first derivative at At that time, the left boundary of the potential time interval will be... Corrected to the updated target time point Otherwise, the right boundary of the potential time interval will be... Corrected to the updated target time point .
5. The contour error calculation method according to claim 1, characterized in that, Determine the potential time interval include: Calculate the profile error evaluation function In the initial value The first derivative at ; when At that time, As the left boundary of the potential time interval The value of, and in Determine the right boundary of the potential time interval within the range. The value of ; when At that time, As the right boundary of the potential time interval The value of, and in Determine the left boundary of the potential time interval within the range. The value of .
6. The contour error calculation method according to claim 5, characterized in that, Determine the potential time interval Also includes: exist At that time, the initial time point ,when Directly As the right boundary of the potential time interval The value of ; when At that time, calculate the contour error evaluation function. At the point of time The first derivative at ,when When As the right boundary of the potential time interval The value of , when season And continue iterating; exist At that time, the initial time point ,when When 0 is directly used as the left boundary of the potential time interval, The value of ; when At that time, calculate the contour error evaluation function. At the point of time The first derivative at ,when When As the left boundary of the potential time interval The value of , when season And continue iterating; in, It updates the step size.
7. The contour error calculation method according to claim 1, characterized in that, In the potential time interval Internal iterative update determines the target time point Also includes: Target time points before and after the update The error is less than the convergence error. When the iteration count reaches the maximum number of iterations, the iteration termination condition is determined and the target time point is obtained. .
8. The contour error calculation method according to claim 1, characterized in that, Contour error evaluation function .