Optimization of an ANN-based speed and position estimator for an FOC-controlled PMSM using genetic algorithm

ABSTRACT


INTRODUCTION
In recent years, permanent magnet synchronous motors (PMSMs) have managed to gain an increased amount of research interest given its efficiency, flexibility in terms of speed, and cost-effectiveness [1].Control methods for the PMSM execute efficiency and robustness but these methods require information such as the rotor's speed and/or position which are accurately retrieved using mechanical sensors in the shaft of the ac machine.But with the introduction of sensorless methods, there presents the advantage of reducing cost and increasing the motor control system's ruggedness and reliability [2].In proposed models for PMSM speed and/or position estimation, there are model-based [3] and rotor-saliency-based techniques [2], [4].
Since model-based sensorless drives are very dependent on the motor parameters, variations or tolerances from the nominal value can affect the performance of the motor based on the decreased accuracy of the estimator which is an undesirable effect [5].Certain methods have also been developed to address variations in the motor parameters including the use of model-reference adaptive models (MRAS) [2], [6], [7].These MRAS-based solutions for parameter deviation are incorporated in the sensorless estimation 1392 method being used.However, when the speed and position estimator is modeled based on artificial neural networks, the compensation for the deviation in motor parameters are embedded in the estimation model itself as demonstrated in [8]- [11].
The use of neural networks in position and/or speed estimation is another popular method used along with MRAS, sliding mode observer (SMO), Luenberger observers, among others [12]- [19].Different network architectures have been implemented in rotor speed and/or position estimators such as feedforward [20]- [30], recurrent [20], [29], linear [29], and radial basis function [28] demonstrating advantages such as high estimation accuracy and good dynamic performance [29].In [11] proposed a neural network-based speed and position estimator that replaces the sliding-mode observer in conventional applications, providing accurate estimations without dependence on the motor parameters.However, most of the research on neural network-based estimators in field oriented control (FOC) have relied upon a trial-and-error method in determining the best hyperparameters including the number of neurons and layers in their proposed neural network architectures, while others have failed to identify the methods used in determining these hyperparameters.Genetic algorithm in hyperparameter optimization in other applications have resulted to improvements in the neural-network's adaptive ability and generalization [31].In this study, genetic algorithm is proposed to be used to optimize the hyperparameters of an artificial neural network that serves as a PMSM rotor's speed and position estimator.

MODELING THE ESTIMATOR 2.1. PMSM model
The PMSM is used in this study as the induction motor as it is known for its efficiency and higher torque density in terms of torque per unit volume [2].The rotor consists of surface-mounted permanent magnets and its stator has a -connected winding for every 120°.The 3-phase PMSM is regarded as a nonlinear time-varying system that can be simplified into a two-phase voltage model in synchronous rotating  −  corrdinates via the concepts of Clark and Park transformations.The model of the PMSM is shown in (1).
Where   ,   represents the -axis stator voltages of the PMSM;   ,   , representing the -axis stator currents;   ,   , representing the -axis stator inductances;   , represents the stator winding resistance of the PMSM;   , represents the rotor's angular speed; and   , represents the permanent magnets' flux-linkage.As mentioned, the  −  coordinate model can be transformed into an equivalent model in the stationary  −  coordinate system.The inverse Park transforms on the  −  model is shown in (2).
Where   ,   represents the alpha and beta stator voltages;   ,   represents the alpha beta stator currents;   represents the stator winding resistance of the PMSM;   represents the stator winding inductance; and   ,   represents the alpha beta equivalent back electromotive force (back-EMF) voltages.

