Design and Implementation of a Machine-Learning Observer for Sensorless PMSM Drive Control

: Information about rotor positions is critical when controlling a permanent-magnet synchronous motor (PMSM). This information can be gathered using a sensor or through an estimation without using a sensor. This article discusses a machine learning technique for estimating rotor positions. The proposed machine learning observer was constructed using a modiﬁed Elman neural network as the main algorithm. The network was trained ofﬂine with training data obtained from PMSM ﬁeld-oriented control simulations and was tested using a validation data set. The PMSM control simulation results revealed that the rotor position estimated through machine learning was comparable with the simulated rotor position; the average error was 0.0127 per unit position. Furthermore, the machine learning model was implemented in an experimental PMSM-control hardware platform. Both the simulation and experimental results indicate that the proposed machine learning observer has an acceptable performance.


Introduction
Electric motors have various uses in modern life, such as in household appliances, manufacturing, and transportation [1][2][3][4]. The permanent magnet synchronous motor (PMSM) is one of the numerous types of electric motors and has a high performance, strength, and torque. Therefore, numerous researchers have studied PMSMs; in particular, the control of PMSMs has attracted substantial attention. Field-oriented control (FOC) is the most frequently used strategy for PMSM control. Because the FOC scheme requires information about rotor positions, PMSMs are typically equipped with a sensor to read this parameter. However, for several reasons, the necessity to use a bulky sensor needs to be avoided to reduce production costs, eliminate reliability challenges, and minimize the effect of noise that can interfere with sensor performance; this method is called sensorless control.
Research on sensorless control strategies can be divided into two categories: (1) control during the initial startup and at a low speed [5][6][7] and (2) control at a medium or high speed [4,8,9]. The high-frequency injection technique is typically used for low speeds, whereas the back-electromotive force (EMF) method is used for high speeds.
As a subset of AI, machine learning (ML) has attracted attention due to its potential applications in many engineering disciplines, including powered electronics and motor part of MATLAB, Simulink has a Motor Control Blockset that contains several fundamental motor-control function blocks, such as the Clark and Park Transformations, space vector generators, and electrical system models, such as those for inverters and motors [36]. Thus, motor-control simulations can be performed rapidly, precisely, and accurately. Because of the precision and accuracy of the simulation data, ML models trained on these data are thought to perform well when implemented on real hardware. The present experimental results were obtained using a hardware control platform based on digital signal processors (DSP) from Texas Instruments (TI). The platform was developed with MATLAB's embedded coder support package, which can efficiently create a control algorithm from a Simulink model [11,37]. ML has high computational demands; thus, determining the sample time was critical to the success of the hardware implementation. Appl. Sci. 2022, 12, x FOR PEER REVIEW 3 of 21 algorithms, design and simulate the control schemes, generate the embedded code for hardware implementation, and control and retrieve data from experimental platforms. As a part of MATLAB, Simulink has a Motor Control Blockset that contains several fundamental motor-control function blocks, such as the Clark and Park Transformations, space vector generators, and electrical system models, such as those for inverters and motors [36]. Thus, motor-control simulations can be performed rapidly, precisely, and accurately. Because of the precision and accuracy of the simulation data, ML models trained on these data are thought to perform well when implemented on real hardware. The present experimental results were obtained using a hardware control platform based on digital signal processors (DSP) from Texas Instruments (TI). The platform was developed with MATLAB's embedded coder support package, which can efficiently create a control algorithm from a Simulink model [11,37]. ML has high computational demands; thus, determining the sample time was critical to the success of the hardware implementation.   algorithms, design and simulate the control schemes, generate the embedded code for hardware implementation, and control and retrieve data from experimental platforms. As a part of MATLAB, Simulink has a Motor Control Blockset that contains several fundamental motor-control function blocks, such as the Clark and Park Transformations, space vector generators, and electrical system models, such as those for inverters and motors [36]. Thus, motor-control simulations can be performed rapidly, precisely, and accurately. Because of the precision and accuracy of the simulation data, ML models trained on these data are thought to perform well when implemented on real hardware. The present experimental results were obtained using a hardware control platform based on digital signal processors (DSP) from Texas Instruments (TI). The platform was developed with MATLAB's embedded coder support package, which can efficiently create a control algorithm from a Simulink model [11,37]. ML has high computational demands; thus, determining the sample time was critical to the success of the hardware implementation.   The following steps were performed to develop the model: • An ML-based observer-training algorithm was developed on the basis of the modified ENN.

