Welcome to our comprehensive guide to using the G40 CNC code. Whether you’re a beginner learning CNC programming or an experienced machinist, understanding the G40 CNC code is extremely important.
In this guide, we’ll break down everything you need to know about this cutter compensation command, including how, when, and why to use it.
What does a G40 code do?
G40 is the CNC G code to turn off cutter compensation.
When cutter compensation is turned off, the center of the cutter will follow the tool path given in the program.
In the animation below, the tool path in the program is shown by the lines with the arrow.
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 based on the size of the D offset chosen using the D code.
The shift is half of the diameter of the cutting tool, otherwise known as the radius.
Ready to master CNC programming?
Try the free 30 minute intro course to see how simple and easy G code can be. Take the shortcut to becoming a G Code Master today!
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 animations below show how the CNC will move when the other cutter compensation modes are active.
With cutter compensation left on (G41), the cutter will be shifted left and the right edge of the cutting tool will follow the tool path.
With cutter compensation right on (G42), the cutter will be shifted right and the left edge of the cutting tool will follow the tool path.
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 up above the part 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.
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 (cancel) commands.
Safety lines are often used at the start of a new section of code to make sure the CNC is set to the correct modes before running the section of code.
Other cancel commands
There are multiple G code cancel commands. The table below shows the most common codes for turning modes off:
Code | Description |
G40 | Cancel cutter compensation |
G49 | Cancel tool length compensation |
G50 | Cancel scaling |
G67 | Cancel custom macro call |
G69 | Cancel rotation |
G80 | Cancel canned cycles |
Ready to master CNC programming?
Try the free 30 minute intro course to see how simple and easy G code can be. Take the shortcut to becoming a G Code Master today!