M-Series Operator’s Manual 4/9/15
G65 - Call Macro
G65 calls a macro with user-specified values. A macro is a subprogram that executes a certain operation (e.g. drill
pattern, contours, etc.) with values assigned to variable parameters within the operation.
Calling methods:
G65 Pxxxx Lrrrr Arguments
or
G65 "program.cnc" Lrrrr Arguments
where xxxx is the macro number (referring to file Oxxxx.cnc, 0000-9999 allowed, leading zeros required in
filename, capital O, lowercase .cnc), rrrr is the repeat value, "program.cnc" is the name of the macro file, and
Arguments is a list of variable identifiers and values.
Arguments to macro calls are specified by using letters A-Z, excluding G, L, N, O, and P.
Macros are written just like normal programs. However, macro programs may access their arguments by using #A,
#B, etc., or by using numbers: #1 for A, #2 for B, etc. (exceptions: #4-6 for I-K, #7-11 for D-H). Arguments I, J,
and K can be used more than once in a macro call, with the first set of values stored as #4-6, the second as #7-9,
etc., to a maximum of 10 sets. See example at the end of this G65 section.
Macros 9100 - 9999 may be embedded into a main program, using O91xx to designate the beginning of the macro
and M99 to end it. The CNC software will read the macro and generate a file O91xx.cnc, but will not execute the
macro. It will be executed when G65 is issued.
Example 1:
Main program:
G65 "TEST.cnc" A5 B3 X4
Macro TEST.cnc:
G1 X#X Y#A Z-#B
This call will produce
G1 X4 Y5 Z-3
Example 2:
Main program:
G65 "TEST2.cnc" I5 J3 K40 I-1 J2 I0 J0
Macro TEST2.cnc:
G1 X#4 Y#5 F#6
G1 X#7 Y#8 Z#9
G1 X#10 Y#11 Z#12
This call will produce
G1 X5 Y3 F40
G1 X-1 Y2 Z0
G1 X0 Y0 Z0
Example 3:
Suppose a piece is to have notches of different lengths and depths along the x-axis: