A2oz

What is the G21 Code?

Published in CNC Machining 1 min read

The G21 code is a G-code used in computer numerical control (CNC) machining. It sets the absolute coordinate system for the machine. This means that all subsequent tool movements will be referenced to the machine's home position, which is typically the lower left corner of the work area.

Here's a breakdown of the G21 code's functionality:

  • Sets the Units: G21 sets the units for all subsequent dimensions in the program to millimeters (mm).
  • Absolute Positioning: It establishes an absolute coordinate system, meaning that all tool movements are measured from the machine's home position.
  • Compatibility: G21 is a standard G-code command recognized by most CNC machines.

Example:

G21  ; Set units to millimeters
G0 X100 Y50 ; Move tool to absolute position X100mm, Y50mm

Practical Insights:

  • The G21 code is essential for ensuring accurate tool positioning and part dimensions.
  • It's crucial to use the correct G-code for your machine's specific requirements.
  • Ensure that the G21 code is set before any subsequent tool movements to avoid unexpected results.

Related Articles