Login to enhance your online experience. Login or Create an Account

G20 and G21 - Length Units

Details:
Program G20 to use inches for length units and program G21 to use millimeters. It is usually a good idea to program either G20 or G21 near the beginning of a program before any motion occurs and not to use either one anywhere else in the program. It is the responsibility of the user to be sure all numbers are appropriate for use with the current length units.
  • G20 Example

    Last Updated Feb 28, 2011
    - Download G20 Code Example   


    (Sample Program G20EX9:)
    (Workpiece Size: X4, Y2, Z1)
    (Tool: Tool #2, 1/4" Slot Drill)
    (Tool Start Position: X0, Y0, Z1)

    N2 G90 G80 G40 G54 G20 G17 G50 G94 G64 (safety block)
    N5 G90 G20 (Set inch mode)
    N10 M06 T2 G43 H2
    N15 M03 S1000
    N20 G00 X1 Y1
    N25 Z1
    N30 G01 Z-0.125 F5
    N35 X3.625 F15
    N40 Y1.75
    N45 G00 Z1
    N50 X0 Y0
    N55 M05
    N60 M30

  • G21 Example

    Last Updated Feb 28, 2011
    - Download G21 Code Example   


    (Sample Program G21EX10:)
    (Workpiece Size: X100, Y75, Z25)
    (Tool: Tool #2, 8mm Slot Drill)
    (Tool Start Position: X0, Y0, Z25.4)

    N2 G90 G80 G40 G54 G20 G17 G50 G94 G64 (safety block)
    N5 G90 G21 (Set metric programming mode)
    N10 M06 T2 G43 H2
    N15 M03 S1200
    N20 G00 X-5 Y5
    N22 Z3
    N25 G01 Z-8 F30
    N35 G01 X90 F300
    N40 X95 Y20
    N45 Y50
    N50 G03 X75 Y65 R15
    N55 G01 X40 Y50
    N60 G02 X0 Y10 R40
    N65 G00 Z25.4
    N70 Y0
    N75 M05
    N80 M30

  • All Machine Code Reference Examples

    Last Updated Sep 16, 2016
    - Download Machine Code Reference Examples