Interpolation algorithms for numerical control

Interpolation algorithms for numerical control

27 State of the Art Interpolation Algorithms for Numerical Control Spiros G. Papaioannou Assistant Professor, Department of Manufacturing Engineerin...

701KB Sizes 26 Downloads 172 Views

27

State of the Art

Interpolation Algorithms for Numerical Control Spiros G. Papaioannou Assistant Professor, Department of Manufacturing Engineering, Boston University, Boston, MA, USA In numerically controlled systems (machine tools, plotters, flamecutters, etc.), interpolation is defined as the process of synthesizing a prescribed curve from a large number of small orthogonal steps. This paper investigates the evolution of interpolation algorithms from the early days of numerical control to the present. The algorithms presented are the most attractive computationally, since they rely on addition and subtraction alone for generating the next step. The DDA method, which dominated the premicroprocessor era, is still fully competitive when properly implemented on a general purpose computer. Now, however, its use is mostly confined to generating straight lines, where the degradation problem is absent. For higher degree curves, the pattern recognition approach provides superior accuracy. Keywords." Numerical Control, Interpolation, Pattern Recognition.

Editor's Comment: Computers in Industry welcomes not only state-of-the-art new developments, but concise tutorials that summarize known facts in a useful form, as well. The work covered in this paper by Professor Papaioannou was sponsored as an Educational Module by the National Science Foundation of the U.S. Government (under Grant No. HES75-20464) and has been used in a number of University-level teaching contexts in the U.S.A. Douglas T. Ross, Member, Advisory Editorial Board

© North-Holland PuNishing Company Computers in Industry 1 (1979) 27-40

1. Introduction A numerically controlled machine tool is a general purpose device in the sense that the cutting tool can be programmed to follow any desired path within the available degrees of freedom. How is this flexibility achieved? The basic idea still remains the proverbial wisdom that every journey begins with and, in fact, is composed of a number of small steps. Each step of the cutting tool is a small fraction of an inch (typically 0.0001" ~ 0.002"). Tens of thousands of such steps are, therefore, required to move the cutter appreciably. The process by which appropriate steps are selected to synthesize a prescribed movement is known as interpolation. The development of interpolation algorithms is thus an essential element for realizing the flexibility and accuracy required in today's machine shops. One difficulty still remains. An interpolation algorithm is usually designed to generate movement along a specific type of curve, for example, a straight line, a circle or a parabola. If higher degree curves are likely to occur, additional interpolation algorithms must be available. Building an interpolation unit, however, capable of performing all these algorithms is expensive. Spiros G. Papaioannou received the B.S. degree in mechanical and electrical engineering from the National Technical University, Athens, Greece in 1961, the M.S. degree in mechanical engineering from Lehigh University, Bethlehem, Pennsylvania in 1972 and the Ph.D. degree in electrical engineering also from Lehigh in 1975. His industrial experience includes four years with the Public Power Corporation of Greece and two years as a Systems Analyst with the Foxboro Company, Foxboro, Massachusetts. Since 1975, he is a professor of Manufacturing Engineering at Boston University, Boston, Massachusetts, where he is engaged in teaching and research in the areas of digital control, numerical control of machine tools, optimization theory and minicomputer and microcomputer applications.

28 State o f the Art A possible alternative is the development of general algorithms which could be applied to any curve regardless of its degree. Although such algorithms do exist, their use does not alleviate the problem, since generality goes hand in hand with complexity and hence again with cost. Clearly, however unwilling one may be to accept a loss o f accuracy, a compromise is necessary if the cost o f generating a curve is to be kept within an affordable limit. A judicious balance between cost and accuracy can be obtained by taking recourse to some mathematics. The basic idea is again not fancy. If interpolation of the original curve is too costly, then approximation of this curve by a simpler one and interpolation o f the latter may work. Weierstrass [7] has shown that every function f ( x ) which is continuous in an interval a<~x<~b can be approximated in that interval, to any desired degree o f accuracy, by a polynomial. Specifically, it is possible to find a polynomial p ( x ) s u c h that If(x)p(x)i < e in the entire interval, where e is any preassigned positive number. The implication is that polynomials have good approximating properties. Since they also happen to be one of the simplest and most thoroughly studied classes of functions, they are extensively used for approximating other more complicated curves. The simplest and most frequently used polynomials in the field o f NC are the straight line and the circle. They are also the easiest to interpolate. Other polynomials which find use in special applications are the parabola and the third degree polynomial or cubic. Consequently, the curve generation problem is normally broken down into two stages. In the first stage, the curve is approximated by a series o f linear segments and circular, parabolic or cubic arcs. In the second stage, each arc is, in turn, interpolated, i.e., it is further broken down into a sequence of elementary cutter steps. As a rule, with the higher degree polynomials, the accuracy of the resulting approximation increases but so does the complexity of the interpolation algorithm. In practice, conventional NC systems are usually equipped with a linear or a combined linear-circular interpolator. This is sufficient in most practical situations where the workpiece is limited to straight-line and circular cuts. Furthermore, many higher degree curves can be closely approximated by a series of circular arcs when circular interpolation is available. If, however, most o f the work consists of free-form

