Non-invasive real-time diagnosis of PMSM faults implemented in motor control software for mission critical applications

The machine ’ s health should be continuously monitored, or a test should be applied on a regular basis to predict failure before fatal damage is incurred. Unexpected failures, particularly in mission-critical applications, can cause irreversible damage to the system, or even human life. This paper introduces a novel non-intrusive, real-time, online Condition Monitoring (CM), and Fault Diagnosis (FD) system for Permanent Magnet Synchronous Machines (PMSMs). Only the motor drive ’ s built-in sensors, such as current and position sensors, are used to detect three types of faults: inter-turn short circuit, partial demagnetization, and static eccentricity. It encompasses the implementation of algorithms within a motor drive system and the creation of failure mode models. The proposed solution adopts a hardware-free approach, utilizing current/voltage signature analysis for cost-effectiveness. It requires a small memory and short execution time, allowing it to be implemented on a simple motor controller with limited memory and calculation power. The drive system is intended for mission critical applications, therefore, computation load, code size, memory allocation, run-time optimization, etc. are the key focuses for real-time operation. It offers immediate insights into motor ’ s health without interrupting the drive operation. Additionally, it ensures rapid processing with modest computational requirements, making it adaptable for implementation on any PMSM controller. The non-intrusive nature of this diagnostic approach has the potential to enhance safety in systems reliant on PMSM drives. The proposed method has a high detection accuracy of 98%, is computationally efficient and can detect and classify the fault accurately. Simulation and experimental results demonstrate the efficiency of the FD algorithm for online identification and classification of machine faults. Theoretical hypotheses are proven based on experimental data.


