Abstract
Five-axis machining is commonly used for complicated features due to its advantage of rotary movement. However, the rotary movement introduces nonlinear terms in the kinematic transform. The nonlinear terms are related to the distance between the cutter location (CL) data and the intersection of the two rotary axes. This research studied the possible setup positions after the toolpaths have been generated, and the objective was to determine the optimal setup position of a workpiece with minimal axial movements to reduce the machining time. We derived the kinematic transform for each type of five-axis machines, and then, defined an optimization problem that described the relationship between the workpiece setup position and the pseudo-distance of the axial movements. Eventually, an optimization algorithm was proposed to search for the optimal workpiece setup position within the machinable domain, which is already concerned with over-traveling and machine interference problems. In the end, we verified the optimal results with a case study with a channel feature, which was real cutting on a table-table type five-axis machine. The results show that we can save the axial movements up to 16.76% and the machining time up to 10.70% by setting up the part at the optimal position.
Keywords
Introduction
Background
In general, a five-axis machine is constructed with three linear axes and two rotary axes, with which the cutting tool can be tilted to cut free-form surfaces and avoid collision between the tool and the workpiece. In addition, the workpiece can be fabricated within minimum setup times, which can effectively reduce machining time including the time for planning multiple setups and making customized fixtures. Although the five-axis machining has the advantages mentioned above, it still requires operators to make many decisions, such as tool selection, tool orientation, and setup position, which may affect the machining efficiency.
Usually, engineers could directly generate the five-axis toolpaths for a part using CAM software. The toolpaths represent the tooltip position and the tool orientation, based on the workpiece coordinate system (WCS). Nevertheless, the machine only recognizes the position relative to the machine coordinate system (MCS). Thus, a transformation between the WCS and the MCS is necessary. During the process, the tool trajectory is complex due to the motion caused by the two rotary movements. Moreover, due to the varying distance between the tooltip position and the rotary center, different setup positions can cause different tool trajectories in MCS. In other words, machining efficiency can be improved by optimizing the setup position of a workpiece. Until now, the decision for a setup position still depends on the operator’s experience. The experience cannot guarantee that the two major issues will not occur: one is the collision between the tool assembly and the machine components, and the other is over-traveling occurring on the linear axes. Additionally, little research on the relationship between the setup position and the machining efficiency has been made.
Literature review
In general, cutter location (CL) data is used to describe the toolpaths. The CL data have to be transformed to the NC code, which is based on the MCS, so that the machine can move accordingly. Thus, the kinematic transforms for five-axis machine structures are needed. Five-axis machine are commonly categorized into three types: head-head, head-table, and table-table, based on the location of the two rotary axes. Many researchers have studied kinematics of the machines using the homogeneous coordinate transformation matrices in Denavit-Hartenberg notation. 1 Lee and She 2 derived kinematics for a head-head type, a head-table type, and a table-table type. Jung et al. 3 developed a postprocessor for a table-table five-axis machine tool with A and C axes (TATC), and then proposed an algorithm to prevent interference in certain situations. She and Lee 4 and She and Chang 5 designed a generalized kinematic model, which combines the primary and the secondary rotary axes on both the spindle side and the table side. The generalized kinematic model can be applied to all types of five-axis machine tools. Sørby 6 derived forward and inverse kinematics for five-axis machine tools with non-orthogonal rotary axes B and C on the worktable. Yang and Altintas 7 used the screw theory to develop a generalized forward and inverse kinematic transform method, which models each kinematic element as a revolute joint or prismatic joint. The screw theory method can easily calculate the inverse kinematics with only the point and vector of each joint. Many researchers developed kinematic models containing nonlinear terms due to the involvement of two rotary axes. The nonlinear terms result in variations of distance equation within five-axis machining trajectories. The result of distance equation could be altered in two aspects, as discussed in the following. One is the orientation of the workpiece; the other is the position of the workpiece. However, the two factors are too complicated to be considered at the same time. Some researchers studied the effects of the orientation of a workpiece on planning the toolpath. Lee et al. 8 determined the optimal workpiece orientation by the minimum rotary movement. Hu et al. 9 determined the optimal setup by the largest intersection of the visibility maps. Some researchers studied the position of the workpiece after the toolpath had been defined. Anotaipaiboon et al. 10 studied the optimization problem of the workpiece position to minimize the kinematic errors caused by nonlinear tool trajectory. Tutunea-Fatan and Bhuiya 11 proposed a method to determine the nonlinear errors of the head-head type five-axis machine. Then, they compared the efficiency between the structures with different combinations of rotary axes, and found that the combination with vertical rotational axis tends to move more than with only horizontal rotational axes. Lin et al. 12 focused on the movement errors on a TATC type machine. Then, the optimal workpiece position was found by using particle swarm optimization in the machinable domain to minimize the nonlinear error caused by the rotary movement. The machinable domain was constructed as a cuboid field according to the travel of three linear axes of machine. Xu and Tang 13 considered energy efficiency on the movement of each axis. Then, they proposed an algorithm to find the optimal workpiece setup with minimum energy cost. Shaw and Ou 14 derived a transformation matrix on a TATC type machine to find the minimum movement on the X, Y, and Z axes. Then, he used a generic algorithm to search for the best position for the workpiece in a cuboid domain that formed with a limit of three linear axes. Pessoles et al. 15 defined the pseudo-distance as a sum of the maximum movement for the three linear axes along the toolpaths. He discretized the possible domain of a workpiece setup position, and then he computed the pseudo-distances for all the setup positions. Eventually, the optimal workpiece setup position was determined by finding the minimum pseudo-distance.
Objective
The research above studied about the machining distance of table-table type machines with AC type and BC type configurations. Nevertheless, the relationship between the workpiece position and the machining time is still unknown for different types of five-axis machines. The machining time is a complicated issue affected by system performance, including toolpath trajectory complexity, acceleration planning, and motor response. To simplify the problem, we considered the axial movement distance as a measure of the machining time and ignored all the other factors that may affect the machining time. In addition, over-traveling and interference problems between the tool assembly and the machine components have not been considered yet. In other words, the workpiece may not be completed due to over-traveling or interference problems. Therefore, the objective of this research was to determine the optimal setup position of a workpiece with minimal axial movements on a tool trajectory in a machinable domain, where the workpiece can be machined with one setup without problems including over-traveling of each axis or interference between the tool assembly and the machine components.
Statement of the optimization problem
Kinematics of a five-axis machine 16
In this section, we only derived the kinematic transform of A and C rotary axes for each type of the machines. Likewise, the machine with different rotary axes can be derived. To derive the kinematic model for each type of five-axis machine, we have to use six coordinate systems: WCS (OWXYZ) and MCS (OMXYZ) and the other four are defined as follows.
The coordinate system at the fourth rotary center (O4XYZ), which is the center of the primary rotary axis.
The coordinate system at the fifth rotary center (O5XYZ), which is the center of the second rotary axis.
The spindle-nose coordinate system (SCS, OSXYZ), which is located at the center of the spindle-nose.
The tool coordinate system (TCS, OTXYZ), which is located at the controlled cutting point on the tool. The cutting point can be either the tooltip or the tool center.
The relationship between the six coordinate systems in a TATC type, which means the fourth axis is an A axis, and the fifth axis is a C axis on a table-table type five-axis machine, can be illustrated in Figure 1. As shown in the figure,

