1 Introduction

Computer numerical control (CNC) machine tools are mainly used to upgrade machining quality and shorten machining time. In particular, CNC machine tools are often used to achieve high-speed and high-accuracy corner machining in workpieces. Workpiece corner machining refers to the fact that the motion axes of the CNC machine tool change their movement directions to perform cornering motions. Although high-speed machining typically shortens the cornering time, it also decreases cornering accuracy in practice. Therefore, cornering control design is an important consideration in the motion control of a CNC machine tool.

The motion axis of a CNC machine tool is mainly composed of a permanent-magnet synchronous motor (PMSM), ball screw, and moving table. Therefore, the driving control of the PMSM has a significant influence on the cornering motions of the CNC machine tool. Unlike the existing cornering motion control methods, the present study considers the following actuation and motion properties of the motion axis:

  • A moving table is typically installed with a heavy workpiece (in milling machines) or is equipped with a heavy-duty turret (in lathes), and the motion axis should therefore be modeled as a two-mass mechanical system in practice.

  • The inherent hardware structures of commercial PMSM drivers typically limit their computational performances as well as the number of registers used to store data during computations, so the control design should be simple and easy to implement in practical applications.

  • Since the proportional (P)–proportional integral (PI) (P–PI) control structure is extensively used in commercial PMSM drivers, control parameter design and adjustment based on the P–PI control structure can be applied directly to these drivers.

Therefore, the motion axis is modeled as a two-mass mechanical system in this study, and based on the P–PI control structure, the control parameters are designed and adjusted to improve the cornering accuracy of the CNC machine tool.

The remainder of this paper is organized as follows. Section 2 presents some relevant research related to this study. Section 3 presents details of the preliminary work, such as the motion axis modeling, P–PI control structure, cornering error definition, and particle swarm optimization (PSO). Section 4 discusses the approaches developed in this study for the design and adjustment of the P–PI control parameters, such as derivation of a two-mass equivalent system, design of the velocity control parameters, and adjustment of the position control parameter. Section 5 describes the results of the experiments performed on a CNC lathe for validating the developed approaches. Section 6 presents the conclusions of this study.

2 Related research

Given the importance of cornering motions in CNC machine tools, many cornering control methods have been proposed in recent years, such as blending curve path design, motion trajectory filter design, and cornering motion control design. Blending curve path design has been extensively studied and is mainly used for corner path planning and spline blending to smooth the cornering motions and provide stable corner machining. For instance, many transition schemes have been developed with specific curves to address the problem of corner path discontinuity; however, the smoothness of the transition curves still affects the corner machining qualities of CNC machine tools. Therefore, considering the mixed-path C3-continuity, smoothing error, and transition curve shape control, a C3-continuous non-uniform rational B-spline transition scheme was developed to smooth the transition curve of a corner path by determining the control point weights using an oscillating circle method [1]. An improved G3-continuous path smoothing method with kinematic constraints as well as confined transition and chord errors has been developed to reduce cornering errors and improve the corner machining efficiency and quality of a CNC machine tool through embedded Bezier transition splines at the corners and optimized maximum feed rates along the splines [2]. Because the cornering motions of CNC machine tools are influenced by the transient splines and corner speeds, a PSO with axial kinematic constraints was applied to determine a smooth corner path combined with the optimal Bézier transient spline and optimal corner speed [3].

Motion trajectory filter design mainly uses trajectory generation, interpolation, and filtering methods to improve cornering motions and avoid tool vibrations. For instance, to improve the accuracy and efficiency of CNC machining through trajectory generation and interpolation, a double-filter-design-based corner smoothing method was developed to smooth cornering motions with confined acceleration, jerk, and cornering errors by determining the appropriate filter order and corner speed [4]. A finite impulse response (FIR)-filter-based trajectory generation and interpolation algorithm that constrains the maximum feed rate of the linear tool motion was developed to avoid tool vibrations at sharp corners and to constrain the cornering errors within a given tolerance value. This was achieved by changing the overlap time of the filtered rectangular velocity-pulse signals [5]. To mitigate the problem of tool vibration and feed rate fluctuation induced by discontinuities in the linear tool path, an input-shaping-based corner rounding algorithm comprising position deviation regulation and distortion compensation modules was developed to smooth cornering motions with minimal position deviations and distortions [6]. Blending curve path and motion trajectory filter designs mainly use path blending and filtering methods to improve the cornering motions in CNC machine tools. Specifically, due to the rigidity of the machine tool structure, blending curve path and motion trajectory filter designs have been extensively applied to five-axis CNC machine tools [7, 8].

Similar to the blending curve path and motion trajectory filter designs, other designs have been proposed to smooth cornering motions. For instance, smoothed interpolation points around the corners can be obtained by transforming the original interpolation points on the linear paths to smooth cornering motions in the absence of specific requirements [9]. A corner smoothing method with low harmonic trajectory generation has been developed to avoid vibrations induced by the high harmonic components in transition curves [10]. An optimization method combined with a back-propagation neural network and genetic algorithm has also been reported to optimize the interpolation parameters while avoiding corner vibrations [11]. A reinforcement learning neural network was proposed to generate servo commands in real time so that the trajectory smoothing method can be used to smooth cornering trajectories and improve cutting efficiencies [12]. A corner smoothing method with an asymmetric transition profile and near time-optimal transition parameters was developed to reduce cornering time and improve cornering accuracy [13]. The cornering motion parameters can be systematically adjusted to balance cornering errors and cornering velocities through the analysis of the power spectral densities of accelerometer signals measured during cornering motions [14]. An S-curve velocity planning algorithm with PSO was developed to generate smooth and fast cornering motions for contouring tool paths composed of line segments in a CNC machine tool [15]. A kinematic corner smoothing technique that accurately calculates the cornering speed and duration was developed to achieve continuous feed motions in the sharp corners of a tool path [16]. The aforementioned designs can smooth cornering motions and improve cornering performances in CNC machine tools; however, because the motion axis dynamics still affect the cornering motions significantly, these existing methods do not address the problem of cornering errors induced by the motion axis dynamics. Therefore, methods related to cornering motion control design have also been proposed in recent decades.