Condition monitoring and fault diagnosis overview
Permanent magnet synchronous motors (PMSM) are widely used in medical, military and aerospace applications because of their easy and precise speed and position control [1].These applications necessitate a high level of reliability and safety.Electrical motors are exposed to external stresses such as vibration and high thermal cycles, resulting in various problems.To minimize disastrous system damage, these faults should be detected and diagnosed in early stages [2].Condition monitoring (CM) and fault diagnosis (FD) are required to prevent minor faults from progressing to complete malfunction [3].
State-of-the-art investigations revealed that signature-based methods were more frequently used in CM and FD of electrical motors because they use well-known motor signatures, such as harmonic analysis, and are easy to apply.As an illustration, the analysis of mechanical vibration signals proves valuable in the diagnosis of faults in PMSMs.Rafaq et al. employed an accelerometer to assess vibration harmonics, successfully identifying mass unbalance faults in PMSMs [4].
Although their method was accurate in fault detection, it requires an additional sensor and verified by offline calculations.Measuring mechanical signals generally requires additional sensors, therefore electrical signals are more suitable for condition monitoring.
The most common electrical signature-based method is Motor Current Signature Analysis (MCSA).For example, the authors in [5] and [6] applied frequency response analysis to the stator current of the PMSMs to detect the Inter Turn Short Circuit Fault (ITSCF).Despite the fact that their methods are non-invasive and can distinguish between healthy and faulty motors, investigations on a real time motor drive system were not presented.A comparison between spectral analysis and wavelet transform methods was presented in [7] to find the optimal fault indictors for one turn short circuit fault based on stator phase current and current phase envelope.In a recent development, the authors in [8], introduced a technique to identify ITSFs in an induction machine by analysing spectrograms of motor currents.The proposed fault detection method was thoroughly investigated in terms of complexity, cost-effectiveness, computational load, generality, and accuracy.Nevertheless, it is noteworthy that the method has not been implemented on a low-cost microprocessor.Instead, the algorithm operates offline, with computations carried out on a PC equipped with an Intel Core i7 processor.In [9], an FPGA-based motor control and CM algorithm was introduced.Exploiting the parallel operation capability of FPGA, MCSA was performed easily, and harmonic content of the phase currents were calculated.However, it is not presented how this information can be used for real-time CM.Harmonic current injection method was also applied in [10] to detect ITSCF on a real-time system, but specialised hardware is required to inject high frequency current into the motor phases.This brings additional cost and more challenging to implement on any motor drive system.In [11], the detection of ITSCF and rotor misalignment faults relied on current residual variance.Despite being described as computationally low-cost, the study lacks real-time implementation or a comparison with alternative methods.In [12], a fluxgate sensor was employed to monitor the stray magnetic field around the PMSM for ITSCF detection.Although the study encompasses modelling, simulation, and experimental verification, it primarily focuses on faults and necessitates the insertion of an additional flux sensor into the machine, posing a disadvantage.External leakage flux sensors were also utilized in [13] for online detection of Stator Eccentricity Faults (SEF); however, the publication does not present the implementation of the proposed algorithm.Similarly, the proposed solution is deemed disadvantageous for the same reason [13].
The literature also uses MCSA to investigate the Partial Demagnetization Faults (DEF), and Static Eccentricity Faults (SEF).However, a complete practical solution for CM and FD of ITSCF, DEF, and SEF is omitted.The Vold-Kalman filter was used in [14], to track the DEF of the PMSMs.In non-stationery conditions, only related harmonics of the stator current were observed to track the DEF [1].Non-invasive SEF detection method based on frequency response analysis of the stator current was presented in [15].Simulation results were only presented in this study to detect the level of SEF.Motor Voltage Signal Analysis (MVSA) has also been investigated in the literature.For example, stator voltage was used in ITSCF detection by the authors in [16].The main drawback of this method is requiring access to stator voltage in DQ frame [1].In [17], the current and voltage signals of the stator were used to detect the DEF in PMSM.The obtained simulation results based on continues wavelet transform and Fourier analysis shown that stator current and stator voltage analysis are useful for accurate DEF detection.The proposed method conducted by Orji et al. involves monitoring the health status of a motor non-intrusively by observing line currents and processing them.However, the study lacks fault classification, and the method, despite being non-intrusive, mandates additional expenses for current sensors and analog filters, introducing additional costs to the system.Additionally, the location of the calculations and the determination of the machine's health status and fault type remain unclear [18].
The literature has also offered various other signal analysis techniques, including those that use motor speed, vibration, acoustics, magnetic flux, etc.For instance, the motor speed signal was used in [19] to apply a particle filter-based magnetic flux estimating approach.Knowing the flux density allows one to assess the rotor magnets' state of health.The measurement of magnetic flux can be accomplished using analog hall sensors, as demonstrated in the research conducted in [20].While these sensors provide precise measurements of flux density in the motor, specifically for detecting demagnetization and eccentricity faults, the limited prevalence of analog magnetic sensors in motor design hinders the widespread applicability of the fault detection algorithm.In a more recent investigation by Skarmoutsos et al., partial demagnetization faults are identified through the motor's speed and induced electromotive force (EMF) in a supplementary winding [21].Although the method is validated through simulations and experiments, the primary drawback lies in the requirement for additional hardware.
Model-based techniques are less sensitive to transients than signature analysis, allowing them to be more accurate, but they require specific motor and drive system parameters to produce reliable results [22].Even if the parameters are accurate, model-based techniques may not be suitable for low-cost motor drivers due to their computational load.In [23], a Simulink model was established to extract features of the demagnetization faults on PMSMs.Support vector regression method was used to detect the level of the fault but the proposed algorithm was not verified experimentally on a real system.Zhu et al. [24] estimated the rotor flux linkage by a torque ripple model of PMSM.Their method was proven experimentally at different speed and load levels, but it was an incomplete work because it did not take ITSCF and SEF into account.In [25], effect of SEF on the inductances of a machine was examined through a mathematical model.Then the model was verified by FEA, but a FD algorithm was not introduced to apply on a real system.The authors in [26], employed a model-based approach to estimate the Q and D axis inductances of a machine for detecting ITSCF.The authors assert that their algorithm can detect ITSCF both at startup and during operation through online monitoring.Nevertheless, the study lacks a detailed explanation of the online functionality of the algorithm and does not provide information on the computational burden associated with the method.While mathematical modelling, FEA and experimental verification are very common in the literature, only a few have implemented their methods to real motor drive systems and proposed practical solutions to the realization of CM and FD algorithms in a limited environment, such as a digital signal processor (DSP) or a microprocessor.
AI-based approaches have lately gained popularity and they often provide generic CM and FD solutions that are not particular to the system or motor.For instance, Saucedo-Dorantes et al. conducted a comprehensive investigation aimed at detecting three simultaneous rotor faults in IM [27].Here, a high-dimensional set of hybrid features derived from motor currents and a vibration sensor mounted on the motor was utilized, introducing additional costs to the drive system.While the proposed method's accuracy is confirmed through experiments, it is noteworthy that the study does not feature implementation on a low-cost microprocessor for online CM.In [28], a recurrent neural network (RNN) model for ITSCF detection was developed.Three-phase current and rotational speed were selected as input features and fed to the RNN for training and FD.Although the authors validate their theory experimentally and detect the fault and its severity accurately without using external sensors, their work covers only ITSF detection, and the computational burden of the AI algorithm makes it difficult to implement on a low-cost microprocessor.Similarly, Song et al. employed a Convolutional Neural Network (CNN) to estimate ITSCF in PMSM through post-processing motor signals.However, the study does not provide details on the implementation of the proposed method on a realtime, low-cost processor [29].In a related context, Maraaba et al. utilized CNN for ITSCF detection in PMSMs, training the algorithm with real motor data and conducting experimental testing.Notably, the method operates offline on a computer rather than on the processor of a motor driver [30].A multi-layer perceptron based diagnostic method was presented in [31] and [32].The extraction of the features was performed using spectral analysis.In [17], a deep convolutional neural network (CNN) called a lifting net was combined with a secondgeneration wavelet transforms for mechanical fault classification.Wen et al. [33]  based methods have the disadvantages of requiring more computational resources than model-based techniques and must be trained in several different systems over a long time.Also, there is no such research that focuses on ITSF, DEF and SEF at the same time.
In this paper, current and voltage signatures have been used for real time CM and FD of PMSM.The faults were mathematically modelled, and then simulations and experiments were performed to validate the derived models.The experiments were conducted on a PMSM drive system with field-oriented control fed by a voltage source inverter.It must be emphasized that the data has been collected in a closed loop speed-controlled system including an inner current control loop.The majority of previous research relied on ideal conditions and open-loop setups to gather data that could be used for modelling and parameter estimation to detect faults but neglected to consider the impact of the actual closed-loop operation on current/voltage signatures, which would have a direct effect on the fault detection accuracy.The influence of measurement noise has also been ignored.
The most prevalent failures on PMSMs include stator ITSCF, nonuniform demagnetization of permanent magnets, and static rotor eccentricities [34], all of which are investigated in this work.To the best of authors knowledge, most of the research focuses only on one or two types of faults.

