Quick Guide to the D CNC Code [Diameter Offset]

a graphic of a cnc machine with text that says learn g code today first d diameter offset

The D code is used to choose the D offset that is used when cutter compensation is turned on.

The D offset value is a number stored in the CNC machine controls that tells the CNC the size of the cutting tool. Once the machine knows the size of the cutter it can adjust how it runs the program based on that size.

illustration of a cnc cutting tool that shows what an D offset is

Want to learn more about CNC G Code?

What is cutter compensation?

Cutter compensation is a CNC mode that allows the CNC controller to adjust for the size of the cutting tool. Setting the size of the cutting tool allows you to use the same program with multiple different cutting tools.

Turning cutter compensation on tells the machine to shift the cutting tool either left with G41 or right with G42. The shift is half of the diameter of cutting tool, otherwise known as the radius.

Visualizing which way the machine will shift can be a little tricky. The shift happens as if you are looking towards the direction that the cutter is moving.

The two images below show how the CNC will move when the other cutter compensation modes are active.

illustration that shows how a CNC will act when using cutter compensation left with the G41 code
illustration that shows how a CNC will act when using cutter compensation right with the G42 code

What are the benefits of using cutter compensation with a D offset?

The benefit of using cutter compensation and D offsets is that adjustments can easily be made to the part being machined without the need for rewriting the whole program.

For instance, if you were to machine your part and find that the part was larger than planned then the D offset could be changed to adjust the size of the part.

D offsets get changed for a variety of reasons. The part could finish at an unexpected size, the cutting tool could wear changing the size or the cutting tool may need to be changed. All of these examples could be fixed through changing the D offset stored in the controller.

Without the use of a D offset, the CNC program would need to be rewritten to make these adjustments. This would be more difficult and require a lot more time.

Can you have more than one D offset?

Yes, you can have more than one D offset but you cannot have more than one D offset active at a time.

This means you can have multiple D offsets stored in your machine controller, one for each of the tools in your machine. However, only one can be on at any time.

Generally, the D offset number will be the same as the tool number it is associated with.

D offset numbering

The D offset for tool number 01 will also be 01.

T01 = tool number 1

D01 = D offset number 1

The D offset number does not have to be the same as the tool number. Sometimes this won’t even be possible depending on the machine.

When possible, it is a great idea to number the offsets the same as the tool they will be assigned to.

Where are D offset values stored?

Most CNC machines allow the cutting tool information to be stored in table form. This tool library is called the tool offset table.

mach 3 tool offset table
Tool offset table

The tool offset table, sometimes called tool table or offset library. The tool offset table is simply a table of values that list the characteristics of the cutting tool, such as the diameter and length of the tool.

Tool offset tables vary from machine to machine. Some will allow you to store the length and diameter offsets together with a single tool. Some will require separate entries for diameter and tool length offsets.

D offset vs H offset

D offsets store the diameter of the cutting tool. H offsets store the length of the cutter.

Both offset types allow more flexibility when running the program and when switching between various cutting tools.

Both offset types are stored in the tool offset table.

Want to learn more about CNC G Code?

Leave a Comment