Tuning of Servo Control Gains for Five-Axis CNC Machine Tools Considering Circularity of Inclined Circular Motions in Workspace

To improve both production quality and capacity, CNC machine tools must have high-accuracy and high-speed machining abilities regarding manufacture of mechanical parts. However, CNC machine tool operators experience difficulty in handling the complicated settings of control parameters, which are usually enabled in advanced servomotor drivers. Therefore, a tuning method is developed in this study to determine the best-fitting control gains for a five-axis CNC machine tool using the measurement data acquired during tests of inclined circular motions in the workspace. Rates of improvement higher than 80% were achieved after using the proposed method to tune the control gains of each motion axis.


Introduction
There is an increasing need to manufacture complex mechanical parts, which requires high levels of precision. Five-axis CNC machine tools with three linear and two rotary axes are rapidly becoming a popular solution for this issue. Generally, five-axis CNC machine tools are equipped with drivers for each motor. These drivers' actions usually depend upon the configuration of several parameters which contain information about the stiffness of the machine, input commands, and control gains for the velocity and position of the servomotors. Despite the availability of tuning guides for different applications, tuning control gains in a five-axis CNC machine tool to enhance its motion performance is still a highly difficult task. Although there are many approaches to analyze and evaluate a five-axis CNC machine tool's motion performance [1] , a lot of time and resources are usually expended in performing the tests for tuning servo control gains of these tools. A tuning method is therefore developed in this study considering the circularity of the inclined circular motions in the workspace of a five-axis CNC machine tool.
In recent years, many studies have focused not only on understanding the influence of motion errors on geometric imperfections when using five-axis CNC machine tools, but also on how to enhance the motion accuracy. Lin et al. [2] developed a virtual machine tool simulation system that considers the servo dynamics of feed drive systems and the tool center point interpolation algorithm of a five-axis machine tool. Geometric errors and component locations were also considered in the developed simulation system; thus, possible error sources during the operations of a real five-axis machine tool could be identified. Because vibration suppression is critical for achieving high-speed and high-precision machining results, Tsai et al. [3] built a detailed dynamic model to represent the dynamics of a feed drive system with closed-loop servo control. Then, an input shaping method with zero vibration was developed to suppress the vibrations of the feed drive system. Zhang and Wu [4] developed an identification method to precisely identify the model of a multi-axis servo drive system using a support vector machine, with the structure parameters optimized by an immune particle swarm optimization algorithm. Hong et al. [5] showed that there are position-independent and position-dependent errors; however, finding these errors is challenging and could be cumbersome, as some of the errors are dependent on others. If these errors are not identified correctly, the precision and accuracy of the machine tool could be further reduced. Lei et al. [6] presented total ball bar dynamic tests, which could be used to inspect and improve dynamic errors of five-axis CNC machine tools, particularly the errors resulting from the gain mismatch. Tsutsumi et al. [7] showed that there are major differences in the clockwise and counterclockwise directions when the tool center path is tracing a circle equivalent to cone-frustum cutting. A significant improvement in roundness cannot be expected because of mechanism errors such as the backlash and pitch errors of the axes of rotation, which cannot be corrected even if the geometric deviations are corrected. Sato et al. [8] showed that tool vibration, vibration of the mechanical structure, the motion error of the feed drive systems, and other factors influence the machined surface. Kato et al. [9] defined a sensitivity coefficient of measurement which is the ratio of the measurement value to the actual error. Moreover, this study uses this sensitivity coefficient of measurement and demonstrates how the influence on the direction of the ball bar (perpendicular or parallel) affects motion error detection in a cone frustum. A different strategy to enhance the accuracy and precision of a five-axis CNC machine tool entails tuning the control gains within the current, velocity and position loops of the servomotors used on the CNC machine tools. Suzuki et al. [10] proposed a method for solving the shape error of machined working pieces considering the relative angle difference between linear and rotary axes. Lin and Wu [11,12] developed a contour error model on five-axis measuring paths during synchronous motions. Trajectory planning and several tests were conducted to investigate how contour charts of the tool center point were affected by the dynamic gains of the five-axis servo loops. Sato and Tsutsumi [13] proposed a servo gain tuning, feed forward controller design, signal delay and backlash compensator, rotational fluctuation compensator, and jerk limited acceleration process design so that an enhancement on the dynamic synchronous accuracy between translational and rotary axes in five-axis machining centers could be achieved. Sato and Tsutsumi [14] also described the dynamic synchronous accuracy of translational and rotary axes in five-axis CNC machine tools. Furthermore, a dynamic model for each motion axis was developed, and synchronous motions were simulated. Kuo and Yen [15] proposed a method for tuning the position servo gains, feedforward gains, dynamic response time constants, and the friction compensation time constants within the speed control loop of the servomotors of a five-axis CNC machine tool using an improved genetic algorithm, so that the contouring accuracy could be optimized.
All the aforementioned studies were performed following the specifications of a defined standard to assess a machine tool's performance; otherwise, there would be no guarantee that an enhancement was achieved whatsoever. It could be seen that further study is required for five-axis CNC machine tool contouring enhancement. Therefore, the objective of this study is to produce a tuning method which enhances the circularity value of the three-dimensional inclined circular motion in a five-axis CNC machine tool. In comparison with the existing approach [16,17] , our approach details on the calculation of the circularity value of a three-dimensional circular contour and presents a systematic control gain tuning procedure, based on the observations and analyses of simulations.

