Optimization of Model Predictive Control Weights for Control of Permanent Magnet Synchronous Motor by Using the Multi Objective Bees Algorithm

In this study, the model predictive control (MPC) method was used within the scope of the control of the permanent magnet synchronous motor (PMSM). The strongest aspect of the MPC, the ability to control multiple components with a single function, is also one of the most difficult parts of its design. The fact that each component of the function has different effects requires assigning different weight coefficients to these components. In this study, the Bees Algorithm (BA) is used to determine the weights. Using the multi-objective function in BA, it has been tried to determine the weights that reduce the current values together with the speed error. Three different PI controllers have been designed to compare the MPC method. The coefficients of one of these are tuned with BA. Good Gain Method and TyreusLuyben Method were used in the other two. As a result of experimental studies, it has been observed that MPC can control PMSM more smoothly and accurately than PI controllers, with weights optimized with BA. With MPC, PMSM has been controlled with 15% settling time than other controllers and also with no overshoot.


Introduction
Permanent Magnet Synchronous Motors (PMSM) have been used for many years due to their features such as high torque, high efficiency and fast dynamic structure.Within the scope of controlling PMSM; robust control [1], field-oriented control and direct torque control [2], fuzzy-based controllers [3,4], sliding mode controller [5], model predictive controller (MPC) [6], and so on different control methods have been used.Especially in high speed PMSMs, driver dynamics must be controlled successfully for effective control [7].When the applications in the literature are examined, it is seen that MPC gives successful results in this scope.Model Predictive Control (MPC), based on the optimal control theory, achieves successful results, especially in power electronics applications.MPC uses the system model equations together with the current state measurements to estimate the control movement.With this predictive ability, it can achieve more successful results against traditional controllers [8].
Three phase inverter circuits are one of the main methods used to drive PMSM.In these circuits, there can be a limited number of switching combinations for 6 switches.This is called the Finite Control Set (FCS).FCS-MPC can be implemented even in low cost devices used today due to the optimization process performed with a limited number of iterations [9].One of the major advantages of the FCS-MPC over other control methods is that different goals, variables, and constraints can be included in a single cost function and controlled simultaneously [10].Adding different categories of variables to the cost function brings great flexibility to MPC.However, the effects of these variables on the system may be different.Therefore, it is necessary to give weight coefficients for each of the variables.
Selection of weights for cost function of MPC optimization is one of the main challenge for researchers.When the MPC studies in the literature are examined, it is seen that a significant part of them are about to calculate these weights.It is seen that different methods are used in different applications.The highlights of these; empirical methods, fuzzy-based methods, evaluation algorithms, heuristic methods etc.In a sample study, a fuzzy-based calculation method was used in the PMSM current control application.Id and Iq currents were used in the cost function [11].In another study, torque control of PMSM with MPC was performed.Torque and flux variables were used in the cost function.While weight was not used for the torque variable, a weight depending on the torque has been determined for the flux variable [12].A different cost function that can be selected for the speed control of the PMSM may include the controller output and speed error.In order not to cause sudden effects on the system, the difference of the two control signals produced consecutively is added to the cost function [13].A similar strategy has been used in DC motor control.With the Quadratic problem approach, along with the speed error and the difference between the two consecutive outputs are included in the cost function [14].
FCS-MPC is also used in different fields other than electric motors and similarly the weights need to be calculated.Simulated Annealing Particle Swarm Optimization with Model Predictive Control was used to control of the electric vehicles [15].Another application that uses genetic algorithm is shunt active power filter.Link voltage, active power and reactive power are used in cost function of MPC within the scope of proper switching [16].In a different MPC application, the multi objective genetic algorithm was used to calculate the weights [17].
In this study, the control of the PMSM used as the driving element of an actuator to be used in the aerospace area was performed with FCS-MPC.Battery life is of great importance in the aerospace area.For this reason, when creating the MPC cost function, the power variable was added along with the speed and current variables.In the PMSM control problem, apart from minimizing the speed error, minimum current consumption is also aimed.In the scope of calculating the weights, the multi objective BA is used.When the studies in the literature are analyzed, it is seen that BA gives successful results against multi objective function problems [18][19][20].In order to compare the developed control system, 3 different PI controllers were designed.The second part of the study includes PMSM equations and MPC studies.The third part includes calculating weights with multi-objective BA studies.In the fourth chapter, there are studies on PI controller design.The fifth section includes experimental studies and comparisons.

