Stacked Auto-Encoder Based CNC Tool Diagnosis Using Discrete Wavelet Transform Feature Extraction

Machining processes are critical and widely used components in the manufacturing industry because they help to precisely make products and reduce production time. To keep the previous advantages, a machine tool should be installed at the designated place and condition of the machine tool should be maintained appropriately to working environment. In various maintenance methods for keeping the condition of machine tool, condition-based maintenance can be robust to unpredicted accidents and reduce maintenance costs. Tool monitoring and diagnosis are some of the most important components of the condition based maintenance. This paper proposes stacked auto-encoder based CNC machine tool diagnosis using discrete wavelet transform feature extraction to diagnose a machine tool. The diagnosis model, which only uses cutting force data, cannot sufficiently reflects tool condition. Hence, we modeled diagnosis model using features extracted from a cutting force, a current signal, and coefficients of the discrete wavelet transform. The experimental results showed that the model which uses feature data has better performance than the model that uses only cutting force data. The feature based models are lower false negative rate (FNR) and false positive rate. Moreover, squared prediction error using normalized residual vector also reduced FNR because normalization reduces weight bias.


Introduction
Machining processes are critical components in manufacturing industry. The processes can help to precisely make products and to reduce production time. To achieve these advantages, the installation of machine's tool should be normal and manufacture conditions should be kept appropriate to environment condition. Especially, the machine's tool is the most influence on the quality of the workpieces, so it always has to be kept appropriate for working condition [1].
Computer numerical control (CNC) machine is one of the most widely used in machining processes. The CNC machine processes workpiece like metals or woods etc. The processes make products by cutting or milling the workpiece accordance with pre-designed form. The process of making products using CNC machine affects tool of CNC machine because the machine processes workpiece as rotating the tool that is fixed at spindle motor of CNC machine. If operators use cracked or weakened tool, the tool may be broken under operating, which can occur damage to people or machine. Furthermore, it makes economical loss by defect of products or delayed production. Connection of machine-to-machine or machine-to-devices is being automatized because automated facilities are being developed by the Fourth industrial revolution. Processes that is connected machine-to-machine can sequentially cause processing defect, so to keep the quality of products is important in each processes. To prevent these problems and determine appropriate time for changing tool, CNC machine tool diagnosis is essential [2].
Generally, there are three maintenance methods for maintaining system or machine, unplanned breakdown, planned scheduled, and condition based maintenance. First, Unplanned breakdown maintenance is to maintain the machine or system when breakdown is occurred at the system or machine. It takes low maintenance cost and has little requirement for management. However, this method causes high downtime and damage to people. These disadvantages can cause financial loss to be beyond our imagination, particularly in the chemical and power plants, which can induce a large amount of economic and societal damages. Second, the planned scheduled maintenance method is to maintain the system or machine on a cycle by constant period, it can minimize occurrence of system and machine failure. Although the method has an advantage, it need high cost to maintain the system because it sometimes change normal parts of the machine, and cannot handle problem happened suddenly. Finally, the condition based maintenance is to determine that the system or machine need maintenance through diagnosis of system condition. It can reduce maintenance cost, lift cycle cost, and downtime, and it also has strength at unpredictable failure. The condition based maintenance method can resolve previous two problems, and its importance also is increasing by improvement of data-driven modeling method [3].
Monitoring of system or machine is one of the most critical component in condition based maintenance. Tool condition monitoring (TCM), especially, is essential for preventing serious damage to machine and products and taking high quality and productivity. TCM is to diagnose tool with sensor signal of machine or tool, and it is actively studied using various sensor signals [4][5][6][7][8]. The representative sensor signal that is used to employ for TCM is: (1) Cutting force, (2) Vibration, (3) Temperature, (4) Sound, (5) Acoustic emission, and (6) Optics [1,9,10]. Cutting force is force that is generated by the cutting tool as it processes the workpiece. There are two method to measure the cutting force. One is direct measurement method that measures the cutting force using dynamometer. The other method is indirect measurement method that induce the cutting force from current. The indirect method calculates the cutting force using current signal, so it makes large error if prediction or calculation model is inaccurate. The direct method to use dynamometer can precisely measure the cutting force. However, this method takes a lot of costs because the sensor that measures the cutting force is expensive, and there is a challenge to install sensors on workpiece or machine [11]. The vibration sensor measures a vibration signal of tool or machine, and an accelerometer is typically employed to measure the signal. Vibration signal is representative signal to indicate condition of tool or machine. The vibration signal can show whether target system is normal or not if the vibration signal is out of normal interval or becomes specific magnitude. However, it is difficult to install vibration sensor on machine, and the vibration signal may take disturbance from vibration of inner factory or other machines. Temperature signals can show fatigue property or degree of tool wear for the target system. However, the temperature signal is weak to interference and needs appropriate outer condition. Although sound, acoustic emission, and optics signal also can indicate tool condition, these signals are weak to noise or environment condition as like the temperature sensor. In this paper, therefore, we employ cutting force induced from current because the cutting force is robust to environment condition and the sensor data can be easily acquired compared to other sensors. Furthermore, current signal extracted from spindle motor is employed to compensate cutting force error. Diagnosis methods for system or machine are typically divided two methods, model-based and data-driven technique. Model-based techniques can make a stable model. The model-based techniques need plenty of information and expert knowledge about target system. Besides, it is difficult to construct model if the target system has a lot of sensors and sub-systems. On the other hand, data-driven technique can make model which has better performance in complex system if there are enough high quality data. Furthermore, the model-based technique was being transformed into the data-driven technique by that computation power has been increasing for more than ten years [12]. There are various data-driven methods for system diagnosis, such as principal component analysis [13], support vector machine [14], nearest prototype classifier [15], k-means clustering [16] and neural network [17], etc. In last few years, several articles have been devoted to the study of system diagnosis using deep learning [18][19][20][21]. Auto-encoder is one of the deep learning methods, which has outstanding performance of signal reconstruction and anomaly detection. Moreover, auto-encoder is unsupervised learning method that is not needed labeled data, so it is a suitable method for the system which is difficult to obtain labeled data. In this paper, therefore, we employ stacked auto-encoder to diagnose machine tool.

