Skip to main content
CNC.wiki

G18 G-Code Guide: ZX Plane Selection in CNC Programming

Master G18 ZX plane selection in Fanuc, Siemens, and Mitsubishi CNC systems. Configure parameters, resolve alarms, and prevent tool nose compensation collisions.

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

CNC CARE Co-founder

Introduction

A catastrophic hard collision where the lathe turret plunges directly into the revolving workpiece chuck, table-mounted vise jaws, or pneumatic fixture clamps is the direct physical consequence of a misconfigured G18 ZX working plane. During high-speed machining transitions on multi-axis turning centers, an incorrect coordinate shift or an unverified offset recalculation will drive the cutting tool off-trajectory. The resulting impact destroys the machine spindle, fractures expensive tooling, and produces a completely ruined scrap part. Operators and programmers must enforce rigorous spatial coordinate alignment to prevent mechanical components from colliding during rapid movements.

If a programmer fails to verify the active working plane prior to calling contour profiles on multi-axis turning centers, the control system defaults to standard milling configurations. This causes radius and tool nose compensation vectors to calculate incorrectly, leaving uncut material or deep gouges in the metal. Establishing safety barriers and verifying default startup parameters are essential operational steps to safeguard the machine and maintain precise geometrical tolerances.

Technical Summary

Technical AspectSpecification Details
Command CodeG18 (ZX Plane Selection)
Modal GroupGroup 02 (Fanuc, Mitsubishi Lathe List 3) / Group 06 (Siemens SINUMERIK, Mitsubishi MC List 1)
Brands CoveredFanuc, Siemens, Mitsubishi
Critical ParametersFanuc: No. 3402, 1022, 5101#0 (FXY); Siemens: MD20150, MD10604; Mitsubishi: #1025, #1080
Main ConstraintPlane changes (G17/G18/G19) are strictly forbidden while tool nose or cutter radius compensation (G41/G42) is active.

Quick Read

  • Cancel Compensation Before Switching: Always program a G40 command to deactivate tool nose radius compensation (G41/G42) before changing planes to avoid Alarm PS0037 or Program Error P411.
  • Define Safety Clearance Zones: Configure and enable the electronic safety envelopes on the Chuck Barrier and Tailstock Barrier screens on the CNC control display to prevent physical turret contact.
  • Verify Tapping Axis Parameters: Set Fanuc Parameter 5101 Bit 0 (FXY) or Siemens _AXN=1 cycle parameter to handle drilling and tapping along the proper axis without manual plane switching.
  • Determine Coordinate Syntax: Program absolute movements via X and Z, and incremental movements via U and W under Fanuc Lathe G-code System A, where G90 acts as a canned turning cycle.
  • Isolate Interpreter Compilers: Use Siemens G290 and G291 to toggle native Sinumerik modes and external ISO Dialect programs when accessing high-level system parameters.
  • Enable Axis Name Switch: Command G111 on Mitsubishi controls to dynamically map and swap horizontal and vertical axes in the active G18 plane during program execution.

Basic Concepts

Selecting G18 establishes the orthogonal Z/X working plane on turning configurations and lathes. Under G18, Z represents the long, longitudinal axis of workpiece geometry, X represents the cross-slide or diameter axis, and the Y-axis is reserved for the vertical tool or drilling axis. The practical programming effect is that it establishes the proper two-dimensional plane for tool nose radius compensation (G41/G42), circular interpolation (G02/G03), and complex canned cycles. If the programmer fails to verify the active working plane prior to calling contour profiles on multi-axis turning centers, the control will default to standard milling configurations, causing radius and tool length compensation vectors to calculate incorrectly, leaving uncut material or deep gouges on the part.

Circular interpolation commands G02 and G03 rely on arc center modifiers to define geometry in the active plane. When G18 is active, these center modifiers map to the X-axis as I and the Z-axis as K. The CNC uses these coordinates to calculate the arc radius from the current start point. Programming incorrect modifiers or mixing coordinate systems will trigger interpreter errors, halting the machine midway through a cut and leaving witness marks on high-value parts.

Command Structure

The G18 command is a modal instruction that remains active until it is overridden by another plane selection code (such as G17 for XY or G19 for YZ). To prevent mathematical errors in the interpreter, the command should be declared in a standalone block before any motion commands or offset calls are executed. The horizontal abscissa axis maps to Z, the vertical ordinate maps to X, and the applicate or perpendicular tool axis maps to Y.

