Skip to main content
CNC.wiki

G20 Inch Input: Guide to CNC Inch Programming and Unit Selection

Master the G20 G-code for inch programming on Fanuc, Siemens, and Mitsubishi CNCs. Learn parameter settings, offset conversions, and how to avoid turret crashes.

Hakan Gündoğdu
Hakan Gündoğdu

CNC CARE Co-founder

Introduction

Driving the tool carrier straight into a table-mounted vise jaw, a pneumatic fixture clamp, or the rotating workpiece chuck is the immediate hazard when switching between inch and metric units mid-program. When an operator toggles the active unit mode without manually recalculating offsets, the control will not mathematically convert the coordinates, causing a programmed position of X60.0 mm to evaluate as a massive X60.0 inches. This sudden scaling error triggers a catastrophic hard collision, shattered tooling, a destroyed spindle, a ruined scrap part, and an axis overtravel alarm code. Declaring the G20 (System A/B) / G70 (System C) command requires strict adherence to initialization parameters and block format constraints to prevent these mechanical failures.

Selecting G20 activates the command units for geometric dimensions, coordinate shifts, active feedrates, and offset values. To ensure the preprocessor parses these commands without scanner errors, the unit selection code must be programmed completely alone at the start of a block. Proper coordination of default power-on states, reset masks, and safety boundaries on Chuck Barrier screens is necessary to safeguard the machine setup before any cutting begins.

Technical Summary

ParameterSpecification Details
Command CodeG20 (System A/B) / G70 (System C) / G700
Modal GroupGroup 06 (Modal)
Supported BrandsFanuc, Siemens, Mitsubishi
Critical ParametersFanuc Parameter No. 3402, Parameter No. 5040 Bit 3 (TCT); Siemens MD10240, MD20154; Mitsubishi Parameter #1041, Parameter #1003
Main ConstraintMust be programmed completely alone in an independent block at the start of a block. Linear axes only (Mitsubishi).

Quick Read

  • Program Alone: Program G20 completely alone at the start of a block to prevent scanner compilation or format errors.
  • Verify Offsets First: Clear active tool offsets and compensations before calling G20 to prevent incorrect trajectory shifts.
  • No Auto-Conversion: Understand that standard G20 does not mathematically convert coordinate registers, causing a hazardous 10-fold or 25.4-fold positioning error.
  • Set Power-On Defaults: Configure default startup units via Parameter No. 3402 (Fanuc), MD20154 (Siemens), or Parameter #1041 (Mitsubishi).
  • Use Chuck Barriers: Define virtual boundaries on Chuck and Tailstock Barrier screens to automatically halt axis movement in case of axis overtravel.
  • Scale Velocities with G700: Use Siemens G700 when tool offsets and feedrates must scale dynamically alongside coordinate data.
  • Perform Dry Runs: Run first-article program checks in the air to verify tool paths clear physical clamps before cutting.

Basic Concepts

The G20 command alters the unit interpreter of the CNC controller, allowing geometric dimensions, coordinates, and offsets to be calculated and executed in inches. However, the command does not dynamically scale active coordinates or display registers. If a system is toggled between metric and inch modes without clearing offsets, the values in the active registers remain unchanged, causing an unexpected scale mismatch. For instance, a programmed coordinate position of 60.0 mm in metric mode evaluates as a massive 60.0 inches when G20 is activated, creating a 25.4-fold positioning error.

In addition to coordinate mismatch, the separation between Program Command Units and Input Setting Units is a critical concept. Toggling G20 only modifies subsequent program coordinate data; it does not change how tool offsets or workpiece coordinates are configured on HMI screens. These display settings are controlled by static system parameters, such as Mitsubishi parameter #1041. Operators must manually calculate, preset, and enter tool offsets to match the system's input configuration. Switching unit modes without verifying active offsets leads to incorrect trajectories, risking tool turret crashes into workholding equipment.

To mitigate mechanical hazards, CNC systems require physical barrier configurations. Virtual safety zones such as Chuck Barriers and Tailstock Barriers are defined in the machine coordinate system. If an uncoordinated axis shift or unit-mismatch trajectory forces the turret to cross these electronic boundaries, the control immediately halts axis travel and triggers a stroke limit alarm. Performing first-article dry runs in the air and validating coordinates on position screens are mandatory steps before commencing active cutting.

