G42 is a modal command called cutter compensation right. This code adjusts the path of the cutting tool based on the diameter of the cutter.
If you are looking towards the direction that the cutter is moving, the tool path is shifted to the right.
There are also codes for using no cutter compensation (G40) as well as using cutter compensation left (G41).
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.
G41 vs G42
There are two different cutter compensation modes that can be used:
- G41 for cutter compensation left
- G42 for cutter compensation right
The direction of the shift is relative to the cutting tools direction of movement.
G41 is used when climb milling, which is the most common type of milling used. G42 is used when conventional milling. Conventional milling sounds like it would be the standard but in reality, it is rarely used.
When climb milling, the cutter moves in the same direction as the stock feeds, which means that the workpiece produces less resistance to the cutting as the chips fall behind the cutter.
This type of milling helps prolong the life of the cutters and creates a better surface finish. This is the most commonly used milling method CNC machines.
On the other hand, with conventional milling the cutter runs in the opposite direction of the stock feed, which means that the cutter will have more resistance against the workpiece and cause more tool wear resulting in a shorter tool life.
The two images below show how the CNC will move when the other cutter compensation modes are active.
Advantage of using cutter compensation
The advantage of cutter compensation is that you won’t need to rewrite your program continuously to adjust for the size of your tool.
Imagine you bought a new end mill, and it came in 0.001” smaller than the last one. This would mean that your parts would now come out larger than before. To account for this you can use cutter compensation and your D offsets to tell the machine how big the cutter is.
This allows you to continue using the same program even though your cutter has changed.
Cutter sizes and D offsets
Because we are talking about cutter compensation with G42, we are going to focus on D offsets.
D offsets are stored in your machine’s controller, and they store the diameter of your cutting tool.
Now usually when the machine reads the coordinates given in the program, it moves the center of the cutting tool to that position. This can make it difficult to get the correct size especially when using different or multiple cutters.
Telling the machine the size of the cutters with your D offsets allows it to account for them and run the same program with different tools and get the same size part. If you didn’t have cutter compensation, then you would need to create a new version of the program every time you wanted to use a new tool.
Using Tool Offset Table for Cutter compensation
The Tool Offset Table, sometimes called Tool Table or Offset Library, is simply a table that the operator uses to store the offset values. This can include both diameter (D) and tool length (H) offsets.
Tool offset tables vary and some machines will only store one type of offset. This means you may need to store both your diameter and tool length offsets in a D offset.
Some other machines may allow you to store the diameter and length of a cutting tool in the same offset number. The setup varies by machine so check yours out to make sure you know how it works.
The purpose of the Tool Table is to tell the CNC machine what the dimensions of the cutting tool are. This includes radius and length.
How to turn off cutter compensation
Cutter compensation with G42 is canceled by using the G40 code which cancels all active cutter compensation modes.
Alternatively, G42 can be canceled by switching to cutter compensation right by using the G41 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 off the part enough keeps the machine from running back into the part.
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.
G42 programming format
There are multiple ways of formatting a G42 command:
- G42 D1. When the G42 code is used with a D offset it is meant to be used on a machine with a built-in tool table in the controller. G42 turns on cutter compensation left and D1 tells the machine to adjust the tool path based on the size stored in the first D offset.
- G42 P2. The P value is the radius of the tool used in the operation. This format is used more often on hobby level machines.
- G42 X2. This format is the same as using the P value.
Focus on learning the first format unless you plan to only ever use simple home level machines.
Other types of compensation
The other main form of compensation is tool length compensation.
Tool length compensation is turned on with either G43 or G44. Although G44 is almost never used. G43 is by a super wide margin the most often used tool length compensation.
Tool length compensation accounts for the length of the cutting tool relative to the end of the spindle.