G66 – Macro Modal Call

Author:

G66 is a G-code for modally calling a custom macro program in CNC machining. A custom macro is a user-defined program that can perform complex tasks, such as machining geometric shapes, calculating coordinates, or setting parameters. G66 allows the user to specify the custom macro number and assign local variables to the value of letter address arguments. The custom macro will be executed after each motion command until G67 is used to cancel the modal calling.

Usage format

The general format for using G66 is:

G66 P_ _ _ _ X_ _ _ _ Y_ _ _ _ Z_ _ _ _ … ;

where P is the custom macro number, and X, Y, Z, etc. are the letter address arguments that will be assigned to the corresponding local variables. The number of arguments depends on the custom macro program.

Explanation

G66 is useful for calling the same custom macro program multiple times with different arguments. For example, if the user wants to machine several round pockets with the same depth, radius, and feed rate, but different center locations, they can use G66 to call a custom macro program that performs the round pocket machining. The user only needs to specify the custom macro number and the common arguments once, and then provide the different X and Y coordinates for each pocket.

However, G66 has some limitations. First, it does not call the custom macro by itself; it only sets the local variables. The custom macro will be called after a motion command, such as G00 or G01. Second, the local variables cannot be updated after the G66 command. The user must use G67 to cancel the modal calling and use G66 again with new arguments if they want to change the local variables.

Example

Here is an example of using G66 to call a custom macro program O1000 that machines a round pocket. The custom macro program O1000 is shown below:

O1000 (Custom Macro for round pocket machining) #32 = #5001 (Get current X absolute position) Z [#26 + 0.1] (Move to approach position) G01 Z [#26 – #7] F [#9 / 2] (Plunge into pocket) G02 X [#32 + #18 – #20 / 2] R [ [#18 – #20 / 2] / 2] F #9 I – [#18 – #20 / 2] (Cut pocket arc) X #32 R [ [#18 – #20 / 2] / 2] (Complete pocket arc) G00 Z [#26 + 0.1] (Retract from pocket) M99 (End of custom macro)

The main program that uses G66 to call O1000 is shown below:

N010 G90 G54 G00 X0 Y0 (Set absolute mode, work offset, and move to origin) N020 G66 P1000 Z0 D0.5 R0.75 T0.5 F5.0 (Set custom macro number and arguments) N030 G00 X5.0 Y5.0 (Move to first pocket center and call O1000) N040 X10.0 (Move to second pocket center and call O1000) N050 Y10.0 (Move to third pocket center and call O1000) N060 X5.0 (Move to fourth pocket center and call O1000) N070 G67 (Cancel modal calling of O1000) N080 M30 (End of main program)

The text diagram below shows the result of the main program. The four round pockets are machined with the same depth, radius, and feed rate, but different center locations.

Y
^
|
|   O   O
|  / \ / \
| O   X   O
|  \ / \ /
|   O   O
|
+--------------> X

Leave a Reply

Your email address will not be published. Required fields are marked *