Contributions and paper structure
Given the recent developments presented in the literature, several challenges have been established in online and real-time CM and FD techniques for the motor drive, particularly in mission-critical applications.These necessitate the integration of the FD algorithm into the motor drive software to provide a degree of drive system CM.In such applications, the FD algorithm must be independent of the motor control software.The FD algorithm's computation load should be low, and FD tasks should allocate a predetermined amount of memory such that the tasks can function independently, allowing software bugs to be isolated [35].All of above challenges were considered in the development and implementation of the proposed CM and FD algorithm.
In existing literature, many PMSM fault diagnosis techniques fail to address the potential for hardware implementation, often requiring additional hardware or expensive software [1].To mitigate this limitation, it is crucial to prioritize the integration of FD algorithms on DSPs or low-cost microcontrollers, ideally harmonized with motor control software.This study introduces a comprehensive, non-invasive, online, and real-time CM and FD solution.The unique contribution lies in implementing the algorithm directly on a real motor drive system, accompanied by mathematical models of various failure modes.This research significantly enhances the reliability and safety of mission-critical systems by enabling the detection of faults in PMSMs.By issuing timely warnings to users before the system necessitates shutdown, it effectively prevents unexpected failures and operational disruptions.The key advantages of this proposed solution are as follows: • The solution utilizes current and voltage signature analysis without the need for additional hardware, ensuring a highly cost-effective implementation.• It furnishes immediate and accurate information on the motor's health without disrupting the normal operation of the drive system.• The algorithm seamlessly integrates into the motor drive system, relying exclusively on the motor drive's built-in sensors.• Operating swiftly and consuming only a modest amount of CPU resources, the solution can be readily implemented on any PMSM controller equipped with current and position sensors.This facilitates the straightforward integration of the proposed CM and FD algorithm into existing systems.
This paper is set out as follows: Section II presents detailed modelling and simulation of PMSM faults.Section III discusses the experimental validation of the proposed CM and FD algorithm, which includes three types of faults: inter-turn short circuit, partial demagnetization, and static eccentricity, while Section IV discusses the real time implementation of the proposed CM and FD blocks into the DSP.Finally, conclusions from the work are outlined in Section V.

Analytical modelling and simulations of PMSM faults
The three key faults investigated in this study are stator inter-turn short circuit faults, non-uniform permanent magnet demagnetization faults, and rotor static eccentricity faults.The effects of failure modes are mathematically modelled, and each fault is simulated using an ANSYS Maxwell simulation.The electrical and mechanical properties of the PMSM and the motor drive are listed in Table 1.

Stator inter-turn short circuit faults
Stator ITSC faults can occur from high voltage stresses caused by the motor's fast-switching control, and excessive heating due to overloading or fabrication faults in the windings or insulation layer [36].

Analysis of stator itsc faults
Fig. 1 shows a simplified electrical equivalent circuit of stator windings for a Y-connected PMSM with ITSCF [37].Stator voltage for the faulty PMSM in a stationary ABC reference frame can be written as [2] where ) )

Table 1
Electrical and mechanical parameters of the test motor and the motor drive.
The phase voltage can also be written independently to study the effect of the fault on each phase as According to aforementioned phase voltage equations, faulty motor equations differ from those for a healthy motor as they include i f .It is logical that if there is no fault, i f equals zero, and ( 5) to (7) remain true for healthy motors.Considering root-mean-square (RMS) phasor values of phase voltages, ( 5) to (7) can thus be re-written as Here, V base,RMS is the common term for all phases.The amplitude of the difference between the RMS voltages of faulty and healthy phases is described in (11).
Now, when an inter-turn short circuit occurs in phase A, change in the RMS voltage will be greater than other two phases.This voltage difference depends on the motor speed and fault characteristics.When u increases, voltage difference between healthy and faulty phases also increases according to (11).Supposing the effective resistance of the shorted turns remains the same, fault current I f ,RMS also increases because of the increase in the induced voltage.This yields more voltage difference as a result.Moreover, voltage difference increases with the severity of the fault.If R f is small, i.e., the fault is severe, I f,RMS increases which is positively related with voltage deviation.It is important to mention that increase in motor speed also leads to increase in induced voltage on faulty turns, which causes more I f,RMS to flow.Therefore, the effect of motor speed on faulty signal should be eliminated for accurate fault diagnosis.
Unbalanced phase resistances might create the similar effect with the ITSCF; however, the severity of a short circuit would be much higher.Normally, the PMSMs are tested for such defects before the first use.Therefore, the unbalance between phases are assumed to be smaller than a predefined threshold value.If an ITSCF occurs during the operation of the motor, this threshold value should be exceeded to alarm a short circuit fault.

Electromagnetic FEA simulations
The motor is modelled in FEA software, and the winding scheme of the healthy motor is modified to create a one-turn ITSC fault on phase A. Both healthy and faulty motors, running at 1500 rpm and loaded at nominal torque, are subject to transient analysis.Fig. 2 depicts the flux linkages of healthy and faulty motors while Fig. 3 shows the torque output of healthy and faulty motors.As shown in Fig. 3, ITSCF creates torque ripple at the motor shaft and may lead to mechanical unbalance and vibration.Also, average torque is the same for healty and faulty motors beause the load torque and the motor speed are the same (see Fig. 3).Normally, ITSF decreases the average electromagnetic torque; however, phase cuurents are greater in the faulty motor resulting the same average torque.
According to (8) to (10), induced phase voltages have the same characteristics as flux linkages, which simulations confirm (see Fig. 4).As shown in Fig. 4(b), the three-phase balance of the motor is disturbed, which creates third harmonic component.Therefore, by applying Clarke and Park transformations to the phase voltages, the ITSCF effect can be observed on V q as a second harmonic.Fig. 5 shows the amplitude spectrum of V q for healthy and faulty PMSMs; f e is 100 Hz.The harmonic at 600 Hz is caused by voltage source inverter and PWM switching; the fault frequency is 200 Hz.It is clearly observed in Fig. 4 that the faulty phase voltage decreases by a certain amount, which verifying (11).The difference between peak or RMS values of phase voltages can be used to detect the ITSCF as predicted mathematically in (11).
As a result, the signature of ITSCF is the difference between peak or RMS values of the induced phase voltages.For fault diagnosis, the RMS  values of the phase voltages will be calculated and compared to their average value.The fault alarm will be activated when a phase voltage deviates from the average value more than a pre-determined threshold value.Even though the simulations were only performed for ideal short circuit case, the effect of the fault on the phase voltages was clearly visible.Although fault current can be measured in simulations, these fault currents will never be available for real fault scenarios.
There are many advantages of detecting the ITSCF by looking at phase voltages.First, by transforming V d and V q , phase voltage measurements can easily be obtained, thus no additional sensors are required.Second, performing a spectrum analysis is far more difficult than calculating the RMS value of a signal so the proposed method does not impose a heavy computational burden.Finally, fault severity can be evaluated and detected, since the greater the phase voltage difference, the more severe the short circuit fault.However, the suggested approach fails to differentiate between significantly raised levels of faulty turns and poor fault resistance, as each of these influences the voltage difference in the same way.Generally, these data may not be needed and the user ought only to be notified of the fault and its scale to determine if the operation should continue.Moreover, as the assessment of transient regions could initiate false alarms, decisions should be made during steady state operation assuming that the algorithm has taken this into consideration.

Non-uniform demagnetization faults
Demagnetization of the permanent magnet can be caused by local heating due to excessive stator current, a strong magnetic field opposing the magnet flux due to extremely high negative d-axis current or mechanical stresses [3839].

Analysis of demagnetization faults
In permanent magnet demagnetization faults, the spatial flux distribution of the airgap is disturbed.Fig. 6 shows fundamental magnetic flux density through the airgap for healthy and faulty motors.Due to a non-uniform magnet defect in one pole, flux density decreases in that area, which is depicted by the green line in Fig. 6.The resulting magnetic flux density function is given in (12), where K dem and pp are the fault severity distortion factor and the number of pole pairs, respectively [40].
The frequency components at the rotational frequency and its integer multiples increase for all three phase currents as a result of the step change in flux density at the fault location.Fault frequencies on phase currents can thus be represented by ( 13) using ( 1) and ( 12) [41].
It is worth noting that DEF has the same effects on three-phase currents.Therefore, phase currents can be represented as ) 3 Since the fault frequency components described in (13) exist in all three phases, they are likewise present in i q .When rotational frame transformation is applied to a signal of f s frequency with the reference frame having a frequency of f r , the resulting waveform has the frequency of |f s − f r |.By applying synchronous reference frame transformation to the phase currents presented in ( 14) to ( 16), i q can be written as The effect of DEF on i q is shown in (17).The i q of a healthy motor is represented by the fundamental DC component, whereas the fault currents are represented by the AC harmonics.Here, the common factor of all harmonics is I f , which is dependent on the demagnetization level.The fault current, I f , increases with the severity of the fault and speed, but not with the load as demonstrated in (17).Non-uniform DEF in PMSMs is indicated by harmonics on i q at rotational frequency and integer multiples of this.By monitoring these harmonics in steady state operation, an accurate FD can be achieved.

Electromagnetic simulations
The simulations were performed on the same healthy model created for ITSC faults.One of the eight magnets was removed from the model to represent the total demagnetization of a single magnet.Transient analysis was performed on both healthy and faulty motors, which were loaded at nominal torque and rotating at 750 rpm and 1500 rpm.Fig. 7 depicts the magnetic flux density distribution of the faulty motor.Near the faulty magnet, the magnetic flux density of the stator teeth is 0.5 T, reaching 1.7 T near the healthy magnets.As the motor rotates, the asymmetry moves along all three phases, and therefore DEF has the same effects on all three phases.
The change in the phase currents is reflected to the produced torque and I q .Fig. 8 and Fig. 9 show the torque output and I q of healthy and faulty motors, respectively.The average value of the current increases to obtain the same amount of torque.The motor torque constant and motor efficiency decrease as a result of demagnetization fault.Also, increase in the torque ripple may create mechanical unbalance and vibration in the future.The frequency of the oscillations in I q are the indications of DEF.According to (17), an increase in the harmonic content of I q at mechanical frequency and its integer multiples is expected.When rotational frame transformation is applied to phase currents to calculate i q , harmonic content at fe 4 shifts to 3fe 4 .Therefore, maximum disturbance on I q is expected at that frequency.Table 2 shows the harmonic contents of I q for healthy and faulty motors, confirming the mathematical approach to the effect of demagnetization.

Static eccentricity faults
Static eccentricity faults may be caused by incorrect positioning during machine assembly or stresses applied to the machine's stator [42].As a result of SEF, motor phase current balance will be disturbed and this may lead to driver phase faults at very high-performance operations.Also, static eccentricity faults may evolve to dynamic eccentricity faults in time due to creation of mechanical stress on the shaft and bearings.

Analysis of static eccentricity faults
Fig. 10 shows the nature of SEF.In such a fault, the position of minimum airgap length does not change as the rotor rotates.Therefore, machine variables are in a steady condition and do not create harmonic components at the rotational frequency, as is the case with DEF.Hence, it can be concluded that a pure SEF cannot be detected the fault harmonics in the current spectrum at the rotational frequency [41].Although the motor variables are steady in time, there are differences between phase inductances.Motor phase inductances are inversely proportional to the airgap length between stator and rotor, as given in (18).
In SEF, the rotor's centre of rotation is displaced by a certain amount,    causing the airgap length to increase for an arbitrary phase but decrease for others, or vice versa.Differences in inductive values between phases are caused by displacement and changes in airgap length.In terms of instantaneous voltage and current vectors, as well as the machine's variables, phase voltage can be stated as ) Considering the steady state RMS values of currents and voltages, (19) can be rewritten for each phase as When the three-phase excitations and permanent magnet flux are the same, the left sides of (20) to ( 22) have equal amplitudes.As a result, it can be deduced from the right side that phase inductances and phase currents have an inverse relationship.At high speeds, inductance impedance rises, and resistive terms become insignificant.Therefore, at higher speeds, the difference between the phase currents is more pronounced.Monitoring peak or RMS values of phase currents helps to detect rotor SEF.Since the fault is asymmetric, it has a greater impact on one phase than the others.Because all three phases are impacted in the same way in such instances, the faulty condition can be distinguished from the instantaneous speed and load changes.However, the following facts should be considered: 1) the more the eccentricity, the greater the imbalance in the phase currents; 2) the proposed method is applicable for steady state operation of the motor; and 3) the proposed method produces more accurate results at higher motor speeds.

