Printed from Kezuriba (kezuriba.net/en/nc/g66/)
G66
Machining center, LatheModal, group 12Modal macro call
Format and notes
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
- For example, you list only the hole positions and run the same machining macro at each one
- The G66 block only sets the calling mode. Z, R, F and so on written in the G66 block are arguments, and the tool does not move there. The macro is called when the move in a following move-command block finishes (Mitsubishi Electric, Siemens ISO dialect)
- On blocks without a move (a block with only an M-code, a block with only a variable calculation, etc.), the macro is not called. G66.1, which calls the macro on every block even without a move (Mitsubishi Electric “modal call B”), is a different command
- Write the arguments only once, in the G66 block; the same values are passed each time the macro is called. The correspondence between addresses and variables is the same as for G65 (A→#1, R→#18, Z→#26, etc.) (Siemens ISO dialect)
- Use G66 and G67 as a pair in the same program (Siemens ISO dialect, Mitsubishi Electric). If G66 is commanded in the main program, write G67 in the main program too
- Difference from G65: G65 calls once, on the block where it is written. G66 keeps calling after every move until G67
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.
Full guide with examples: Intro to custom macros and subprograms (M98, M99, G65, # variables)
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.
| Source | Machine | Item | Detail |
|---|---|---|---|
| Haas | Machining center | Availability | G66 and G67 are not in the G-code list (macros are called with G65) |
| Haas | Lathe | Availability | G66 and G67 are not in the G-code list (macros are called with G65) |
| Mitsubishi Electric | Lathe | Code | There 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.
- 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
- Siemens AG — SINUMERIK 802D sl/840D/840D sl/840Di/840Di sl/810D Programming Manual ISO Turning, 04.2007 Edition cache.industry.siemens.com
- Mitsubishi Electric — MITSUBISHI CNC 700/70 Series Programming Manual (Lathe System) (IB-1500057) mitsubishielectric.com
- Haas Automation, Inc. — Mill Operator's Manual – 17 Mill G-Codes (online version) haascnc.com
- Haas Automation, Inc. — Lathe Operator's Manual – 16 Lathe G-Codes (online version) haascnc.com