Sensorless field oriented control scheme
FOC or the vector control of a PMSM is a motor drive control scheme or approach that improved the performance of an induction motor driven by an inverter.This approach can obtain near-instantaneous response in torque by transferring from a steady-state condition to another.With the motor's phase currents serving as the inputs, the first transformation is the alpha-beta transformation or also called as the Clarke transformation wherein the three-phase system is projected into a two-dimension orthogonal system.The mathematics behind the Clarke transform isolates the common-mode component among the three vectors as shown in (3).
Where   ,   ,   represents the three-phase motor currents;   ,   represents the alpha and beta axis projections of the motor currents.The Park transform will deliver the 2-D orthogonal system into a rotating 2-D Where   ,   represents the direct and quadrature projections of the motor currents;   ,   represents the alpha and beta axis projections of the motor currents.Proportional-integral controllers are used in the proposed control system to reduce certain error values to zero.Reference values for flux, speed, and torque are introduced.Reference flux should be zero since this follows the concept of FOC.The reference speed is user input.The reference torque value is simply obtained from the output of the proportional-integral (PI) controller for speed.Space vector modulation (SVM) is the control method to be used in FOC in driving the 3-phase PMSM in this proposal.The SVM is utilized due to its ability to make instantaneous changes in its output phasor's angular position which is advantageous when used for field-oriented control or vector control of a 3-phase motor.The block diagram for the entire field-oriented control scheme is shown in Figure 1.This includes the PMSM, the Clarke and Park transforms, the PI controllers, the observer, the space vector modulator, and the 3-phase inverter.This will be the same block diagram used in the proposed genetic algorithm (GA)-optimized neural network estimator which is to be represented by the observer block.

Neural network estimator model
In this study, the estimator block used takes the alpha and beta voltages and currents as the inputs to the neural network.The outputs come in the form of sin (  ) and cos (  ) that is a representation of the motor's equivalent alpha and beta back-EMF as shown in (5).
where   is the flux linkage of the permanent magnets;   is the rotor's angular speed;   and   represents the back-EMF voltages; and   is the electrical position of the motor.
where   and   represents the back-EMF voltages obtained from (5), and  ̂ is the estimated angle.To retrieve the estimated speed, the change in position is obtained using (7).where  ̂ is the position value determined from equation 6,  ̃ is the position obtained from integrating the rotor speed in the phase-locked loop (PLL), and   is the position error that serves as the input of the phaselocked loop as shown in Figure 2.
In Figure 2, the position error   is fed into a PI controller, the output of the PI controller is the estimated rotor speed  ̂.Integrating further, the estimated position  ̃ is obtained.The scheme, when using sine and cosine values highly reduces spikes from − to  [32].The proposed neural network estimator for optimization is shown in Figure 3.
In Li and Zhao [33], the PLL used the calculated alpha and beta back-EMF to estimate the speed and position.In this case, the SMO calculates the back-EMF which serves as the PLL input.The use of the PLL was proven to be effective in reducing estimation error and filtering high frequency components.By replacing the back-EMF with an artificial neural network (ANN), the proposed model will make use of the advantages of the PLL but without the disadvantages brought by conventional estimators like the inherent chattering when using the SMO.This performance will be validated by comparing the speed and position estimation errors.

Genetic algorithm optimization
As stated in this study, previous research involving the use of neural network estimators in fieldoriented control of PMSMs make use of trial and error or using the previous experimental data in determining certain hyperparameters.This study will introduce the use of genetic algorithm in optimizing the network hyperparameters for this application.The process for genetic algorithm to be used in this study is shown in Figure 4.The algorithm will start off with initializing a population.Each individual of the population will have its fitness evaluated.From the data of fitness values, the termination criterion is checked if already met.If not, the population enters parent selection wherein individuals are paired based on their individual fitness to generate an offspring.This offspring is developed by the crossover operator.The mutation operator is also used to help avoid convergence on a local minimum.This will ensure the effectiveness of the optimization process.In developing the genetic algorithm for the speed and position estimator, the termination criteria should be set.These criteria can come in the form of a maximum number of generations and/or in the form of a target mean-squared error (MSE).As for the hyperparameters to be optimized, a valid range of values should be declared from which the genetic algorithm will limit itself to.This range can be realized during the linear mapping process.The initial population is used as the initial values for the hyperparameters in the neural network design.The target hyperparameters to be optimized are the following: number of hidden layers, number of neurons for the hidden layers, activation function, batch size, initial mu, mu decrease factor, and the mu increase factor.