designs as, for example, in the case of automobile die sculpturing, the use of parabolic or cubic interpolation becomes economically justified. In certain aerospace applications such as production of aircraft wings or helicopter motor blades, where complex curves must be cut with extreme accuracy, general interpolation algorithms which completely bypass the approximation stage are necessary. With the beginning of the seventies, as a result of the ever falling cost of minicomputers, the on-line concept of "computer numerical control" (CNC)has emerged. The machine tool is connected to a minicomputer as any other peripheral device and control takes place in real time. Unlike conventional NC systems which use a hardwired interpolator, in CNC the interpolation function is performed by a computer program. As a result, the impact of more sophisticated interpolation algorithms on system cost has been greatly reduced. Furthermore, the user is no longer limited to a fixed repertory of algorithms. Instead. he can use or program any algorithm that suits his particular needs. It is this additional power and flexibility that makes familiarity with interpolation algorithms important for tomorrow's manufacturing engineer.

2. interpolation by Integration Although the idea of approximating a curve by a series of polynomial arcs has been extensively studied in mathematics, mathematicians have, for the most part, refrained from addressing the interpolation problem in the form in which it arises in numerical control, namely, generating a curve from a sequence o f fixed-sized steps. Nevertheless, in the more simple cases of a straight line and a circle, it is possible to draw an approach to this problem from the area of differential equations. Numerical control came into existence concurrently with the development of hardware methods for solving such equations. In one of these methods, a digital integrator is used as a building block and the equations are solved by an appropriate interconnection of such integrators. In other words, a n e t w o r k o f integrators is tailored or "programmed" to solve a specific set of differential equations. This network is known as a Digital Differential Analyzer (DDA), [6]. The DDA method can be used to implement linear and circular interpolation reliably and economically. In addition, the feed rate can be easily controlled. It

S.G. Papaioannou / Algorithms for Numerical Control 29 is, therefore, not surprising that most conventional NC systems employ a DDA interpolator.

2.1. The linear DDA interpolator A digital integrator consists of an N-bit register R, a binary adder A, an accumulator AC, a counter C and a source At of timing pulses (Fig. 1). Integration is performed by means o f successive differential additions. Consider first a linear function o f time

x =at +b.

(1)

This function can be obtained by integrating the differential equation dx

-a

dt with initial condition x(0) = b, i.e., we can write

x =at +b

register and the counter, respectively, while the accumulator is reset to 0. At is set equal to 2 -N, thus establishing a weight o f 1/2 N for a. At each timing pulse, the contents o f the register are added to those o f the accumulator and the result replaces the previous contents of the accumulator. Since the accumulator is o f finite length, an overflow occurs periodically and the overflowing digit steps the counter up or down depending on whether the number in the accumulator is positive or negative. As a result of this arrangement, the counter and the accumulator contain the integral and fractional part o f x i, respectively, for all values o f i. Example 2.1. Let x = 5t + 6, N = 4. Table 1 lists the contents of the register, accumulator and counter during the first eight steps o f the integration process. The acronym LSB indicates the position of the least significant bit. In each integration step, the current value o f x is computed by adding a At = 0.0101 - ¢6

t

=/adt

+b

0

t : a f dt +b.

(2)

0

Let the time interval 0 - t be divided into i equal increments Atj. Then, the value o f x at the end o f the ith time increment is i

X i =a ~

j=l

j=l

Next consider a point moving along a straight line with constant velocity represented by the vector V

Table 1. Numbers generated during the first eight integration steps.

/xt/+b)+aAt i

= Xi - 1 + a

At i .

(3)

This value is computed by a digital integrator. The coefficients a and b are initially stored into the

Accumulator (AC)~--~

Counter (C)

t

I

Xs = 0 1 1 1 . 1 0 0 1 = 7 ~ .

Atj +b

i-1