Electromagnetic FEA simulations
To simulate SEF, the centre of rotor and axis of rotation are displaced from the centre of stator in a healthy motor model.As illustrated in Fig. 11, simulations were carried out for three levels of SEF, corresponding to 0.3 mm, 0.5 mm, and 0.8 mm displacements.Table 3 shows the numerical results.The peak values of the three phases differ depending on the severity of the faults, as illustrated in Fig. 12.This is due to the movement of minimum airgap position towards one of the phases.
The detection of SEF by observing phase currents has some advantages.First, it is simple to implement.In motor drive, phase current feedbacks are already accessible for motor control, and so performing CM requires no additional sensors.Second, calculating current peak or RMS values is easier than performing a spectrum analysis.Therefore, the proposed method is computationally light and can be implemented on microprocessor used for motor control.Finally, the difference between phase currents can be used to detect a fault's severity.However, in the transient period, the method may trigger false alarms so the FD algorithm should be conducted in a steady state.

Experimental validations and data collection
To verify the precision of the fault indicators introduced in Section II, four identical PMSMs underwent disassembly, and artificial faults were intentionally induced.The process of creating individual faults is elucidated in detail in the corresponding section.The electrical specifications of the test PMSM and the motor driver are detailed in Table 1.This particular PMSM was selected as the test motor due to its widespread use in motion control systems, with over 5000 instances available in the field, facilitating the potential collection of field data for further studies.
The system schematic and experimental setup are illustrated in Fig. 13 and Fig. 14.Prior to implementing real-time Condition Monitoring (CM) and Fault Detection (FD) algorithms, both healthy and faulty motors underwent five consecutive runs for each specified operating condition as detailed in Table 4. Current and voltage signals were recorded through the RS422 test channel and subsequently processed offline using a MATLAB Simulink model to validate the proposed fault indicators.The repetition of experiments reveals minimal variation in measurements between consecutive runs for the same fault, speed, and load level.This marginal difference does not impact the fault diagnosis algorithm.Consequently, in all subsequent figures, one measurement for each condition is selected and presented, while the others are omitted for the sake of simplicity.
The results obtained from theoretical and simulation analyses in Section II were then compared with the signal characteristics, such as harmonic content and Root Mean Square (RMS) values, of healthy and faulty motors recorded during the experimental runs.Once the offline calculations confirmed the signal characteristics proposed in Section II, the online CM and FD algorithm was implemented in real-time motor control software (MCS), as detailed in Section IV.

Experiments with stator inter-turn short circuit faults
The stator winding of the PMSM comprises a distributed winding with 128 turns, organized into 16 series and 8 parallel turns.Fig. 15 illustrates that one of these 16 series turns is accessible from A2 and A3 terminals, while Fig. 16 provides a detailed view of the terminals, revealing 8 parallel conductors within them.Initially, a minor fault, specifically a one-conductor fault, is induced by short-circuiting only one of the 8 parallel conductors (A2-a and A3-a).This results in a 1/128 (0.8 %) ITSCF on phase A. Subsequently, a two-conductor fault is introduced by additionally short-circuiting one more turn (A2-b and A3b), corresponding to a 1.6 % ITSCF.For a clearer understanding, Fig. 17 presents a view of the real test motor and its terminals.In Fig. 18, a comparison is depicted between the phase currents of healthy and 1.6 % faulty PMSMs operating at 1800 rpm with a 0.8 Nm load torque.At this operating point, total RMS vibrations of the phase currents are − 6.84 dB and − 6.58 dB for healthy and faulty motors, respectively.However, the amplitudes of the phase currents are higher in the faulty case to produce the same amount of torque to maintain the operating point.
Because a short circuit current is a direct indictor of fault severity, it was measured in both cases under various torque and speed conditions.Fault current increased as the number of shorted turns and motor speed increased, but did not alter with the load torque, as seen in Fig. 19.The results demonstrate that, in faulty cases, phase voltage differences Table 3 Simulation results of the peak values of phase currents and their difference for a healthy PMSM and a PMSM wıth a static eccentricity fault running at 1,500 RPM and 2.5 Nm Load Torque.increase.The faulty phase deviates the most from the average.In Fig. 20, the maximum voltage differences for Root Mean Square (RMS) phase voltages are depicted for both healthy and faulty motors across diverse load and speed conditions, as detailed in Table 4. Obviously, the RMS voltage deviation is a true diagnostic of ITSCF as it has the same characteristics as the short circuit fault currents.The deviation is normalized by the average of RMS phase voltages to create an indicator that is independent of the speed.The resulting indicator in Fig. 21 is nearly speed independent, and it increases as the severity of the fault increase.Thus, the fault indicator also provides information about the severity of the fault.

