This is a complete Fanuc Macro which works same as Fanuc G81 Drilling Cycle.
G66 Modal Call
Once Fanuc G66 is issued to specify a modal call a macro is called after a block specifying movement along axes is executed. This continues until G67 is issued to cancel a modal call.
Macro Call Parameters
G65 P9110 X x Y y Z z R r F f L l ;
X: X coordinate of the hole (absolute only) . . . (#24)
Y: Y coordinate of the hole (absolute only) . . . (#25)
Z: Coordinates of position Z (absolute only). . . (#26)
R: Coordinates of position R (absolute only). . . (#18)
F : Cutting feedrate . . . . . . . . . . . . . . . . . . . .. . . (#9)
L: Repetition count
O0001; G28 G91 X0 Y0 Z0; G92 X0 Y0 Z50.0; G00 G90 X100.0 Y50.0; G66 P9110 Z–20.0 R5.0 F500; G90 X20.0 Y20.0; X50.0; Y50.0; X70.0 Y80.0; G67; M30;
O9110; #1=#4001; (Stores G00/G01) #3=#4003; (Stores G90/G91) #4=#4109; (Stores the cutting feedrate) #5=#5003; (Stores Z coordinate at the start of drilling) G00 G90 Z#18; (Positioning at position R) G01 Z#26 F#9; (Cutting feed to position Z) IF[#4010 EQ 98]GOTO 1; (Return to position I) G00 Z#18; (Positioning at position R) GOTO 2; N1 G00 Z#5; (Positioning at position I) N2 G#1 G#3 F#4; (Restores modal information) M99;