1 Introduction

Productivity and quality of manufactured products have been main attention of manufacturers in the increasingly competitive economic environment. A comprehensive approach to monitor and predict product quality is needed in manufacturing industry towards full automation and to achieve zero defect production. For computer numerical control (CNC) manufacturing machines, the product final surface quality is mainly influenced by the interaction between the cutting tool, the workpiece and the machining system [1].

Many researchers have conducted theoretical and experimental studies to develop efficient prediction systems for machined product quality. Machining with CNC requires setting process parameters such as feed rate, depth of cut and spindle speed, which depends on knowledge and experience. Quality monitoring and prediction have been studied by analyzing the effects of these process parameters on quality and furthermore by application of optimization technique to these process parameters [2,3,4]. To predict the quality using the process parameters more precisely, machine learning techniques have been extensively applied [5,6,7,8,9], among which Refs. [5,6,7] are concerned with roughness; Ref. [8] is for both roughness and profile accuracy; and Ref. [9] applies a neural network to predict the profile error which is subsequently used to correct CNC code. However, process parameters based approaches cannot guarantee the achievement of desired surface finish, as CNC machines are a bulky and complex system, and the interaction between the cutting tool, the workpiece and the machining system play a critical role in influencing surface finish. As mentioned in Ref. [10], one of the most important factors influencing the quality of the machined workpiece surface is the vibrations of machine tool and spindle which may cause excessive surface waviness and cylindricity. Therefore, sensors were installed in the machine system such as vibration sensors and force sensors, and the collected sensor signals were used to predict the quality together with the process parameters. For example, in Ref. [11], cutting forces, cutting vibrations, cutting speed, and the ratio of feed rate to tool-edge radius were taken as the inputs to a multi-layer perceptron neural network to predict surface roughness. References [12,13,14] considered spindle vibration, and the effect of spindle vibration on surface roughness was studied. And in Ref. [15], a linear regression model was developed to predict surface roughness using the measured displacement signals of relative spindle motion for an end milling machine. Spindle error motion and machined workpiece roundness are both studied in terms of relationship with spindle rotational speed for a roll lathe in Ref. [16], implying that spindle error motion causes the roundness deviation in machined cylinder workpiece [17].

In this work, a machine learning based approach using sensor signals of spindle vibration and cutting force is proposed to predict surface roughness, profile accuracy and roundness of the machined workpiece by a lathe. The spindle preload and temperature for different rotational speeds were set at different levels, by considering that preload [18] and temperature [19,20,21] were two main factors affecting the spindle vibration. By analyzing and interpreting the sensor signals under different settings of spindle parameters of speed, preload, and temperature, the features closely related to the parameters’ change are extracted from the raw sensor signals. The workpiece qualities are accurately predicted with the trained neural network models using these features as inputs.

2 Experiment and data collection

The 2-axis CNC lathe machine (model: HAAS ST-10) as shown in Fig. 1 is used to carry out the experiment. The experimental setup consists of workpiece, sensors and cutting tool, and is shown in Fig. 2a. The cylinder workpiece is of stainless steel and clamped using the soft-jaw. The cutting tool insert is DNGA-type CBN insert with the information detailed in Fig. 2b, and the coating is PCBN. For all cuttings, coolant was used.

Fig. 1
figure 1

CNC lathe machine HAAS ST-10

Fig. 2
figure 2

Experimental system a experimental setup inside the lathe machine, b DNGA-type of cutting tool and tool holder, D = 12.7 mm, Rε = 1.2mm, L10 = 15.5 mm

2.1 Design of experiment

Three spindle parameters, spindle preload, spindle housing temperature and rotational speed, are used to study the spindle failure. Each parameter has three value settings, and therefore there are twenty-seven combinations or cases. For each case, the cutting process was run three times, and the cutting parameters, which were 100 m/min cutting speed, 0.1 mm/r feed rate and 0.1 mm depth of cut, were fixed for all cases. After each cutting, the quality of the workpiece was measured to obtain the values of roughness parameter Ra, profile deviation Pt and roundness deviation RONt. In total, there are eighty-one sets of experimental sensor data together with corresponding workpiece quality data. Table 1 summarizes the design of experiment.