Experiments with non-uniform demagnetization faults
To corroborate the findings outlined in Section II, a non-uniform demagnetization was induced in a test motor.To achieve this, one magnet was deliberately detached from the rotor and exposed to intense heat until demagnetization occurred.The demagnetization process is illustrated in Fig. 22.Subsequently, experiments were conducted at the specified speed and torque values detailed in Table 4.
Torque oscillations at mechanical rotational frequency are caused by single faulty magnet on the rotor.In speed control mode, the speed controller compensates for torque oscillations by adjusting motor phase currents.Therefore, the effects of the fault can be seen on the phase currents and I q in this scenario, shown in Fig. 9.
The phase current measurements of healthy and faulty motors were compared.The FFT coefficients of phase currents corresponding to f m were higher for the faulty motors.Fig. 23 shows the amplitude spectrum of phase A current for healthy and faulty motors running at 1200 rpm under the no-load condition.For a better view, the frequency axis was centred around the mechanical frequency, which was 20 Hz.At this particular operating point, total RMS vibration of the phase currents are − 4.26 dB and − 4.16 dB for the healthy and faulty motors, respectively.However, sideband at the mechanical frequency rises from − 37.4 dB to -23.55 dB with respect to the fundamental frequency when the fault occurs, proving that the proposed signal is an accurate fault indictor.At all operating points shown in Table 4, a higher harmonic content is measured for the faulty motor at mechanical frequency meeting the expectations.Permanent magnet DEF created no asymmetries between the phases.Therefore, the FFT coefficient of I q corresponding to 3fe pp should be used as a DEF indictor, as given in (17).FFT coefficients of I q at 3fe pp for the healthy and faulty motors running at varied torque and speed conditions are shown in Fig. 24.
Although the relevant coefficient was unaffected by load torque, it did increase with speed.To determine a fault indictor that is independent of speed, the FFT coefficients were normalized with the square of the rotor speed per unit.As shown in Fig. 25, the resulting indicator easily distinguishes between healthy and faulty motors under all operating conditions.In speed control mode of operation, speed was regulated by the motor controller and the effect of demagnetization was seen in the phase currents and I q .According to these experimental results, the harmonic contents of phase currents at f m and I q at 3fe pp are good    candidates to be indicators of permanent magnet DEF, corroborating the conclusion presented in Section II.

Experiments with static eccentricity faults
In order to fully verify the results presented in Section II, the effects of SEF on the motor signals were observed experimentally.A permanent static eccentricity fault was intentionally induced in the motor by machining the inner part of the motor cage by 0.5 mm on one side and placing a shim on the other side.The resulting permanent static eccentricity fault in the motor is depicted in Fig. 26.Given the 1.8 mm air gap, the 0.5 mm displacement led to a 28 % SEF.
The tests in Table 4 were carried out.The rotor's displacement from the stator's centre caused a non-uniform airgap clearance.Non-uniform airgap distribution causes variances in phase inductances, as seen in (18).Changes in inductances disrupt the motor's three-phase balance, causing phase currents to differ in the case of SEF.Phase currents of healthy and faulty motors running at 1800 rpm with 0.4 Nm load are shown in Fig. 27.At this particular operating point, total RMS vibration of the phase currents are − 6.76 dB and − 6.69 dB for the healthy and faulty motors, respectively.However, the peak value of phase current C was higher for the faulty PMSM because the machined part of the bearing is close to phase-C winding.In all operating conditions, as shown in Fig. 28, phase current deviations from the average were bigger for the faulty motor.
This deviation is proportional to speed and independent of load torque.The fault indicator becomes speed independent when the deviation is normalized by motor speed, as shown in Fig. 29.Experimental results reveal that SEF disrupts the three-phase balance of motor windings, resulting in changes in RMS values for phase currents.As the motor speed increased, the difference became larger.By normalizing phase current differences by motor speed, a proper FD indicator can be used.In conclusion, the experimental work supports the theoretical predictions.

Remarks on the experiments
Experiments on partial DEF, stator ITSCF, and rotor SEF were conducted, and analytical methodologies were validated.Explanations and comments on the correctness of the experiments are presented in this section.First, the fault indications for healthy PMSMs were non-zero due to inherent mechanical and electrical imperfections, such as rotor imbalances, stator winding unbalances and so on.Measurement noises also      In such instances, the FD algorithm should evaluate numerous signals to classify the fault appropriately.Consider the following scenario: • Using deviations of phase currents normalized by motor speed, SEF can be easily detected, as shown in Fig. 29.However, as demonstrated in Fig. 30, the same fault indication cannot discriminate between DEF and SEF in low torque operation.As a result, when utilizing only one variable, faults may not be distinguished from one another.
• When the fault indication used to detect DEF is also used in the SEF decision process, the algorithm can decide whether the irregularity in the motor is a SEF or DEF signature.SEF does not appear in the ampli-tude spectrum of I q , as illustrated in Fig. 31.

Implementation of the proposed condition monitoring and fault diagnosis algorithm
As mentioned earlier, an online real time algorithm is needed to detect PMSM faults early and alert users so that they can take precautions.The proposed CM and FD algorithm has four key goals: 1) online and real time monitoring with minimum time delay; 2) accurate detection of the fault type and its severity; 3) sole use of built-in sensors; and 4) implementation on a low-cost microprocessor platform.

Feature extraction method
Motor signals were evaluated under stationary conditions.The short time Fourier transform (STFT) is a suitable method of feature extraction because it provides appropriate time and frequency resolutions [43].
At nominal speed, frequencies up to a third harmonic (480 Hz) can be detected; this adequately implements the proposed FD algorithm because only fractional harmonics need to be calculated.When determining the window length of an STFF, the frequency resolution requirements, and available memory in the processor should be considered.A 512-point FFT divides double sided frequency spectrum into 512 equal parts, yielding a frequency resolution of 2 Hz.While the motor is running at 120 rpm, a resolution of 2 Hz is sufficient to extract information from the measurements (5 % of the nominal speed).Then, the motor signals used in the calculations are stored in 32-bit registers.Prior to calculations, these signals should be buffered.For STFT and RMS calculations, the buffer length is 512 and 128 samples, respectively.The memory requirement of these buffers is indicated in Fig. 32.Moreover, fault decision blocks need 0.3 kB of memory for low-pass filtering.To implement a real-time FD algorithm in the servo controller, around 8 kB of memory is required for data storage.

System design and implementation
A Simulink model of the proposed CM and FD algorithm was built for each fault case.A fixed step time of 1 ms was selected since the feedback signals, were collected and evaluated at 1 kHz in DSP.Embedded-Coder in Simulink can generate C-code of the designed models for real-time and standalone implementation on DSP.

Demagnetization fault detection block
Fig. 33 depicts the block's content for DEF detection.The fault indicator for DEF, which is given in (23), is: 1) for the faulty motor, greater than 0.08 in all cases; and 2) for the healthy motor, less than 0.02 in all cases as shown in Fig. 25.Therefore, the fault threshold for DEF was set to 0.06.

