Skip to main content
CNC.wiki

G51.1 Programmable Mirror Image ON: CNC Programming Guide

Master G51.1 programmable mirror image on Fanuc, Siemens, and Mitsubishi CNC controls. Learn to prevent coordinate drift, alarm codes, and tool crashes.

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

CNC CARE Co-founder

Introduction

The unexpected travel of a spindle or tool turret directly into a table-mounted workpiece clamp, workpiece fixture vise jaw, or rotating spindle chuck represents one of the most catastrophic collisions on a CNC machining center. When programming G51.1 programmable mirror imaging, executing the cancellation command G50.1 at any position other than the original mirror center introduces a silent coordinate deviation. Because the control's absolute register and physical machine positions drift, subsequent machining blocks will bypass established safety zones. This deviation shatters the cutting tool, deforms the linear guides, triggers axis-overload alarm codes, and immediately ruins the stock, converting it into a scrap part.

To avoid these mechanical crashes, CNC programmers must understand the specific syntax, parameters, and control-specific interlocks of mirror image commands. G51.1 allows the creation of symmetrical parts (like left- and right-hand plates) using a single subprogram. When activated, the motion kernel automatically reverses the circular interpolation arc direction and flips cutter radius compensation vectors (swapping G41 and G42). Proper activation and cancellation techniques ensure absolute safety and eliminate coordinate drift on Fanuc, Siemens, and Mitsubishi controls.

Technical Summary

FeatureSpecification
Command CodesG51.1 (ON) / G50.1 (Cancel) (Fanuc, Mitsubishi, Siemens ISO); MIRROR / AMIRROR (Siemens Native)
Modal Group / ModalityGroup 22 modal (Fanuc, Siemens ISO Dialect); Group 19 modal (Mitsubishi)
Supported BrandsFanuc, Siemens, Mitsubishi
Critical ParametersParameter No. 5002 Bit 2 (LWT) & Bit 4 (LGT), Siemens MD 10610 $MN_MIRROR_REF_AX, Mitsubishi Parameter #1003 (iunit)
Main ConstraintMirroring must be activated and canceled at the same center coordinates. It is not applied to G53 machine coordinates. Cannot be active during Tool Center Point Control (G43.4/G43.5) or Inclined Surface Control (G176/G68.2).

Quick Read

  • Always command G51.1 and G50.1 in separate, independent blocks to prevent parsing and interpreter errors.
  • Activate and cancel the mirror image at the exact same coordinate center to avoid axis drift and coordinate deviation.
  • Verify that cutter radius compensation (G41/G42) is cancelled (G40) before calling or canceling mirror imaging.
  • Never command G53 travel moves while G51.1 mirror imaging is active, as machine coordinate movements bypass mirroring.
  • Check parameter interlocks (like Fanuc 5002 LWT/LGT or Siemens MD 10610) to prevent Alarm PS0509 when changing tool offsets.
  • Cancel tool center point control (G43.4/G43.5) or inclined surface control (G176) before commanding mirror imaging.

Basic Concepts

Activating the G51.1 programmable mirror image command on a CNC machining center mathematically inverts workpiece coordinate signs with respect to the designated symmetry axis, allowing programmers to machine symmetrical workpiece shapes—such as left- and right-hand plates—using a single subprogram. A critical advantage of the motion kernel is that when a single-axis mirror image is applied to the active working plane, the control automatically reverses the circular interpolation arc direction (interpreting G02 clockwise moves as G03 counter-clockwise, and G03 as G02) and flips cutter radius compensation offset vectors (interpreting G41 left-side offset as G42 right-side offset, and G42 as G41). This automated vector path recalculation allows operators to run identical contours symmetrically while maintaining correct climb or conventional milling strategies on the mirrored workpiece.

