What is G code in CNC?

G-code is the common name for the most widely used computer numerical control (CNC) programming language, which has many implementations. Used mainly in automation, it is part of computer-aided engineering. G-code is sometimes called G programming language.

G-code Appeared in 1950s (first edition) Designed by Massachusetts Institute of Technology Major implementations many, mainly Siemens Sinumeric, FANUC, Haas, Heidenhain, Mazak. Generally there is one international standard – ISO 6983. Usual filename extensions .mpt, .mpf .nc and several others.

In fundamental terms, G-code is a language in which people tell computerized machine tools what to make and how to make it. The “what” and “how” are mostly defined by instructions on where to move to, how fast to move, and through what path to move. The most common situation is that a cutting tool is moved according to these instructions, cutting away excess material to leave only the finished work piece. Non-cutting tools, such as cold-forming tools, burnishing tools, or measuring probes, are also sometimes involved.

M-Code (miscellaneous function) is an auxiliary command; descriptions vary. Many M-codes call for machine functions like open workstation door,’ which is why some say “M” stands for “machine”, though it was not intended to.

Design2Cut CNC Software in Machine Control Screen
Design2Cut CNC Software in CUT Screen

What is the difference between G Code and M Code?

Generally G codes are written in and performed by the CNC machine processor and operate the motion control part of the control, the M codes are MACHINE codes, these operate most of the basic electrical control functions such as Coolant, Tool changers, safety circuits etc.

Here are some common G Code’s:

  • G00 – Positioning at rapid speed; Mill and Lathe
  • G01 – Linear interpolation (machining a straight line); Mill and Lathe
  • G02 – Circular interpolation clockwise (machining arcs); Mill and Lathe
  • G03 – Circular interpolation, counter clockwise; Mill and Lathe
  • G04 – Mill and Lathe, Dwell
  • G09 – Mill and Lathe, Exact stop
  • G10 – Setting offsets in the program; Mill and Lathe
  • G12 – Circular pocket milling, clockwise; Mill
  • G13 – Circular pocket milling, counterclockwise; Mill
  • G17 – X-Y plane for arc machining; Mill and Lathe with live tooling
  • G18 – Z-X plane for arc machining; Mill and Lathe with live tooling
  • G19 – Z-Y plane for arc machining; Mill and Lathe with live tooling
  • G20 – Inch units; Mill and Lathe
  • G21 – Metric units; Mill and Lathe
  • G27 – Reference return check; Mill and Lathe
  • G28 – Automatic return through reference point; Mill and Lathe
  • G29 – Move to location through reference point; Mill and Lathe (slightly different for each machine)
  • G31 – Skip function; Mill and Lathe
  • G32 – Thread cutting; Lathe
  • G33 – Thread cutting; Mill
  • G40 – Cancel diameter offset; Mill. Cancel tool nose offset; Lathe
  • G41 – Cutter compensation left; Mill. Tool nose radius compensation left; Lathe
  • G42 – Cutter compensation right; Mill. Tool nose radius compensation right; Lathe
  • G43 – Tool length compensation; Mill
  • G44 – Tool length compensation cancel; Mill (sometimes G49)
  • G50 – Set coordinate system and maximum RPM; Lathe
  • G52 – Local coordinate system setting; Mill and Lathe
  • G53 – Machine coordinate system setting; Mill and Lathe
  • G54~G59 – Work piece coordinate system settings #1 t0 #6; Mill and Lathe
  • G61 – Exact stop check; Mill and Lathe
  • G65 – Custom macro call; Mill and Lathe
  • G70 – Finish cycle; Lathe
  • G71 – Rough turning cycle; Lathe
  • G72 – Rough facing cycle; Lathe
  • G73 – Irregular rough turning cycle; Lathe
  • G73 – Chip break drilling cycle; Mill
  • G74 – Left hand tapping; Mill
  • G74 – Face grooving or chip break drilling; Lathe
  • G75 – OD groove pecking; Lathe
  • G76 – Fine boring cycle; Mill
  • G76 – Threading cycle; Lathe
  • G80 – Cancel cycles; Mill and Lathe
  • G81 – Drill cycle; Mill and Lathe
  • G82 – Drill cycle with dwell; Mill
  • G83 – Peck drilling cycle; Mill
  • G84 – Tapping cycle; Mill and Lathe
  • G85 – Bore in, bore out; Mill and Lathe
  • G86 – Bore in, rapid out; Mill and Lathe
  • G87 – Back boring cycle; Mill
  • G90 – Absolute programming
  • G91 – Incremental programming
  • G92 – Reposition origin point; Mill
  • G92 – Thread cutting cycle; Lathe
  • G94 – Per minute feed; Mill
  • G95 – Per revolution feed; Mill
  • G96 – Constant surface speed control; Lathe
  • G97 – Constant surface speed cancel
  • G98 – Per minute feed; Lathe
  • G99 – Per revolution feed; Lathe

Common CNC M Codes:

  • M00 – Program stop; Mill and Lathe
  • M01 – Optional program stop; Lathe and Mill
  • M02 – Program end; Lathe and Mill
  • M03 – Spindle on clockwise; Lathe and Mill
  • M04 – Spindle on counterclockwise; Lathe and Mill
  • M05 – Spindle off; Lathe and Mill
  • M06 – Tool change; Mill
  • M08 – Coolant on; Lathe and Mill
  • M09 – Coolant off; Lathe and Mill
  • M10 – Chuck or rotary table clamp; Lathe and Mill
  • M11 – Chuck or rotary table clamp off; Lathe and Mill
  • M19 – Orient spindle; Lathe and Mill
  • M30 – Program end, return to start; Lathe and Mill
  • M97 – Local sub-routine call; Lathe and Mill
  • M98 – Sub-program call; Lathe and Mill
  • M99 – End of sub program; Lathe and Mill

More From Westcott Plasma

  • All
  • CNC Plasma Projects (Tips & Tricks)
  • How to start a CNC Plasma Cutting Business
  • The basics of CNC Plasma Cutters
  • The Basics of CNC Plasma Cutting
  • The Basics of CNC Plasma Software
  • The basics of Plasma Tables

Key Terms: CNC Plasma Terminology

What does “blow-back” mean? What are “lag lines”? The plasma cutting industry is full of unique words and phrases. Fortunately, …

What is CAD / ART Software in CNC Plasma Cutting?

There are hundreds of options out there when it comes to software. I’m going to cover adobe illustrator and Design2Cut, …

Design2Cut CNC Software in Machine Control Screen

The basics CNC Plasma Cutting Software (Complete Guide)

When it comes to Software for CNC Plasma Cutting, you can break things up into 3 distinct categories: CAD or …

sign up for our newsletter

Learn everything there is to know about plasma cutting! We’ll email you twice a week with a new article to read.