(a) Coordinate systems defined on the table-table type five-axis machine and (b) their relationship.
The CL data can be transformed from OWXYZ to OMXYZ in five steps. The overall transformation matrix on the table side can be obtained through the five steps described below:
Translate from OWXYZ to O5XYZ with vector
Rotate an angle
Translate from O5XYZ to O4XYZ with vector
Rotate an angle
Translate from O4XYZ to OMXYZ with vector
We define
(1) TATC type
Similarly, the relationship between each coordinate system of the head-table type and head-head type, or the HATC type and the HCHA type, five-axis machine can be illustrated in Figures 2 and 3, respectively. The transformation of these two types of machines can be derived by using the kinematic chain loop as well. The transformation matrices are defined as equations (3) to (6).
(2) HATC type
(3) HCHA type

(a) Coordinate systems defined on the head-table type five-axis machine and (b) their relationship.

(a) Coordinate systems defined on the head-head type five-axis machine and (b) their relationship.
Define the optimization problem of the workpiece position with axial movements
The five-axis toolpath generated in CAM software usually consists of small linear segments. To keep the tooltip on the toolpath, we need to obtain the transformation matrices derived in section 2.1. As shown in Figure 4(a), the toolpath is a linear path in OWXYZ (solid line). The linear path can be divided into small segments by time interpolation, and then, the position of each segment can be transformed into OMXYZ to form the true trajectory in Figure 4(b) (dotted line) as a nonlinear movement. The started position and ended position of the nonlinear movement are shown in Figure 4(b) and (c), respectively. Here, the nonlinear movement caused by rotary axes would introduce nonlinear terms in the kinematic transform.

