Intelligent Fault Detection in Hall-Effect Rotary Encoders for Industry 4.0 Applications

: Sensors are the foundational components of any smart machine system and are invaluable in all modern technologies. Consequently, faults and errors in sensors can have a signiﬁcant negative impact on the setup. Intelligent, lightweight, and accurate fault diagnosis and mitigation lie at the crux of modern industries. This study aimed to conceptualize a germane solution in the domain of fault detection, focusing on Hall-effect rotary encoders. Position monitoring through rotary encoders is essential to the safety and seamless functioning of industrial equipment such as lifts and hoists, and commercial systems such as automobiles. This work used multi-strategy learners to accurately diagnose quadrature and offset faults in Hall-effect rotary encoders. The obtained dataset was then run through a lightweight ensemble classiﬁer to train a robust fault detection model. The complete mechanism was simulated through interconnected models simulated in a MATLAB Simulink™ environment. In real time, the developed fault detection algorithm was embedded in an FPGA controller and tested with a 1 kW PMSM drive system. The resulting system is computationally inexpensive and achieves an accuracy of 95.8%, making it a feasible solution for industrial implementation.


Introduction
As we move towards realizing smart factories, and towards the digitization of industrial processes, there is a need to improve every component of each system. Industry 4.0 technologies [1] require every machine to be smart, more reliable, and automated [2]. Hence, there is a need to improve the sensor systems that are involved in the industrial process. As much as the machines are vulnerable to different types of fault scenarios, so are their embedded sensor systems. These sensor systems are essential to the performance and feedback control of every smart machine. One such sensor system is the position monitoring used for a myriad of applications in the industry, ranging from automobiles to flow control [3]. With the increased focus on EV technology, there is a need for improved rotary position sensors for applications such as torque vectoring [4]. Therefore, there is a need for further research and development in this domain [5]. There are different types of rotary sensors available in the market today. One common methodology used for position measurement in BLDC motors is back EMF measurement for rotor position sensing, but this method is lacking because it often results in inaccurate measurements, leading to large torque ripples [6]. Other types of position sensors used for automotive applications are resistance-based potentiometric sensors, capacitive sensors, optical sensors, and Halleffect magnetic sensors [7]. Hall-effect position sensors are preferred over potentiometric sensors because there is no need for contact in their utilization. They are also preferred over optical position sensors as they are immune to dust, compact, and cost-effective. Capacitive sensors provide high-accuracy output but require additional circuitry, thus increasing manufacturing complexity [8]. The Hall effect was discovered by Edwin Hall in 1897. Hall-effect sensors work based on the magnetic field effect. When a Hall element is placed in a perpendicular magnetic field, a potential difference is developed across the element that is commensurate to the magnetic field applied [9]. This effect is known as the Hall effect, and the developed potential difference is used for the measurement of angles. Different types of Hall-effect sensors can be used for rotary position-sensing applications, including latch-, switch-, and linear-type sensors [10]. They have been used widely for the stable and reliable operation of PMSM drives for various applications [11,12]. Linear Hall-effect sensors are applied in cases where precise and continuous position information is required. Applications of linear sensors include flow meters, pressure diaphragms, voltage regulators, and tachometers [13]. Hall sensors are also preferred for elevator and hoist applications in PMSM [14].
A single linear Hall sensor can be used for angle measurements in the range of ±90 • . This can be useful for some applications, but not for rotating machinery where 360 • measurements are required. The literature cites that a single sensor can only accurately measure angles in the range of ±45 • , as the setup is affected by the sensor's position and the external magnetic fields that might be present. For applications where 360 • measurements are required, it is recommended that a four-element Hall sensor is used [15]. For this, four Hall elements are placed at an equidistant position from each other under a magnetized surface. The major advantages of using the four-element approach are that it eliminates the temperature-based inaccuracies and negates the effect of the external magnetic fields, thus eliminating any magnetic offsets. Two main types of error are encountered when using four-element Hall sensors, namely, offset error and orthogonal error. The main causes of these errors are (i) changes in the magnetization of the permanent magnet; (ii) permanent magnets with different widths; (iii) air-gap temperature fluctuation; and (iv) the presence of harmonics in the air gap [11]. These factors lead to errors in the rotor position measurement accuracy, which can lead to unsatisfactory performance and low efficiency, therefore causing losses. They can also give rise to a DC component in the Hall elements' signal, which will then be amplified by the differential amplifiers. Therefore, there is a need for a mechanism to be in place to detect these errors, to enable compensation to be applied at the software or the hardware side, and therefore keeping the machine performance at the required level [16]. Some work with regards to detection of faults in the Hall-effect sensors already exists in the literature. Ref. [17] uses a BLDC motor setup along with Hall-effect sensors to develop a fault detection method based on discrete Fourier transform and the spectral density error of line voltages. Ali Mousmi et al. [18] use combinatory circuits for the detection of Hall-effect sensor faults in a BLDC motor. In [19], phase locked loops are used for detection of three types of faults occurring in Hall-effect sensors in a PMSM motor setup. All these methods are effective in terms of detecting different kinds of faults occurring in a Hall-effect sensor, but none are based on a machine learning approach. This paper proposes a novel machine learning-based strategy to detect and classify these faults. The four-element Hall-effect sensor was co-simulated with a permanent magnet synchronous motor setup for elevator and hoist applications, induced with various fault scenarios for offset and orthogonal errors. A lightweight ensemble classifier was applied to the given dataset to train a reliable defect detection model. The Simscape electrical toolbox was primarily used to simulate the linked models that make up the whole mechanism in MATLAB Simulink. The designed fault detection method was tested in real time using a 1 kW PMSM drive system implementing the fault detection model in an FPGA controller. The remainder of this paper is organized as follows. Section 2 builds on the theoretical and mathematical conception of the sensor and industrial setup. Section 3 describes the design of an FOC-based PMSM drive with fault creation and data extraction. Section 4 presents the sensor fault detection on the FOC-based PMSM drive system through model simulation and prototype hardware. Section 5 discusses the simulation and hardware results under quadratic and offset sensor errors, and showcases the fault diagnosis system results. Finally, Section 6 concludes.

