CNC Programming

G71 CNC programming for CNC lathe rough turning

What G71 does in a CNC lathe program

G71 CNC programming is used on many CNC lathes to rough-turn stock on an outside diameter or inside diameter with a canned stock-removal cycle. Instead of programming every roughing pass line by line, the programmer defines the finished contour between a start block and an end block. The control then calculates the repeated roughing cuts, retract moves, and remaining stock for finishing. Syntax varies by control, but the purpose is the same: remove bulk material efficiently while leaving a controlled allowance for a G70 finishing cycle or a separate finishing toolpath.

On Fanuc-style, Haas, Mitsubishi, and similar turning controls, G71 is a common way to turn a finished profile into a repeatable roughing routine. It is also a cycle that should be handled carefully. Depth of cut, retract amount, finish allowance, profile direction, tool nose compensation, and Type I versus Type II behavior can all change the result. Use the examples below as a programming framework, then confirm each address and interpretation in the machine builder’s programming manual before cutting metal.

code, coding, programming, html, typing, work, business, hands, laptop, computer, technology, office, desk, coding, coding, coding, coding, coding, programming

For more turning and control-code explainers, see the CNC programming section.

Common G71 formats and what the addresses mean

Most programmers see G71 in either a two-line Fanuc-style format or a one-line format used on some controls. The two-line format separates roughing depth and retract from the contour call. The one-line format places more of the cycle information in a single G71 block. The address letters may look familiar across controls, but the measurement basis can differ. For example, roughing depth may be treated as a radial value on one control, while an X-axis allowance may follow diameter programming rules on another.

Format Typical structure Primary use
Two-line Fanuc-style G71 G71 U… R…
G71 P… Q… U… W… F…
Common rough-turning format where the first line sets roughing depth and retract, and the second line identifies the profile and finish stock.
One-line G71 G71 P… Q… U… W… D… F… Used on some controls where D defines depth of cut and the P-Q blocks define the finished profile.
G70 after G71 G70 P… Q… Often used to finish the same contour after roughing, usually with the same P and Q block numbers.

The most common G71 addresses are listed below. Always verify the sign convention and unit basis for the specific control. Code that runs correctly on one lathe may leave the wrong stock, cut in an unexpected direction, or alarm out on another.

Address Common meaning in G71 roughing Programming note
P First block number of the finished contour The cycle reads the profile from this N block.
Q Last block number of the finished contour The cycle stops reading the profile at this N block.
U on first G71 line Roughing depth of cut on many two-line formats Often treated as a positive depth; check whether the value is radial or diameter-based.
R Retract amount between roughing passes Too small a retract can rub or drag; too large a retract wastes cycle time.
U on second G71 line Finish allowance in X Usually leaves stock for finishing; sign and diameter/radius interpretation are control-specific.
W Finish allowance in Z Positive or negative direction depends on the programmed contour and control convention.
D Depth of cut in some one-line formats Common on Haas-style one-line notation.
F Roughing feedrate Some controls use the F value in the G71 block throughout the roughing cycle.
S and T Spindle speed and tool command, where supported Use according to the control manual and shop programming standard.

How to build a reliable G71 program

A reliable G71 routine starts with the finished geometry, not with the roughing passes. The control needs a clean, logical contour between the P and Q blocks. If that contour is ambiguous, reverses in a way the selected cycle type cannot handle, or includes compensation that the control treats differently inside canned cycles, the generated roughing path may be wrong even when the code appears simple.

  1. Set a safe start position. Approach from a clearance position that is safely outside the stock in X and ahead of the part in Z. The cycle uses this area as part of its roughing logic, so do not begin from a marginal clearance point.
  2. Define the finished contour in order. Use the P and Q block numbers to wrap only the profile that should be rough cut. Keep unrelated moves, tool changes, optional stops, and probing logic outside the P-Q range.
  3. Choose a realistic roughing depth. The cut depth must suit the insert, material, workholding rigidity, available horsepower, and chip evacuation. G71 simplifies code; it does not remove machining limits.
  4. Leave finishing stock deliberately. U and W finish allowances should be large enough to clean up roughing marks and tool-pressure error, but not so large that the finishing tool is overloaded.
  5. Separate roughing feed from finishing feed. Use a roughing feed suitable for chip control and insert life. The finishing pass normally uses a different feed, speed, and sometimes a different tool.
  6. Run graphics, dry run, and single block. A G71 cycle can generate many internal moves from only a few program lines. Simulation and cautious first-run procedures are essential.

In production programming, the profile blocks should be easy to audit. Use consistent block numbering, make the first contour move predictable, and avoid placing geometry-changing commands inside the P-Q range unless the control manual specifically allows them.

Example of a two-line G71 roughing cycle

The simplified example below shows the structure of a two-line G71 cycle for outside-diameter rough turning. It is not a drop-in program for a specific machine. Units, spindle mode, work offset, tool call format, and safety blocks must match the shop’s machine and postprocessor standards.

Program line Purpose
N10 G50 S2500 Sets a spindle speed limit on controls where this is used.
N20 G96 S180 M03 Starts constant surface speed mode and spindle rotation, where supported.
N30 G00 X62.0 Z2.0 Moves to a safe roughing start position outside the stock.
N40 G71 U2.0 R0.5 Sets roughing depth and retract amount in a common two-line format.
N50 G71 P100 Q160 U0.4 W0.2 F0.25 Calls the contour from N100 to N160, leaving finish stock in X and Z.
N100 G00 X30.0 Begins the finished profile at the P block.
N110 G01 Z0.0 Feeds to the face or start of the turned feature.
N120 X36.0 Z-10.0 Programs a taper or angled section.
N130 Z-30.0 Programs a straight diameter section.
N140 X50.0 Z-45.0 Programs another taper or transition.
N150 Z-60.0 Programs the final straight section.
N160 X62.0 Ends the finished contour at the Q block.
N170 G70 P100 Q160 Finishes the same contour after roughing, if appropriate.
N180 G00 X100.0 Z100.0 Retracts to a safe position.