GA-optimized neural network experimental setup
The field-oriented control is modeled in Simulink as well as the neural network estimator.The dataset containing the alpha and beta voltages and currents as well as the target sine and cosine values are obtained from the simulation and is exported.The genetic algorithm optimization is done externally via python to obtain the set of hyperparameters with the best estimation accuracy.The optimized neural network model is imported back into the Simulink model for qualification.The motor used in this study is the X2212 980 KV II whose parameters are shown in Table 1.
The qualification of the proposed GA-optimized neural network estimator is conducted against the conventional methods of using the model-reference adaptive system (MRAS) and the sliding-mode observer (SMO) as well as two other neural network configurations from [11], [17].The performances of the estimators are also compared against when using sensors which is the reference performance.The Simulink model of the sensored FOC system is shown in Figure 5.

EXPERIMENTAL RESULTS
The performance of the proposed GA-optimized neural network estimator is verified using several comparative test cases against the sensor-based FOC, the conventional MRAS and SMO estimators, and two reference neural network configurations from [11], [17].A sample of the training dataset is retrieved first.Then the genetic algorithm data is also to be presented containing the various iterations made on the hyperparameters.Then the optimized neural network is compared against the other methods in steady-state condition to validate the estimation accuracy improvements made.Followed by the dynamic response, the input power drawn when using the different estimators is measure as well.For the purpose of simplicity in the data that follows, only the electrical angle of the motor will be presented.The actual rotor position measured as the reference is obtained as the mechanical angle and is simply converted into the electrical angle for comparison since the estimator's output is in electrical degrees.The conversion is done using the following equation: where   is the electrical angle,  ℎ is the mechanical angle, and  is the number of poles.

Training dataset
From the working model of the FOC system, the dataset to be used for the training of the neural network estimator was obtained.Due to the periodic behaviour of the motor, the dataset for a certain speed and load condition only covers one electric period.The dataset to be used are gathered at specific operating points of the motor.Conditions wherein the motor is not to be operated should not be included.The operating points in this study are from 1000 to 9000 rpm as the speed reference, and from 0.0 to 1.0 Nm as the motor load.A sample dataset for the 4000 rpm and 0.8 Nm Load operating point's voltages, currents, and sinecosine components are shown in Figure 6

Genetic algorithm optimization
Initially, there is a population of 100 individuals with genes that are randomly selected and that represents the hyperparameters of the neural network.The performance of each individual is determined by training a neural network using the individual's hyperparameters on the collected dataset.The GA was run for 30 generations.The performance of each individual in terms of its neural network's loss over the entire run is shown in Figure 7(a).
In Figure 7(a), majority of the individuals scored a loss of less than 0.3.The individuals that scored a loss of 1 are those that were unable to converge during training resulting in an error and were given the highest loss.The data is presented in three indicators for the tanh, linear, and sigmoid activation functions of the hidden layers for every individual.As better observed in Figure 7(b), majority of the individuals that uses the linear activation function are encountering resistance to perform better than a loss of 0.07.It can also be observed that a lot of individuals retain the sigmoid activation function through generations indicating it is performing relatively better than the two other activation functions, and numerous individuals are performing with a loss of less than 0.001.In considering a minimum loss of 0.0001, the individuals meeting this criterion are shown in Figure 7(c).The loss of the individual is plotted against the total number of neurons that it requires.From the figure it can be shown that the number of neurons does not solely dictate the best performing configuration but still relies on the remaining hyperparameters as there are individuals above the 250-neuron count but is outperformed by individuals in the 100 to 150 neuron count range.Based on the genetic algorithm optimization, the hyperparameters for the individual with the fewest neurons with a loss of less than 0.0001 and the best performing individual are shown in table, along with the configuration used in the reference neural networks [11], [17].As shown in Table 2, the activation function, batch size and the Levenberg-Marquardt hyperparameters are the same, save for the number of neurons in the hidden layers between the least complex and the best performing configuration.For the remainder of the study, the best performing set of hyperparameters is to be used due to its relatively better performance sans the complexity.The total time for the genetic algorithm optimization process was 14 hours and 38 minutes.The optimization was done without the aid of the graphics processing unit (GPU).