Mathematical Modeling
This work requires mathematical modeling of two main components, namely, the four-element Hall-effect rotary encoder and the permanent magnet synchronous motor (PMSM). This section provides mathematical modeling of both of these components.

PMSM Modeling
Permanent magnet synchronous motors operate through the permanent magnets embedded in the rotor, which generates an undulating magnetic field. When this magnetic field interacts with the field created by energized stator windings, a sinusoidal rate of flux change with respect to rotor angle is established [20]. When the rotor becomes synchronous, its poles hold this rotating magnetic field between the air gaps, consequently resulting in net generation of torque. The construction of the PMSM and its equivalent circuit diagram are both seen in Figure 1. As per this circuit, the voltage in stator windings can be computed, as shown in (1).
where v a , v b , and v c are the three-phase voltages, i a , i b , and i c are the three-phase currents, and R s is the net resistance of each of the stator windings. (dψ a )/dt, (dψ b )/dt, and (dψ c )/dt are magnetic flux rates of change in each of the stator windings. The total flux linkage in each winding can then be defined as given in (2).
where ψ a , ψ b , and ψ c are the total fluxes and ψ am , ψ bm , and ψ cm are the permanent magnet fluxes linking the stator windings. L aa , L bb , and L cc represent the self-inductances and L ab , L ac , L ba are the mutual inductances. For more useful correlation, these entities may be represented with respect to the rotor electrical angle (θ e ), as defined by (3)- (9).
Lab = Lba = −Ms − Lm cos 2 θe + π 6 (7) where θ r is the rotor mechanical angle, O f is the rotor offset, L s is the stator self-inductance per phase, L m is the stator inductance fluctuation, and Ms is the stator mutual inductance. These equations are still complex to solve concurrently; therefore, it is best practice to transform them into dq0 frame relations through Park's transform (P), as shown in (10) and (11). 11) scribes the design of an FOC-based PMSM drive with fault creation and data extraction. Section 4 presents the sensor fault detection on the FOC-based PMSM drive system through model simulation and prototype hardware. Section 5 discusses the simulation and hardware results under quadratic and offset sensor errors, and showcases the fault diagnosis system results. Finally, Section 6 concludes.

Mathematical Modeling
This work requires mathematical modeling of two main components, namely, the four-element Hall-effect rotary encoder and the permanent magnet synchronous motor (PMSM). This section provides mathematical modeling of both of these components.

PMSM Modeling
Permanent magnet synchronous motors operate through the permanent magnets embedded in the rotor, which generates an undulating magnetic field. When this magnetic field interacts with the field created by energized stator windings, a sinusoidal rate of flux change with respect to rotor angle is established [20]. When the rotor becomes synchronous, its poles hold this rotating magnetic field between the air gaps, consequently resulting in net generation of torque. The construction of the PMSM and its equivalent circuit diagram are both seen in Figure 1. As per this circuit, the voltage in stator windings can be computed, as shown in (1).
where va, vb, and vc are the three-phase voltages, ia, ib, and ic are the three-phase currents, and Rs is the net resistance of each of the stator windings. (dψa)/dt, (dψb)/dt, and (dψc)/dt are magnetic flux rates of change in each of the stator windings. The total flux linkage in each winding can then be defined as given in (2). Similarly, the inductances can also be translated to the dq0 frame as given in (12)- (14).
Using these equations, the electrical equations that determine the overall operation of the motor in the dq0 frame can be computed as in (15)- (18).
where N is the number of rotor permanent magnet pole pairs, ω is the mechanical speed of the rotor, ψ m is the permanent magnet flux linkage, and T is rotor torque.

Four-Element Hall-Effect Rotary Encoder
The four-element Hall-effect sensor requires the placement of four Hall elements around a diametrically magnetized magnet at an equal distance from each other. This then generates four sinusoidal waves, all with a phase difference of 90 • with its neighbor [15]. The four Hall sensors can be labeled as H1, H2, H3, and H4, as shown in Figure 2. The outputs of each of the sensors is given in (19)- (22).

Four-Element Hall-Effect Rotary Encoder
The four-element Hall-effect sensor requires the placement of four Hall elements around a diametrically magnetized magnet at an equal distance from each other. This then generates four sinusoidal waves, all with a phase difference of 90° with its neighbor [15]. The four Hall sensors can be labeled as H1, H2, H3, and H4, as shown in Figure 2. The outputs of each of the sensors is given in (19)- (22).
The outputs from H1 and H3 are then passed through a differential amplifier to give the component Vsinα (23). Similarly, the outputs of the sensors H2 and H4 are passed through a differential amplifier to give the component Vcosα (24).
The Vsinα and Vcosα components are then converted into digital signals using ADC converters, and the rotor position can then be obtained by solving the tan −1 equation as given in (25). The overall workflow of the angular computation is visualized in Figure 3, which shows the flow of the signals from the Hall elements to the differential amplifiers. The signals from differential amplifiers are then converted using ADCs and fed into a processor to obtain the angular rotor position. The output signal from the sensor or the signal conditioning circuit should be the source of the Hall-effect encoder's error. The outputs from H1 and H3 are then passed through a differential amplifier to give the component Vsinα (23).
Similarly, the outputs of the sensors H2 and H4 are passed through a differential amplifier to give the component Vcosα (24).
The Vsinα and Vcosα components are then converted into digital signals using ADC converters, and the rotor position can then be obtained by solving the tan −1 equation as given in (25). The overall workflow of the angular computation is visualized in Figure 3, which shows the flow of the signals from the Hall elements to the differential amplifiers. The signals from differential amplifiers are then converted using ADCs and fed into a processor to obtain the angular rotor position. The output signal from the sensor or the signal conditioning circuit should be the source of the Hall-effect encoder's error.

