Close Button
ShopSabre Blog
made in usa
August 09, 2022

Understanding G-Code and M-Code in CNC Work

By scribe


CNC machines provide a massive productivity and precision boost over manual methods, all thanks to the computer-driven nature of their operation. But those advantages don’t just take shape automatically.

CNC machines are driven by codes that tell the machine how and where to cut. There are two main types of codes CNC operators use – G-codes and M-codes – both of which are needed in order for the system to properly perform a desired job.

The complexity and intricacy of these codes is what allows CNC machines to perform such precise cuts. But rather than having to input code manually, most operators use CAD/CAM software to help do the heavy lifting. The operator tells the software what to do, and it creates the code for the machine to understand.

Here is a closer look at what G-code and M-code are and how they work together to drive the functionality of CNC machines.

What is G-Code?

G-code is the original and most common programming language used by CNC software, with the “G” standing for “geometry.” It is an alphanumeric format the system uses to tell the machine what to do, dictating how and where the machine moves to create the part.

Some basic examples of G-code include:

  • G0: Move as fast as possible to a specified coordinate
  • G1: Move in a straight line
  • G2: Create an arc in a clockwise direction
  • G3: Create an arc in a counterclockwise direction

What is M-Code?

M-code, on the other hand, is a function inside the G-code language that controls miscellaneous machine functions not involved with cutting. This includes the stopping and starting of specific actions or programs. Some refer to M-code as “machine code.”

Some basic examples of M-code include:

  • M00: Stop whatever program is currently operating (axes, coolant flooding, or spindle)
  • M01: Indicates an optional stop for the program
  • M02: End of the currently running program
  • M03: Begin to move the spindle clockwise

M-code is not the only function within the G-code language, which includes an extensive series of functions all defined by a given letter that tells the machine how to move.

These additional codes include:

  • N: Gives the line number
  • G: Tells the tool when to move and stop
  • X, Y, Z: Indicate the position of the tool along the x, y, and z axes
  • F: Indicates how quickly the machine feeds the workpiece
  • S: Tells the machine how quickly to move the spindle
  • T: Tells the machine which tool to use
  • I and J: Indicate the incremental center of any arcs the machine makes
  • R: Gives the radius of arcs made by the machine
  • A: Directs the tool around the x-axis
  • B: The number paired with B shows the rotational value around the y-axis
  • C: The auxiliary axis that rotates around the z-axis gets its positional value from the C value
  • D: Shows how much the system offsets the tool diameter
  • L: Gives the system a value to indicate repeating operations and how many times to loop
  • P: Program jumps in time or in delayed time with the P command

Experience CNC the Way It Was Meant to Be with ShopSabre

ShopSabre’s industry-best CNC routers, plasmas, and accessories are designed to help shop owners grow their production through unmatched precision, repeatability, and automation – all at an affordable price.

Our machines are easy to get up and running and to learn how to operate, even without any formal training. Our team of dedicated experts offers one-on-one support to help find the right machine for you and to make sure it works the way you and your business need it to.

Here are a few of the reasons ShopSabre is able to develop and produce such revolutionary CNC technology:

  • Experienced in-house engineering talent
  • The ability to totally fabricate and test designs onsite
  • The ability to place the designs into production in-house

Shop our unmatched collection of CNC routers and CNC plasmas today to experience CNC the way it was meant to be.

  • Please fill out the form to access the finance calculator

Max Out Year-End Savings

0 Payments for 90 Days*

  • Expense 100% of the equipment cost (up to $1,160,000) this year!
  • Maximize tax savings now vs. depreciating over time.
  • Equipment must be installed and put into use by 12/31/23.
  • Promo Code: 0for90
*Example is for illustrative purposes only and may vary. We recommend reviewing your own unique situation with your tax advisor. Financing is subject to credit and equipment approval and 2+ years in business.
*Not all customers will qualify for promotional rates. Program may require a deposit and cannot be combined with other offers, discounts, or specials.
Made In USA Icon
Proudly Engineered, Developed, Manufactured, Assembled, and Supported in the USA!
© Copyright 2023 ShopSabre CNC. All rights reserved. Minneapolis SEO by Perrill.
  • Thank you for your interest.

    Please fill out the form below to receive your free Brochure.