The key idea is that the cycle roughs toward the P-Q contour while respecting the stock allowance. The G70 line then reuses the same geometry for finishing. In a real program, the finishing tool may have its own tool call, offset, spindle speed, coolant command, and feedrate before G70. Many shops prefer this separation because it makes the roughing and finishing responsibilities easier to review.

Type I and Type II G71 behavior

One of the most important distinctions in G71 CNC programming is the difference between Type I and Type II roughing. The names describe how the control interprets the profile shape. Type I is generally associated with a monotonic profile, meaning the contour progresses in one general direction without pockets or undercuts that require the tool to reverse in the roughing axis. Type II is used on controls that support more complex profiles, including certain non-monotonic shapes and undercut-style geometry.

The practical effect is straightforward: if a profile contains a groove, pocket, or shape that turns back on itself, a Type I roughing cycle may alarm, ignore part of the shape, or generate an unsuitable path. A Type II-capable control may be able to rough that geometry, but only if the program format tells the control to use Type II and the tool can physically cut the feature. On many Fanuc-style controls, the first block of the P-Q profile is involved in Type I versus Type II recognition, but the exact rule is not universal. Haas, Fanuc, Mitsubishi, and builder-specific implementations should be checked individually.

Even when Type II is available, it is not a substitute for process planning. A roughing insert may not have clearance for a narrow undercut. Tool nose radius compensation may behave differently inside the canned cycle than it does in a manually programmed contour. Chip packing can also become a problem in deep pockets. When the profile is not a simple outside turn, simulate the path and consider whether a separate grooving or profiling operation is safer. See also: CNC Machining.

Common G71 mistakes and how to avoid them

Most G71 problems come from a small group of programming errors. Because the cycle is compact, one wrong address can affect every roughing pass.

  • Wrong P or Q block numbers. If P and Q point to the wrong blocks, the control may rough an incomplete contour or include moves that do not belong in the cycle. Keep the P-Q section clean and easy to inspect.
  • Unsafe start position. Starting too close to the stock can cause unexpected engagement. Start outside the raw material with enough X and Z clearance for the retract moves.
  • Confusing rough depth with finish allowance. The first-line U or D value controls roughing depth on common formats, while the second-line U and W leave stock. Mixing these up can overload the tool or leave no finishing material.
  • Assuming every control uses the same syntax. G71 is widely used, but it is not identical everywhere. A program transferred from one lathe family to another should be reviewed address by address.
  • Using an unsupported profile shape. Type I cycles are not intended for every undercut or pocket. Complex shapes may require Type II support or a different strategy.
  • Forgetting finishing conditions. G71 roughing does not guarantee final size or surface finish. Plan the finishing tool, speed, feed, compensation, and allowance.
  • Ignoring insert clearance and chip flow. The control may be able to calculate a path that the insert cannot survive. Check approach angles, shoulder clearance, and chip evacuation.

A useful shop practice is to review G71 code in three passes. First, check the geometry between P and Q. Second, check cycle addresses and allowances. Third, check machine-state commands such as spindle mode, feed mode, coolant, work offset, and compensation. This approach helps prevent the review from becoming a quick visual scan that misses the real risk.

When to use G71 and when to program manually

G71 is strongest when the part has a clear turning profile, repeatable stock conditions, and enough material to justify multiple roughing passes. It reduces program length and makes the finished geometry easier to maintain because the same P-Q profile can be used for roughing and finishing. It is especially efficient for stepped shafts, tapers, and simple internal bores where the roughing envelope is predictable.

Manual roughing or CAM-generated toolpaths may be better when the profile includes interrupted cuts, difficult grooves, thin walls, delicate workholding, or a sequence that needs custom engagement control. CAM may also provide more control over entry moves, chip thinning strategies, rest roughing, and toolpath smoothing. The best choice is not based on code length alone. It depends on whether the cycle produces a safe, understandable, and repeatable process for the actual machine, tool, material, and fixture.

Frequently asked questions

What is G71 in CNC programming?

G71 is a lathe roughing canned cycle used to remove stock along a programmed contour. The programmer defines the finished shape between P and Q blocks, and the control calculates roughing passes while leaving specified material for finishing.

Is G71 only for outside diameter turning?

No. On many lathe controls, G71 can be used for outside-diameter and inside-diameter stock removal. Tool orientation, start position, programmed contour, and control-specific rules determine how it should be applied.

What is the difference between G71 and G70?

G71 is used for roughing. G70 is commonly used afterward to finish the contour defined by the same P and Q blocks. In many programs, G71 removes most of the material and G70 makes the final profile pass.

Can G71 rough undercuts?

Only if the control and program format support the required Type II or equivalent behavior, and only if the tool can physically cut the geometry. Simple Type I roughing is generally intended for monotonic profiles and may not handle undercuts correctly.

Why does copied G71 code fail on another machine?

G71 syntax and address interpretation vary by control and machine builder. Differences may include one-line versus two-line format, depth-of-cut address, Type I and Type II recognition, finish allowance signs, and tool nose compensation behavior. Always adapt copied code to the target machine manual.