Implementation of ARM STM32F4 microcontroller for speed control of BLDC motor based on bat algorithm

ABSTRACT


INTRODUCTION
Although the utilization of new and renewable energy sources remains a viable option, the escalation of economic activity and population growth has led to an augmented need for fossil fuels such as coal, natural gas, and oil [1], [2].Three things are brought about by this economic activity: i) The depletion of petroleum reserves; ii) The rise and volatility of the price of petroleum fuel as a result of the increased demand for oil production; and iii) The rise in glasshouse gas emissions as a result of the burning of fossil fuels [3].In light of the widening disparity between energy supply and demand, the usage of fossil fuels makes national energy security vulnerable [4].Furthermore, the utilization of new renewable energy (EBT) is imperative for the attainment of national energy sovereignty, aligning with Indonesia's objective of reducing glasshouse gas (GHG) emissions as stipulated in the Paris agreement [5], [6].
The automotive industry has created electric vehicles as a result of the availability of nonrenewable natural resources [7] for instance, electric bicycles, motorcycles, and vehicles [8], [9].The electric motor, which is a prime mover in electric vehicles, is what makes them run.Because they employ brushes for motor 128 commutation, direct current (DC) electric motors, which are often used, require expensive maintenance [10].When used, brushes on DC motors will quickly become destroyed.A brushless direct current (BLDC) motor is employed as a solution to this issue due to its benefits of high motor torque and simple speed management [11]- [13].
In order to ensure optimal operation and facilitate the adjustment of motor rotation speed as required, the utilization of a control system is important for brushless DC (BLDC) motors [14].A three-phase inverter is utilized by the BLDC motor speed control system for digitally controlled switching by a microcontroller [15].Accurate variable speed configurations are important for the ARM STM32F4 microcontroller, which is employed to operate a BLDC motor by means of the metal oxide semiconductor field effect transistor (MOSFET) driver's on-and-off control mechanism [16].The variable speed of the ARM STM32F4 microcontroller is determined by generating six pulse width modulation (PWM) pulses that are sent to the MOSFET driver board in order to control the switching sequence [17].The operation of a threephase brushless DC (BLDC) motor is facilitated by a MOSFET driver, consisting of six N-channel power MOSFETs connected to a three-phase bridge [18]- [21].
The BLDC motor's performance and speed may be impacted when running under load conditions.As a result, it is critical to use a controller capable of maintaining a constant speed for the BLDC motor following the predefined set-point, especially while the motor is working under load.The speed of the BLDC motor is controlled by a proportional integral derivative (PID) controller based on the bat algorithm.The bat algorithm was chosen because of its positive properties, such as its potential for rapid convergence in the early phases and its ability to move from exploration to exploitation as optimality neared.

METHOD
The research's methodology, titled "Implementation of ARM STM32F4 microcontroller for speed control of BLDC motor based on bat algorithm," was divided into several stages, including hardware design, mathematical modelling of BLDC motors, and optimization with a PID controller based on the bat algorithm.In the hardware design stage, the electronic components needed for the BLDC motor control system will be selected and assembled as needed.Mathematical modelling of the BLDC motor aims to obtain a mathematical representation of the BLDC motor which will later be used in the optimization process.Meanwhile, the optimization process with bat algorithm-based PID control is carried out to improve the efficiency and accuracy of motor speed control.

Hardware design
The microcontroller is a component that functions as the brain of the PID controller implementation system in the prototype control system of BLDC motor speed using ARM STM32F4.The microcontroller generates the PWM waves used for the MOSFET switching in the 3-phase inverter at the rotation speed of the BLDC motor.In addition, the microcontroller also receives input from the Hall effect sensor to determine the processed PWM output from using the PID control system algorithm.In this study, the microcontroller used was the DSP STM32F407.STM32F407 module PCB board series has been joined and made with the LCD circuit.Microcontroller STM32F407 has many ports.Because each pin on each port serves a specific purpose to support the work system, it must be regulated in the input-output planning (I/O).Figure 1 depicts the plant's block architecture optimization speed control of BLDC motor.In Figure 1, the hall effect sensor output is used as an input signal by the ARM microprocessor to produce a PWM signal with a variable duty cycle.The 3-phase inverter switching that serves as the BLDC motor speed regulator will be activated by this PWM signal.