However, programmers and setup operators must maintain absolute vigilance regarding coordinate registration and physical boundaries when G51.1 mirror image modes are executed. To prevent axes drift, it is a critical safety rule that mirror image commands must always be activated and canceled directly at the original mirror image center. If an operator programs G50.1 to cancel the mirror image at a different coordinate position, the absolute program coordinates and the actual machine positions will deviate. This coordinate deviation persists in the NC system until an absolute positioning command (G90) is issued or a reference zero return (G28 or G30) is executed. If subsequent blocks are executed under this coordinate deviation in close proximity to workholding, the spindle or tool turret will travel on an uncompensated path, bypassing established safety zones. This unexpected movement can drive the tool turret or spindle directly into table-mounted workpiece clamps, a workpiece fixture vise jaw, or the rotating spindle chuck, resulting in a catastrophic hard collision. This physical crash inevitably shatters the cutting tool, damages the axis guides, throws axis-overload alarm codes, and converts the raw stock into a completely ruined scrap part.

Command Structure

Symmetrical machining programs require precise coordinate mapping around a designated mirror plane. The programmable mirror image command establishes an axis of symmetry, multiplying all coordinate points along the selected axis by negative one. The syntax defines the target axes to mirror and their center coordinates.

Programmers must construct G51.1 blocks using specific addresses. The command must reside in a dedicated block prior to executing any motion commands on the mirrored path. This ensures the control updates its registers before processing coordinate offsets.

  • Fanuc:
    G51.1 IP_ ; (ON) / G50.1 IP_ ; (Cancel)
  • Siemens ISO Dialect:
    G51.1 X_ Y_ Z_ ; (ON) / G50.1 X_ Y_ Z_ ; (Cancel)
  • Siemens Native Mode:
    MIRROR X0 (or Y0, Z0) / AMIRROR X0 (or Y0, Z0) / MIRROR (Cancel)
  • Mitsubishi:
    G51.1 X_ Y_ Z_ ; (ON) / G50.1 X_ Y_ Z_ ; (Cancel) or G62 X_ Y_ Z_ ; (Position-relative)
Address / ParameterDescription
IP_ / X_ Y_ Z_Coordinates specifying the mirror axis and the center of the mirror plane. In G50.1, the axis coordinates are dummy values but must be specified to select which axes are canceled.
MIRROR / AMIRRORSiemens native absolute (MIRROR) or additive (AMIRROR) mirroring commands. MIRROR alone cancels all mirror frames.
G62Mitsubishi command to activate or cancel mirroring centered at the current tool position (coordinates specify axes: 1 to mirror, 0 to cancel).

Brand Applications

Fanuc

Fanuc controls manage programmable mirror imaging through Group 22 G-codes. Tool wear and tool geometry offsets in mirror mode are strictly controlled by parameters to prevent coordinate recalculation errors.

The G-code G51.1 activates mirroring about the specified center point, while G50.1 cancels mirroring for the designated axes using dummy coordinate inputs.

  • Parameter No. 5002 Bit 2 (LWT): Tool Wear Offset addition method. If 1, wear offsets are added by coordinate system shifts, triggering Alarm PS0509 if offset is specified in mirror mode.
  • Parameter No. 5002 Bit 4 (LGT): Tool Geometry Offset addition method. If 0, geometry offsets are added by coordinate system shifts, triggering Alarm PS0509 in mirror mode.
  • Parameter No. 5001 Bit 6 (EVO): Tool Offset Change lock. If 1, changing tool offsets while G51.1 is active is prohibited, triggering Alarm PS0509.
  • Alarm PS0509: Triggers if a tool offset is specified or changed while G51.1 is active under active shift parameters.
  • Alarm PS0037: Triggers if the active plane (G17/G18/G19) is changed while cutter compensation is active under single-axis mirroring.
  • Version difference: Modern Series 30i/31i/32i-B Plus controls calculate G40 cancel vectors using Parameter No. 5000 Bit 3 (GNI), whereas older Series 16i/18i/21i and 0i-C did not use this specific parameter, sometimes causing path discrepancies.

Warning: Changing or specifying tool offsets while G51.1 is active will trigger Alarm PS0509 if parameters No. 5002 Bit 2 or Bit 4 are configured to add offsets by coordinate system shifts.

Siemens

Siemens controls offer bilingual compiler processing. Native mode uses frame instructions, while ISO dialect mode compiles Fanuc-style mirror commands when the external language interpreter is enabled.