•
Training and validation data were recorded from the sensored PMSM-FOC digital simulation performed with Simulink.

•
The ML-based observer was trained and validated using the recorded data.

•
The validated ML function block was implemented in a Simulink simulation for a sensorless PMSM-FOC.

•
The ML-based observer was realized in a DSP-based hardware control scheme.
The remainder of this paper is organized as follows: Section 2 describes the PMSM drive system. Section 3 details the methodology for building the ML model, collecting learning data, and performing training and validations. The ML-based observer block is also described. In Section 4, the simulation results are presented and discussed. Section 5 presents the experimental results and discusses the implementation of the proposed algorithm. The final section concludes the paper.

PMSM Drive System
To control a PMSM using an ML-based observer, the observer need to be trained with data from a running PMSM control process. Training data were obtained from a simulation model instead of from a workbench control process.
In general, the mathematical model of a PMSM is expressed in the d-q synchronous rotating coordinate as follows: Here, v d and v q are the dand q-axis voltages, respectively, and r s is the winding resistance per phase of the stator. For a surface-mounted PMSM, L s = L d = L q , where L d and L q are the dand q-axis inductances, respectively; i d and i q denote the dand qaxis currents, respectively; the rotational speed of magnet flux is denoted as ω e ; and the permanent magnet flux linkage is denoted as λ f . Figure 1 indicates that i d and i q are obtained from Clarke and Park transformations of the phase currents. These currents are then controlled using proportional-integral (PI) current controls. The behavior is similar to a DC motor when the current i d is set to zero. In mode 2, the torque produced by the PMSM can be expressed as follows: Here, T e is the electromagnetic torque, K t is the torque constant, and N p is the pole pairs. If T L is the load torque, J is the inertia, and B is the friction constant, then the dynamic equation for the rotor speed (ω r ) of PMSM would be as follows: If θ is the rotor position angle, the d-q axes of v d and v q can be returned to the α-β frame by using Park's inverse function: Appl. Sci. 2022, 12, 2963 5 of 20 The three-phase currents (i a , i b , and i c ) from the PMSM are turned into two-phase α-β currents using the Clarke transform: The two-phase α-β currents are then transformed into currents in the d-q axis as i d and i q with the Park transform as follows: i q = −I α sin θ + I β cos θ (10) Figure 1 indicates that the FOC process comprises two control loops, typically called the inner loop and the outer loop. The inner loop control is the control of i d and i q . The outer loop control is the speed control. Both types of control are achieved using PI control strategies. Furthermore, a Simulink-based control simulation with sensors is performed to obtain the desired training data information for v α , v β , I α , I β , sin θ and cos θ.

Machine Learning
A flowchart of ML is presented in Figure 3. ML is the study of computer algorithms that can learn and develop on their own with experience and data [38]. Appl. Sci. 2022, 12, x FOR PEER REVIEW 5 of 21 The three-phase currents ( , , and ) from the PMSM are turned into two-phase -currents using the Clarke transform: The two-phase α-β currents are then transformed into currents in the d-q axis as and with the Park transform as follows: = − + (10) Figure 1 indicates that the FOC process comprises two control loops, typically called the inner loop and the outer loop. The inner loop control is the control of and . The outer loop control is the speed control. Both types of control are achieved using PI control strategies. Furthermore, a Simulink-based control simulation with sensors is performed to obtain the desired training data information for , , , , , and .

Machine Learning
A flowchart of ML is presented in Figure 3. ML is the study of computer algorithms that can learn and develop on their own with experience and data [38]. An ML algorithm is initially a computational algorithm with a particular structure that provides random output. After each round of learning with training data, the algorithm capability is updated and the outputs are improved. A validation data set is then used to test the performance of the model. During testing, the ML model should give the correct output for each corresponding input with a low error rate. After updating its estimation capabilities, the model gives the desired output in accordance with previously learned input data features.

Modified ENN
In this study, the ENN was used as the core of the ML-based observer. The ENN is a network with memory neurons and a context layer [24]. The context-layer neurons store An ML algorithm is initially a computational algorithm with a particular structure that provides random output. After each round of learning with training data, the algorithm capability is updated and the outputs are improved. A validation data set is then used to test the performance of the model. During testing, the ML model should give the correct output for each corresponding input with a low error rate. After updating its estimation capabilities, the model gives the desired output in accordance with previously learned input data features.