PMSM equations and FCS-MPC design
In MPC design, first of all, it is necessary to prepare the mathematical model of the system.One of the most popular methods of controlling of PMSM with MPC is to use machine equations in the rotor reference frame [6].MPC is designed within the scope of speed control of PMSM.Therefore, speed and current equations were needed in the MPC cost function.
In the currents and torque equations; ψ m , i q , i d , v q , v d , R, L q , L d , w r , and p and are the rotor magnetic flux linkage, stator currents in q and d axis, stator voltages in q and d axis, stator resistance, stator inductances in q and d axis, rotor angular speed, and pole pairs respectively.In the equation of speed; J is the inertia, T l is the load torque, B is the viscous friction coefficient, and T e is the electrical torque produced by the motor [11].
In the equations, resistance, inductance, pole pairs, inertia, and magnetic flux values are known.(Motor resistance and inductance can vary depending on the motor temperature [21].This situation has been neglected in this study.It should be consideration in applications where the motor will operate under load for a long time.)In order to find Vd and Vq values, the inverter circuit must be analyzed.A typical 3 Phase Inverter circuit used in the study is given in Figure 1.The circuit has two driver components for each phase of the PMSM and switches for switching these components.(In this study, mosfet is used as the driver component, it is shown in green color in the figure .)In order that the components on the same phase are not switched at the same time, there is a note gate between them.Therefore, 3 switches (Switches S a ,S b , and S c shown in blue color in the figure .)are sufficient for switching operations.These 3 switches can be switched in 8 different combinations, each with a 0 or 1 [22].Conversions of V dc (Bus voltage) to V d and V q according to the switching states are found by Park-Clarke methods [23].
θ is the angle of rotation of the rotor in radians (In this study, it is measured by the encoder integrated into the PMSM.Also, w r is obtained by the derivative of θ.).Other unknowns of the equations are the I d and I q currents.I a ,I b ,andI c currents are measured with the current sensor.Again, Park-Clarke method is used for transition from abc phases to dq axis (In the Eq. ( 5), instead of switches, this time the currents are placed.).
Various discretization methods can be used to obtain a discrete-time model for calculating predictions.One of the simplest methods is the Forward Euler method, which is based on derivatives.In this method, the prediction expression is obtained by leaving the expression x(k + 1) alone.T s is the sampling time [23].
When the Forward Euler approach is applied to stator currents ( 1) and ( 2) the following MPC prediction equations are obtained [11].
In the equations, expressions with (k) show the values measured from PMSM at the previous sampling time, while the expressions with (k + 1) show the predicted values.
For each sampling time, for the 8 different Vd and Vq values given above, currents estimates will be made.Under normal conditions, what is expected from the microprocessor is to make these calculations in the period determined for the application and to generate the necessary control signal.In real application, the microprocessor also has many different tasks.Therefore, there may be delays in estimates.In this case, a dynamic system cannot be controlled successfully.Against these possible delays, it has been suggested to predict two next steps.In this study, the prediction equations for the next two steps were updated by taking this suggestion into consideration [24].
For velocity prediction, Eq. ( 4) is discretized by Forward Euler method.In the equation, i q k þ 2 ðÞ expression is used in T e [6].
For velocity control in PMSM, Eqs. ( 9), ( 10) and ( 11) may be sufficient in the cost function.But for a more effective cost function, it has been proposed to include the switching losses in the inverter circuit.In the sample study, the power variable was also added in this context, and the choices were made to use low power at each step of the control system [25].In this study, the power effect (P f Þ was added to the cost function.However, this effect is added as shown in (12) in a simple form so that the processing load does not increase.
One of the strong features of MPC is that the constraints required for the system can be defined in cost function.The combination that gives the best result among the switching alternatives may also cause high current from the PMSM.Therefore, the current constraint given in (13) has been added to the cost function [22].When the current values are higher than a limit value, a large value is assigned to the relevant switching option to be excluded from the options.(In the part indicated by ∞ in the equation, 1e10 is used in the application.) The final version of the cost function is shown below.For each sampling time, for 8 different switching combinations, current and velocity prediction will be performed and the cost function defined in (14) will be calculated.After 8 iterations, the switching configuration that gives the minimum "g" value will be determined and sent to the inverter circuit.The flow diagram of the designed MPC is given in Figure 2.

Calculating weights with multi objective Bees Algorithm (MOBA)
BA is a population-based search algorithm.The algorithm mimics the nectar source search behavior of honey bees.Basically, it does some kind of neighbor region search along with random search and can be used for both integrated and functional optimization [26].Detailed explanations about the algorithm were provided in Ref.s [27][28][29].The pseudo code of the algorithm is given in Figure 3.
When designing control systems in general, the integral of the square of the error (ISE) is used as the objective function.The equation of ISE is given in (15).The equation shows the reference velocity value with r(t), the output velocity value with y(t) and the error value with e(t).
When the error is only aimed to be minimized, it may cause high currents to be drawn from the PMSM and thus excessive energy consumption.As a solution to this issue, a multi objective (MO) optimization algorithm is suggested.The goal of MO optimization is to try to optimize all defined objective functions simultaneously.All objectives can be minimized or maximized at the same time, or some can be minimized and some maximized.General definition in the literature is given below [30].

Min or Max
ðÞ Although there are different MO methods, the prominent method is the weighted sum method.Here, each goal has a weight coefficient.This method is also called scalarization method.In this method, basically, multiple solutions are combined into a single solution using weights [31].
It is necessary to limit the current for low power consumption [32].Based on this situation, the integral of the square of the i bus is included in the multi objective function (MOF) to find weights that will also minimize the i bus current.
The optimization process consists of two main parts.First part is Matlab M file with MOBA, second part is Simulink file with MPC, 3 Phase Inverter and PMSM models.The algorithm starts with the definition of BA parameters given in Appendix-B.Using these parameters, a random first population is created.Simulink model is run and MOF value is obtained for each member of the population.After this process is completed, the first population is sorted from small to large, according to the MOF value.Then local search section starts.In the elite and nonelite local areas, new values are generated by neighborhood search and simulations are made with these values in the Simulink model.In the global search, new sites are discovered randomly.Finally, the new population is re-sorted.These operations are repeated for all iterations and the best values are recorded when completed.
The system model used in the simulation is given in Figure 4 and the flow chart of the optimization algorithm is given in Figure 5.The simulation model has been prepared in discrete-time to be close to the real application.The sampling frequency is 50KHz.(Information about the model is given in Appendix-A.)The w1, w2, w3, and w4 weights produced by the optimization algorithm are transmitted to the Simulink model and the simulation is performed.At the end of the simulation, the outputs are taken with the "Error" and "Current" blocks and sent to the MOF in the optimization algorithm.
One of the critical parameters in the optimization algorithm is determining the value ranges of weights.BA focuses on the areas with the best values with the first iterations.Therefore, even if large ranges are specified for variables, it quickly shrinks the solution set to include the parts with the best.For this reason, when determining the value ranges, the range 0-1000 was initially chosen to have a wide solution range.After the optimization study these values were calculated; w1 = 251.5,w2 = 6.9, w3 = 5.1, and w4 = 1.05.Consideration of these values, 300 for w1 and 10 for the others were selected and a second optimization study was carried out.The results of the both studies are given in Figure 6.As can be seen, in the first optimization where wide ranges are defined, there are higher error values in the first iterations.But along with other iterations, cost functions are minimized quickly.In the second optimization, since the limit values are chosen in a narrower ranges, the cost function change is also in a narrow area.(Sufficient number of searches must be made for escaping the local minimums.The important parameters in this regard are the number of foraging bees and the number of iterations.As can be seen from the figures, the minimization process has been fixed in the last iterations.This indicates that the current algorithm parameters are sufficient.If the decline continues in the last iterations, it is necessary to update the parameters.)

PI controller design
One of the advantages of controlling PMSM with MPC that it does not need an external section for commutation.When controlling PMSM with PID control, it is necessary to prepare a commutation section as well.One of the methods used in this context is PWM (Pulse width modulation).The PWM signal provides the signal in a certain order with the duty cycle changes so that the DC signal becomes an AC signal.(If this signal is passed through a low-pass filter, a pure sine wave is obtained.)In SPWM (Sinusoidal Pulse Width Modulation), two signals are compared.The reference signal is sinusoidal and the carrier signal is triangular.Pulses are produced by comparing two signals, and the width of each pulse varies in proportion to the amplitude of the sine signal.The frequency of the reference signal determines the inverter output frequency and controls the reference peak amplitude, the modulation index of the output voltage, and the RMS value [33].SPWM model used in the simulation is given in Figure 7.
Simulink model prepared for PI controller design is given in Figure 8. Id and Iq currents are used in the model as in MPC simulation.As can be seen from Eq. ( 3),  ThecoefficientsofthePIcontrollerarefirsttunedwithBA.Thesamestructure in Figure 5 is prepared for the PI model.Similarly, the error value is used in the objective function together with the currents.For Kp and Ki, values from 0 to 10000 were set as the limit for a wide range.BA parameters are the same as in the MPC study.Figure 9 shows the optimization results.Costs decrease with the first iteration.The minimum value was reached with the 13th iteration.The changes in Kp and Ki are also shown in the table.The PI controller tuned with BA isgivenin (19).
Also, two different conventional methods were used to determine the coefficients of the PI controller.The first of these is the Tyreus-Luyben method.Tyreus  and Luyben's adjustment method is based on oscillations as in the Ziegler-Nichols method but has been modified for the controller parameters to achieve better stability in the control loop compared to the Ziegler-Nichols method.First, only P control is used and all gains are set to zero.The proportional gain K p is increased until there are oscillations in the system response.K p is increased until the oscillations are symmetrical.The final K p value is recorded as Ku.The oscillation period of the signal is taken as Pu.K p and T i values are found according to the equation given in (20) [34].
When the K p value is 27, the oscillations approached the symmetrical state (Figure 10).K p and T i values are calculated using (20).K p ¼ 0:31 * 27 ¼ 8:37,T i ¼ 2:2 * 0:01284 À 0:0122 ðÞ ¼ 0:0014 As the second conventional method, The Good Gain (TGG) method was used, which is more stable than the ZN method and therefore can obtain fewer oscillation values.In the TGG method, K i value is chosen as 0 first and K p value is increased starting from 0. This increase is continued until the answers close to the desired reference value are obtained.As shown in the graph below, when the peak value of the system response approaches the reference value, the K p increase is stopped and the T ou value is calculated.T ou value is the time between the overshoot and undershoot values in the system response.From the T ou value, the T i and K p values are calculated as shown below [35].
Velocity response for Tyreus-Luyben method and the good gain method.

Experimental studies and results
To drive the PMSM, a motor driver card with a dsPIC33f model MCU is used.In addition to the MCU, the driver board includes the communication interface, the MOSFET H Bridge and drivers, and sensor reading interfaces.The driver board and other hardware used in the tests can be seen in Figure 11.Target Language Compiler in Simulink was used to convert the model into a machine code that dsPIC MCU can run directly.Firstly, ANSI C code was created and then machine code was generated by using the C30 C compiler provided by Microchip.Current sensors are located on the driver circuit in series with the motor phases.It is collected from each phase separately.Position data are taken from the digital encoder connected to the back of the motor shaft.
In experimental studies firstly, "100 rad/s" step command was applied to the PMSM for all controllers.All velocity results are given in Figure 12. and current results are given in Figure 13.It is seen that all four controllers are able to give enough response to the velocity command.But as can be seen, there is an overshoot (MPO) of 7% and 11.8% in PI controllers which were tuned by conventional methods.On the other hand, an overshoot of 4.2% was observed in PI tuned with BA.There is no overshoot in MPC.Because of the prediction realized by MPC using the PMSM model, controller output is produced in a more controlled manner after each step, thus creating a smooth effect on the system.In PI controllers, rise time (RT) is 0.1 ms smaller than MPC.The aggressiveness seen in overshoot is also seen here.On the other hand, in the settling time (ST) smaller value was obtained in MPC.The most important factor here is the overshoot and oscillations in PI controller responses.The resistance and inductance values of PMSM used in this study are very low.For this reason, high currents can be seen especially during take-off.Because of the optimum switching with MPC, instantaneous accelerations and currents can be suppressed.The low-value fluctuations seen in the velocity responses in PI control, after the settling time, cause continuous current to be drawn from the battery.Table 1 shows the performance values of the controllers.
As the second test, a sinusoidal signal with an amplitude of 100 rad/s and a frequency of 2 Hz was applied to the PMSM.Test results are shown in Figures 14  and 15.MPC also follows the reference value in this test with a steady state error of approximately 0.4%.In the MPC cost function design, especially low power consumption was emphasized and power constraints were added.Similarly, in the calculation of the weights with BA, the bus current is also used with the speed error in MOF.Thus, when calculating the weights, the values with low speed error and   In PI controllers, although there is no steady state error, higher oscillations are seen compared to MPC.These oscillations can cause significant damage to systems, especially in applications requiring precise control.The effect of oscillations in the velocity response is clearly seen in the flow results.Amplitudes less than 2 A in MPC is up to 4 A in PI controllers.
Finally, a position control application was implemented to test the controllers.Only a P controller with a gain value of 100 has been added to existing controllers.As a test signal, a profile with many changes of direction was used to test its Both controllers were able to respond to the references successfully.Error values are around 0.02 rad, except for the instantaneous step reference applied initially.Current data can also be seen in Figure 18.As with velocity application, MPC control uses less current in position control.It is seen that the optimum inverter switching method used in this study gives successful results.The success of the weights calculated with BA in PMSM control has also been confirmed by the position control application.

Conclusion
FCS-MPC has a limited number of optimization and calculation processes.Therefore, the delay compensation method was used to prevent timing errors in MPC.Thus, in this application, MPC was used with a relatively low-level processor without any problem.In addition to speed error and current predictions, power prediction has been added to the standard cost function used for speed control.In this way, in each switching selection, the possibilities that the lowest power consumption may occur along with other factors are evaluated.
For the Bees Algorithm, which is used to determine the weight coefficients, an infrastructure has been established to minimize the speed error and bus current.With the fast search capability of BA, optimum weight coefficients were calculated in approximately 15 iterations.Because of the low current and low energy preferences used in both the MPC and BA, MPC has achieved a more effective and less oscillatory control by using much lower currents than PI methods.With MPC, PMSM has been controlled with 15% settling time than other controllers and also with no overshoot.There is no exact method for determining the weight coefficients.It seems that manual adjustment is still preferred in many applications.With the efficient neighborhood search structure of BA, weights can be calculated with a small number of iterations.It provides great convenience for researchers.By designing a multi objective function, the number of variables that can be optimized can be increased if desired.
Energy consumption in autonomous vehicles and robots is one of great importance.MPC is used in this context with its smooth control structure.As in this application, BA can be preferred for autonomous control applications that require weight optimization.One of the advantages of BA over other meta-heuristic algorithms is that there is no mathematical equation in its structure.In this way, it can be used easily on different platforms and software languages.
In future works, the parameters of the CARIMA method, which is one of the popular MPC methods, will be optimized using this algorithm.A comparison of different MPC methods will be carried out together with the same test system.

Figure 4 .
Figure 4. Model of PMSM control with MPC.

Figure 18 .
Figure 18.Current responses of position controllers.

Table 1 .
Results of step response.
13 Optimization of Model Predictive Control Weights for Control of Permanent Magnet… DOI: http://dx.doi.org/10.5772/intechopen.98810low currents at the same time came to the fore.Therefore, a very low steady state error occurs in MPC control.