Steady-state performance
Qualifications for the estimators starts off with the speed and position estimation accuracy.The performances of the estimators for accuracy gives an insight into the expected response for the subsequent tests.Estimators with high accuracy would have an FOC performance comparable to when using a sensor-based system.The data for estimation accuracy is taken at steady state at a fixed speed reference of 4000 rpm with the rated load of 0.8 Nm.
The speed estimation is comparable for the estimators as shown in Figure 8, the variations manifest in the peak-to-peak and the average speed estimation error, but all estimators can average down on the actual 4000 rpm motor speed, with Figure 8(a) being the comparison between GA-NN and using a sensor.In comparing the performance of the GA-NN vs MRAS estimators, as shown in Figure 8(b), it is observed that the GA-NN easily outperforms the MRAS given the presence of a ripple in both the speed and position estimates.For the SMO comparison with the GA-NN, the SMO can better estimate the speed of the motor as shown in Figure 8(c).However, the inherent chattering in a SMO estimation is visible especially in the position estimation whereas the GA-NN has a more accurate and stable estimation relatively.The GA-NN position estimation is very comparable to that of the neural network reference 1 (NN REF 1) [11], there are some low frequency signatures on the NN REF 1 as compared to the GA-NN, as shown in Figure 8(d) but the signature of the estimation is still relatively similar.For the NN REF 2 performance however, the low frequency variations are more observable, as shown in Figure 8(e).The differences are also more profound when observing the transition from 2 pi radians to 0 radians in the vertical fall of the position value, the differences in terms of time for the transitions provide additional insights of how the estimates vary.
The steady state estimations of the proposed GA-optimized neural network against reference estimators provide an early insight as to the estimation accuracy performances.The peak-to-peak and the average estimation errors for both speed and position of the motor provides the metric in qualifying the different estimators, as shown in Table 3.
In Table 3, the proposed GA-NN estimator outperforms the other reference estimators in terms of speed estimation, for both -to- and average error.The SMO also has a very good estimation performance for the average position error, but the effect of the chattering is observable in the -to- error.For the speed estimation, the GA-NN has the smallest -to- error but the NN REF 1 [11] outperformed in terms of the average speed estimation error.The data presented gives an overview of the improvements made by optimizing the NN hyperparameters via genetic algorithm in terms of steady-state estimation.

Step-response performance
The step-response of the FOC using the estimators provides an outlook for the performance using the estimated values under dynamic conditions.The reference or target speed is stepped-up from 0 to 4000 rpm at 0.8 Nm load.The GA-NN estimation, as shown in Figure 9(a) had a leading response compared to a near vertical increase against the performance of the MRAS, as shown in Figure 9(b).There is also an observable overshoot against the GA-NN.An attempt to increase the speed was observed early for the MRAS response but was not able to reach the target speed initially.For the SMO response, as shown in Figure 9(c), it lagged the GA-NN response as well with no other abnormalities observed during the step input.The FOC system was able to reach its target speed for all three estimators used.
The signatures of the motor speed when using the GA-NN and the two reference neural network estimators are very similar as shown in Figure 9(d) and Figure 9(e).The GA-NN response is leading against the two reference NN estimators.The step-response comparisons show the effect of the difference in neural network configuration for a dynamic response.The GA-NN has performed relatively better than the two other neural network configurations.
The summary of the step-response measurements made on the GA-NN and the other reference estimators is shown in Table 4.As expected, the sensored FOC provides the best response to a step-input.The GA-NN however, outperforms all the other estimators used in terms of rise time and settling time.The MRAS has the lowest percent overshoot as compared to the other estimators.In terms of the steady-state error, the GA-NN has the same performance as the SMO both coming after the performance when using the sensor-based FOC.The data from Table 4 gives an overview on the effect of using a GA-optimized neural network estimator compared to the conventional estimators as well as other neural networks that are not optimized by genetic algorithm.

Performance at low speed
The performance of the estimators was also qualified for speed estimation at low speed.Some observers such as the back-EMF SMO are expected to perform poorly at lower speed due to the inherent nature of the model.As such, the estimators were evaluated at a 500-rpm target speed with 0.8 Nm load.
As can be observed in Figure 10, when comparing the performance of the GA-NN vs the reference estimators.There is an observable difference in terms of the peak-to-peak ripple of the estimation as shown in Figure 10(a), this makes it apparent that the inherent chattering in the SMO becomes more defined at lowspeed operation that is not observable in other estimators.As such, there is no distinguishable feature in the low-speed operation with the MRAS, and the two reference NN estimators, as shown in Figure 10

Efficiency
The efficiency of the FOC scheme using the estimators was compared to the efficiency when running on sensors.This was obtained by measuring the power drawn from the DC source or the battery at a steady state of 4000 rpm and 0.8 Nm.In this method, the load of the system is held constant while only updating the estimator being used, the difference in the power drawn will indicate the relative efficiency performance.
As shown in Table 5, when using the sensor, the FOC system draws the least average power compared to the FOC systems using an estimator which is expected.However, in comparison between the estimators themselves, the GA-optimized neural network managed to draw the least amount of power at 362.6 W. The performance of the GA-NN was followed closely by the conventional SMO estimator and by the NN REF 1 [11] by a margin of 0.4 W and 0.6 W respectively.These findings would indicate that the improvements in estimation in a GA-NN still comes short of the sensored performance but is a step in the right direction as it outperforms the rest of the estimators verified.The data shows that there is an improvement in efficiency when optimizing the hyperparameters of the neural network estimator as demonstrated by the performance of the proposed GA-NN.[11] 363.2 NN REF 2 [17] 363.8

CONCLUSION
The design and simulation of a neural network-based speed and position estimator for a field-oriented control PMSM was successfully done in the MATLAB/Simulink environment with the neural network hyperparameters optimized via genetic algorithm.The genetic algorithm optimized the following hyperparameters: batch size, Levenberg-Marquardt training parameters (initial µ, µ increase factor, µ decrease factor), activation function for the hidden layer/s, and the number of hidden layers and its corresponding number of neurons.The trained neural network based on the genetic algorithm-optimized hyperparameters managed to attain a mean-square error loss of 0.00001140 on the validation data.The proposed GA-optimized neural network has outperformed the other estimators during steady-state condition, speed range performance, step-response performance and efficiency.In comparing the proposed network against other neural network estimators, the optimization of the hyperparameters provide significant improvement in the performance of the estimation process leading to a better steady-state and dynamic response of the FOC.During qualification, some conditions provide room for improvement for all estimators including the performance during very low speeds of below 500 rpm, and the margin between the efficiency of the system when using sensors and when using estimators.

Figure 1 .
Figure 1.Sensorless field oriented control block diagram

Figure 2 .
Figure 2. Phase locked loop block diagram

Figure 5 .
Figure 5. Simulink model of the FOC system

Figure 7 .
Figure 7. Genetic algorithm optimization results (a) optimization scores, (b) zoomed-in version, and (c) neuron count vs loss


ISSN: 1693-6930 TELKOMNIKA Telecommun Comput El Control, Vol.21, No. 6, December 2023: 1391-1404 1402 This will deliver almost direct current (DC) values to be used as feedback values for the control loop.This transform enables the ease of control by manipulating these DC values instead of sinusoidal ones.The formula used for Park Transform is given by (4).

Table 1 .
Motor parameters

Table 2 .
Neural network configurations

Table 3 .
Steady-state performance summary

Table 5 .
Efficiency summary