=(a ~

to the contents of the accumulator and allowing the overflowing digit (if any) to step the counter up. This value may be formed by concatenating the contents o f the counter with those o f the accumulator and placing a decimal point between them. Ii1 step 5, for example,

I Fig. 1. Digital integrator.

Timing pulse

Register (LSB)

Accum. (LSB)

Overflow

preset

1010

0000

OllO

6

1

1010

1010

0110

61-~g

2

1010

0101

OllO

10 6yg

3

1010

1111

0110

15 6Fg

4

1010

0010

ltlO

71~

5

1010

1001

lllO

79

6

lOlO

0111

1110

14 7yg

7

1010

1100

8

1010

0001

~

Counter (LSB)

~

0001

83

0001

88

30

State o f the Art

(Fig. 2). The position of the point at time t is given by the position vector

(4)

R : Vt + R o ,

R0 being the initial position, or in terms o f coordinates |.ig. 3. Linear DDA Interpolator. X = //t + X 0 ,

v

(5)

vt + Y o •

Since each coordinate is a linear function of time, it may be computed by a digital integrator. Consequently, the movement of the point along the line can be generated by a pair of integrators driven by a common source of timing pulses (Fig. 3). Each integrator controls one component of the movement. The pair is thus, in effect, a linear interpolator. An attractive feature of the integration process is the fact that each coordinate is incremented or decremented by one everytime an overflow occurs out of the accumulator. In numerical control, the overflowing digit is used directly as a stepping command to effect movement of the cutting tool by one step in the appropriate direction. E x a m p l e 2.2. Let us trace the steps taken by a cutting tool starting from an initial position Ro = [2, 10] and moving along a straight line with constant velocity V = [ 6 , ~ ] . It is assumed that the stepping commands are generated by a linear interpolator with N = 4 and that the step size coincides with the unit of length. The parametric equations of the line are x

It is seen that the error between the actual cutter path and the straight line is less than one step. In actual machining, the step size is extremely small so that a sufficiently smooth path is obtained. Accuracy and smoothness, however, are not the only practical considerations. ?ul important production decision is the choice of a cutting speed or feed-rate that minimizes production cost. The optimal feed-rate depends on the properties of the work material, the rate of tool wear and economic factors. It is, therefore, necessary to be able to select a feedrate according to the prevailing cutting conditions. In the linear interpolator of Fig. 3, the cutting speed along the line increases proportionally with tire pulse rate of the timing source. In fact. each integra-

Fable 2. Initial steps in the linear interpolation example Fiming pulse

x

preset

2

Step in +x direction

y

Step in -3' direction

10 4

2+6t, 12

y= 10- 4t.

~

2/-g

3

3

The signs of the linear terms indicate that the two integrators will generate steps in the positive x and in the negative y direction. Table 2 shows the progress of the interpolation algorithm during the first 16 timing pulses, while Fig. 4 is a plot of the resulting cutter path.

4

38

5

3Fg

6

4

7

41°

x

Fig. 2. Uniform Movement Along a Straight Line.

~

5

~

5i~

11

6

12

61~

13

6i- 8-

14

71-~

8

8 4 Fg

8

Fg

7 4

7 -i--g ~

10

16

8 ]~

8

14

7Tg

4

8 i~ ~

15

9

8

12

10

ig-

lz 9-Yg

16

56

10

9 -~

9

--16

9

14

8

8

10

7 7

-~

6

1-% 12

1-g

S.G. Papaioannou / Algorithms for NumericaI Control

31

with (8), we obtain

Y.

i0 9 8 7 6 5 4 3 2 1

p

"'%..

fpo

px = ~-ZN- u

(9)

fPo P y - 2M+N v .

-.g

In practice, a straight line segment is defined by the coordinates of its end points Po, P f (Fig. 6). Let V be the desired cutting speed along the line. Then, U

V

_ _ a .

x / ~ +b ~ 5

8

i0

x v-

Fig. 4. Linear Cutter Path.

tor may be considered as a p u l s e rate multiplier. Let Pi be the input pulse rate and p the resulting overflow rate. Then, a

P =~

(6)

Pi,

where a is the number stored in the integrator register. For the linear interpolator, this equation yields

V __b. x/'fi + b 2

(10)

The registers of the integrators are supplied with the lengths a and b instead of the velocity components u, v since a and b are readily available. Therefore, eq. (9) becomes

fpo Px - 2 M ÷ N a ,

fpo

(11)

p y - 2M+N b ,

or in view of(10)

U

Px = ~ P i

fpo x / ~ Px - 2M+N

V

u ,

fPo ~ PY - 2 M+N

+bz V v .

13

(7)

P y = -fR Pi .

Speed control is achieved by deriving the pulse rate Pi from the output of an additional integrator, [3] whose M-bit register is supplied with a feedrate word f (Fig. 5) so that pi

f

-- 5-~ p0

(8)

(12)

In deriving these equations, it has been implicitly assumed that the pulse rates are expressed in pulses per second and the velocity components in steps per second. Since each step results from an overflow pulse, u equals Px and v equals py, so that from (12)

Po being a constant pulse rate. As a result, the cutting speed becomes a function of f. Combining eq. (7) Pf

Po ~

u ~'--~Px

l k ~ p y x

Fig. 5. Linear DDA Interpolator with Speed Control.

Fig. 6. Specification of a Linear Segment.

State o f the Art

32

we obtain

y,

2 M+N

f=

Po