Table 1 Design of experiment (repeat the experiments for two more times)

The machine spindle was normally preloaded at the level of 32 µm. A new lock nut of a different height with internal locking was fabricated and used to lower the spindle preload to 19 µm. The spacer used in between front bearings were grinded to increase the spindle preload to 51 µm.

Industrial heating controller system was used to heat up the spindle housing. A large ceramic heating pad was wrapped around the spindle’s housing, before adding the insulating layer of glass wool. The heating process usually took about 2 h for temperature to reach equilibrium point.

To run the experiment with different rotations per minute (RPMs), the cutting speed was fixed at 100 m/min, and the workpieces with three different diameters of 80 mm, 120 mm and 150 mm were used. Accordingly, the spindle rotational speeds were 400 r/min, 260 r/min, and 210 r/min.

2.2 Sensor location and data collection

A tri-axial dynamometer and a tri-axial accelerometer were used to measure the cutting force and the spindle vibration, respectively. The cutting force and the spindle vibration are both simultaneously measured in XYZ standard three directions of the machine.

The accelerometer (Dytran 3273A2) was attached at the bottom of the spindle housing, and the dynamometer (Kistler 9129AA) was mounted at the cutting tool side. The raw vibration signals were processed through a multi-channel accelerometer amplifier, which was embedded in an national instrument (NI) data acquisition system. The raw force signals were processed through a multi-channel charge amplifier that was also connected to an NI data acquisition system. The signals from these sensors were collected for each cutting. The NI data acquisition system was programmed to capture all the sensor signals synchronously, and the signals were all sampled at 25.6 kHz. These collected raw signals were stored in TDMS file format.

3 Analysis of workpiece quality

Analysis of variance (ANOVA) test was carried out for Ra, Pt, and RONt, respectively, with respect to the spindle parameters of preload, temperature and RPM. The purpose of the statistical ANOVA test is to investigate which parameter significantly affects Ra, Pt, and RONt. It turns out that RPM is the major factor affecting Ra and Pt, followed by temperature and preload, and preload is the major factor affecting RONt, followed by RPM and temperature. Next, Ra, Pt, and RONt relationships with the spindle parameters will be shown individually.

3.1 Roughness parameter

Roughness as a measure refers to the texture of a surface [22]. According to ISO 4287, roughness parameter Ra is the arithmetical mean of the absolute values of the profile deviations (Zi) from the mean line of the roughness profile, as illustrated in Fig. 3. Surface roughness tester Talysurf equipment is used to measure the roughness parameter Ra of a workpiece.

Fig. 3
figure 3

Illustration of roughness parameter Ra [23]

The surface roughness is an important measure of product quality since it influences the product mechanical properties like fatigue behavior, corrosion resistance, creep life, etc., as well as production cost. It is quantitatively valued as the vertical deviation of a real surface from its ideal form. Large deviation means the surface is rough, and small deviation means the surface is smooth. Typically, roughness is related to the high frequency component of a measured surface.

ANOVA test showed that RPM and temperature were two main factors affecting Ra, and among the three parameters of preload, temperature and RPM, RPM was the most significant factor. Figure 4 plots the change trend of Ra with respect to RPM under different temperatures. Except for under the room temperature where Ra kept almost constant, it decreased as RPM was higher under the temperatures of 50 °C and 70 °C.

Fig. 4
figure 4

Roughness Ra vs. RPM for different temperatures

3.2 Total deviation of primary profile

Figure 5 gives an example of parameter Pt measurement. Here, Pt refers to the total deviation of primary profile of a workpiece.

Fig. 5
figure 5

Example of a workpiece profile deviation Pt measurement

Through ANOVA test, it was known that RPM most significantly affected Pt, followed by temperature and preload. Figure 6 shows how Pt changes with RPM at different temperatures. At the temperatures of 50 °C and 70 °C, Pt decreases as RPM is higher. At lower RPM, Pt is higher at 50 °C than 70 °C. By viewing Figs. 4 and 6 together, it is found that Ra and Pt are similar in terms of change trend with RPM and temperature.

Fig. 6
figure 6

Pt vs. RPM for different temperatures

3.3 Total roundness deviation

