Abstract
CNC machine tools have been popularized in the development of the manufacturing industry because of their high precision, high speed, high efficiency, and safe and reliable processing. The numerical control system and the measurement system of the machine tool are the key components of the modern numerical control machine tool, especially the measurement system of the machine tool, which is a prerequisite to ensure the high precision of the machine tool. The sensor is an important part of the measurement system. Sensors are devices that can sense the measurement objects within the measurement range and convert them into output signals and information according to certain rules. They are mainly used to detect the operating objects, system status, and operating environment status of the machine tool system and effectively control the normal operation of the machine tool system. Accurate and reliable information is provided. This study takes the CNC machine tool control system as the research object and studies the optimization measures of the sensor data to its performance. First, a model of the CNC machine tool control system was built based on MATLAB/Simulink, and then, based on this model, an open-loop (without sensor) and closed-loop (with speed and position sensors) control systems were built and were finally verified by simulation. The research results show that when there are sensors, the CNC machine tool control system has better stability and robustness.
1. Introduction
The sensor is a measuring device that converts the measurement to a certain physical quantity with a certain degree of accuracy and is convenient for application. The input quantity of a commonly used sensor is a certain measured quantity, which may be a physical quantity and can be a physical quantity of gas, light, or electricity, mainly electrophysical quantity. There are many types of sensors [1–7].
The requirements of CNC machine tools for sensors include (1) high anti-interference and strong reliability; (2) meeting the requirements of high precision and high speed; (3) convenient use and maintenance, suitable for the operating environment of the machine tool; and (4) low price and cost low. In a broad sense, the servo system refers to an automatic control system whose output can follow the change in the input with certain accuracy. Its control is also a motion control with high precision and high speed as the goal. It mainly includes a spindle servo drive system and a feed servo system. [8, 9]. Figure 1 shows the CNC machine tool system.