Calculating from a five-axis toolpath in OWXYZ (solid line) to a true trajectory in OMXYZ (dotted line): (a) Original workpiece setup position with five-axis toolpath, (b) tool started position in the true trajectory, (c) tool ended position in the true trajectory, (d) new workpiece setup position OW1XYZ with offset
As shown in Figure 4(d), we define an offset vector
Because the linear and rotary movements in a single NC block would be completed simultaneously, we used the pseudo-distance instead of the linear distance to represent the total axial movements. Typically, the total pseudo-distance,
17
which will be called distance in the following, of the axial movements is determined as the root sum square of the movement in each axis, as shown in equation (7), in which
To find the pseudo-distance, first, we derived the 4 4 homogeneous transformation matrix
We can define an offset vector
Because the fourth element of homogeneous coordinate is used for homogeneous transformation only, we can reduce the vector
Here we defined
In addition, we defined
As shown in equation (17), it is well-known that the Euclidean distance is a convex function.
18
In other words, the equation is a typical convex function, we called the distance function
Since the rotary movements stay the same within the transformation from OWXYZ to OMXYZ, the terms
Then we can redefine the distance function of segment i,
The vector
where
The distance function now is
which maps the distance function
The equation shows that the function
The objective function,
Then,
where
Next, we proposed an algorithm to search the optimal result within the constraint region of the machinable domain. 19
Method to determine the optimal setup position
The objective function has been proven as a convex function, which means that the local minimum is the same as the global minimum in a dexel. Hence, we can use the gradient descent method to search for the minimum in the machinable domain for each dexel. 20 The machinable domain is the collection of all possible setup position without having problems including over travel limits of any linear axis and collision between the tool assembly and the machine components. However, the machinable domain is too complicated so that practically it can be described in discretized dexel, which is pixels on the XY plane with depth information in the Z-axis, as shown in Figure 5.

Represent domain with discretized dexels. Each dexel has one local minimum (blue layer), then compare and select the minimal value as a global minimum in the domain (red layer).
To ensure that the global minimum is selected within the machinable domain, we need to check each local minimum to obtain the global minimum. The local minimum is the minimum in each dexel. Nevertheless, there might exist certain minimal values that are the same as the global minimum. Thus, we proposed another criterion to select the global minimum from the same minimum values at different positions. The criterion is to choose the position closest to the center of the worktable in order to meet the common setting in industry. Eventually, the optimal workpiece setup position with the shortest distance of the axial movements can be obtained.
As a result of optimization,
Experimental environment and setup
Experimental environment
In this research, the toolpaths would be planned in NX software (Siemens, Germany) and then simulated on a TATC machine (Model Number UX300, Quaser, Taiwan), as shown in Figure 6(a), which is equipped with a Heidenhain iTNC530 controller. The specifications of the machine, including the travel limit (Table 1) and the offset data of the coordinate system (Table 2), were applied to calculate the optimal workpiece setup position. The offset data from O5XYZ to OwXYZ was set to zero because we coincided these two points with the setup setting on machine. The dimensions of the five-axis machine