During the machining process, when a certain level of spindle failure exists, the workpiece gets deformed. On the convex deformed surface of the workpiece, the material removal is higher, and on the concave deformed surface, the material removal is lower. Consequently, the machined workpiece shape differs from the previous state and causes roundness deviation. In this work, the roundness of the workpiece was measured using equipment Talyor Hobson Talyrond 565XL. The reference type is LS circle; the filter type is Gaussian; the filter range is 1–50 upr. Figure 7 shows an example of roundness measurement.

Fig. 7
figure 7

Example of measurement result showing the roundness (green curve)

ANOVA test showed that preload was the most significant factor affecting roundness RONt, followed by RPM and temperature. The relationship of RONt with RPM and temperature is clearly observed in Fig. 8, where the roundness deviation is higher as the preload increases, which is consistent for all RPMs.

Fig. 8
figure 8

Roundness RONt vs. preload for different RPMs

4 Power spectral density (PSD) based feature extraction

Multiple sensors are used with the aim to increase the richness of information indicative of machine conditions. But the information provided by the multiple sensors may be redundant, which will deteriorate the accuracy of prediction models. Using key sensor signal features closely related to machine states or conditions is more effective and necessary than using all possible sensor features. Therefore, an extraction method for key features which will be the input of the machine learning model, is critically important to the achievable modeling accuracy. In general, three signal processing methods are employed for feature extraction, i.e., time and statistical domain method such as amplitude, mean, kurtosis and root-mean-square (RMS), frequency domain method such as FFT, PSD and harmonics, and time-frequency domain method such as short-time FFT and wavelet. After analyzing the sensor signals, it is found that the frequency-domain method is most appropriate as it shows obvious correlation with the change of spindle parameters. Thereby, in this section, features will be calculated from the power spectral density of the raw signals. Feature selection will then be applied on the candidate feature dataset to obtain a low dimension feature vector. By this way, the proposed method, which, on one hand, can reduce the risk of losing meaningful information and improve the prediction performance, and on the other hand, has little impact on the running speed of the machine learning model.

Eighty-one sets of sensor data and corresponding eighty-one sets of workpiece quality data (roughness Ra, profile Pt, roundness RONt) were collected. For each set, there are six channels of sensor signals, i.e., the spindle vibrations from the tri-axial accelerometer, and the cutting forces from the tri-axial dynamometer on the tool side. Figures 9a, b show one set of the sensor signals, as an example. The signals during the cutting period, as indicated in Figs. 9a, b by the windows, are used to build a model to predict the quality. In order to predict accurately, the features extracted from the raw signals should be correlated well enough with the machined workpiece quality, and the workpiece quality is related to the spindle parameters of spindle preload, temperature and RPM under consideration. In light of this, we have investigated the change of PSD of each signal when the spindle parameters of preload, temperature and RPM are set differently. As an example, Fig. 10 shows the PSD of the spindle vibration for different temperatures.

Fig. 9
figure 9

One set of the sensor signals a spindle vibration and b cutting force in X, Y, Z directions (the signals within the steady cutting period used for workpiece quality prediction)

Fig. 10
figure 10

Power spectral density of a set of spindle vibration, in the directions of a X, b Y and c Z for the temperatures of 25 °C, 50 °C, and 70 °C

According to Fig. 10, the sensor signal PSD could be used as a feature vector since it noticeably changes for different levels of the spindle temperature which lead to the change of the machined workpiece quality. Furthermore, since the PSD change concentrates on certain frequency ranges, an integrated PSD value in the frequency range is taken as a feature component. This feature extraction method can greatly reduce the length of the feature vector, and thus speed up the training process and running of the model.

The proposed features are defined as follows.

$$g\left( k \right) = \sqrt {\mathop \sum \nolimits_{i = ks}^{{\left( {k + 1} \right)s - 1}} S\left( {f_{i} } \right)^{2} } ,\quad k = 0,1,2, \cdots ,$$
(1)

where \(S\left( {f_{i} } \right)\) is the PSD value of a sensor signal at frequency \(f_{i}\). Equation (1) means that g(k) is defined as the root of sum of the PSD squares in the sequential frequency range from ksΔf to ((k + 1)s − 1)Δf, where Δf is the frequency resolution of the PSD. The frequency range is (s − 1)Δf and s is selected to determine the value of the frequency range. Therefore, for a sensor signal x, its feature vector, namely G(x), is composed of g(k) in Eq. (1), and given by

