CNC

Basics of G Code Programming 231

This class introduces learners to the fundamentals of G code programming, including program blocks, toolpaths, the use of CAD and CAM software, and the function of different address letters. Learners will explore how to read, write, and organize part programs, as well as how to plan and simulate toolpaths for efficient and accurate machining. The course also covers key coding elements such as coordinate codes, feed and speed commands, and tool selection and control, culminating in a step-by-step walkthrough of a sample program in action.

Understanding G code part programs is essential for operating CNC machines effectively in manufacturing. Learners who complete this class will understand how to translate design data into executable programs, optimize machining sequences, and reduce errors, ultimately improving production efficiency, part quality, and workplace safety.

  • Difficulty Intermediate

  • Format Online

  • Number of Lessons 14

  • Language English

Take the Next Step in Workforce Training

Talk with a Tooling U-SME specialist about class options and pricing.

1.866.706.8665

Contact Form

Course Outline
  • CNC Part Programs
  • CAD and CAM in Programming
  • Creating a Part Program
  • Review: Sequence of Part Machining
  • G Code Program Structure
  • G Codes
  • Programming Coordinates
  • Coordinate Codes
  • Review: Coordinates and Programming Blocks
  • F and S Codes
  • T and M Codes
  • Other Code Types
  • Part Program Walkthrough
  • Review: Word Types
Objectives
  • Describe the role of a CNC part program.
  • Describe the role of CAD and CAM in CNC programming.
  • Identify the major steps in creating a CNC program.
  • Identify the components of a G code program.
  • Describe the function of G codes.
  • Explain how the Cartesian coordinate system impacts CNC programs.
  • Describe the function of coordinate codes.
  • Describe the function of F and S codes.
  • Describe the function of T and M codes.
  • Identify additional code types.
  • Explain how a CNC program runs step-by-step.
Glossary
Vocabulary Term
Definition

A axis

The axis that describes motion around the X axis. A axis movement in CNC machining is generally only available on multi-axis machines.

A code

A G code programming command that gives a position on the A axis. A codes help control rotation around the X axis.

additive manufacturing

AM. The process of joining or solidifying materials to make an object based on a three-dimensional computer model. Additive manufacturing methods typically build up layers of material to create an object.

address

The letter used within a word of G code programming. Address letters signal the word’s essential function.

American Standard Code for Information Interchange

ASCII. A universal code language that uses standardized numeric codes to represent letters, numbers, and symbols. The American Standard Code for Information Exchange allows different computers, CNC machines, and software systems to read, store, and share part programs.

B axis

The axis that describes motion around the Y axis. B axis movement in CNC machining is generally only available on multi-axis machines.

B code

A G code programming command that gives a position on the B axis. B codes help control rotation around the Y axis.

blocks

A single line of a G code part program. Blocks are composed of words that together instruct the machine on operations, positions, and movement.

C axis

The axis that describes motion around the Z axis. C axis movement in CNC machining is generally the rotation of the machine spindle.

C code

A G code programming command that gives a position on the C axis. C codes help control rotation around the Z axis.

CAM

Computer-aided manufacturing. The use of computer software to generate part programs from digital models. CAM software creates toolpaths and program code to ensure accurate machining.

Cartesian coordinate system

A numerical system that locates points and defines movement by their locations along three perpendicular linear axes and three rotational axes. The Cartesian coordinate system is used to program machining positions on a CNC machine.

character encoding

A system that assigns numeric codes to letters, numbers, and symbols so computers can store and transmit information. Character encoding allows CNC machines and software to interpret part programs consistently across different platforms.

CNC

Computer numerical control. A self-contained system of computers and precision motors that executes program instructions to guide machine tool components and manufacture parts. CNC machines use part programs to automate cutting operations and produce consistent parts.

commands

An instruction in a part program that tells a machine to perform a specific action or movement. Commands are written with code words that the machine control reads and follows.

computer numerical control

CNC. A self-contained system of computers and precision motors that executes program instructions to guide machine tool components and manufacture parts. Computer numerical control machines use part programs to automate cutting operations and produce consistent parts..

computer-aided design

CAD. The use of software to create digital representations of parts or assemblies. Computer-aided design models provide precise dimensions and features that guide manufacturing and part program creation.

computer-aided manufacturing

CAM. The use of computer software to generate part programs from digital models. Computer-aided manufacturing software creates toolpaths and program code to ensure accurate machining.

coordinates

A value that identifies a position on a machine axis. Coordinates tell the CNC machine where the tool or workpiece should move.

cutter compensation offset

A stored value that adjusts the toolpath for the size of the cutting tool. Cutter compensation offsets help the machine cut the correct part size.