The machine tool industry is the industry that uses the most servo products, so the development of the machine tool industry is closely related to the development of servo technology. The servo system used in CNC machine tools should meet the basic requirements of good stability, high positioning accuracy, fast response without overshoot, large torque, and wide speed range. In order to meet these requirements, the detection devices related to the servo system must also have high accuracy and precision. The development of the servo system is closely connected with the speed regulation theory of AC motors and the development of power electronic technology, micromotor technology, microcomputer technology, sensor technology, etc. and has experienced the development of open loop, hydraulic, electrical, DC motor servo, etc. Later, the current electrical servo system driven by AC motors has become the mainstream of the development of modern high-performance servo systems, and the system is mainly composed of semiclosed loop, fully closed loop, and other servo control forms [10–15].
The AC servo system used in CNC machine tools generally includes servo motors, drives (power amplifiers), motion controllers, and some feedback detection devices. Broadly speaking, they should also include transmission devices and work tables. The driver mainly completes the control of the motor speed and torque (current), which is the core of the servo system; the motion controller completes the more complex position motion control. Servo motors used in AC servo systems include synchronous motors and asynchronous motors. Permanent magnet synchronous motors have the characteristics of small size, high efficiency, excellent low-speed performance, wide speed range, high efficiency, and easy realization of field weakening control, etc., which can meet the requirements of high-performance control such as CNC machine tools, and with the performance of magnetic materials constantly increasing, declining prices, and easy control, etc., permanent magnet synchronous motors are more and more widely used [16–23].
According to the application and the different control performance requirements, the structure of the CNC servo system includes an open-loop position servo system, a semiclosed-loop position servo system, and a fully closed-loop position servo system.(1)The position servo system for an open loop is a kind of servo system used in early CNC machine tools without position feedback. Due to the low positioning accuracy and large transmission error, it is generally suitable for simple CNC systems that do not require high control accuracy and low movement speed.(2)The semiclosed-loop position servo system has the functions of position detection and feedback, but this position detection uses the displacement value integrated by the measured speed of the pulse encoder coaxially connected to the servo motor as the position feedback signal. In the case of bars and other transmission links, the displacement value measured in this way may have a certain deviation from the final table position, so it can only be called a semiclosed loop. With the improvement of manufacturing level, technology, and processing accuracy, the quality of the functional transmission components that constitute the servo system is getting better and better, which greatly improves the error of the transmission part, and the system can also use backlash compensation and pitch error compensation. The servo system of this structure also occupies a large proportion of the market share in the current mid-range CNC machine tools [24–28].(3)The fully closed-loop position servo system is directly installed on the worktable of the machine tool using high-precision measuring devices such as grating rulers. The precise displacement of the actual movement of the machine tool worktable can be obtained, so the precise position information of the worktable movement can be returned. In the above, this kind of control is the most ideal, with the smallest error. However, because the mechanical transmission chain of the machine tool itself is included in the position of the closed loop, the gap of the transmission part of the system, the nonlinearity of the friction characteristic, and the rigidity of the transmission will cause the system to be unstable, causing the system to resonate and crawl at low speed, which also gives control to the system. The tuning of system parameters brings great difficulties. The basic servo system is shown in Figure 1.
Most of the servo system manufacturers at present provide supporting servo motors and servo drives for different users to choose and use. The supporting drive equipment makes the drive parameter setting more convenient and reliable. Generally speaking, most of the system parameters can be set using the initial parameters provided by the drive manufacturer, and some parameters that have a greater impact on the control performance of the machine tool and are related to the load, such as position loop gain value, speed gain value, compound position feedforward coefficients, and other parameters that affect the accuracy of the machine tool need to be manually adjusted and set by professional engineers with experience [29]. However, the control system of the CNC machine tools is still a problem and is to be covered in detail.
Reasonable setting of the servo system parameters is an important measure to improve the machining performance and work stability and reliability of the machine tool. For the same type of machine tools, the gap in processing performance between China and foreign countries is a very important aspect of the fact that the domestic optimization of servo parameters is not enough or the parameters are too conservative in the setting. Of course, stability and reliability are the prerequisites, but on the basis of improving machine tool manufacturing performance, we should try to set more reasonable parameters. Due to the wide variety of CNC machine tools produced by the machine tool factory, and the manufacturing process and load conditions of the same model of machine tools may be different, this is a serious problem for the staff of servo optimization. In order to be helpful to the debugging personnel of the machine tool, this study will study the debugging process of some commonly used servo parameters and put forward some ideas and measures to improve the optimization performance of the servo. Specifically for the FANUC CNC servo system used on a horizontal machining center, with the help of its servo adjustment software Servo Guide and the machine tool circular error measurement suite Ballbar (ballbar) produced by Renishaw, some errors of the machine tool are measured and analyzed. The performance changes such as the accuracy of the machine tool after the adjustment of the parameters that have a greater impact are expected to provide some ideas for the parameter setting of the CNC machine tool servo system and the improvement of the machine tool performance.
The feed servo system is the intermediate connection part of the CNC numerical control device and the mechanical transmission part. Its performance directly affects the tracking and positioning accuracy of the servo axis movement, the surface quality of the processing, the productivity, and the working reliability, and other technical indicators, so the servo system is improved. Reliability and motion control performance are of great significance to CNC machine tools.
2. Mathematical Model of CNC Machine Tool Control System
The performance of the permanent magnet synchronous motor servo system is closely related to the structure and performance of the motor itself and the selected control strategy called direct torque control. As the motion execution unit of the servo system, the AC permanent magnet synchronous servo motor itself has many advantages and can well meet the performance requirements of the servo system, so it has become a motor widely used in the servo system of the high-precision transmission field. Starting from the basic structure of the permanent magnet synchronous motor, this study establishes the dynamic mathematical model of the motor in each analysis coordinate system, which lays the foundation for the subsequent analysis of different motor control strategies and methods.
What needs to be emphasized here is that before the mathematical modeling of the AC motor, the equations satisfied by the three-phase composite flux linkage of the AC motor must be first solved. The total flux linkage of the turns of each phase winding of the AC motor is mainly the flux linkage generated by the armature magnetic field and the flux linkage generated by the permanent magnet magnetic field. Therefore, we have obtained the flux linkage equation of the AC motor winding, as shown in formula (11):where ψm0 is the DC component of the permanent magnet flux linkage, ψm is the fundamental wave amplitude of the permanent magnet flux linkage, and θe is the position angle of the AC motor mover.
In the actual modeling process, some specific mathematical transformations, such as Parker transformation, are usually used to transform the coordinate system of each physical quantity of the AC motor:
Therefore, after transforming the formula (1), the following form can be obtained as follows:
In the formula, ψmd is expressed as the d-axis permanent magnet flux linkage, ψmq is expressed as the q-axis permanent magnet flux linkage, and ψm0 is expressed as the 0-axis permanent magnet flux linkage.
Substituting formulas (1) and (2) into formula (3), the following relationship can be obtained as follows:
In addition, each element in the inductance matrix of the AC motor and the specific expression of the permanent magnet flux linkage of the AC motor are obtained, and finally, the flux linkage equation of the AC motor can be obtained. The next two steps start with the elements of the inductance matrix. Generally speaking, the specific expressions of the self-inductance and mutual inductance of an AC motor are as follows:
What needs to be explained here is that the torque discussed here is derived from the electromagnetic torque equation of the AC motor under the condition of constant amplitude. At the same time, the frequency and phase angle of the current of the AC motor also remain constant, so the average electromagnetic torque in the steady-state expression is as follows:
In the formula, Pem is expressed as the power of the AC motor, and Tpm is expressed as the permanent magnet torque generated by the permanent magnet flux linkage of the AC motor and the armature current, which satisfies the following:
If the above formula is subjected to a certain mathematical transformation, then we can get the following:
Figure 2 is the control vector principle diagram of the CNC machine tool control system when direct torque control is used. As can be seen, both the static and dynamic coordinate systems exist when modeling the control system since both the static and dynamic parts contain. The coordinate system is the AC motor stator two-phase static coordinate system. When it needs to be explained here, the selected axial and stator A1-phase windings here, the axis directions of the D and q coordinate systems are the same; the rotating coordinate system of the D and q coordinate systems is considered to be fixed on the rotor side of the AC motor, the axial direction of the stator is the positive direction of the D axis, and the angle between the D axis and A1 winding is θe, us and is are each the stator voltage and current vector of the AC motor, and ψs and ψm are the stator armature flux and stator permanent flux. If the stator resistance is ignored, δ is the torque angle of the motor. In direct torque control, the stator flux is integrated with the stator voltage. The torque is estimated based on the inner product of the estimated stator flux vector and the measured current vector. The magnetic flux and torque will be compared with the reference value. If the error between the magnetic flux or torque and the reference value exceeds the allowable value, the power crystal in the inverter will switch so that the error of the magnetic flux or torque can be reduced as soon as possible.

