G40 is the CNC G code to turn off cutter compensation.
Cutter compensation is turned on with either the G41, for cutter compensation left or G42, for cutter compensation right.
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.
Where does G40 show up in a program?
The G40 command can be found at any point within the program, but the most common place to find one is in safety lines of the program.
Safety lines are a set of codes used to put the CNC machine into the correct mode(s) prior to running the program. Sometimes this means turning modes on, sometimes it means turning them off.
G40 is one of the off commands.
Safety lines are also used at the start of a new section of code. For example, you
Things to know when using the G40 code
The two main things to pay attention to when using G40 to cancel cutter compensation are:
- Cancel cutter comp when you are off the part more than half the diameter of the cutter
- Make a move when canceling cutter compensation
Canceling cutter compensation when off the part enough keeps the machine from running back into the part. A good practice is to move the machine in the Z axis so that it is away from the part before canceling cutter compensation.
Making a move forces the machine to move in a consistent way. Some machines can react unexpectedly if no move is made when canceling cutter compensation. The machine basically thinks it has teleported location.
Don’t teleport your CNC. Make a move when canceling cutter compensation.
Other cancel commands
There are multiple G code cancel commands. The table below shows the most common codes for turning modes off:
Cancel cutter compensation
Cancel tool length compensation
Cancel custom macro call
Cancel canned cycles