# Machine Tools Anomaly Detection Through Nearly Real-Time Data Analysis

^{1}

^{2}

^{3}

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Industrial Context and Infrastructure

#### 2.1. Data Description

- The machine’s CNC and PLC parameters,
- The vibrations of the spindle, the ball screws and the pinion racks,
- The state of the oil and temperature,
- Information on the hydraulic system,
- The energy consumption of the machine components, and
- The alarms and warnings provided by the machine.

- User-defined variables: These variables are provided directly or indirectly by the user. These variables include: the name of the CNC program, code of the tool in use, or commanded axis position
- Analog-input variables: These variables cannot be directly controlled by the user. On the other hand, they are gathered from different machine monitoring sensors. These variables record different machine parameters, such as component temperature, electric power consumption, or real axis position rather than commanded.

**actions**that the machine is ordered to perform, whether it is through direct commands or through automated routines, while the second group representing the

**reactions**of the machine to the actions performed.

#### 2.2. Implementation

## 3. Methods

#### 3.1. Data Segmentation

`Cnc_Program_Name_RT`. A CNC program is a list of commands that are executed one line (also called blocks) at the time. The number of program line being executed at each moment is stored in the variable

`Cnc_Program_BlockNumber_RT`.

**operation**.

`Cnc_Tool_Number_RT`.

**in production**if the axes are moving or the spindle is spinning or the axes are moving, along with the program name being non-null and the block and tool number being neither null nor zero.

**operation**is defined as a sequence of time where

- the program name does not change,
- the tool number does not change, and
- the machine does not stay without production for more than 600 seconds.

**operations of the same type**if the three following conditions are fulfilled:

- ${P}_{i}={P}_{j}$ (same program),
- ${T}_{i}={T}_{j}$ (same tool), and
- $\left(\right)open="["\; close="]">\mathrm{min}{B}_{i},\mathrm{max}{B}_{i}\ne \varnothing $ (intersection of block extrema intervals).

#### 3.2. Overview of Techniques

`Spindle_Power_percent`. This variable represents the percentage of electrical power that is using the Spindle with respect to its nominal power (in this particular case, 81 kW).

#### 3.2.1. Dynamic Time Warping

**alignment**between U and V as a set of tuples $\mathcal{T}=\left\{\right(u,v\left)\right\}$ with $u\in U$ and $v\in V$ that fulfills the following conditions:

- $({u}_{1},{v}_{1})\in \mathcal{T}$,
- $({u}_{N},{v}_{M})\in \mathcal{T}$,
- if $\forall i,j,{j}^{\prime}$, if $({u}_{i},{v}_{j})\in \mathcal{T}$ and $({u}_{i+1},{v}_{{j}^{\prime}})\in \mathcal{T}$, then ${j}^{\prime}\ge j$ and
- if $\forall i,j,{i}^{\prime}$, if $({u}_{i},{v}_{j})\in \mathcal{T}$ and $({u}_{{i}^{\prime}},{v}_{j+1})\in \mathcal{T}$, then ${i}^{\prime}\ge i$.

#### 3.2.2. Hierarchical Clustering Techniques

**clusters**. A family of subsets ${\left\{{S}_{i}\right\}}_{i=1}^{N}$ is a

**partition into clusters**of S if they are mutually disjointed and their union is equal to S. A distance function

**linkage function**of the algorithm. Then, the algorithm goes as follows:

- It starts from a partition of S where each element of S forms a single cluster.
- Each step it takes the two clusters for which D is minimized and combine them into a single cluster. If there is more than one possible choice, select randomly.
- Repeat until there is a single cluster that contains the whole set S.

**single-linkage**clustering the linkage function is the following:

**height**of the dendogram. If S has N elements, ${h}_{i}$ denotes the height of the dendogram for each step of the algorithm, having a total of $N-1$ heights. This sequence is strictly non-decreasing.

#### 3.3. Anomaly Detection

**anomalous**with respect to the previous ones by using this criterion: Let $S=\{{s}_{1},\cdots ,{s}_{N},{s}_{N+1}\}$ be a sequence of time series belonging to different executions of operations of the same type, and let $H=\{{h}_{1},\cdots ,{h}_{N-1},{h}_{N}\}$ be the ordered set of heights of the dendogram resulting from applying the single-linkage clustering algorithm to these series. Then, ${s}_{N+1}$ is anomalous with respect to the previous one if the following two conditions apply:

