Quick Guide to the G91 CNC G Code [Tips and Tricks]

a graphic of a cnc machine with text that says learn g code today G91 incremental positioning mode

Code

G91

Name

Incremental Positioning

Type


Modal - stays on until changed

Description

The machine will read all locations as relative to its current location

A G91 code sets the CNC to incremental positioning mode. This means that the CNC will interpret all location values as relative to the position of the machine before making the move.

The zero location of the machine will move each time the machine moves. This can be good for repetitive work such as drilling a series of holes.

G90 vs G91: CNC positioning modes

For a CNC machine there are two positioning modes available. They are absolute (G90) and incremental (G91) positioning.

As noted above, incremental positioning with G91 will take all locations relative to the machines current location.

With absolute positioning (G90), the machine will interpret all locations as relative a static location. This will usually be the work offset zero location as set by G54 or the machines home location if no work offset is active.

Both codes are modal which means that the code will stay active until it is either canceled or changed. For G90 and G91, there is no cancel code so the only way to change them is to call the opposite code.

graph paper example of absolute positioning with multiple points as examples
graph paper example of incremental positioning with multiple points as examples

The images above show the difference between the absolute and incremental positioning modes. The numbers in parentheses are the locations given to the the machine to make the move.

Notice how in absolute mode, all locations are relative to a single location, usually either the workpiece zero or machine home location. 

In incremental mode, all locations are relative to the machine’s current location.

When to use a G91 code

The main portion of most programs will be in absolute mode (G90). Incremental mode (G91) is usually only used to create repetitive features such as drilling a set of holes.

G91 is a much less frequently used code compared to G90.

G90 codes are used frequently. This is because they get used as part of safety lines of code sometimes called safety block.

Safety lines are a chunk of code that is used to ensure that the machine is in the correct modes before executing a section of the CNC program.

They are used at the start of new sections of code such as when changing tools.

Why using a G91 code is important

Both G90 and G91 are modal commands which means that they will stay in effect until changed or canceled.

It is important to set your positioning mode in your program with either G90 (absolute mode) or G91 (incremental mode).

Imagine if you had an operation where you were going to drill a set of holes. Before you drill those holes, it would be wise to set all the necessary modes you will need to have active.

Setting the positioning mode (absolute or incremental), setting the type of units you are in (inches or mm) and turning on various compensation modes are just some of the modes that you might want to have set.

If these modes are already active, then nothing will change. No harm, no foul.

If they weren’t active and you didn’t turn them on, you might crash your machine.

When writing your CNC programs, it is critical to be in the correct positioning mode at all times. For this reason, a G90 or G91 code should be used at the start of a new section of the program.

What to think about when using a G91 code

Know where you are at and where you want to move the machine.

In other words, you need to know where the start and stop location of each move is.

The main body of most programs will be written in absolute mode (G90). This is because it is easier to visualize a part based on absolute coordinates.

Portions of a program get written in incremental mode. Often incremental mode is used when dealing with canned cycles or subprograms.

You can make your whole program in incremental mode if you wish, most people don’t though.

G91 code example

N0010 G90 F100 S1200 T01

N0020 G00 X36 Y10

N0030 Z2

N0040 G91 G01 Z-12 M03

N0050 X10

N0060 Z12 M05

N0070 M30

Line N0010 sets the positioning mode as absolute. It also sets the feed rate to 100, spindle speed to 1200 and selects tool 01.

Line N0020 sets the movement mode as rapid travel. It then moves to the XY location listed.
Line N0030 rapid moves to the Z location.

Line N0040 sets the movement mode to incremental mode and straight-line movement. It turns the spindle on clockwise and feeds 12 units in the negative Z direction at the feed rate listed in line N0010.

Line N0050 moves 10 units in the positive X direction in a straight line at the previous feed rate.

Line N0060 moves 12 units in the positive Z direction and turns the spindle off.

Line N0070 ends the program.

CNC codes that are similar to G91

We already discussed the most common code that is similar to G91. G90 sets the machine in absolute positioning mode.

The other main codes that affect positioning are G60 and G64.

G60 sets the CNC to single direction positioning mode.

The G60 code will make force the machine to approach each new location from the same direction. This decreases location errors that can occur because of backlash in the machine.

G64 is normal positioning mode. In normal positioning mode, the machine will move all axes at the same time and will approach the workpiece form whichever side is fastest.

Leave a Comment