Command Structure

To program in inches, the G20 command must be executed at the beginning of the program. It must be written on a block by itself, preceding any coordinate movement. The command is modal, meaning once called, it remains active until explicitly canceled by G21. When writing programs that switch units, programmers must ensure all coordinate compensation is deactivated before the switch. Setting the system to G20 changes the command unit for linear coordinates, feedrates, and circular interpolation parameters.

The system parameters define how coordinate data is parsed. If leading-zero suppression is active, a value without a decimal point is interpreted differently depending on the unit mode. For instance, a command of Z1000 is processed as Z0.1 inches under G20 but Z1.0 mm under G21. Programmers must use explicit decimal points for all coordinates to prevent scaling errors. Modifying the unit system also requires adjusting system data. Dynamic coordinate offsets can be loaded via G10 parameter management commands, which must be canceled with G11 programmable data input cancel on compatible controllers.

The syntax for initiating inch mode across brands is as follows:

G20 ;

The active coordinates and parameters scale according to the following addresses and parameters:

Address / ParameterSystem DescriptionScaling Behavior
X, Y, ZLinear geometry coordinatesInterpreted as inches when G20 is active.
I, J, KInterpolation parameter valuesCalculated in inches for arc center definitions.
RCircle radius coordinateInterpreted in inches for radial arcs.
FFeedrate commandEvaluated in inches per minute (in/min) or inches per revolution (in/rev).

Brand Applications

Fanuc

On Fanuc controls, G20 sets the active linear command unit to inches. The default startup unit is controlled by Parameter No. 3402. System offsets and length compensations are affected by Parameter No. 5040 Bit 3 configuration.

The following block initializes the G20 command on Fanuc systems:

G20 ;
  • Parameter No. 3402: Dictates the default G-code modal states upon control power-on.
  • Parameter No. 5040 Bit 3 (TCT): Manages tool length compensation shift types. Altering this during active offsets triggers Alarm PS0368.
  • Parameter No. 3453 Bit 4 (FRC): Enables chamfer and corner R feedrates via address E. Programming E during threading triggers Alarm PS0009.
  • Alarm PS0368: Triggered when Parameter No. 5040 Bit 3 is modified while tool offsets remain active.
  • Alarm PS0011: Issued if the programmed feedrate exceeds the maximum limit set in machine parameters.
  • Alarm PS0010: Occurs when a G-code not listed in the standard table is programmed.
  • Version Difference (G-code Systems): Fanuc G-code System A and B use G20/G21, whereas System C uses G70/G71.
  • Version Difference (Series 15): Legacy Series 15 systems utilize G84.2 for rigid tapping, while standard systems use G84.

Warning: Switching between G20 and G21 mid-program without canceling tool offset registers causes severe coordinate scaling errors, driving the tool turret off-trajectory.

Siemens

Siemens SINUMERIK controls support G20 through their ISO Dialect Mode. The default system state at reset is determined by channel-specific data parameter MD20154. Standard machine resolution and units are defined by parameter MD10240, which governs feedrates, tool offsets, and adjustable work offsets unless native G700 is invoked.

The following block initializes the G20 command on Siemens controls:

G291 ;
G20 ;
G290 ;
  • MD20154 ($MC_EXTERN_GCODE_RESET_VALUES): Defines the default Group 6 G-code active on reset or startup.
  • MD10240 (SCALING_SYSTEM_IS_METRIC): Establishes the default base measuring system of the machine.
  • MD18800 ($MN_MM_EXTERN_LANGUAGE): General machine data that must be set to 1 to enable ISO dialect interpretation.
  • Option Bit 19800 ($MN_EXTERN_LANGUAGE): System option bit required to allow external ISO language programming.
  • MD20734 Bit 3 ($MC_EXTERN_FUNCTION_MASK Bit 3): Prevents alarms on ISO scanner errors, forwarding blocks to the native translator.
  • Alarm 61800: Triggered if G20 is parsed when MD18800 or Option Bit 19800 is disabled.
  • Alarm 14800: Triggered if path feedrate F evaluates to zero under G20 because metric feedrates did not scale.
  • Alarm 61811: Issued if the G20 block contains an axis identifier not configured in the active channel.
  • Alarm 61812: Occurs when an external cycle call contains an illegal numeric value.
  • Version Difference (SINUMERIK 802D sl): The reset configuration MD20154 and PLC parameter MD22515 are locked as read-only on the 802D sl. Higher-end models like the 840D sl allow these parameters to be modified.