Design of FOC-Based PMSM Drive with Fault Creation and Data Extraction
The designed model focuses on the conventional mechanism of a PMSM de for industrial hoists [21,22]. The PMSM is an ideal subject for the use of Hall-effect encoders as this setup is commonly utilized in industries [23]. The complete fault tion strategy was designed as a three-tier framework ranging from the PMSM and simulation, and the data acquisition, to the fault detection system. This layered ar

Design of FOC-Based PMSM Drive with Fault Creation and Data Extraction
The designed model focuses on the conventional mechanism of a PMSM deployed for industrial hoists [21,22]. The PMSM is an ideal subject for the use of Hall-effect rotary encoders as this setup is commonly utilized in industries [23]. The complete fault detection strategy was designed as a three-tier framework ranging from the PMSM and sensor simulation, and the data acquisition, to the fault detection system. This layered architecture can be summarized by the schematic diagram in Figure 4. A further in-depth overview of the conception of this integrated model is described in the following subsections.

Design of FOC-Based PMSM Drive with Fault Creation and Data Extraction
The designed model focuses on the conventional mechanism of a PMSM deployed for industrial hoists [21,22]. The PMSM is an ideal subject for the use of Hall-effect rotary encoders as this setup is commonly utilized in industries [23]. The complete fault detection strategy was designed as a three-tier framework ranging from the PMSM and sensor simulation, and the data acquisition, to the fault detection system. This layered architecture can be summarized by the schematic diagram in Figure 4. A further in-depth overview of the conception of this integrated model is described in the following subsections.

Motor and FOC Architecture
PMSMs are gradually replacing induction motors in elevator and hoist setups due to their high torque-to-speed ratio, compact construction, relatively high efficiency, less noisy operation, and high-power density [14,24]. The faults occurring within the PMSM were not considered in the design phase of this model as they are less relevant to the scope of the study, which focuses on the faults developed in the sensory mechanism. This motor provides a standard quadratic load torque profile for multiple 10 s simulations.

Motor and FOC Architecture
PMSMs are gradually replacing induction motors in elevator and hoist setups due to their high torque-to-speed ratio, compact construction, relatively high efficiency, less noisy operation, and high-power density [14,24]. The faults occurring within the PMSM were not considered in the design phase of this model as they are less relevant to the scope of the study, which focuses on the faults developed in the sensory mechanism. This motor provides a standard quadratic load torque profile for multiple 10 s simulations.
In applications that require higher levels of torques while maintaining low starting current, in addition to high efficiency in PMSMs, field-oriented control (FOC) is the preferred technique. Briefly, this strategy dissociates torque and flux signals by translating the static phase currents to a mobile or rotational frame [25]. In the case of the FOC implemented in this model, the rotor dq frame is used as a reference point. The design of the controller is shown in Figure 5. Here, ω and ω ref are the measured and reference level angular velocities, T ref is the reference torque, and θ e is the rotor electrical angle. The dq frame current references are represented by i dr and i qr , whereas v dr and v qr are the reference voltages. The implemented controller can effectively track the reference signal. In addition to the focused monitoring and logging of the Hall-effect rotary encoder, the model also consists of a comprehensive sensing unit for scrupulous analysis of the motor's behavior.
This setup predominantly consists of three-phase current and voltage, torque, and speed sensing. In addition to being used for analysis, these parameters are also fed back to the field-oriented controller in order to iteratively adjust the controller gains and maintain consistent electrical behavior. For the purposes of this study, the system was designed such that it requires the Hall monitoring system to perform adequately with logging and monitoring capabilities. However, if the system was to be developed into a product, it would be fundamental to implement this in a modular fashion so that the system can function in its basic mode without the added functionality of the Hall sensing.
the static phase currents to a mobile or rotational frame [25]. In the case of the FOC implemented in this model, the rotor dq frame is used as a reference point. The design of the controller is shown in Figure 5. Here, ω and ωref are the measured and reference level angular velocities, Tref is the reference torque, and θe is the rotor electrical angle. The dq frame current references are represented by idr and iqr, whereas vdr and vqr are the reference voltages. The implemented controller can effectively track the reference signal. In addition to the focused monitoring and logging of the Hall-effect rotary encoder, the model also consists of a comprehensive sensing unit for scrupulous analysis of the motor's behavior. This setup predominantly consists of three-phase current and voltage, torque, and speed sensing. In addition to being used for analysis, these parameters are also fed back to the field-oriented controller in order to iteratively adjust the controller gains and maintain consistent electrical behavior. For the purposes of this study, the system was designed such that it requires the Hall monitoring system to perform adequately with logging and monitoring capabilities. However, if the system was to be developed into a product, it would be fundamental to implement this in a modular fashion so that the system can function in its basic mode without the added functionality of the Hall sensing.