It can be seen from the figure that the torque equation of AC motor can be expressed as follows:
Since the Ld and Lq of the AC motor are approximately equal, the formula (10) can be written as follows:
Among them, δ is expressed as the angle formed between the stator armature flux linkage of the AC motor and the corresponding permanent magnet flux linkage. However, because the ψm obtained by the permanent magnets of the AC motor stator is a constant amount, we can adjust the stator armature flux, the value, and the included angle δ between the stator armature flux linkage of the AC motor and the stator permanent magnet flux linkage, so as to achieve the purpose of controlling the electromagnetic torque Tem of the AC motor system. Therefore, direct torque control can also be regarded as a hysteresis or relay control.
For AC motors, the corresponding stator flux linkage vector can be expressed by formula (11):
Since in the control circuit, when the control switch is turned on or off, each voltage vector is a constant quantity, so the formula (12) can also be expressed as follows:
Among them, ψs is expressed as the initial armature flux linkage vector of the AC motor stator. Since the AC motor uses a permanent magnet motor, there is also a flux linkage when the motor is not energized. That is to say, what needs to be noted here is that these two quantities have not only magnitude but also direction, Therefore, it is necessary to know the initial position of the AC motor rotor during actual operation. The stability of the AC control system control will depend to a certain extent on the judgment of the rotor position.
If the stator resistance is neglected, then according to formula (12), it can be known that the stator flux linkage of an AC motor can be directly expressed as integrating the voltage space vector:
Therefore, we can achieve the control of the flux linkage by appropriately selecting the space voltage vector so that its trajectory is close to a perfect circle.
In an AC control system, when the angle between the applied voltage vector and the current flux linkage vector of the AC motor is <90°, the corresponding flux linkage amplitude will accordingly increase. When the angle between the applied voltage vector and the current flux linkage vector of the AC motor is >90°, the corresponding flux linkage amplitude will correspondingly decrease due to the effect of the vector.
Therefore, in order to facilitate our selection of voltage vector, we can divide the vector plane into six regions as shown in Figure 3. For example, when the stator flux linkage runs in the I area and rotates counterclockwise, we can choose the voltage space V6 to increase the amplitude of the flux linkage or select the voltage space V5 to reduce the amplitude of the flux linkage. In the same way, if the stator flux linkage of the AC motor runs clockwise, we can choose V3 to increase the flux linkage amplitude or select V2 to decrease the flux linkage amplitude. Therefore, we can choose an appropriate space vector to control the amplitude of the AC motor's stator flux linkage so that its amplitude is basically constant.

