The Language of G-Code

G-code is the primary language used to control CNC (Computer Numerical Control) machines. It consists of a series of commands that instruct a machine tool, such as a mill, lathe, or router, on how to move and operate. These commands specify details such as tool movement, feed rate, spindle speed, and coolant operation. The foundation of G-code is RS274, an early standard developed by the Electronic Industries Association (EIA) to define the syntax and structure of CNC programming. RS274 has since been expanded and formalized into ISO 6983, which serves as the international standard for G-code. However, manufacturers have modified and extended RS274-based G-code to fit their specific machine controllers, leading to variations in implementation across different CNC brands.

The core structure of G-code follows the RS274 conventions, which define the use of G-codes (preparatory functions) for specifying movement types, such as G00 for rapid positioning, G01 for linear interpolation (cutting moves), and G02/G03 for circular interpolation. Additionally, M-codes (miscellaneous functions) handle machine-specific operations, such as spindle control (M03/M05), coolant activation, and program stops. Other commands define parameters like feed rate (F), spindle speed (S), tool selection (T), and machine coordinates (X, Y, Z).

Despite the standardization efforts in RS274 and ISO 6983, CNC manufacturers such as Fanuc, Haas, Siemens, and Heidenhain have introduced proprietary extensions to G-code, resulting in variations between controllers. Consequently, while the fundamental principles of RS274-based G-code remain consistent, programmers must reference machine-specific manuals to account for these differences when writing or modifying CNC programs.

The Language of G-Code

G00 – Rapid

G00 – Rapid
Rapid move to a point. (Not necessarily in a straight line!) G0 (G zero) tells the machine to move as quickly as possible to a given point (absolute or relative, depending on the setting of G90 or 91). This command is modal, so any coordinates that follow will be rapid as well (until a Group 01...

G01 – Linear Interpolation

G01 – Linear Interpolation
Linear move at a specified feed rate.  It can cut in a single axis, or using multiple axes. It is a modal command, so any coordinates that follow it will be treated as liner move destinations or distances (see G90/G91) until another command cancels it (such as a G00 or G02). G1 is usually used to cut...

G02 and G03 – Circular Interpolation

G02 and G03 – Circular Interpolation
Circular interpolation at a given feedrate. G02 Clockwise arc motion at feedrate.G03 Counterclockwise arc motion at feedrate. The clockwise direction is determined by viewing the arc from the positive side of a vector normal to the arc plane. Like the G01 command, G02 and G03 require a feedrate (F) as well as destination (or distance) coordinates (X, Y, and/or...

G17, G18, and G19 – Plane Selection

Plane Selection Circular milling operations (such as G02 and G03) must be aligned on a plane defined by two axes of motion.  This plane is selected by calling one of these functions. G17 aligns the arc plane with the X and Y axes. G18 aligns the arc plane with the X and Z axes. G19...

G90 and G91 – Absolute Vs. Incremental Coordinates

Interpretation of RS274/NGC code can be in one of two distance modes: absolute or incremental. To go into absolute distance mode, program G90. In absolute distance mode, axis numbers (X, Y, Z, A, B, C) usually represent positions in terms of the currently active coordinate system. Any exceptions to that rule are described explicitly in...
G00 - Rapid

G00 - Rapid

Rapid move to a point. (Not necessarily in a straight line!) G0 (G zero) tells the machine to move...
G01 - Linear Interpolation

G01 - Linear Interpolation

Linear move at a specified feed rate.  It can cut in a single axis, or using multiple axes. It...
G02 and G03 - Circular Interpolation

G02 and G03 - Circular Interpolation

Circular interpolation at a given feedrate. G02 Clockwise  arc motion at feedrate.G03 Counterclockwise...

G17, G18, and G19 - Plane Selection

Plane Selection Circular milling operations (such as G02 and G03) must be aligned on a plane defined...

G90 and G91 - Absolute Vs. Incremental Coordinates

Interpretation of RS274/NGC code can be in one of two distance modes: absolute or incremental. To...