cutting fluid

Any fluid used to cool, lubricate, and clear chips during metal cutting. Cutting fluid in CNC operations is controlled by the part program to optimize cutting performance and tool life.

cutting operations

A process in which material is removed from a workpiece to shape it. A cutting operation uses specific tool movements and parameters to achieve the desired part geometry.

cutting tool

A device used to remove material from a workpiece during a cutting operation. A cutting tool may have one or multiple cutting edges and is selected based on the material and shape to be machined.

cutting variables

A setting that affects how a cutting tool removes material from a workpiece. Cutting variables include feed, speed, and depth of cut.

D codes

A word that identifies a cutter compensation offset. D codes help the machine adjust the toolpath based on the cutter’s size.

dry run

A preliminary operation to ensure that the part program will machine workpieces properly. A dry run allows operators to verify the program and toolpath before actual machining begins.

F code

A word in a part program that determines the feed rate during a cutting operation. F codes are usually given in ipm, ipr, mm/min, or mm/rev.

features

A distinct geometric element of a part, such as a hole, pocket, or contour. Features define the specific shapes and details that must be machined on a workpiece.

feed

The rate at which the cutting tool and workpiece move past one another. Feed affects how quickly the tool removes material during a cutting operation.

feed rate

The speed at which the cutting tool and workpiece move past one another during machining. Feed rate is programmed with an F code and is measured in units such as inches per minute (ipm) or millimeters per minute (mm/min), depending on the machine and operation.

G code programming

A programming language that pairs address letters with numerical values to form commands. G code programming directs CNC machine movements.

G00

The G code command for rapid positioning. G00 moves the cutting tool quickly to a specified location before starting a cutting operation.

G01

A G code command for linear interpolation. G01 moves the cutting tool along a straight line.

G20

A G code command that sets programming units to inches. G20 ensures that a CNC machine interprets distances, coordinates, and cutting variables using the English system.

G21

A G code command that sets programming units to millimeters. G21 ensures that a CNC machine interprets distances, coordinates, and cutting variables using the metric system.

geometry

The size, shape, and spatial relationships of the surfaces and features of a part or cutting tool. Geometry provides the information needed to plan toolpaths and ensure accurate manufacturing.

H codes

A word that identifies a tool length offset. H codes help the machine adjust for the length of the cutting tool.

inches per minute

Ipm. A unit that measures how many inches the tool moves in one minute. Inches per minute is commonly used to measure feed.

inches per revolution

Ipr. A unit that measures how many inches the tool moves for each rotation of the spindle or workpiece. Inches per revolution is commonly used to measure feed on lathes.

ipm

Inches per minute. A unit that measures how many inches the tool moves in one minute. Ipm is commonly used to measure feed.

lathes

A machine tool that rotates a workpiece against a cutting tool to remove material. Lathes are typically used to produce cylindrical or round parts.

linear axes

Straight reference line used to define an object's location or movement in space. The linear axes in the Cartesian coordinate system are the X, Y, and Z axes.

linear interpolation

A cutting movement in a straight line from one point to another. Linear interpolation uses coordinate values to guide the tool along a straight path.

live tooling

Rotating cutting tools used on a lathe. Live tooling allows a lathe to perform operations such as drilling or milling.

M code

A word in a part program that signals a miscellaneous machine action. M codes control functions including tool changes, spindle rotation, cutting fluid, or workpiece clamps.

machine control unit

MCU. A small, powerful computer that controls a CNC machine. Machine control units interpret part programs and allow you to enter information or make adjustments to the machine.

machine tool

A power-driven machine that shapes or cuts material to make a part. Machine tools include CNC mills, lathes, and machining centers.

machine zero

The home position or origin for a machine’s axes and components. Machine zero is a position that is permanently set by the manufacturer of each particular CNC machine.

meters per minute

M/min. A unit that measures how many meters of workpiece surface pass the cutting edge in one minute. Meters per minute is commonly used to describe cutting speed on metric machines.

millimeters per minute

Mm/min. A unit that measures how many millimeters the tool moves in one minute. Millimeters per minute is commonly used to measure feed on metric machines.

millimeters per revolution

Mm/rev. A unit that measures how many millimeters the tool moves for each rotation of the spindle or workpiece. Millimeters per revolution is commonly used to measure feed on metric lathes.

mills

A machine tool that removes material from a workpiece using a rotating multi-point cutting tool. Mills are commonly used to create flat surfaces, slots, and complex 3D shapes on parts.

modal

A characteristic of certain G codes that remain active until another code changes or cancels them. Modal G codes do not need to be repeated in every program block because the machine continues using the last active command.

