Machine Learning-Based Stator Current Data-Driven PMSM Stator Winding Fault Diagnosis

Permanent magnet synchronous motors (PMSMs) have become one of the most important components of modern drive systems. Therefore, fault diagnosis and condition monitoring of these machines have been the subject of many studies in recent years. This article presents an intelligent stator current-data driven PMSM stator winding fault detection and classification method. Short-time Fourier transform is applied in the process of fault feature extraction from the stator phase current symmetrical components signal. Automation of the fault detection and classification process is carried out with the use of three selected machine learning algorithms: support vector machine, naïve Bayes classifier and multilayer perceptron. The concept and online verification of the original intelligent fault diagnosis system with the potential of a real industrial deployment are demonstrated. Experimental results are presented to evaluate the effectiveness of the proposed methodology.


Introduction
In recent years, permanent magnet synchronous motors (PMSMs) have become increasingly popular in industrial applications [1]. This fact is associated with their high efficiency, high power density and excellent dynamic performance. These properties make the use of PMSMs in drive systems perfectly in line with the current trend of sustainable development in the industry, as it allows to meet the requirements of using highly efficient, energy-saving and environmentally friendly solutions. Moreover, significant progress in the field of microprocessor technology, power electronics and materials engineering for permanent magnets contributed to the notable popularization of PMSM drives in the robotics, automotive, transport, home appliances and aviation industries [2]. Nonetheless, even when operated in a normal environment and under rated conditions, PMSMs are exposed to various types of damage.
Taking into account the growing popularity of PMSMs, fault diagnosis and monitoring of the condition of these machines have also become an important issue. The complex and demanding operating environment, such as high temperature, vibration and humidity, makes the PMSMs even more vulnerable to failures [3]. All of the faults can lead to the interruption of the PMSM drive system operation and unexpected maintenance breaks in processes if not detected in time. Therefore, in recent years, PMSMs fault diagnosis and condition monitoring have attracted many studies [4,5].
PMSMs failures can be divided according to their type into mechanical, magnetic and electrical damages [6]. Electrical damages are mainly stator winding faults. According to the IEEE and EPRI statistics [7,8], stator winding faults represent between 36% and 66% of all electric motor failures, depending on the type and size of the machine. It makes them one of the most common faults of AC motors [9].
Stator winding faults have a very destructive character. They begin mainly as an imperceptible short circuit of single turns-interturn short circuit (ITSC) and then spread   (4) The proposal and online verification of the intelligent PMSM stator winding fault diagnosis system developed in the LabVIEW and MATLAB programming environment. The developed data-driven intelligent system has significant potential for real deployment in the industry.
The rest of the paper is organized as follows. After the introduction, Section 2 presents the impact of the stator winding fault on the waveforms of stator phase currents symmetrical components. Section 3 gives the theoretical basis of the STFT. The experimental setup is presented in Section 4. In Section 5, the stator winding fault symptoms extraction part with the use of STFT analysis is presented. The theoretical basis and training process of the selected ML based stator winding fault classifier models is presented in Section 6. In Section 7, the concept and online verification of the intelligent diagnosis system of the PMSM stator winding faults are shown. Finally, Section 8 contains conclusions resulting from the results obtained.

Impact of the PMSM Stator Winding Fault on the Waveforms of Symmetrical Components of the Stator Phase Currents
The asymmetry of the stator phase currents caused by the ITSCs in the PMSM stator winding has an impact on the values of the stator currents symmetrical components. Since there is no zero sequence component in three-phase PMSMs, only positive and negative sequence components are calculated using the following equation [44]: where: I 1 , I 2 -positive and negative stator phase current component in steady state, I sA , I sB , I sC -stator phase currents in steady state, and: a = e j 2π 3 (2) Equation (1) applies to the sinusoidal signals of the stator phase currents in a steady state. Nonetheless, PMSMs are supplied by Voltage Source Inverters (VSIs), which introducs a number of additional harmonics, causing the distortion of voltages and currents. In such cases, in order to use the classical method of symmetrical components calculation, it is necessary to filter out the disturbing harmonics or extract only the fundamental component of the supply voltage (f s ). In this paper, the second approach is used. It is based on the calculation of instantaneous values of the stator current symmetrical components using the 90 • shift operator in the time domain, according to [44]: where: i 1 , i 2 -instantaneous value of the positive and negative sequence stator phase current component, i sA , i sB , i sC -instantaneous value of the stator current in phase A, B and C, S 90 -operator of a phase shift by an angle of 90 • in the time domain.
The influence of the ITSCs on the PMSM stator winding on the positive stator phase current sequence component waveform for the nominal power supply frequency f s (rotation speed), different load torque T L levels and number of shorted turns N sh is presented in Figure 1. As shown, for each of the T L set-in the range (0-1)T N with 0.2 T N step-momentary short circuits of 1 to 5 successive turns in phase A of the PMSM stator winding are performed. Analysis of this waveform shows that the amplitude changes of the stator current positive sequence component as a result of ITSC is noticeable, but the influence of the T L level is much more significant.
The influence of the ITSCs on the PMSM stator winding on the positive stator phase current sequence component waveform for the nominal power supply frequency fs (rotation speed), different load torque TL levels and number of shorted turns Nsh is presented in Figure 1. As shown, for each of the TL set-in the range (0÷1)TN with 0.2 TN step-momentary short circuits of 1 to 5 successive turns in phase A of the PMSM stator winding are performed. Analysis of this waveform shows that the amplitude changes of the stator current positive sequence component as a result of ITSC is noticeable, but the influence of the TL level is much more significant. The unbalance of the PMSM stator phase currents caused by the ITSC are also visible in the negative sequence component [32]. The waveform of this component for the nominal fs, different TL and Nsh is presented in Figure 2. The level of TL has a much smaller impact on the value of the negative sequence amplitude compared to the positive sequence component, and more importantly, a significant increase resulting from the ITSCs is visible. It can also be observed that the higher the Nsh, the greater the increase in amplitude. However, based only on the raw waveforms of the stator phase current positive and negative sequence components, an effective diagnosis and classification of the stator winding fault would be difficult, because for the higher TL levels (TL = 0.8TN, TL = TN), the increase caused by the ITSC of a lower number of turns (Nsh = 1, Nsh = 2) is insufficient. Due to the destructive nature and high dynamics of the PMSM stator winding fault, it is necessary to detect this type of damage at the earliest possible stage. Therefore, in this study, the signal processing method (STFT) is used to extract the more sensitive symptoms (features) of the ITSC fault, also in the initial stage of the damage.

Short-Time Fourier Transform
The frequency domain representation of the signal provided by the classical FFTbased spectral analysis does not contain information about the occurrence of a particular The unbalance of the PMSM stator phase currents caused by the ITSC are also visible in the negative sequence component [32]. The waveform of this component for the nominal f s , different T L and N sh is presented in Figure 2. The level of T L has a much smaller impact on the value of the negative sequence amplitude compared to the positive sequence component, and more importantly, a significant increase resulting from the ITSCs is visible. It can also be observed that the higher the N sh , the greater the increase in amplitude.
mentary short circuits of 1 to 5 successive turns in phase A of the PMSM stator winding are performed. Analysis of this waveform shows that the amplitude changes of the stator current positive sequence component as a result of ITSC is noticeable, but the influence of the TL level is much more significant. The unbalance of the PMSM stator phase currents caused by the ITSC are also visible in the negative sequence component [32]. The waveform of this component for the nominal fs, different TL and Nsh is presented in Figure 2. The level of TL has a much smaller impact on the value of the negative sequence amplitude compared to the positive sequence component, and more importantly, a significant increase resulting from the ITSCs is visible. It can also be observed that the higher the Nsh, the greater the increase in amplitude. However, based only on the raw waveforms of the stator phase current positive and negative sequence components, an effective diagnosis and classification of the stator winding fault would be difficult, because for the higher TL levels (TL = 0.8TN, TL = TN), the increase caused by the ITSC of a lower number of turns (Nsh = 1, Nsh = 2) is insufficient. Due to the destructive nature and high dynamics of the PMSM stator winding fault, it is necessary to detect this type of damage at the earliest possible stage. Therefore, in this study, the signal processing method (STFT) is used to extract the more sensitive symptoms (features) of the ITSC fault, also in the initial stage of the damage.

Short-Time Fourier Transform
The frequency domain representation of the signal provided by the classical FFTbased spectral analysis does not contain information about the occurrence of a particular  However, based only on the raw waveforms of the stator phase current positive and negative sequence components, an effective diagnosis and classification of the stator winding fault would be difficult, because for the higher T L levels (T L = 0.8T N , T L = T N ), the increase caused by the ITSC of a lower number of turns (N sh = 1, N sh = 2) is insufficient. Due to the destructive nature and high dynamics of the PMSM stator winding fault, it is necessary to detect this type of damage at the earliest possible stage. Therefore, in this study, the signal processing method (STFT) is used to extract the more sensitive symptoms (features) of the ITSC fault, also in the initial stage of the damage.

