G40 G-Code Command

  • 2 mins read

G40 G-Code Command

G40 is a code used in CNC machining that cancels the cutter compensation that was previously applied. Cutter compensation is a feature in CNC machining that adjusts the tool path based on the size of the cutting tool being used. This ensures that the tool cuts the desired shape and size accurately. However, there are times when the cutter compensation needs to be cancelled, and that’s where the G40 code comes in. When G40 is executed, the CNC machine stops applying the cutter compensation, and the tool follows the original programmed path without any adjustments.

How G40 G-Code Command is used

Here’s an example of a G-code program that includes the G40 code along with comments in brackets and a spindle on command for 2000 rpm:

M03 S2000   (Turn on spindle at 2000 rpm)
G00 X-1 Y0   (Rapid move to starting position)
G01 Z-0.5 F100   (Move down to cutting depth at a feed rate of 100 mm/min)
G01 G41 X0 Y0 (Apply cutter comp and move to start of next line)
G02 X50 Y50 I25 J0   (Cut a circle with a radius of 25 mm at position 50,50)
G03 X0 Y0 I-25 J0   (Cut another circle with a radius of 25 mm at position 0,0)
G40   (Cancel cutter compensation)
G00 Z10   (Rapid move up to clearance plane)

In this example, the program starts with a rapid move to the starting position at X0 Y0. Then, it moves down to a cutting depth of Z-0.5 at a feed rate of 100 mm/min. The program then cuts two circles using the G02 and G03 codes, both with a radius of 25 mm. After the cutting is complete, the program cancels the cutter compensation using the G40 code. Then, the spindle is turned on at 2000 rpm using the M03 command. Finally, the program moves the tool up to a clearance plane at Z10 using the G00 code.