When coordinate remapping or parallel axes (like U, V, or W) are configured, the command structure can include secondary parameters. These parameters designate the physical axes to use for plane mapping. On controls that support dynamic remapping, specifying axis addresses directly in the G18 block redefines the coordinate system layout for subsequent commands.

Syntax Specifications:

  • Fanuc: G18 ;
  • Siemens: G18
  • Mitsubishi: G18 ; or G18 Xp Zp ;

System Parameters Table:

BrandParameter NameSystem DescriptionValue Range
FanucParameter No. 3402Configures the default plane active at system startup or reset.0: G17, 1: G18, 2: G19
FanucParameter No. 1022Sets parallel axis definitions for mapping parallel coordinate systems (U, V, W).Positive integers
FanucParameter No. 5101 Bit 0 (FXY)Determines drilling axis behavior. Switches drilling axis dynamically with plane.Binary (0 or 1)
FanucParameter No. 5209 Bit 0 (RTX)Controls drilling axis during side face rigid tapping (G88).Binary (0 or 1)
SiemensMD20150 ($MC_GCODE_RESET_VALUES[5])Channel-specific machine data defining reset state of G-group 6.1: G17, 2: G18
SiemensMD10604 ($MN_WALIM_GEOAX_CHANGE_MODE)Controls working area limitation during geometry axis switchover.0: Deactivate, 1: Retain
SiemensMD18800 ($MN_MM_EXTERN_LANGUAGE)Activates compilation and execution of external NC programs (ISO Dialect).0 or 1
SiemensMD20734 ($MC_EXTERN_FUNCTION_MASK) Bit 3Controls external parser behavior (scanner error bypass).Binary (0 or 1)
MitsubishiParameter #1025 I_planeControls default active plane selection at system power-on.0 to 2 (2 is G18)
MitsubishiParameter #1080 Dril_ZRestricts coordinate rotation tapping to G17 if set to 1.Binary (0 or 1)
MitsubishiParameters #1026 to #1028Configures primary physical geometry axes for plane mapping.Axis identifiers
MitsubishiParameters #1029 to #1031Sets parallel axes (typically U, V, W) for dynamic substitution.Axis identifiers

Brand Applications

Fanuc

Operating G18 on Fanuc lathe systems involves setting default startup states and defining parallel axes to prevent toolpath errors. The default plane at power-on is set via Parameter No. 3402, and parallel axis associations are mapped using Parameter No. 1022 to coordinate incremental motion.

To program G18 on a Fanuc lathe using G-code System A, absolute movements use X and Z, while incremental moves use U and W: G18 G90 G01 G41 X120.0 Z-80.0 F150 ; (Note: G90 in System A behaves as a canned turning cycle, so absolute mode is determined by axis name rather than G90).

  • System Parameters: Parameter No. 5101 Bit 0 (FXY) controls the drilling axis (0: Z remains drilling axis, 1: switches dynamically to Y in G18); Parameter No. 5209 Bit 0 (RTX) specifies side face rigid tapping axes.
  • System Alarms: Alarm PS0037 triggers if changing planes with G41/G42 active; Alarm PS0330 halts if an axis outside the G18 plane is programmed in turning canned cycles; Alarm PS0055 is active if chamfering axes do not match active plane coordinates; Alarm PS0064 halts if finishing shapes are non-monotonous along the Z-axis in G71/G72 Type II cycles.
  • Version Differences: Lathe G-code System A eliminates absolute/incremental modal codes G90/G91; legacy Series 15 format G84.2 rigid tapping selects tapping axis based purely on G18 plane, whereas Series 16 uses G88; Type II pocket roughing retraction starts immediately along the X-axis at block boundaries.

Warning: Attempting to toggle planes while tool nose compensation is active will cause an immediate system halt. Always cancel compensation with G40 before executing a G18 command.

Siemens

Siemens SINUMERIK controls integrate G18 with channel-specific reset values and geometry axis switchover settings to maintain workspace security. The active G-code reset state is configured via MD20150, and working area limitations are governed by MD10604 during coordinate switches.

To program G18 on Siemens controls, absolute coordinates are specified via Z and X, and the perpendicular tool length infeed is mapped to Y: G18 G90 G01 G41 Z100.0 X50.0 Y-5.0 F150 ;.

  • System Parameters: MD18800 activates compilation of external NC languages (ISO Dialect); MD20734 Bit 3 controls external scanner error bypassing (0: alarm on syntax error, 1: bypass scanner errors and forward directly to Siemens native translator).
  • System Alarms: Alarm 14800 triggers if programmed path velocity is less than or equal to zero; Alarm 61800 occurs if external language option MD18800 is inactive during an ISO program call; Alarm 61815 occurs if G41/G42 is active when calling standard turning cycles.
  • Version Differences: SINUMERIK 802D sl locks geometry axis working area parameter MD10604 as read-only; widescreen HMI touchscreen ABC keys are supported on 840D sl but unavailable on legacy panels; multi-edge turning G51.2 is supported on 840D sl but unavailable on 802D sl.