$${{G}}\left( x \right) = \left[ {\begin{array}{*{20}c} {g\left( 0 \right)} & {\begin{array}{*{20}c} {g\left( 1 \right)} & \cdots \\ \end{array} } & {g\left( N \right)} \\ \end{array} } \right].$$
(2)

From all available sensor signals, we have the feature given by

$${{H}} = \left[ {\begin{array}{*{20}c} {G\left( {V_{x} } \right)} & {G\left( {V_{y} } \right)} & {\begin{array}{*{20}c} {G\left( {V_{z} } \right)} & {G\left( {F_{x} } \right)} & {\begin{array}{*{20}c} {G\left( {F_{y} } \right)} & {G\left( {F_{z} } \right)} \\ \end{array} } \\ \end{array} } \\ \end{array} } \right],$$
(3)

where Vx, Vy, Vz respectively refer to spindle vibrations in XYZ directions, and Fx, Fy, Fz respectively represents cutting force signals in XYZ directions. It should be noted that each feature vector H corresponds to quality values of Ra, Pt, and RONt. Note that the feature vector H in Eq. (3) is calculated from all sensor signals in the full frequency range from 0 to 12.8 kHz.

As seen in Fig. 10 for example, the signal responds to the change of the spindle parameter by different levels in the frequency ranges. It is recalled that the change of the spindle parameter leads to the workpiece quality difference. The observation from Fig. 10 implies that the importance level of the feature components in Eq. (3) is different to the workpiece quality. Therefore, feature ranking based on the importance levels is necessary, and redundant features can be removed through just selecting top features for building machine learning models. Here, the importance level is determined by the correlation coefficient of the feature to the workpiece quality.

Rewrite H in Eq. (3) and the corresponding workpiece quality Q as follows.