V ~

Y-Yc

+b 2

The feed-rate word is supplied to the interpolator through the input medium (paper or magnetic tape) along with the dimensions of the segment and a parameter specifying the type of interpolation to be performed. [2]

I ~Xc_ x

)

x

Fig, 7. Circular Arc.

2.2. T h e Circular D D A I n t e r p o l a t o r

A circular arc is usually defined by its center Pc and two end points Po, P/(Fig. 7) It is assumed that the arc is traced by the cutting tool with constant angular velocity co -

ly

dO

(14) .

dt'

where 0, the angular position, is measured with respect to Po. If V is the velocity vector and x , y the coordinates o f the current point, we have ds

V---:R

dt

Control of the cutting speed is again achieved by deriving the pulse rate Pi from the output of an additional integrator whose M-bit register holds tire feedrate number f, so that

dO

--

dt

(15)

Px -

dO 3) = - ( x - Xc) d-t-

fOo 2M+N 1)'

yc [ ,

J'po

(16)

(19)

from which _

v = ~/(~)2 + ~ 2

dx

f P ~

2 M+N

2 M+N V

-Y -Yc

dY : - ( x dO

(18)

j ' : 2 M + N ix -- xcl,

from which we obtain a pair of differential equations

dO

[3' - .Vc I

where Po is a constant pulse rate. Since the speed components 0~,~)are equal to the pulse rates P x , P y we obtain )¢

dO dO : R sin 4~~ = (Y - Yc) d-t-

Pi = ~

fPo Ix-- xcl p y - 2M+N

_

2 = V sin

fPo

- Yc I

2N

f=

- - - -

Po Xc).

(17)

The fact that the independent variable is the angular position rather than time poses no problem, since 0 is proportional to t. A digital differential analyzer for integrating this system is shown in Fig. 8. It consists of two integrators whose registers are initially supplied with the numbers Yo - Yc and -(Xo - xe). The overflow signal from the y-integrator is connected to the R input of the x-integrator while the overflow signal from the xintegrator is first reversed in sign and then connected to the R input of the y-integrator.

(20)

--

R

E x a m p l e 2.3. A circular interpolator generates stepping commands from the recursive relations i

Xi + l = Xi + [ ~

QYi -- Yc) AO] ,

i=O i

y;+1 =y; + I S

]=0

- ( x i - Xc) ~x01,

where [ ] denotes the overflow of the sunmaation process. Assume that the circular segment is centered at Pc = [3,2] and that the initial point is Po = [0,6]. Let N = 4, so that A0 = ~ . Table 3 lists the first 32

S.G. Papaioannou / Algorithms for Numerical Control

33

Yt ~f

"4 l:ig. 8. Circular DDA Interpolator.

Fig. 9. Circular Cutter Path.

interpolation steps. The resulting cutter path is illustrated in Fig. 9.

parametric equation of the form 2.3. A combined linear-circular interpolation unit

y =f(x).

Both the linear and the circular DDA interpolator can be incorporated into a single unit consisting of only three integrators (Fig. 10). The actual configuration of the unit is controlled by the SELECT signal and the external logic. When SELECT is equal to 0, the two integrators are not interconnected and the unit functions as a linear interpolator. With the SELECT signal equal to 1, the two integrators are connected as in Fig. 8 and the unit becomes a circular interpolator.

(22)

Differentiating with respect to time, we obtain

df. 35 = ~ x .

(23)

For a point moving along the curve with constant speed V (Fig. 11), we have (2)2 + @)2 = i/2 .

(24)

Substitution of (23) into (24) yields 1+

(~)2 = v ~ .

(25)

2.4. Parabolic interpolation

For the straight line and the circle, the DDA technique results in a particularly simple implementation of the interpolator. The complexity of implementation increases sharply when the method is applied to other types of curves such as a parabola or a cubic. The reason for this can be traced to the basic fact that a DDA interpolator is a device for integrating a system

Equations (23) and (25) are the differential equations of the motion. A parabola is generally defined by y = ax 2 + bx + c .

Then, 35=(2ax+b) 2

d$ --=2ax+b dx

or

so that equations (23) and (25) become

2 =u(x,y, t),

V