Hall-Effect Rotary Encoder Operation and Faults
The central focus of this study was the operation of the Hall-effect sensor. The position monitoring of rotating machines requires the full revolution range of angular measurements. For such an application, it is not feasible to use a single Hall element, and the conventional approach is to utilize four equidistant Hall elements under a diametrically magnetized rotating magnet [26]. Therefore, this study also utilized a four-element Halleffect rotary encoder in the decoded angular position mode, which generates four sinusoidal waveforms [12]. These are then used to compute the incremental position of the PMSM shaft. The Hall-effect sensor is considered a low-cost robust mechanism for industrial sensing [27]. However, as with all sensors, the operation can be subject to calibration and instrumentation errors. These may not damage the sensor itself, but a loss of position accuracy for industrial equipment such as lifts and hoists can result in catastrophic accidents and extended downtime. This makes the rapid diagnosis of such faults crucial for continued seamless operation. For this study, two significant Hall-effect encoder faults

Hall-Effect Rotary Encoder Operation and Faults
The central focus of this study was the operation of the Hall-effect sensor. The position monitoring of rotating machines requires the full revolution range of angular measurements. For such an application, it is not feasible to use a single Hall element, and the conventional approach is to utilize four equidistant Hall elements under a diametrically magnetized rotating magnet [26]. Therefore, this study also utilized a four-element Hall-effect rotary encoder in the decoded angular position mode, which generates four sinusoidal waveforms [12]. These are then used to compute the incremental position of the PMSM shaft. The Hall-effect sensor is considered a low-cost robust mechanism for industrial sensing [27]. However, as with all sensors, the operation can be subject to calibration and instrumentation errors. These may not damage the sensor itself, but a loss of position accuracy for industrial equipment such as lifts and hoists can result in catastrophic accidents and extended downtime. This makes the rapid diagnosis of such faults crucial for continued seamless operation. For this study, two significant Hall-effect encoder faults were modeled for training and testing the fault detection subsystem: quadrature error and offset bias error. The particulars of these faults are as follows: • Quadrature error (QE): Quadrature detection in rotary encoders allows the user to monitor the speed and direction of rotation, and incremental changes in angle [28]. Placement and alignment errors, magnet tilt, and off-axis magnet rotation may all contribute to a total measurement error known as quadrature error. Additionally, variations in device sensitivity will impact overall quadrature accuracy. During continuous rotation, small quadrature errors for speed calculations may average out over time, but detecting distinct pole transitions for the absolute position requires finer precision.

•
Offset error (OE): Offset errors occur primarily in the Hall element and are due to poor transistor matching of the components in the analogue signal path [26]. An offset voltage may also develop due to non-ideal temperature conditions [29]. In well-designed sensor elements, these errors are small and existing OEs can be tackled with offset compensation and front-end calibration.
The typical characteristics shown by the position waveform in healthy conditions and with the above-mentioned faults are shown in Figure 6. To distinguish the variation, a short snippet of 0.6 s is demonstrated once the motor starting is complete and the waveform has stabilized.
Placement and alignment errors, magnet tilt, and off-axis magnet rotation may all contribute to a total measurement error known as quadrature error. Additionally, variations in device sensitivity will impact overall quadrature accuracy. During continuous rotation, small quadrature errors for speed calculations may average out over time, but detecting distinct pole transitions for the absolute position requires finer precision.

•
Offset error (OE): Offset errors occur primarily in the Hall element and are due to poor transistor matching of the components in the analogue signal path [26]. An offset voltage may also develop due to non-ideal temperature conditions [29]. In welldesigned sensor elements, these errors are small and existing OEs can be tackled with offset compensation and front-end calibration.
The typical characteristics shown by the position waveform in healthy conditions and with the above-mentioned faults are shown in Figure 6. To distinguish the variation, a short snippet of 0.6 s is demonstrated once the motor starting is complete and the waveform has stabilized. The simulated dataset consisted of three categories of data: healthy, with quadrature error, and with offset error. The fault categories were simulated with varying error degrees and offset voltages. The total number of collected data points amounted to approximately 4 million.

Data Extraction and Classification
Considering the functional constraint of manually acquiring such a vast dataset, parallel pool processing with Simulink ensemble datastore was utilized to automate and streamline the data acquisition and compilation process. Following the collection of data into a comprehensive database, data features were extracted for each of the files to compile a labeled feature table. The statistical features computed for this model were mean, standard deviation, skewness, kurtosis, peak value, root mean square (RMS), impulse factor, crest factor, clearance factor, and shape factor. Additionally, some common signal processing features were also calculated, including signal-to-noise and distortion (SINAD), signal-to-noise ratio (SNR), and total harmonic distortion (THD).
Feature extraction is considered an essential process for producing a high-accuracy machine learning model as it tends to highlight trends in the data, ignoring irrelevant anomalies [30]. This process reduces the dimensionality of the data, which optimizes the computational load for the training process. Although extraction of features lowers dimensionality and redundancy, sieving for significant features can further optimize model training and accuracy [31]. Therefore, the model employs two feature selection techniques The simulated dataset consisted of three categories of data: healthy, with quadrature error, and with offset error. The fault categories were simulated with varying error degrees and offset voltages. The total number of collected data points amounted to approximately 4 million.