- After dividing S in two clusters, ${s}_{N+1}$ is alone in one cluster and the rest are in the other.
- ${h}_{N}$ is anomalous with respect to ${h}_{1},\cdots ,{h}_{N-1}$. A good criteria is that ${h}_{N}$ is anomalous if ${h}_{N}>\mu +\sqrt{10}\sigma $ where $\mu $ and $\sigma $ are the mean value and standard deviation of $\{{h}_{1},\cdots ,{h}_{N-1}\}$. The scalar $\sqrt{10}\approx 3.16$ is chosen according to Chebyshev’s inequality, by which, if ${h}_{N}$ comes from the same distribution as the rest of ${h}_{i}$’s, its probability of being outside $[\mu -\sqrt{10}\sigma ,\mu +\sqrt{10}\sigma ]$ is smaller than 0.1.

## 4. Results

## 5. Discussion

- The first limitation of this methodology is the assumption that the machine user is going to always use the machine the same way. If the machine user follows best practices, changes in the CNC program should imply a new release and a new program name where the release number is indicated, however, this cannot always be assured. This situation could lead to misclassification of operations, and therefore to false negatives or false positives when detecting anomalous behaviors. As long as good practices are followed, this algorithm should be robust enough to be trusted.
- Another limitation of this work (and a path for possible future work) comes from the batch-like nature of the architecture. Data are downloaded and operations are segmented each number of minutes, and an operation is only analyzed (that is, compared with previous executions of the same operation) when it has finished. Due to this, if a very severe anomaly takes place, it might take some minutes until the system detects it. Regarding this limitation, when very severe anomalies happen there are usually other ways to be aware of them, including manual thresholds; the main target of this approach is to detect changes that might not be severe per se, but do imply a change in the way the machine is working, so the gap of a few minutes until it is detected does not make a large difference.

## 6. Conclusions and Future Work

- The developed methodology introduced in this paper takes industrial manufacturing a step further towards the Smart manufacturing and the Industry 4.0 paradigm.
- It allows machine operators to obtain a nearly real-time diagnosis of the production process.
- It permits a thorough scrutiny of so far unsupervised production parameters either pneumatic, hydraulic and/or electronic as far as production information can be analyzed and consolidated from an assortment of sensors.
- Rapid differentiation between anomalous and normal manufacturing processes is made possible via comparison between nearly real-time collected data and stored sequences from previous manufacturing cycles or theoretical ones developed by the hardware vendors.
- Manufacturing equipment can be preventively maintained as production anomalies are detected in advance.
- Collaborative manufacturing, one of the most important aims of Smart manufacturing and Industry 4.0, is put forward by the methodology summarized in this article.

- Apply the knowledge acquired during the pattern detection process, which allows the detection of other behaviors, anomalies or wear, in critical elements of the machine and therefore allows for the avoidance of unscheduled stops or long periods of inactivity of the machine.
- Improvement of the visualization is proposed, adapting more to the process focusing on the operator at the foot of the machine, allowing him to have a diagnosis at all times.
- Validate the model when there is no continuity in the processes, that is, when serial pieces are not made. By having more diverse information, there is not so much specific information about the process, which can be a great barrier to developing a reliable model.
- Use mixed models of deep learning and machine learning and combining them with DTW to improve the model, as well as different methodologies that can be adjusted to the problems that may appear.
- Using deep learning techniques to be able to implement a predictive model. Currently making a predictive model in real time is very complex due to the limitations offered by the numerical control. It must be taken into account that it is not the task of the CNC to have to perform such tasks.
- In order to improve the response time to anomalies, early classification techniques for time series [27] will be considered so that anomalous behavior can be detected before the operation has finished.

## Author Contributions

## Funding

## Conflicts of Interest

## Abbreviations

API | Application Programming Interface |

CNC | Computer Numerical Control |

DBSCAN | Density-Based Spatial Clustering of Applications with Noise |

DTW | Dynamic Time Warp |

IIoT | Industrial Internet of Things |

IoT | Internet of Things |

PLC | Programmable Logic Controller |

## References

