G87

Machining center, LatheModal, group 09

Back boring cycle (reverse spot facing)

On machining centers

G87 X_ Y_ Z_ R_ Q_ (shift amount) P_ F_ K_

Diagram: G87 motion (side view)

RapidCutting feedInitial pointZR point (below)① At initial point,orient spindle and shift② Through the hole tolower R point (rapid)③ Shift back, spindle CW④ Cut upward to Z⑤ Stop, shift, andrapid out upward
Passes through the hole with the tool shifted away, then at the bottom of the hole (R point) shifts it back and cuts upward to Z (back boring). The R point is below the hole, so G99 cannot be used.

On lathes: Side deep hole drilling cycle (live tooling, systems A/B)One source / reference

The same number means something different on lathes (FANUC-type G-code system A). Group 10.

Differences between controls and machines

The same code can be written or assigned differently depending on the CNC control and the machine builder. Always check your machine’s manual.

SourceMachineItemDetail
HaasMachining centerCodeG77 (Back Bore Canned Cycle)Haas mills use G77 for back boring. G87 is not in the list
NISTMachining centerFormatG87 X_ Y_ Z_ R_ I_ J_ K_NIST: I/J give the shift position and K gives the top of the counterbore

Frequently asked questions about G87

What is G87 (Back boring cycle (reverse spot facing)) used for and how is it formatted in a CNC program?
G87 commands "Back boring cycle (reverse spot facing)" on Machining center, Lathe. The standard program format is "G87 X_ Y_ Z_ R_ Q_ (shift amount) P_ F_ K_". The spindle orients and the tool is shifted so the cutting edge clears the hole, passed through, then shifted back on the far side and cuts upward
Is G87 a modal code or a one-shot (non-modal) code?
G87 is a modal code (Group 09). Once commanded, it remains active across subsequent blocks until another code from the same modal group overrides it or the control is reset. Always state or cancel modal states explicitly in your safety block and at the end of a tool operation so residual modes do not cause unexpected motion when restarting mid-program.
Does G87 work differently on machining centers (mills) versus CNC lathes?
Yes. On a machining center G87 means "Back boring cycle (reverse spot facing)", whereas on a CNC lathe (FANUC G-code System A) G87 means "Side deep hole drilling cycle (live tooling, systems A/B)". Never copy G87 between mill and lathe programs without checking which G-code system (A, B, or C) your lathe uses.
Are there differences in G87 across FANUC, Mitsubishi, Okuma, Haas, and Siemens controls?
Yes. Control builders such as FANUC, Mitsubishi Electric (M80/M800), Okuma (OSP), Haas, Mazak, Siemens (SINUMERIK ISO dialect), and Heidenhain can differ in argument letters, decimal-point rules, and optional parameters for G87. Review the control comparison table above and verify the exact syntax in your machine’s programming manual before proving out the program.

Sources

The meaning of this code agrees in two or more sources from different publishers. Explanations are written in our own words.

  1. Siemens AG — SINUMERIK 802D sl/840D/840D sl/840Di/840Di sl/810D Programming Manual ISO Milling, 04.2007 Edition (6FC5398-7BP10-0BA0) cache.industry.siemens.com
  2. National Institute of Standards and Technology (NIST), USA — The NIST RS274NGC Interpreter – Version 3 (NISTIR 6556, 2000) nvlpubs.nist.gov
  3. Haas Automation, Inc. — Mill Operator's Manual – 17 Mill G-Codes (online version) haascnc.com
  4. Siemens AG — SINUMERIK 802D sl/840D/840D sl/840Di/840Di sl/810D Programming Manual ISO Turning, 04.2007 Edition cache.industry.siemens.com