Glossary · CNC and machine tools
G-code
Also known as: Preparatory function, G word
German: G-Code
In CNC programming, a G-code is a preparatory function, written with the address letter G and a number, that tells the control how to perform the following movement or which mode to use, for example linear interpolation (G01) or circular interpolation (G02, G03).
- CNC
- Standards
In one sentence
A G-code is a preparatory function in a CNC program, such as G01 for linear interpolation, that sets how the control executes movements.
Example
G00 X0 Y0 moves the tool at rapid traverse to the zero point; the next block G01 Z-5 F100 starts a linear cut at 100 mm/min.
How it applies
- Programming: ISO 6983-1 (and DIN 66025 in Germany) standardizes the basic format and many G-codes, but controls from different vendors extend and interpret them differently. A program written for one control is not automatically correct on another.
- CAM: Postprocessors in Computer-aided manufacturing (CAM) systems translate tool paths into the G-code dialect of a specific machine and control.
- Documentation: A G-code reference in machine documentation should list the codes actually supported by that machine, mark which are Modal commands and name the control and software version. Don't copy a generic G-code table without checking it against the control vendor's programming manual.
G-code vs. M-code
G-codes prepare and define movements and modes. M-codes are miscellaneous functions that switch machine functions such as spindle, coolant or tool change. In everyday speech, 'G-code' is also used for a complete NC program.