Warning: Activating G20 without programming a new feedrate value (F) immediately after can cause feedrates to resolve to zero, triggering Alarm 14800 and halting machine movement.

Mitsubishi

Mitsubishi controls use G20 to define the program command unit for linear axes. Initial units at power-on are managed by Parameter #1041. Axis resolution settings are established by Parameter #1003, which configures coordinate increments from 0.0001 inches to 0.0000001 inches.

The following block initializes the G20 command on Mitsubishi controls:

G20 ;
  • Parameter #1041 I_inch: Sets the default unit system for HMI displays, counters, and parameters at power-on.
  • Parameter #1003 iunit: Input Setting Unit. Configures axis resolution (B=0.0001 in, C=0.00001 in, D=0.000001 in, E=0.0000001 in).
  • Parameter #1151 rstint: Determines the initialization status of G-groups at system reset.
  • Parameter #1210 RstGmd Bit 5: Specifies if Group 06 modal G-codes are reset or retained at startup/reset.
  • Program Error P33: Triggered when G20 or G21 is programmed in the same block as other movement commands.
  • Program Error P162: Occurs when toggling units while 3D tool radius compensation (G41.2/G42.2) is active.
  • Program Error P951 / P942: Triggered if a unit switch is called while G176 (Inclined Surface) or G174 (Tool Center Point) control is active.
  • Version Difference (Sequence Numbers): Sequence number address N supports up to 8 digits on the M8 Series, but is restricted to 6 digits on the C80 Series.
  • Version Difference (G10 L50): Programmable parameter entry using G10 L50 is restricted to legacy models and unsupported on the modern M8 Series.

Warning: Mitsubishi restricts G20/G21 commands strictly to linear axes. Any rotational axes configured in the system will bypass unit scaling completely, risking sync errors in multi-axis setups.

Brand Comparison

FeatureFanucSiemensMitsubishi
G-code System SupportSupports System A/B (G20/G21) and System C (G70/G71).Supports G20/G21 inside ISO Dialect Mode (G291).Supports G20/G21 inside modal G-code system.
Coordinate Conversion MismatchToggling units does not mathematically convert coordinate values (causes 10-fold shift).Toggling units mid-program does not convert coordinate registers (causes 25.4-fold shift).Toggling units changes only program unit interpretation; screen registers do not convert.
Tool Offset & Feedrate ScalingTool length and compensation offsets scale depending on active units, subject to parameter No. 5040 (TCT) constraints.Standard G20 does not scale tool offsets or feedrates automatically; requires native G700/G710 commands.Separation of input units and program units; offsets and coordinate systems do not scale with G20/G21.
Rotational Axes Unit ScalingSupports conversions that interact dynamically with rotary vectors.Supports conversions that interact dynamically with rotary vectors.Restricts unit scaling to linear axes only; rotation axes are completely ignored.

Technical Analysis

The handling of unit selection commands reveals significant architectural differences between Fanuc, Siemens, and Mitsubishi controllers. Fanuc systems differentiate their command unit selection based on G-code systems. In Systems A and B, G20 and G21 are the standard modal commands. In G-code System C, however, the control utilizes G70 and G71 to perform the equivalent functions. In addition, Fanuc interprets coordinates with leading-zero suppression based on the active unit. For example, a command of Z1000 without a decimal point resolves to Z0.1 inches when G20 is active, but is interpreted as Z1.0 mm when the control is set to G21 metric mode. This creates a critical programming variance that operators must account for when migrating G-code files between machines.

