A2oz

What is the G31 G-code?

Published in CNC Machining 2 mins read

The G31 G-code is a tool length measurement (TLM) command used in CNC machining. It allows the machine to automatically measure the length of a tool and adjust its position accordingly.

How G31 Works:

  1. Probe: The G31 command instructs the machine to move the tool to a specific point, usually a probe, to measure the tool's length.
  2. Measurement: The machine probes the surface and records the distance between the tool tip and the measured surface.
  3. Compensation: The measured length is then used to adjust the tool length offset (TLO), which is stored in the machine's control system.
  4. Offset: The TLO is applied during subsequent machining operations, ensuring that the tool is positioned accurately relative to the workpiece.

Benefits of Using G31:

  • Accuracy: G31 helps ensure that the tool is positioned correctly, improving the accuracy of machining operations.
  • Efficiency: Automating the tool length measurement process saves time and reduces manual errors.
  • Flexibility: G31 allows for easy adjustments to tool lengths when using different tools or changing tool lengths due to wear.

Example:

G31 Z0.0 F1000 (Probe to measure tool length)
G10 L2 P1 Z-1.2 (Set tool length offset to -1.2mm)

In this example, the G31 command moves the tool to Z0.0 to probe the surface. The G10 command then sets the tool length offset to -1.2mm based on the measured length.

Conclusion:

The G31 G-code is a valuable tool for ensuring accurate tool length measurement and enhancing the efficiency and accuracy of CNC machining operations.