model

A digital or physical representation of a part or assembly. Models serve as the basis for design review, simulation, and toolpath generation.

multi-axis

A type of CNC machine that uses more than three machine axes. Multi-axis machines can move or rotate the tool or workpiece in several directions to cut more complex shapes.

N code

A word that acts as the name or title for a G code program block. N codes usually increase in increments of ten to help organize and troubleshoot part programs.

output signals

Digital information that a computer or other electronic device sends to another device. Output signals in CNC machining control, activate, or adjust machine functions.

part programs

A series of alpha-numeric instructions that direct a CNC machine to perform the necessary sequence of operations to machine a specific workpiece. Part programs can be stored and reused on a machine to create multiple identical parts.

program zero

The position that acts as the origin, or starting point, for the part program of a particular workpiece. Program zero is unique to each workpiece design and is selected by the part programmer.

R codes

A word that can define an arc radius or another machine-specific value. R codes are often used with circular interpolation commands.

revolutions per minute

Rpm. A unit that measures how many times a spindle, tool, or workpiece rotates in one minute. Revolutions per minute is commonly used to measure spindle speed.

rotational axes

Imaginary reference axis used to define rotational position or movement around a linear axis. The rotational axes in CNC machining are the A, B, and C axes, which rotate around the X, Y, and Z axes, respectively.

rpm

Revolutions per minute. A unit that measures how many times a spindle, tool, or workpiece rotates in one minute. Rpm is commonly used to measure spindle speed.

S code

A word in a part program that determines the spindle speed during a cutting operation. S codes are usually given in revolutions per minute, surface feet per minute, or meters per minute.

speed

The rate at which the machine spindle rotates. Spindle speed affects how quickly the cutting tool or workpiece moves at the point of contact.

speed

The rate at which the spindle or rotating tool turns. Speed affects how fast the cutting edge moves against the workpiece.

spindle

The part of a machine tool that rotates. Spindles may rotate either a workpiece or a cutting tool, depending on the machine type.

standardized

Using an established rule or set of expectations. Standardized coordinates, programming codes, and machine settings ensure that part programs function correctly on a variety of machines and setups.

surface feet per minute

Sfm. A unit that measures how fast the cutting edge moves across the workpiece surface. Surface feet per minute is commonly used to describe cutting speed.

surface speed

The speed at which the surface of a rotating cutting tool or workpiece moves past the cutting edge. Surface speed is typically measured in surface feet per minute (sfm) or meters per minute (m/min) and can be converted to rpm for programming an S code.

T code

A word in a part program that selects a specific cutting tool for a tool change. T codes indicate the tool’s position in a turret or toolchanger and ensure the correct tool is used for each operation.

tool length offset

A stored value that adjusts for the length of a cutting tool. Tool length offsets help the machine position the tool correctly along the Z axis.

toolchanger

A device on a milling machine that organizes multiple cutting tools and positions them for automatic changes. The toolchanger also stores tools between uses to reduce setup time and improve efficiency.

toolpath

A series of program blocks that describes the movement of a single cutting tool. Toolpaths ensure accurate and efficient cutting operations.

turret

A lathe component that holds multiple cutting tools and rotates to place the correct tool in position. The turret allows you to use multiple tools in one setup.

word

The pairing of an address letter and a numerical value in a part program. Words combine to form a block that tells the machine what operation to perform, where, and how.

workholding devices

Equipment used to support, locate, and clamp a workpiece for a manufacturing operation. Workholding devices, such as vises, clamps, chucks, and collets, ensure the part remains stable and accurately positioned.

workpiece

A part that is in the process of being manufactured. A workpiece may be a complete product in itself or one component of a larger assembly.

X axis

The linear axis representing coordinate positions along a line parallel to the longest edge of the worktable. The X axis usually runs left to right and defines horizontal movement.

X code

A word in a part program that indicates a specific position along the X axis. X codes command both CNC mills and CNC lathes to move a tool or workpiece in the X axis.

Y axis

The linear axis representing coordinate positions along a line parallel to the shortest edge of the worktable. The Y axis usually runs back and forth and defines depth or front-to-back movement.

Y code

A word in a part program that indicates a specific position along the Y axis. Y codes are typically used in CNC mills but not in CNC lathes.

Z axis

The linear axis representing coordinate positions along a line parallel to the spindle. The Z axis usually runs up and down and defines vertical movement of the tool or workpiece.

Z code

A word in a part program that indicates a specific position along the Z axis. Z codes command both CNC mills and CNC lathes to move a tool or workpiece in the Z axis.