Data Extraction and Classification
Considering the functional constraint of manually acquiring such a vast dataset, parallel pool processing with Simulink ensemble datastore was utilized to automate and streamline the data acquisition and compilation process. Following the collection of data into a comprehensive database, data features were extracted for each of the files to compile a labeled feature table. The statistical features computed for this model were mean, standard deviation, skewness, kurtosis, peak value, root mean square (RMS), impulse factor, crest factor, clearance factor, and shape factor. Additionally, some common signal processing features were also calculated, including signal-to-noise and distortion (SINAD), signal-tonoise ratio (SNR), and total harmonic distortion (THD).
Feature extraction is considered an essential process for producing a high-accuracy machine learning model as it tends to highlight trends in the data, ignoring irrelevant anomalies [30]. This process reduces the dimensionality of the data, which optimizes the computational load for the training process. Although extraction of features lowers dimensionality and redundancy, sieving for significant features can further optimize model training and accuracy [31]. Therefore, the model employs two feature selection techniques to choose the most significant features for training. The first is neighborhood component analysis (NCA), which is a non-parametric method used to select features to maximize the prediction accuracy of regression and classification algorithms. It is cited in machine learning systems due to its non-linear decision surface and simplicity with a single integer parameter [32,33]. The model's dataset is run through an NCA feature selection with regularization to learn feature weights for minimization of an objective function that measures the average leave-one-out classification or regression loss over the training data. The resulting computation for each feature weight is shown in Figure 7. The second strategy used for feature selection is the minimum redundancy maximum relevance (mRMR) algorithm, which finds the optimal array of features by ranking them according to their overlap with other features. Although many algorithms focus on finding the most relevant features, they ignore the fact that these may be correlated and therefore dispensable. The mRMR algorithm is uniquely aimed at reducing redundant or correlated features, which may weigh down the training process, while also maintaining relevance [31]. On running the feature table through the mRMR, a ranking of best features was produced, as shown in Figure 7. By combining their results, the two selection methods were superimposed and the irrelevant features were omitted prior to the training process. This resulted in more efficient training and saved valuable computational resources.
The resulting computation for each feature weight is shown in Figure 7. The second strategy used for feature selection is the minimum redundancy maximum relevance (mRMR) algorithm, which finds the optimal array of features by ranking them according to their overlap with other features. Although many algorithms focus on finding the most relevant features, they ignore the fact that these may be correlated and therefore dispensable. The mRMR algorithm is uniquely aimed at reducing redundant or correlated features, which may weigh down the training process, while also maintaining relevance [31]. On running the feature table through the mRMR, a ranking of best features was produced, as shown in Figure 7. By combining their results, the two selection methods were superimposed and the irrelevant features were omitted prior to the training process. This resulted in more efficient training and saved valuable computational resources.

Realization of FOC for PMSM Drive System for Sensor Fault Detection
The objective of this work was to detect the sensor fault under various operating conditions using machine learning algorithms. The prime focus was to extract the machine data under healthy and sensor fault conditions, and analysis with the trained machine learning model. Hence, the FOC for a 2.87 kW PMSM drive system was developed in the MATLAB Simulink/Simscape™ environment and realized experimentally with a scaleddown model, i.e., a 1 kW PMSM drive system.

Simscape Model of PMSM Drive System
The complete mechanism was simulated through interconnected models simulated in MATLAB Simulink™, mostly through the Simscape electrical toolbox, as shown in Figure 8. Simscape™ enables the creation of models of physical systems within the Simulink ® environment. Simscape helps to develop control systems and test system-level performance. Physical component models can be built based on physical connections that directly integrate with other modeling paradigms. In the Simscape environment, the FOCbased PMSM drive with a sensor fault-enabled system was designed and deployed. The

Realization of FOC for PMSM Drive System for Sensor Fault Detection
The objective of this work was to detect the sensor fault under various operating conditions using machine learning algorithms. The prime focus was to extract the machine data under healthy and sensor fault conditions, and analysis with the trained machine learning model. Hence, the FOC for a 2.87 kW PMSM drive system was developed in the MATLAB Simulink/Simscape™ environment and realized experimentally with a scaleddown model, i.e., a 1 kW PMSM drive system.