Siemens SINUMERIK controls approach unit selection through a bilingual interpreter structure. The G20 command is restricted to the ISO Dialect Mode, enabled via G291. To utilize high-level parametric cycles or system variables (such as $TC_DPH tool offsets), programmers must transition the control back to native Siemens Mode using G290. When operating in native mode, Siemens uses G70 for inch dimensions. However, a major difference lies in feedrate and offset scaling. While standard G20/G70 commands only scale positional data, the native G700 and G710 commands scale both geometric coordinates and technological values, including feedrate (F) and active offsets. This prevents velocity mismatch errors. On lower-end models like the SINUMERIK 802D sl, reset data values (MD20154) are locked as read-only, whereas high-end series like the 840D sl permit full modification of these default startup units.

Mitsubishi controllers isolate program command unit interpretation from HMI offset configuration. Activating G20 only influences coordinates within the active program block; it does not scale HMI offsets, which are fixed by Parameter #1041. This is a rigid separation not present in Fanuc or Siemens controls. Additionally, Mitsubishi is unique in restricting unit command scaling exclusively to linear axes, completely ignoring rotational axes during conversions. Finally, Mitsubishi maintains a fixed metric PLC window. Regardless of HMI configurations or G20 commands, all data transferred via the PLC window is processed in metric units, requiring PLC logic to maintain a permanent metric calculation structure.

Program Examples

Fanuc Example

%
O1001 (FANUC G20 INCH SELECTION) ;
G20 ; (Activate inch input mode in an independent block)
G00 X6.0 Z3.0 T0800 ; (Rapid position to X6.0 inches, Z3.0 inches, tool offset 0)
G04 U2.0 ; (Dwell for 2.0 seconds in imperial format)
G21 ; (Restore metric input mode in an independent block)
M30 ;
%

Dry run: Before running this code, the operator verifies that all tool offsets are canceled. When G20 is read, the controller switches its interpreter to imperial units. The turret moves rapidly to X6.0 inches and Z3.0 inches relative to the workpiece zero. The machine dwells for 2.0 seconds, then G21 is read, reverting the command system to metric coordinates. The operator verifies that the axis movements did not exceed the soft travel limits.

Siemens Example

; SIEMENS G20 ISO DIALECT SELECTION
G291 ; (Switch compiler to ISO Dialect Mode)
G20 ; (Activate inch input mode)
G00 X2.75 Y3.22 ; (Rapid position to X2.75 inches, Y3.22 inches)
G290 ; (Switch compiler back to native Siemens Mode)
G70 X2.75 Y3.22 ; (Position using native Siemens inch dimensioning)
M30 ;

Dry run: During the dry run, the operator executes the program block-by-block. The compiler transitions from native Siemens Mode to ISO Dialect Mode (G291). The G20 command activates inch data interpretation. The axes travel to absolute position X2.75 inches and Y3.22 inches. The control then returns to Siemens Mode (G290), where the G70 command executes positioning to the same physical coordinates. The operator checks the active position HMI screens to confirm that coordinates match the expected inch measurements.

Mitsubishi Example

%
; MITSUBISHI G20 INCH SELECTION
G20 ; (Activate inch program command units on linear axes)
G00 X6.5 Z3.22 ; (Rapid position to absolute coordinates in inches)
G21 ; (Cancel inch input and restore metric command units)
M30 ;
%

Dry run: The operator loads the program and verifies that parameter #1041 matches the HMI setup. The G20 command is parsed in a block by itself, configuring the program command units to inches. The linear axes travel to X6.5 inches and Z3.22 inches, while any rotational axis positions remain unscaled. Reading G21 restores the default millimeter command system. The operator monitors the HMI display to ensure that no coordinate scaling anomalies occurred during the transition.

Error Analysis

