Absolute and Incremental

G90 and G91 G Codes

G90 and G91

When programming CNC machines, we have to be aware of the difference between G90 and G91 G-Codes. Also known as absolute (G90) or incremental (G91) programming.

These G-Codes tell the machine controls how to read the measurements. Below we take a look at how each one works

G90 Absolute positioning

G90 absolute coordinate system for a CNC machine

The G Code G90 is used to define the absolute positioning system. When G90 is active the machine will read all dimensions and movements from the working datum position.

If we were to issue a movement command such as G00 X100.0 Y100.0; then the machine would move 100mm in the plus direction from the datum in both the X and Y axis.

If we were to enter G00 X0.0 Y0.0; we would move the spindle/tool to the datum position.

Each and every movement command we make will move the tool in relation to the datum position that we have set previously.

Regarding the above drawing. To move the cutter to position A from the datum in the lower left-hand corner of the part, we would give an X dimension of +80. To continue to move to position B we would give an X dimension of +100.

So in absolute mode, each dimension is taken from the datum.


G91 incremental positioning

G91 incremental coordinate system for a CNC machine

When working with G91 incremental positioning, We command the tool to move from its current position and not the datum position.

The above drawing shows that to move to position A from the origin we would give a distance of 80mm, the same as absolute. To move from position A to position B we would need to command the X-axis to move 20mm in the plus direction.

This is because we are giving the distance from the tool position and not the datum position.

We can think of it as the origin or datum is shifting to the centre of the tool after each movement.

Programming with G90 absolute

Programming with G90 absolute

Let's have a look at how we would program the hole positions on this drawing.

The way the dimensions are laid out gives us everything we need to know to be able to program this using the absolute system. Everything comes from the datum, just like the way we would program using G90.

Note: This program simply moves to each position marked on the drawing using the absolute G90 system. This program does not drill the holes

:0002 (G90 EXAMPLE);
N2 T0202 (15MM DRILL);
G90 G21;
S600 M03;
G00 X15.0 Y15.0 (POSITION 1);
X35.0 (POSITION 2);
X55.0 (POSITION 3);
X75.0 (POSITION 4);
Y35.0 (POSITION 5);
X55.0 (POSITION 6);
X35.0 (POSITION 7);
X15.0 (POSITION 8);
Y55.0 (POSITION 9);
X35.0 (POSITION 10);
X55.0 (POSITION 11);
X75.0 (POSITION 12);
G00 Z50.0;
G28 X0.0 Y0.0 M05;
M00;

Every X and Y movement command takes the dimensions from the datum position on the bottom left of the part.

Programming with G91 incremental

Programming with G91 incremental

Now for the same program written using the G91 Incremental system.

The drawing here shows the dimensions using incremental. All dimensions are taken from the tool position and not the datum.


:0003 (G91 EXAMPLE);
N2 T0202 (15MM DRILL);
G90 G21 (MOVING TO POSITION 1 IN ABSOLUTE);
S600 M03;
G00 X15.0 Y15.0 (POSITION 1);
G91 (INCREMENTAL MODE); X20.0 (POSITION 2);
X20.0 (POSITION 3);
X20.0 (POSITION 4);
Y20.0 (POSITION 5);
X-20.0 (POSITION 6);
X-20.0 (POSITION 7);
X-20.0 (POSITION 8);
Y20.0 (POSITION 9);
X20.0 (POSITION 10);
X20.0 (POSITION 11);
X20.0 (POSITION 12);
G90 (ABSOLUTE MODE);
G00 Z50.0;
G28 X0.0 Y0.0 M05;
M00;

I have used G90 absolute to move the cutter to the first position since the spindle position is unknown at this time, once the tool is at the first hole, G91 is activated for the duration of the movements.

Drilling Cycles

We can't talk about incremental without mentioning canned cycles.

A lot of canned cycles such as the G81 drilling cycle automatically use incremental when activated on most machines (but not all, check your users manual). We do not have to state this by entering the G91 command. Below is an example of the same program but this time using a G81 drilling cycle.

:0004 (G91 EXAMPLE);
N2 T0202 (15MM DRILL);
G90 G21;
S600 M03;
G00 G81 X15.0 Y15.0 Z-10.0 (POSITION 1, DRILLING CYCLE ACTIVE);
X20.0 (POSITION 2);
X20.0 (POSITION 3);
X20.0 (POSITION 4);
Y20.0 (POSITION 5);
X-20.0 (POSITION 6);
X-20.0 (POSITION 7);
X-20.0 (POSITION 8);
Y20.0 (POSITION 9);
X20.0 (POSITION 10);
X20.0 (POSITION 11);
X20.0 (POSITION 12);
G00 Z50.0;
G28 X0.0 Y0.0 M05;
M00;

On the third line, we select the absolute system with G90 and move to the position of the first hole. We continue to drill all holes using incremental but we don't need to select G91 as it is part of the G81 drilling cycle.

Safety

When switching between G90 and G91 within your programs care must be taken when not running the program from the start. A good habit to minimise mistakes is to state G90 or G91 before any movement commands are made on each section of G-Code after the tool change.

Share this article

To learn the basics of G Code programming, check out my Foundation course

The quickest way to learn CNC Programming