G66

Machining center, LatheModal, group 12

Modal macro call

Format and notes

G66 P_ L_ arguments … (executes the macro after every following move command)

Example

G90 G54 G00 X0 Y0 ;
G43 H03 Z30. ;
G66 P9020 Z-5. R2. F100. ; (MODE ONLY. NO MOVE HERE)
X10. Y10. ; (MOVE, THEN O9020 RUNS)
X30. ; (MOVE, THEN O9020 RUNS)
Y30. ; (MOVE, THEN O9020 RUNS)
G67 ; (CANCEL)
G00 Z30. ;
M30 ; O9020 ; (DRILL ONE HOLE)
G00 Z#18 ; (#18 = R)
G01 Z#26 F#9 ; (#26 = Z, #9 = F)
G00 Z#18 ;
M99 ;

An example in which the drilling macro O9020 is called each time the tool moves to the three hole positions (X10 Y10, X30 Y10, X30 Y30). Z, R and F in the G66 block are arguments; inside the macro, Z goes into #26, R into #18 and F into #9. The macro is not called by G00 Z30. after G67. The values are for illustration.

Differences between controls and machines

The same code can be written or assigned differently depending on the CNC control and the machine builder. Always check your machine’s manual.

SourceMachineItemDetail
HaasMachining centerAvailabilityG66 and G67 are not in the G-code list (macros are called with G65)
HaasLatheAvailabilityG66 and G67 are not in the G-code list (macros are called with G65)
Mitsubishi ElectricLatheCodeThere is also G66.1 (modal call B), which calls the macro on every block including blocks without a move. During G66.1, the contents of each block are passed as arguments instead of being executed

Frequently asked questions about G66

What is G66 (Modal macro call) used for and how is it formatted in a CNC program?
G66 commands "Modal macro call" on Machining center, Lathe. The standard program format is "G66 P_ L_ arguments … (executes the macro after every following move command)". After G66, the specified macro runs each time a block with a move command ends. Cancel with G67
Is G66 a modal code or a one-shot (non-modal) code?
G66 is a modal code (Group 12). Once commanded, it remains active across subsequent blocks until another code from the same modal group overrides it or the control is reset. Always state or cancel modal states explicitly in your safety block and at the end of a tool operation so residual modes do not cause unexpected motion when restarting mid-program.
Does G66 work differently on machining centers (mills) versus CNC lathes?
G66 is primarily used on Machining center, Lathe. Depending on the machine type and the lathe G-code system (System A, B, or C), this code may be unavailable or assigned to a different function, so verify against your machine tool manual.
Are there differences in G66 across FANUC, Mitsubishi, Okuma, Haas, and Siemens controls?
Yes. Control builders such as FANUC, Mitsubishi Electric (M80/M800), Okuma (OSP), Haas, Mazak, Siemens (SINUMERIK ISO dialect), and Heidenhain can differ in argument letters, decimal-point rules, and optional parameters for G66. Review the control comparison table above and verify the exact syntax in your machine’s programming manual before proving out the program.

Sources

The meaning of this code agrees in two or more sources from different publishers. Explanations are written in our own words.

  1. Siemens AG — SINUMERIK 802D sl/840D/840D sl/840Di/840Di sl/810D Programming Manual ISO Milling, 04.2007 Edition (6FC5398-7BP10-0BA0) cache.industry.siemens.com
  2. Siemens AG — SINUMERIK 802D sl/840D/840D sl/840Di/840Di sl/810D Programming Manual ISO Turning, 04.2007 Edition cache.industry.siemens.com
  3. Mitsubishi Electric — MITSUBISHI CNC 700/70 Series Programming Manual (Lathe System) (IB-1500057) mitsubishielectric.com
  4. Haas Automation, Inc. — Mill Operator's Manual – 17 Mill G-Codes (online version) haascnc.com
  5. Haas Automation, Inc. — Lathe Operator's Manual – 16 Lathe G-Codes (online version) haascnc.com