G codes for milling form the foundational language that directs computer numerical control machines to remove material with precision. These alphanumeric instructions tell a milling machine where to move, at what speed, and with what tooling configuration to achieve the desired geometry. Understanding this programming language is essential for anyone involved in modern manufacturing, from the programmer setting up the job to the operator monitoring the cut.
Understanding the G Code Language
At its core, G code is a type of geometric programming that uses blocks of commands to control machine tool functions. Each line of code, or block, typically contains a word—a letter followed by a number—that conveys a specific instruction. While many specific functions exist, the G words are responsible for motion control, dictating the path the cutting tool takes through the workpiece. These commands are the direct link between a CAD design and the physical part being machined.
Modal vs. Non-Modal Commands
Not all G codes behave the same way, and this distinction is critical for efficient programming. Modal commands remain active until they are canceled or overridden by another command in the same group. For example, G01 (linear interpolation) stays active after being specified, allowing the programmer to issue subsequent move commands without restating the G code. Conversely, non-modal commands are effective only for the single line in which they appear, requiring repetition if needed later in the program.
Essential Motion Codes for Milling
The most frequently used G codes in milling applications govern the movement of the spindle and tool. Rapid positioning, controlled cutting feed, and tool return to the clearance plane are the basic actions required to machine a part. Mastery of these fundamental movements ensures both efficiency in the program and safety in the operation.
G00 (Rapid Positioning): This command moves the tool at the machine's maximum safe speed to a specified coordinate. It is used to position the tool quickly between cutting operations without removing material.
G01 (Linear Interpolation): Used for straight-line cutting at a programmed feed rate (F code). This is the primary cutting command for facing, pocketing, and contouring operations.
G02 (Clockwise Circular Interpolation) and G03 (Counterclockwise Circular Interpolation): These codes enable the creation of arcs and circles. The direction is viewed from the opposite side of the spindle, determining whether the tool path curves left or right.
Coordinate System and Plane Selection
Defining the work area is just as important as defining the tool path. G codes establish the coordinate system that the machine uses to interpret positions. Selecting the correct plane ensures that the tool moves in the intended two-dimensional or three-dimensional space relative to the part.
G Code | Function | Description
G17 | Plane Selection | Selects the XY plane for operations, meaning tool movements will occur in the horizontal plane.
G18 | Plane Selection | Selects the ZX plane, useful for operations on vertical faces or specific profiling tasks.
G19 | Plane Selection | Selects the YZ plane, typically utilized for operations on the sides of a part or specific angular cuts.
G20 / G21 | Units Selection | Sets the programming units to Inches (G20) or Millimeters (G21), a critical setting to avoid part rejection.