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 controlWith tool center point controlFaint drawing: before turning (tool straight down); dark drawing: after turningCenter of rotationPoint to cutX and Z move to compensateStays on the point to cutThe axis just rotates, so the tool tipdrifts off along an arcOnly the tool orientation changes,and the tip stays at the programmed position

For the comparison of code numbers and cautions, see the G-code dictionary entry for G43.4 (tool center point control).

◢Tilted working plane (the tilted coordinate system for 3+2 machining)

Diagram: tilted working plane, building a coordinate system on a tilted plane (3+2 machining)

XfZfYf (toward you)90° to tool axisRotary axis tilts the tableG68.2: tilted-plane coordinatesG53.1: tool normal to the planeWrite an ordinary 3-axis program on the yellow plane
With G68.2 and similar commands, a new coordinate system Xf, Yf, Zf is created on the tilted plane (yellow). With G53.1 and similar commands, the rotary axes are indexed so the tool points perpendicular to that plane, and the rest is cut with an ordinary 3-axis program.

For FANUC-type controls, CAM makers' generic FANUC post-processors output G68.2 (definition), G53.1 (indexing) and G69 (cancel). The numbers could not be confirmed in FANUC's own public documents, so treat them as a reference. This is a different function from G68 (2D coordinate rotation within the machining plane). For details, see the G-code dictionary entry for G68.2.

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. The G-code numbers of FANUC's tilted working plane command could not be confirmed in FANUC's own public documents, so the output of CAM makers' post-processors is shown as a reference.

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). CAM makers' generic FANUC post-processors output G68.2 (define the tilted plane), G53.1 (index the tool perpendicular to the plane) and G69 (cancel). The G-code numbers could not be confirmed in FANUC's own public documents[2][7][14]
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 controls and Mazak. The selection guide does not say which format 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 assumes the machine builder has registered the kinematics (machine geometry)
  • Tool length is referenced to the center of the ball at the tool tip
  • Cancel M128 before M91/M92 positioning and before TOOL CALL
  • With a Hirth-coupling tilting axis, retract the tool before changing the angle (disengaging the coupling can damage the workpiece)
  • FUNCTION TCPM is an improved M128. You can choose the feed as the relative speed at the tool tip (F TCP) or the contour feed of each axis (F CONT), the rotary-axis values as axis positions (AXIS POS) or spatial angles (AXIS SPAT), and the interpolation as a straight tool-tip path only (PATHCTRL AXIS) or with the tool axis also interpolated in a plane (PATHCTRL VECTOR)
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 axes, in that order (A, B, C). Do not omit any of the three, even when they are 0
  • MOVE: moves the rotary axes and compensates the linear axes to keep the tool-to-workpiece position. TURN: moves only the rotary axes. STAY: you rotate them yourself in a separate block (the calculated values go into Q120–Q122)
  • Always cancel with PLANE RESET. Entering all zeros does not fully cancel it
  • On machines with a C rotary table you can choose COORD ROT (rotate only the coordinate system) or TABLE ROT (rotate the table)
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][15][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
  • Depending on the configuration, TRAORI may reset the active work offset, so program the work offset again after TRAORI to be safe
  • Programming the tool orientation with the direction vector A3, B3, C3 is recommended. The vector points toward the tool holder and its length does not matter. Five decimal places for linear axes and six for the direction vector give good results
  • Programming only C3=1 points the tool in the Z direction (useful, for example, when retracting from a hole)
  • Orientation can be referenced to ORIWKS (workpiece coordinate system) or ORIMKS (machine coordinate system). Use ORIWKS for a 5-axis program when you don't know which machine it will run on
  • Orientation can also be programmed with Euler or RPY angles (A2, B2, C2), surface normal vectors (A4–C4/A5–C5), and LEAD/TILT (ORIPATH)
  • TOROT: creates a coordinate system whose Z is the tool orientation, so the tool can retract straight along Z if it breaks (cancel with TOROTOF)
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][16]
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 handle tool offsets and the zero point
  • The swivel function is standard (not an option). TRAORI is an option in the 5-axis package
  • Machine types: swivel head (type T), swivel table (type P), mixed (type M)
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 (measures the position of the center of rotation and compensates for it; for the idea, see the kinematics calibration in the "Calibration, collision, workholding and tools" page)[1]

Haas (NGC)

Tool center point control
G234 H_ (group 08) Cancel G49 (G43 and G44 also cancel it)[6][13]
  • Write the H code in the same block (G234 cancels the previous H)
  • Set the rotary axes to 0 before commanding G234
  • During TCPC, rapid moves of the rotary axes do not maintain the tool-tip position. Do not move rotary axes at rapid
  • G43 and G234 cannot be active at the same time. G234 also cannot be combined with G254 (DWO)
  • The control calculates the tool-tip position from the rotary-axis centers of rotation (MRZP), the work offset and the tool length
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[17]
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)

