Configuring G87 Usercycles in Siemens NX Post Processors

David Krause14 min read
Motion ControlSiemensTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Overview of G87 Back Boring in CNC Manufacturing

The G87 canned cycle is one of the standardized hole-machining cycles defined originally under ISO 6983 (DIN 66025), the modern descendant of the EIA RS-274 numerical-control standard first adopted in 1963. Unlike the more common G81 (drilling), G83 (deep-hole peck drilling), G84 (rigid tapping), and G82 (counter-boring the top face), G87 is specifically intended for back boring — counter-boring the underside of an existing through-hole. The spindle must approach from below the part, retract clear of the bore wall during rapid-traverse phases, and re-orient before the cutter engages the bottom face. Failure to honor this eight-step sequence produces cutter breakage on the bore wall, scrapped parts, or — on machines without software overtravel protection — a hard limit-switch trip and machine stop.

Implementing G87 from a CAD/CAM system is non-trivial because the cycle requires synchronized oriented-spindle, lateral-retract, and re-engagement motion that no naive linear-motion post-processor can emit correctly. Siemens NX CAM addresses this through a two-layer architecture: a declarative Usercycle library that defines the cycle geometry, and a Post Processor (PP) layer of TCL event handlers that emit controller-specific syntax. This article documents the end-to-end procedure for declaring a G87 back-bore Usercycle, wiring it into a PP for a Sinumerik 840D sl or Fanuc 30i-MB controller, verifying the output, and recovering from the most common field failures.

G87 Cycle Specification and Eight-Step Motion Profile

The reference motion for G87, documented in the LinuxCNC G-code reference and re-implemented under Siemens' Sinumerik 840D sl programming manual, decomposes into eight discrete sub-phases:

  1. Initial position. Spindle at programmed X/Y coordinates, Z at the initial plane above the part.
  2. Oriented spindle stop. Spindle rotates to a fixed angular position (typically M19) so that a flat or drive key on the cutter body is parallel to the bore wall — this is what allows lateral retract without scoring.
  3. Rapid to clearance (R plane) at Z. Tool traverses in Z+ at rapid to clear the bore wall before lateral movement.
  4. Rapid lateral to clearance at X/Y. Tool offsets laterally to clear the bore wall before descending.
  5. Feed to Z target. Controlled feed into the bottom face for the counter-bore cut.
  6. Dwell. Pause at depth (P parameter, seconds on Fanuc, milliseconds on Sinumerik depending on version).
  7. Spindle restart and feed retract. Spindle resumes rotation in the original direction, tool retracts at feed to the clearance plane.
  8. Rapid retract to initial plane. Return to start position, ready for the next hole.

This eight-step pattern is what differentiates G87 from G82 and is the reason a CAM system without cycle-aware logic cannot generate G87 by emitting plain G0/G1 motion — the oriented-spindle synchronization is lost.

Required G87 Parameter Set

Word Meaning Typical Range Notes
X, Y Hole center coordinates Within machine travel Absolute or incremental per modal state
Z Bottom of counter-bore (target depth) Workpiece Z minus tool length Sign convention is controller-dependent
R R plane (clearance used during lateral retract) Z + 1 to 25 mm Must clear bore-wall diameter plus cutter flat length
Q Cut depth per pass (incremental) 0.1–5.0 mm Single-pass if omitted; multi-pass on Fanuc with deep-bore option
P Dwell at bottom 0.0–5.0 s Integer seconds on Fanuc; ms with decimal on Sinumerik
F Feedrate 50–800 mm/min Modal; reset by G94/G95
S Spindle speed By cutter diameter Modal; reset by G97

On a Siemens Sinumerik 840D sl, the closest native equivalent is CYCLE82(... , 2, ...) with the second-from-last argument set to 2 (backside-machining flag) or, for production, the higher-level ShopTurn cycle CYCPL95 with _FR (radial feed) and _DF (finish allowance) explicitly set. On Fanuc 30i/31i/32i-MB, G87 is retained as-is with the parameter set above; the oriented-spindle option (parameter M-baxis or B-axis orient) must be present and licensed.