Short circuit fault detection block
Fig. 34 shows the block's content for the proposed ITCF detection.
The fault indicator, which is presented in (24), is: 1) greater than 0.01 in all cases for the faulty motor; and 2) less than 0.002 in all cases for the healthy motor as shown in Fig. 21.Thus, the fault threshold is set at 0.005.In addition, the designed model detects the faulty phase and alerts the user.The faulty phase is the one with maximum voltage deviation.

Static eccentricity fault detection block
Content of the model for SEF detection is shown in Fig. 35.The fault indicator, which is given in (25), is: 1) greater than 0.85 in all cases for the faulty motor; and 2) smaller than 0.55 in all cases for the healthy motor as shown in Fig. 29.Therefore, the fault threshold is set to 0.7.Checking multiple fault indicators prior to decision of SEF improves the accuracy of FD, as explained in the Section III.
In all the fault blocks, if the fault indicator exceeds the fault threshold, the comparator is activated.After that, it passes through a low-pass filter.Finally, the presence of a fault is given as a percent probability to the user.The threshold values are derived from the measured data for both healthy and faulty motors.In other words, the

Integration of the proposed condition monitoring and fault detection algorithm with the motor control software
The next phase is to integrate the FD blocks into the motor control software.The DSP is a fixed-step time controller that is typically implemented in a low-cost, low memory processor.Therefore, the designed blocks must be structured so that they can run in real-time without compromising the motor control functions.

Memory and run-time considerations
As indicated in Fig. 32, the amount of memory required for data storage is 8 kB.The FD algorithm, which includes STFT, buffers, RMS computations, and other features, is added to DSP, which increases the size of the output code.Another critical parameter is the runtime.Tasks are classified and a specified amount of time is allocated for each task to be accomplished for proper operation of motor control and CM at the same time.As a result, optimization is required to construct a model that runs quick enough to finish all tasks within the time constraints while also fitting inside the DSP memory map.
The algorithm is implemented in DSP's speed controller loop.All activities in the speed loop must be accomplished in one millisecond.Fig. 36 shows a timing diagram for the speed control loop.The maximum amount of time available for fault detection is 300 microseconds.STFT and RMS computations consume a significant amount of time.The length of the STFT can be reduced to minimize the runtime, but this reduces the frequency resolution.The same principle applies to RMS calculations.As a result, runtime should be lowered without compromising the FD algorithm's performance.Two different models are used for this purpose, which are fault detection preliminaries and fault detection.Fig. 37 depicts the data flow between these blocks.
Fault detection preliminaries update every 1 ms in the speed controller loop.There are stages for buffering the signals that are subject to STFT and these signals are recorded in data stores after being sampled at 1 kHz.With a sampling frequency of 1 kHz, the RMS values of phase currents and voltages are determined.All relevant data are written to the data stores to be used in fault detection model.
The sample period for fault detection is 64 ms; both STFT and decision making are performed in this block and updated every 64 ms.Since electrical signals are sampled and buffered inside the speed control loop at 1 kHz, there is no loss in the frequency resolution.The trade-off is in the time resolution.Fault decisions are made every 64 ms instead of every 1 ms; however, this does not compromise the overall performance of the CM and FD algorithm because the motor faults occur and evolve at a much slower transition rate.The speed controller loop with the FD method takes 900 microseconds to run.Fig. 38 shows the updated timing diagram in further detail.Preliminaries for fault detection are accomplished in less than 200 microseconds, ensuring that the motor control and CM algorithms are working properly at the same time.The software is compiled and the sizes of the resulting code segments are compared.The FD algorithm uses 36 kB of RAM, of which 8 kB is used for data storage and the rest is to generate C code.

Real-time testing of the proposed algorithm
The Real-time CM and FD algorithms underwent testing on the experimental setup post successful integration with the motor control software.Tests were conducted using both healthy and faulty motors, following the parameters outlined in Table 4. Based on the results of the real-time CM and FD algorithm tests, 125 out of 128 accurate decisions were made, resulting in an algorithmic accuracy of 98 %.Fault signals at the user-end are illustrated in Fig. 39, Fig. 40, Fig. 41 and Fig. 42 under conditions where the load torque is 0.8 Nm, and the motor speed is 1800 rpm.After a three-second start-up, the system is poised for fault detection.In the case of healthy PMSMs, all three signals register as zero, affirming the motor's sound condition.
For DEF and SEF, related signals go high showing that the PMSM is faulty.Fault categorizations are correct.Finally, for ITSCF, the fault signal goes high, and another parameter shows the faulty phase, which is phase-A in the experiments.The incorrect decisions are made when the motor speed and load torque were 600 rpm and 0.4 Nm, respectively.The fundamental frequencies of the signals become smaller in this situation.As a result, performing STFT and RMS computations at the same time produces fluctuating results.The decisions are correct in all other circumstances, and the overall accuracy is 98 %.Furthermore, all cases with a healthy motor are accurately identified, ensuring that no false

Conclusion
In this paper, a complete solution has presented from mathematical models of the failure modes to implementation of the algorithm on a real motor drive.The proposed method is non-distractive and has the advantage of not requiring any external hardware or sensors.Three types of faults known as ITSCF, non-uniform DEF, and SEF in PMSMs were investigated.The proposed CM and FD algorithm was integrated into the motor drive system for real time operation.It has found that the proposed FD requires a small memory and a short runtime so that it can be realized on even a simple motor controller having limited memory and calculation power.The FD algorithm was designed for steady state operation of the motor to overcome faulty alarms, and the feedback signals were evaluated during steady speed operation.From all these points of views, the proposed algorithm is compared with the most recent and related research in Table 5.It is seen that, the work conducted in this article is unique and contributes to the literature.
Experimental results showed that the proposed solution achieved 98 % accuracy in fault detection without jeopardizing the motor drive's operation.To detect the slightest fault indications and determine fault threshold limits for a different PMSM, the algorithm should be trained so that it acclimatizes to the normal operation of the machine and then recognizes faults.The algorithm can easily be transferred to other systems by running a learning algorithm on the drive and tracking the behaviour of healthy motors in order to understand the fault pattern using AI algorithms; this will be the focus of future work.