In native mode (G290), mirroring is activated by MIRROR or AMIRROR and cancelled by MIRROR alone. In ISO Dialect mode (G291), mirroring uses G51.1 and G50.1.

  • MD 10610 $MN_MIRROR_REF_AX: Mirror Reference Axis. Defines the axis around which coordinate mirroring is executed.
  • MD 18800 $MN_MM_EXTERN_LANGUAGE: Activation of external NC languages. Must be 1 to enable G291 ISO dialect mode.
  • Alarm 61800: External CNC system missing, triggered if G291, G51.1, or G50.1 is programmed while MD 18800 is disabled.
  • Alarm 12080: Syntax error / Unknown block, triggered if an unrecognized command is parsed during ISO Dialect mode.
  • Version difference: Advanced SINUMERIK 840D sl systems support collision avoidance and dynamic parameters, whereas SINUMERIK 802D sl locks machine data such as MD 10604, preventing changes.

Warning: Native MIRROR is a substituting command. Writing MIRROR on a line by itself will cancel mirroring, but it will also clear other active transformations such as ROT (rotation) or TRANS (zero offset).

Mitsubishi

Mitsubishi machining centers implement G51.1 as a modal Group 19 command. It supports standard coordinate mirroring and position-relative mirror imaging to simplify setup.

In addition to G51.1 and G50.1, Mitsubishi provides G62 to mirror coordinates using the current tool position as the symmetry center.

  • Parameter #1003 iunit: Input Setting Unit, defining coordinate input resolution and valid range of mirror center coordinates.
  • Parameter #8211 Mirror image: Mirror image by parameter setting, enabling software-based mirroring.
  • Program Error (P801): Issuing G51.1 or G50.1 while G43.7 (Tool Position Compensation) is active, or vice versa.
  • Program Error (P942): Issuing G51.1 or G50.1 while Tool Center Point Control (G43.4/G43.5/G174) is active.
  • Version difference: M800V/M80V series controls support sub-micron Metric Unit E input settings (up to 6 decimal places), which is not available on legacy Mitsubishi controls.

Warning: Commands such as G51.1 and G50.1 must not be executed while Tool Center Point Control (G43.4/G43.5) or Inclined Surface Control (G176) is active, otherwise Program Error P942 or P952 will be triggered.

Brand Comparison

TopicFanucSiemensMitsubishi
G-code CommandG51.1 IP_ ; (Group 22)Native MIRROR/AMIRROR (G290) or G51.1 in ISO mode (G291)G51.1 X_ Y_ Z_ ; (Group 19) or alternative G62
Cancellation MethodG50.1 IP_ ; (Group 22)Native MIRROR with no axes, or G50.1 in ISO mode (G291)G50.1 X_ Y_ Z_ ; (Group 19) or G62 X0 Y0 Z0
Center Point DefinitionSpecified in the G51.1 block coordinates (absolute/incremental).Native: determined by active work offsets. ISO mode: coordinates in G51.1 block.Specified in G51.1 block, or dynamically at the current tool position via G62.
Cancellation Side-effectsG50.1 only cancels mirroring for specified axes without affecting other offsets.A blank native MIRROR command automatically cancels all other active frames (rotations, scaling, offsets).G50.1 only cancels mirroring for specified axes without affecting other offsets.
Parameter InterlocksTriggers Alarm PS0509 if tool offset is defined/changed in mirror mode under active shift parameters (No. 5002 LWT/LGT).MD 10760 defines tool correction suppression during frame suppression (G53/SUPA).Triggers Program Errors P801/P942/P941/P952/P953 if mirroring conflicts with active tool position compensation, tool center point control, or inclined surface control.

Technical Analysis

The architectural differences in mirror imaging between Fanuc, Siemens, and Mitsubishi center on how coordinate frames and compiler interpreters are structured. Siemens implements a bilingual compiler structure, requiring a distinct transition between native SINUMERIK mode (G290) and ISO dialect mode (G291). When programming legacy ISO codes, the programmer must explicitly command G291 for G51.1 and G50.1 to be parsed correctly. Conversely, Fanuc and Mitsubishi compile mirroring commands natively within their primary instruction sets, avoiding the need for interpreter switches.

