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
- Tool center point controlA function that treats the programmed X, Y, Z as the position of the tool tip (tool center point), and has the NC automatically calculate the linear-axis compensating motion so the tool tip follows the programmed position and path even when the rotary axes turn. The feed rate can also be treated as the tool tip speed.[1][2][3][4][5][6]
- Two command formats of tool center point control (FANUC classification) Type I: command the rotary axis angles directly. Type II: command the tool orientation as a vector (I, J, K). With Type II, the same program works even on different machine configurations (head rotation, table rotation, mixed).One source / reference[3]
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)
- Tool axis direction controlA function that automatically indexes the rotary axes so the tool is perpendicular to the plane defined by the tilted working plane command. Because the tilted coordinate system follows when indexing turns the rotary axes, you don't need to reset the coordinate system after indexing.[7][8]
- There are normally two rotary axis solutionsFor the same tilted plane, there are generally two sets of rotary axis angles that point the tool perpendicular to it (e.g., A+45°/C+90° and A−45°/C−90°). You can specify which to use; if you don't, the NC chooses the nearer one within the travel range. If it is out of range, an error occurs.One source / reference[5]
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
- 3D tool radius compensationSo that you can use a tool with a different diameter from the one CAM calculated for, the tool radius is compensated in the direction of the surface normal (face milling) or in the direction perpendicular to both the travel direction and the tool axis (side milling). CAM must output the surface normal vector for each block.[1][2][5]
- Tool orientation control (orientation interpolation for side milling) Interpolates between the tool orientations at the start and end points so that the side of the tool sweeps a flat plane. Prevents overcutting by the tool side when machining a slanted surface with the side of the tool.[2][3][5][1]
- Workpiece setup error compensationEven if the workpiece is placed offset from what the program assumes (translated or rotated), the measured error is used to correct the path so the part can be machined without changing the program. It also applies to the rotary axis motion of tool center point control and tilted working plane commands.[2][3][11][12]
- 3D manual feed (retracting along the tool axis direction) A function to manually pull a tilted tool out along its tool axis, or move it parallel to the tilted plane, for example when a tool breaks. On a 3-axis machine you just raise Z, but on a 5-axis machine several axes must move in coordination.[2][4][1]
- Smoothing of tiny line segmentsA series of short lines (G1) output by CAM gives stepped speed at the block joints, leaving stripes and vibration marks on the surface. NCs have functions that merge them into splines or round corners within tolerance (Siemens COMPCAD and CYCLE832; FANUC Nano Smoothing 2 and Smooth TCP).[1][2][3]
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_CancelG49[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
Heidenhain (TNC 640)
- Tool center point control
M128 (or FUNCTION TCPM)CancelM129 (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
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]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))CancelTRAFOOF[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)CancelG49 (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)CancelG255Dynamic 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)CancelG269Defines 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)
- On Haas, a reset returns to G94One source / reference[18]
- After switching among G93, G94 and G95, command the feed againOne source / reference[20]
- Group number: Haas uses group 05One source / reference[18]
To calculate the F value, use5-axis calculations.
If you move a rotary axis in G94 (feed per minute)
- The meaning of the feed when you move a rotary axis in G94 (feed per minute) differs by NC. In NIST RS274NGC, a block where linear axes move uses feed per minute along the length of the XYZ path as if the rotary axes were not moving, and a block with only rotary axes uses deg/min.One source / reference[19]
- In Heidenhain's standard, the rotary axis feed is in deg/min, so the farther the tool is from the center of rotation, the faster the actual contouring feed. M116 treats a rotary table axis as mm/min.One source / reference[5]
Tool length and center of rotation
- If the center of rotation position used by the control (Haas MRZP, each maker's machine configuration parameters and kinematics) differs from the real machine, the machined part will show errors when the rotary axes move. That is why measuring and correcting the center of rotation (kinematics calibration) is needed.[21][6][7][1]
- Mitsubishi Electric has a function (tool length compensation along the tool axis direction) that can apply tool length compensation along the tool axis even when a rotary axis has moved the tool axis away from the Z direction.One source / reference[4]
What determines the accuracy of RTCP (tool center point control)
- Names comparedThe same function goes by different names: RTCP (Beckhoff, FIDIA, Cimatron and others), tool center point control (G43.4 on FANUC and Mazak), TCPM (M128 on Heidenhain), TRAORI (Siemens), and TCPC (G234 on Haas). In English and Chinese sources it is most often written as RTCP.[22][23][13][24]
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.
- ② The registered tool lengthIf the tool length is off by ΔL, the tip is off by ΔL in Z when pointing straight down, and when tilted that offset rotates with the tool. The mismatch with the surface cut with the tool straight down is ΔL·sinθ laterally and ΔL(1−cosθ) vertically, 2ΔL·sin(θ/2) combined (about 10 µm for ΔL = 20 µm and θ = 30°). Even on table-tilting machines, a tool length error appears in the same form as a Z-direction location error of the tilt axis.[13][27][24]
- ③ HeatThe center of rotation moves with spindle heat and room temperature. In a research example, the position of opposing faces changed by 20–22 µm during about 80 minutes of machining.[27]
- ④ Handling during rapid traverseOn some NCs, the tool tip position is not maintained during rotary motion in rapid traverse (TCPC on Haas).One source / reference[6]
- Calibration that corrects the machine sideAs an example of calibration that corrects the machine-side data, the compensation of Okuma's 5-axis auto-tuning system is said to work whether tool center point control is on or off. This is because the machine's geometry data itself is corrected, not the program.One source / reference[28]
- Standards for checking accuracyRTCP accuracy is also tested in standards. Besides the tests in the annex of ISO 10791-6 (JIS B 6336-6), such as BK1 and BK2 for two table-side axes, China's GB/T 39953-2021 “Five-axis simultaneous machining centers — RTCP accuracy inspection” defines RTCP as “a function that does not change the coordinates of the tool center point when the position of the rotary axes changes,” and RTCP accuracy as “how close the theoretical and actual values of the tool center point are during coordinated multi-axis motion with RTCP enabled.”One source / reference[29][30][31]
Checks before finishing with the tool tilted under RTCP
- Did you measure the center of rotation after warm-up? Is there no long gap between measuring and finishing?[27]
- After calibrating the kinematics, did you reset the workpiece origin (presets)?One source / reference[21]
- When checking with a ballbar or similar, did you run the program dry without the instrument attached the first time?One source / reference[13]
- Did you check what the feed during tool center point control is treated as (on some NCs it becomes the feed of the rotary axis)?One source / reference[13]
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
- G43.4: tool center point control. Comparison of the code numbers for FANUC-type, Mitsubishi Electric, Haas, Siemens, Heidenhain and Okuma post-processors
- G68.2: tilted working plane command (3+2 machining). The numbers come from CAM post-processor output and are not confirmed in NC makers' public documents
- G43: tool length compensation. Tool center point control extends this idea to tool orientation and rotary axes
- G49: canceling tool length compensation. Some NCs also use it to cancel tool center point control
- G53: positioning in the machine coordinate system. Used to retract the tool before rotating
- G68: 2D coordinate rotation. Not the same as 3D tilted-plane machining
- G94: feed per minute. The counterpart of inverse time feed G93
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

5-axis machining basics
The difference between 3+2 and simultaneous 5-axis machining, the advantages of 5 axes, and terminology.

5-axis machine configurations
The three types (head-head, table-table, head-table) with their advantages and drawbacks, the names and directions of rotary axes A, B, C, vertical vs. horizontal machines, and multitasking machines.

Calibration, collision, workholding and tools
Location errors of the rotary axes (center offset and tilt), R-test, ballbar and touch probe, kinematics calibration and heat, accuracy test standards, collision checking, 5-axis vises, and how to tilt a ball end mill.

Common 5-axis mistakes
Singularities (which orientation makes the C axis swing), the two solutions of a rotary axis and the long way around, feed units, tool length error, forgetting to cancel a tilted plane, and calibrating while cold. A checklist to verify on the shop floor.

5-axis CNC simulator
Run G43.4, G43.5 and G68.2 programs in the browser and cut in 3D — side holes and undercuts included — with warnings for TCP-off drift, singularities and holder collisions. Four exercises.

5-axis calculations
The F value for G93 inverse time feed, the tilt angle of a ball end mill, angles from a direction vector, the shortest way to turn a rotary axis, the effect of a center-of-rotation offset, and C axis speed near a singularity.

CAD/CAM
CAM workflow, toolpaths, a list of software, and data formats.
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.
- Siemens AG, “Milling with SINUMERIK — 5-axis machining Manual, Edition 05/2009 (DocOrderNo. 6FC5095-0AB10-0BP1)”
- FANUC America Corporation, “5-Axis Machining — CNC systems for high-performance machine tools (MBA-025-EN_03_1308, 2013)”
- 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)”
- Mitsubishi Electric Corporation, “NC Specification Selection Guide M800V/M80V/E80/C80 Series (BNP-A1244 ENG D)”
- DR. JOHANNES HEIDENHAIN GmbH, “TNC 640 User's Manual Conversational Programming, NC Software 340590-01 / 340591-01 / 340594-01, 4/2012 (892903-20)”
- Haas Automation, Inc., “G234 Tool Center Point Control (TCPC) (G-code reference page)”
- FANUC Corporation, “FANUC Series 30i/31i/32i-MODEL B Plus catalog (English edition FS30i-BPlus(E)-01)”
- Mitsubishi Electric Corporation, Naoki Nakamura, “Improved usability of indexed machining on the ‘MITSUBISHI CNC M700V Series’,” Mitsubishi Denki Giho Vol.85 No.4 (2011)
- Haas Automation, Inc., “G268 / G269 Feature Coordinate System (G-code reference page)”
- FANUC Europe, “Tilted Working Plane (software introduction page)”
- FANUC America Corporation, “Advanced Machining Tips & Tricks | 5-axis CNC (introduction page for an explainer video series)”
- 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)”
- Renishaw plc, "Application note: ISO 10791-6 using QC20 ballbar"
- Autodesk, “FANUC generic post processor (fanuc.cps, Fusion post library; the output of a CAM maker, not a FANUC document)”
- Siemens AG, “SINUMERIK live: Programming dynamic 5-axis machining directly in SINUMERIK Operate (2018)”
- Siemens AG, “SINUMERIK live: Multi-face machining milling (3+2 axes) (2017)”
- Haas Automation, Inc., “G254 Dynamic Work Offset (DWO) (G-code reference page)”
- Haas Automation, Inc., “G93 Inverse Time Feed Mode (G-code reference page)”
- National Institute of Standards and Technology (NIST), “The NIST RS274NGC Interpreter – Version 3 (NISTIR 6556, 2000)”
- Siemens AG, “SINUMERIK 840D sl/828D Fraisage ISO, Manuel de programmation 02/2012 (6FC5398-7BP40-3DA0, French edition)”
- 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)”
- Beckhoff Automation, "TwinCAT CNC Programmierung: Rotation Tool Center Point (RTCP)" (in German)
- Cimatron (Sandvik Group), "Cimatron 2026 Online Help: RTCP Settings"
- FIDIA S.p.A., “Functions for 5-axis machine tools (RTCP)”
- 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)
- 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)”
- 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)”
- Okuma America Corporation (Okuma), “MU-V Series 5-Axis Vertical Machining Centers catalog”
- 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”
- 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)
- Chinese Standard (standards sales site), “GB/T 39953-2021 Five-axis simultaneous machining centers — RTCP accuracy inspection (overview and table of contents)”