5-AXIS CNC5-axis NC functions

How a 5-axis program is written depends on how the NC calculates the motion of rotary and linear axes. This summarizes how the main functions work and how commands differ by NC maker. Command syntax is shown only in outline. Availability depends on the model and options, so always check the instruction manual.

⊙With and without tool center point control

Without tool center point controlCenter of rotationPoint to cutThe axis just rotates, so the tool tipdrifts off along an arcWith tool center point controlX and Z move to compensateStays on the point to cutOnly the tool orientation changes,and the tip stays at the programmed position

◇Other 5-axis functions

≡Commands by NC maker

The same function is commanded differently depending on the NC. The G-codes and M-codes below are only those confirmed in each maker's public documents. G-code numbers for FANUC's tilted working plane command and others are not listed because they could not be confirmed in public documents.

FANUC (Series 30i/31i-B5 etc.)

Tool center point control
G43.4 H_ Cancel G49[13]From the comparison table in Renishaw's ISO 10791-6 ballbar test document (FANUC 30 series: Tool Centre Point (TCP) G43.4 / G49). Example sequence: G43.4 H1 → B90 → G49. G-code numbers could not be confirmed in FANUC's own public documents.
Tool orientation vector command
(Type II vector command. G-code number not confirmed in FANUC's public documents)[3]
Tilted-plane machining
Tilted Working Plane (tilted working plane command) and Tilted Working Plane Indexing (tool axis direction control). G-code numbers not confirmed in FANUC's public documents[2][7]
Workpiece setup error compensation
G54.4 (workpiece setup error compensation)[11]

Mitsubishi Electric (M800V/M80V etc.)

Tool center point control
Tool center point control (G43.4/G43.5): controls the position commands in the machining program as the tool center point on a coordinate system that rotates with the workpiece (table coordinate system)[4]The G43.4 number matches FANUC-type and Mazak (s18). The selection guide does not say which of the two formats G43.5 is assigned to.
Tool cutting point control
Tool cutting point control (G43.8/G43.9)[4]
Tilted-plane machining
Tilted working plane command (6 definition methods) + tool axis direction control. A simplified tilted working plane command is also available. R-Navi is a function that registers a tilted coordinate system through screen operations and confirms it in a 3D display[8][4]Both are from Mitsubishi Electric (one publisher). G-code numbers not confirmed in public documents.
Others
Tool length compensation along the tool axis direction, tool handle feed and interruption, 3D tool radius compensation, workpiece setup error compensation, 3D manual feed[4]

Yamazaki Mazak (EIA on MAZATROL Matrix 2)

Tool center point control
G43.4 Cancel G49Tool Tip Point Control (TTPC)[13]

Heidenhain (TNC 640)

Tool center point control
M128 (or FUNCTION TCPM) Cancel M129 (FUNCTION RESET TCPM)[5][13]
L X_ Y_ Z_ B_ … F_ M128 F_ (the second F is the feed for the compensating motion) / FUNCTION TCPM F TCP|F CONT  AXIS POS|AXIS SPAT  PATHCTRL AXIS|PATHCTRL VECTOR
  • M128 requires the machine maker to have registered the kinematics (machine geometry) (s11)
  • Tool length is referenced to the center of the ball at the tool tip (s11)
  • Cancel M128 before M91/M92 positioning and before TOOL CALL (s11)
  • For tilt axes with a Hirth coupling, retract the tool before changing the angle (the form is damaged when the coupling disengages) (s11)
  • FUNCTION TCPM is an improved version of M128. You can choose whether the feed is the relative speed of the tool tip (F TCP) or the contouring feed of each axis (F CONT), whether rotary axis values are axis positions (AXIS POS) or spatial angles (AXIS SPAT), and whether interpolation covers only the tool tip line (PATHCTRL AXIS) or also interpolates the tool axis in a plane (PATHCTRL VECTOR) (s11)
Tilted-plane machining
Define the tilted plane with PLANE functions (SPATIAL / PROJECTED / EULER / VECTOR / POINTS / RELATIVE / AXIAL); cancel with PLANE RESET[5]
PLANE SPATIAL SPA_ SPB_ SPC_ MOVE|TURN|STAY [DIST_] [F_] [SEQ+|SEQ−] [COORD ROT|TABLE ROT]
  • Spatial angles are rotations about the machine-fixed X → Y → Z in that order (A, B, C order). Don't omit them even when all three are 0 (s11)
  • MOVE: moves the rotary axes and also compensates the linear axes to keep the relative position of tool and workpiece. TURN: moves only the rotary axes. STAY: you rotate in a separate block yourself (the calculated values go to Q120–Q122) (s11)
  • Always cancel with PLANE RESET. Entering all zeros does not cancel it completely (s11)
  • On machines with a C rotary table you can choose COORD ROT (rotate only the coordinate system) or TABLE ROT (rotate the table) (s11)
M codes for rotary axes
M126 / M127Turn a rotary axis displayed under 360° the shortest way / cancel[5]
M94Reduce the displayed value of a rotary axis to under 360° and then move[5]
M116 / M117Treat the feed of a rotary table axis as mm/min (calculated from the distance between the tool and the center of rotation) / cancel. Has no effect on swivel heads[5]
M138Select the tilt axis used for M128, TCPM and tilted planes[5]
M144 / M145Reflect kinematics changes caused by spindle attachments and the like in the position display (not to be used together with M128 or tilted planes)[5]

Siemens (SINUMERIK 840D sl etc.)

Tool center point control
TRAORI (TRAORI(n)) Cancel TRAFOOF[1][14][13]
TRAORI → G54 (command the work offset again after TRAORI) → G1 X_ Y_ Z_ A3=_ B3=_ C3=_ (direction vector) or G1 X_ Y_ Z_ B=_ C=_ (rotary axis positions) … TRAFOOF
  • On some configurations TRAORI resets the active work offset, so command the work offset after TRAORI to be safe (s1)
  • Commanding the tool orientation with the direction vector A3, B3, C3 is recommended. The vector points toward the tool holder, and its length is irrelevant. Linear axes to 5 decimal places and the direction vector to 6 decimal places give good results (s1)
  • Commanding only C3=1 points the tool in the Z direction (useful for retracting from a hole, for example) (s1)
  • Orientation can be referenced to ORIWKS (workpiece coordinate system) or ORIMKS (machine coordinate system). For 5-axis programs where you don't know which machine will run them, use ORIWKS (s1)
  • Orientation can also be commanded with Euler angles and RPY angles (A2, B2, C2), or surface normal vectors (A4–C4 / A5–C5) with LEAD and TILT (ORIPATH) (s1)
  • TOROT: creates a coordinate system with the tool orientation as Z, and retracts straight in the Z direction when a tool breaks (cancel with TOROTOF) (s1)
Tilted-plane machining
CYCLE800 (swivel cycle). Turns the rotary axes so the machining surface is perpendicular to the tool, and automatically converts the zero point and tool offsets to the swiveled state. You can choose to command A, B, C directly to the machine, or to command rotations about workpiece coordinate X, Y, Z as on the drawing. When commanding consecutively, choose new or additive[1][15]
CYCLE800 (swivel data name, swivel / don't swivel, new / additive, reference point before swiveling X0 Y0 Z0, per axis / projection angles / spatial angles, each angle, zero point shift after swiveling …) → ordinary program in the XY plane → swivel back
  • CYCLE800 takes the machine kinematics into account. Frames such as ROT (coordinate rotation) rotate only the coordinate system, so the user has to think about tool offsets and zero points (s1)
  • The swivel function is standard (not an option). TRAORI is an option of the 5-axis package (s1)
  • Machine types: swivel head (type T), swivel table (type P), mixed (type M) (s1)
Others
CYCLE832A cycle that sets high-speed machining settings (tolerance, compressor, smoothing, jerk, etc.) all at once. Used by switching to speed-oriented for roughing and accuracy-oriented for finishing[1]
CUT3DC / CUT3DF / CUT3DCC3D tool radius compensation (side milling / face milling / taking the bottom limiting surface into account)[1]
ORIAXES / ORIVECT (ORIPLANE) / ORICONxx / ORICURVEOrientation interpolation: linear interpolation of the rotary axes / great circle (vector) interpolation / on a cone / two splines[1]
CYCLE996Kinematics measuring cycle (see practice.json below)[1]

Haas (NGC)

Tool center point control
G234 H_ (group 08) Cancel G49 (G43 and G44 also cancel it)[6][13]
  • Write an H code in the same block (because G234 cancels the previous H) (s13)
  • Set the rotary axes to 0 before commanding G234 (s13)
  • During TCPC, the tool tip position is not maintained in rapid moves of a rotary axis. Don't move rotary axes in rapid traverse (s13)
  • G43 and G234 are not active at the same time. They also can't be combined with G254 (DWO) (s13)
  • The control calculates the tool tip position from the center of rotation of the rotary axes (MRZP), the work offset and the tool length (s13)
Dynamic Work Offset (3+2 positioning)
G254 (group 23) Cancel G255Dynamic Work Offset: for 3+1 and 3+2 positioning. Not used in simultaneous 4- and 5-axis (cancel with G255 before simultaneous machining). Command G254 after the rotary axis move finishes, then command X, Y and Z again in separate blocks. Retract the tool with G53 before rotating[16]
Tilted coordinate system (feature coordinate system)
G268 (group 14) Cancel G269Defines a tilted feature coordinate system in which canned cycles and G-codes can be used normally. Activate G43 before G268. G268 only creates the coordinate system; no axis moves. If you use it with G234, put G268 first[9]
G268 X_ Y_ Z_ [I_ J_ K_ Q_] (origin + rotations about WCS X, Y, Z and the rotation order. Q123 = X→Y→Z is the default, Q321 = Z→Y→X)

FG93 (cancel and return to normal with G94)

To calculate the F value, use5-axis calculations.

If you move a rotary axis in G94 (feed per minute)

↧Tool length and center of rotation

GRelated pages in the G-code dictionary

Other 5-axis machining pages

📚Sources

The command outlines are key points from each maker's public manuals and technical documents; manual text and examples are not copied. Many are options that cannot be used unless the machine maker has enabled the function.

  1. Siemens AG, “Milling with SINUMERIK — 5-axis machining Manual, Edition 05/2009 (DocOrderNo. 6FC5095-0AB10-0BP1)”
  2. FANUC America Corporation, “5-Axis Machining — CNC systems for high-performance machine tools (MBA-025-EN_03_1308, 2013)”
  3. Fuji Technology Press (author: Masako Sudo, FANUC Corporation), “Development Report: Advanced Control Technologies for 5-Axis Machining, Int. J. of Automation Technology Vol.1 No.2, pp.108-112, 2007 (DOI 10.20965/ijat.2007.p0108, CC BY-ND 4.0)”
  4. Mitsubishi Electric Corporation, “NC Specification Selection Guide M800V/M80V/E80/C80 Series (BNP-A1244 ENG D)”
  5. DR. JOHANNES HEIDENHAIN GmbH, “TNC 640 User's Manual Conversational Programming, NC Software 340590-01 / 340591-01 / 340594-01, 4/2012 (892903-20)”
  6. Haas Automation, Inc., “G234 Tool Center Point Control (TCPC) (G-code reference page)”
  7. FANUC Corporation, “FANUC Series 30i/31i/32i-MODEL B Plus catalog (English edition FS30i-BPlus(E)-01)”
  8. Mitsubishi Electric Corporation, Naoki Nakamura, “Improved usability of indexed machining on the ‘MITSUBISHI CNC M700V Series’,” Mitsubishi Denki Giho Vol.85 No.4 (2011)
  9. Haas Automation, Inc., “G268 / G269 Feature Coordinate System (G-code reference page)”
  10. FANUC Europe, “Tilted Working Plane (software introduction page)”
  11. FANUC America Corporation, “Advanced Machining Tips & Tricks | 5-axis CNC (introduction page for an explainer video series)”
  12. Osaka Institute of Technology, Faculty of Engineering, Department of Mechanical Engineering, Precision Engineering Laboratory (Yukitoshi Ihara Laboratory), “A Study of Machining Accuracy Test Methods for 5-Axis Machining Centers (research introduction poster)”
  13. Renishaw plc「Application note: ISO 10791-6 using QC20 ballbar」
  14. Siemens AG, “SINUMERIK live: Programming dynamic 5-axis machining directly in SINUMERIK Operate (2018)”
  15. Siemens AG, “SINUMERIK live: Multi-face machining milling (3+2 axes) (2017)”
  16. Haas Automation, Inc., “G254 Dynamic Work Offset (DWO) (G-code reference page)”
  17. Haas Automation, Inc., “G93 Inverse Time Feed Mode (G-code reference page)”
  18. National Institute of Standards and Technology (NIST), “The NIST RS274NGC Interpreter – Version 3 (NISTIR 6556, 2000)”
  19. Siemens AG, “SINUMERIK 840D sl/828D Fraisage ISO, Manuel de programmation 02/2012 (6FC5398-7BP40-3DA0, French edition)”
  20. DR. JOHANNES HEIDENHAIN GmbH, “TNC 640 User's Manual Programming of Measuring Cycles for Workpieces and Tools, NC Software 34059x-18, 10/2023 (1303409-23)”