Experimental Setup
The proposed method was developed based on a five-axis CNC demo kit which was developed by the Industrial Technology Research Institute (ITRI) for control technology development of five-axis CNC machine tools. As shown in Fig. 1, this demo kit emulated the performance and behavior of real five-axis CNC machine tool controllers. Additionally, several parameters on the controller of the demo kit could be adjusted so that it could accurately simulate behavior on the real CNC machine tool controller. Once all of the parameters which emulate the behavior of the real five-axis CNC machine tool were set correctly, the demo kit could accurately predict results on a five-axis CNC machine tool. Therefore, the demo kit allowed users to see trends and offered results with an acceptable precision with respect to the ones from the real five-axis CNC machine tool. The study works were performed using a demo kit which included six AC servomotors with a rated rotational speed of 3000 rpm [18] . The servomotors were controlled using six AC servo drivers with velocity, position, torque and full-closed control.
The tests in this study were performed using a numeric control file (NC file) containing the G-code information required for three-dimensional circular motions.

Calculation of Circularity
When a three-dimensional inclined circular motion is performed by the five-axis CNC demo kit, the measurements of the encoder can be used to obtain the spatial positions that emulate the motions of the tool center point in a five-axis CNC machine tools. Hence, these coordinates can be used for calculating the circularity of the three-dimensional circle. However, some errors might exist during the measurements, resulting in erroneous points which may severely affect the circularity value. This is the reason that this study proposes filtering these points according to a degree of belonging which is based on the standard deviation concept before calculating the circularity.
As is known, the standard deviation is a measure that is used to quantify the amount of variation or dispersion of a set of data values. It is known that only 0.2% of the data is farther than  3 from the mean value of a certain measurement parameter of a set. The points on a given data set can be filtered by using a certain measurement degree, so that the principle of standard deviation can be applied. Since the set points contain information on spatial coordinates X, Y and Z, the challenge is to find a suitable measurement parameter, so that points which do not contribute useful information for the calculation of the circularity can be effectively removed from the original dataset. Even though the motion of each axis of a five-axis CNC machine tool is complex, the movement of the tool center point (TCP) is a three-dimensional circle which might be rotated in space or be parallel to a given plane. Hence, it can be said that the circle is located on a plane for which an equation can be calculated using the points of the data set. Eq. (1) represents a plane in space. Since the coordinates of the points are known, constants a, b, c and d can be estimated by using coordinates x, y and z for each point in the data set: (1) Once the parameters of the plane's equation are estimated, a belonging degree can be defined. This belonging degree is based on the fact that the right side of the plane's equation ought to be zero. Therefore, if a point in space is passed through the plane's equation, the response should be very close to zero, which entails that this point belongs to this plane; but if the belonging degree is away from zero, it means that this point does not belong to a plane. In this case, the standard deviation approach can be used. Eq. (2) shows this belonging degree. The standard deviation can be used by setting zero as the mean of the belonging degree and filtering the points where the belonging degree is farther from   3 . The points outside the boundaries can be disregarded without having severe effects on the calculations of the remaining data.
(2) Once a strategy has been developed, in order to calculate the center of a circle in space which crosses three specified points, it is necessary to develop a new procedure to calculate the center of the coordinates of a circle which is supposed to cross several points in space. Evidently, this procedure should include choosing points in groups of three and calculating their centers of coordinates. Theoretically, if all of the points belong to a circle, all of the resulting centers of coordinates should be located on the same coordinates. However, due to small position deviations, this is not the case. After the points have been filtered, the proposed algorithm chooses a group of three points each time in such a way that each one of the points has the same separation with respect to the others. Ideally the angular separation would be 120 degrees. Fig. 2(a) illustrates how the points are chosen. In the first iteration the points labeled in red and 1 are used to find the center coordinates. In the second iteration, the points labeled with 2 are chosen and the procedure is repeated. The third iteration chooses the points labeled with the number 3 and this procedure is performed until all of the points have been taken into consideration without being repeated. After all of the points have been taken into consideration, due to small position deviations, there will be many possible centers for the circle being discussed. This can be clearly seen in Fig. 2(b).
The next step focuses on using the information from all the elicited centers and choosing the optimal one. The standard deviation principle is applied to each one of the coordinates of the centers. This means that the mean value for the X, Y and Z coordinates is calculated independently, and if a center has a coordinate in X, Y or Z which does not satisfy the condition that it must be within the range [ 3σ − , 3σ ], then, this coordinate is not used. Nevertheless, the coordinates are managed independently, which means that if the X coordinate of a point is not used for the calculation of the X coordinate of the optimal center, its Y or Z coordinates might still be used if they satisfy the principle of standard deviation. Once the necessary coordinates for calculating the optimal center have been chosen, the algorithm finds the average of all the X coordinates, Y coordinates and Z coordinates independently and the resulting values are the coordinates of the optimal center, which is the center of the three-dimensional circle rotated or not in space.
(a) Point selection and arrangement (b) Calculated centers Fig. 2. Points used in each iteration and the calculated centers.
After the center of the three-dimensional circle has been calculated, the measurement of its circularity has to be calculated. This is a relatively easy and straightforward procedure, as it entails knowing both the farthest and closest points from the center. Since the circle is located in a Euclidean three-dimensional space, the easiest way to find the coordinates of these two points is by calculating all of the distances from the center of the circle to each one of the points located on its circumference. Once the farthest and closest distances have been calculated, then the circularity value results can be found from a simple subtraction between them. Ideally, if all of the points are located on the circumference of a perfect three-dimensional circle, the circularity value should be zero. However, in many cases, this is not the case, even though the circularity value is very small. Therefore, it must be measured using lower scale units such as m  . To ensure that the circularity value obtained using the algorithm for calculating the circularity works very well and can accurately calculate the circularity value of a set of points, whether they are along an orthogonal plane or on a tilted plane in space, several tests were performed using different point sets. Three workpieces were manufactured in advance, according to ISO standard 10791-7, and then used to generate nine data sets. Here, three data sets per workpiece were generated from the upper, medium, and lower circles of the workpiece. These point sets were obtained from the CGM's circularity measurement reports. The measurements were made using a coordinate measuring machine (CMM). Their results were compared with the ones calculated by the proposed algorithm after using the same data point sets. Table 1 shows the results obtained after testing the algorithm on nine different sets of points. It can be seen that the results from the proposed algorithm have a very high accuracy. The highest error is 1.1 um. In most cases the error is below 0.5 um and in the case of sets 1 and 6, there are no errors whatsoever. From the results, it can be concluded that the algorithm works very well for calculating the circularity value from a set of points in space when the X, Y and Z coordinates are known.