Cross-coupled control designs had been initially proposed to deal with the cornering error problems considering the coupling dynamic characteristics of a biaxial motion control system from the contouring control point of view [17, 18]. Subsequently, Chen and Tsutsumi [19] applied the inverse compensation principle and developed an inverse compensation technique to reduce the corner-tracking errors in a machining center without precisely modeling its feed drive systems. Yamazaki et al. [20] developed a multi-axis control system that integrates a feedforward compensator with a P-control-based feedback compensator to improve the cornering motions of a CNC machine tool using the model matching method. Bearee et al. [21] analyzed the influence of servo parameters and axial dynamics on the contouring accuracy of a biaxial machine tool and derived an analytical contouring error formula for corner crossing motions. Nevertheless, motion control designs to further improve the cornering motion performance by considering motion axis dynamics have been proposed. For instance, considering the acceleration and deceleration of cornering motions, a torque generation and compensation method was developed to address the vibrations induced by changes in high-speed cornering motion directions [22]. By compensating the referenced trajectory and smoothing velocity transitions, an iterative learning contour control combined with contouring error compensation and Bézier repositioning trajectory was developed to reduce the cornering errors [23]. Because trajectory discontinuities and external disturbances significantly influence the contouring results of motion axes, an iterative learning contour control composed of proportional–derivative control and a disturbance observer was designed to improve both the tracking and cornering motion performances [24]. By studying the corner-tracking performance and comparing techniques such as cross-coupled control, zero-phase error tracking control, and real-time frequency-modulated interpolation, a combined control system that can be easily actuated at high frequencies was developed to improve cornering motions [25].

Given that the motion axis of a CNC machine tool should be modeled as a PMSM-driven two-mass mechanical system using the P–PI control structure [26], the available motion control methods can provide good cornering results for PMSM motions but cannot ensure good cornering results of the moving table, thus limiting the cornering accuracy. Moreover, because the motion axis is generally driven by the PMSM with the P–PI control structure, the motion control design must comply with the P–PI control structure in practical applications of CNC machine tools. Further, P–PI control design and adjustment must consider the cornering motions and dynamic characteristics of two-mass mechanical systems for improved cornering accuracies of CNC machine tools. However, few reports discuss such practical issues (i.e., the motion axis of the CNC machine tool should be modeled as a PMSM-driven two-mass mechanical system with P–PI control) with respect to cornering motion control design in CNC machine tools. Therefore, this study focuses on the design and adjustment of P–PI control parameters by considering the cornering motions and dynamic characteristics of the motion axis to improve the cornering accuracy of the CNC machine tool.

In this study, the machine tool motion axis is modeled as a two-mass mechanical system, and the transfer function of the motion axis is derived for further analysis and design. The P–PI control structure used in the PMSM driver has inner and outer loops for velocity and position controls, respectively. Therefore, a system equivalent to the P–PI-controlled two-mass mechanical system is developed, and the proportional and integral control parameters of the inner loop are designed for velocity control based on the equivalent system, thereby enabling PMSM velocity responses with short rise times and small overshoots. Among the optimization algorithms, PSO uses a metaheuristic method to iteratively optimize an objective function but does not require its gradient. Thus, PSO exhibits features, such as being derivative-free, having few algorithm parameters, scale-insensitivity to variables, and efficient global search. Therefore, PSO is simple and powerful and is typically used to search for optimal parameters in complex systems. In this study, with regard to the cornering error definition and motion axis model, the PSO is used to adjust the proportional control parameter of the outer loop for position control, thereby enabling an improved cornering accuracy of the moving table. The motion axis of a CNC lathe is used to demonstrate the proposed P–PI control parameter design and adjustment method and to perform experiments. The experimental results indicate that the average and maximum cornering errors of the moving table on the test path are reduced by 31.11 and 33.76%, respectively, thus demonstrating the feasibility of the developed method.

3 Preliminary works

3.1 Motion axis modeling

The motion axis of a CNC machine tool uses a PMSM to drive the moving table by actuating a ball screw. Because a moving table is practically heavy, referring to the dynamics of the motion axis, the two-mass model was used for modeling the motion axis, as shown in Fig. 1, with the variables presented in Table 1. Here, for building a two-mass model of the motion axis, the motion axis was assumed to be influenced by viscous friction and not by nonlinear frictions and external disturbances. Referring to the motion axis model shown in Fig. 1, the dynamic equations of the motion axis can be derived using Newton’s law of motion as shown in (1).