G93 (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

What determines the accuracy of RTCP (tool center point control)

Tool center point control is a function that “keeps the tool tip at the programmed position,” but if the numbers used in its calculation differ from the real machine, the tip is off by the same amount. Four things determine the accuracy.

LCenter of rotation (tilt axis)Tip used by the NC (tool length L)Actual tip (L + ΔL)Tip offset (enlarged)Gray: tip offset ΔL when straight downGreen: tip offset ΔL when tilted by θθLateral ΔL·sinθVertical ΔL(1−cosθ)Red: combined 2ΔL·sin(θ/2)If the tool length is entered wrong by ΔL, the tip is off by ΔL in Z when pointing straight down (ΔL is drawn large)When tilted, the offset rotates with the tool, and the mismatch with the surface cut with the tool straight down is 2ΔL·sin(θ/2)Example: ΔL = 20 µm, θ = 30° gives 10 µm lateral and 2.7 µm vertical, about 10 µm combined

Checks before finishing with the tool tilted under RTCP

For the size of the offset, use 5-axis calculations (center-of-rotation offset, tool length error). For how to measure the center of rotation, see Calibration and accuracy.

Related pages in the G-code dictionary

Frequently Asked Questions

What is tool center point control?
It treats the programmed X, Y and Z as the tool tip position, and the CNC automatically calculates compensating linear-axis moves so that the tip follows the programmed path even as rotary axes turn. Without it, every change in tool length needs a program recalculated in CAM.
What is a tilted working plane command?
It defines a coordinate system along a tilted face so that you can program on that face as if it were an ordinary XY plane; it is the function used most in 3+2 machining. The commands are the PLANE functions on Heidenhain, CYCLE800 on Siemens and G268 on Haas.
Is there only one rotary-axis solution that sets the tool normal to a tilted plane?
Usually there are two (for example A+45°/C+90° and A−45°/C−90°). You can specify which one; if not, the CNC picks the nearer one within the travel range, and raises an error if it is out of range.
Why do long runs of short CAM line segments leave stripes on the surface?
With consecutive short lines (G1), speed steps at each block junction, leaving stripes or vibration marks on the surface. CNCs have functions that merge them into splines or round the corners within a tolerance (Siemens COMPCAD and CYCLE832, FANUC Nano Smoothing 2 and Smooth TCP).

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. Autodesk, “FANUC generic post processor (fanuc.cps, Fusion post library; the output of a CAM maker, not a FANUC document)”
  15. Siemens AG, “SINUMERIK live: Programming dynamic 5-axis machining directly in SINUMERIK Operate (2018)”
  16. Siemens AG, “SINUMERIK live: Multi-face machining milling (3+2 axes) (2017)”
  17. Haas Automation, Inc., “G254 Dynamic Work Offset (DWO) (G-code reference page)”
  18. Haas Automation, Inc., “G93 Inverse Time Feed Mode (G-code reference page)”
  19. National Institute of Standards and Technology (NIST), “The NIST RS274NGC Interpreter – Version 3 (NISTIR 6556, 2000)”
  20. Siemens AG, “SINUMERIK 840D sl/828D Fraisage ISO, Manuel de programmation 02/2012 (6FC5398-7BP40-3DA0, French edition)”
  21. 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)”
  22. Beckhoff Automation, "TwinCAT CNC Programmierung: Rotation Tool Center Point (RTCP)" (in German)
  23. Cimatron (Sandvik Group), "Cimatron 2026 Online Help: RTCP Settings"
  24. FIDIA S.p.A., “Functions for 5-axis machine tools (RTCP)”
  25. Japan Society for Precision Engineering (S. Ibaraki), “Measurement and Compensation of Motion Errors of Five-Axis Machine Tools (review)”, Journal of the Japan Society for Precision Engineering 78(9) (2012) (in Japanese)
  26. Fuji Technology Press (S. Ibaraki, Y. Ota), “Error Calibration for Five-Axis Machine Tools by On-the-Machine Measurement Using a Touch-Trigger Probe, Int. J. of Automation Technology 8(1) (2014)”
  27. Elsevier (S. Ibaraki et al., Hiroshima University repository), “A machining test to evaluate thermal influence on the kinematics of a five-axis machine tool, Int. J. Machine Tools and Manufacture 163, 103702 (2021)”
  28. Okuma America Corporation (Okuma), “MU-V Series 5-Axis Vertical Machining Centers catalog”
  29. Japanese Standards Association (JSA), “JIS B 6336-6:2018 Test conditions for machining centres — Part 6: Accuracy of feeds, speeds and interpolations (ISO 10791-6:2014), preview”
  30. Japan Society for Precision Engineering (Y. Ihara, M. Tsutsumi, T. Eguchi, S. Ibaraki), “A Study of Measurement and Compensation Techniques for Volumetric Accuracy of 5-Axis Machine Tools”, Journal of the Japan Society for Precision Engineering 85(10) pp.809-812 (2019) (in Japanese)
  31. Chinese Standard (standards sales site), “GB/T 39953-2021 Five-axis simultaneous machining centers — RTCP accuracy inspection (overview and table of contents)”