Simscape Model of PMSM Drive System
The complete mechanism was simulated through interconnected models simulated in MATLAB Simulink™, mostly through the Simscape electrical toolbox, as shown in Figure 8. Simscape™ enables the creation of models of physical systems within the Simulink ® environment. Simscape helps to develop control systems and test system-level performance. Physical component models can be built based on physical connections that directly integrate with other modeling paradigms. In the Simscape environment, the FOC-based PMSM drive with a sensor fault-enabled system was designed and deployed. The model shown in Figure 8 consists of the PMSM, two-level voltage source inverter and source module, rotary encoder, and FOC.
The permanent magnets contained in the rotor of permanent magnet synchronous motors produce an undulating magnetic field, which powers the motor. Energized stator windings produce a magnetic field that interacts with this magnetic field, resulting in a sinusoidal rate of flux change with respect to the rotor angle. The poles of the rotor keep this revolving magnetic field between the air gaps when it becomes synchronous, which leads to the net creation of torque. As discussed in Section 2.1, the machine model was developed in the Simscape™ environment. Six IGBTs with antiparallel diodes are wired in series and parallel combinations and connected with a DC voltage source to form the source module. The inverter produces line-to-neutral voltage for a three-phase balanced load. Four Hall elements evenly placed beneath a revolving magnet serve as the basis for the Hall-effect rotary encoder block's representation of a 360 • rotational position sensor. The four sinusoidal waveforms noted in Section 2.2 are produced by the elements.  The permanent magnets contained in the rotor of permanent magnet synchronous motors produce an undulating magnetic field, which powers the motor. Energized stator windings produce a magnetic field that interacts with this magnetic field, resulting in a sinusoidal rate of flux change with respect to the rotor angle. The poles of the rotor keep this revolving magnetic field between the air gaps when it becomes synchronous, which leads to the net creation of torque. As discussed in Section 2.1, the machine model was developed in the Simscape™ environment. Six IGBTs with antiparallel diodes are wired in series and parallel combinations and connected with a DC voltage source to form the source module. The inverter produces line-to-neutral voltage for a three-phase balanced load. Four Hall elements evenly placed beneath a revolving magnet serve as the basis for the Hall-effect rotary encoder block's representation of a 360° rotational position sensor. The four sinusoidal waveforms noted in Section 2.2 are produced by the elements.
Field-oriented control is the preferred technique in applications that demand higher torque with low starting current and high efficiency in PMSMs. By transforming the static phase currents to a dynamic or rotating frame, this method simply separates the signals for flux and torque. The rotor dq frame is employed as a reference point for the FOC used in this model. Figure 9 shows the FOC control design. Here, ω and ωref are the measured and reference level angular velocities, Tref is the reference torque, and θe is the rotor electrical angle. The dq frame current references are represented by idr and iqr, whereas vdr and vqr are the reference voltages. The implemented controller can effectively track the reference signal. The model has a thorough sensing unit for careful examination of the motor's behavior, in addition to targeted monitoring and logging of the Hall-effect rotary encoder. These characteristics are utilized both for analysis and as feedback to the field-oriented controller, which iteratively modifies the controller gains to maintain stable electrical behavior. Field-oriented control is the preferred technique in applications that demand higher torque with low starting current and high efficiency in PMSMs. By transforming the static phase currents to a dynamic or rotating frame, this method simply separates the signals for flux and torque. The rotor dq frame is employed as a reference point for the FOC used in this model. Figure 9 shows the FOC control design. Here, ω and ω ref are the measured and reference level angular velocities, T ref is the reference torque, and θ e is the rotor electrical angle. The dq frame current references are represented by i dr and i qr , whereas v dr and v qr are the reference voltages. The implemented controller can effectively track the reference signal. The model has a thorough sensing unit for careful examination of the motor's behavior, in addition to targeted monitoring and logging of the Hall-effect rotary encoder. These characteristics are utilized both for analysis and as feedback to the field-oriented controller, which iteratively modifies the controller gains to maintain stable electrical behavior.  Figure 10 shows the adopted experimental arrangement to analyze the dynamic performance of the permanent magnet synchronous machine under sensor faults and extract the real time data. The experimental arrangement consists of a 1 kW PMSM coupled with the mechanical loading arrangement. An IGBT-based two-level voltage source inverter is employed to drive the PMSM. The gate pulse signal for the converter is provided by the real-time FPGA controller. The VHDL code for Hall-effect sensor-based PMSM field-ori-  Figure 10 shows the adopted experimental arrangement to analyze the dynamic performance of the permanent magnet synchronous machine under sensor faults and extract the real time data. The experimental arrangement consists of a 1 kW PMSM coupled with the mechanical loading arrangement. An IGBT-based two-level voltage source inverter is employed to drive the PMSM. The gate pulse signal for the converter is provided by the real-time FPGA controller. The VHDL code for Hall-effect sensor-based PMSM field-oriented control was developed and implemented on a Xilinx Artix ® -7 FPGA processor. The VHDL logic gates for FOC are shown in Figure 11. The ratings of the PMSM, converter, and controller are shown in Table 1. To obtain the speed feedback, the PMSM machine is integrated with a Hall-effect encoder and signal conditioning circuit. Moreover, the controller receives feedback signals from the Hall-effect current and voltage sensors through signal conditioning and the filtering circuit. The sensed signals from sensors are fed to analog-to-digital channels of the FPGA controller, and these signals are recorded on the computer. The offset fault is created manually by adjusting the sensor gain in the signal conditioning circuit. Similarly, the quadrature error is created by varying the Hall-effect sensor output angle through integrating a variable for external input. The field-orientedcontrolled PMSM's performance under different operating conditions was analyzed under different operating and fault conditions.  Figure 10 shows the adopted experimental arrangement to analyze the dynamic p formance of the permanent magnet synchronous machine under sensor faults and ext the real time data. The experimental arrangement consists of a 1 kW PMSM coupled w the mechanical loading arrangement. An IGBT-based two-level voltage source inverte employed to drive the PMSM. The gate pulse signal for the converter is provided by real-time FPGA controller. The VHDL code for Hall-effect sensor-based PMSM fieldented control was developed and implemented on a Xilinx Artix ® -7 FPGA processor. VHDL logic gates for FOC are shown in Figure 11. The ratings of the PMSM, conver and controller are shown in Table 1. To obtain the speed feedback, the PMSM machin integrated with a Hall-effect encoder and signal conditioning circuit. Moreover, the c troller receives feedback signals from the Hall-effect current and voltage sensors thro signal conditioning and the filtering circuit. The sensed signals from sensors are fed analog-to-digital channels of the FPGA controller, and these signals are recorded on computer. The offset fault is created manually by adjusting the sensor gain in the sig conditioning circuit. Similarly, the quadrature error is created by varying the Hall-ef sensor output angle through integrating a variable for external input. The field-orient controlled PMSM's performance under different operating conditions was analyzed der different operating and fault conditions.  The VHSIC Hardware Description Language (VHDL) is a hardware description la guage that may be used for design entry, documentation, and verification. It can represe the behavior and structure of digital systems at various levels of abstraction, from t system level down to that of logic gates. Dataflow modeling, behavioral modeling, a structural modeling are all used in the architecture of the VHDL code for the FOC PMS The primary design of VHDL for FOC PMSM is depicted in Figure 11a. It has a clo capture a, capture b, and capture c for input from Hall-effect sensors, program enab status, and speed reference (set PWM). In addition to this, the developed fault detecti algorithm was embedded in an FPGA controller and tested. When the fault is identifie an indication is given. Figure 11b also depicts the VHDL's internal design.    The VHSIC Hardware Description Language (VHDL) is a hardware description language that may be used for design entry, documentation, and verification. It can represent the behavior and structure of digital systems at various levels of abstraction, from the system level down to that of logic gates. Dataflow modeling, behavioral modeling, and structural modeling are all used in the architecture of the VHDL code for the FOC PMSM. The primary design of VHDL for FOC PMSM is depicted in Figure 11a. It has a clock, capture a, capture b, and capture c for input from Hall-effect sensors, program enable status, and speed reference (set PWM). In addition to this, the developed fault detection algorithm was embedded in an FPGA controller and tested. When the fault is identified, an indication is given. Figure 11b also depicts the VHDL's internal design.