Simulation and Experimental Studies
In order to simulate the whole system, it is important to sum up how it actually works. Fig. 3(a) shows the block diagram to illustrate this. It starts with a pulse command to each one of the AC servomotors. Since the mathematical models we have been using do not consider pulse inputs and outputs but rather position, we first need to transform the pulse commands into position commands (mm for the linear axes and degrees for the rotary axes). The transfer functions of each of the five axes have already been obtained, so we can simulate the output behavior of each axis. This input data to each one of the transfer functions consists of position commands which are to be sent to the AC servomotors.
(a) Block diagram of the whole system in this study (b) Simulation result Fig. 3. Block diagram of the simulation system and the corresponding result.
It is known that the sampling time of the real controller is 1 ms. Therefore, each set of data was taken as a sample considering the just-described sampling time. If the number of commands to the AC motors is known, then it is easy to find the overall amount of time for the simulation. We may consider all the input data for each AC servomotor as a vector with a length equal to the number of commands, where each command is set at a sampling time of 1 ms. Then, by some simulation commands from MATLAB, we can find the response of the system to the input commands, as shown in Fig. 4. As can be seen in the block diagram, the next step is to use the response values for each of the simulated axes as inputs to the forward kinematic model of the five-axis CNC machine tool. This study employed a general BC-type five-axis machine tool kinematic model for simulations [5] . By doing this, we can discover the spatial position of the machining tool corresponding to each response to the AC motors. Next, we store this data and calculate the circularity value of the resulting points in the overall simulation, as the example shown in Fig. 3(b). After performing the simulation of the whole system, we can obtain some valuable data about its overall behavior depending on the values of the position and velocity loop gains for each one of the five axes. We can see that when the gain values are set too low, the resulting positions for the tool, with respect to the commanded ones, are unacceptable and thus, the circularity values are not good at all. Because the value of the circularity is affected by the control gain values of each one of the five axes, several tests are conducted so that we can start observing traits of behavior by changing the gains.  Fig. 5 shows how the frequency affects the phase behavior of the velocity loop. It is easy to see that the greater the frequency, the faster the phase diagram leads to a lower value; furthermore, it is clear that the behaviors of the phase depend on both the time integration constant and the frequency values. The greater the frequency, the lower the value of the phase of the velocity loop response. Regarding the magnitude response, Fig. 6 illustrates the behavior of the magnitude values depending on the Ti values and the velocity loop gain in Hz (units from the AC motor driver manual). Fig. 6 has been formed by setting a constant frequency to clearly understand the relationship between Kvp and Ti regarding magnitude values. From Fig. 6, we see that the greater the Kvp value; the higher the magnitude in dB. However, the greater the Ti value; the smaller the magnitude becomes.
Based on the observations from circularity and frequency responses, we can see some traits and patterns and therefore, we can elaborate on a procedure for tuning the control gains of both velocity and position loops. Since the velocity loop phase response is independent of the value of the velocity loop gain, the first step is to use the phase diagram as a reference for tuning the Ti. Then, we adjust the Kvp in order to enhance the magnitude diagram of the velocity loop. Finally, we can tune the Kpp to adjust the position loop. The overall procedure can be summarized in the following steps: Step 1. Gather the frequency response of the five axes of the DEMO KIT under the same input signals.
Step 2. Choose a referential linear and rotary axis so that its phase values are the minimum among the chosen range of frequency. Step 3. Tune the time integration constants Ti from the remaining linear axes so that the phase diagram approaches the diagram of the chosen axis to achieve matched phase responses. Repeat the procedure for the rotary axes.
Step 4. Tune the velocity loop gain of the five axes so that the magnitude diagrams are very similar between the linear axes and between the rotary axes to achieve matched magnitude responses (there might be differences between the linear and rotary axes' responses).
Step 5. Tune the position loop gains of the five axes so that their position's magnitude responses are very similar to achieve matched frequency responses.
Step 6. Test the circularity value by using the proposed algorithm.

Experimental Results
The tests were divided into two groups, namely Test 1 and Test 2, to verify that the proposed method can reduce the circularity of the circular tool's central path. From the results of the simulation studies, the position loop gains significantly affected the circularity value in comparison with the velocity loop control gains. This section, therefore, focuses on tuning the position loop gains (by Step 5 and Step 6), based on the well-tuned velocity loop control gains (by Step 1 to Step 4), to clarify the influence of the position loop gains on the circularity value. Table 2 shows the chosen position loop gains for Test 1. These gains were established to achieve a relatively fast response on each motion axis, without high oscillations and with relatively small overshoots. Table 2 also shows the resulting circularity from the demo kit. The circularity value was reduced by 65.90%. It can be seen that the improvement rate of the circularity value after tuning the position loop gains is relatively large. This means that the proposed method worked very well with the initial position loop gains proposed in Test 1.
The results from Test 2 have been summarized in Table 3. The initial position loop gains were arranged so that the time domain responses were sufficiently fast. However, their values were lower than the ones from Test 1. Hence, no overshoots were expected on the motion axes' time domain responses. The results of Test 2 show that the circularity value was reduced by 82.54%, after tuning the initial position loop gains. This also shows the potential of the proposed method.
Clearly, the best circularity result was achieved in Test 1, with the best circularity value and the smallest rate of improvement, in comparison with the circularity results obtained in Test 2. This was because the position loop gains were sufficiently, but not excessively, high; thus, each motion axis could have a very fast response. After the tuning procedure, the improvement in the circularity value was, thus, limited. However, for the circularity results achieved by Test 2, each motion axis demonstrates a slower response with smaller gains. The improvement in the circularity value could be, thus, significantly reduced after the tuning procedure.

Conclusions
A control gain tuning method was developed to enhance the circularity value of three-dimensional inclined circular motion in a five-axis CNC machine tool. An essential step for the proposed method was analyzing the effects of the control gains on the circularity, and the effects of the frequency responses of the control loops of the five motion axes. Three control gains were considered in this study: the position loop gain, velocity loop gain, and the time integration constant of the velocity loop. Once the influence of the control gains was known, a suitable frequency response for each motion axis could be chosen; then, the respective control gains could be tuned. In this study, an actual reduction in the real circularity values was achieved. After testing the proposed method on a demo kit with multiple rotary axes driven by AC servomotors, it could be seen that the circularity was improved, and the improvement rates ranged from 65% to 82%.