$$\left\{ \begin{aligned} & {\varvec{H}} = \left[ {\begin{array}{*{20}c} {\begin{array}{*{20}c} {h_{11} } & {h_{12} } \\ {h_{21} } & {h_{22} } \\ \end{array} } & {\begin{array}{*{20}c} \cdots \\ \cdots \\ \end{array} } & {\begin{array}{*{20}c} {h_{1m} } \\ {h_{2m} } \\ \end{array} } \\ {\begin{array}{*{20}c} { \vdots } & { \vdots } \\ \end{array} } & \ddots & \vdots \\ {\begin{array}{*{20}c} {h_{n1} } & {h_{n2} } \\ \end{array} } & \cdots & {h_{nm} } \\ \end{array} } \right] \\ & {\varvec{Q}} = \left[ {\begin{array}{*{20}c} {\begin{array}{*{20}c} {\begin{array}{*{20}c} {q_{1} } \\ {q_{2} } \\ \end{array} } \\ \vdots \\ \end{array} } \\ {q_{n} } \\ \end{array} } \right], \\ \end{aligned} \right.$$
(4)

where m is the feature number, and n is the sample number. For each feature j, its correlation coefficient r(j) is calculated as

$$r\left( j \right) = \frac{{\mathop \sum \nolimits_{i = 1}^{n} \left( {h_{ij} - \mu_{j} } \right)\left( {q_{i} - \overline{q}} \right)}}{{\sqrt {\mathop \sum \nolimits_{i = 1}^{n} \left( {h_{ij} - \mu_{j} } \right)^{2} \mathop \sum \nolimits_{i = 1}^{n} \left( {q_{i} - \overline{q}} \right)^{2} } }},\quad j = 1,2, \cdots ,m,$$
(5)

where µj is the mean value of {hij}, \(\overline{q}\) the mean of Q={qi}, i=1,2,⋯, n. The feature ranking can be done by comparing r(j), j=1, 2,⋯, m.

The signal processing for the feature extraction in this section and the machine learning work in the next section are all carried out through Python programing. Additionally, the functions such as ExtraTreesClassifier for classification and ExtraTreesRegressor for regression in Python/sklearn.ensemble [24, 25], can be used to do the feature ranking and directly come up with the sorted features.

The next task is to use machine learning method with the sorted features and the corresponding quality to train a model that is subsequently used to predict the quality for another experiment which is not included in the dataset building for the previous model training. Here, the neural network algorithm will be used as the machine learning method, which is powerful in solving regression problem.

5 Modeling and prediction of R a, P t, and R ONt

All signals are segmented to several portions, as indicated in Fig. 11 as an example. Here, the segment length we used is 2 s. Features are extracted for each segment. The features have been sorted by the feature ranking method stated in the previous section. As an example, the top ten features for roundness RONt are listed in Table 2. The model training and the quality prediction with the trained model are based on top fifty features. Multi perceptron neural network [24, 26] for solving regression problem was used to build machine learning models by training on the features extracted from the experimental data.

Fig. 11
figure 11

Example of the signal with segments 1, 2, 3,⋯, Ns

Table 2 Top ten features for roundness RONt

Recall Table 1. There are eighty-one experiments in total. Each of the experiments is used for the validation of trained machine learning model, and the (feature, quality) dataset for all other experiments is used to build the model through training. The built model is then used to predict the quality value for the validation experiment. This scheme is employed to emulate real-time scenarios using all available data for training, with the purpose to have a well-trained accurate model to predict the current and online case. The final predicted quality is valued as the mean of the predicted results using the features from the segments, which refers to the mean value of Ns values predicted from the trained model. R2 score (1 means perfect) is used to evaluate the accuracy of the predictions.

The predicted Ra, Pt, and RONt are respectively shown in Figs. 1214 for total 81 experiments with comparison to the measured values. The obtained R2 score is 0.92 for roughness Ra, 0.86 for profile Pt, and 0.95 for roundness RONt. These high R2 scores show that the proposed methods of feature extraction and neural network based modelling are able to precisely predict the product qualities using the sensor signals and without using the information about the process parameters.

Fig. 12
figure 12

Predicted roughness parameter Ra compared with its measured values (R2 score: 0.92)

Fig. 13
figure 13

Predicted profile deviation Pt compared with its measured values (R2 score: 0.86)

Fig. 14
figure 14

Predicted roundness deviation RONt compared with its measured value (R2 score: 0.95)

Using only the spindle vibrations, the regression models were also built. The resultant R2 scores are all lower than using both the cutting forces and the spindle vibrations, which are 0.88 for roughness Ra, 0.77 for profile Pt, and 0.93 for roundness RONt, though for roundness, the accuracy is just slightly lowered.

6 Conclusions

The quality parameters of roughness Ra, profile Pt and roundness RONt of the workpiece machined by a lathe have been predicted with the measured spindle vibrations and cutting forces. The prediction has been accurately accomplished by modeling with neural network based machine learning technique. The feature extraction method in the frequency domain is proposed, since it has produced well-correlated features containing rich information relevant to the product qualities. The multi perceptron neural network algorithm is powerful in solving the regression problem. As such, using these effective features through the neural network algorithm, accurate models have been built for the prediction of the product qualities. Comparison has been made between the predicted and the measured quality values. The achieved R2 score is 0.92 for roughness parameter Ra, 0.86 for profile deviation Pt, and 0.95 for total roundness deviation RONt.

The developed frequency-domain feature extraction method in this paper works effectively to find rich and useful information from sensor signals, particularly for those situations where the studied performance or parameters are only sensitive to sensor signals in certain frequency ranges. It should be mentioned that using the standard time and statistical domain features such as RMS, mean, skewness, and kurtosis, etc., are also carried out for the quality prediction. However, the prediction accuracy is not as satisfactory as using the proposed feature extraction method in this paper.

Overall, the approach proposed in this paper enables the machined workpiece quality to be accurately predicted with the acquired sensor signals, and time-consuming manual measurement is no longer necessary. And the extracted feature based machine learning approach is advantageous in fast running speed and thus efficient modelling and prediction. As such, real-time monitoring on the product quality can be achieved. Considering that the used vibration and force sensors are of high cost, in the future, cost-effective sensors will be used so as to improve practical benefit. To overcome the drawback of big amount of training data needed for machine learning, as another future work, new machine learning methodologies will be studied to handle limited amount of available sensor data for training models without much sacrifice of modeling accuracy.