NX CAM Architecture: Usercycles and the Post Processor Layer

In NX CAM (formerly Unigraphics, now part of the Siemens Xcelerator portfolio), hole-machining operations such as HOLE_MILLING, BORING, and BACK_BORE expose two cooperating mechanisms for cycle output:

  • Operation-level cycle selection. The operation's Cycle Type / Cycle Subtype property in the Operation Navigator drives which built-in cycle template is invoked.
  • User Cycles. A programmable cycle library — .tcl source files paired with a ugs_user_cycle.def declaration table — that defines fully custom cycle syntax on top of the operation-level selection.

The Post Processor is the layer that converts internal CAM motion events into controller-specific G-code. When the operation calls a Usercycle, the PP invokes a matching event handler — typically a MOM (Manufacturing Output Manager) call such as MOM_user_cycle or PB_CMD_user_cycle — which emits the controller-specific syntax for that cycle. This split — declarative cycle definition in Usercycles, syntactic emission in the PP — is what allows the same operation geometry to output different cycle syntax on a Sinumerik versus a Fanuc without changing the manufacturing feature. The official Siemens NX Post Builder documentation describes this split under the "User Cycles and Custom Commands" chapter; users should consult the section corresponding to their installed NX release (NX 1847 / NX 1872 / NX 1899 / NX 1926 / NX 1953 / NX 1980 / NX 2007 series).

Prerequisites for Custom G87 Implementation

  • NX version: Siemens NX 1847 series or newer (Usercycle API stable since NX 12; cycle-handling API stabilized in NX 1847 with the introduction of MOM_user_cycle parameter binding). Earlier versions (NX 11 and below) require manual ugs_user_cycle.def edits without the high-level binding helper.
  • Post Builder license: Shipped standard with NX CAM Manufacturing. Verify under Menu → Help → About NX → License Information.
  • TCL interpreter: Version 8.6 or later, bundled with the NX installation; no separate install required.
  • Reference PP bundle for the target controller: sin840d.tcl + sin840d.def (Sinumerik 840D sl), fanuc_30i.tcl + fanuc_30i.def (Fanuc 30i-MB), or heidenhain_tnc640.tcl + heidenhain_tnc640.def (Heidenhain TNC 640 with the conversational-cycle equivalent CYCL DEF 207).
  • Controller firmware documentation: Match the PP version to the controller firmware. Sinumerik Operate V4.95 SP5 (or later) for the latest CYCLE82 variant; Fanuc Series 30i-MB B0F4 (or later) for stable G87 lateral-retract handling.
  • Test geometry: A 50 mm thick aluminum 6061-T6 plate with a pre-existing Ø20 mm through-hole and four M8 counter-bore positions on the underside — sufficient to exercise X/Y/Z/R/Q/P/F/S parameter binding and oriented-spindle synchronization.

