Journal logo

G And M-Codes: The Difference Between The Two With Examples

We studied G and M-codes in our Engineering course of studying CAM (Computer Aided Manufacturing) in this article I will share my learning and differentiate between G and M-codes.

By Intelligent CreatorPublished about a year ago 3 min read
G And M-Codes: The Difference Between The Two With Examples
Photo by Sigmund on Unsplash

In CAM (Computer Aided Manufacturing) which was one of our subjects during our engineering course. In this article, we will discuss the difference between G and M-codes used in CAD. In CNC programming we used G and M-codes which will help you give a command line to the machine.

Programming is very difficult and if you stop practicing it, you will lose the command over it. In this case, we will discuss the different types of CNC programming based on position then we will discuss G and M-codes with an example.

Types of CNC Programming:

There are two types of CNC programming;

1. Absolute programming: In absolute programming, the point of reference is the same. If you are starting with the bottom-left point in drawing apart then your point of reference will be the same. The X or Y coordinates will be changing based on your first reference point.

2. Relative programming: In relative programming, the point is always changing. In the first case, any two of the coordinates, one might be zero or in some cases, both might be zero. Relative programming just takes that point as a reference and check whether the "X" or "Y" coordinates might be zero.

What are G and M-codes?

"G" stands for Geometric while "M" stands for Machine. The G-codes are used for discussing or giving dimensions to a Geometry of a tool or part they are designing. M-codes are used for giving command line to machine-like turning On/Off and changing the directions of the tool.

Following are some of the G-codes.

  • N: The N value gives the line number.
  • G: The G number tells when the tool moves and stop.
  • X, Y, Z: These values indicate the position of the tool in three dimensions — X for horizontal, Y for vertical, and Z for depth.
  • F: F relates to how quickly the machine feeds the piece.
  • S: S tells the machine how quickly to move the spindle.
  • T: The T tells the machine which tool to use.
  • M: M values give miscellaneous functions or machine functions, telling the device how to act by giving on and off directions.
  • I and J: These values indicate the incremental center of any arcs the machine makes.
  • R: R gives the radius of arcs made by the machine.
  • A: A values direct the tool around the x-axis.
  • B: The number with B shows the rotational value around the y-axis.
  • C: An auxiliary axis that rotates around the z-axis gets its positional value from the C value.
  • D: This number shows how much the system offsets the tool diameter.
  • L: L gives the system a value to indicate repeating operations and how many times they need to loop.
  • P: The program jumps in time or a delayed time with the P command.

Following are some examples of M-codes:

  • M00:Stop whatever program is currently operating — axes, coolant flooding, or spindle.
  • M01: This command indicates an optional stop for the program.
  • M02: End of the currently running program.
  • M03: Begin to move the spindle clockwise.
  • M04: Start moving the spindle counterclockwise or in reverse.
  • M05: Stop moving the spindle.
  • M06: Load on a different tool. Typically, this command comes with the T value. For example, you may see "T1 M06."
  • M08: Start flooding the system with coolant.
  • M09: Stop the coolant flow.

The difference between G and M-codes:

1. The G-codes are used for designing the part or tool. The M-codes are used for giving a command-line to the machine.

2. G stands for Geometric which is concerned with the Geometry of the product. M stands for Machine.

3. G-codes activates the Numerical Control part of the CNC machine while the M-codes activates the PLC of the CNC machine.

how tohow to

About the Creator

Intelligent Creator

My posts are informational & something I do great research for SEO before writing it. Writing posts to make you more intelligent.

Work with OFAgency: Join OFAgency.co as a Creator here

Sell Feet Pics on FeetFinder here.

Reader insights

Be the first to share your insights about this piece.

How does it work?

Add your insights

Comments

Intelligent Creator is not accepting comments at the moment
Want to show your support? Become a subscriber or send them a one-off tip.

Find us on social media

Miscellaneous links

  • Explore
  • Contact
  • Privacy Policy
  • Terms of Use
  • Support

© 2026 Creatd, Inc. All Rights Reserved.