Modified ENN
In this study, the ENN was used as the core of the ML-based observer. The ENN is a network with memory neurons and a context layer [24]. The context-layer neurons store data generated by the hidden-layer neurons during each cycle; the stored data are then Appl. Sci. 2022, 12, 2963 6 of 20 used as inputs for the hidden-layer neurons in the next cycle. The context and hidden layers have the same number of neurons. Figure 4 shows how values from the output layer are fed back to the input layer to improve ML performance. The number of input neurons is increased to handle this feedback. The initial four neurons (v α , v β I α and I β ) were increased to six neurons due to the additional feedback of sin θ and cos θ. Appl. Sci. 2022, 12, x FOR PEER REVIEW 6 of 21 data generated by the hidden-layer neurons during each cycle; the stored data are then used as inputs for the hidden-layer neurons in the next cycle. The context and hidden layers have the same number of neurons. Figure 4 shows how values from the output layer are fed back to the input layer to improve ML performance. The number of input neurons is increased to handle this feedback. The initial four neurons ( , , , and ) were increased to six neurons due to the additional feedback of and . During the training process, the updating weight in this algorithm is the difference between the output neuron value and target output value. This process is the same as that in the BPNN. However, because the modified ENN has more input neurons and has a context layer, the required training time and execution time are longer than for the BPNN. Nonetheless, with the addition of this input, the observer's performance becomes much better because it can overcome the problem of speed transition.
The modified ENN algorithm depicted in Figure 4 was developed with the following steps:


Step 1. The number of neurons in each layer is initially established. The input layer has six neurons (k + n), the output layer (n) has two neurons, and both the hidden layer and the context layer have seven neurons (m). The learning-rate value (lr) is 0.001.  Step 2. The weights for each input layer (wil), context layer (wcl), and hidden layer (whl); the bias value of the hidden layer (bhl) and output layer (bol); and the memory coefficients of the context layer (mcho and mch) are randomly generated.  Step 3. In the first iteration of the training process, the context-layer neuron values must be initiated (z′).  Step 4. Each neuron from the input layer (x and y′) and context layer (z′) is distributed to the input of each neuron in the hidden layer. Finally, these values are summed During the training process, the updating weight in this algorithm is the difference between the output neuron value and target output value. This process is the same as that in the BPNN. However, because the modified ENN has more input neurons and has a context layer, the required training time and execution time are longer than for the BPNN. Nonetheless, with the addition of this input, the observer's performance becomes much better because it can overcome the problem of speed transition.
The modified ENN algorithm depicted in Figure 4 was developed with the following steps:

•
Step 1. The number of neurons in each layer is initially established. The input layer has six neurons (k + n), the output layer (n) has two neurons, and both the hidden layer and the context layer have seven neurons (m). The learning-rate value (lr) is 0.001.

•
Step 2. The weights for each input layer (wil), context layer (wcl), and hidden layer (whl); the bias value of the hidden layer (bhl) and output layer (bol); and the memory coefficients of the context layer (mcho and mch) are randomly generated.

•
Step 3. In the first iteration of the training process, the context-layer neuron values must be initiated (z ).

•
Step 4. Each neuron from the input layer (x and y ) and context layer (z ) is distributed to the input of each neuron in the hidden layer. Finally, these values are summed with an appropriate bias value (vb). The summation results are then input into the activation function to obtain the output value of each hidden-layer neuron (z).

•
Step 5. The output values of the hidden-layer neurons (z) are fed back to the context layer and become z for the next iteration. Moreover, z is weighted (w) and is distributed to the next layer for each neuron in the output layer (y). All inputs from each hidden-layer neuron (z) are summed with an appropriate bias (wb). The summation results are then used on the activation function to obtain the value of each output-layer neuron (y).

•
Step 6. The activation function calculation result for the output-layer neurons is the output of the network. This output is fed back to the input layer as y and is compared with the target output to obtain an error value.

•
Step 7. The weights and biases of the network are updated on the basis of the error values and learning rate.

•
Step 8. Steps 4-7 are repeated until the desired number of training cycles (maximum epoch) is reached or the convergence condition is met.
Next, the generated model had to be tested using actual learning data. Data were obtained by running a sensored PMSM-FOC simulation on MATLAB Simulink.