Transformation cancellation represents another major divergence. On Fanuc and Mitsubishi, G50.1 operates as a selective modal cancel command, affecting only the programmed axes and leaving other coordinate transformations (like scaling or work coordinate system offsets) unchanged. On Siemens, a native MIRROR command programmed without axes acts as a substituting instruction. This native cancel clears the entire frame stack, automatically wiping out active rotations (ROT), scaling (SCALE), and fine zero offsets (TRANS). Programmers must therefore handle native Siemens cancellations with care to avoid losing chained coordinate transformations.

Finally, parameter-level interlocks protect the physical machine state differently across the three brands. Fanuc relies heavily on parameter settings (No. 5002 and No. 5001) to lock or permit tool offset modifications during active mirroring, triggering Alarm PS0509 if violated. Mitsubishi enforces strict programmatic blocks, throwing specific error codes (like P801 for tool position compensation conflicts, and P942 or P952 for multi-axis center point or inclined surface control conflicts). Siemens uses machine data registers (like MD 10760) to define whether tool length and radius compensations are suppressed or maintained when frames are deactivated.

Program Examples

Fanuc Example:

G90 G00 G54 X150.0 Y100.0 ; Rapid traverse to absolute start position in normal coordinates
G51.1 X100.0 Y50.0 ; Activates mirror imaging on X and Y axes around the center coordinates X100.0, Y50.0
; Symmetrical machining path goes here...
G50.1 X0 Y0 ; Cancels mirror imaging on the X and Y axes (note that coordinate values X0 and Y0 are dummy values and are ignored)

Perform a dry run of the Fanuc program before starting machining operations. The operator must execute a dry run with Z-axis offset raised above the workpiece. The control processes the G51.1 block, setting the mirror symmetry center at X100.0 Y50.0. The subsequent movements are mapped symmetrically across this center point. Finally, the G50.1 block cancels mirroring, restoring the coordinate scale calculation to 1:1.

Siemens Example:

N10 G290 ; Native mode: Select plane, coordinate offset, tool edge, and start spindle
N20 AMIRROR X0 ; Native mode: Add additive coordinate mirroring on the X-axis (negates X coordinates)
N30 MIRROR ; Native mode: Cancels coordinate mirroring on all axes by commanding MIRROR without parameters
N40 G291 ; Switches interpreter to ISO Dialect Mode to compile legacy G-codes
N50 G51.1 X100.0 Y50.0 ; ISO mode: Activates programmable mirroring on X and Y axes around the center X100, Y50
N60 G50.1 X0 Y0 ; ISO mode: Cancels programmable mirroring on X and Y axes (coordinate values are ignored)

Execute a dry run to verify the Siemens coordinate mirroring transformations. The NC compiler switches to native mode and applies X-axis mirroring. The empty MIRROR instruction resets all active frames. When the compiler toggles to ISO mode (G291), it reads G51.1, establishing the mirror center at X100.0 Y50.0. The G50.1 command cancels the mirroring, restoring the standard coordinate system.

Mitsubishi Example:

G90 G00 G54 X150.0 Y100.0 ; Absolute rapid position in normal coordinates
G51.1 X100.0 Y50.0 ; Activates G-code mirror imaging on X and Y axes around the center coordinates X100.0, Y50.0
; Symmetrical path...
G50.1 X0 Y0 ; Cancels mirror imaging on the X and Y axes (coordinate dummy values are ignored)

Perform a dry run to verify the Mitsubishi mirroring states. The machine rapids to the start coordinates in normal mode. When G51.1 is executed, the control mirrors subsequent movements across the X100.0 Y50.0 center. Finally, G50.1 Cancels the mirroring mode, returning coordinate processing to standard absolute values.

Error Analysis