Defining G87 in NX Usercycles — Step-by-Step

  1. Open Post Builder in NX via Menu → Tools → Post Builder and load the target controller's .tcl / .def pair. Confirm the bundle unloads cleanly and the test-post completes against a trivial operation (e.g., a single-line G0).
  2. Locate the Usercycles section. This is typically pb_cmd_usercycles.tcl and the matching declaration block in ugs_user_cycle.def. Do not modify the built-in cycle block (entries 1–99); instead, append a new cycle entry in the 100–999 private range, which Sinumerik reserves for user cycles and which the Fanuc reserved-word table leaves free.
  3. Declare the cycle in ugs_user_cycle.def:
    CYCLE_USER_87  "G87_BACK_BORE"
      PARAM, X, "Hole center X"
      PARAM, Y, "Hole center Y"
      PARAM, Z, "Target Z (bottom of counter-bore)"
      PARAM, R, "R plane (lateral clearance)"
      PARAM, Q, "Cut increment"
      PARAM, P, "Dwell at bottom"
      PARAM, F, "Feedrate"
      PARAM, S, "Spindle speed"
    END
  4. Define the cycle behavior in pb_cmd_usercycles.tcl by appending a new procedure. The default G87 implementation on Fanuc uses M19 for the oriented spindle stop, with the controller handling the lateral-retract sequencing internally. Confirm against the LinuxCNC G87 reference for the controller-independent motion semantics before binding to your vendor's syntax:
    proc MOM_user_cycle_G87_BACK_BORE { } {
      global mom_cycle_parms
      set x [lindex $mom_cycle_parms(X) 0]
      set y [lindex $mom_cycle_parms(Y) 0]
      set z [lindex $mom_cycle_parms(Z) 0]
      set r [lindex $mom_cycle_parms(R) 0]
      set q [lindex $mom_cycle_parms(Q) 0]
      set p [lindex $mom_cycle_parms(P) 0]
      set f [lindex $mom_cycle_parms(F) 0]
      set s [lindex $mom_cycle_parms(S) 0]
    
      MOM_output_literal "S$s M03"
      MOM_output_literal "G87 X[format %.3f $x] Y[format %.3f $y] Z[format %.3f $z] R[format %.3f $r] Q[format %.3f $q] P[format %.0f $p] F[format %.1f $f]"
      MOM_output_literal "M19"
    }
    Note the explicit integer format on P — Fanuc rejects fractional seconds in the P word.
  5. For Sinumerik 840D sl, do not call raw G87 — emit the equivalent CYCLE82 with the back-side flag. The eight-step motion is then handled by the controller's cycle interpreter, which is the documented behavior in the Sinumerik 840D sl cycles programming manual:
    proc MOM_user_cycle_G87_BACK_BORE { } {
      global mom_cycle_parms
      set z [lindex $mom_cycle_parms(Z) 0]
      set r [lindex $mom_cycle_parms(R) 0]
      set q [lindex $mom_cycle_parms(Q) 0]
      set p [lindex $mom_cycle_parms(P) 0]
      set f [lindex $mom_cycle_parms(F) 0]
      set s [lindex $mom_cycle_parms(S) 0]
    
      MOM_output_literal "S$s M03"
      MOM_output_literal "CYCLE82([format %.3f $z], [format %.3f $r], [format %.3f $q], [format %.3f $p], 2, [format %.1f $f])"
    }
    The trailing argument 2 is the back-side-machining flag. Setting it to 0 emits a top-face counter-bore and silently changes the cycle semantics.
  6. Re-save the PP bundle via Post Builder's Save As, write to a fresh .zip archive, and re-post a test operation. Verify the output .cls (Sinumerik) or .nc (Fanuc) file contains the cycle call and that MOM_user_cycle_G87_BACK_BORE is invoked exactly once per hole. Use the verbose-2 trace log (post_processor --verbose 2) to confirm.
  7. Bind the Usercycle to the operation in NX Manufacturing. Open the BACK_BORE operation → Cycle → Usercycle → select G87_BACK_BORE from the dropdown. Re-post and confirm output.

Post Processor Event-Handler Integration

Beyond the cycle call itself, two event handlers must be confirmed or added to the PP bundle: MOM_spindle_orientation (for M19 emission) and MOM_rapid_move (for any pre-cycle clearance moves). A minimal Fanuc handler for oriented spindle stop:

proc MOM_spindle_orientation { } {
  global mom_spindle_orientation_angle
  MOM_output_literal "M19"
}

If the operation calls for coolant supply during the cycle (typical for aluminum), also confirm that MOM coolant_on and MOM_coolant_off emit M08 / M09 respectively — the default NX template does this correctly but a custom PP may have overridden the values to M07 / M08 (mist) which would be wrong for back-bore chip evacuation.

Controller-Specific Output Variants

