9 months by cncdivi

 

Gcode G91 & Gcode G90: CNC Absolute and Incremental Programming

Here’s the scoop: gcodes G90 and G91 tell your CNC machine whether to use absolute or incremental coordinates.

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. Incremental 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 incremental 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,” those directions use absolute positioning.

If instead, he responds, “It’s three aisles down that way,” that’s an incremental mode 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 “incremental 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 Incremental (g code G91) and Absolute Positioning Mode (g code G90)

How can we switch between Incremental and Absolute Positioning Mode in our cnc program? The usual way is to use g code G90 to use Absolute Mode and G91 to use Incremental Mode. For example:

G90 ( Switch to absolute mode)

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

G91 ( Switch to incremental mode )

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

G90 ( Switch back to absolute coordinates )

The preceeding program includes absolute positioning to X0Y0Z0 and incremental positioning. As you can see, g code G90 and g code G91 are modal.

G90 G Code Absolute Programming Example

In this example and the next I will show how to carve out the same figure, a rectangular solid, using absolute and incremental coordinates.  Let’s start with G Code G90 Absolute Mode.

Given a 6″ wide by 4″ tall by 1″ thick piece of material, we want to cut a pocket that is inset 1″ from the edges using a 1/2″ end mill.  Here’s a drawing of our part:

gcode g90 gcode 91 absolute incremental coordinates

Here’s our part…

Okay, and here is some sample gcode:

;  We assume the cutter is somewhere a safe distance above the part so that we can rapid.

G90    ;  Make sure we are in gcode G90 absolute positioning mode.

G00    ;  Use rapids speed.

X1.25 Y1.25     ;  Absolute coordinates right above the corner

G01   ;  Use cutting feedrate (actual feedrate and spindle rpm gcodes are not shown

Z-0.5 ;  Plunge to bottom of pocket

;  Now we go around the pocket counter-clockwise so we are climb milling

X4.75

Y2.75

X1.25

Y1.25

;  Not going to show all the moves to clear the pocket, but we’ve just gone around the perimeter using absolute moves.

The resulting moves look like this:

gcode g90 absolute coordinates

G91 GCode Incremental Positioning Mode Example

Let’s try it again with relative moves.  Here’s our gcode:

;  We assume the cutter is somewhere a safe distance above the part so that we can rapid.

G90    ;  Make sure we are in gcode G90 absolute coordinate mode.  We don’t know where the cutter is, so we use absolute to make sure.

G00    ;  Use rapids speed.

X1.25 Y1.25     ;  Absolute coordinates right above the corner

G01   ;  Use cutting feedrate (actual feedrate and spindle rpm gcodes are not shown

Z0.0

G91   ;  Now we know exactly where we are, so switch to incremental coordinates.

Z-0.5 ;  Plunge to bottom of pocket

;  Now we go around the pocket counter-clockwise so we are climb milling

X3.5

Y1.5

X3.5

Y-1.5

;  Not going to show all the moves to clear the pocket, but we’ve just gone around the perimeter using absolute moves.

Dimensions are always handy when figuring incremental moves:

gcode g91 incremental coordinates

 

 

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!

 

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 gcode G90 or gcode 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 incremental 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 incremental 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 incremental 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.

Canned Cycles and Automatic gcode G91

Many canned cycles (such as drilling cycles) allow you to list coordinates so the canned cycle runs multiple times, once for each time you want the cycle to run.  This makes it easy to do things like drill multiple holes using a list of hole coordinates.  Typically, the coordinates will be incremental , as if the code automatically stuck a G91 in front and then returned to whatever mode was in effect at the end.

Be sure to check your controller’s documentation to learn whether or not it does this.

Use G-Wizard Editor to Convert Between Absolute and incremental Coordinates

It can be a tedious and error prone process to convert a bunch of g-code from absolute to incremental or vice versa, but it’s easy if you have software to do it automatically.  Turns out G-Wizard Editor has a command that does this conversion for you.

Under Tools Revision, there is a Incremental / Absolute command that makes it super easy:

automatically convert g90 g code to g91 g code

You can either convert the whole program or a block of lines you’ve selected.

References

Exercises

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 (gcode G90).

2. Convert the program you wrote in #1 to use incremental coordinates (don’t forget to include gcode G91!). 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 incremental coordinates.

Next Article: Polar Coordinates

G90 and G91 GCode FAQ

What is G90 in GCode?

The G90 gcode causes coordinates to be interpreted as absolute coordinates.

What does G91 do in GCode?

The G91 gcode causes coordinates to be interpreted as relative to the current position.

What is absolute positioning CNC?

Absolute positioning is triggered by the G90 gcode. With absolute positioning, coordinates are relative to part zero, the machine’s position at X0Y0Z0.