Short-Time Fourier Transform
The frequency domain representation of the signal provided by the classical FFTbased spectral analysis does not contain information about the occurrence of a particular frequency over time. In the field of motor fault diagnosis, information about the fault time can be very useful. Based on this information, the source of the failure can be found.
The STFT overcomes the limitations of the FFT analysis. It is an extension of FFT for time-frequency domain analysis. To achieve this, the analyzed signal is divided in the time domain through temporary windows of the same width, and subsequently frequency content of each of these windows is obtained using the FFT. The size of the time window defines the resolution of time and frequency [30]. An additional advantage of STFT is its suitability for the analysis of nonstationary signals [45].
In the implementation of the STFT, a design trade-off must be made between the time and frequency resolution. A short window provides good time resolution at the expense of poor frequency resolution and vice versa. The STFT calculates the Fourier Transform (FT) of a function f (t) over a symmetrical and real window function w(t), which is translated by time t and modulated at frequency ω. The continuous domain expression of the STFT is illustrated by [46]: The magnitude of the STFT yields the spectrogram. In this investigation, the amplitudes of the spectrogram are analyzed. The spectrogram is the result of calculating the frequency spectrum of windowed signal frames. It is a three-dimensional plot of the energy of the signal frequency content as it changes over time and is expressed as follows: In the real world, signals are sampled with a fixed sampling frequency (f p ), and the FFT is computed to analyze the frequency spectrum of the signal. Therefore, Equation (4) in the discrete domain is expressed by the following equation [46]: where: N-number of FFT points, n-time domain input sample index, x[n]-input sample, w[n]-window function, H-window size (width), k-frequency index.
The key parameters of the STFT analysis that influence its result are as follows [46]: • Sampling frequency (f p ): It affects the time and frequency resolution of the STFT output. Higher f p results in better time and frequency resolution and vice versa. In this research, f p of the STFT-based ITSC symptoms extraction algorithm is set to 8192 Hz, which is typically used in modern drive systems for current measurements.

Experimental Setup
The main part of the experimental setup is a 2.5 kW PMSM supplied from a VSI and operating in the Field-Oriented Control (FOC). The loading machine is a second PMSM with nominal power equal to 4.7 kW. The real view of the laboratory stand is shown in Figure 4. The stator winding construction of the tested PMSM is specially prepared to allow for the physical modeling of the ITSCs of a selected number of turns in a phase. Each of the three phases of the stator winding consists of two coils, at 125 turns each. An illustrative diagram of the derived phase terminals of the tested PMSM stator winding is presented in Figure 5. During the experimental verification, a maximum of five turns in Phase A were short circuited, which accounted for 2% of all turns in one phase. The direct short circuits are performed by connecting the taps corresponding to the given number of turns led out on the terminal board with a wire without limiting the current in the ITSC loop with an additional resistance. The rated parameters of the tested motor are grouped in Table A1 in Appendix A.

Experimental Setup
The main part of the experimental setup is a 2.5 kW PMSM supplied from a VSI and operating in the Field-Oriented Control (FOC). The loading machine is a second PMSM with nominal power equal to 4.7 kW. The real view of the laboratory stand is shown in Figure 4. The stator winding construction of the tested PMSM is specially prepared to allow for the physical modeling of the ITSCs of a selected number of turns in a phase. Each of the three phases of the stator winding consists of two coils, at 125 turns each. An illustrative diagram of the derived phase terminals of the tested PMSM stator winding is presented in Figure 5. During the experimental verification, a maximum of five turns in Phase A were short circuited, which accounted for 2% of all turns in one phase. The direct short circuits are performed by connecting the taps corresponding to the given number of turns led out on the terminal board with a wire without limiting the current in the ITSC loop with an additional resistance. The rated parameters of the tested motor are grouped in Table A1 in Appendix A.
The stator phase currents are measured with LEM LA 25-NP multirange current transducers and are transferred to the data acquisition system, which is the National Instruments (NI) DAQ NI PXI-4492 measurement card. This measurement card is placed inside the industrial PC-NI PXI 1082. The diagnostic application is developed in a LabVIEW and MATLAB programming environment. Lenze Engineer software is used to control the tested PMSM, whereas VeriStand is used to set the load torque. The general block diagram of the experimental stand is shown in Figure 6.   The stator phase currents are measured with LEM LA 25-NP multirange current transducers and are transferred to the data acquisition system, which is the National Instruments (NI) DAQ NI PXI-4492 measurement card. This measurement card is placed inside the industrial PC-NI PXI 1082. The diagnostic application is developed in a Lab-VIEW and MATLAB programming environment. Lenze Engineer software is used to control the tested PMSM, whereas VeriStand is used to set the load torque. The general block diagram of the experimental stand is shown in Figure 6.   The stator phase currents are measured with LEM LA 25-NP multirange current transducers and are transferred to the data acquisition system, which is the National Instruments (NI) DAQ NI PXI-4492 measurement card. This measurement card is placed inside the industrial PC-NI PXI 1082. The diagnostic application is developed in a Lab-VIEW and MATLAB programming environment. Lenze Engineer software is used to control the tested PMSM, whereas VeriStand is used to set the load torque. The general block diagram of the experimental stand is shown in Figure 6.

Stator Winding Fault Features Extraction
In this research, the ITSCs symptom extraction process is realized using STFT analysis. The analyzed signals are positive and negative sequence components of the stator phase currents. In the diagnosis of electric motor faults, the application of the STFT is associated with the search for the frequency components that are sensitive to the specific