35 = v(x, s, n ,

(21)

point-by-point. Speed control is achieved by selecting a system of the form 21, which describes the motion of a point tracing the curve with constant speed. In the case of a straight line or a circle, this system is simple enough to require only two DDA elements for its integration. For other types of curves, however, the system becomes substantially more complex. Assume that the curve is initially defined by a non-

:/-

x/1 + (2ax + b'?

,

3) = (2ax + b) 2 . A digital differential analyzer for integrating this system is shown in Fig. 12. Integrators 1, 2, and 3 form a square root network [6] which calculates the quantity l/x/1 + (2ax + b) 2. The small circle at the output of integrator 2 denotes a sign reversal. It is seen that a parabolic interpolator requires eight inte-

34

State of the Art

Table 3. Initial steps in the circular interpolation example Pulse

[(Y -Yc)]

x

preset

4

0

Step i n x direction

[ (x - Xc) }

y

3

Step iny direction

1

4

4 1-~

3

6 63

2

4

3

4

816 12 a-g

3 3

6 i ~6 69

4

4

1

2

6T-d

5

4

11~

2

6iT

6

5

7

5

18 13 ITg

2 9_

7 72

9

5

27

l

75

10

5

12

2T-g

I1

5

312g

12

5

36

-,

--

11

13

5

3i~

14

5

4

15

5

45

1

76 77

0

77

5

17 18

5 5

19

5

59

77

-1

76

4Tg 15 4i-g

20

4

5i~

21

4

6i~

22

4

66

23

4

24 25

4 4

61L~ 6 i14 g

26

3

28

54

16

1 1 --,

14

77

-1

10

16

14

0

t)

-~

12

75 74

--2

73

2

71

,~

15

-~

6Tg

3 -3

613 TZ 10 6Tg

,~3 --3

67-16 61~g

-4

61

76

--4

5 Tg

4

59

3

7 i12 ~

4

51~

29

3

15 7Vg

--4

5 1~

30

2

82

-5

4i~

31

2

84

-5

48

32

2

86

-5

43

grators

plus

72

an

additional

integrator

.

.

.

.

~

~

for

speed

control.

2.5. Accuracy o f the DDA method Our discussion so far suggests t h a t i n t e r p o l a t i o n b y i n t e g r a t i o n is a n i n h e r e n t l y i n e x a c t process. N e v e r t h e -

13

13

less, in t h e case o f a linear D D A i n t e r p o l a t o r it was f o u n d ( E x a m p l e 2.2) t h a t t h e error b e t w e e n t h e straight line a n d t h e a c t u a l c u t t e r p a t h r e m a i n s less t h a n o n e step. A s t a t e m e n t such as this is reassuring, since, it g u a r a n t e e s t h a t t h e e r r o r will n e v e r e x c e e d t h e r e s o l u t i o n o f t h e m a c h i n e tool. U n f o r t u n a t e l y ,

S.G. Papaioannou / AIgorithms for Numerical Control

35

~ELEC7

>

i I:ig. 10. Linear-circular DDA Interpolator.

the statement does not hold for any arbitrary curve. The question, therefore, arises what can be done in the general case to keep the interpolation error within an acceptable limit. The DDA technique relies on a system of differential equations of the form 21 for generating points along the curve. This system is transformed into a set of recursive relations Xi + 1 = Xi + L/(Xi, .Fi, ti) A t , Yi+ 1 = Yi + V(Xi, )'i, ti) A t

(26)

from which successive points can be readily computed. These relations are, in general, approximate. The resulting error can be estimated from the Taylor expansions Xi+l=Xi+xiAt+

'~

x (.') At2+...+"~-Atn+

....

2

l'}n ) -

=

1

+

(2ax

+

b) 2

Fig. 12. Parabolic DDA Interpolator.

In the case of a straight line, all higher order derivatives are zero and successive points along the line can be conrputed exactly from the truncated Taylor series Xi+ 1 - Xi + Xi A t ,

(28)

Yi+l = Yi +)'i A t .

For any other curve, however, the above relations constitute only a first-order approximation and systematic errors are introduced into the computation. Recursive relations of this form yield, in fact, the silnplest known method of numerical integration and were first used by Euler [51. Although Euler's method is inaccurate, it can be used as a starting point for further improvement. Substantially higher accuracy, for example, can be obtained by including the small triangles (At) (2~2 i)/2 into the area of integration (Fig. 13). The resulting trapezoidal rule is a second-order approximation ~X2i 2

11.

3. Yi+l : Y i +);i A t + Y i At2 +

u

Xi + 1 = X i + )Ci At + - - A t n

" + "n!' &t + ...

(27)

which show that the next point (xi+l, Yi+l) depends not only on the current point (xi, Yi) and the first time derivatives 2i, J~i, but also on all derivatives of higher order.

x i +2 i At + X i A t 2 2 '

i.e., the second derivative is included into the truncated Taylor series. Normally a digital integrator follows Euler's rule. It can, however, be converted to a trapezoidal integrator with very little modification. This is seen by writing the trapezoidal rule in the form Xi+l=Xi+(Jci+~-)At.

x

Fig. 11. Uniform Movement along an Arbitrary Curve.

(29)

(30)

Since AfCi/2 is the input to the R register shifted one place to the left, a trapezoidal integrator can be realized by letting A2 i become the least significant bit in the adding process. As a result of the limited accuracy of the integration process, the cutter path eventually diverges from the ideal curve. Nevertheless, the amount of diver-