- Moldovan, L.; Gligor, A. Foreword Global trends in manufacturing technologies which create a path to tomorrow’s innovations. Procedia Manuf.
**2018**, 22, 1–3. [Google Scholar] [CrossRef] - Directorate-General Internal Market, Industry, E.; SMEs. Digital Transformation Monitor Germany: Industrie 4.0; Technical Report; European Comission: Brussels, Belgium, 2017. [Google Scholar]
- Schleinkofer, U.; Klöpfer, K.; Schneider, M.; Bauernhansl, T. Cyber-physical Systems as Part of Frugal Manufacturing Systems. Procedia CIRP
**2019**, 81, 264–269. [Google Scholar] [CrossRef] - Vaidya, S.; Ambad, P.; Bhosle, S. Industry 4.0—A Glimpse. Procedia Manuf.
**2018**, 20, 233–238. [Google Scholar] [CrossRef] - Boyes, H.; Hallaq, B.; Cunningham, J.; Watson, T. The industrial internet of things (IIoT): An analysis framework. Comput. Ind.
**2018**, 101, 1–12. [Google Scholar] [CrossRef] - Aberdeen Group; Cline, G. Towards Industry 4.0: An Overview of European Strategic Roadmaps; Technical Report; IBM: Aberdeen, UK, 2010. [Google Scholar]
- Santos, C.; Mehrsai, A.; Barros, A.; Araújo, M.; Ares, E. Towards Industry 4.0: An overview of European strategic roadmaps. Procedia Manuf.
**2017**, 13, 972–979. [Google Scholar] [CrossRef] - Gerrikagoitia, J.; Unamuno, G.; Urkia, E.; Serna, A. Digital Manufacturing Platforms in the Industry 4.0 from Private and Public Perspectives. Appl. Sci.
**2019**, 9, 2934. [Google Scholar] [CrossRef] - Dalenogare, L.S.; Benitez, G.B.; Ayala, N.F.; Frank, A.G. The expected contribution of Industry 4.0 technologies for industrial performance. Int. J. Prod. Econ.
**2018**, 204, 383–394. [Google Scholar] [CrossRef] - Lee, J.; Kao, H.A.; Yang, S. Service Innovation and Smart Analytics for Industry 4.0 and Big Data Environment. Procedia CIRP
**2014**, 16, 3–8. [Google Scholar] [CrossRef] - Detecting CNC Anomalies with Unsupervised Learning (Part 1). Available online: https://medium.com/machinemetrics-techblog/using-pca-and-clustering-to-detect-machine-anomalies-part-1-ba89f6a6a8cd (accessed on 6 November 2019).
- Zhang, L.; Elghazoly, S.; Tweedie, B. Introducing AnomDB: An Unsupervised Anomaly Detection Method for CNC Machine Control Data. Proc. Annu. Conf. PHM Soc.
**2019**, 11. [Google Scholar] [CrossRef] - Hyndman, R.J.; Wang, E.; Laptev, N. Large-Scale Unusual Time Series Detection. In Proceedings of the 2015 IEEE International Conference on Data Mining Workshop (ICDMW), Atlantic City, NJ, USA, 14–17 November 2015; pp. 1616–1619. [Google Scholar] [CrossRef]
- Liang, Y.; Wang, S.; Li, W.; Lu, X. Data-Driven Anomaly Diagnosis for Machining Processes. Engineering
**2019**, 5, 646–652. [Google Scholar] [CrossRef] - DEmilia, G.; Gaspari, A.; Hohwieler, E.; Laghmouchi, A.; Uhlmann, E. Improvement of Defect Detectability in Machine Tools Using Sensor-based Condition Monitoring Applications. Procedia CIRP
**2018**, 67, 325–331. [Google Scholar] [CrossRef] - Żabiński, T.; Mączka, T.; Kluska, J.; Madera, M.; Sep, J. Condition monitoring in Industry 4.0 production systems—The idea of computational intelligence methods application. Procedia CIRP
**2019**, 79, 63–67. [Google Scholar] [CrossRef] - Yin, S.; Ding, S.X.; Xie, X.; Luo, H. A Review on Basic Data-Driven Approaches for Industrial Process Monitoring. IEEE Trans. Ind. Electron.
**2014**, 61, 6418–6428. [Google Scholar] [CrossRef] - Klartext Portal. Available online: https://www.klartext-portal.com (accessed on 23 October 2019).
- ISO 6983-1:2009. Available online: https://www.iso.org/standard/34608.html (accessed on 23 October 2019).
- Jeong, Y.S.; Jeong, M.K.; Omitaomu, O.A. Weighted dynamic time warping for time series classification. Pattern Recogn.
**2011**, 44, 2231–2240. [Google Scholar] [CrossRef] - Maimon, O.; Rokach, L. Data Mining and Knowledge Discovery Handbook, 2nd ed.; Springer: New York, NY, USA, 2010. [Google Scholar]
- Lin, J.; Williamson, S.; Borne, K.; DeBarr, D. Pattern Recognition in Time Series. Adv. Mach. Learn. Data Min. Astron.
**2012**, 1, 617–645. [Google Scholar] [CrossRef] - Git Repository for This Work. Available online: https://gitlab.danobatgroup.com/gherranz/pattern-recognition (accessed on 29 November 2019).
- Ester, M.; Kriegel, H.P.; Sander, J.; Xu, X. A Density-based Algorithm for Discovering Clusters a Density-based Algorithm for Discovering Clusters in Large Spatial Databases with Noise. In Proceedings of the Second International Conference on Knowledge Discovery and Data Mining; AAAI Press: Palo Alto, CA, USA, 1996; pp. 226–231. [Google Scholar]
- Candès, E.J.; Li, X.; Ma, Y.; Wright, J. Robust Principal Component Analysis? J. ACM
**2011**, 58, 11:1–11:37. [Google Scholar] [CrossRef] - Hyndman, R.J. Computing and Graphing Highest Density Regions. Am. Stat.
**1996**, 50, 120–126. [Google Scholar] [CrossRef] - Mori, U.; Mendiburu, A.; Miranda, I.; Lozano, J. Early classification of time series using multi-objective optimization techniques. Inf. Sci.
**2019**, 492, 204–218. [Google Scholar] [CrossRef][Green Version]

