With Fanuc controls, a special series of parameters is used to create user defined G codes. As with all parameters, specific parameter numbers vary from one control model to the next, meaning you must reference the custom macro B section of your manual to find the parameters related to user defined G codes.
With a 16 series Fanuc control, parameter number 6050 can contain the G code number used to activate program number O9010. (There are nine more user defined G code parameters available). If, for example, you place a value of 24 in parameter number 6050 (on a 16 series control), the machine will execute program O9010 whenever it sees a G24 command.
When you create user defined G codes, of course, you must be careful not to overwrite a needed G code. Fanuc allows you to choose three-digit values (100, 101, 102, etc.) to ensure that you don’t overwrite a needed G code.
Again, if a value of 24 is in the parameter related to program O9010, G24 will cause the machine to execute program O9010. But to this point, the calling command (G24) will not be modal.
To create modal user defined G code, the value placed in the parameter (6050 in our case) must be negative. So if the value -24 is placed in parameter 6050, G24 will behave like the G66 command – meaning the machine will continue to move and execute program O9010 with each successive command – until the modal calling command is cancelled.
As you know, G67 is the canceling command. However, if you are trying to create a modal hole-machining canned cycle, it may be inconvenient to use G67 to cancel. We recommend creating a second, more universal cancellation command. I like to modify the use of G80 for this purpose.
To do so, we place a value of 80 in parameter number 6051 (again, for a 16 series control). From now on, when G80 is seen, program number O9011 will be executed. Here is the simple cancellation custom macro number O9011.
O9011 (Cancellation custom macro)
G80 (Cancel canned cycle)
G67 (Cancel modal custom macro call)
M99 (End of custom macro)
With this method intact, G80 will cancel both canned cycles and modal custom macro calling commands. Here is our final version of the program, which more closely resembles the use of canned cycles.
O0002 (Main program)
N005 T01 M06 (Load drill in spindle)
N010 G90 S600 M03 (Start spindle)
N015 G00 X1.0 Y1.0 (Move to first hole location)
N020 G43 H01 Z0.1 M08 (Instate tool length compensation, move above work surface)
N025 G24 R0.1 Z-0.75 F8.0 W-1.0 H3.0 (Set variables)
N030 X1.0 Y1.0 (Machine first hole)
N035 X2.0
N040 X3.0
N045 X4.0
N050 X5.0
N055 G80 (Cancel modal call)
N060 G91 G28 Z0 M19 (Retract to tool change position)
N065 M01 (Optional stop)
.
.
.
Your the best