BLDC motor mathematical modeling
To collect measurement data, the parameters of the BLDC motor system must first be identified.Following that, simulations based on the gathered measurement data must be run in order to generate mathematical equations.The mathematical equation is used to build the framework of the BLDC motor plant model, demonstrating the relationship between input data parameters and output data.

BLDC motor speed control optimization
The optimization of BLDC motor speed control involves two stages: the use of a proportional integral derivative (PID) controller and the use of the bat algorithm-based optimization technique, such as in Figure 2. In the first stage, the PID controller part is used to regulate the dynamic response of the BLDC motor and to reduce the steady-state error.While in the second stage, the bat algorithm-based optimization technique is applied to find the best PID parameters that can provide optimal control performance.Figure 2. PID controller optimization block using bat algorithm

Optimization using PID controller
PID control in this final project is used to maintain the stability of the RPM output RPM BLDC Motorbike to remain constant at 300 rpm.A development of conventional control, the proportional integral derivative (PID) controller seeks to optimize the system's control performance [23], [24].The construction of the PID control system is straightforward, and each parameter is not independent.By integrating the three controllers (proportional, integral, and derivative) in parallel to form a PID controller, it becomes possible to effectively weigh the advantages and disadvantages of each individual controller (P, I, and D) against each other [25], [26].It is anticipated that the designed system will have a quick rise time, the least amount of overshoot, and no steady state inaccuracy.The transfer function of the PID controller illustrate as (2) and (3) [27], [28].