Direct torque control (DTC) is a way for the inverter to control the torque of a three-phase motor. The method is to calculate the estimated value of the motor magnetic flux and torque according to the measured motor voltage and current, and after controlling the torque, the speed of the motor can also be controlled.
3. Optimization of CNC Machine Tool System Based on Speed Sensor and Position Sensor
In order to ensure that the machine tool reaches the best state when it leaves the factory to obtain the best steady-state performance and dynamic performance, after the servo drive completes the basic configuration of the drive and the motor, further control parameters need to be adjusted for the system with load to make the electrical parameters that are matched with the mechanical structure to improve the accuracy of the system speed and position control, which is called the optimization of the servo system.
The optimization and adjustment of controller parameters should not only follow the general principles of controller parameter settings but also combine some experience in actual debugging. Different types of machine tools (or even the same type of machine tools) often have different settings according to the load of the servo system. The value of this is indeed a complicated matter for the engineers who optimize and debug the machine tool. This study specifically combines the fully closed-loop permanent magnet synchronous motor feed position servo system used in a horizontal machining center to study the servo optimization method. The machining center uses FANUC permanent magnet synchronous servo motor and matching servo drives. Combining some basic theories of servo system design, a large number of experiments are carried out on the optimization of servo system parameters, and certain optimization conclusions and methods are analyzed and obtained in order to help the machine tool factory’s servo optimization and debugging work.
The closed-loop servo system usually includes three feedback loops: position loop (outer loop), speed loop (middle loop), and current loop (inner loop). The general structure diagram is shown in Figure 4. As can be seen, using the closed loops can help to improve the precision, which will be further discussed in the following. For a position servo system controlled by three loops, the response speed of the inner loop current loop should be higher than the response speed of the outer loop. In order to avoid the vibration and poor response of the servo system, the general servo optimization process is to first optimize the current loop, then optimize the speed loop, and finally adjust the position loop parameters.

3.1. Current Loop
The main function of the current loop is to play a timely antiwinding effect against the fluctuation of the grid voltage, and second, it can limit the armature current when the motor is locked and play a role in automatically and quickly protecting the motor. The AC servo system achieves good control of motor torque and speed through high-performance control of the current link. The control parameters of the current link are related to the used inverter power electronic devices, current detection devices, motor stator inductance, and other parameters. The parameters of the current controller are determined according to the physical parameters of the motor and the load. The parameters of the motor play an important role in the parameter setting of the current loop. In the current general-purpose servo products, the servo driver can identify the serial number of the matching motor and automatically set the current controller parameters to ensure that the current loop has a good response. For users, there is generally no need to manually adjust current loop parameters. The torque comparison with/without the current loop is shown in Figure 5. Besides, the torque map is compared in Figure 6.