Stator Winding Fault Features Extraction
In this research, the ITSCs symptom extraction process is realized using STFT analysis. The analyzed signals are positive and negative sequence components of the stator phase currents. In the diagnosis of electric motor faults, the application of the STFT is associated with the search for the frequency components that are sensitive to the specific fault.
As previously mentioned, proper selection of the STFT window width H is essential to provide efficient fault symptoms extraction. Nevertheless, there is no single rule for selecting this value. The appropriate H value depends on the nature of the analyzed signal, measurement parameters and the specific application. In this research, the window width is set to 2048. The sampling frequency of the signal is 8196 Hz. The selection of H = 2048 allows for obtaining a sufficient resolution (0.25 s) in the time domain. The appropriate time domain resolution is extremely important in the diagnosis of the stator winding faults, because they have to be detected as fast as possible. Due to this, too wide a window (the number of samples to be collected for one cycle of STFT analysis) would delay the detection of the fault.
The STFT spectrograms of the positive sequence component of the stator phase currents for an undamaged motor and with ITSC of three turns in phase A of the stator winding are shown in Figures 7a and 7b, respectively. The spectrograms show a significant increase in the amplitude value of the frequency component corresponding to the first harmonic (f s = 100 Hz) with the increasing load torque level. There is also a noticeable increase of the 3rd harmonic (3f s = 300 Hz) amplitude value as a result of the stator winding fault. Figure 8a,b show the STFT spectrograms of the negative sequence component of the stator phase currents for the undamaged winding and for three shorted turns in phase A, respectively. By comparing the spectrograms, a significant increase in the amplitude value of the f s frequency component can be observed as a result of a short circuit.       To emphasize the main advantage of the STFT analysis-the possibility of the harmonic tracking of the faulty components during the on-line operation of the drive system, and also to compare the sensitivity to the ITSC of the amplitudes of 3f s component in the i 1 spectrogram and f s component in the i 2 spectrogram, the experimental tests for momentary short circuits (lasting 1÷2s) and increasing T L are conducted.
In Figure 9, the stator phase currents positive sequence component STFT spectrogram ( Figure 9a) and amplitude changes of the 3f s component during the online operation of the drive system and cyclic momentary short-circuiting of 1 to 5 turns at variable load torques (Figure 9b) are shown. In this scenario, the T L value is increased from 0 to T N with 0.2T N step and for each value, the ITSCs are performed. Based on the analysis of the results presented in this figure, it can be concluded that the value of the 3f s component amplitude increases with the increasing degree of stator winding fault (N sh ). However, as the T L increases, the amplitude increase is lessened. For the rated load (T L = T N ), the increase for one shorted turn is no longer visible. This is a significant limitation. 0.2TN step and for each value, the ITSCs are performed. Based on the ana presented in this figure, it can be concluded that the value of the 3fs com increases with the increasing degree of stator winding fault (Nsh). How creases, the amplitude increase is lessened. For the rated load (TL = TN), th shorted turn is no longer visible. This is a significant limitation. In Figure 10, the stator phase currents negative sequence compon gram and the fs component amplitude changes during the online oper system and the same operating conditions and stator winding states as p itive sequence component analysis are shown. In this case, the fs comp increases as a result of the stator winding fault in the entire range of the drive system operating conditions. The increase is visible also for the inc fault-for one shorted turn (Nsh = 1). Therefore, an increase in the amp quency component is a good indicator of the ITSC fault.  In Figure 10, the stator phase currents negative sequence component STFT spectrogram and the f s component amplitude changes during the online operation of the drive system and the same operating conditions and stator winding states as presented for positive sequence component analysis are shown. In this case, the f s component amplitude increases as a result of the stator winding fault in the entire range of the analyzed working drive system operating conditions. The increase is visible also for the incipient stage of the faultfor one shorted turn (N sh = 1). Therefore, an increase in the amplitude of this frequency component is a good indicator of the ITSC fault.
In order to assess the exact impact of the ITSC on the amplitude of a given frequency component and the subsequent comparison of the increases between the fault indicators extracted from positive and negative stator phase current symmetrical components, the increase in the amplitude for a given N sh in relation to the value for an undamaged motor is analyzed: where f c is the characteristic failure frequency component and A Damaged  In order to assess the exact impact of the ITSC on the amplitude of component and the subsequent comparison of the increases between t extracted from positive and negative stator phase current symmetrica increase in the amplitude for a given Nsh in relation to the value for an u is analyzed: where fc is the characteristic failure frequency component and ADamaged an amplitudes of the fc component for an damaged and undamaged moto The influence of the stator winding fault degree (Nsh) and TL on amplitude of the 3fs frequency component in the positive sequence co gram is shown in Figure 11a. The dependence on the fs value is illustra  Figure 11a. The dependence on the f s value is illustrated in Figure 11b. On the basis of the presented results, it can be concluded that the increase in amplitude of 3f s caused by the stator winding fault is significant, especially in the case of the motor operating at a rotation speed close to the rated value. Nevertheless, as the value of the f s decreases, the fault sensitivity (A DIFF ) is much lower. The same trend is visible for the increasing level of T L , which was also mentioned in the analysis of the results presented in Figure 9. In the case of the f s component amplitude increases in the negative sequence spectrogram (Figure 12  The results presented above and also thorough analysis of changes in harmonic amplitudes visible in the STFT spectrograms, caused by the stator winding faults, allowed for concluding that the component most sensitive to the ITSC is the fs amplitude in the spectrogram of the negative sequence stator phase currents component.

Machine Learning-Based Stator Winding Fault Classifiers
In this research, the automatization of the PMSM stator winding fault classification process based on the selected ML algorithms is proposed. The models under analysis are SVM, NB and MLP. This subsection covers the theoretical foundations and training process of these models. The possibility of improving the accuracy of these algorithms by tuning the hyperparameters is also presented.

SVM
SVM is an ML algorithm that is widely used in various classification problems. It was proposed in 1999 by Vladimir Vapnik [47]. The principle of SVM classification is to find the hyperplane that separates data points belonging to one class from points belonging to another class as much as possible in order to maximize the margin. This concept is shown in Figure 13.  The results presented above and also thorough analysis of changes in harmonic amplitudes visible in the STFT spectrograms, caused by the stator winding faults, allowed for concluding that the component most sensitive to the ITSC is the fs amplitude in the spectrogram of the negative sequence stator phase currents component.

Machine Learning-Based Stator Winding Fault Classifiers
In this research, the automatization of the PMSM stator winding fault classification process based on the selected ML algorithms is proposed. The models under analysis are SVM, NB and MLP. This subsection covers the theoretical foundations and training process of these models. The possibility of improving the accuracy of these algorithms by tuning the hyperparameters is also presented.

SVM
SVM is an ML algorithm that is widely used in various classification problems. It was proposed in 1999 by Vladimir Vapnik [47]. The principle of SVM classification is to find the hyperplane that separates data points belonging to one class from points belonging to another class as much as possible in order to maximize the margin. This concept is shown in Figure 13.

Nsh [-]
(a) The results presented above and also thorough analysis of changes in harmonic amplitudes visible in the STFT spectrograms, caused by the stator winding faults, allowed for concluding that the component most sensitive to the ITSC is the f s amplitude in the spectrogram of the negative sequence stator phase currents component.

Machine Learning-Based Stator Winding Fault Classifiers
In this research, the automatization of the PMSM stator winding fault classification process based on the selected ML algorithms is proposed. The models under analysis are SVM, NB and MLP. This subsection covers the theoretical foundations and training process of these models. The possibility of improving the accuracy of these algorithms by tuning the hyperparameters is also presented. SVM is an ML algorithm that is widely used in various classification problems. It was proposed in 1999 by Vladimir Vapnik [47]. The principle of SVM classification is to find the hyperplane that separates data points belonging to one class from points belonging to another class as much as possible in order to maximize the margin. This concept is shown in Figure 13. Given data input xi (i = 1, 2, …, Ns), where Ns is the number o are assumed to have two classes (binary classification), namely a p ative class. Each class is associated with a label: yi = 1 for the posit the negative class. In the case of the linearly separable data, it is po hyperplane that separates the given data [48]: where w is the Ns-dimensional normal vector of the hyperplane an In the linearly separable case, in order to find the optimal hy imum classification margin, it is necessary to solve the following [48,49]:  Taking into account the linearly inseparable data, the optimal data can be obtained as a solution to the following optimization p Given data input x i (i = 1, 2, . . . , N s ), where N s is the number of samples, the samples are assumed to have two classes (binary classification), namely a positive class and a negative class. Each class is associated with a label: y i = 1 for the positive class and y i = −1 for the negative class. In the case of the linearly separable data, it is possible to determine the hyperplane that separates the given data [48]: where w is the N s -dimensional normal vector of the hyperplane and b is a scalar.
In the linearly separable case, in order to find the optimal hyperplane with the maximum classification margin, it is necessary to solve the following optimization problem [48,49]: is subject to: Taking into account the linearly inseparable data, the optimal hyperplane separating data can be obtained as a solution to the following optimization problem [47,48]: is subject to: where ξ i is the distance between the margin and C is the error penalty. To solve this optimization problem, by introducing the Lagrange multiplier α i > 0 and subject to (12), the dual quadratic optimization problem is obtained [47,48]: is subject to: To make the linear classification possible, inner multiplication in (13) is replaced by the kernel function. The kernel functions transform the training data set, so that a nonlinear decision surface can be transformed into a linear equation in a higher dimension space. Then, the decision function is defined as follows [47,48]: There are different kernel functions used in SVMs, such as linear, polynomial and Gaussian. Choosing an appropriate kernel function is very important because the kernel defines a feature space in which the training set examples will be classified [48]. In this research linear, polynomial and Gaussian kernel functions are verified. The most popular kernel functions are defined as follows: where σ is the width of the Gaussian function and γ is the degree of the polynomial. The initial version of the SVM algorithm discussed above was used to perform a binary classification-distinguishing between two classes only. In real-world problems, more than two classes can be classified, such as different types of faults in the fault diagnosis field. Therefore, multi-class classification techniques are applied [48]. They allow for categorizing the test data into multiple class labels included in the training dataset. In this research, the One-vs-One multiclassification method is used.
Let N CL > 2 be the number of classes. The One-vs-One approach constructs N CL (N CL −1)/2 binary classifier models. An example of this classification for N CL = 3 is shown in Figure 14. The multi-class classification problem is divided into three binary classification problems. The more detailed mathematical foundations of this algorithm are discussed in [50].

NB
Due to its simplicity, efficiency and efficacy, the NB algorithm continues to be one of the top 10 algorithms in the machine learning community [50]. NB models are commonly used for classification problems. The operation principle of the NB classifier is based on Bayesian theory. It assumes that each feature of a particular class is irrelevant to other features. The NB is a probabilistic classifier. Assuming A 1 , A 2 , . . . , A m are m attributes, given a test instance x represented by an attribute value vector [a 1 ; a 2 ; . . . ; a m ], NB predicts the class label of a new instance x using the following equation [51]: where c(x) is the class label of the test instance x predicted by NB, a j is the value of the j-th attribute A j and C is the collection of all possible class labels c.
nosis field. Therefore, multi-class classification techniques are applied [48]. categorizing the test data into multiple class labels included in the training research, the One-vs-One multiclassification method is used. Let NCL > 2 be the number of classes. The One-vs-One approach construc binary classifier models. An example of this classification for NCL = 3 is sh 14. The multi-class classification problem is divided into three binary class lems. The more detailed mathematical foundations of this algorithm are dis  There are different types of Bayesian classifiers. They are divided according to the method of calculating the conditional probability P(a j |c). One of the most popular classifiers is the Gaussian Naïve Bayes (GNB). For GNB, the probability is calculated as follows: The Kernel Naïve Bayes (KNB) is also widely used in the data classification field. More detailed theoretical foundations connected with the NB algorithm can be found in [50,51].

MLP
MLP is one of the most popular types of neural networks that are utilized in the field of electrical motor fault diagnosis. Compared to the other structures of neural networks, MLPs are relatively easy to implement in embedded systems. MLPs are feedforward neural networks. They consist of the input layer, one or more hidden layers and the output layer. Each neuron in each layer is connected to a neuron in the next layer.
The structure of the MLP network has a direct impact on the effectiveness of the model. The key parameters to be set in the process of the NN model design are the number of layers, number of neurons in each layer and type of activation function. Equation (21) describes the output of an exemplary two-layer MLP network. The exemplary structure of this type of network is presented in Figure 15 [52].
The training process of the MLP model is based on the modification of the weights to minimize the objective function [52]. The two-layer MLP output signal is described as follows [39]: where x n -n-th value of the input, y k -output value of the k-th neuron, f (1) , f (2) -activation function of the 1st and 2nd layer and w-weight of the neuron in the selected layer.
ral networks. They consist of the input layer, one or more hidden layers a layer. Each neuron in each layer is connected to a neuron in the next layer. The structure of the MLP network has a direct impact on the effect model. The key parameters to be set in the process of the NN model design a of layers, number of neurons in each layer and type of activation function describes the output of an exemplary two-layer MLP network. The exemp of this type of network is presented in Figure 15 [52]. The training process of the MLP model is based on the modification to minimize the objective function [52]. The two-layer MLP output signal follows [39]:

Training Process and Offline Verification
Based on the fault indicators extracted with the use of the symmetrical components stator current STFT analysis, the input vector of the ML models consists of the amplitudes of the f s components in the positive (Af si1 ) and negative (Af si2 ) sequence components spectrograms, as well as the determined f s value: X = [Af si1 , Af si2 , f s ]. The rationale for selecting these elements of the input vector is as follows: Af si1 changes along with the T L changes, so it makes the models robust to the load changes, and Af si2 is very sensitive to the ITSC fault and f s is easy to determine and makes the models independent of the f s value.
The collected dataset consists of 1000 vectors, 70% of which are used in the training process, and the remaining 30% are used for offline tests. In the following subsections, the training process, hyperparameters tuning and offline test results of the proposed ML-based fault classifier models are presented. The accuracy of these models is compared for different parameters and the best one for each algorithm is selected.
The model accuracy defines how often predictions equal actual (true) labels. This metric indicates how accurate the developed model is in the tasks of the ITSC classification and is defined as follows: where n actual represents the number of input vectors that the selected ML model is able to classify correctly and N t is the total number of vectors in the training set.

SVM
In the design process of the SVM classifier model, it is necessary to select the appropriate kernel function. The kernel functions analyzed are Linear, Quadratic, Cubic and Gaussian function with different width. The accuracy of the model for selected cases analyzed is presented in Figure 16 and grouped in Table 1. Based on these results, it can be concluded that the highest model accuracy (96.4%) is achieved for the Gaussian kernel function with the width of σ = 0.4. priate kernel function. The kernel functions analyzed are Linear, Quadratic, Cub Gaussian function with different width. The accuracy of the model for selected cas lyzed is presented in Figure 16 and grouped in Table 1. Based on these results, it concluded that the highest model accuracy (96.4%) is achieved for the Gaussian function with the width of σ = 0.4.  In order to evaluate the effectiveness of the proposed stator winding fault classifiers in offline tests, and in the next stage, in online tests, the C EFF index is introduced. It determines the ratio of the correctly classified stator winding states to the sum of the correct classifications and misclassifications. This index is defined by the following equation: where Y C -number of correct stator winding state classifications and Y M -number of stator winding state misclassifications performed by the analyzed ML models. The response to the test vectors is shown in Figure 17. In this case, the effectiveness achieved by the SVM-based ITSC failure classifier is as high as 97.7%. There are only single misclassifications of the real PMSM stator winding state.

NB
The NB models are characterized by the function that calculates the conditional probability. The compared types of the NB classifiers are Gaussian (GNB) and Kernel Naïve Bayes (KNB) with triangle, box and Epanechnikov kernel. The accuracy of the model for each type of NB classifier is shown in Figure 18 and grouped in Table 2. Based on this, it can be concluded that the highest model accuracy (79.6%) is achieved for the KNB with the Epanechnikov kernel function. The accuracy of this model is much lower than for the model based on the SVM algorithm.
where YC-number of correct stator winding state classifications and YM-number tor winding state misclassifications performed by the analyzed ML models.
The response to the test vectors is shown in Figure 17. In this case, the effect achieved by the SVM-based ITSC failure classifier is as high as 97.7%. There are only misclassifications of the real PMSM stator winding state.

NB
The NB models are characterized by the function that calculates the conditiona ability. The compared types of the NB classifiers are Gaussian (GNB) and Kerne Bayes (KNB) with triangle, box and Epanechnikov kernel. The accuracy of the mo each type of NB classifier is shown in Figure 18 and grouped in Table 2. Based on can be concluded that the highest model accuracy (79.6%) is achieved for the KN the Epanechnikov kernel function. The accuracy of this model is much lower than model based on the SVM algorithm.

Test vector number [-]
Nsh [-]  The response of the NB model to the test vectors is shown in Figure 19. The ness of the PMSM stator winding failure classifier based on the NB model for cation is equal to 77.7%. Misclassification is also visible when distinguishing b undamaged motor (Nsh = 0) and an early stage of damage (Nsh = 1). This is a limitation, as the goal of the research is to detect the PMSM stator winding fau as possible-at a very early stage of damage.  The response of the NB model to the test vectors is shown in Figure 19. The effectiveness of the PMSM stator winding failure classifier based on the NB model for this verification is equal to 77.7%. Misclassification is also visible when distinguishing between an undamaged motor (N sh = 0) and an early stage of damage (N sh = 1). This is a significant limitation, as the goal of the research is to detect the PMSM stator winding fault as soon as possible-at a very early stage of damage.
ness of the PMSM stator winding failure classifier based on the NB model for this cation is equal to 77.7%. Misclassification is also visible when distinguishing betw undamaged motor (Nsh = 0) and an early stage of damage (Nsh = 1). This is a sign limitation, as the goal of the research is to detect the PMSM stator winding fault a as possible-at a very early stage of damage. Figure 19. Response of the NB stator winding fault classifier to the test data set.

MLP
In this investigation, the MLP structure is selected based on the constructiv proach, i.e., gradually adding neurons in hidden layers and verifying the model ac The hyperbolic tangent sigmoid activation function is applied to the activation fu and the Levenberg-Marquardt gradient algorithm is used for training purposes. Figure 20 shows the accuracy of the MLP model for the selected network stru from those that have been tested. Based on this comparison, it can be concluded t highest model accuracy (99.0%) is achieved for two MLP structures. The first one c

Test vector number [-]
Nsh [-] Figure 19. Response of the NB stator winding fault classifier to the test data set.

MLP
In this investigation, the MLP structure is selected based on the constructivist approach, i.e., gradually adding neurons in hidden layers and verifying the model accuracy. The hyperbolic tangent sigmoid activation function is applied to the activation functions and the Levenberg-Marquardt gradient algorithm is used for training purposes. Figure 20 shows the accuracy of the MLP model for the selected network structures from those that have been tested. Based on this comparison, it can be concluded that the highest model accuracy (99.0%) is achieved for two MLP structures. The first one contains two hidden layers with 9 and 15 neurons and the second one with 9 and 17 neurons. The first of these models is used in further tests because of its simpler structure. The model accuracies for each of the tested structures are grouped in Table 3.  Table 3.  The response of the MLP model to the test vectors, taking into account the rounding of the network output to the nearest integer, is shown in Figure 21. The effectiveness of  The response of the MLP model to the test vectors, taking into account the rounding of the network output to the nearest integer, is shown in Figure 21. The effectiveness of the PMSM stator winding failure classifier based on the MLP model for this verification equals 97.8%.

Summary
Comparison of the effectiveness of the analyzed ML-based classifier models for various hyperparameters allowed for selecting the models with the highest effectiveness in the classification of the PMSM stator winding condition. The average accuracies and CEFFs together with the standard deviations in five trials (for different partition of training and

Summary
Comparison of the effectiveness of the analyzed ML-based classifier models for various hyperparameters allowed for selecting the models with the highest effectiveness in the classification of the PMSM stator winding condition. The average accuracies and C EFFs together with the standard deviations in five trials (for different partition of training and test data) for these models are presented in Figure 22 and grouped in Table 4. Both the accuracy and the C EFF for the test vectors are significantly higher for the SVM-and MLP based stator winding fault classifiers, compared to the NB-based model. In the next step, online tests will be carried out in order to finally evaluate the classifier models. test data) for these models are presented in Figure 22 and grouped in Table 4. Both the accuracy and the CEFF for the test vectors are significantly higher for the SVM-and MLP based stator winding fault classifiers, compared to the NB-based model. In the next step, online tests will be carried out in order to finally evaluate the classifier models.  In this section, the proposal and online verification of the original intelligent PMSM stator winding fault diagnosis system developed in LabVIEW and MATLAB program-

Concept and Online Verification of the Intelligent Diagnosis System of the PMSM Stator Winding Faults
In this section, the proposal and online verification of the original intelligent PMSM stator winding fault diagnosis system developed in LabVIEW and MATLAB programming environment is presented. The structured flowchart of this system is shown in Figure 23. It consists of four main modules: (1) Measurement of the stator phase current signals, (2) Data acquisition, (3) Signal pre-processing and ITSC symptom extraction and (4) Inference about the PMSM stator winding state. The functionality of each of these modules is described in Table 5.

A
The first module (A) is responsible for the measurement of the diagnostic signal. In this research, the stator phase current signals are used. These signals are measured with the use of the multirange current transducers (LEM LA 25-NP).

B
The main task of the second module (B) is the stator phase current signal acquisition. It is realized by the DAQ PXI-4492 measurement card by NI, placed in the industrial PC (NI PXI 1082). From the software point of view, the link between the DAQ card and the diagnosis system is realized with the use of the DAQ assistant block available in the LabVIEW environment.

C
The third module (C) plays a key role in the structure of the developed PMSM stator winding fault diagnosis system. It is responsible for the symmetrical current components calculation, their STFT analysis and also for the symptoms (amplitudes of the characteristic frequency components) extraction. In addition, the online tracking of the selected amplitudes Af s1 , Af s2 and the determination of power supply frequency f s is realized here.

Conclusions
This paper proposes an original intelligent PMSM stator winding fault diagnosis system based on the hybrid method that combines the STFT analysis of the stator phase current symmetrical components and selected ML algorithms. On the basis of the conducted The highest C EFF index of 96.1% is achieved by the SVM-based PMSM stator winding fault classifier. The NB model achieved a significantly lower effectiveness, amounting to 67.4%. The MLP model achieved a slightly lower effectiveness, amounting to 97.8%. Therefore, it can be stated that the SVM-and MLP-based models can be successfully applied in the last module (D) of the developed stator current data-driven intelligent stator winding fault diagnosis system. The effectiveness achieved by the fault classifier based on the NB algorithm is insufficient for the implementation of effective diagnostics. The relatively low effectiveness of the NB-based classifier may be caused by the fact that the operation principle of this algorithm assumes that each feature of a particular class is irrelevant to other features. In the case of fault diagnostics and the proposed input vector, its elements are interrelated.

Conclusions
This paper proposes an original intelligent PMSM stator winding fault diagnosis system based on the hybrid method that combines the STFT analysis of the stator phase current symmetrical components and selected ML algorithms. On the basis of the conducted experimental tests, it is proven that the amplitude value of fundamental frequency component (f s ) in the STFT spectrogram of the negative sequence component of the stator phase current is a very good indicator of PMSM stator winding fault. This indicator is susceptible to ITSC in a wide range of tested motor operating conditions and for the incipient stage of the fault.
The effectiveness of the automatic inference about the state of the PMSM stator winding has been verified for three ML-based models: SVM, NB and MLP. The input vector of these models was built based on an in-depth analysis of the STFT results. Experimental studies have shown that the SVM-and MLP-based PMSM stator winding faults classifier are characterized by much higher model accuracy and classification effectiveness compared to the NB. A significant influence of the model key parameters on their accuracy has also been proven. It is shown that the model design process should be carried out carefully.
The proposed stator phase current data-driven intelligent stator winding fault diagnosis system has potential for real deployment in the industry. This system has a modular structure, which allows it to be scalable and easy to modify. The proposed methodology can be improved to detect other motor faults by the adaptation of the ML for more advanced multi-fault-classification task.
Further research will focus on the development of a low-cost diagnostic system based on the proposed concept, but with the use of less expensive components. An attempt will be made to implement the described software in one of the low-budget microcontrollers. In addition, to evaluate the possibility of using information from several, different ML-based models in parallel in order to improve the effectiveness of the entire system through the use of ensemble learning technique is being planned.
Author Contributions: All of the authors contributed equally to the concept of the paper and proposed the methodology; investigation and formal analyses, P.P. and M.W.; software and data curation, P.P.; measurements, P.P. and M.W.; proposed the paper's organization, P.P. and M.W.; validated the obtained results, M.W. All authors have read and agreed to the published version of the manuscript.