G42 G-Code Command

G42 G-Code Command

G42 is a code used in CNC machining that specifies the tool compensation value for a particular tool. Tool compensation is necessary to account for the size and shape of the cutting tool when machining a workpiece. G42 is used to specify the amount of tool compensation that should be applied to the right side of the tool. This allows the tool to cut accurately along the programmed path, even when the tool diameter is larger than the path specified in the program. G41 is the code used for tool compensation on the left side of the tool.

How G42 G-Code Command Is Used

Here’s an example of a G-code program that uses G42 for tool compensation and includes comments in brackets:

M03 S2000           (turn on spindle clockwise at 2000 RPM)
G00 X0 Y0           (rapid move to starting position)
G01 Z-5 F100        (move tool down 5mm at 100mm/min)
G01 G42 D01 X50 Y50 F500    (turn on tool compensation and move tool to position (50,50) at 500mm/min)
G01 X100 Y0         (move tool to position (100,0) at default speed)
G40                 (turn off tool compensation)
G01 Z10 F200       (move tool up at 200mm/min)
G00 X0 Y0           (rapid move back to starting position)
M05                 (turn off spindle)

In this program, G42 is used to turn on tool compensation for tool offset 1 (D01). The program then moves the tool to two different positions using G01 commands. After the second move, G40 is used to turn off tool compensation. The program then turns on the spindle at 2000 RPM using M03 and moves the tool down to a depth of 10mm using G01. Finally, the program returns the tool to the starting position using G00 and turns off the spindle using M05.

Share on pinterest
Share on email
Share on print

Table of Contents