3.2. Speed Loop
The speed loop is an important part of the machine tool servo system to realize dynamic tracking. The basis of the servo system's fast positioning and accurate tracking is that its speed loop has good dynamic response capability, wide speed range, and excellent antidisturbance performance. In engineering practice, the speed loop controller is usually set as a PI regulator.
The problems of unstable operation, slow response, vibration, and howling of the servo motor in the machine tool are closely related to the performance of the speed loop servo. The basic principle of speed controller parameter tuning is to maintain the stability of the system. On this basis, the proportional and integral gains of the speed loop are adjusted to adjust the dynamic performance of the system to the best. Generally, high-performance servo drives have some automatic optimization functions, but these parameters fully consider the stability of the system, and the settings are relatively conservative. Through the measurement and analysis of the frequency response of the speed loop, the parameters can be adjusted to make the bandwidth of the speed loop large enough to improve the dynamic response speed of the speed loop. Speed and torque comparisons with/without speed loop are shown in Figures 7 and 8.


3.3. Position Loop
The function of the position loop is to use the difference between the set target position and the actual position to generate the motor degree command through the position regulator. The regulator of the position loop is usually designed as a pure proportional regulator, which can easily obtain stable, non-overshoot position control and good positioning accuracy, but it is inevitable that there will be a steady-state position following error, which affects the accuracy of the machine tool processing.
The analysis results of the position following error of CNC machine tool linear cutting, taper cutting, arc cutting, etc. show that the tracking error of the position servo system is closely related to the position loop gain of the system and presents a certain inverse proportional relationship, that is, the position loop. The higher the gain, the smaller the tracking error of the system. However, the increase in the position loop gain is limited by the cut off frequency of the speed inner loop. It cannot be indefinitely increased; otherwise, it will affect the stability of the system. For this reason, the method of compound feedforward control is often used to reduce the position following error.
The servo optimization of the position loop is mainly to adjust the position loop control gain and the position loop compound control feedforward gain coefficient to reduce the following error of the position loop. Since the three closed loops are employed in this method, less error may be obtained when compared with the conventional methods.
Combined with the FANUC drive control system adopted by the machine tool, this debugging intends to adjust the following main servo parameters, and the adjustment of auxiliary parameters should be set according to the needs, without too much research. First, with the help of the FANUC system servo debugging guide tool—Servo Guide software, the servo axis parameters are adjusted to optimize the single-axis servo performance. Using Servo Guide software to collect test signals can easily make judgments on the servo performance after servo parameter adjustment and guide the optimization of servo parameters to determine the best state of servo adjustment. Subsequently, the QC10 ballbar is used to simulate the arc, analyze the dual-axis linkage operation performance after adjusting the parameters, and use the error analysis function provided by the software to further guide the optimization of the servo performance parameters of each servo axis. The machine tool is made to meet the needs of actual processing.
On the premise that the mechanical system does not vibrate, the larger the parameter setting, the better the command tracking of the speed loop, and the stronger the rigidity of the servo system. FANUC system No. 2021 parameter speed gain, also known as load inertia ratio, is the most critical parameter of the speed loop. Its setting is related to the actual load inertia ratio of the axis servo system, but the two are relatively independent and different concepts. For convenience, the 2021 parameter is called as the load inertia ratio parameter.
There is a conversion relationship between the actual saved value of the No. 2021 load inertia ratio parameter and the speed gain display value. The higher the load inertia ratio parameter setting, the faster the response speed of the system, so this parameter should be set as high as possible. But the setting value is not as high as possible. If the speed gain is set too high, vibration and whistling will occur when the machine axis moves. The predicted values are shown in Figure 9.(1)Measurement of the frequency response of speed loop interference. First, the position gain is set to a lower value (such as 1000), and then, the speed gain is gradually increased without generating abnormal response and vibration. At each speed gain value, the servo debugging software Servo Guide is used to input the frequency-varying sinusoidal disturbance to the torque command, the sine wave disturbance input is measured as 1 and the torque command output 1 is output by the speed controller, and then, the speed loop interference frequency can be obtained as a response. The best speed gain is selected with the help of the frequency response graph obtained by the measurement and whether there is abnormal vibration and howling during the measurement process.(2)Software automatic gain adjustment. The Servo Guide software adjustment navigator provides the function of automatically optimizing the speed gain. The speed closed-loop frequency response graph (called the speed feed frequency response graph) is generated through the feed motion. The measurement principle is to make the machine tool servo axis feed at a low speed. The frequency response of the transfer function between the input speed command (input 2) and the motor feedback speed (output 2) is measured, as shown in Figures 5 and 6. But after experimentation, it is found that when the initial setting value is low (such as 100), the software will recommend a higher speed gain value, which may cause the machine tool to significantly oscillate. When setting a slightly higher gain value (such as 150), the value recommended by the software is reasonable, but the recommended value is also conservative. It can be adjusted upward on the basis of this recommended value. After selecting the appropriate gain, you can adjust the filter and reduce the gain value at the resonance frequency through the notch filter.