Results and Discussion
As per the work process, the PMSM was tested under various operating conditions and the data were extracted and the algorithm trained. The machine was permitted to run normally (with full load and no load) for the first 1.2 s. At this point, the rotary encoder quadrature error was activated, and variations in speed, torque, and current were noted. Similar to the first simulation, the variance in speed, torque, and current was observed when the rotary encoder offset error was activated at 1.2 s (Figure 12). The machine ran without any load while experiencing a sensor error.

Results and Discussion
As per the work process, the PMSM was tested under various operating condi and the data were extracted and the algorithm trained. The machine was permitted t normally (with full load and no load) for the first 1.2 s. At this point, the rotary enc quadrature error was activated, and variations in speed, torque, and current were n Similar to the first simulation, the variance in speed, torque, and current was obse when the rotary encoder offset error was activated at 1.2 s (Figure 12). The machin without any load while experiencing a sensor error. Speed: The machine's speed under quadrature error had a steady throbbing s Because the speed oscillation's amplitude is so small, it has no effect on the motor's s When there was an offset error, oscillation occurred slowly at first and then acceler Later, the speed amplitude also decreased.
Torque:Under quadrature error, the machine's electromagnetic torque had a st pulsing shape, and increased from 0 to 0.78 p.u. of its rated value. When there w offset error, the torque oscillation was higher initially, before decreasing. The torqu plitude exceeded 1.p.u. in later stages.
Current: According to the findings, the second phase's current increased from 0.78 p.u. under quadrature error. The other two-phase currents also rose, from 0.1 to p.u. In the case of offset error, all of the phase current's waveform trend changed pletely, and the magnitude increased beyond 1.p.u.
The stator current of an FOC-controlled PMSM with quadrature error and offset is shown in Figure 13a,b, respectively, which demonstrate an experiment that was ca out ina similar manner. The machine was permitted to operate at 0.4 p.u. load u healthy conditions for the duration of the trial before the rotor fault was enabled. Speed: The machine's speed under quadrature error had a steady throbbing shape. Because the speed oscillation's amplitude is so small, it has no effect on the motor's speed. When there was an offset error, oscillation occurred slowly at first and then accelerated. Later, the speed amplitude also decreased.
Torque:Under quadrature error, the machine's electromagnetic torque had a steady pulsing shape, and increased from 0 to 0.78 p.u. of its rated value. When there was an offset error, the torque oscillation was higher initially, before decreasing. The torque amplitude exceeded 1.p.u. in later stages.
Current: According to the findings, the second phase's current increased from 0.1 to 0.78 p.u. under quadrature error. The other two-phase currents also rose, from 0.1 to 0.44 p.u. In the case of offset error, all of the phase current's waveform trend changed completely, and the magnitude increased beyond 1.p.u.
The stator current of an FOC-controlled PMSM with quadrature error and offset error is shown in Figure 13a,b, respectively, which demonstrate an experiment that was carried out ina similar manner. The machine was permitted to operate at 0.4 p.u. load under healthy conditions for the duration of the trial before the rotor fault was enabled.
The training data were entered into the MATLAB Classification Learner App to train the model. For this fault detection system, a single machine learning algorithm would provide inferior results; therefore, melded multi-agent ensemble learning models were used. These ensemble models have lower interpretability but are relatively fast to train and memory efficient. Using parallel computing, five ensemble models were trained simultaneously. The models used and their classification results are shown in Table 2. The highest accuracy of 95.8% was achieved with the subspace KNN ensemble model. Further analysis of this model is shown in Figure 14a,b through a confusion matrix and parallel coordinates plot. Closer examination of the results showed that certain combinations of classifiers are not suited for unveiling the pattern of the sensor faults, although they may have a more suitable role in other applications. This was partly expected due to the properties of the various classifiers. The AdaBoost model, for example, is adept at handling binary classification,but does not perform as well in cases such as ours where there are multiple classes. As the RUS Boost model is an enhanced derivative of AdaBoost, it has a similar bottleneck. Alternatively, using the same decision trees with a random forest meta-estimator effectively controls overfitting when managing multiple decision trees;this is beneficial in our case, as the model needs to maintain flexibility regarding various levels of fault intensity. This is reflected in the results, which show a higher accuracy for the random forest ensemble than for the boosted methods. Finally, the subspace clustering mechanism is shown to be highly accurate, especially with the KNN algorithm. This high accuracy is likely due to the fact that subspace clustering specializes in cases such as that being studied, where there are a large number of high-dimension features available and the clustering needs to extend beyond a traditional entity into more unconventional patterns. It can be seen that using the framework of a well-matched classifier ensemble for intelligent fault detection leads to superior diagnostic accuracies. Furthermore, using this type of a system for Hall-effect sensors, based on customizing the framework in terms of its characteristics, and using a model for support, is unique to this work and beneficial to developing more modern systems.  The training data were entered into the MATLAB Classification Learner App to train the model. For this fault detection system, a single machine learning algorithm would provide inferior results; therefore, melded multi-agent ensemble learning models were used. These ensemble models have lower interpretability but are relatively fast to train and memory efficient. Using parallel computing, five ensemble models were trained simultaneously. The models used and their classification results are shown in Table 2. The highest accuracy of 95.8% was achieved with the subspace KNN ensemble model. Further analysis of this model is shown in Figure 14a,b through a confusion matrix and parallel coordinates plot. Closer examination of the results showed that certain combinations of classifiers are not suited for unveiling the pattern of the sensor faults, although they may have a more suitable role in other applications. This was partly expected due to the properties of the various classifiers. The AdaBoost model, for example, is adept at handling binary classification,but does not perform as well in cases such as ours where there are multiple classes. As the RUS Boost model is an enhanced derivative of AdaBoost, it has a similar bottleneck. Alternatively, using the same decision trees with a random forest metaestimator effectively controls overfitting when managing multiple decision trees;this is beneficial in our case, as the model needs to maintain flexibility regarding various levels of fault intensity. This is reflected in the results, which show a higher accuracy for the random forest ensemble than for the boosted methods. Finally, the subspace clustering mechanism is shown to be highly accurate, especially with the KNN algorithm. This high accuracy is likely due to the fact that subspace clustering specializes in cases such as that being studied, where there are a large number of high-dimension features available and the clustering needs to extend beyond a traditional entity into more unconventional patterns. It can be seen that using the framework of a well-matched classifier ensemble for intelligent fault detection leads to superior diagnostic accuracies. Furthermore, using this type of a system for Hall-effect sensors, based on customizing the framework in terms of its characteristics, and using a model for support, is unique to this work and beneficial to developing more modern systems.  Although the results show a positive outlook regarding what can be achieved for sophisticated sensor systems, it is also important to discuss the issues that may arise when deployed commercially. In systems utilizing classification via intelligent methods, it is often debated whether the complexity of the mechanism makes it unsuitable for widespread use. This may be true to an extent with the mechanism developed in this study; however, closer inspection shows that the pipeline is highly integrated and requires little intervention. This means that the complexity for the user is reduced at the completion of the process. Although the complexity of acquiring data and training the model may still be high, a hybrid implementation using periods of collected data to train the machine during off-time may circumvent the complexity and boost the efficiency of the mechanism.  Although the results show a positive outlook regarding what can be achieved for sophisticated sensor systems, it is also important to discuss the issues that may arise when deployed commercially. In systems utilizing classification via intelligent methods, it is often debated whether the complexity of the mechanism makes it unsuitable for widespread use. This may be true to an extent with the mechanism developed in this study; however, closer inspection shows that the pipeline is highly integrated and requires little intervention. This means that the complexity for the user is reduced at the completion of the process. Although the complexity of acquiring data and training the model may still be high, a hybrid implementation using periods of collected data to train the machine during offtime may circumvent the complexity and boost the efficiency of the mechanism.