$$ \left\{ \begin{gathered} J_{m} \ddot{\theta }_{m} + B_{m} \dot{\theta }_{m} + \frac{l}{2\pi }B_{i} \left( {\frac{l}{2\pi }\dot{\theta }_{m} - \dot{x}_{t} } \right) + \frac{l}{2\pi }K_{a} \left( {\frac{l}{2\pi }\theta_{m} - x_{t} } \right) = T_{m} \\ M_{t} \ddot{x}_{t} + B_{L} \dot{x}_{t} - B_{i} \left( {\frac{l}{2\pi }\dot{\theta }_{m} - \dot{x}_{t} } \right) - K_{a} \left( {\frac{l}{2\pi }\theta_{m} - x_{t} } \right) = 0 \\ \end{gathered} \right. $$
(1)
Fig. 1
figure 1

Motion axis model of a CNC machine tool

Table 1 Variables used in the motion axis model

By taking Laplace transform of (1), the matrix Eq. (2) can be obtained by rearranging the transformed equation; furthermore, the Laplace functions, \(\theta_{m} \left( s \right)\) and \(x_{t} \left( s \right)\), can be obtained by solving (3). Here, \(\theta_{m} \left( s \right)\), \(x_{t} \left( s \right)\), and \(T_{m} \left( s \right)\) denote the Laplace functions of the motor rotating angle \(\theta_{m}\), load moving distance \({{x}}_{{{t}}}\), and motor driving torque \({{T}}_{m}\), respectively. Figure 2 shows a block diagram of the two-mass-modeled motion axis.

$$ \left[ {\begin{array}{*{20}c} {J_{m} s^{{2}} + \left( {B_{m} + \left( {\frac{l}{2\pi }} \right)^{{2}} B_{i} } \right) s + \left( {\frac{l}{2\pi }} \right)^{{2}} K_{a} } & { - \frac{l}{2\pi }B_{i} s - \frac{l}{2\pi }K_{a} } \\ { - \frac{l}{2\pi }B_{i} s - \frac{l}{2\pi }K_{a} } & {M_{t} s^{{2}} + \left( {B_{L} + B_{i} } \right) s + K_{a} } \\ \end{array} } \right]\;\left[ {\begin{array}{*{20}c} {\theta_{m} \left( s \right)} \\ {x_{t} \left( s \right)} \\ \end{array} } \right] = \left[ {\begin{array}{*{20}c} {T_{m} \left( s \right)} \\ {0} \\ \end{array} } \right] $$
(2)
$$ \left[ {\begin{array}{*{20}c} {\theta_{m} \left( s \right)} \\ {x_{t} \left( s \right)} \\ \end{array} } \right] = \left[ {\begin{array}{*{20}c} {J_{m} s^{{2}} + \left( {B_{m} + \left( {\frac{l}{2\pi }} \right)^{{2}} B_{i} } \right) s + \left( {\frac{l}{2\pi }} \right)^{{2}} K_{a} } & { - \frac{l}{2\pi }B_{i} s - \frac{l}{2\pi }K_{a} } \\ { - \frac{l}{2\pi }B_{i} s - \frac{l}{2\pi }K_{a} } & {M_{t} s^{{2}} + \left( {B_{L} + B_{i} } \right) s + K_{a} } \\ \end{array} } \right]^{{ - {1}}} \left[ {\begin{array}{*{20}c} {T_{m} \left( s \right)} \\ {0} \\ \end{array} } \right] $$
(3)
Fig. 2
figure 2

Block diagram of the two-mass-modeled motion axis

Because of the Laplace functions of the motor rotating velocity \(\dot{\theta }_{m} \left( s \right) = s \cdot \theta_{m} \left( s \right)\) and load moving velocity \(\dot{x}_{t} \left( s \right) = s \cdot x_{t} \left( s \right)\), the transfer function \({{H}}_{m} \left( {{s}} \right)\) of the motor driving torque \(T_{m} \left( s \right)\) and motor rotating velocity \(\dot{\theta }_{m} \left( s \right)\) and transfer function \({{H}}_{{{L}}} \left( {{s}} \right)\) of \(T_{m} \left( s \right)\) and load moving velocity \(\dot{x}_{t} \left( s \right)\) can be derived from (3), as shown in Eqs. (4), (5), and (6).

$$ H_{m} \left( s \right) = \frac{{\dot{\theta }_{m} \left( s \right)}}{{T_{m} \left( s \right)}} = \frac{{4\pi^{2} \left( {M_{t} s^{2} + \left( {B_{L} + B_{i} } \right)s + K_{a} } \right)}}{\Delta } $$
(4)
$$ H_{L} \left( s \right) = \frac{{\dot{x}_{t} \left( s \right)}}{{T_{m} \left( s \right)}} = \frac{{2\pi l\left( {B_{i} s + K_{a} } \right)}}{\Delta } $$
(5)
$$ \begin{aligned} \Delta & = \left( {4J_{m} M_{t} \pi^{2} } \right) s^{3} \\ + \left( {4B_{m} M_{t} \pi^{2} + 4B_{i} J_{m} \pi^{2} + 4B_{L} J_{m} \pi^{2} + B_{i} M_{t} l_{{}}^{2} } \right) s^{2} \\ + \left( {4K_{a} J_{m} \pi^{2} + 4B_{m} B_{i} \pi^{2} + 4B_{m} B_{L} \pi^{2} + K_{a} M_{t} l_{{}}^{2} + B_{L} B_{i} l_{{}}^{2} } \right) s \\ + \left( {4B_{m} K_{a} \pi^{2} + B_{L} K_{a} l_{{}}^{2} } \right) \\ \end{aligned} $$
(6)

3.2 P–PI control structure

The P–PI control structure shown in Fig. 3 is often used in the driving control of commercial PMSMs. In Fig. 3, \(K_{vp}\) and \(K_{i}\) represent the proportional and integral control parameters of the velocity control, respectively, and \({{K}}_{pp}\) represents the proportional control parameter of the position control. When the PMSM is used to actuate the machine tool motion axis, as shown in Fig. 1, the P–PI control parameters (\(K_{vp}\), \(K_{i}\), and \({{K}}_{pp}\)) should be designed and adjusted to enable rapid and precise motion results of the motion axis. Because the P–PI control structure has inner and outer loops for velocity and position controls, respectively, a design and adjustment method is proposed herein to mitigate the complexity of the P–PI control parameter design, including the derivation of a two-mass equivalent system that features velocity control parameter design and position control parameter adjustment. To ensure that the PMSM velocity responses have short rise times and small overshoots, a two-mass equivalent system is used to design the velocity control parameters (\(K_{vp}\) and \(K_{i}\)) while the PSO is used to adjust the position control parameter (\({{K}}_{pp}\)), thereby ensuring that the cornering motions of the moving table of the CNC machine tool have reduced cornering errors.

Fig. 3
figure 3

Block diagram of the P–PI control structure

3.3 Definition of cornering error

In this study, the cornering error is defined as shown in Fig. 4, where \({{P}}\) is the corner position on the command path, \({{R}}\) and \({\vec{{v}}}\) denote the actual position and tangent vector of the moving table during the cornering motions, respectively, and \(\theta_{{{c}}}\) is the corner angle. Figure 4a shows that when \({{R}}\) and \({\vec{{v}}}\) of the moving table are known, the line \({{L}}\) passing through \({{R}}\), which is parallel to \({\vec{{v}}}\), can be obtained. Thereafter, the shortest distance \({{d}}\) can be calculated using \({{P}}\) and \({{L}}\). In the cornering motions, although \({{P}}\) is fixed, \({{R}}\) and \({\vec{{v}}}\) change with the motion of the moving table. This means that \({{d}}\) changes with \({{R}}\) and that \({{d}}\) is a function of \({{R}}\) (i.e., \(d\left( R \right) \, \)). Therefore, the cornering error \({{d}}_{{{c}}}\) in this study is defined as the maximum value of \({{d}}\) when \({{R}}\) changes along the actual path, as shown in Fig. 4b and (7).

$$ d_{{{c}}} = \mathop {{\text{max}}}\limits_{{R \in {\text{actual\;path}}}} \, d\left( R \right) \, $$
(7)
Fig. 4
figure 4

Definition of cornering error as applied in this study

3.4 Description of PSO algorithm

PSO is an optimization algorithm developed by observing the foraging behaviors of birds [27], and several extended designs based on the PSO have been proposed in the literature. Given that PSO with a linear decreasing inertial weight (PSO-W) [28] has superior searching ability without excess computational burden, PSO-W was used herein to adjust the position control parameter of the P–PI control structure in Fig. 3 to minimize the cornering error defined in Fig. 4. PSO-W is expressed as (8)–(10), where \(x_{id}\) is the present position of particle \(i\) in dimension \(d\), \(v_{id}\) is the present velocity of particle \(i\) in dimension \(d\), \(w\) is the inertial weight, \(c_{1}\) and \(c_{2}\) are weighting factors, \(p_{id}\) is the previous best position, \(p_{gd}\) is the global previous best position, \(rand{(} \cdot {)}\) is a function to generate a random number between 0 and 1, \(w_{c}\) is the constriction factor, and \(n\) is the index of iteration.

$$ v_{id}^{{n + {1}}} = w^{n} \cdot v_{id}^{n} + c_{1} \cdot rand{(} \cdot {)} \cdot \left( {p_{id}^{n} - x_{id}^{n} } \right) + c_{2} \cdot rand{(} \cdot {)} \cdot \left( {p_{gd}^{n} - x_{id}^{n} } \right) $$
(8)
$$ x_{id}^{n + 1} = x_{id}^{n} + v_{id}^{n + 1} $$
(9)
$$ w^{n + 1} = w^{n} \cdot w_{c} $$
(10)

The objective function, which is necessary for finding the optimum solution of PSO, can also be the basis for judging the optimum solution and can change the movements of the particles.

4 Methods

4.1 Derivation of two-mass equivalent system

Referring to the transfer functions expressed by (4) and (5), the PMSM velocity-controlled two-mass system can be obtained as shown in Fig. 5 using the inner loop of the P–PI control structure. To simplify the subsequent derivations, the transfer function \(C\left( {{s}} \right)\) is expressed as (11).

$$ {{C}}\left( {{s}} \right) = {{K}}_{vp} \left( {1 + \frac{{{{K}}_{i} }}{s}} \right) = \frac{{N_{{{C}}} \left( {{s}} \right)}}{{D_{{{C}}} \left( {{s}} \right)}} $$
(11)
Fig. 5
figure 5

Block diagram of the PMSM velocity-controlled two-mass system

The transfer functions \({{H}}_{m} \left( {{s}} \right)\) and \({{H}}_{{{L}}} \left( {{s}} \right)\) are expressed as (12) and (13), respectively, and have the same denominator polynomial, as shown in (14).

$$ {{H}}_{m} \left( {{s}} \right) = \frac{{\dot{\theta }_{{{m}}} \left( {{s}} \right)}}{{{{T}}_{{{m}}} \left( {{s}} \right)}} = \frac{{N_{m} \left( {{s}} \right)}}{{D_{m} \left( {{s}} \right)}} $$
(12)
$$ {{H}}_{L} \left( {{s}} \right) = \frac{{{\dot{{x}}}_{{{t}}} \left( {{s}} \right)}}{{{{T}}_{{{m}}} \left( {{s}} \right)}} = \frac{{N_{L} \left( {{s}} \right)}}{{D_{L} \left( {{s}} \right)}} $$
(13)
$$ D_{m} \left( {{s}} \right) = D_{L} \left( {{s}} \right) = D\left( {{s}} \right) $$
(14)

The transfer function \({{M}}\left( {{s}} \right)\) between the velocity command \(\dot{\theta }_{{{m}}}^{{{r}}}\) and load moving velocity \({\dot{{x}}}_{{{t}}}\) is derived as shown in (15):

$$ M\left( {{s}} \right) = \frac{{{\dot{{x}}}_{{{t}}} \left( {{s}} \right)}}{{\dot{\theta }_{{{m}}}^{{{r}}} \left( {{s}} \right)}} = \frac{{C\left( {{s}} \right){{H}}_{m} \left( {{s}} \right)}}{{1 + C\left( {{s}} \right){{H}}_{m} \left( {{s}} \right)}} \cdot \frac{{N_{L} \left( {{s}} \right)}}{{N_{m} \left( {{s}} \right)}} = {{G}}\left( {{s}} \right) \cdot N\left( {{s}} \right), $$
(15)

where the transfer function \({{G}}\left( {{s}} \right)\) of the PMSM velocity control is expressed as (16).

$$ {{G}}\left( {{s}} \right) = \frac{{\dot{\theta }_{{{m}}} \left( {{s}} \right)}}{{\dot{\theta }_{{{m}}}^{{{r}}} \left( {{s}} \right)}} = \frac{{C\left( {{s}} \right){{H}}_{m} \left( {{s}} \right)}}{{1 + C\left( {{s}} \right){{H}}_{m} \left( {{s}} \right)}} $$
(16)

The load-equivalent transfer function \({{N}}\left( {{s}} \right)\) is expressed as (17).

$$ {{N}}\left( {{s}} \right) = \frac{{{\dot{{x}}}_{{{t}}} \left( {{s}} \right)}}{{\dot{\theta }_{{{m}}} \left( {{s}} \right)}} = \frac{{N_{L} \left( {{s}} \right)}}{{N_{m} \left( {{s}} \right)}} $$
(17)

Based on (15), the PMSM velocity-controlled two-mass equivalent system is obtained as shown in Fig. 6 and is applied to design the velocity control parameters (\(K_{vp}\) and \(K_{i}\)).

Fig. 6
figure 6

Block diagram of the two-mass equivalent system

4.2 Design of velocity control parameters

The two-mass equivalent system shown in Fig. 6 indicates that the load moving velocity is affected by transfer functions \({{G}}\left( {{s}} \right)\) and \({{N}}\left( {{s}} \right)\). Because the load-equivalent transfer function \({{N}}\left( {{s}} \right)\) denotes the inherent characteristics of the two-mass system, the velocity control parameters (\(K_{vp}\) and \(K_{i}\)) designed in this study achieve a PMSM with velocity response \(\dot{\theta }_{m}\) along with a short rise time and small overshoot. Moreover, (11) and (12) are used to rewrite the transfer function \({{G}}\left( {{s}} \right)\) as shown in (18).

$$ {{G}}\left( {{s}} \right) = \frac{{\frac{{N_{{{C}}} \left( {{s}} \right)}}{{D_{{{C}}} \left( {{s}} \right)}}\frac{{N_{m} \left( {{s}} \right)}}{{D_{m} \left( {{s}} \right)}}}}{{1 + \frac{{N_{{{C}}} \left( {{s}} \right)}}{{D_{{{C}}} \left( {{s}} \right)}}\frac{{N_{m} \left( {{s}} \right)}}{{D_{m} \left( {{s}} \right)}}}} = \frac{{N_{{{C}}} \left( {{s}} \right)N_{m} \left( {{s}} \right)}}{{N_{{{C}}} \left( {{s}} \right)N_{m} \left( {{s}} \right) + D_{{{C}}} \left( {{s}} \right)D_{m} \left( {{s}} \right)}} $$
(18)

Thereafter, the characteristic equation of the PMSM velocity control is obtained as (19).

$$ N_{{{C}}} \left( {{s}} \right)N_{{{m}}} \left( {{s}} \right) + D_{{{C}}} \left( {{s}} \right)D_{{{m}}} \left( {{s}} \right) = 0 $$
(19)

Let \(s = \left( { - \sigma + j\omega } \right)\) be a root of the characteristic equation, and

$$ N_{C} \left( { - \sigma + j\omega } \right) = N_{Cre} + jN_{Cim} , $$
(20)
$$ D_{C} \left( { - \sigma + j\omega } \right) = D_{Cre} + jD_{Cim} , $$
(21)
$$ N_{m} \left( { - \sigma + j\omega } \right) = N_{mre} + jN_{mim} , $$
(22)
$$ D_{m} \left( { - \sigma + j\omega } \right) = D_{mre} + jD_{mim} . $$
(23)

Equation (19) can then be rewritten as (24)

$$ \left( {N_{Cre} + jN_{{C{{im}}}} } \right)\left( {N_{{{{m}}re}} + jN_{{{{m}}im}} } \right) + \left( {D_{Cre} + jD_{{{{C}}im}} } \right)\left( {D_{{{{m}}re}} + jD_{{{{m}}im}} } \right) = 0 $$
(24)

and

$$ \begin{gathered} \left( {N_{Cre} + jN_{{C{{im}}}} } \right) = - \frac{{\left( {D_{Cre} + jD_{{{{C}}im}} } \right)\left( {D_{{{{m}}re}} + jD_{{{{m}}im}} } \right)}}{{\left( {N_{{{{m}}re}} + jN_{{{{m}}im}} } \right)}} \hfill \\ \, = \frac{{\left[ {\left( { - D_{Cre} D_{{{{m}}re}} + D_{{{{C}}im}} D_{{{{m}}im}} } \right) - j\left( {D_{Cre} D_{{{{m}}im}} + D_{{{{C}}im}} D_{{{{m}}re}} } \right)} \right] \cdot \left( {N_{{{{m}}re}} - jN_{{{{m}}im}} } \right)}}{{\left( {N_{{{{m}}re}}^{2} + N_{{{{m}}im}}^{2} } \right)}} \hfill \\ \end{gathered} $$
(25)

Functions \({{X}}\), \({{Y}}\), and \({{Z}}\) are defined as (26), (27), and (28), respectively.

$$ {{X}} = {{D}}_{{{{C}}im}} D_{{{{m}}im}} - D_{Cre} D_{{{{m}}re}} $$
(26)
$$ Y = D_{Cre} D_{{{{m}}im}} + D_{Cim} D_{{{{m}}re}} $$
(27)
$$ {{Z}} = N_{{{{m}}re}}^{2} + N_{{{{m}}im}}^{2} $$
(28)

Thereafter, \(N_{Cre}\) and \(N_{Cim}\) are obtained as in (29) and (30), respectively.

$$ N_{Cre} = \frac{{\left( {X \cdot N_{{{{m}}re}} - Y \cdot N_{{{{m}}im}} } \right)}}{Z} $$
(29)
$$ N_{Cim} = \frac{{ - \left( {X \cdot N_{{{{m}}im}} + Y \cdot N_{{{{m}}re}} } \right)}}{Z} $$
(30)

Substituting \(s = \left( { - \sigma + j\omega } \right)\) in (11), the transfer function \(C\left( {{s}} \right)\) can be rewritten as (31):

$$ C\left( { - \sigma + j\omega } \right) = \frac{{K_{vp} \left( { - \sigma + j\omega } \right) + K_{vp} K_{i} }}{ - \sigma + j\omega } = \frac{{N_{Cre} + jN_{Cim} }}{{{{D}}_{Cre} + j{{D}}_{Cim} }}, $$
(31)

where \(N_{Cre}\) and \(N_{Cim}\) are expressed as (32) and (33), respectively.

$$ N_{Cre} = - K_{vp} \sigma + K_{vp} K_{i} $$
(32)
$$ N_{Cim} = K_{{{{v}}p}} \omega $$
(33)

Then, (32) and (33) can be used to derive the velocity control parameters \(K_{vp}\) and \(K_{i}\) as shown in (34) and (35), respectively.

$$ K_{vp} = \frac{{N_{Cim} }}{\omega } $$
(34)
$$ K_{i} = \frac{{N_{Cre} }}{{K_{vp} }} + \sigma $$
(35)

Equations (29) and (30) are substituted in (34) and (35) to obtain the design equations for the velocity control parameters \(K_{vp}\) and \(K_{i}\), which are expressed as (36) and (37), respectively.

$$ K_{vp} = \frac{{ - \left( {X \cdot N_{{{{m}}im}} + Y \cdot N_{{{{m}}re}} } \right)}}{\omega \cdot Z} $$
(36)
$$ K_{i} = \frac{{X \cdot N_{{{{m}}re}} - Y \cdot N_{{{{m}}im}} }}{{K_{vp} \cdot Z}} + \sigma $$
(37)

Accordingly, the calculations of the velocity control parameters \(K_{vp}\) and \(K_{i}\) can be summarized as follows:

  • Assign a root \(s = \left( { - \sigma + j\omega } \right)\) of the characteristic Eq. (19).

  • Refer to (21) and set \(D_{Cre} = - \sigma\) and \(D_{Cim} = \omega\) by comparing the denominator polynomial of (31).

  • Calculate the values of the polynomial functions \(N_{m} \left( { - \sigma + j\omega } \right)\) and \(D_{m} \left( { - \sigma + j\omega } \right)\) using (22) and (23), respectively, to obtain \(N_{mre}\), \(N_{mim}\), \(D_{mre}\), and \(D_{mim}\).

  • Calculate the values of the functions \({{X}}\), \({{Y}}\), and \({{Z}}\) using (26), (27), and (28), respectively.

  • Calculate \(N_{Cre}\) and \(N_{Cim}\) using (29) and (30), respectively.

  • Calculate the velocity control parameters \(K_{vp}\) and \(K_{i}\) using (34) and (35), respectively.

Therefore, \(K_{vp}\) and \(K_{i}\) were designed in accordance with the assigned root \(\left( { - \sigma , j\omega } \right)\) as well as (36) and (37). The assigned root \(\left( { - \sigma , j\omega } \right)\) is designed with reference to the prototype second-order system; that is, the parameters \(\sigma\) and \(\omega\) of the assigned root are expressed as (38) and (39), respectively.

$$ \sigma = \zeta \omega_{n} , $$
(38)
$$ \omega = \omega_{n} \sqrt {1 - \zeta^{2} } , $$
(39)

where \(\zeta\) and \(\omega_{n}\) represent the damping ratio and undamped natural frequency, respectively, and the magnitude of \(\zeta\) must be in the range of \(0 < \zeta < 1\). To increase the velocity response of the PMSM and avoid large velocity overshoots, the damping ratio is generally chosen for the slightly underdamped condition. Moreover, the design of \(\zeta\) and \(\omega_{n}\) must achieve the roots of the characteristic equation expressed by (19) with a negative real part.

The characteristic equation of the PMSM velocity-controlled two-mass system is a fourth-order equation, and (36) and (37) are used to design a pair of complex roots; therefore, the other roots of the characteristic equation may influence the velocity response of the PMSM. To handle the problems caused by the other roots, the design ranges of \(\zeta\) and \(\omega_{n}\) are set as in (40) and (41), respectively:

$$ \zeta \in \left[ {\begin{array}{*{20}c} {\zeta^{L} } & {\zeta^{U} } \\ \end{array} } \right], $$
(40)
$$ \omega_{n} \in \left[ {\begin{array}{*{20}c} {\omega_{n}^{L} } & {\omega_{n}^{U} } \\ \end{array} } \right], $$
(41)

where \(\zeta^{L}\) and \(\zeta^{U}\) denote the upper and lower bounds of \(\zeta\), and \(\omega_{n}^{L}\) and \(\omega_{n}^{U}\) denote the upper and lower bounds of \(\omega_{n}\), respectively. Within the specified ranges, the velocity control parameters can be designed with the required rise time and overshoot; for example, in this study, the velocity control parameters are designed to achieve the average velocity response of the PMSM while the damping ratio and undamped natural frequency are varied within their specified ranges.

4.3 Adjustment of position control parameter

Once the velocity control parameters \(K_{vp}\) and \(K_{i}\) are designed, the PSO is used to adjust the position control parameter \({{K}}_{pp}\) of the P–PI control structure. The aim here is to reduce the cornering errors of the moving table during the cornering motions of a given tool path. Because the cornering motions comprise synchronous motions of multiple axes, the PSO must simultaneously adjust the position control parameters of multiple motion axes. Once the position control parameters are adjusted, they must be maintained constant when the multiple axes perform the cornering motions of the given tool path.

The particle positions in the PSO represent the position control parameters of the multiple motion axes. Moreover, the particle constraints must include the stability conditions of position control. The P–PI control structure in Fig. 3 and two-mass equivalent system in Fig. 6 indicate that the adjustment of \({{K}}_{pp}\) must ensure that the roots of the characteristic equation in (42) have negative real parts.

$$ s \cdot \left( {N_{{{C}}} \left( {{s}} \right)N_{{{m}}} \left( {{s}} \right) + D_{{{C}}} \left( {{s}} \right)D_{{{m}}} \left( {{s}} \right)} \right) + K_{pp} \cdot \left( {N_{{{C}}} \left( {{s}} \right)N_{{{m}}} \left( {{s}} \right)} \right) = 0 $$
(42)

Furthermore, the position control parameters must be adjusted such that the moving table will not have significant overcut motions. Figure 7 shows the check rule for the overcut motions designed as in (43), where \(\vec{t}_{{{\text{first}}}}\) and \(\vec{t}_{{{\text{second}}}}\) represent the unit vectors of the first and second paths, respectively, and \(\overrightarrow {PR}\) represents the vector from \({{P}}\) to \({{R}}\).

$$ \left( {\vec{t}_{{{\text{first}}}} \times \vec{t}_{{{\text{second}}}} } \right) \bullet \left( {\vec{t}_{{{\text{second}}}} \times \overrightarrow {PR} } \right) < 0 $$
(43)
Fig. 7
figure 7

Check rule for the overcut motions

The objective function \({{J}}\) of the PSO is defined as (44), where \({{m}}\) represents the number of corners in the test path, \({{d}}_{{{c}}}^{{{k}}}\) represents the cornering error of the \({{k}}\) th corner, and \(w_{k} \in \left( {0, 1} \right)\) represents the weight of the \({{k}}\) th cornering error. Because a large corner angle usually implies a large cornering error, \({{w}}_{{{k}}}\) and the corner angle have a positive correlation. The cornering error weight \({{w}}_{{{k}}}\) is expressed as in (45), where \(\theta_{c}^{k} \in \left( {{0, }\pi } \right)\) represents the corner angle of the \({{k}}\) th corner. Thus, the objective function (30) can be expressed as the root-mean-squared value of the weighted cornering errors.

$$ J = \sqrt {\frac{1}{{{m}}}\sum\limits_{{{{k}} = 1}}^{{{m}}} {\left( {w_{{{k}}} \cdot {{d}}_{{{c}}}^{{{k}}} } \right)^{2} } } $$
(44)
$$ w_{k} = \frac{{\theta_{c}^{k} }}{\pi } $$
(45)

In this study, the two-mass-modeled motion axis (Sect. 3.1) integrated with the P–PI control structure (Sect. 3.2) was built to simulate the cornering motions of a CNC machine tool. The cornering errors (Sect. 3.3) were calculated and applied to the calculation of the objective function to ensure that the PSO (Sect. 3.4) could minimize the root-mean-squared value of the weighted cornering errors and adjust the position control parameters to reduce the cornering errors.

5 Experiments

5.1 Experimental setup

A CNC lathe is used to perform the experiments. Figure 8 shows that the X- and Z-motion axes use a 2.0 kW PMSM and ball screw to actuate a moving table so as to provide the lateral and longitudinal motions, respectively. The FPGA-based cRIO control console and input–output interface modules, developed by National Instruments (NI), control the PMSM of the X- and Z-motion axes. The NI FPGA-based cRIO control console uses NI LabView software in the design and realization of the motion control system, including the operating interface, signal measurement and feedback control, and recording and displaying of experimental data. This console is integrated with the input–output interface modules to connect the driver of the PMSM, send motion control commands to the driver, and receive feedback signals with a sampling period of 1.0 ms. The motion control commands are sent to the driver through a 16-bit digital-to-analog converter installed on an NI 9263 analog output module. The rotary incremental optical encoder is directly coupled with the output shaft of the PMSM. Moreover, the pulse signals generated by the encoder can be decoded using an NI 9401 bidirectional digital module to obtain the angle of rotation of the PMSM. Heidenhain linear encoders are installed on the lathe to measure the displacements of the moving table along the X- and Z-motion axes. The NI 9401 module is also used to decode the positional signals from the Heidenhain linear encoders. A 16-bit analog-to-digital converter is installed on an NI 9215 analog input module to receive the analog detection signals provided by the driver to obtain the driving torque and angular velocity of the PMSM.

Fig. 8
figure 8

CNC lathe used in this study

Referring to Fig. 8, the motion axis models are built as shown in Fig. 9, and the variables used in the motion axis models are presented in Table 2. Given that the X-motion axis is installed on the Z-motion axis and that the two motion axes are mutually independent, the derivations of the dynamic equations and transfer functions of the X- and Z-motion axes can be performed separately.

Fig. 9
figure 9

Motion axis models of the CNC lathe

Table 2 Variables used in the motion axis models

5.2 Velocity control experiment

The velocity control parameters (\(K_{vp}\) and \(K_{i}\)) were designed such that the PMSM of the motion axis exhibited a velocity response with a short rise time without significant maximum overshoot. Equations (46) and (47) are used as the designed ranges of \(\zeta\) and \(\omega_{n}\), respectively.

$$ \zeta \in \left[ {\begin{array}{*{20}c} {0.7} & {0.9} \\ \end{array} } \right] $$
(46)
$$ \omega_{n} \in \left[ {\begin{array}{*{20}c} {40} & {50} \\ \end{array} } \right] $$
(47)

The velocity control parameters of the X- and Z-motion axes are designed as shown in Table 3, and Fig. 10 shows the velocity responses of the PMSM along the X- and Z-motion axes. According to the experimental results of the X-motion axis, the rise time of the velocity response is 0.021 s and velocity overshoot is 3.252 rad/s (16.26% of the steady-state value). The experimental results for the Z-motion axis indicate that the rise time of the velocity response is 0.019 s and velocity overshoot is 3.300 rad/s (16.50% of the steady-state value). From the experimental results, the velocity control parameters designed in this study can achieve the desired velocity response of the PMSM, thus validating the feasibility of the developed design method.

Table 3 Velocity control parameters of the motion axes
Fig. 10
figure 10

Velocity responses of the PMSM along the motion axes

5.3 Cornering motion experiment

The test path comprising both acute and obtuse angles is designed as shown in Fig. 11. The tested motion speed was 2000 mm/min. Table 4 lists the position control parameters before and after adjustment using the PSO for 50 particles. Figure 12 shows the experimental results using the position control parameters before adjustment; here, the position control parameters were manually adjusted using the tuning rule typically adopted in industrial applications of PMSM drivers and CNC machine tools. The tuning rule can reduce the axial position errors to almost zero with a short settling time without any oscillation when the motion axes move with the tested motion speed and stop; in other words, the tuning rule can ensure axial position responses with short response times without significant overshoots. Moreover, the position control parameters were set to the same values to achieve synchronous motions of multiple axes. The experimental results show that the value of the objective function \({{J}}\) is \(0.{163}\) mm and that the average cornering error is \(2.581 \times 10^{ - 1}\) mm. Given that the cornering error and corner angle have a positive correlation, the maximum cornering error is \(4.221 \times 10^{ - 1}\) mm, which occurs at the third corner. Figure 13 shows the experimental results of the position control parameters after adjustment. Compared with the results in Fig. 12, the value of the objective function \({{J}}\) reduces to \(0.{108}\) mm, average cornering error reduces to \(1.778 \times 10^{ - 1}\) mm (reduction of 31.11%), and maximum cornering error still occurs at the third corner. However, the maximum cornering error reduces to \({2}{{.796}} \times {10}^{{ - 1}}\) mm (reduction of 33.76%). Therefore, the experimental results confirm the feasibility of the P–PI control parameter design and adjustment approach developed in this study. Based on the definition of the cornering error, the experimental results of the test path further confirm the improvement obtained using the proposed approach for the cornering motions in CNC machine tools.

Fig. 11
figure 11

Test path used in the experiments

Table 4 Position control parameters of the X- and Z-motion axes
Fig. 12
figure 12

Cornering errors of the test path (before adjustment)

Fig. 13
figure 13

Cornering errors of the test path (after adjustment)

6 Conclusions

Cornering control has become an important aspect in the motion control design of a CNC machine tool in recent years. Unlike the investigations on blending curve path, motion trajectory filter, and cornering motion control designs, the present study considers P–PI control that is extensively used in commercial PMSM drivers and CNC machine tool controllers; further, the motion axis is realistically modeled as a two-mass system to develop a P–PI control parameter design and adjustment method to further improve the linear cornering motions of CNC machine tools.

In this study, the motion axis of a CNC machine tool is modeled as a two-mass system with physical variables, such as the motor-equivalent inertia, load-equivalent mass, motor-equivalent viscous coefficient, load-equivalent viscous coefficient, axial stiffness, and axial viscous coefficient. Thereafter, by referring to the inner velocity control loop of the P–PI control structure, the PMSM velocity-controlled two-mass equivalent system is developed for subsequent design of the proportional and integral control parameters using the pole assignment method, thereby enabling the desired velocity response of the PMSM with a short rise time and small overshoot. Moreover, by referring to the cornering error defined in this study, the proportional control parameter of the outer position control loop of the P–PI control structure is adjusted using PSO to further reduce the cornering errors during the linear cornering motions of a given tool path. Given that the cornering error and corner angle have a positive correlation, the objective function is designed as the root-mean-squared value of the weighted cornering errors. Experiments were performed on a CNC lathe, and the results show that the cornering errors are reduced by 30%. Therefore, the experimental results validate the feasibility of the P–PI control parameter design and adjustment approach developed in this study for improving the cornering accuracies of CNC machine tools.