G90 and G91 in CNC: absolute vs. incremental programming
G90 and G91 in CNC: absolute vs. incremental programming with examples
How to change the way the machine interprets coordinates and why it matters
In any CNC program, coordinates can be expressed in two ways: relative to a fixed origin or relative to the current position of the tool. This simple distinction is controlled with two codes (G90 and G91) and is one of the first things to master when programming a lathe or a milling machine. A wrong choice between one mode and the other is a frequent cause of errors and collisions.
What G90 and G91 mean in CNC programming
G90 and G91 are modal codes within the ISO 6983 standard that determine how the control interprets the coordinates written in each block of the program. Modal means that, once activated, the mode remains in effect until another code from the same group replaces it.
-
G90 activates absolute programmingmode: each coordinate is measured from the work zero defined by the operator.
-
G91 activates incremental programmingmode: each coordinate is measured from the current position of the tool.
Although the difference seems subtle on paper, it has important consequences for how programs are built, for their maintainability and for how easily errors can be detected.
G90: programming in absolute coordinates
In G90 mode, all coordinates refer to a fixed point (the work zero) that the operator sets at the start of the job. If the program specifies G01 X50 Z-30, the tool will move to the point located 50 mm in X and -30 mm in Z from the work zero, regardless of where it was before.
The main advantage of absolute mode is independence between blocks: each line is self-contained. If a coordinate is changed in the middle of the program, the others are not affected. This makes debugging, reading the code and later editing easier.
G90 is the default mode on most CNC controls and the one most recommended for manual programming of parts with complex geometry.
G91: programming in incremental coordinates
In G91 mode, coordinates are interpreted as relative distances from the current position of the tool. If the tool is at X100 Z0 and the program commands G01 X-20 Z-30, it will move 20 mm toward the center and 30 mm toward the chuck, ending up at X80 Z-30.
The advantage of G91 is code economy when patterns are repeated. If you want to machine ten slots spaced the same distance apart, you only need to write the incremental move once and repeat the block, without recalculating the absolute coordinates of each slot.
The drawback is that any error in one line is carried over to all the following ones: if the tool did not reach the previous theoretical point exactly, the next relative coordinate will be offset.
Visual comparison: the same movement in G90 and G91
To understand the difference with a specific case, let's assume the tool has to pass through three consecutive points:
-
Point A: X20 Z0
-
Point B: X20 Z-40
-
Point C: X35 Z-40
In absolute mode (G90), the program would be:
G90
G01 X20 Z0
G01 X20 Z-40
G01 X35 Z-40
Each coordinate refers to the work zero. Anyone can read the program and know where the tool is at any moment without having to calculate anything.
In incremental mode (G91) (starting from position A) the same path would be:
G91
G01 X0 Z-40 (advances 40 mm in Z, without moving in X)
G01 X15 Z0 (advances 15 mm in X, without moving in Z)
The program is shorter, but it requires keeping track of the cumulative position mentally to know where the tool is. And if one of the lines is wrong, all the following ones will be too.
When to use G90
Absolute programming is the recommended option in most situations:
-
Parts with complex geometry: when there are many reference points, absolute mode avoids accumulating calculations.
-
Long programs: it makes debugging and reading by third parties easier.
-
One-off changes: changing one coordinate does not require recalculating the following ones.
-
Manual programming from the drawing: it allows dimensions to be transferred directly from the drawing to the program.
For these reasons, G90 is the default active mode on virtually all CNC controls after switching on the machine or performing a reset.
When to use G91
Incremental mode has specific applications where it offers clear advantages:
-
Repetitive patterns: series of holes, equally spaced grooves or multiple threads are programmed with far fewer lines.
-
Reusable subroutines: when an operation is going to be repeated in different areas of the part, writing it in incremental mode lets you call it several times, changing only the starting position.
-
Small adjustments at the machine: moving the tool a few tenths during setup is more intuitive in incremental mode than recalculating the absolute coordinate.
In industrial practice, G91 is rarely used to program the whole part: the usual approach is to combine G90 for the bulk of the program and G91 within subroutines or repetitive cycles.
How to switch between G90 and G91 within a program
As modal codes, G90 and G91 can be alternated within the same program. You simply write the corresponding code at the start of the block where you want to switch. For example:
G90 G01 X20 Z0 (Absolute mode: to point X20 Z0)
G91 G01 X10 (Switch to incremental: advances 10 mm in X)
G91 G01 Z-15 (Still incremental: advances 15 mm in Z)
G90 G01 X100 Z50 (Back to absolute: to X100 Z50)
Good practices to avoid problems:
-
Always declare the mode at the start of the program: don't assume the control's default mode.
-
Return to G90 after a subroutine or cycle in G91: forgetting to do so leaves the program in incremental mode and the following blocks will be misinterpreted.
-
Comment the changes: a note such as (incremental mode for drilling) helps you quickly find the change during debugging.
Common mistakes when using G90 and G91
Problems with G90 and G91 recur even among experienced operators. The most common are:
-
Not declaring the mode in the header: the program works the first time because the control is in G90 by default, but fails after a reset that changes the modal state.
-
Forgetting to return to G90 after a subroutine in G91: the following blocks are interpreted as incremental and the tool ends up far from where it should be.
-
Mixing the two modes within the same block: some controls accept declaring G90 or G91 line by line, which makes the program confusing to read.
-
Assuming incremental in CAM programming: post-processors generate G90 by default. Manually editing blocks in G91 without declaring the change is a frequent cause of collisions.
The best way to detect these faults is to always run the graphic simulation of the program before actual machining. A collision caused by two badly mixed modes is obvious on the screen and can be avoided in a matter of seconds.
📩 hola@vurcon.com
📞+34 966 662 296