Controller Cycle Syntax Notes
Fanuc Series 30i/31i/32i-MB G87 X_ Y_ Z_ R_ Q_ P_ F_ + M19 Oriented spindle option mandatory; P integer seconds only.
Fanuc Series 16i/18i/21i-MB G87 as above Older M-code orient; verify option M-baxis installed.
Fanuc Series 0i-MD Not supported Use G82 top-face counter-bore instead.
Sinumerik 840D sl CYCLE82(Z, R, Q, P, 2, F) Trailing 2 = back-side flag.
Sinumerik ONE / 828D CYCLE82(...) + CYCPL95 for production Run MyCycle / ShopTurn extension recommended.
Heidenhain TNC 640 CYCL DEF 207 RIGID TAPPING N.C. Conversational-cycle equivalent is CYCL DEF 207; verify against the Heidenhain documentation for the installed NC software version.
Mitsubishi M80 / M800 G87 as Fanuc-equivalent Oriented spindle option M19 required.

Verification and Simulation

  1. NX ISV / MTK simulation. Run NX Internal Simulation Viewer or the supplied Machine Tool Kinematics model (.mtk). Confirm zero overtravel events during the eight-step motion. The MTK must include the oriented-spindle axis (M-baxis) for G87 simulation to be valid; otherwise the simulator silently bypasses the M19 step.
  2. Toolpath backplot. The backplot must show: oriented-spindle rotation indicator, lateral retract in X/Y, re-engagement at the bottom face, dwell, feed retract. If any phase is missing, the PP has dropped the step.
  3. Per-hole parameter consistency. Use MOM_output_literal "M00" as a dry-run pause after the first cycle to verify the second and subsequent cycles inherit correct modal parameters. P parameter formatting is the most common silent failure — confirm with a regex search of the output file.
  4. Machine dry-run. On the actual controller, run the program with single block ON, rapid override at 25 %, dry-run (DRY-RUN) ON, and Z-axis override at 50 % before committing to production feedrates. Verify oriented-spindle positioning indicator (Fanuc: SPOS parameter in the position screen; Sinumerik: actual-position display) before each lateral retract.
  5. CMM check. Measure counter-bore depth, diameter, perpendicularity, and surface finish on a coordinate-measuring machine against the drawing tolerance. Typical acceptance: depth ±0.05 mm, diameter ±0.025 mm, Ra ≤ 1.6 µm on aluminum.

Troubleshooting Matrix

Symptom Likely Cause Diagnostic Resolution
G87 emitted as raw motion (G0/G1) instead of cycle call Operation-level Cycle Type not set to Usercycle Operation → Cycle Type → confirm Usercycle selection Re-select Usercycle and re-post
M19 oriented stop not honored PP event handler for spindle orientation missing or overridden Trace MOM for MOM_spindle_orientation call Add explicit MOM_output_literal "M19" in cycle proc
Sinumerik rejects cycle as "unknown cycle" CYCLE82 not licensed on NCU Check machine data MD10715 $MN_M_NO_FCT_CYCLE Enable cycle in machine data, or fall back to user-defined CYCPL95
Counter-bore depth off by tool length Z parameter not including tool-length offset Inspect mom_tool_length_adjust_register value Emit MOM_output_literal "G43 H#" before cycle, with # resolved to tool register
Cycle hangs in single-block P parameter formatted as float Inspect raw output: P1.500 is invalid Force integer formatting with %-d on P
Lateral retract crashes into bore wall R plane too low; flat on cutter longer than expected Inspect MTK simulation: Z- retract below bore wall Increase R by cutter-flat length + 1 mm safety
Cycle runs but no material is removed Spindle not oriented; cutter flat aligned with feed direction Verify SPOS / M19 in position display Re-verify oriented-spindle option installed; check M-code parameter M-baxis
Coolant not on during cycle Custom PP overrode MOM_coolant_on to mist Trace coolant handler Restore M08 / M09 emission for flood
Cutter pull-out alarm on Sinumerik Back-side flag missing from CYCLE82 Inspect output: CYCLE82(Z, R, Q, P, 0, F) vs (Z, R, Q, P, 2, F) Set 5th argument to 2 for back-side machining