Warning: Programmers must cancel tool radius compensation (G40) before retracting tools from G18 contours to avoid sudden compensation vector moves that can crash the turret.

Mitsubishi

Mitsubishi systems control G18 startup defaults and axis mapping to ensure safe coordinate transitions on lathes and milling systems. The startup default plane is controlled by Parameter #1025, and coordinate rotation tapping limits are governed by Parameter #1080.

Mitsubishi programs issue G18 to select default basic geometry axes: G18 X0 Z0;. Programmers can also command G111 XY; to dynamically swap axis assignments during cycle execution.

  • System Parameters: Parameters #1026 to #1028 define basic axes I, J, K; Parameters #1029 to #1031 define flat/parallel axes U, V, W; Parameter #1148 governs high-accuracy control mode at power-up.
  • System Alarms: Program Error P111 occurs if tapping under coordinate rotation is executed on G18 when #1080 Dril_Z is set to 1; Program Error P411 halts if G111 axis switching is commanded under active compensation; Program Error P396 triggers if conflicting planes are called during geometric calculations.
  • Version Differences: Programmable parameter inputs via G10 L50 are locked out on modern M8 Series; Software version C3 upgrades on M800V/M80V added G187 thread milling and G53.1 tool axis control; G18 belongs to modal Group 02 on lathes and Group 06 on machining centers based on active formats.

Warning: Do not command G111 axis switching while tool nose radius compensation is active. Program G40 to cancel compensation before changing axis names.

Brand Comparison

Comparison AspectFanucSiemensMitsubishi
Interpolation PlaneZ-X orthogonal plane. (Z is 1st/abscissa, X is 2nd/ordinate, Y is perpendicular tool axis).Z-X plane. (Z is 1st geometry/abscissa, X is 2nd geometry/ordinate, Y is 3rd geometry/perpendicular tool axis).Z-X plane. (K/Z is horizontal/abscissa, I/X is vertical/ordinate, Y is perpendicular tool axis).
Coordinate ModeLathe G-code System A: X/Z for absolute, U/W for incremental. G90/G91 not supported (G90 is canned turning cycle).Standard G90 (absolute) and G91 (incremental) modal states.Standard G90 (absolute) and G91 (incremental) modal states.
Drilling Cycle LogicRequires physical plane switch to G17, or parameters 5101/5209 to switch active drilling axis.G18 remains active; use cycle parameter _AXN=1 to drill along Z-axis directly.Requires physical plane switch to G17, or parameter #1080 config for boring axis limit.
Axis Remapping / SwitchingStatic parameter-based mapping (Parameter No. 1022).Static parameter-based mapping (TRANSMIT/TRACYL kinematics).Dynamic runtime remapping via G-code command G111 (Axis Name Switch).
Interpreter SelectionSingle native Fanuc interpreter.Bilingual: Switched via G290 (native) and G291 (ISO Dialect) commands.Multi-format G-code list formats configured via cmdtyp parameters.

Technical Analysis

Three distinct behaviors clearly differentiate Fanuc's G18 operations from Siemens and Mitsubishi controls. First, Fanuc's standard lathe-specific G-code System A address structure eliminates absolute/incremental modal G-codes (G90/G91). Absolute coordinates are programmed using X and Z addresses, while incremental values use U and W. Under G-code System A, commanding G90 actually initiates a longitudinal turning cycle rather than setting absolute mode. This contrasts sharply with Siemens and Mitsubishi, which maintain standard G90/G91 modal states across both milling and turning coordinate paths.

Second, Fanuc lathe systems utilize a unique multiple repetitive cycle pocket cutting logic (G71 Type II). During pocket cutting in a roughing cycle, Fanuc first cuts the nearest pocket to the start point, whereas other systems may use different calculation algorithms. Also, during G71 roughing under G18, if the tool moves only along the first axis (Z) for a chamfer, Fanuc immediately starts its retraction directly along the second axis (X) at the block boundary. This conservative path-recovery philosophy is designed to protect legacy program profiles from overcutting, a hardware-software bridge not found in Siemens or Mitsubishi interpreters.

