Professional Documents
Culture Documents
248-255
Abstract: This paper presents an improved minimum error interpolation algorithm for general curves generation
in computer numerical control (CNC). Compared with the conventional interpolation algorithms such as the By-
Point Comparison method, the Minimum-Error method and the Digital Differential Analyzer (DDA) method,
the proposed improved Minimum-Error interpolation algorithm can find a balance between accuracy and
efficiency. The new algorithm is applicable for the curves of linear, circular, elliptical and parabolic. The
proposed algorithm is realized on a field programmable gate array (FPGA) with Verilog HDL language, and
simulated by the ModelSim software, and finally verified on a two-axis CNC lathe. The algorithm has the
following advantages: firstly, the maximum interpolation error is only half of the minimum step-size; and
secondly the computing time is only two clock cycles of the FPGA. Simulations and actual tests have proved
that the high accuracy and efficiency of the algorithm, which shows that it is highly suited for real-time
applications. Copyright © 2014 IFSA Publishing, S. L.
then this direction is selected. The maximum error is In Fig. 1, F is a deviation judgment formula,
just half of min-step size, but the method is too which is determined by the interpolation curve. Here
complex for MCU system. this formula can be simply understood as the
As to DDA method, each axis accumulates a coordinates of the point error of plus or minus.
value to a register and this value is related to current According to the positive or negative value of
coordinate position. When the accumulator register deviation judgment formula in the mid-point M and
value is bigger than a set value which we called N, we judge the mobile direction:
overflow, the corresponding axis output a pulse, the When F ( M ) ≤ 0 , point C ( xi , yi + 1) is closer to
accumulator register subtracts the set value and the the curve. So select the direction of Y-axis.
remainder is used for the next calculation. When
F (M ) > 0
calculate non-linear interpolation, DDA need to When , point A( xi + 1, yi + 1) is closer
change the accumulated value to current coordinate F ( N ) < 0
position, which makes unavoidable rounding error. to the curve. So select diagonal direction (both X-axis
In conclusion, because of the defect of low and Y-axis).
accuracy or low efficiency in By-Point Comparison, When F ( N ) ≥ 0 , point B ( xi + 1, yi ) is closer to
Min-Error and DDA, this paper proposed the the curve. So select the direction of X-axis.
Slightest Min-Error interpolation algorithm of linear, In every step the result of deviation judgment
circular, elliptical and parabolic for MCU system. formula needs to be recalculated, which is used to
Field programmable gate array (FPGA) is an determine the mobile direction of next coordinates.
advanced product on the basis of programmable
devices such as PAL \ GAL \ EPLD. Compared with
ASICs and PLDs, FPGA has the characteristics of
easy to be modified, low cost, short design cycle, etc.
3. Interpolation of General Curves
Compared with traditional MCUs, the FPGA has the
Next the new method was deduced to general
characteristics of real-time control, high speed,
curves, like line, circle, ellipse and parabola, which
reliability, parallelism. With these advantages, the
the most important is the deviation judgment
FPGA is quite suited for reconfigurable systems such
formula.
as computer numerical control (CNC) systems.
249
Sensors & Transducers, Vol. 170, Issue 5, May 2014, pp. 248-255
The deviation judgment formula: In the Fig. 3, the coordinate of different points
was as follows: P(xi, yi), A(xi+1, yi-1), B(xi, yi-1),
F = X e y − Ye x , (2) C(xi+1, yi), M(xi+1, yi-1/2) and N(xi+1/2, yi-1).
F (P) = Fi = X e yi − Ye xi , (3)
1
F ( M ) = X e ( yi + 1) − Ye ( xi + ) F (M ) > 0
2 F (N ) ≥ 0 F (M ) ≤ 0
1 (4) F (N ) < 0
= Fi + X e − Ye
2
Fig. 3. Circular interpolation schematic.
1
F ( N ) = X e ( yi + ) − Ye ( xi + 1)
2 3.2.2. Formula Derivation
(5)
1
= Fi + X e − Ye Circle equation is:
2
x2 + y 2 = R2 (10)
Combined with Fig. 2 and the theory of slightest
min-error, derive as follows:
When F(M)≤0, the point C(xi, yi+1) is closer to The deviation judgment formula is:
the curve. So the direction of Y-axis was selected.
And the value of deviation judgment formula was F = x2 + y 2 − R2 (11)
updated:
Substitute P , M and N into the formula:
Fi+1 = X e ( yi + 1) − Ye xi = Fi + X e (6)
F (P) = Fi = xi 2 + yi 2 − R 2 (12)
F (M ) > 0
When , the point A(xi+1, yi+1) is 1
F ( N ) < 0 F ( M ) = ( xi + 1) 2 + ( yi − ) 2 − R 2
2
closer to the curve. So the diagonal direction was (13)
5
selected. And the value of deviation judgment = Fi + 2 xi − yi +
formula was updated: 4
Fi+1 = X e ( yi + 1) − Ye ( xi + 1) 1
F ( N ) = ( xi + ) 2 + ( yi − 1) 2 − R 2
(7) 2
= Fi + X e − Ye (14)
5
= Fi + xi − 2 yi +
4
When F(N)≥0, the point B(xi+1, yi) is closer to the
curve. So the direction of X-axis is selected. And the Due to the value 5/4, which is not conductive for
value of deviation judgment formula was updated: calculation, multiply both sides of the equation with
the value 4.
Fi+1 = X e yi − Ye ( xi + 1) = Fi − Ye (8)
4 F ( M ) = 4 Fi + 8 xi − 4 yi + 5
(15)
Finally, because the start point is on the line,
obtain the initial value of deviation judgment
formula: 4 F ( N ) = 4 Fi + 4 xi − 8 yi + 5 (16)
250
Sensors & Transducers, Vol. 170, Issue 5, May 2014, pp. 248-255
Fi+1 = xi 2 + ( yi − 1) 2 − R 2 = Fi − 2 yi + 1 (19)
ti = a 2 yi 2
(27)
Finally, because the start point is on the circle,
obtain the initial value of deviation judgment
formula: 1
F (M ) = b2 ( xi + 1)2 + a2 ( yi − )2 − a2b2
2
F0 = 0 (20) 2 2 1 2 2
= Fi + 2b xi − a yi + a + b (28)
4
1
= Fi + 2si − ti + a2 + b2
3.3. Elliptical Interpolation 4
Fi+1 = b 2 ( xi + 1) 2 + a 2 yi 2 − a 2 b 2
F (M ) > 0 = Fi + 2b 2 xi + b 2 (30)
F (N ) ≥ 0 F (M ) ≤ 0
F (N ) < 0 = Fi + 2 si + b 2
251
Sensors & Transducers, Vol. 170, Issue 5, May 2014, pp. 248-255
si +1 = si + b 2 (33) 1
F ( M ) = ( yi + 1) 2 − 2 p( xi + )
2 (41)
ti +1 = ti − a 2 (34) = Fi + 2 yi − p + 1
Fig. 5. Parabola interpolation schematic. Finally, because the start point is on the Parabola,
obtain the initial value of deviation judgment
formula:
3.4.2. Formula Derivation
F0 = 0 (47)
Parabola equation:
y 2 = 2 px (38)
4. Software Simulation
The deviation judgment formula:
Slightest Min-Error interpolation algorithm is
2
F = y − 2 px realized based on FPGA hardware platform by
(39)
Verilog HDL. Here shows the simulation waveforms
in ModelSim software, which displays 4 kinds of
Substitute P, M and N into the formula:
general cures.
Here are the generic signals in the simulation
F (P) = Fi = yi 2 − 2 pxi (40) waveform, as follows:
252
Sensors & Transducers, Vol. 170, Issue 5, May 2014, pp. 248-255
253
Sensors & Transducers, Vol. 170, Issue 5, May 2014, pp. 248-255
(a)
(b)
Para
General Curves Line Circle Ellipse
bola
Start point (0,0) (0,5) (0,4) (0,0)
End point (3,5) (5,0) (6,0) (4,4)
Speed of By-Point (c)
8 10 10 8
Comparison
Speed of Slightest
5 7 7 5
Min-Error
maximum error of
By-Point 0.686 0.877 0.937 0.743
Comparison
maximum error of
Slightest Min- 0.343 0.385 0.431 0.400
Error
6. Verification
(d)
The actual two-axis CNC system controller is
composed of MCU STM32F407 and FPGA Fig. 12. General curve interpolation picture.
EP2C8Q208C8. MCU Controller is responsible for
human-computer interaction, G-code analysis and
communication with FPGA. EP2C8Q208C8 is 7. Conclusion
responsible for hardware interpolation, IO output and
signal detection. The kernel software of the FPGA is A general curve interpolation algorithm based
developed in Quartus II. Four kinds of general curves on FPGA is presented, which is realized based on
interpolation picture is shown below. FPGA hardware platform, programmed by Verilog
In the Fig. 12, (a), (b), (c) and (d) represent the HDL, simulated by software ModelSim and finally
interpolation trajectories of line, circle, ellipse and verified on a two-axis CNC lathe. Because the
parabola. The min-step size of the servo controller is proposed Slightest Min-Error interpolation algorithm
at the magnitude of 1 um. has high mobile speed and machining accuracy,
254
Sensors & Transducers, Vol. 170, Issue 5, May 2014, pp. 248-255
whose maximum error is less than half of the min- [5]. P. Kaewsaiha, N. Dejdumrong, A Combined Linear
step size, it can be widely used in precision CNC and Circular-Arc Approximation of Curves for
systems and industrial robots. Because the FPGA has Feedrate Smoothing of CNC Machining, in
the characteristics of simple program, highly Proceedings of the 10th International Conference
Computer Graphics, Imaging and Visualization
integrated, real-time, parallel and low prices, it has a (CGIV), 2013, pp. 23-26.
high application value and economic benefits. [6]. Suk-Hwan Suh, Seong-Kyoon Kang, Dae-Hyuk
Chung, Ian Stroud, Theory and Design of CNC
Systems, Springer-Verlag London Limited, 2008.
References [7]. J. Balic, Model of automated computer aided NC
machine tools programming, Journal of
[1]. K. Erwinski, M. Paprocki, L. Grzesiak, et al., Achievements in Materials and Manufacturing
Application of Ethernet Powerlink for Engineering, Vol. 17, Issue 1-2, 2006, pp.309-312.
communication in a Linux RTAI open CNC control [8]. M. Tikhon, NURBS interpolator for constant material
system, IEEE Transactions on Industrial Electronics, removal rate in open NC machine tools, International
Vol. 60, Issue 2, 2013, pp. 628 - 636. Journal of Machine Tools & Manufacture, Vol. 44,
[2]. R. E. Breaz, G. S. Racz, O. C. Bologa, et al., Motion 2004, pp. 27-36.
Control of medium size CNC Machine-Tools–A [9]. D. Ungureanu-Anghel, D.-I. Belci, E. Raduca,
Hands-on Approach, in Proceedings of the M. Raduca, Minimum vicinity interpolation
Conference on Industrial Electronics and algorithms for calculation of trajectory processing for
Applications (ICIEA), 2012, pp. 2212-2217. a model of CNC machine tool, in Proceedings of the
[3]. P. Sofer, J. Skuta, J. Gebauer, Drilling of circuit International Joint Conference on Computational
boards using CNC controlled by programmable logic Cybernetics and Technical Informatics (ICCC-
controller, in Proceedings of the 13th International CONTI), 2010. pp. 367-372.
Carpathian Control Conference (ICCC), 2012, [10]. T. Masood, A. Mubashar, M. A. Jawad Khan,
pp. 711 - 714. Techniques used in the simulation and control of
[4]. S. Tarnovean, R. E. Breaz, C. Biris, et al., Simulation PROTEC computer numerically controlled (CNC)
tools for studying the behavior of CNC laser cutting machine software Industrial Technology, in
machines in different working regimes, in Proceedings of the IEEE International Conference on
Proceedings of the 16th International Conference on Industrial Technology (ICIT), 2002, pp. 504-509.
System Theory, Control and Computing (ICSTCC),
2012, pp. 1-6.
___________________
2014 Copyright ©, International Frequency Sensor Association (IFSA). All rights reserved.
(http://www.sensorsportal.com)
255