The adjustment of the position loop gain is mainly based on two principles: the principle of stability and the principle of small tracking error. Generally, the position loop controller in the industrial application field is a constant gain, that is, the proportional gain, which has the characteristics of simple control and fast response speed. When the position loop gain is small, the servo system is easy to stabilize, but the tracking error of the servo system is large, which will form a large contour error when processing the workpiece; the position loop gain value is high, the position tracking error is small, but the input feed speed suddenly changes. When its output drastically changes, the mechanical load has to withstand greater impact. Therefore, the setting of the specific position gain should comprehensively consider the two factors of stability and position following error.
In order to maintain a smooth transition at the start, stagnation, trajectory turning, and speed changes in the machine tool, the machine tool must be accelerated and decelerated in accordance with a given smooth law. Commonly used acceleration and deceleration control laws are linear and exponential. There are two control modes of acceleration and deceleration: acceleration and deceleration before interpolation and acceleration and deceleration after interpolation. The acceleration and deceleration before interpolation are to control the speed along the trajectory direction, which will not cause trajectory error but require complicated path calculation along the arc direction, and the acceleration and deceleration method after interpolation is based on the coordinate direction of each axis to the end point. The difference is controlled by changing the system loop gain, which may cause trajectory errors due to the inconsistent servo characteristics of each coordinate axis of the machine tool.
The interpolation time constant of the servo axis cutting feed is used to control the acceleration of the interpolation axis during cutting motion. The smaller the time constant after interpolation is set, the shorter the acceleration and deceleration time when the motor is running, and the greater the acceleration, which may cause acceleration overshoot and excessive axis movement. Therefore, it is not advisable to set the time constant too small. The reasonable setting of this parameter value can effectively reduce the time to accelerate to a given cutting speed without mechanical impact and reduce the contour error in the acceleration and deceleration phases. This method does not require complex coordinate transformation but directly calculates the magnitude of the flux linkage and torque on the motor stator coordinates and realizes PWM pulse width modulation and high dynamic performance of the system through the direct tracking of flux linkage and torque.
4. Conclusions
CNC machine tools have been popularized in the development of the manufacturing industry because of their high precision, high speed, high efficiency, and safe and reliable processing. The numerical control system and the measurement system of the machine tool are the key components of the modern numerical control machine tool, especially the measurement system of the machine tool, which is a prerequisite to ensure the high precision of the machine tool. The sensor is an important part of the measurement system. Sensors are devices that can sense the measurement objects within the measurement range and convert them into output signals and information according to certain rules. They are mainly used to detect the operating objects, system status, and operating environment status of the machine tool system and effectively control the normal operation of the machine tool system. Accurate and reliable information is provided. This study takes the CNC machine tool control system as the research object and studies the optimization measures of the sensor data to its performance. First, a model of the CNC machine tool control system was built based on MATLAB/Simulink, and then, based on this model, an open-loop (without sensor) and closed-loop (with speed and position sensors) control systems were built and finally verified by simulation. The research results show that when there are sensors, the CNC machine tool control system has better stability and robustness.
Data Availability
The dataset can be accessed upon request.
Conflicts of Interest
The authors declare that there are no conflicts of interest.