Search This Blog

Monday, December 01, 2014

G20 & G21 (Unit Selection Codes)

G-Code G20 & G21 (Unit Selection Codes):

The CNC Programming can be done either with Imperial Unit (Inches G20) or The Metric Unit (Millimeter G21).  The following items are also changed depending on whether G20 or G21 in the programs.
1) Positioning command values (X, Y and Z).
2) Incremental movement distances.
3) Feed rates commanded by the F code.
4) Offset values.
In the world the US, Canada region are particularly use in inches, and other part of the world used Millimeter and some parts they use both inches and Millimeter depending on their requirements.
Lowest input value in G20 (Inch) is 0.0001 inch and the Lowest input value in G21 (Millimetre) 0.001 mm, this give an advantage for G21 for more accuracy.

NOTE: G20 and G21 are the modal G-codes, so G20 can only be cancelled by G21 and vice versa.

NOTE:  Units have to be defined in the beginning of the program or else Machine considers the default set by previous programs.

NOTE: Units cannot be reversed by changing only G20 or G21 in your program. It has to be defined before Post processing the program.

Example G20 Inch programming selection:

N170 O1000
N171 T02 M06
N172 G20
N173 G94 G54 G00 X10 Y10 Z100


G21 metric programming selection:

N170 O1000
N171 T02 M06
N172 G21
N173 G94 G54 G00 X10 Y10 Z100

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Good post. I was searched this topic. Finally I got the information in this blog. Thanks for posting such a nice article. CNC milling

    ReplyDelete