One Shot G-Codes and Modal G-Codes

Last modified: June 10, 2024

CNCCookbook's G-Code Tutorial

What Are G-Code Modes?

Let's talk about G-Code "Modes." Simply put, a Mode is the CNC Controller's way of remembering what you told it to do last time. Think of it like muscle memory for machines. If you don't specify every little detail, the CNC just assumes you want to do it the same way as before. It's like the CNC's way of saying, "Been there, done that!"

Modes are your time-saving buddies, making your g-code programs shorter and sweeter. So, instead of repeating yourself, let the Modes do the heavy lifting.

When you run a G-Code program in the GWE simulator, it shows you which modes are in effect in the little box under the backplot:

CAD software interface with 3D model.

The controller's state and G-Code Modes are shown Below the GWE Backplot...

There are many examples of modes in g-code, not the least of which are the coordinates of the current position. You don't always have to specify X, Y, and Z for every move. You only specify the coordinates that have actually changed.

The exact use of modes is one of the areas that differs from one G-Code Dialect to the next, so make sure you understand which things are modal in your g-code dialect and which are not.

What is a One-Shot G-Code?

Speaking of things which are not modal, we have a name for a big category of non-modal behavior which are called One-Shot G-Codes. A one-shot g-code is only in effect for the block it is used in, and then the mode goes back to whatever it was before the block was executed. Most of the one-shot g-codes are fairly advanced, so we'll save them for a later chapter.

Exercises

1. Get out the programming manual for your control and find at least one example of a modal g-code and one example of a one-shot g-code.

Try the Free Trial Version of G-Wizard G-Code Editor...

Green rounded rectangle with white text.

No credit card required-just your name and email.

Next Article: CNC Editors

Be the first to know about updates at CNC Cookbook

Join our newsletter to get updates on what's next at CNC Cookbook.