Intrex, an experienced defense machining company

CNC Programming: G & M codes

Aug 16, 2023

CNC programming is a critical part of modern manufacturing. Most machining is now done on CNC machines instead of older manually operated equipment. Understanding G & M codes is foundational to successful CNC programming. At Intrex Aerospace, we have made significant investments in CNC equipment. Our engineering staff, some with 40+ years of machining experience, are very knowledgeable of CNC machine tools and the programming language that allows us to optimize our machines for maximum output and efficiency.

A common question asked by people aware of what CNC machines are capable of but unfamiliar with how they operate is: how are they programmed? This a great question, and the answer is that most CNC machines use three basic CNC machine programming methods — manual, conversational, and CAM system programming. Intrex uses the most prominent method, CAD/Cam software primarily.

CAD (computer-aided design) software defines part configuration (sizes/shapes), that raw information is then transferred into a CAM (computer-aided machining) software, where it is translated into machined data points via a programming language the machine tool controller recognizes. This machine programming code controls facets of the machine tool function: machine axis movements, spindle speeds, coolant on/off, etc.

Basic machining has existed since the advent of the industrial revolution, but the first CNC machines were developed following WWII. In 1952 a collaboration between IBM (International Business Machines) and MIT (Massachusetts Institute of Technology) developed a milling machine. Along with the development of CNC machines, there were also several forms of CNC programming language. Through the 50’s and 60’s years, a widely accepted language standard was developed. It was named RS-274.

Screen Shot at

What Are G Codes and M Codes?

RS-274, or G-code, was developed from the APT programming language. The APT contained data about cutting tool location, tool geometry, and other non-geometry machine functions (spindle speed, coolant on/off, etc.). Using the G and M code format allows the programs to be shorter and more convenient for the machine controller.

APTG and M codes
GO TO {X, Y, Z}G1, G2, G3 {X, Y, Z}

What Are G Codes?

 G code or G functions are distinct from M code functions. They are primarily related to defining geometry. G code means the word “Geometry.” G codes include functions for selecting the coordinate system, working plane, programming units, setting the programming mode (absolute or incremental), tool movement in rapid and working mode, etc.

What Are M Codes?

 M codes or M functions are related to the operation of the machine. M in the term “M code” means “Machine.” Usually, in CNC machine programming, the following functions can be included in these functions: Switching the main spindle on or off, turning the coolant on or off, automatic tool change, etc.

To simplify it, G codes show: How the tool moves in relation to the workpiece, and the M codes” is what the machine does in the machining process”.

The G code and M codes also have multiple auxiliary functions. Task-specific CNC programming codes, identified by different letters of the alphabet, tell the machine tool when, where, and how to remove material from the raw stock. Below is a listing of the program letter designations that are shown in the program and their function:

  • X,Y, Z – positioning point coordinates
  • I,J, K – coordinates of the distance between the start point and circle center
  • F- interpolation speed
  • S- spindle speed
  • T- tool number
  • H- tool height offset number
  • D- tool radius offset number

List Of Basic G Codes

Main functionsDescriptionAuxiliary functions
G0Rapid positioning (linear)X, Y, Z
G1Linear interpolationX, Y, Z, F
G2Clockwise circular interpolationX, Y, Z, I, J, K, F
G3Counter clockwise circular interpolationX, Y, Z, I, J, K, F

 Having a working knowledge of CNC programming for those not directly involved in machining is not critical, even for those involved in purchasing complex machined parts, but among our goals at Intrex Aerospace is posting articles on our website that inform and educate. Understanding CNC Programming: G & M codes gives exposure to some aspects of the manufacturing process that may stimulate interest for those wanting to pursue a career in manufacturing.

If you are one of those who have an interest in manufacturing, we welcome you to have further conversations with us. Please click here and we will contact you.

High-Level Services

Intrex Aerospace is a world-class manufacturer of precision CNC machined components for the aviation, defense, and space industries.

Supply Chain Buyer
Intrex Aerospace Reviews Intrex Aerospace Reviews Intrex Aerospace Reviews Intrex Aerospace Reviews Intrex Aerospace Reviews

"Intrex has excellent customer service. They honor their commitments. I enjoy working with the entire team."

Aerospace Quality Manager
Intrex Aerospace Reviews Intrex Aerospace Reviews Intrex Aerospace Reviews Intrex Aerospace Reviews Intrex Aerospace Reviews

"We can count on Intrex to take critical to quality work. They are a superior company focused on quality and customer service."

Aerospace Supply Chain Manager
Intrex Aerospace Reviews Intrex Aerospace Reviews Intrex Aerospace Reviews Intrex Aerospace Reviews Intrex Aerospace Reviews

"Intrex is a strategic supplier of ours. We consider them our partner. We can count on them and when a key project is in their hands, I never worry."

Work With Us

We Need Your Skills

Intrex Aerospace is a growing, dynamic organization. We are proud of our rich and rewarding work environment. We place great value on our employees and recognize the key role they play in our continued success. Being in a growth industry, we are always looking to attract and develop new, motivated employees.

Apply Now