G-code, also known as RS-274, is a language used to program computer numerical control (CNC) machines, including milling machines, lathes, 3‑axis routers, laser cutters, and 3‑D printers. The code directs the actions of a machine tool by specifying tool paths, feed rates, spindle speeds, and other operational parameters. While the original standard was defined by the Electronic Industries Alliance (EIA) as RS‑274-D, subsequent revisions and de facto extensions have led to a family of dialects tailored to particular manufacturers and machine types.
Historical Development
The term “G-code” derives from the “G” commands that form the core of the language, where “G” stands for “geometry” or “go”. Early CNC systems in the 1950s and 1960s employed simple point‑to‑point instructions; the formal RS‑274 standard was first published in 1968. Over the following decades, the language was expanded to incorporate additional functions such as circular interpolation (G02/G03), canned cycles for drilling (G81‑G89), and coordinate system selection (G54‑G59). Industry‑specific variations, notably Fanuc, Haas, and Heidenhain dialects, have added proprietary codes and parameters while preserving compatibility with the core RS‑274 syntax.
Structure and Syntax
A typical G-code program consists of a series of blocks, each block containing one or more words. A word is a letter followed by a numeric value, for example, “G01 X10.0 Y5.0 F1500”. The primary categories of words include:
- G‑words – Command the type of motion or function (e.g., G00 rapid positioning, G01 linear interpolation, G02/G03 circular interpolation).
- M‑words – Control auxiliary functions such as spindle start/stop, coolant on/off (e.g., M03, M05, M08, M09).
- X, Y, Z – Define target positions along the respective axes.
- F – Specify feed rate.
- S – Set spindle speed.
- T – Select tool number.
Blocks can also contain comments, denoted in various ways depending on dialect (e.g., parentheses “(comment)”, semicolon “; comment”, or slash “/ comment”). Execution proceeds sequentially unless altered by flow‑control commands (e.g., conditional jumps, subprogram calls).
Machine Tool Operation
When a CNC controller reads a G-code program, it translates each block into coordinated motion of stepper or servo motors, typically via a real‑time motion planner. The controller maintains a reference coordinate system (absolute or incremental) and may compensate for tool length, tool radius, and workpiece offsets. Advanced controllers support adaptive feed, tool wear monitoring, and integration with computer‑aided manufacturing (CAM) software.
Standards and Interoperability
The ISO 6983 standard (ISO G-code) is an international adaptation of the RS‑274 series, providing a common baseline for interchange between equipment from different manufacturers. However, complete interoperability is limited because many vendors implement extensions not covered by ISO, such as custom macro variables, user‑defined functions, or specific safety protocols.
Applications
G-code is employed across diverse manufacturing sectors:
- Aerospace and automotive – High‑precision milling and turning of metal components.
- Electronics – PCB drilling and routing.
- Fabrication – CNC wood carving, metal fabrication, and signage.
- Additive manufacturing – 3‑D printers that interpret G-code to control filament extrusion, laser sintering, or resin curing.
Related Technologies
Alternative programming paradigms for CNC include STEP‑NC (ISO 14649), which uses a feature‑based approach, and newer high‑level languages such as Python‑based CNC controllers. Nevertheless, G-code remains the dominant language for direct machine instruction due to its simplicity, widespread adoption, and extensive tooling support.
References
- EIA RS‑274-D (1968) – Original specification of the G-code language.
- ISO 6983 – International standard for CNC programming.
- Fanuc, Haas, Heidenhain technical manuals – Manufacturer‑specific dialect documentation.
See also
- Computer numerical control (CNC)
- CNC milling
- CNC lathe
- STEP‑NC
- CAM (computer‑aided manufacturing)