Field Commissioning Notes

  • Always run the cycle on a sacrificial part with single-block ON before committing to production feedrates. Back-bore crashes are destructive and expensive.
  • Verify the R plane geometry against the actual cutter used. A cutter with a 4 mm flat requires R to clear the bore wall by at least 4.5 mm before lateral retract.
  • For multi-spindle or multi-channel controllers (Sinumerik 840D sl with NCU 720.3, Fanuc 30i-MB with dual-path), verify the cycle is bound to the correct channel. Spindle orientation is per-channel; emitting M19 on channel 1 while the cutter is in channel 2 produces a silent failure.
  • For machines with a B-axis (5-axis back-bore), the cycle must be combined with the appropriate rotary-axis positioning block before the cycle call. Confirm against the controller's 5-axis documentation; Fanuc 30i-MB5 and Sinumerik 840D sl with 5-axis option bundle both have explicit cycle-extension procedures.
  • For dry-run verification, many controllers (Sinumerik Operate) expose a "dry run cycle" toggle that simulates the cycle motion at rapid without cutting. Use this for first-article confirmation.
  • Tool-length measurement should be performed with the same probe strategy used for top-face boring. Back-bore tools are often longer than top-face tools by 25–50 mm; thermal growth over that length is non-trivial in production.

Migration from Older Unigraphics / UGS Installations

Users migrating from Unigraphics NX 11 or earlier should note the following compatibility considerations:

  • The ugs_user_cycle.def syntax was updated in NX 12. Older declarations using the CYCLE_DEFINITION macro require a one-time conversion script run from Post Builder.
  • The MOM_user_cycle parameter binding helper was introduced in NX 1847. Pre-NX 1847 builds must read mom_cycle_parms directly, which is what the code samples in this article do.
  • Custom user cycles added in UGS NX 4 or UGS NX 5 (the *.cls export from cam_post) are not forward-compatible. Re-declare using the modern syntax.
  • Contact your local Siemens Industry Software representative for paid migration assistance if the legacy installation has more than ~50 custom cycles.

FAQ

Can G87 be programmed manually at the controller without CAM?

Yes. On Fanuc 30i-MB and Sinumerik 840D sl, G87 (or CYCLE82 with back-side flag) can be entered as a manual NC block. The oriented-spindle and lateral-retract sequencing must be handled explicitly by the programmer, so CAM is recommended for any production work with more than three holes.

What is the minimum NX version that supports the Usercycle API used here?

Siemens NX 1847 is the first release where MOM_user_cycle was stabilized for custom cycle definitions with parameter binding. Earlier versions (NX 11 and below) require manual ugs_user_cycle.def edits and direct mom_cycle_parms reads.

Why does Sinumerik reject G87 even when it is in the program?

Sinumerik 840D does not implement the Fanuc G87 directly. Use CYCLE82 with the back-bore flag (5th argument = 2) or a higher-level ShopTurn cycle such as CYCPL95. Verify licensing via machine data MD10715 $MN_M_NO_FCT_CYCLE.

How do I add a dwell without affecting the rest of the cycle?

Use the P parameter at the controller level. Do not insert a separate dwell (G04) block before or during the cycle — that breaks the lateral-retract synchronization and may produce an unintended spindle orientation fault.

Is G87 supported on all Fanuc models?

G87 is supported on Fanuc Series 16i/18i/21i/30i/31i/32i-MB with the boring option (M-baxis orients spindle). On Fanuc 0i-MD and earlier 0/16/18 without oriented-spindle option, the cycle degrades silently to a plain Z feed — confirm the option is installed before commissioning.

What is the correct R plane value for a Ø12 mm cutter with a 3 mm flat?

The R plane must clear the bore wall by at least the flat length plus 1 mm safety. For a 3 mm flat in a Ø20 mm bore, R = bore diameter + flat length + 1 mm = 24 mm above the target Z. Confirm with MTK simulation.

Back to blog