G-code reference

G51.2 G-Code: Polygon Turning

Polygon Turning — Fanuc lathe function that synchronises a rotating tool axis with the spindle at a fixed ratio, so a fly cutter produces flats (squares, hexagons) on a turning…

By cnccode · Updated
PropertyValue
CodeG51.2
FunctionPolygon Turning
Modal group20
TypeModal — stays active until replaced by another code of the same group
Used onLathes
SyntaxG51.2 P_ Q_

What does G51.2 do?

Fanuc lathe function that synchronises a rotating tool axis with the spindle at a fixed ratio, so a fly cutter produces flats (squares, hexagons) on a turning part in seconds. G50.2 cancels.

G51.2 is modal: once programmed it remains in effect for the following blocks until another code from modal group 20 replaces it or the control is reset.

Syntax and parameters

Format
G51.2 P_ Q_
AddressMeaning
PSpindle speed ratio part
QTool speed ratio part (sign = direction)

G51.2 example program

Example
M03 S1000
G51.2 P1 Q2 (tool turns twice per spindle turn)
G01 X40.0 F0.1
G50.2

▶ Open this example in the G-code viewer

Tips and common mistakes

  • Flats are slightly convex — fine for wrenches and nuts, not for precision faces.

Controller compatibility

G51.2 follows the ISO/Fanuc dialect used by Fanuc, Haas, Brother, Doosan, Hurco (ISO mode), Mazak (EIA/ISO mode), Okuma (G-code mode) and Siemens in ISO dialect mode. Parameters, option packages and builder-specific behaviour can differ, so confirm the details in your machine's programming manual before running a new program.

Frequently asked questions

Is G51.2 modal?
Yes. G51.2 belongs to modal group 20 and stays active until another code of that group is programmed.
What does G51.2 mean in CNC?
G51.2 means Polygon Turning. Fanuc lathe function that synchronises a rotating tool axis with the spindle at a fixed ratio, so a fly cutter produces flats (squares, hexagons) on a turning part in seconds. G50.2 cancels.
Can I use G51.2 on a mill?
Usually not with the same meaning: G51.2 is documented here for lathes. Check your control manual for the equivalent.