36 State of the Art

x(t)

x(t)

__

I

T

~

I

(At)(L~i)

:£. 1

i

I t

C --~

t

(a) (b) l:ig. 13. Integration in the x-Direction: (a) by Euler's rule, (b) by the Trapezoidal Rule.

gence or degradation as is usually called, decreases rapidly as the cutter step becomes smaller and smaller, until for today's typical step size degradation can for most practical purposes be ignored. One need only look at Fig. 14, however, to be reminded of its existence. The circular path in this figure was drawn by a digital plotter controlled by a PDP-8 minicomputer at Boston University's Computer Control Laboratory. Stepping commands were generated by a PDP-8 program simulating the operation of a circular DDA interpolator. To produce a pronounced effect, Euler's rule was used. The degradation error is seen to be approximately 3 steps per revolution. The same circle was redrawn with a much smaller step size and no appreciable degradation was visible. Furthermore, generating circles more than one revolution is of little practical interest.

3. Orthogonal Interpolation by Pattern Recognition The advent of minicomputer control has created new possibilities as far as the interpolation function is concerned. A minicomputer can be used as a processor for a host of different algorithms. In addition, its inherent power and flexibility open the way for more general interpolation algorithms capable of generating complex curves accurately and economically. In order to take advantage of the full potential of the mini, however, a fresh approach to the interpolation problem is required. Since simplicity is no longer a critical factor, greater emphasis should be placed on the side of generality. A most promising method in this direction relies on the local geometry o f the curve for generating the next step [1,4]. It may, therefore, be aptly classified as a pattern recognition

technique. 3.1. The general algorithm Let the curve be defined by a non-parametric equation of tile form

S %_

fix, y) = 0 .

/

Fig. 14. Degradation of Circular Path Interpolated by Euler's rule.

(31)

Interpolation proceeds by moving the cutting tool along a single coordinate axis at a time. This type of interpolation is called orthogonal. Without loss of generality, it may be assumed that the step size is equal to 1. Let Pi be the current point (Fig. 15). In order to select the next point among the four possible candidates, X+, X_, Y+ and Y_, the computer must somehow recognize the local geometry of the curve in tire vicinity of Pi. Successful interpolation requires that the next point be located in the direction o f interpolation and not further from the curve than one step. A con-

S.G. Papaioannou / Algorithms for Numerical Control

37

decision are defined as follows: F = 1 if and only iff(x, y ) >~ 0 , f

A =1 if and only if 0f ~> 0 0x B =1 if and only i f 0 f ~ > 0 . av X+ = 1 for a step in the positive x direction X_ = 1 for a step in the negative x direction Y+ = 1 for a step in the positive y direction Y_ = 1 for a step in the negative y direction.

x

l.ig. 15. Possible Steps in Orthogonal Interpolation.

Then equations (32) yield four selection rules venient measure of closeness to the curve at a point P is provided by the value tiP) of the function f ( x , y ) at that point. Normally, f(P) is positive on one side of the curve and negative on the other. Furthernrore, on either side, f(P) approaches 0 as P moves closer to the curve. It follows that a step brings us closer to the curve if the value o f / I x , 3') at the end of the step is closer to 0 than at its beginning. The variation of f(x, y ) along each step may be expressed as a Taylor expansion