Related Works
In this paper, we propose stacked auto-encoder based CNC machine tool diagnosis models that use feature data extracted by wavelet transform. Figure 1 shows three types of auto-encoder models for tool diagnosis. First, Figure 1a is a cutting force based stacked auto-encoder (CFSAE) which uses cutting force signal. Second, Figure 1b is a feature based stacked auto-encoder (FSAE) which employs feature extracted from cutting force and current. Finally, Figure 1c is a feature based stacked auto-encoder using normalized residual vector (FSAENR) that use normalized residual vector for calculating squared prediction error (SPE).

Auto-Encoder
Auto-encoders are unsupervised learning methods which have similar structure to general feed-forward neural network. The auto-encoders learn a representation of the data, typically obtained by a non-linear parametric transformation, after then learn a transformation going backwards from the representation to the data [22]. The auto-encoders use input data as target data of output layer. Therefore, it is unnecessary for the auto-encoders to get labeled data unlike supervised learning method. As shown in Figure 2, auto-encoder is composed of three layers: (1) input layer; (2) hidden layer; (3) output layer [23]. Progressing input layer to hidden layer is called encoder: the encoder reduce dimension by transforming input vector to low dimension vector. Decoder is to progress hidden layer to output layer: it reconstructs the vector reduced by encoder to original vector. Let x = [x 1 , x 2 , ..., x m ] be an input vector collected from a target system, which consists of m features that are used in Figure 1b,c model or time series data of m period that is used in Figure 1a model, i.e., x ∈ R m . In the encoder part, input x is transformed by encoding function as shown in Equation (1).
where f indicates the encoding function and h represents the hidden encoder vector calculated from x. W e and b e are a weight matrix and a bias vector between input layer and hidden layer, respectively. The decoder layer reconstruct the input vector x from the hidden representation h by decoding function as shown in Equation (2 where g indicates the decoding function andx is a reconstructed input vector, W b and b d are a weight matrix and a bias vector between the hidden layer and the output layer, respectively. The auto-encoders train to reduce the reconstruction error like Equation (3).
where [L (x,x)] is loss function. Mean squared error(MSE) is widely used in training the auto-encoders as the loss function, defined as

Wavelet Transform
To analyze time series signal, frequency analysis methods like Fourier transform (FT) have been widely used in plenty of research [24][25][26]. However, FT is weak in analyzing non-stationary signal because it represents only frequency domain [27]. Short-time Fourier transform (STFT), which is proposed to solve the problem, is used for analysis of non-stationary signals by windowing the signal using shifted window function [28]. Although the STFT has the advantage, it has weaknesses: (1) Dilemma of resolution, (2) Unchanged window, and (3) Heisenberg uncertainty principle [29,30]. Wavelet transform (WT) can be used to meet the above requirement. WT represents the signal in time and frequency domain and can change the frequency resolution and time interval by dilation and shift of wavelet function [31,32].
The wavelet function, ψ (a,b) (t), is derived from mother wavelet ψ(t) by dilation and translation.
where a is the scaling parameter which is inversely proportional to frequency, b is the time localization parameter, a > 0 and b ∈ R. The parameters make daughter wavelet function differ from others. The wavelet transform is performed by following equation: where '*' denotes complex conjugation.
The discrete wavelet transform (DWT) is based on multiresolution analysis. The DWT divides signal into different frequency components. These components are precisely obtained by splitting with frequency bands of a signal into various sub-bands based on a power of two divisions, which is called dyadic sampling. Initially, the signal is split into two wavelet coefficient, one is approximation coefficient that is result of low-pass filter, and the other is detail coefficient that is result of high-pass filter. The approximation coefficient still has high-frequency components, so to continuously conduct the process is needed until getting useful feature as shown in Figure 3. G 1 (z) is high-pass filter and G 0 (z) is low-pass filter, after through filter the signal down-sampled as half. This process splits the discrete signal spectrum in the frequency domain as shown in Figure 4.

Data Description and Detection Index
This section describes the data of signal that is measured from CNC machine to help understanding for CNC machine signal and feature extraction.

Data Description
CNC machine used in this paper is Dusan mynx 5400 as shown in Figure 5. We produced products like Figure 6 pattern. The tool size is 8φ and the tool has three blades.
In this paper, we use two types of sensor data, cutting force and current. Cutting force is measured from CNC machine and current is three-phase current measured from spindle motor. Current measurement device is designed and manufactured Korea electrotechnology research institute (KERI). Figures 7 and 8 show cutting force and current waveform. In case of current waveforms, we only show u-phase waveform because others current show similar pattern.
Cutting force sampling time is 4Hz and current sampling time is 2000Hz. We synchronize current signal on the basis of cutting force signal, which has lower sampling frequency, because the sampling frequencies of two signal are differ. There are high impulse data in cutting force signal when the tool move next line. The impulse signal can interrupt tool diagnosis, hence the signal should be removed for good performance. The cutting force signal removed impulse signal is depicted in Figure 7b. After removing the impulse signal from the cutting force signal, we synchronize the current signal on the basis of the cutting force signal. Figure 8b shows the current signal that is equivalent to Figure 7b interval.    # of samples

Feature Extraction
In this paper, we use three tool diagnosis models as shown in Figure 1. Among the models, Figure 1b,c models, which don't use original signal of cutting force and current, uses feature of cutting force and current signal. Let CF CNC and I phase be cutting force and current signal, respectively. Three-phase current are divided as u, v, and w. These are indicated I u , I v , and I w .
The features employed in this paper are mean, maximum, minimum, median, and standard deviation value in case cutting force. In case of current, RMS calculated by three-phase current is employed and maximum, standard deviation and RMS values calculated by each phase current are employed. The RMS about three-phase current is defined as [33]: In this paper, we apply 6-level discrete wavelet transform to decompose the current signal that is high frequency signal and is measured by high sampling rate. Each signal derives six detail coefficients and an approximation coefficient. To extract feature from result of DWT, we calculate the using the derived signal. RMS of wavelet coefficient is defined as: where A RMS , D RMS , A L , and D l are RMS value of approximation coefficient, detail coefficient, final level approximation coefficient and l-level detail coefficient, respectively. F s is sampling frequency, l indicates level of DWT. Extracted features are totally 36 variables as shown in Table 1. The input vector x of tool diagnosis model employing feature variables uses these variables, so x ∈ R 36 . Table 1. Feature variables extracted from cutting force and current signal.

Notation
Description Unit Notation Description Unit Maximum value of w-phase A X 31 RMS value of D 2 (w-phase) -X 14 STD of w-phase A X 32 RMS value of D 3 (w-phase) -X 15 RMS value 3-phase A X 33 RMS value of D 4 (w-phase) -X 16 RMS value of D 1 (v-phase) -X 34 RMS value of D 5 (w-phase) -X 17 RMS value of D 2 (v-phase) -X 35 RMS value of D 6 (w-phase) -X 18 RMS value of D 3 (v-phase) -X 36 RMS value of A 6 (w-phase) -

Detection Index
To diagnose CNC machine tool, residual vector e new (k) (= x new (k) −x new (k)) is calculated from original signal(x new (k)) and estimated signal(x new (k)) from auto-encoder model at sample k. After calculating residual vector, SPE is applied for measuring magnitude of residual. SPE is defined as: Tool condition is determined by SPE. The diagnosis model determine that tool is usable if SPE is lower than a specific threshold value. On the other hands, if SPE is higher than the threshold value, the diagnosis model determine that tool should be changed after some days or weeks. In this paper, we employ percentile and kernel density estimation for finding confidence limit used as threshold value.

Data Preparation
In this paper, we use two tools of CNC machine, a new tool and a used tool. The new tool has been used less than an hour and the use tool has been used over fifty hours. We made 4 workpieces with the new tool and 12 workpieces with the used tool. To generate the data which is able to apply to diagnosis models, we extract the part of signal processed in same pattern from the whole cutting force signal and remove the impulse signal which interrupt diagnosis. After extracting the cutting force signal, synchronizing the cutting force and the current signal should be performed because of different sampling time between the cutting force and the current signal. In the new tool dataset, there are 100 samples that are processed as same pattern. Among the new tool dataset, 80 samples are used as training dataset, others are employed test sample. In the used tool dataset, there are 218 samples that are processed as same pattern. Figure 1a model is trained by only the raw cutting force data in training dataset. Figure 1b,c models are trained by feature extracted from the cutting force and the current signal in training dataset. The cutting force and the feature data used as training and test data are normalized by the min-max normalization before training and test.

Experiments
In this paper, we experiment three models for diagnosis of CNC machine tool. Before training the test model is carried out, threshold value should be selected from detection index of training datasets. To select the threshold value, one-leave out method is employed [34]. The neural network and auto-encoder have different results even though the models have same structure and are trained by same datasets. Using this characteristic, we make 50 detection indices from different 50 models using a dataset for choosing the threshold value. Figure 9 shows the results of one-leave-out method as histogram, where dashed lines indicate threshold value which is 99 percent confidence level (Thr n ) of normal distribution, solid lines indicate threshold value which is 99 percentile(Thr p ) value. Model performance of auto-encoder indicates different results according to hyperparameter of auto-encoder (code size, the number of layers and the number of nodes per layer) and the number of learning epoch. Therefore, it is necessary for auto-encoder to optimize hyperparameter and the number of learning epoch. To optimize hyperparameter and the number of learning epoch, we carried out k-fold cross validation in this paper. Table 2 indicates optimized hyperparameter and the number of learning epoch obtained through k-fold cross validation, where code size is the number of neurons in latent space (end of encoder). CFSAE, FAE and FSAENR are Figure 1a-c model, respectively. To verify the diagnosis models, we train the models according to optimized values. Figure 10 shows results of the diagnosis models. Figure 10a,c,e show SPE result of each models. Blue solid line indicates calculation result of SPE using the new tool data, black solid line is calculation result using the used tool. Blue and red dashed line indicate threshold value extracted from percentile and kernel density estimation results, respectively. Figure 10b,

Conclusions
In this paper, we proposed CNC tool diagnosis models using auto-encoder. The auto-encoder is unsupervised method which do not need labeled data, so the method is appropriate at processes that have difficult to get the plenty of failure data. We used the cutting force extracted from CNC machine and the current data extracted from spindle motor for machine tool diagnosis. The diagnosis model that had used raw data showed low performance. Hence, feature data generated from the cutting force and current signal are employed. We carried out experiments about three models. The CFSAE model used raw cutting force data. The FSAE and FSAENR models used feature data. The results of CFSAE showed that the new tool and the used tool have similar SPE value, so the CFSAE model have not identified the type of tools. Hence, FNR and FPR of CFSAE model is high. In case of FSAE and FSAENR models, the used tool signals were almost completely classified and the test cases of new tool are perfectly identified at using Thr p as threshold value, FNR is zero. It can be seen that the feature data represents the characteristics of fault signal better than the raw signal. Furthermore, FSAENR has lower FNR than FSAE since normalized residual vector reduce effect of large unit scale like cutting force signal.
The condition based maintenance needs not only fault detection and tool diagnosis but also prediction model which estimates remained life time of tool. In future work, we will research about the tool diagnosis model that can continuously update criteria of tool condition using cumulated data in online and prediction model that can estimate remained life time of tool and denote the time to replace tool.
Author Contributions: All authors contributed equally to this work. All authors have read and agreed to the published version of the manuscript.