Table 5
Comparison of the proposed CM and FD method with the most recent and related researches from the literature.

Declaration of competing interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.
developed a novel fault diagnosis approach by converting the measured signals into 2-D images.The converted images are then fed to a CNN known as LeNet-5 for features extraction and fault diagnosis.AI-A.Demirel et al.

Fig. 1 .
Fig. 1.Electrical equivalent representation of the stator windings of a PMSM.

Fig. 2 .
Fig. 2. Simulation of the flux linkages of the stator windings of PMSMs: a) a healthy PMSM; and b) a PMSM with ITSCF.

Fig. 4 .
Fig. 4. Simulation of the induced phase voltages of PMSMs: a) the healthy PMSM b) the PMSM with ITSCF.

Fig. 5 .Fig. 6 .
Fig. 5. Simulation of the amplitude spectrum of Vq at 1500 rpm with 2.5 Nm load torque for the healthy PMSM and PMSM with ITSCF.

Fig. 7 .
Fig. 7. FEA simulation of 2D Flux density distribution of PMSM with a demagnetization fault.The faulty magnet is shown in the black circle.

Fig. 8 .
Fig. 8. Simulation of the electromagnetic torque produced by healthy a PMSM and a PMSM with a demagnetization fault.

Fig. 9 .
Fig. 9. Simulation of the Q-axis current waveforms of a healthy PMSM and a PMSM with a demagnetization fault.

Fig. 12 .
Fig. 12. Simulations of the phase current waveforms of healthy and faulty PMSMs: a) A healthy motor; b) A faulty motor with 0.3 mm static eccentricity; c) A faulty motor with 0.5 mm static eccentricity; and d) A faulty motor with 0.8 mm static eccentricity.

Fig. 15 .
Fig. 15.Drawing of the windings and terminals of the special design stator.

Fig. 16 .
Fig. 16.Detailed view of the windings on which the short circuit fault is created.

Fig. 17 .
Fig. 17.Actual test motor with specially designed stator and terminals.

Fig. 18 .
Fig. 18.Experimental results of the phase current measurements of healthy and 1.6 % faulty PMSMs operating at 1,800 rpm with a 0.8 Nm load for Interturn Short Circuit Fault.

Fig. 21 .
Fig. 21.Experimental results of the normalized deviation of Va from the average vs motor speed at no load.

Fig. 23 .
Fig. 23.Experimental results of the normalized amplitude spectrum of phase-A current for the healthy motor and the motor with demagnetization fault running at 1,200 rpm and no load, fe = 80 Hz, fmech = 20 Hz.

Fig. 24 .
Fig. 24.Experimental results of FFT coefficients of Iq at the fault frequencies for the healthy motor and the motor with demagnetization fault: a) 0.4 Nm, b) 0.8 Nm, c) 1.2 Nm, d) 1.6 Nm.

Fig. 25 .
Fig. 25.Experimental results of FFT coefficients of Iq at fault frequencies normalized by w 2 for the Healthy Motor and the Motor with Demagnetization Fault: a) 0.4 Nm, b) 0.8 Nm, c) 1.2 Nm, d) 1.6 Nm.

A
. Demirel et al. affect the accuracy of FD.The software's resolution for phase currents and rotor position measurements is limited and noise is unavoidable.Healthy and faulty lines become closer at speeds below 25 % of the rated speed.As a result, fault signals below 600 rpm can be ignored to avoid false alarms.Confusion can also be caused by the effects of different sorts of faults on the same signal.

Fig. 27 .
Fig. 27.Experimental results of the phase current measurements of healthy and faulty PMSMs running at 1,800 rpm with 0.4 Nm load: a) Healthy motor, b) Motor with Static eccentricity fault.

Fig. 28 .
Fig. 28.Experimental results of the deviation of phase currents from the average for a healthy motor and a motor with a static eccentricity fault: a) 0.4 Nm, b) 0.8 Nm, c) 1.2 Nm, d) 1.6 Nm.

Fig. 29 .
Fig. 29.Experimental results of the normalized deviation of phase currents from the average for a healthy motor and a motor with a static eccentricity fault: a) 0.4 Nm, b) 0.8 Nm, c) 1.2 Nm, d) 1.6 Nm.

Fig. 30 .
Fig. 30.Experimental results of the normalized deviation of phase currents from the average for demagnetization and static eccentricity faults: a) 0.4 Nm, b) 0.8 Nm, c) 1.2 Nm, d) 1.6 Nm.

Fig. 31 .
Fig. 31.Experimental results of FFT coefficients of Iq corresponding to fault frequencies normalized by w 2 for demagnetization and static eccentricity faults: a) 0.4 Nm, b) 0.8 Nm, c) 1.2 Nm, d) 1.6 Nm.

A
. Demirel et al.CM and FD algorithm requires training data to identify a proper fault threshold.Although IoT and AI algorithms can be used to collect and evaluate training data from PMSMs distributed in the field, for now it is outside the scope of this work.

Fig. 39 .
Fig. 39.Experimental results of fault detection algorithm results in a healthy case.

Fig. 40 .
Fig. 40.Experimental results of fault detection algorithm results in stator short circuit fault.

Fig. 41 .
Fig. 41.Experimental results of fault detection algorithm results in demagnetization fault.

Fig. 42 .
Fig. 42.Experimental results of fault detection algorithm results in static eccentricity fault.

Table 4
Test conditions for the motors.