f(x+l,Y)-f(x'Y)=O~

f(x

l,j,}-f(x,y)

f(x,y+l)-f(x,y)=

f(x, y - 1 ) - f ( x , y )

O f + l O2f+ 2Ox 2 ....

~f ax

=- ~+

1 O2f 2 Ox 2

....

l~2f

~ + ~ @ ~ + ....

= - Of+ 1 O2f Oy 2 Oy 2

....

(32)

On first approximation, the effect of a step on the value of the function is given by the first partial derivative. If, for example, f(x, y ) is currently negative, then a step in the positive x direction brings closer to the curve if the value of the function along this step increases. Thus, an X+ step is permissible if f(x, y ) < 0 and the partial derivative Of l a x is positive. By similar reasoning, X+ is also permissible if f(x, y ) > 0 and ~f/Ox < O. A set of rules for selecting the next step is more concisely expressed in Boolean notation. Let +, • and - denote the logical OR (conjunction), AND (disjunction) and NOT (negation) operation, respectively. The Boolean variables involved in the selection

X+ = A • F + A " F ,

X_=A

"F+A'F,

Y+ =B" F + B " F , Y

-B'F+B'F.

(33)

These rules, however, do not result in a unique choice, since, they simply express the conditions under which a step brings closer to the curve. In fact, for every set of values of A, B, F two of the above expressions assume the value 1, indicating two possible moves. This is not surprising, since, as can be seen from Fig. 15, for example, on the basis of closeness to the curve alone, both an X+ and a Y+ move are permissible. A closer examination of Fig. 15, however, reveals that X+ and Y+ correspond to opposite directions of interpolation. This observation suggests that in order to arrive at a unique step choice, the direction of interpolation must be considered. Let t = [Of/Oy,-Of/Ox] be the tangent to the curve in the vicinity of Pi. Then, of the two possible moves X,, Y, obtained from equation (33), one is in the t direction and the other in the t direction. Since the direction o f interpolation (t or t) is prescribed, the direction requirement eliminates one of the two possible moves so that the remaining move becomes the final choice. The direction requirement can be accounted for by introducing the variable D = 1 if interpolation is in the t direction, = 0 otherwise, into the Boolean conditions 33. Assume, for example, that interpolation is performed in the direction of t(D = 1). It is apparent that t points to the positive x

38 State o f the Art direction if and only if its x-component is positive (i.e., af/ay > 0). Thus, a step X+ satisfies the direction requirement if D = 1 and B = 1. Similarly, X+ is permissible if D = 0, B = 0. This line of reasoning leads to the final expressions

Y

X+ = ( A " F + A " F)(B" D + B" O) , X _ = (A" F + A . F ) ( B . D + B" D ) , Y+ = (B" F + B" F ) ( A . D + A " D) ,

t:ig. 17. Actual and Interpolated Ellipse.

(34)

Y _ = (B" F + B . F ) ( A . n + A . D) ,

which satisfy both the closeness and direction requirements. These conditions yield a unique step choice, since, for every set of values of A, B, D, t;, one and only one of the above expressions assumes the value 1. To summarize, given a non-parametric description

ellipse defined by the equation X2

f(x, y ) =

2

+~144 64

1=0

The partial derivatives are

f(x, y ) = 0

of

x

af

y

of a plane curve, a segment PoPy on the curve and a direction of interpolation, the algorithm defined by the flowchart of Fig. 16 will generate stepping commands for the orthogonal interpolation of the segment. E x a m p l e 3.1. Fig. 17 shows the interpolation of an

0x

72'

0y

32"

f=O, x=xo, Y=Yo

yES< " 0

I

NO

Interpolation was carried out with the help of a computer program. Computer results for the first ten steps are listed in Table 4. This example illustrates one of the basic features of the algorithm, namely, the absence o f degradation. The actual cutter path never diverges more than one step from the ideal curve. In fact, it can be said that the algorithm exhibits feedback, since even if the point is more than one step away, it will automatically seek its way back to the curve. The feedrate is controlled by the interpolation software and can be easily programmed. Due to the orthogonal nature of the steps, the speed with which the cutting tool moves along the desired path varies

Table 4. Initial interpolation steps Step

x

y

f

q~ I

F

]

YEs I

I

I

.

I

[

Fig. 16. Flowchart of the Interpolation Algorithm.

0 1 2 3 4 5 6 7 8 9 10

---12 -11 -11 --11 -11 11 -10 - 10 -9 -9 -8

0 0 1 2 3 4 4 5 5 6 6

O. --0.160 -0.144 -0.097 -0.019 0.090 -0.056 0.085 -0.047 0.125 0.007

~f

af

ax

~)3;

--0.167 -0.153 -0.153 -0.153 -0.153 0.153 -0.139 -0.139 -0.125 -0.125 0.11l

O. O. 0.031 0.063 0.094 0.125 (].125 0A 56 0.156 0.188 0.188

F

,,t

B

I 0 0 0 0 1 0 1 0 1 1

0 0 0 0 0 0 0 0 0 0 0

1 1 1 1 1 1 1 1 1 1 1

S.G. Papaioannou / Algorithms for Numerical Control

sonrewhat depending on the direction of the path with respect to the x-axis. At 0 or 90 degrees the speed is x/2 times the speed at 45 degrees. This results in a speed variation o f +-20% which poses no particular problem in most applications. Although the generality o f this algorithm is remarkable, a word of caution is in order. The algorithm may occasionally fail to pick its way through an unusual local geometry as, for example, when there is an abrupt change in the direction of the path. Difficulties o f this nature are common in pattern recognition techniques and can be usually avoided with a slight modification o f the decision rules. 3.2. L i n e a r a n d Circular I n t e r p o l a t i o n

Since the straight line and the circle are the most elementary and at the same time the most frequently encountered types o f curves in CNC work, it is advisable to use special computer algorithn~s for their interpolation. These algorithms can be easily derived from the general algorithm of Fig. 16. Consider first a straight line. Assuming that interpolation proceeds from the initial point P0 to the final point Pr, there is only one direction in which the line can be traced, namely, the direction of the vector PoPf. This is a general characteristic of open curves (straight line, parabola, etc.) as opposed to closed ones (circle, ellipse, etc.) for which two opposite directions of interpolation are possible. Consequently, for the straight line, D = 1. A non-parametric description o f the line is (Fig. 6) f ( x , y ) - aCv - Y o ) - b ( x - Xo) = 0

39

Table 5. Decision variables for linear interpolation xf - xo

yf -- Yo

A

B

X+

X

Y+

Y

+ +

+ -

0 1

1 1

F bv

0 0

kv 0

0 F

-

+

0

0

0

F

F

0

1

0

0

F

0

/?

-

the direction of nrovement is determined by tile sign o f (xf - x0) while in the case of a y move the direction o f movenrent is given by the sign o f 0 ' f Yo)- A similar analysis can be made when J ( x , y ) is negative. Fig. 18 shows the flowchart o f the interpolation algorithm. We next turn our attention to the circle. Its nonparametric description f(x,y)

(/V-yc) 2 +(x

Xc) 2

r 2 =0

(37)

yields a f _ 2(x - xc) 0x '

Of = 2 0 ' 03'

3'c).

(38)

There are again four cases to consider (Table 6), each case corresponding to one quadrant. The analysis of the table proceeds along similar lines as in the case o f the straight line. For example, if D = 1 and

f=O, a = xf-

x=x

o,

Y=Yo

x 0 , b = yf-Y 0

(3s)

from which

aS

3x

of 3.Y

-a

e = - ( y f - yo), ( x r - xo).

(36)

Depending on the sign of (xf - X o ) and 0 ' f - Y 0 ) , we distinguish four cases summarized in Table 5. It is seen that in each case the Boolean expressions 34 are simplified to the point where each o f the four step variables is equal to 0, F or F . This table also indicates that if the function f(x, y ) is positive (/7 = 1), then an x move is selected whenever ( x f - X o ) and ( Y f - Y o ) have the same sign, while a y move is selected whenever the signs o f these two quantities are opposite. Furthermore, in the case o f an x move,

I

I

I

I

l

Fig. 18. Flowchart of the Linear Interpolation Algorithm.

40

State o f the A r t

Table 6. Decision variables for circular interpolation

f=0, a=×o-

x - xc

Y -Yc

A

B

X+

X

Y+

Y

+

+

1

1

F'D

I' "D

F'D

F'I)

+

-

-

+

1

1

F "D

I: • D

F "D

1: " D

0

1

F "D

Y

F "D

F •

0

0

F'D

I:'D

F'D

F'D

" [)

I

x = x o , y = _y~[i xc'b=Yo ,

< 7 N Y

B the f u n c t i o n f(x, y ) is positive ( F = 1), t h e n the selection of an x or a y move depends on whether (x - X c ) and (y - Y c ) h a v e opposite or identical signs, respectively. F u r t h e r m o r e , the direction o f an x move is d e t e r m i n e d by the sign o f Cv - Yc), while the direction o f a y move is derived from the sign o f - ( x xc). A flowchart o f the i n t e r p o l a t i o n algorithm is given in Fig. 19. The c o m p u t a t i o n o f f ( x , y ) a t the end o f each step is carried out recursively. Assume, for example, a move x = x + s y . Then, the n e w value o f f is f=Cv-yc)

