G Code Explained – Lesson 01

In this lesson, I’ll introduce you to G code, which is the most common way to program CNC machines. Watch the video below, and check out all the extra resources on this page!

Lesson Summary

Here’s the lesson in a nutshell.

The machine is given positions by using the Cartesian coordinate system. This can define any point in 3D space.

The origin is the X, Y and Z “zero” point that we program from. It’s usually based on where the part is within the machine.

A modal command is a code that stays active until it’s either turned off or overwritten. It works in the same way that a light switch does.

A non-modal command is a single-use command that does not stay active. It’s more like a button on a keyboard.

G codes are preparatory codes, and they get the machine ready to perform some kind of action.

M codes are miscellaneous commands, and they can be used for pretty much anything.

Positional addresses give the machine a position to interpret in some way, whether to use as a reference position or a go-to point.

“Other” letter addresses are used to set parameters and values, and they’re paired with G and M codes.

Review Questions

  1. What’s an example of a modal command?
  2. Give an example of a non-modal command.
  3. What system is used to define positions within the machine?
  4. What are M codes used for?
  5. What are G codes used for?
  6. Name 3 types of positional addresses along with what they define.