BrandAlarm CodeTrigger ConditionOperator SymptomRoot Cause / Fix
FanucAlarm PS0368Modifying Parameter No. 5040 Bit 3 (TCT) while tool offsets are active in the registers.Automatic execution halts, and the screen displays Alarm PS0368.Clear all tool offsets and deactivate compensation before modifying Parameter No. 5040.
FanucAlarm PS0011Programmed cutting feedrate exceeds the maximum feedrate limit set in the machine parameters.Axis motion stops, displaying Alarm PS0011.Verify the active feedrate F and adjust the programmed velocity within the allowable machine parameters.
SiemensAlarm 61800G20 executes while external language parameter MD18800 or Option Bit 19800 is deactivated.The control system stops processing and displays Alarm 61800 ("External CNC system missing").Set machine data parameter MD18800 to 1 and ensure the Option Bit 19800 is active.
SiemensAlarm 14800Path feedrate F evaluates to zero because the metric feedrate failed to scale after activating G20.Execution halts at the first linear movement, displaying Alarm 14800.Program a new F value (feedrate) immediately after the G20 block to establish the active feedrate in inches.
MitsubishiProgram Error P33Programming G20 or G21 in the same block as coordinate movements or other G-codes.NC scanner halts execution, triggering Program Error P33 ("Illegal G-code command format").Ensure the G20 command is programmed completely alone in its own independent block.
MitsubishiProgram Error P162Toggling units (G20/G21) while 3D tool radius compensation (G41.2/G42.2) is active.Automatic cycle halts, displaying Program Error P162 on the control panel.Program a G40 command to deactivate all 3D tool radius compensation before switching unit systems.

Application Note

Shattering tooling and ruining a workpiece chuck during rapid coordinate transitions is the direct consequence of initiating G20 unit switching while offset registers contain un-canceled values. Because standard G20 commands do not dynamically scale existing offset parameters, a 10-fold or 25.4-fold positioning error occurs if an operator executes a unit change mid-program. To prevent the tool turret from colliding with a table-mounted vise jaw or pneumatic fixture clamps, operators must configure virtual electronic envelopes using the Chuck and Tailstock Barrier screens on the control unit. Additionally, programmers must enforce the independent block rule, ensuring the G20 command is parsed completely alone at the start of the program, followed by a manual offset recalculation to match the new units.

Related Command Network

  • G21 (Metric Data Input): Cancels the active G20 inch mode and restores the default metric (millimeter) command unit system.
  • G700 (Siemens Native Inch System): Automatically scales both geometry coordinates and technological parameters (such as feedrate and offsets) to inches.
  • G291 (Siemens ISO Dialect Mode): Enables the interpreter to recognize external ISO dialect G-codes, including G20.
  • G10.9 (Mitsubishi Diameter/Radius Switch): Toggles the dynamic diameter or radius designation for coordinate axes, which interacts with unit scaling.

Conclusion

Successful imperial programming depends on strict isolation of unit-selection commands and active verification of offset registers. Program G20 in a block completely by itself at the program start, and coordinate parameter changes with the machine's default setup. Double-check HMI display systems and perform air cuts to verify that coordinate transitions do not cause unintended axis travel near workholding fixtures.

FAQ

Does G20 automatically convert my tool offsets from metric to inches?

No, standard G20 only changes the interpretation of program coordinates. Active tool offsets, work coordinates, and feedrates must be manually recalculated and re-entered, or scaled using advanced commands like Siemens G700 to prevent collisions.

Can I program G20 in the same block as a rapid coordinate movement?

No, programming G20 with coordinate coordinates in the same block triggers alarms like Mitsubishi Error P33 or Fanuc format errors. Always write G20 in an independent block completely by itself at the very beginning of the program.

Why does the feedrate fail to scale when I switch to G20 on Siemens controls?

Standard G20 does not scale velocities or feedrates, which can result in a zero-feed condition and trigger Siemens Alarm 14800. Program a new F feedrate value immediately after the G20 command to define the feed speed in inches.

Still not resolved?

Ask our AI assistant about this topic in natural language. Grounded in verified sources, no hallucinations.

Ask AI Assistant
Hakan Gündoğdu
Hakan Gündoğdu
  • CNC CARE Co-Founder (May 2025 - Present)
  • Mitsubishi Electric NC Sales & Service Section Manager (2008 - 2025)
  • Reis CNC Service Engineer (2003 - 2008)
  • Ören Kalıp CNC Mold Line Team Leader (1999 - 2002)

With over 25 years of experience working in all areas of the CNC machine industry, I continue my activities as a co-founder of CNC CARE, where we offer brand-independent consulting, engineering, and original spare parts services.

Related Articles

Other articles on this topic