A CNC Direct Interpolation Algorithm Based On NURB
A CNC Direct Interpolation Algorithm Based On NURB
Research Article
DOI: https://doi.org/10.21203/rs.3.rs-1378144/v1
License: This work is licensed under a Creative Commons Attribution 4.0 International License.
Read Full License
Title Page
Title: A CNC Direct Interpolation Algorithm based on NURBS and its Error Analysis
Authors:
1. WEI Shengli, School of Computer Science and Information Engineering, Anyang Institute of
Technology, Anyang, Henan Province, China. Zip code: 455000, E-mail:
[email protected]. Corresponding author.
2. ZHAO Kai, School of Computer Science and Information Engineering, Anyang Institute of
Technology, Anyang, Henan Province, China. Zip code: 455000
Abstract: For free-form surfaces or curves, it is not the best choice to use traditional G01 or G02
interpolation to generate the reference motion trajectory. Direct interpolation method is a better
choice. Direct interpolation is more useful in a free-curve/surface dedicated Computer Numerical
Control (CNC) system. A free-curve/surface dedicated CNC system just needs curve/surface
information as input, not as a conventional CNC system uses G code as its input. NURBS (Non-
Uniform Rational B-spline) is a powerful expression method for free-form curves and surfaces, and
so a direct interpolation algorithm based on NURBS curves is studied. In order to realize high speed,
high accuracy and stable interpolation, an adaptive prediction-correction with constraint chord
error method is presented to define the NURBS curve parameter. S velocity planning is used to make
tool move more smoothly. As NURBS curves are piece-wise curves, NURBS direct interpolation
must be computed with the parameter within its corresponding sections, and a section transition
method is proposed to guarantee computing validity. Also, three reference trajectory generation
methods, i.e. position interpolation, velocity interpolation and acceleration interpolation are
presented, and their advantages and disadvantages are discussed. The calculation and simulation
show that the position interpolation method is more stable and the error is the smallest. The error of
velocity interpolation is about 4 times that of position interpolation.
sharp corner
corner smoothing
B i ,k (u )Wi Vi
P (u ) i 0
n
B
i 0
i ,k (u )Wi
Where Vi is the control point vertex matrix, Wi is the weight factor vector, and Bi ,k (u) is the
NURBS curve.
Let
i n
(3)
M(u)
VW B
i 0
i i i ,k (u )
N (u )
i n
(4)
W B
i 0
i i,k (u )
B i ,k (u )Wi Vi
M (u ) (5)
P(u ) i 0
n
B
N (u )
i ,k (u )Wi
i 0
i n
(u ) and N (u) can be calculated with deboor-Cox algorithm.
i n
M(u ) VW B
i 0
i i i ,k W B
i 0
i i ,k (u )
u i 1 u i u (8)
Where u is a constant. However, this method is completely based on parameter control and
does not contain step control information. Uniform increase of u cannot ensure consistent step
length, which will cause speed change, and is not conducive to maintaining the stability of
interpolation. In machining process, we hope to keep step length other than u invariant. Many
literatures use a consistent step length method which is guaranteed by the Taylor expansion method.
In practical application, the first-order or second-order Taylor expansion can be used to determine
parameter u according to the accuracy requirements, as shown in the following formula.
Where, u i and u i 1 respectively represent the current value and the next required value of
order derivatives, o(T ) and o (T 2 ) represent the first-order and second-order infinitesimal.
To convert the above formula to parameter space, there are
l (11)
u i 1 u i '
P (u )
u i 1 u i
l
l 2 P ' (u )P '' (u ) (12)
'
P (u ) ' 4
2 P (u )
Where l is the step length of interpolation, P ' (u ) and P '' (u ) are the first and second
derivatives of the NURBS curve in the parameter space. Usually l is predetermined before
machining according to the required global machining speed. As long as the chord error satisfies the
required accuracy, we hope step length keep invariant all the time.
To keep step length consistent by control NURBS curve parameter u is very difficult. Using
formula 11 and 12 reverse computing u i 1 exists truncation error. And more seriously, truncation
error will accumulate step by step. An improved method is the prediction-correction method.
Literatures [10-11] discuss this method, but they don’t take section transition and velocity planning
into consideration. The prediction-correction method first uses the Taylor expansion to predict the
value of u , and the predicted step length is calculated with the predicted value of u .
lˆ Pˆ i 1 P i (13)
Use formula 14 to verify the predicted step length. If the predicted step length satisfies
requirement (say δ < 0.1%), the predicted value of u and the predicted step length are adopted.
Otherwise, correct u according to formula 15.
|𝑙−𝑙̂|
δ= ∗ 100% (14)
𝑙
lˆ lˆ (15)
u i 1 uˆ i 1 (1 )u i
l l
2.3 Adaptive Prediction-correction with Constraint Chord Error Method
Prediction-correction method can ensure step length consistent, but it does nothing with chord
error control. If the curvature is large, still using initiative step length will result in excessive chord
error which will deteriorate machining accuracy. So, an adaptive prediction-correction with
constraint chord error method is presented to ensure machining accuracy. In each interpolation cycle,
firstly, formula 16 is used to verify if the chord error satisfies accuracy requirement [12].
𝑙2
ε=
8𝜌
(16)
Where ε is the chord error when step length is l , and 𝜌 is the smaller of curvature radius and
torsion radius. If ε satisfies accuracy requirement, l is OK to be used as step length. Otherwise,
re-compute l according the acceptable chord error which will be set up before machining. Fig. 3
shows how the adaptive prediction-correction with constraint chord error method control step
length and chord error. Fig. 3(a) shows that step length will decrease where the curve change
dramatically, and Fig. 3(b) shows that the chord error is controlled under 0.01 by decreasing step
length where the curve change dramatically.
In this stage, the acceleration will reach its maximum, amax . The maximum acceleration can
be set in advance to satisfy the dynamics requirement. In the second stage, we have:
a a max (20)
In this stage, acceleration a remains invariant. v01 and s01 is the velocity and
replacement individually at the end of the first stage. In the last stage, there are:
a a max Kt (23)
Generally, interpolation cycle is a fixed period of time, for example 50μs. In this situation,
velocity is proportional to step length l . There are:
𝑙 = v ∗T (26)
Where T is the interpolation cycle. Velocity planning equals to step length planning. So, S
velocity planning is realized by the control of the step length l . If step length l is set according to
the law stipulated by formula 18, 21, 24, and the parameter u is determined just as presented in
part 2 of the paper, S velocity planning will be obtained. Fig. 4 shows velocity planning of a NURBS
curve trajectory. It is difficult to predict where to begin the deceleration process, especially chord
error is taken to consideration. This problem will be studied in the future research.
Fig. 4 S velocity planning of motion trajectory
3.2 Section Transition
Since a NURBS curve is a piecewise curve, its position and derivative must be calculated with
parameter u in the corresponding section. According to formula 1 and 2, it is easy to know that
𝐵𝑖,𝑘 (𝑢), Vi and 𝑊𝑖 vary in different sections. So, we must be careful, and know exactly which
section the parameter u belongs to. Because of the introduction of the adaptive prediction-
correction with constraint chord error method, this problem become more difficult which has not
been discussed in other literatures. Here, a section transition method is put forward, and the section
transition process is illustrated in Fig. 5. First, the step length l should be set, and it can come
from the global step length, or come from formula 16 to satisfy acceptable chord error, or come
from formula 26 to comply with velocity planning. Second, parameter u is predicted in accordance
with step length l according to formula 11 or 12. Then, predicted u is verified if it still belongs
to current section or it already enters next section. If it still belongs to current section, the position
and derivative are directly calculated in current section. If it enters next section, the position and
derivative must be calculated using next section expression, and set Flag to 1. Then, the predicted
step length can be computed with this point and the last point. If the difference between the predicted
step length and l is very small, for example, δ < 0.1% according to formula 14, correction is not
needed, and the predicted step length is used. Otherwise, parameter u is corrected according to
formula 15. Because the predicted parameter and the corrected parameter may be in different
sections, we must be careful in this situation. There are four combinations:
(1) Both the predicted and the corrected parameter are in current section, Flag=0;
(2) Both the predicted and the corrected parameter are in next section, Flag=1;
(3) The predicted parameter is in current section, the corrected one is in next section, Flag=0;
(4) The predicted parameter is in next section, the corrected one is in current section, Flag=1.
For combinations (2) and (4), Flag=1, because the predicted parameter enters next section, next
section becomes current section.
After the parameter is corrected, predicted step length must be re-computed according to one
of the four combinations.
Begin
Setting step
length
Predicting
parameter
Yes Is u in current No
section?
No
Correction needed?
Yes
Re-computing
parameter
Yes Flag=1? No
Is u in current No Is u in current No
section? section?
Yes Yes
Computing in Computing in Computing in Computing in
last section current section current section next section
Flag=0
end
xi 1 xi xi ' t (27)
(a) Step length 2.5mm (b) Step length 0.6mm (c) Step length 0.12mm
Fig. 6 Comparison of the three trajectories
In order to further illustrate the problem, a butterfly contour curve is used for simulation. The
results also show that when the interpolation step length is long, the trajectory generated by velocity
interpolation or acceleration interpolation will deviate from the contour curve, and when the
interpolation step length is short, three trajectories will coincide the contour curve, as shown in Fig.
7.
(a) Step length 0.6mm (b) Step length 0.12mm
Fig. 7 Comparison of three butterfly trajectories
3.3 Error Analysis
Three trajectory generation methods can all be used to generate reference motion trajectory,
and when the step length is short enough, trajectories generated by them will coincide together. But,
do they have the same error? Let’s deeply look into it. Position interpolation and velocity
interpolation are taken as example to compare their error. The error of position interpolation is
mainly chord error, which is l 8r 1 [12]. Where r is the radius of curvature, 1 is the chord
error, and l is the step length. It can be seen from Fig. 8 that the chord error is as follows:
2
1 r r 2
l (34)
2
Formula 34 can be rewritten as:
Then we have:
l2
1 (36)
8r
From Fig. 8, we also see the relationship between velocity interpolation error and step length,
that is:
l 2r 2 (37)
Rewrite formula 37 as 38.
l2
2
2r (38)
From formula 36 and 38, we know:
2 41 (39)
According to formula 36 and 38, the position interpolation error and velocity interpolation
error are directly proportional to the square of the step length. From formula 39, the velocity
interpolation error is 4 times that of the position interpolation.
Calculation results and simulation also prove that the velocity interpolation error is about 4
times the position interpolation error, which are shown in Fig. 9. In Fig. 9(a), “high” represents the
chord error, and “speeder” represents the velocity interpolation error. Fig. 9(b) shows that whatever
the step length is, the velocity interpolation error is about 4 times the position interpolation error.
Position
Interpolation Error
Velocity
Interpolation Error
Radius of
Curvature r
(a) Values of chord error and (b) Diagram of chord error and
velocity interpolation error velocity interpolation error
Fig. 9 Comparison of chord error and velocity interpolation error
5. Conclusion
Traditional CNC systems only receive G01 linear interpolation and G02 circular interpolation,
and a few advanced CNC systems support spline or NURBS interpolation. This is mainly caused by
historical reasons, because the traditional CNC machining mainly needs linear or circular motion.
CAM systems solves the incompatibility between CAD systems and CNC systems. The cooperation
of CAD, CAM and CNC can well complete the design and manufacturing problems in most cases.
However, for the machining of free-form surfaces or curves, it is not the best choice to continue to
use this method. The use of direct interpolation algorithm can bring faster, higher precision and
more stable machining. With rapid development of the computing capacity of CPU, it is not a
problem for the CNC system to undertake the function of direct interpolation. Developing a free-
curve/surface dedicated CNC system using direct interpolation algorithm only for machining free-
form curves and surfaces can become a choice.
A direct interpolation algorithm based on NURBS curves is elaborated in this paper. Adaptive
prediction-correction with constraint chord error method, S velocity planning, and section transition
method support the direct interpolation algorithm work well to provide high speed, high accuracy
and stable motion control. Three motion reference trajectory methods of position interpolation,
velocity interpolation and acceleration interpolation demonstrate that they can all generate
reference motion trajectory when the step length is short enough. Calculation results and simulation
shows that whatever the step length is, the velocity interpolation error is about 4 times the position
interpolation error. Position interpolation mainly produces chord error, but in the three trajectory
generation methods, it still has more stable performance and smaller error. However, only position
interpolation cannot give velocity and acceleration information. In CNC system, not only position
information, but also velocity and acceleration information are needed to achieve better results. In
direct interpolation, position interpolation is used to control position and accuracy, velocity and
acceleration interpolation is used for motion control, which can achieve greater accuracy and
smoother effect. In NURBS direct interpolation process, position, velocity and acceleration all
involve recursive iterative operations, and their calculations can be conveniently completed at the
same time.
In traditional CNC systems, most motion are linear motion and circular motion, but for the
machining of free-form curves and surfaces, the direct interpolation algorithm is more appropriate.
In this way, the CAM stage can be skipped over, which can not only improve the smoothness and
accuracy of machining, but also provide the possibility for the two-way flow of information, and
provide conditions for the introduction of intelligent manufacturing technologies such as digital
twins into CNC systems.
Reference
[1] Syh-Shiuh Yeh, Pau-Lo Hsu. Adaptive-Feedrate Interpolation for Parametric Curves with a
Confined Chord Error[J]. Computer-Aided Design, March 2002, Volume 34, Issue 3:229-237.
[2]Tsehaw Yong, Ranga Narayanaswami. A Parametric Interpolator with Confined Chord Errors,
Acceleration and Deceleration for NC Machining[J]. Computer-Aided Design, November 2003,
Volume 35, Issue 13:1249-1259.
[3] Burak Sencer, Kosuke Ishizaki, Eiji Shamoto. A curvature optimal sharp corner smoothing
algorithm for high-speed feed motion generation of NC systems along linear tool paths[J]. Int J Adv
Manuf Technol (2015) 76:1977–1992.
[4] Shingo Tajima, Burak Sencer, Eiji Shamoto. Accurate interpolation of machining tool-paths
based on FIR filtering[J]. Precision Engineering 52 (2018) 332–344.
[5] Shingo Tajima, Burak Sencer. Global tool-path smoothing for CNC machine tools with
uninterrupted acceleration[J]. International Journal of Machine Tools & Manufacture 121 (2017)
81–95.
[6] Li Dongdong, Zhang Liqiang, Yang Le Accurate interpolation algorithm of corner contour error
based on FIR filter[J]. Computer integrated manufacturing system, January 2021.
[7] Du Jinfeng, Zhang Liqiang, Gao Tian. Kinematic smoothing algorithm for high speed machining
of continuous short segments based on jump constraint [J]. Computer integrated manufacturing
system, September 2018.
[8] Liu Chunyan. Research on motion controller for open CNC[D]. Fuzhou, Fuzhou University,
2003
[9] Zhu Xinxiong. Free form curve and surface modeling technology[M]. Beijing: Science Press,
2000.
[10]Syh-Shiuh Yeh, Pau-Lo Hsu. Adaptive-Feedrate Interpolation for Parametric Curves with a
Confined Chord Error[J]. Computer-Aided Design, March 2002, Volume 34, Issue 3:229-237.
[11] You Youpeng, Wang Min, Zhu Jianying. Adaptive interpolation algorithm for parametric
curves[J]. Journal of Nanjing University of Aeronautics and Astronautics, December 2000: 667-671.
[12]Tianmiao Wang, Yunan Cao, Youdong Chen, etc. A new feedrate adaptation control NURBS
interpolation based on de Boor algorithm in CNC systems[J]. Proceedings of the American Control
Conference, July 2008. DOI: 10.1109/ACC.2008.4587131.
Statements and Declarations
Funding:
This work was supported by Key scientific research projects of colleges and universities in Henan
Province (Grant numbers [20B520001])
Competing Interests:
The authors have no relevant financial or non-financial interests to disclose.
Author Contributions:
Both authors contributed to the study conception and design. The manuscript was mainly written by
Shengli WEI. Both authors commented on previous versions of the manuscript. Both authors read
and approved the final manuscript.