Conclusions
In the age of Industry 4.0, artificial sensory mechanisms in machines are as significant as sensory systems are to the human body. As a result of the rapidly expanding domain of remote condition monitoring and the Industrial Internet of Things, the focus on sensor systems has become even more significant. However, commensurate to their role in industry, sensors have an equally catastrophic impact on industrial setups when faults or errors exist in their measurement. In this study, a novel machine learning-based fault diagnosis system for Hall-effect rotary encoders used in lifts and hoists was developed. Position monitoring is essential in maintaining the seamless operation of PMSM lifts, and efficient fault mitigation is invaluable in this scenario. The developed system utilizes multi-learner models to train fault detection, achieving a maximum accuracy of 95.8%. The model is computationally lightweight and accurate, giving it the potential to consolidate with bespoke industrial setups and revolutionizing the domain of machine maintenance. Integrating the intelligent system with onboard PLCs would effectively reduce machine downtime due to erroneous readings. This will be the future scope of this work.

Conclusions
In the age of Industry 4.0, artificial sensory mechanisms in machines are as significant as sensory systems are to the human body. As a result of the rapidly expanding domain of remote condition monitoring and the Industrial Internet of Things, the focus on sensor systems has become even more significant. However, commensurate to their role in industry, sensors have an equally catastrophic impact on industrial setups when faults or errors exist in their measurement. In this study, a novel machine learning-based fault diagnosis system for Hall-effect rotary encoders used in lifts and hoists was developed. Position monitoring is essential in maintaining the seamless operation of PMSM lifts, and efficient fault mitigation is invaluable in this scenario. The developed system utilizes multi-learner models to train fault detection, achieving a maximum accuracy of 95.8%. The model is computationally lightweight and accurate, giving it the potential to consolidate with bespoke industrial setups and revolutionizing the domain of machine maintenance. Integrating the intelligent system with onboard PLCs would effectively reduce machine downtime due to erroneous readings. This will be the future scope of this work.