Third, Mitsubishi controls feature a highly flexible G111 Axis Name Switch command, allowing the programmer to dynamically switch the physical geometry axes representing G18 ZX on-the-fly. Fanuc controls, conversely, rely on rigid parameter configurations (like parameter No. 1022) and do not support runtime remapping via G-code commands.

Furthermore, Siemens implements a highly advanced bilingual transition architecture via G290 (native mode) and G291 (ISO Dialect mode). While other controls treat G18 plane mapping as a static background calculation within a single interpreter, Siemens isolates ISO G-code structures strictly inside G291 mode. This allows legacy programs to run seamlessly, while providing the unique capability to switch directly to native mode (G290) in the same file to program high-level system parameters (such as tool cutting edge variables like $TC_DP1 or coordinate frame transformations) without requiring separate ISO-only control setups. Additionally, Siemens offers the _AXN tool axis drilling parameter. While Fanuc and Mitsubishi controls require the programmer to perform a physical plane switchover from G18 to G17 in order to map standard face-drilling and face-tapping cycles, Siemens allows the lathe programmer to keep G18 active and simply designate the active drilling geometry axis via _AXN=1, completely avoiding plane-switching errors. Siemens also features dynamic Cycle Parameter HMI adapting where, in standard ShopMill and ShopTurn graphical programming cycles, when the user changes the plane selection parameter (PL) from G17 to G18, the interface dynamically re-adapts. The horizontal and vertical reference points are automatically renamed on-the-fly to ZO and XO (matching the active axes of the G18 plane), and the tool axis depth parameter is renamed to Y1 (matching G18's vertical infeed axis). This dynamic graphical and lexical re-adapting of HMI parameters on-the-fly represents a highly customized technology-to-geometry integration unique to Siemens SINUMERIK.

Program Examples

Fanuc Example

%
O0001 (FANUC G18 EXAMPLE) ;
G18 ; Select Z-X plane
G00 U0 W0 ; Rapid positioning (incremental coordinates)
G41 X120.0 Z-80.0 F150 ; Activate left-hand tool nose radius compensation
G01 Z-120.0 ; Linear turning feed
G40 X150.0 Z-120.0 ; Cancel tool compensation and retract tool
M30 ;
%

dry run: The control activates G18 plane selection. The tool moves to the starting position using incremental coordinates U and W. Tool nose radius compensation is initialized under G41, shifting the toolpath to the left. The machine feeds linearly to the Z-120.0 depth. A G40 command is executed to cancel tool nose compensation before the turret retracts to a safe tool change coordinate.

Siemens Example

N10 G18 T5 D1 ; Select Z/X plane, activate tool 5 and offset D1
N20 G90 G01 G41 Z100.0 X50.0 Y-5.0 F150 ; Absolute motion with cutter compensation
N30 Z-50.0 ; Machine along the Z-axis
N40 G40 G00 X100.0 ; Cancel compensation and retract
N50 M30 ;

dry run: The SINUMERIK control selects G18 for ZX plane selection and applies cutting edge offsets. The Y-axis is set as the perpendicular tool length applicator. Under G90 absolute mode, the tool feeds to coordinate Z100.0 X50.0 Y-5.0 with cutter radius compensation active. The tool cuts along the Z-axis to Z-50.0. To retract safely, G40 cancels the offset, and the axis moves rapidly to X100.0.

Mitsubishi Example

%
O0003 (MITSUBISHI G18 EXAMPLE) ;
G18 ; Select default ZX plane
G00 X0 Z0 ; Rapid move to home axes
G111 XY ; Dynamically swap physical axes representing ZX coordinates
G01 X-20.0 Z-30.0 F100 ; Feed along the dynamically swapped axes
G111 ; Clear axis name switch and return to default parameters
M30 ;
%

dry run: G18 activates the default Z-X plane. The axes rapid-position to X0 Z0. The control executes a G111 command to swap physical coordinate names, mapping subsequent commands to the alternate axes. A linear interpolation pass is completed along the remapped plane, after which G111 is commanded without parameters to reset axis mapping to system defaults.

Error Analysis

BrandAlarm CodeTrigger ConditionOperator SymptomRoot Cause / Fix
FanucAlarm PS0037Plane selection command (G17/G18/G19) is programmed while tool nose compensation (G41/G42) is active.Cycle execution stops instantly, displaying "CAN NOT CHANGE PLANE IN G41/G42" on the screen.A plane switch was attempted during active tool path compensation. Program G40 to cancel compensation before issuing a plane change command.
FanucAlarm PS0064Contour is non-monotone along the first axis (Z-axis in G18) during G71/G72 Type II roughing cycles.The machine halts during the pre-run compilation phase and displays "THE FINISHING SHAPE IS NOT A MONOTONOUS CHANGE".The programmed pocket profile changes direction along the Z-axis, violating monotone rules. Ensure the geometry profile moves in a single direction.
SiemensAlarm 61815Tool radius compensation (G41/G42) is active before calling standard turning cycles (CYCLE374T).The program execution halts at the cycle block, displaying "G40 not active" on the control panel.Turning cycles require raw coordinates. Insert G40 to cancel tool nose compensation immediately prior to calling the cycle.
SiemensAlarm 14800Programmed path feedrate F0 is parsed and the fixed feedrates function is inactive.Axis motion stops, displaying "Channel %1 Set %2 programmed path velocity is less than or equal to zero".A linear/circular interpolation is called without a valid feedrate command. Program a positive F-value (e.g., F150) before motion.
MitsubishiProgram Error P111Tapping cycle during coordinate rotation is executed while G18/G19 is active and boring parameter #1080 is set to 1.The machine immediately halts program execution and displays "TAPPING AXIS LIMIT" or Program Error P111.Mitsubishi limits tapping rotations on G18 when #1080 is enabled. Deactivate coordinate rotation or switch to G17 plane.
MitsubishiProgram Error P411Attempted to execute Axis Name Switching (G111) while tool nose radius compensation is actively applied.Execution halts instantly with Program Error P411.Remapping axes under active compensation is unsafe. Program a G40 command to deactivate compensation before calling G111.

Application Note

A catastrophic hard collision where the lathe turret plunges directly into the revolving workpiece chuck, table-mounted vise jaws, or pneumatic fixture clamps is the direct physical consequence of a misconfigured G18 ZX working plane. During high-speed machining transitions on multi-axis turning centers, an incorrect coordinate shift or an unverified offset recalculation will drive the cutting tool off-trajectory. The resulting impact destroys the machine spindle, fractures expensive tooling, and produces a completely ruined scrap part. Operators and programmers must enforce rigorous spatial coordinate alignment to prevent mechanical components from colliding during rapid movements. To prevent these outcomes, operators must set up and enable the virtual electronic safety zones on the Chuck Barrier and Tailstock Barrier screens on the control display. If a coordinate calculation error or incorrect offset shift forces the turret reference point to enter these restricted envelopes, the control immediately halts travel and displays a stored stroke limit alarm code, protecting the machine from physical contact.

Related Command Network

  • G17 (XY Plane Selection): Establishes the X/Y orthogonal plane, switching interpolation and compensation vectors away from G18's Z/X setup.
  • G19 (YZ Plane Selection): Establishes the Y/Z orthogonal plane, commonly used for face milling or cross-drilling cycles on multi-axis turning centers.
  • G09 (Exact Stop Non-Modal): Forces the control to decelerate and check position at the end of a block before starting the next block, preventing corner rounding on G18 profiles.
  • G16 (Polar Coordinate Command): Activates polar coordinate programming, allowing locations to be specified by radius and angle instead of Cartesian coordinates in the active G18 plane.

Conclusion

Ensuring system stability and toolpath precision requires verifying the active plane before executing canned cycles and contour paths. Confirm default startup parameters (such as Parameter No. 3402, MD20150, or Parameter #1025) on your machine control console to guarantee G18 is automatically loaded on turning systems. Always program a G40 command to clear radius offsets prior to a plane toggle or tool retraction, preventing sudden compensation moves and preserving the mechanical integrity of the machine.

FAQ

Can I switch the working plane while cutter radius compensation is active?

No. Attempting to switch planes (e.g., G18 to G17) while compensation is active will trigger Alarm PS0037 or Program Error P411. Practical action: Always insert a standalone G40 command block to cancel tool nose radius compensation before executing a plane change code.

What parameters control the default active plane at system power-on?

The default startup plane is determined by manufacturer parameters. Fanuc uses Parameter No. 3402, Siemens uses MD20150 channel reset configuration, and Mitsubishi uses Parameter #1025. Practical action: Access the system parameter screen on your control display and change the value (typically to 1 or 2 depending on brand) to ensure G18 defaults active on turning centers.

How do I drill along the Z-axis in G18 without switching planes?

On Siemens controls, you can use the cycle parameter _AXN=1 to force drilling or tapping along the longitudinal Z-axis, keeping the G18 plane active. On Fanuc, verify that Parameter No. 5101 Bit 0 (FXY) is configured to select the desired default axis. Practical action: Use these parameter settings to eliminate unnecessary plane-switching commands from your G-code programs.

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