2+(x+sy-xc)

¥

N

=f+

sy)

-

Xc)]

sy

-

~

=x= a



:

I

Fig.

= f + 2 [(x +

N

sx=

2-r 2

=(y-yc) 2+(x-xc) z---r2+2(x

~"

19. Flowchart of the Circular Interpolation Algorithm.

Xc) Sy+l

1

2a - 1 .

It is seen that updating f requires two additions and one subtraction or t w o subtractions and one addition. No multiplication is involved.

References

[ 1 ] P. Danielson, Incremental Curve Generation, IEEE Trans. on Computers, Vol. C-19, pp. 783-793, Sept., 1970. [2] Electronic Industries Association, Interchangeable Perforated Tape Variable Block Format for Positioning,

Contouring and Contouring/Positioning Numerically Controlled Machines, EIA Standard RS-274-C, June, 1974. [3] Y. Koren, Interpolator for a Computer Numerical Control System, 1EEE Trans. on Computers, Vol. C-25, pp. 32-37, Jan., 1976. [4] S. Papaioannou, "An Interpolation Algorithm for Computer Numerical Control", Society of Manufacturing Engineers Techn. Paper MR76-359, 1976. [5] J. Scarborough, N u m e r i c a l M a t h e m a t i c a l A n a l y s i s , The Johns Hopkins Press, 1966. [6] T. Sizer, Editor, The Digital D i f f e r e n t i a l A n a t y z e r , Chapman and Hall, London, 1968. [7] K. Weierstrass, "Uber die analytishe l)arstellbarkeit sogenannter willkurlicher Funktionen einer reelen Veranderlichen", Sitzungsberichte der Kgl. AK. der Wiss., 1885.