**Figure 2.**(

**a**) Evolution in time of

`Cnc_Program_BlockNumber_RT`. (

**b**) Segmentation of two executions of the same program by operation.

**Figure 5.**(

**a**) Example of analysis with no anomalous executions. (

**b**) Example of analysis with one anomaly.

**Figure 6.**(

**a**) Spindle power during executions with no anomalies. (

**b**) Spindle power for executions where one is anomalous.

**Figure 7.**(

**a**) Representation of the one cosine (red) and nineteen sines (grey). (

**b**) Application of [12] to these series.

Name | Description | Unit |
---|---|---|

Timestamp | Time of the data acquisition | YYYY/MM/DD hh:mm:ss |

Axis_FeedRate_actual | Tool Feed Rate | mm/min |

Cnc_Program_Name_RT | Program Name | |

Cnc_Block_Number_RT | Program Line Number | |

Cnc_Tool_Number_RT | Tool Code Number | |

Spindle_Power_percent | Spindle Power consumption | % |

Spindle_speedActual_rpm | Spindle angular velocity | rpm |

timestamp | Spindle_Power_percent | Cnc_Program_Name_RT | … |
---|---|---|---|

2019-04-01 19:00:00 | 100 | Program1 | … |

2019-04-01 19:00:01 | 101 | Program1 | … |

2019-04-01 19:00:02 | 99 | Program1 | … |

© 2019 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Herranz, G.; Antolínez, A.; Escartín, J.; Arregi, A.; Gerrikagoitia, J.K.
Machine Tools Anomaly Detection Through Nearly Real-Time Data Analysis. *J. Manuf. Mater. Process.* **2019**, *3*, 97.
https://doi.org/10.3390/jmmp3040097

**AMA Style**

Herranz G, Antolínez A, Escartín J, Arregi A, Gerrikagoitia JK.
Machine Tools Anomaly Detection Through Nearly Real-Time Data Analysis. *Journal of Manufacturing and Materials Processing*. 2019; 3(4):97.
https://doi.org/10.3390/jmmp3040097

**Chicago/Turabian Style**

Herranz, Gorka, Alfonso Antolínez, Javier Escartín, Amaia Arregi, and Jon Kepa Gerrikagoitia.
2019. "Machine Tools Anomaly Detection Through Nearly Real-Time Data Analysis" *Journal of Manufacturing and Materials Processing* 3, no. 4: 97.
https://doi.org/10.3390/jmmp3040097