𝑢(𝑡) = 𝐾 𝑝 (𝑒(𝑡) +
= The three parameters P, I, and D have a significant influence on the PID controller's characteristics [29].The prominence of each element's attributes will depend on how the constants Kp, Ki, and Kd are changed.It is possible to set one or more of the three constants to stand out more than the others.Outstanding constants that will impact the responsiveness of the entire system.To get the required output signal, the control system must enhance the system's dynamic response.A good control system responds well to different input signals [14].

Optimization using the bat algorithm
The bat algorithm was developed as a result of studying how bats use sonar waves to locate eating sites [30].This algorithm works based on the bat species echolocation mechanism when using the echolocation method to detect prey [31], [32].The effectiveness of bats in obtaining settlements depends on the frequency or wavelength setting in obtaining the optimal balance between exploration and exploitation [33].Each bat is coded with velocity    and location    , at t iterations, in the d-dimensional search or solution space.Location can be considered as a solution vector for solving a problem.Some ideal rules that serve as guidelines in solving bat algorithms with the following assumptions [34]- [37]: -Using the echolocation technique, all bats can recognise and locate prey; -Each bat has a different loudness and frequency, and all bats fly at a frequency of min while moving at a speed of vi; and -Each bat's volume ranges from the lowest value (Amin) to the highest value (A0).
Mathematical equation for bat algorithm in updating location    , and speed    can be written as ( 4), ( 5), and (6).
With β [0,1] acting as a uniformly distributed random vector.Additionally, during iterations, the volume and pulse emission levels may change.The ( 7) and ( 8) can be used to modify the pulses' volume and emission levels simply.
Following is an explanation of the stages of the bat algorithm [38]- [40]: The implementation of the bat algorithm begins with the initialization of its parameters.This involves the establishment of the initial population of bats and the determination of the maximum iteration required to attain the optimal   solution within the population.Subsequently, every bat is allocated arbitrary values for its positional attribute (  ), velocity attribute (  ), frequency attribute (  ), loudness attribute (  ), and pulse rate attribute (ri) As the algorithm advances and under the condition that the value of t remains below the maximum threshold, the positional, velocity, and frequency attributes of each bat are modified.Following this, a stochastic value is generated for each individual bat.In the event that the value exceeds the threshold value ri, a localized location is generated based on the updated position (  ).In contrast, in cases where the random value is not only smaller than (ri) but also falls below   , and as(   ) is lower than ( * ), the algorithm will increase the value of ri, decrease the value of   , and afterwards choose the position that yields the highest overall score.The parameters utilized in the bat algorithm as outlined in this work are presented in Table 1.

ARM STM32F4 microcontroller system
The ARM STM32F4 microcontroller receives the output signal from the BLDC motor's hall effect sensor.The microcontroller will then send a pulse width modulation (PWM) signal to the MOSFET driver, which will act as an inverter to operate the BLDC motor.Figure 3 depicts the results of the BLDC motor system test.
Figure 3 shows the test results for measuring the PWM value, voltage, and rotational speed of the BLDC motor.Figure 4 shows a change in the value of the voltage and PWM causing a change in the rotational speed of the BLDC motor.The graph also shows that there is an overshoot at the 130th second to the 405th second with a speed above 250 rpm.

Mathematical model of BLDC motor
The measurement data of the ARM STM32F4 microcontroller system test results were utilized to conduct a simulation test employing the system identification toolbox (SIT) application within the MATLAB programmed.This test aimed to determine the model accuracy test value (best fit), which was found to be 83.04%.The mathematical model of the BLDC motor, as represented by (8), exhibits a transient response graph, which is depicted in Figure 5.In Figure 5

PID controller
Figure 6 depicts the test simulation block utilized for optimization purposes with the proportionalintegral-derivative (PID) controller.Figure 7 presents a visual illustration of the step response pertaining to the enhancement of speed control for a brushless direct current (BLDC) motor.This improvement is achieved by employing a proportional-integral-derivative (PID) controller.The PID controller analyses the computed disparity between the achieved speed and the predefined speed set point of the BLDC motor to establish the intended speed set point.The utilization of the PID controller auto tuning technique was implemented in order to ascertain the optimal values of Kp, Ki, and Kd, with N being assigned a value of 13.8279.The

PID optimization with bat algorithm
Figure 8 depicts the Simulink block diagram illustrating the performance evaluation of the BLDC motor system when optimized by the utilization of both the PID controller and the bat algorithm.Figure 8 depicts the transfer function of the brushless DC (BLDC) motor, which has been optimized by the utilization of a proportional-integral-derivative (PID) controller in conjunction with the bat method.The objective of this study is to determine the ideal values for the Kp, Ki, and Kd constants.The simulation results are shown in Figure 9.
The graph in Figure 9 depicts the transient response obtained from the optimization of the PID controller by the utilization of the bat method.Based on the outcomes of the simulation, the gain constant values for Kp, Ki, and Kd are determined to be 31.2685,7.7375, and -1.1934, respectively.In the present context, it is seen that the minimum frequency value is 6381934,619, while the transient response value is determined by the rise time of 0.289 seconds, settling time of 10.9 seconds, overshoot of 3.4%, peak time of 1.04, and the close loop stability is deemed stable.
Table 3 displays a comparison of variables pertaining to the performance of the optimized BLDC motor speed control system when employing a hybrid intelligent controller.According to the data presented in Table 3, there is a notable improvement in the performance of the brushless DC (BLDC) motor speed control system when a smart hybrid control, combining the proportional-integral-derivative (PID) controller with the bat algorithm, is used.

CONCLUSION
Based on the findings derived from measurements, testing, and simulations conducted in the context of research endeavors titled "Implementation of ARM STM32F4 microcontroller for speed control of BLDC motor based on bat algorithm," it can be inferred that multiple stages were undertaken to achieve optimal system performance.These stages encompassed tool design, variable measurement of PWM values, mathematical modelling, and enhancement of system performance through the utilization of a PID controller, as well as an optimized PID controller employing the bat algorithm.The optimization findings indicate that the optimal value is achieved when the PID controller is optimized with the bat algorithm.

Figure 3 . 131 Figure 4 .
Figure 3. Testing the ARM STM32F4 microcontroller system which shows the transient response of the mathematical model of the BLDC motor plant.

Table 1 .
The initial parameters of bat algorithm