(a) Quaser UX300 five-axis machine with a Heidenhain controller. (b) Measuring the machine kinematics by a Heidenhain probe TS740 and a calibration sphere KKH100.
Quaser UX300 axis limits.
Offset data measured from the machine.
Example of optimization program process
In this section, we would use a simple example to demonstrate the process of optimization. The example is a linear cutting toolpath. The CL data are shown as follows,
FEDRAT/MMPM, 1000.0000
GOTO/0.000, 0.000, 0.000, 0.000, 0.000
GOTO/10.000, 20.000, 30.000, –40.000, 50.000
The start position
The first step was to divide the toolpath into small segments with the interpolation time of the controller
Then we can extract the first segment of the cutting path by using
With the interpolation ratio
Next, we focused on the interpolation segment between position A
With the elements in the transformation matrices, we can use equation (17) to obtain the distance function of segment one as
Then we can derive the gradient of the distance function of segment one as the partial derivative of the distance function with respect to
With the numerical gradient

(a) Workpiece machinable domain results of the linear toolpath in the example. (b) Machining distance value versus Z offset value at position X = 0 and Y = 0. (c) Contour plots of axial movements on the XY plane at Z = 4. “x” shows the optimal setup offset.
Case study
A cuboid with a curved channel was used to demonstrate our study, as shown in Figure 8(a). The channel is altered from 30 mm to 28 mm in diameter along a spline curve. It can be machined from both sides at one-time setup on a five-axis machine tool. The origin of the workpiece was at the center of the bottom surface, which is coincided with the center of the worktable, as shown in Figure 8(b). The toolpath was planned to finish the channel from both sides with a 80 mm long, 10 mm in diameter ball-milling tool. The total length of the tool assembly is 230 mm, as shown in Figure 9.

(a) Channel from 30 mm to 28 mm in diameter along a spline curve. (b) Initial workpiece setup on machine.

Toolpath for the channel: (a) left-side; (b) right-side.
According to the workpiece’s machinable domain, it was found that the workpiece must be raised 123 mm along the Z-axis from the orginial workpiece setup position, so that the workpiece is machinable. Figure 10 shows a contour plot of the total axial movements distance. The figure shows that the original setup position, the black “o” at (0, 0, 0), is not machinable. Within the constraint of the machinable domain, the modified setup position, the blue “o” at (0, 0, 123), gives the distance of 64653 units. However, we can find an optimal setup position, the orange “o” at (0, 90, 65), to reduce the distance. The global minimum of optimal setup position at (0, 90, 65) gives the shortest distance of 53,816 units.

Contour plot of axial movements results on the section (a) YZ plane at X0, and (b) XY plane at Z65. The boundaries of the cross section of the machinable domain are the black lines. The black “o” refers to the origin setup position, the blue “o” refers to the modified setup position and the orange “o” refers to the optimal setup position.
Three parts with three different setup positions listed in Table 3 were machined, as illustrated in Figure 11. Because the part put at (0, 0, 0) is not machinable, we move the part to the modified setup position (0, 0, 123) to make it machinable, and the total axial movements was calculated as 64,653 units as listed in Table 3. The real machining time was 561 s. Then we set the part at the optimal setup position, and the total axial movements was calculated as 53,816 units, which was 16.76% less than the those for the part put at the modified setup position. The machining time was 501 s, which was 10.70% less than that for the part put at the modified setup position. Because the total axial movements were very complicated, the reduction in distance was not very consistent with that in machining time. Based on the results, it is demonstrated that the algorithm proposed can find the optimum setup position to reduce the machining time effectively.
Calculated and real machining results of the channel.

(a) The real cutting process and (b) the section view of the channel.
Conclusion
In this paper, we derived the kinematics for each type of five-axis machine tools. Then, we used the general transformation matrix to derive the optimization equation and the gradient descent method to find the global minimum. A case is presented to verify the proposed method and the total axial movements were reduced by 16.76%, and the machining time was reduced by 10.70% if we set up the workpiece at the optimal position. The proposed method can substantially reduce the machining time for the five-axis machining, which is practically important to the machining industry.
Footnotes
Appendix
Acknowledgements
The authors wish to thank the Ministry of Science and Technology, Republic of China, for financial support of this research.
Handling Editor: James Baldwin
Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: Ministry of Science and Technology, Republic of China, under Grant MOST 105-2221-E-011-055.