Learning Process
In the learning step, ML requires both training data and validation data. The learning data must be gathered from a reliable source [16]. A sensored PMSM-FOC simulation based on MATLAB Simulink was performed and was used to acquire learning data ( Figure 5). with an appropriate bias value (vb). The summation results are then input into the activation function to obtain the output value of each hidden-layer neuron (z).  Step 5. The output values of the hidden-layer neurons (z) are fed back to the context layer and become z′ for the next iteration. Moreover, z is weighted (w) and is distributed to the next layer for each neuron in the output layer (y). All inputs from each hidden-layer neuron (z) are summed with an appropriate bias (wb). The summation results are then used on the activation function to obtain the value of each outputlayer neuron (y).  Step 6. The activation function calculation result for the output-layer neurons is the output of the network. This output is fed back to the input layer as y′ and is compared with the target output to obtain an error value.  Step 7. The weights and biases of the network are updated on the basis of the error values and learning rate.  Step 8. Steps 4-7 are repeated until the desired number of training cycles (maximum epoch) is reached or the convergence condition is met.
Next, the generated model had to be tested using actual learning data. Data were obtained by running a sensored PMSM-FOC simulation on MATLAB Simulink.

Learning Process
In the learning step, ML requires both training data and validation data. The learning data must be gathered from a reliable source [16]. A sensored PMSM-FOC simulation based on MATLAB Simulink was performed and was used to acquire learning data (Figure 5). The motor parameters are presented in Table 1. In the simulation, the PI control parameters for the current loop were Kp = 1.7011 and Ki = 3098.9, whereas the PI control parameters for the speed loop were Kp = 0.4595 and Ki = 6.0661. The sampling frequency was 10 kHz. To optimize the computational process, the values of several variables using a The motor parameters are presented in Table 1. In the simulation, the PI control parameters for the current loop were K p = 1.7011 and K i = 3098.9, whereas the PI control parameters for the speed loop were K p = 0.4595 and K i = 6.0661. The sampling frequency was 10 kHz. To optimize the computational process, the values of several variables using a per-unit system (p.u system) were used to scale the international value system of unit or SI values as p.u-values from −1 to 1 [39].

Training Data and Validation Data
A control system has a certain control range; this is also true in the present ML-based control system. The ML network must learn from training data that cover the entire range of motor speeds and torque control operations, including both speed and torque transitions. The speed variation commands and load variation profile for training data acquisition are shown in Figure 6a. Validation data were acquired using the profiles displayed in Figure 6b. per-unit system (p.u system) were used to scale the international value system of unit or SI values as p.u-values from −1 to 1 [39]. A control system has a certain control range; this is also true in the present ML-based control system. The ML network must learn from training data that cover the entire range of motor speeds and torque control operations, including both speed and torque transitions. The speed variation commands and load variation profile for training data acquisition are shown in Figure 6a. Validation data were acquired using the profiles displayed in Figure 6b.  For the training and validation processes, learning data were recorded from a simulation. An example of the acquired data is presented in Figure 7. Data were recorded and saved as arrays; each data array contained six values: v α , v β , I α , I β , sin θ and cos θ. The sizes of the training and validation data arrays were 660.000 and 100.000, respectively. For the training and validation processes, learning data were recorded from a simulation. An example of the acquired data is presented in Figure 7. Data were recorded and saved as arrays; each data array contained six values: , , , , , and . The sizes of the training and validation data arrays were 660.000 and 100.000, respectively.

Training and Validation
A set of training-routine programs was successfully created using MATLAB on the basis of the algorithm described in Section 3.2. The training process was executed several times to obtain the optimal training parameters and results. The optimal learning rate was 0.001, and the optimal number of neurons in the hidden layer was seven. The mean square error reached 3 × 10 −6 ; the epoch error graph during training is presented in Figure 8. The trend of the graph shows that the ML model trains properly. The ML model's "brain" is the value of its weights, biases, and other coefficients at the end of the training process. A testing procedure with validation data can be used to confirm that the ML model has high performance for real data. Only steps 3, 4, and 5 (Section 3.2) were used during testing. A MATLAB testing routine program was created and successfully executed. Figure 9a,b presents the error histograms for the training and validation data, respectively. Most errors in Figure 9a,b are close to zero; thus, the existing ML model is accurate and can be applied further as the core of the ML-based observer.

Training and Validation
A set of training-routine programs was successfully created using MATLAB on the basis of the algorithm described in Section 3.2. The training process was executed several times to obtain the optimal training parameters and results. The optimal learning rate was 0.001, and the optimal number of neurons in the hidden layer was seven. The mean square error reached 3 × 10 −6 ; the epoch error graph during training is presented in Figure 8. The trend of the graph shows that the ML model trains properly. For the training and validation processes, learning data were recorded from a simulation. An example of the acquired data is presented in Figure 7. Data were recorded and saved as arrays; each data array contained six values: , , , , , and . The sizes of the training and validation data arrays were 660.000 and 100.000, respectively.

Training and Validation
A set of training-routine programs was successfully created using MATLAB on the basis of the algorithm described in Section 3.2. The training process was executed several times to obtain the optimal training parameters and results. The optimal learning rate was 0.001, and the optimal number of neurons in the hidden layer was seven. The mean square error reached 3 × 10 −6 ; the epoch error graph during training is presented in Figure 8. The trend of the graph shows that the ML model trains properly. The ML model's "brain" is the value of its weights, biases, and other coefficients at the end of the training process. A testing procedure with validation data can be used to confirm that the ML model has high performance for real data. Only steps 3, 4, and 5 (Section 3.2) were used during testing. A MATLAB testing routine program was created and successfully executed. Figure 9a,b presents the error histograms for the training and validation data, respectively. Most errors in Figure 9a,b are close to zero; thus, the existing ML model is accurate and can be applied further as the core of the ML-based observer. The ML model's "brain" is the value of its weights, biases, and other coefficients at the end of the training process. A testing procedure with validation data can be used to confirm that the ML model has high performance for real data. Only steps 3, 4, and 5 (Section 3.2) were used during testing. A MATLAB testing routine program was created and successfully executed. Figure 9a,b presents the error histograms for the training and validation data, respectively. Most errors in Figure 9a,b are close to zero; thus, the existing ML model is accurate and can be applied further as the core of the ML-based observer.

ML Function Block
The obtained ML model was used to estimate the values of and . A function block of the model was constructed to implement the ML model in the simulation ( Figure 10).

ML Function Block
The obtained ML model was used to estimate the values of and . A function block of the model was constructed to implement the ML model in the simulation ( Figure 10).

PLL
The ML model output can be used to estimate sin θ and cos θ; however, Figure 1 indicates that in sensorless control, the observer should be able to estimate the rotor position. Thus, a PLL was used to estimate the rotor position [11]. The PLL architecture is presented in Figure 11.

PLL
The ML model output can be used to estimate and ; however, Figure indicates that in sensorless control, the observer should be able to estimate the rotor po tion. Thus, a PLL was used to estimate the rotor position [11]. The PLL architecture presented in Figure 11. The serial connection between the ML block and the PLL is the proposed ML-bas observer.

Simulation Results
In this section, a simulated implementation of the proposed ML-based observer fo sensorless PMSM-FOC is discussed. The goal of the simulation was to determine the v lidity and performance of the proposed observer when it is implemented in a full-contr process environment. The simulation was performed with MATLAB Simulink and w based on the architecture displayed in Figure 1. Full PMSM and inverter models are ava able in the Motor Control Blockset library of Simulink. Figure 12a presents the rotor-speed simulation results. The load was 0.1 p.u-torq (0.027 Nm). From the standstill condition and for a predetermined time (4 s), the mot rotated in a ramp speed with the Volt/Hz strategy to the 0.1 p.u-speed (410 rpm). Wh the reference speed exceeded 0.1 p.u-speed, the sensorless closed-loop process was en bled. The serial connection between the ML block and the PLL is the proposed ML-based observer.

Simulation Results
In this section, a simulated implementation of the proposed ML-based observer for a sensorless PMSM-FOC is discussed. The goal of the simulation was to determine the validity and performance of the proposed observer when it is implemented in a full-control process environment. The simulation was performed with MATLAB Simulink and was based on the architecture displayed in Figure 1. Full PMSM and inverter models are available in the Motor Control Blockset library of Simulink. Figure 12a presents the rotor-speed simulation results. The load was 0.1 p.u-torque (0.027 Nm). From the standstill condition and for a predetermined time (4 s), the motor rotated in a ramp speed with the Volt/Hz strategy to the 0.1 p.u-speed (410 rpm). When the reference speed exceeded 0.1 p.u-speed, the sensorless closed-loop process was enabled.

