Beruflich Dokumente
Kultur Dokumente
MACRO PROGRAMMING
Vratraj K Joshi1, Prof K P Desai2, Prof H K Raval3
1
Research Scholar, Department of Mechanical Engineering, SVNIT, Surat 395007
2-3
Professor, Department of Mechanical Engineering, SVNIT, Surat 395007
ABSTRACT
It is necessary to machine curvilinear tool paths considering aesthetic requirements of todays
manufacturing world. Generally, preparatory codes available with the machine controller but,
the limitation of machining curvilinear tool paths, as most of the controllers are supported
with machining of linear and circular tool path. Further, the machining of curvilinear tool
path using commercially available CAD-CAM software required the identification of current
cutter location points which are to be connected by linear interpolation. Each linear segment
to machine the curve is adding single block in the part program. This will increase length of
the part program and add to program memory size. Understanding of the CAD software is
also essential to machine the curve shape. To overcome this difficulty, MACRO
programming is attempted to machine curvilinear profile (Bezier Spline). It can be introduced
at any block with subroutine without affecting previous preparatory or miscellaneous codes.
The purpose of the present work is to machine Bezier spline expressed by mathematical
equation using MACRO programming. Surfaces quality for the machined tool path is
measured and reported.
NOMENCLATURE
1. INTRODUCTION
Like any other computer programming language, programming with MACRO can be
prepared while working with CNC Fanuc controller. It can be executed by preparatory codes
of CNC controller. It is a flexible programming that can utilize conditional and logical loops,
arithmetic variables and operators. A subprogram is required for parts with similar machining
operations. But, for parts with the similar design, a single MACRO part program is to be
developed that can considerably reduce part programming time. It can be further beneficiary
in product development. It is to be prepared frequently for changing workpiece variable such
as dimensions, holes, threads, slots etc. A single MACRO program can machine similar parts
and most suitable for a same part family because tool position coordinates are not needed to
be changed every time as and when the part is changed. It helps in reducing duplication of the
similar program. Some of the commands used in MACRO program are GO TO, IF
[condition] THEN [do something condition], EQ [equals], NE [not equals], GT [greater then],
LT [Less then], +, -, *, /, SIN, COS, TAN, ATAN, SQRT, ABS etc. Good amount of work
has been carried by various authors to develop algorithms for command generation or canned
cycle to reduce program length as well increase shape flexibility.
1
DR B R AMBEDKAR NATIONAL OF TECHNOLOGY JALANDHAR-144011, INDIA
DEPARTMENT OF INDUSTRIAL AND PRODUCTION ENGINEERING
IVTH INTERNATIONAL CONFERENCE ON PRODUCTION AND INDUSTRIAL ENGINEERING, CPIE-2016
4. MODELLING/EXPERIMENTATION
The curve geometry can be represented mathematically by 2nd or higher order; for every point
P on the Bezier spline.
P(u ) Ap 0 (u ) Bp1 (u ) Cp 2 (u ) Dp 3 (u ) (1)
where,
A 1 3t 3t 2 t 3
B 3t 6t 2 3t 3
C 3t 2 3t 3
D t3
P( y ) 1 t p 0 ( y ) 3t 1 t p1( y ) 31 t t 2p 2 ( y ) t 3 p3( y )
3 2
2
DR B R AMBEDKAR NATIONAL OF TECHNOLOGY JALANDHAR-144011, INDIA
DEPARTMENT OF INDUSTRIAL AND PRODUCTION ENGINEERING
IVTH INTERNATIONAL CONFERENCE ON PRODUCTION AND INDUSTRIAL ENGINEERING, CPIE-2016
Circular arc in first quadrant can be represented as a cubic curve by adjusting starting point
P0, end point P3 and control points P1 and P2. In first quadrant, circular arc intersects
horizontal axis (i.e. x axis) at point P0 (1, 0) and vertical axis (i.e. y axis) at P3 (0, 1) as shown
in figure 1. Considering single arc of circle as a Bezier spline, start point and end point will
be P0 [1, 0] and P3 [0, 1] and control points will be P1 [1, K] and P2 [K, 1]. The position of the
control points P1 and P2 can be determined by finding the value of K. Here, the values of
P0x and P3x are 1 and 0 respectively. As, t is considered as a knot vector of Bezier spline,
value of t is 0 (zero) at start point P0 , 1 (one) at end point P3 and 0.5 at the middle point of
the curve tangent.
The value of knot vector can be taken in the range of 0 to 1.0 (i.e.one). In the present study
for the circular curve, the value of knot vector t is taken 0.5 to solve equation (2) at the
midpoint of the spline,
P (x) = (1-0.5) 3 P0 X+ 3(1-0.5) 2 (0.5) P1X + 3(1-0.5) (0.5)2 P2 X + (0.5)3 P3X (4)
For the curve segment 00 to 900, the midpoint of curve angle is 450. Hence, cosine distance is
0.707.
So, substituting P(x) = 0.707 in equation (4)
0.707 = (1-0.5) 3 (0) + 3(1-0.5) 2 (0.5) (1) + 3(1-0.5) (0.5)2 (K) + (0.5)3 (1) (5)
Resolving the equation (5),
K=0.552
Figure 1 Circular arc as a Bezier Spline
Circular arc for first quadrant is shown in Figure 1. It can be represented as a cubic Bezier
spline curve by adjusting points P0 (1, 0), P1 (0.552, 1), P2 (1, 0.5520 and P3 (0, 1)
respectively. After determining the value of X and Y co ordinates, with the help of equation
(2) and (3) other cutter location points on the circure tool path are determined.
The machining of circular cutter path is carried out using MACRO programming and
considering curve as a Bezier spline. The complete circle is derived in to four quadrant
having center of the circle at an origin of the Cartesian axis. The co ordinate of various points
(viz. start point P0, first control point P1, second control Point P2, and end point P3) for each
quadrant are summarize in table 1. The start point P0, first control point P1, second control
Point P2, and end point P3, value of X and Y co ordinates are positive in first quadrant, value
of X co ordinate is negative and Y co ordinate is positive in second quadrant, value of X and
Y co ordinates are negative in third quadrant. In fourth quadrant value of X co ordinate is
positive and Y co ordinate is negative. It is noted that end point of spline in any quadrant
becomes start point of immediate next quadrant in anti clockwise direction. By stitching, the
end point of one arc of the 1st quadrant with the start point of the second arc in 2nd quadrant,
end point of second arc of the 2nd quadrant with the start point of the third arc of the 3rd
quadrant, end point of third arc of the 3rd quadrant with the start point of the fourth arc of the
3
DR B R AMBEDKAR NATIONAL OF TECHNOLOGY JALANDHAR-144011, INDIA
DEPARTMENT OF INDUSTRIAL AND PRODUCTION ENGINEERING
IVTH INTERNATIONAL CONFERENCE ON PRODUCTION AND INDUSTRIAL ENGINEERING, CPIE-2016
4rd quadrant and end point of fourth arc of the 4th quadrant with the start point of the first arc
the 1st quadrant will form circular geometry using Bezier Spline.
Table 1 Sign Convention for circle in each quadrant
Quadrant
i ii iii iv
Start Point P0 (1,0) (0,1) (-1,0) (0, -1)
First Control Point P1 (1,0.552) (-0.552, 1) (-1, -0.552) (0.552, -1)
Second Control Point P2 (0.552, 1) (-1, 0.552) (-0.552, -1) (1, -0.552)
End Point P3 (0,1) (-1,0) (0,-1) (1,0)
Figure 2 shows the flow chart describing the steps of the various calculated x, y co ordinates
at various point on circular geometry using Bezier spline function. Circle is obtained by
connecting Bezier spline in each quadrant.
Figure 2 Flow chart of a Circle represented by Bezier spline function
Start
t=0
t=t+0.01
Y
t>1
End
Start point P0, end point P1, control points P2 and P3 are to be selected as per quadrant of the
circular arc. Total 100 cutter location points are determined to interpolate with Bezier spline
function in each quadrant. Hence, the value of knot variablet starts from zero and it is
increased in the step size of 0.01 up to maximum value of t is equal to 1.0 (i.e. one). The
initial value of knot vectort, X and Y co ordinates of P0, P1, P2 and P3 are stored in
MACRO as per Table 2. Separate MACRO addresses are assigned to feed (F), spindle speed
(S), depth of cut (z) and knot vector (t). The variable can be changed as per geometrical
requirement. This makes program flexible. The Circle is fitted with the linear interpolation
(G01) by Conventional programming method with the fixed angular distance between two
successive co ordinates. As discussed earlier, total 100 cutter location points in each quadrant
are determined to interpolate circle with Bezier spline function by MACRO programming
method.
4
DR B R AMBEDKAR NATIONAL OF TECHNOLOGY JALANDHAR-144011, INDIA
DEPARTMENT OF INDUSTRIAL AND PRODUCTION ENGINEERING
IVTH INTERNATIONAL CONFERENCE ON PRODUCTION AND INDUSTRIAL ENGINEERING, CPIE-2016
The same numbers of cutter location points are required to interpolate the circle with
conventional method. For that, circle is plotted in AutoCAD and 100 cutter location points
are measured at fixed angular interval in each quadrant.
5. RESULT AND DISCUSSION
For MACRO programming, Circle is interpolated with Bezier spline. Knot vector starts from
initial value 0 and ends at 1 with the increment of 0.01 in each quadrant. It means total
calculated cutter location points are determined by dividing the subtraction of maximum
value of knot vector and minimum value of knot vector with the step size [i.e. (1-0) / 0.01
=100] in each quadrant. Drawing a circle in AutoCAD with measuring 100 cutter location
points in each quadrant take more time. In the present case, time for drawing circles with
dimensions 100 cutter location points for each quadrant in AutoCAD is 4925 seconds. Table
3 shows a comparison between MACRO and Conventional programming for machining of
the circular geometry.
Table 3 Comparison of conventional programming with MACRO programming (Bezier
Spline)
Time (Seconds)
Circular Length Size
tool path (Words) (KB) Program Writing Program
Total
Drawing Feeding execution
Conventional
2709 17 4925 1140 117 6182
programming
Bezier spline
268 11 0 332 219 551
MACRO
Time for feeding these co ordinates is 1140 seconds. In case of MACRO programming, cutter
tool path is equation driven. No such drawing is needed. Hence, program feeding time (332
seconds) is very less. It is notable that machine feed is 100 mm/min and program execution
time to cut a circle by conventional programming is 117 seconds. But, in case of MACRO
programming, circle fits as a Bezier spline. In this case, the processor has to calculated X and
Y co ordinate for every cutter location points. So, program execution time is 219 seconds,
more than double of conventional programming. Considering the total time, program writing
time (including drawing and feeding) with program execution time for the Conventional
method to cut the circle is quite high (6182 seconds) compared to MACRO programming
method (551 seconds). The additional advantage of MACRO programming is that program
size is 17 KB and length 2709 words for conventional programming. Which is more than
MACRO programming program size is 11 KB and length is 268 words.
5
DR B R AMBEDKAR NATIONAL OF TECHNOLOGY JALANDHAR-144011, INDIA
DEPARTMENT OF INDUSTRIAL AND PRODUCTION ENGINEERING
IVTH INTERNATIONAL CONFERENCE ON PRODUCTION AND INDUSTRIAL ENGINEERING, CPIE-2016
2.5
2
Surface Roughness Ra
1.5
Conventional
1 Bezier Spline
0.5
0
0 30 60 90 120 150 180 210 240 270 300 330 360
Development of Angle
The circular tool path is fitted with Bezier spline to cut by MACRO programming method.
The similar circular tool path is linearly interpolated cutter location points cut by
Conventional programming method. The surface quality is examined, for both the methods
with the help of SURFTEST (SJ-210 Mitutoyo). The work piece is marked clockwise at 300
for the measurement of surface quality at 12 positions (3600/120) of the test piece. As stated
in Figure 3, surface roughness is less in the case of the circle is fitted with Bezier spline and
cut with MACRO compared to Conventional programming. This is because, controller takes
more time (219 seconds) to cut the circular profile interpolated with Bezier spline function
compared to time taken (117 seconds) to cut with Conventional method as the controller has
to compute the co ordinate of each point based on the term used in MACRO programming.
The tool stops for a while at the previous point co ordinates till the next point is calculated. It
minimizes tool over drive and improve surface quality while machining circular profile with
Bezier spline function using MACRO programming method.
6. CONCLUSIONS
6
DR B R AMBEDKAR NATIONAL OF TECHNOLOGY JALANDHAR-144011, INDIA
DEPARTMENT OF INDUSTRIAL AND PRODUCTION ENGINEERING
IVTH INTERNATIONAL CONFERENCE ON PRODUCTION AND INDUSTRIAL ENGINEERING, CPIE-2016
REFERENCES
G. Albrecht, R.T. Farouki (1996) Construction of C2 Pythagorean hodograph interpolating
splines by the homotopy method Advances in Computational Mathematics, 5, 417-442
Farouki R.T. (1996) The elastic bending energy of Pythagorean hodograph curves
Computer aided Geometric Design, 13, 227-241
T. Sata, F. Kimura, N. Okada, M. Hosaka (1981) A new method of CNC interpolation for
machining the sculptured surface Annals of the CIRP, 30, 369-372
D.J. Walton, D.S. Meek (1996) A Pythagorean Hodograph quintic spiral Computer Aided
Design, 28, 943-950
Omirou S., Barouni A. (2005) Integration of new programming capabilities into a PC-based
milling machine controller Robotics and Computer Integrate Manufacturing, 21/6, 518-527.
Omirou S., Nearchoub A. (2009) An epitrochoidal pocket - A new canned cycle for CNC
milling machines Robotics and Computer-Integrated Manufacturing, 25 /1, 73-80
Abbas A.T., S.M. Megahed (2005) A general algorithm for drilling holes lying in a matrix
Computer Integrated manufacturing, 21, 235-239
Farouki RT, Manjunathaiah J, Yuan G. (1999) G codes for the specification of Pythagorean
hodograph tool paths and associated federate functions on open architecture CNC machines
International Journal of Machine Tools Manufacturing, 39, 123-142
Pateloup V, Duc E, Ray P, (2004) Corner optimization for pocket machining International
Journal of Machine Tool Manufacturing, 44/12, 1343-53