BrandAlarm CodeTrigger ConditionOperator SymptomRoot Cause / Fix
FanucAlarm PS0509Specifying or changing tool offsets while G51.1 is active under active shift parameters (e.g. LWT = 1, LGT = 0, or EVO = 1).The machine halts, displaying Alarm PS0509: "TOOL OFFSET CANNOT BE CHANGED IN G51.1 MODE".Tool offsets cannot be modified or called during active mirroring. Fix: Cancel the mirror image using G50.1 before changing offsets, or adjust parameters No. 5002 and No. 5001.
FanucAlarm PS0037Changing active working plane (G17/G18/G19) while cutter compensation is active under single-axis mirroring.The machine halts, displaying Alarm PS0037: "PLANE SWITCH DURING MIRRORING WITH CRC ACTIVE".Active cutter radius compensation clashes with working plane changes during mirroring. Fix: Cancel cutter compensation with G40 before changing the plane.
SiemensAlarm 61800Programming G291, G51.1, or G50.1 while the external NC language interpreter is disabled.The control halts execution, displaying Alarm 61800: "EXTERNAL NC SYSTEM OPTION MISSING".The Siemens interpreter cannot parse ISO dialect codes. Fix: Set machine data MD 18800 ($MN_MM_EXTERN_LANGUAGE) to 1 to enable ISO compiling.
MitsubishiProgram Error (P801)Issuing G51.1 or G50.1 while G43.7 (Tool Position Compensation) is active, or vice versa.The machine enters error state, showing Program Error P801 on the screen, and stops.Conflict between active tool position compensation and mirror imaging. Fix: Cancel tool position compensation before calling or canceling mirror imaging.

Application Note

A tool turret collision with table-mounted workpiece clamps or a workpiece fixture vise jaw is the direct consequence of failing to activate and cancel G51.1 programmable mirror imaging at the exact same coordinate center. When the G50.1 cancel command is issued at a different physical position, the absolute coordinate system and the physical machine position drift, causing subsequent moves to travel on an uncompensated path that bypasses safety zones. Programmers must ensure that the coordinates of the mirror center are strictly verified, and that safety interlocks (such as Fanuc Parameter No. 5002 Bit 2 and Bit 4, or Siemens MD 10610) are checked. In addition, cutter radius compensation (G40) must be deactivated before mirror imaging is called to prevent Alarm PS0037 or Alarm 61815.

Related Command Network

  • g50-1-mirror-image-cancel: The direct G-code to cancel programmable mirror imaging, restoring standard coordinate mapping.
  • g51-scaling-on-milling: Activates coordinate scaling on milling systems, establishing proportional scaling about a center.
  • g41-cutter-radius-compensation: Activates left-side cutter radius compensation, which is automatically inverted to right-side (G42) under single-axis mirroring.
  • G291: Switches the Siemens interpreter to ISO dialect mode to parse G50.1 and G51.1 commands.

Conclusion

A clean verification checklist is the best defense against coordinate drift and axis crashes. Operators should perform a dry run with Z-axis coordinates raised before executing mirroring paths on raw stock. By enforcing the rule that mirror image commands must activate and cancel at the exact same coordinate center, shops can prevent axis deviation, safeguard tool spindles, and ensure correct climbs on mirrored geometries.

Frequently Asked Questions (FAQ)

Why does a circular interpolation (G02/G03) fail under active G51.1 mirroring?

Circular interpolation requires the control to coordinate movements across two axes in the active plane. If mirroring is applied to only one axis, the controller interprets the circular path as an ellipse, which standard circular interpolation cannot compile, resulting in Alarm PS0070 (Fanuc) or Program Error P70 (Mitsubishi). Action: Always specify identical mirroring parameters for both plane axes in the G51.1 block, or cancel mirroring using G50.1 before executing circular moves.

What happens to G51.1 mirror states during an emergency stop or NC reset?

An emergency stop, control reset, or program end (M02/M30) automatically clears the modal Group 22 (Fanuc) or Group 19 (Mitsubishi) mirroring state, reverting the system to a 1:1 scale. If the program is restarted from the middle of the toolpath, the control will execute movements in standard coordinates, causing the tool to crash into clamps. Action: After any program interruption, manually retract the tool to a safe position and restart the program from the safety block that establishes G51.1.

How does G51.1 coordinate mirroring affect tool radius compensation (G41/G42)?

When G51.1 mirroring is active on a single axis, the control's motion kernel automatically reverses cutter radius compensation vectors to maintain climb milling. However, attempting to modify or call new tool wear or geometry offsets while G51.1 is active will trigger Alarm PS0509 on Fanuc systems if parameters (No. 5002) are configured to shift coordinates. Action: Cancel active cutter compensation using G40 before calling G51.1, and ensure all tool offset calls (T commands) are executed outside of the mirroring loop.

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