Rotor-Speed Simulation Results
In the increasing speed simulation, the speed step references were 0.18, 0.26, 0.32, and 0.48 p.u-speed and continued to 0.36, 0.44, 0.54, and 0.6 p.u-speed; the ramp speed was increased from 0.24 to 0.65 p.u-speed. Most of the stepped reference-speed and ramping reference-speed values were not included in the training data ( Figure 6); however, the simulated system still performed highly.
A similar result was observed in the decreasing speed simulation. Decreasing speed variations from 0.65, 0.55, 0.45, and 0.25 p.u-speed and speed variations from 0.65 to 0.2 p.uspeed were also not included in the training data. However, the proposed observer was still effective. Figure 12a reveals that the suggested method's rotor speed value and the actual rotor speed both smoothly tracked the given speed reference. Thus, the proposed observer method worked successfully in transition speeds.

Rotor-Position Simulation Results
The performance of the proposed observer for determining the rotor position can be observed in Figure 12b-e. The position responses are presented at the four speeds of 0.18, 0.32, 0.48, and 0.65 p.u-speed, respectively. Overall, the positions of the observer and encoder were almost identical; the average position error was close to zero (0.0127 p.uposition). Figure 12b, for example, presents the results for 0.18 p.u-speed (738 rpm). The simulation result reveals that the time required for one electrical position cycle was 0.0203 s, and the time for one mechanical cycle was 0.0812 s. The rotation frequency was thus 12.4376 Hz, or 738.92 rpm. The other three speed calculation results are presented in Table 2.  Figure 13 presents the d-q current simulation responses. The proposed method is effective for the sensorless control strategy. In the sensorless mode, the current reference i q * was discovered to increase or decrease in accordance with the speed setting. For example, if the speed setting was increased from 0.26 p.u-speed to 0.32 p.u-speed, the motor required more current, causing an increase in the current i q * from 0.0308 to 0.0310 p.u-current, and vice versa. In general, the current i q smoothly followed the reference current i q *. The current i d was close to zero, following the setting of the current reference i d *. A small spike in i d was observed when the speed setting changed. A similar spike was observed for i q * and i q in response to a stepped speed change. Larger speed changes resulted in larger spikes.

Simulation Response for a Varied External Load
The simulation response for a varied external load is presented in Figure 14. The load variation is given at 0.45 p.u-speed. The motor was initially loaded with 0.1 of rated torque, and the load was increased to 0.2 of rated torque at t = 25 s. At t = 35 s, the load was reduced back to 0.1 of the rated torque.

Simulation Response for a Varied External Load
The simulation response for a varied external load is presented in Figure 14. The load variation is given at 0.45 p.u-speed. The motor was initially loaded with 0.1 of rated torque, and the load was increased to 0.2 of rated torque at t = 25 s. At t = 35 s, the load was reduced back to 0.1 of the rated torque.

Simulation Response for a Varied External Load
The simulation response for a varied external load is presented in Figure 14. The load variation is given at 0.45 p.u-speed. The motor was initially loaded with 0.1 of rated torque, and the load was increased to 0.2 of rated torque at t = 25 s. At t = 35 s, the load was reduced back to 0.1 of the rated torque.  As the load was increased, a spike occurred in the rotor-speed reduction to the minimum value of 0.443 p.u-speed at t = 25.174 s. Simultaneously, the current began to increase from 0.0313 to 0.0610 p.u-current. Under the decreased load condition (t = 35 s), the rotor speed spiked to a maximum value of 0.458 p.u-speed at t = 35.165 s, causing the current to decrease from 0.0610 to 0.0313 p.u-current. Although a spike in the motor speed occurred in response to a change in the load, the motor speed could return to its initial value, indicating that the proposed system is robust to load variations.

