How Do You Test Your G-Code Before Putting It On a Machine?

Sure you can cut "air", but it's slow going.  Would you like to learn about some software that lets you perform 5 essential tests on your g-code before it goes on the machine?  It'll save you a lot of time and frustration.

You Bet, Tell Me More!



G91 & G90 G-Code: CNC Absolute and Incremental Programming

What’s the Difference Between Absolute and Incremental Coordinate System?

Let’s start with a definition. Absolute coordinates are measured from program zero, the program’s origin. Relative moves are measured from the current position. We just looked at Circular Arc moves using G02 and G03. The coordinates of the arc center as expressed by I and J are relative coordinates.

Now, a more practical example. Suppose you’re in a grocery store and you ask the clerk which aisle the cookies are on. If he responds, “Go to Aisle 14 for the cookies,” that’s an absolute coordinate that is relative to the first aisle–the grocery store’s “part zero”.

If instead he responds, “It’s three aisles down that way,” that’s an incremental coordinate. We’re used to both kinds in everyday life and both are useful depending on the situation.

Mr Whipple: Grocery Clerk

Note that what we might call “relative coordinates” are often called “incremental mode” coordinates in the CNC Controller Programming manuals. It’s just another way of saying the same thing.

Switching between Relative and Absolute Coordinates

How can we switch between Relative and Absolute Coordinates? The usual way is to use G90 to use Absolute Coordinates and G91 to use Relative Coordinates. For example:

G90 ( Switch to absolute coordinates )

G0 X0Y0Z0 ( Move to program origin at 0, 0, 0 )

G91 ( Switch to relative coordinates )

G0 X1Y1 ( Move one unit right in X and one unit right in Y )

G90 ( Switch back to absolute coordinates )

The preceeding program includes both an absolute move to X0Y0Z0 and a relative move. As you can see, G90 and G91 are modal.

Which Mode Does My Controller Use as the Default?

Interestingly, most controls will startup in relative/incremental mode (G91). This is done because it is thought to be safer if the mode is not what you expect. In other words, if you expected absolute it is thought to be safer to start in incremental than if you expected incremental and start in absolute. The truth is, not being in the mode you expect is not safe any way you look at it because the machine will do something unexpected. Therefore, make sure one of the first things you do in your program is to set it to either G90 or G91 so it does what you expect!

Using UVW Words for Incremental Coordinates

Some controllers allow both styles to be active at once using UVW. We could write the previous program this way:

G90 ( Switch to absolute coordinates )

G0 X0Y0Z0 ( Move to program origin at 0, 0, 0 )

G0 U1V1 ( Move one unit right in X and one unit right in Y )

This UVW format is convenient and a little shorter. We’ve already mentioned controllers where I and J are relative which is a similar case to UVW, albeit intended for arc center location.

Why Would I Use Incremental vs Absolute Moves?

Let’s consider a couple of cases.

First, its all about how you want to think about your problem. Is it more natural to think about what’s going on relative to some absolute central point or relative to your current location? The CNC controller doesn’t care, so do what’s easy for you.

Second, suppose you’re just reading off a print and keying in the g-code. It may be easier to use the relative coordinates for some points as you may not have an absolute coordinate readily available. Prints usually provide dimensions relative to adjacent features rather than relative to some absolute part zero origin.

A last example, is when writing subprograms. Suppose you have a feature that is repeated more than once in your g-code program. Perhaps you drill a hole, chamfer it, and then thread it with a tap, for example. These holes are located all over a plate you’re machining. The easy way to program such a thing is to create a subprogram (we’ll be talking about subprograms in detail a little later, but for now, use your imagination) that assumes it is located above the center of the hole and can just proceed to do all the work using relative coordinates. Now you can just make an absolute move and then call the subprogram for each hole and only have to write the code once. What a time saver.


1. Write a g-code program that feeds the cutter around a 1 inch by 1 inch rectangle whose center is at 1, 1. Use absolute coordinates.

2. Convert the program you wrote in #1 to use relative coordinates. You may use an absolute coordinate to get to the center of the rectangle in an initial G00 move.

3. Determine whether your control allows UVW moves, and if so, rewrite #2 to use them without calling G91 to switch to relative coordinates.

Next Article: Polar Coordinates