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.