G65

Machining center, LatheOne-shot, group 00

Macro call (simple call, with arguments)

Format and notes

G65 P_ (program number) L_ (repeat count) A_ B_ … (arguments)

Example

G90 G54 G00 X0 Y0 ;
G43 H03 Z30. ;
G65 P9010 X10. Y20. Z-8. R2. F120. I15. K4. ; (4 HOLES, PITCH 15)
G00 Z30. ;
M30 ; O9010 ; (DRILL A ROW OF HOLES)
#30 = 0 ; (COUNTER)
WHILE [#30 LT #6] DO1 ; (#6 = K: NUMBER OF HOLES)
G00 X[#24 + #30 * #4] Y#25 ; (#24 = X, #4 = I, #25 = Y)
Z#18 ; (#18 = R)
G01 Z#26 F#9 ; (#26 = Z, #9 = F)
G00 Z#18 ;
#30 = #30 + 1 ;
END1 ;
M99 ;

An example that calls macro O9010, which drills 4 holes at 15 mm intervals in the X direction starting from X10. Y20., from R2. down to Z-8. at F120. Inside the macro, X is in #24, Y in #25, Z in #26, R in #18, F in #9, I in #4 and K in #6. #30 is a local variable that receives no argument and is used to count the holes. 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 centerNotesG65 calls can be nested up to 9 levels
Mitsubishi Electric—FormatInstead of a number, the call can use a file name, as in G65 <file name> L_ arguments

Frequently asked questions about G65

What is G65 (Macro call (simple call, with arguments)) used for and how is it formatted in a CNC program?
G65 commands "Macro call (simple call, with arguments)" on Machining center, Lathe. The standard program format is "G65 P_ (program number) L_ (repeat count) A_ B_ … (arguments)". Unlike M98, arguments can be passed by address (A, B, X, Z, etc.). The passed values go into the macro's local variables
Is G65 a modal code or a one-shot (non-modal) code?
G65 is a one-shot (non-modal, Group 00) code. It acts only in the single block where it is written and does not carry over to the next block, so you must write G65 on every line where that action is required.
Does G65 work differently on machining centers (mills) versus CNC lathes?
G65 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 G65 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 G65. 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. Haas Automation, Inc. — G-code, M-code, and Setting (per-code explanation pages) haascnc.com
  3. Haas Automation, Inc. — Mill Operator's Manual – 17 Mill G-Codes (online version) haascnc.com
  4. Haas Automation, Inc. — Lathe Operator's Manual – 16 Lathe G-Codes (online version) haascnc.com
  5. Haas Automation, Inc. — Mill Operator's Manual – 13 Macros (online version) haascnc.com
  6. Mitsubishi Electric — MITSUBISHI CNC 700/70 Series Programming Manual (Lathe System) (IB-1500057) mitsubishielectric.com