Experimental Hardware Realization
The proposed method was implemented on a hardware platform. The platform is depicted in Figure 15. The platform comprised a motor drive control module, a PMSM motor with the parameters listed in Table 1, a generator, and an electronic load module.
The proposed control algorithm was implemented on a TI motor-drive control consisting of TI DSP LAUNCHXL-F28069M and TI BOOSTXL-DRV8301 motor drivers. This DSP had a 90-MHz CPU, 256 kB of flash memory, 96 kB of RAM, 16 enhanced pulse-width modulation (e-PWM) channels, and 16 analog-to-digital converter (ADC) channels. Additionally, the DSP supports various serial communication protocols, including SCI, SPI, and I2C. It enables real-time command and response data transmissions to and from hardware via a Simulink host file.
In the hardware implementation, the speed control and current loop had sampling frequencies of 1 kHz and 10 kHz, respectively. The inverter's PWM switching frequency was set at 10 kHz. occurred in response to a change in the load, the motor speed could return to its initial value, indicating that the proposed system is robust to load variations.

Experimental Hardware Realization
The proposed method was implemented on a hardware platform. The platform is depicted in Figure 15. The platform comprised a motor drive control module, a PMSM motor with the parameters listed in Table 1, a generator, and an electronic load module. The proposed control algorithm was implemented on a TI motor-drive control consisting of TI DSP LAUNCHXL-F28069M and TI BOOSTXL-DRV8301 motor drivers. This DSP had a 90-MHz CPU, 256 kB of flash memory, 96 kB of RAM, 16 enhanced pulse-width modulation (e-PWM) channels, and 16 analog-to-digital converter (ADC) channels. Additionally, the DSP supports various serial communication protocols, including SCI, SPI, and I2C. It enables real-time command and response data transmissions to and from hardware via a Simulink host file.
In the hardware implementation, the speed control and current loop had sampling frequencies of 1 kHz and 10 kHz, respectively. The inverter's PWM switching frequency was set at 10 kHz. Figure 16a presents the experimental results for the rotor speed. The PMSM motor was attached to a generator but was not loaded. Initially, the motor was rotated at a ramp speed of 0.1 p.u-speed by using the Volt/Hz method. Later, at t = 15 s, the reference speed was increased to 0.15 p.u-speed, enabling the application of the sensorless control technique.  Figure 16a presents the experimental results for the rotor speed. The PMSM motor was attached to a generator but was not loaded. Initially, the motor was rotated at a ramp speed of 0.1 p.u-speed by using the Volt/Hz method. Later, at t = 15 s, the reference speed was increased to 0.15 p.u-speed, enabling the application of the sensorless control technique.

Experimental Rotor-Speed Results
The variable speed-step references for the increasing speed experiment were 0.15, 0.25, 0.35, 0.45, 0.55, and 0.65 p.u-speed. The experimental results revealed that both the actual motor speed and speed estimated by the proposed ML-based observer could successfully track the reference speed. The observer also successfully tracked the speed reference when the speed was reduced from 0.65 to 0.55, 0.45, 0.35, 0.25, and 0.15 p.u-speed. Thus, the proposed observer method also worked successfully in transition speeds on this hardware realization.

Experimental Rotor-Position Results
The proposed observer's performance in determining the rotor position on the experimental platform is presented in Figure 16b-e. The position responses are shown for four speed conditions: 0.15, 0.25, 0.45, and 0.65 p.u-speed. In general, the observer's rotor positions and actual rotor positions nearly matched, and the average position error was close to zero (0.0607 p.u-position). For example, Figure 16b presents the rotor position at 0.15 p.u-speed (615 rpm). The duration of one electrical position cycle was 0.026 s; therefore, the time for one mechanical cycle was 0.104 s. The rotational frequency was 9.6154 Hz (576.92 rpm). The results for the remaining three speeds are presented in Table 3.

Experimental Current Response in the d-q Axis
On the basis of the experimental speed variation presented in Figure 16a, Figure 17 displays the experimental results for the d-q current responses. For example, if the speed setting was adjusted from 0.25 to 0.35 p.u-speed, the current reference i q * increased from 0.0122 to 0.0129 p.u-current. As the motor speed decreased-for example, from 0.55 to 0.45 p.u-the current decreased from 0.0141 to 0.0134 p.u. The current i q can generally track the current reference i q *. A spike in i q * and i q was observed in response to the stepped speed adjustment. The experimental results indicated that the current i d trace was close to zero relative to the reference i d *.

