# IoT System for Detecting the Condition of Rotating Machines Based on Acoustic Signals
## 2 Condition Detection Algorithm
### Discrete Wavelet Transform  
The most important step in many classification problems is the extraction of features, which will be used later as a classifier input. Features are useful information in the recorded signals that can be used to distinguish different states of machines. There are several solutions offered in the literature for feature extraction with the purpose of state detection. Most of them concentrate on detecting the frequencies of the highest peaks and the amplitudes of those peaks [23]. In order to implement feature extraction procedures such as these, it is necessary to have knowledge beforehand of what the expected spectrum of the acoustic signal looks like. Therefore, generalization for different machines with different signatures is not an easy task. Another approach is to implement some sort of filter bank with adjustable boundaries that would be applied to the signals, and descriptors such as signal power or a number of peaks can be extracted from filtered outputs. Discrete wavelet transform offers a variation of such a method, and it has been demonstrated to yield promising results for feature extraction for the purpose of machine state estimation [19]. Wavelet transform (WT) is similar to short-term Fourier transform, but instead of using windowed sinusoidal functions as the basis, WT uses wavelets, which are oscillatory signals limited in time with an average value of zero. Wavelet transform of a signal \(x(t)\), \(t\in R\) is defined as  
\[X_{WT}(s,\tau)=\frac{1}{\sqrt{|s|}}\int_{-\infty}^{\infty}x(t)\psi\bigg{(} \frac{t-\tau}{s}\bigg{)}dt, \tag{1}\]  
where \(\psi(t)\) is a continuous basis function called a mother wavelet [24], \(\tau\in R\) represents a time shift and \(s\in R\) is a scaling factor used to scale mother wavelet. In this way, WT provides adjustable time-frequency resolution by changing the position (with parameter \(\tau\)) and width (with parameter \(s\)) of the basis \(\psi(t)\). The most commonly used mother wavelet is Daubechies 4-tap, which will also be used in this paper [24]. It is worth mentioning, however, that depending on the type of wavelet \(\psi(t)\), the features of the transform may differ. By adopting a discrete scaling factor \(s=2^{j},\ j=1,2,\ldots\) and discrete time shift \(\tau=2^{j}m,\ m=1,2,\ldots\) a Discrete Wavelet Transform of a discrete signal \(x(n),\ n\in Z\) is obtained, and its analytical description is  
\[X_{DWT}(j,m)=\frac{1}{\sqrt{2j}}\sum_{n=-\infty}^{\infty}x(n)\psi\left(\frac{n- 2^{j}m}{2^{j}}\right). \tag{2}\]  
It has been shown that multiresolution can be used to obtain DWT by applying a series of low-pass (LP) and high-pass (HP) filters and downsampling the output of those filters by 2 after each step, as shown in Figure 1. In this cascading filter scheme, the output of the low-pass filter is used as an input to subsequent low-pass and high-pass filters, and this is repeated \(M\) times. If N is the length of the original input signal \(x(n)\), then the maximum number of decomposition steps is \(M_{max}=\log_{2}N\). The outputs of each high pass filter are named _detailed coefficients_ of the appropriate level, and outputs of the last lowpass filter are named the _approximation coefficients_. The total number of output samples is the same as the length of the original signal, and the parameters of the filters themselves depend on the choice of the wavelet function \(\psi(n)\). The frequency band which corresponds to each level coefficient from Figure 1 is given in Table 1 (\(F_{N}\) denotes the Nyquist frequency of the signal). Every decomposition level in DWT yields information about a specific frequency band. The frequencies of interest can be analyzed by adjusting the parameter \(M\). This kind of multiresolution analysis is ideal for acoustic and vibrational signals of rotary machines because frequency bands can be adjusted (by manipulating parameters \(M\) and \(F_{N}\)) so that each band consists of one or more characteristic frequencies.