Experimental Response of the Speed and Current with Varied External Load
The experimental response to varying external loads is presented in Figure 18. The motor was started using the Volt/Hz control technique; the generator was not loaded. The speed was then gradually increased from 0.1 to 0.25 p.u-speed and finally to 0.4 p.u-speed by using the proposed method. At t = 26.26 s, the generator was connected to an electrical load by using a 3 Ω resistor. The speed dropped temporarily but quickly recovered to 0.40 p.u-speed. At t = 26.39 s, a minimum speed of 0.367 p.u-speed was reached. After the load was connected, the currents iq* and iq increased by 0.033 p.u-current from 0.013 to 0.046 p.u-current. At t = 35.64 s, the load was disconnected. A short spike in speed was observed on the speed response graph to a maximum at 0.440 p.u-speed. The currents iq* and iq immediately returned to 0.013 p.u-current.

Experimental Response of the Speed and Current with Varied External Load
The experimental response to varying external loads is presented in Figure 18. The motor was started using the Volt/Hz control technique; the generator was not loaded. The speed was then gradually increased from 0.1 to 0.25 p.u-speed and finally to 0.4 p.u-speed by using the proposed method. At t = 26.26 s, the generator was connected to an electrical load by using a 3 Ω resistor. The speed dropped temporarily but quickly recovered to 0.40 p.u-speed. At t = 26.39 s, a minimum speed of 0.367 p.u-speed was reached. After the load was connected, the currents i q * and i q increased by 0.033 p.u-current from 0.013 to 0.046 p.u-current. At t = 35.64 s, the load was disconnected. A short spike in speed was observed on the speed response graph to a maximum at 0.440 p.u-speed. The currents i q * and i q immediately returned to 0.013 p.u-current.
A similar result was observed when the speed was increased to 0.65 p.u-speed and a 3-Ω load was applied. The speed sharply decreased to a minimum of 0.590 p.u-speed and sharply increased to a maximum of 0.710 p.u-speed when the load was applied (t = 50.90 s) and removed (t = 65.85 s). Applying the load also caused increases in the currents i q * and i q . These experiments revealed that the motor speed can recover quickly in response to a load, demonstrating that the proposed system is also robust when implemented in hardware. by using the proposed method. At t = 26.26 s, the generator was connected to an electrical load by using a 3 Ω resistor. The speed dropped temporarily but quickly recovered to 0.40 p.u-speed. At t = 26.39 s, a minimum speed of 0.367 p.u-speed was reached. After the load was connected, the currents iq* and iq increased by 0.033 p.u-current from 0.013 to 0.046 p.u-current. At t = 35.64 s, the load was disconnected. A short spike in speed was observed on the speed response graph to a maximum at 0.440 p.u-speed. The currents iq* and iq immediately returned to 0.013 p.u-current.  The next part discusses clarifying and verifying the roles of and linkages between the previous sections in realizing the PMSM sensorless control with ML-based observers. The proposed ML-based observer use modified the ENN as a basic algorithm of the ML model. The development of the ML model needs several steps. Section 3.2 outlined the steps. Then in Section 3.3.2, the ML model was trained and validated offline using a data-driven method, which was previously recorded from the simulation (Section 3.3.1). The validated ML model was attached to the ML function block (Section 3.4.1). The output of the function block was linked to the PLL function block (Section 3.4.2). The combination of these two function blocks formed the proposed ML-based observer. Then, the proposed ML-based observer was implemented in a full-control process environment to verify its performance. As a result, the simulation of the full-control process environment (Section 4) and experimental hardware (Section 5) confirmed that the proposed ML-based observer could be used in sensorless PMSM drive control. It can follow the transition of speed command changes well and is also robust to load changes.

Conclusions
An ML-based observer was successfully designed and implemented in a DSP-based sensorless PMSM-FOC process. A modified ENN algorithm, used as the ML model's basic architecture, was proven to overcome the speed transition problem. Data for training and validation were obtained from a simulated control process. The trained ML model combined with a PLL was the ML-based observer. The proposed observer was tested in a full-environment-control process simulation. An open-loop Volt/Hz startup strategy was used at the beginning of the control process, followed by the proposed sensorless control strategy. A hardware control platform based on DSP F28069M was used to experimentally implement the proposed observer. Compared to the actual rotor position, the rotor position estimated by the proposed ML-based observer has an average error of 0.0127 p.u-position on simulation and 0.0607 p.u-position on hardware implementation. Thus, the sensorless PMSM drive can be controlled well to follow the commanded speed and is robust to changes in load. Both the simulation and experimental results indicate that the proposed observer is effective as a sensorless PMSM-drive control system.