Implementation of ARM STM32F4 Microcontroller For Speed Control of BLDC Motor Based On Bat Algorithm
Implementation of ARM STM32F4 Microcontroller For Speed Control of BLDC Motor Based On Bat Algorithm
Corresponding Author:
Izza Anshory
Department of Electrical Engineering, Faculty of Science and Technology
Universitas Muhammadiyah Sidoarjo
Sidoarjo, Indonesia
Email: [email protected]
1. 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
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 three-
phase 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.
2. 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.
Figure 1. Block diagram of the speed control mechanism of a brushless DC (BLDC) motor
Int J Pow Elec & Dri Syst, Vol. 15, No. 1, March 2024: 127-135
Int J Pow Elec & Dri Syst ISSN: 2088-8694 129
mathematical model was developed using the autoregressive exogenous (ARX) model, which is specified
by (1) [22].
𝑦(𝑡) + 𝑎1 𝑦(𝑡 − 1) + ⋯ 𝑎𝑛𝑎 𝑦(𝑡 − 𝑛𝑎) = 𝑏1 𝑢(𝑡 − 𝑛𝑘) + ⋯ + 𝑏𝑛𝑏 𝑢(𝑡 − 𝑛𝑏 − 𝑛𝑘 + 1) + 𝑒(𝑡) (1)
1
𝐾𝑖 = 𝐾𝑝 𝑥 and 𝐾𝑑 = 𝐾𝑝 𝑥𝑇𝑑 (3)
𝑇𝑖
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].
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.
𝐴𝑡+1
𝑖 = 𝛼𝐴𝑡𝑖 (7)
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.
Int J Pow Elec & Dri Syst, Vol. 15, No. 1, March 2024: 127-135
Int J Pow Elec & Dri Syst ISSN: 2088-8694 131
Figure 4. PWM test results, voltage, and BLDC motor rotation speed
Implementation of ARM STM32F4 microcontroller for speed control of BLDC motor based … (Izza Anshory)
132 ISSN: 2088-8694
resultant values were Kp = 0.5161, Ki = 0.023165, and Kd = -0.037296. The transient response outcomes for
the PID controller are presented in Table 2.
Int J Pow Elec & Dri Syst, Vol. 15, No. 1, March 2024: 127-135
Int J Pow Elec & Dri Syst ISSN: 2088-8694 133
4. 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.
ACKNOWLEDGEMENTS
Thank you to the Directorate of Research and Community Service (DRPM) Universitas
Muhammadiyah Sidoarjo and Research Center for Energy Conversion and Conservation, National Research
and Innovation Agency (BRIN), Indonesia contract number B-15303/III.3.1/TU.05.01/12/2022 for providing
financial assistance for research activities.
REFERENCES
[1] S. R. Sharvini, Z. Z. Noor, C. S. Chong, L. C. Stringer, and R. O. Yusuf, “Energy consumption trends and their linkages with
renewable energy policies in East and Southeast Asian countries: Challenges and opportunities,” Sustainable Environment
Research, vol. 28, no. 6, pp. 257–266, Nov. 2018, doi: 10.1016/j.serj.2018.08.006.
[2] G. R. Chandra Mouli, P. Van Duijsen, F. Grazian, A. Jamodkar, P. Bauer, and O. Isabella, “Sustainable E-Bike Charging Station
That Enables AC, DC and Wireless Charging from Solar Energy,” Energies, vol. 13, no. 14, p. 3549, Jul. 2020, doi:
10.3390/en13143549.
[3] S. K. Gill, K. Vu, and C. Aimone, “Quantifying fossil fuel savings from investment in renewables and energy storage,” in 2017
Saudi Arabia Smart Grid (SASG), Dec. 2017, pp. 1–6. doi: 10.1109/SASG.2017.8356488.
[4] M. Rasoul, H. Abdi, S. Rezaei, and H. Rahimzadeh, “Demand side management and charging and discharging for multiple
PHEVs to reduce cost and reduce fossil fuel using game theory in smart grid,” in 2015 IEEE 15th International Conference on
Environment and Electrical Engineering (EEEIC), Jun. 2015, pp. 128–132. doi: 10.1109/EEEIC.2015.7165499.
[5] D. F. Silalahi et al., Indonesia Post-Pandemic Outlook: Strategy towards Net-Zero Emissions by 2060 from the Renewables and
Carbon-Neutral Energy Perspectives. Penerbit BRIN, 2022. doi: 10.55981/brin.562.
[6] BPPT, “Outlook Energi Indonesia 2014,” 2014. doi: 10.1007/s13398-014-0173-7.2.
[7] R. A. Hanifah, S. F. Toha, S. Ahmad, and M. K. Hassan, “Swarm-Intelligence Tuned Current Reduction for Power-Assisted
Implementation of ARM STM32F4 microcontroller for speed control of BLDC motor based … (Izza Anshory)
134 ISSN: 2088-8694
Steering Control in Electric Vehicles,” IEEE Transactions on Industrial Electronics, vol. 65, no. 9, pp. 7202–7210, Sep. 2018,
doi: 10.1109/TIE.2017.2784344.
[8] A. Gaurav and A. Gaur, “Modelling of Hybrid Electric Vehicle Charger and Study the Simulation Results,” in 2020 International
Conference on Emerging Frontiers in Electrical and Electronic Technologies (ICEFEET), Jul. 2020, pp. 1–6. doi:
10.1109/ICEFEET49149.2020.9187007.
[9] J. A. Domínguez-Navarro, R. Dufo-López, J. M. Yusta-Loyo, J. S. Artal-Sevil, and J. L. Bernal-Agustín, “Design of an electric
vehicle fast-charging station with integration of renewable energy and storage systems,” International Journal of Electrical
Power & Energy Systems, vol. 105, pp. 46–58, Feb. 2019, doi: 10.1016/j.ijepes.2018.08.001.
[10] S. S. Babu and A. Sukesh, “Current Programmed Controlled DC-DC Converter for Emulating the Road Load in Six Phase
Induction Motor Drive in Electric Vehicle,” in 2020 International Conference on Power Electronics and Renewable Energy
Applications (PEREA), Nov. 2020, pp. 1–6. doi: 10.1109/PEREA51218.2020.9339779.
[11] Y. Ma, S. Lv, X. Zhou, and Z. Gao, “Review analysis of voltage stability in power system,” in 2017 IEEE International
Conference on Mechatronics and Automation (ICMA), Aug. 2017, pp. 7–12. doi: 10.1109/ICMA.2017.8015779.
[12] P. Kundur et al., “Definition and Classification of Power System Stability IEEE/CIGRE Joint Task Force on Stability Terms and
Definitions,” IEEE Transactions on Power Systems, vol. 19, no. 3, pp. 1387–1401, Aug. 2004, doi: 10.1109/TPWRS.2004.825981.
[13] A. Sabir and M. Kassas, “A Novel and Simple Hybrid Fuzzy/PI Controller for Brushless DC Motor Drives,” Automatika, vol. 56,
no. 4, pp. 424–435, Jan. 2015, doi: 10.1080/00051144.2015.11828656.
[14] C. M. R. Charles and S. J S, “Bidirectional DC-DC Converter Fed BLDC Motor in Electric Vehicle,” in 2021 International
Conference on Advances in Electrical, Computing, Communication and Sustainable Technologies (ICAECT), Feb. 2021, pp. 1–6.
doi: 10.1109/ICAECT49130.2021.9392394.
[15] M. F. Bhuiyan, M. Rejwan Uddin, Z. Tasneem, M. Hasan, and K. M. Salim, “Design, Code Generation and Simulation of a BLDC
Motor Controller usuuing PIC Microcontroller,” in 2018 International Conference on Recent Innovations in Electrical, Electronics &
Communication Engineering (ICRIEECE), Jul. 2018, pp. 1427–1431. doi: 10.1109/ICRIEECE44171.2018.9008910.
[16] R. V. A. Krishnan, N. Tomson, C. S. A. John, and S. Navya, “A microcontroller based five phase BLDC motor drive,” in 2014
International Conference on Green Computing Communication and Electrical Engineering (ICGCCEE), Mar. 2014, pp. 1–6. doi:
10.1109/ICGCCEE.2014.6922423.
[17] Y. Lee, “Commutation Torque Ripple Minimization for Three Phase BLDC Motor Drive using A Simple PWM Scheme Reliable
to Motor Parameter Variation,” in 2019 IEEE PES Asia-Pacific Power and Energy Engineering Conference (APPEEC), Dec.
2019, pp. 1–4. doi: 10.1109/APPEEC45492.2019.8994517.
[18] A. A. El-samahy and M. A. Shamseldin, “Brushless DC motor tracking control using self-tuning fuzzy PID control and model
reference adaptive control,” Ain Shams Engineering Journal, vol. 9, no. 3, pp. 341–352, Sep. 2018, doi: 10.1016/j.asej.2016.02.004.
[19] M.-C. Tsai, S.-K. Lin, and S.-H. Wang, “Condition monitoring of BLDC motor drive systems by Hilbert Huang Transform,” in
2015 Tenth International Conference on Ecological Vehicles and Renewable Energies (EVER), Mar. 2015, pp. 1–5. doi:
10.1109/EVER.2015.7112964.
[20] I. Anshory, I. Robandi, and Wirawan, “Monitoring and optimization of speed settings for Brushless Direct Current (BLDC) using
Particle Swarm Optimization (PSO),” in 2016 IEEE Region 10 Symposium (TENSYMP), May 2016, pp. 243–248. doi:
10.1109/TENCONSpring.2016.7519412.
[21] S. George, R. V. Chacho, and K. Salitha, “Modelling and simulation of Electric Vehicle power train in SEQUEL,” in 2014 IEEE
International Conference on Power Electronics, Drives and Energy Systems (PEDES), Dec. 2014, pp. 1–6. doi:
10.1109/PEDES.2014.7042149.
[22] S. Mokhlis, S. Sadki, and B. Bensassi, “System Identification of a DC Servo Motor Using ARX and ARMAX Models,” in 2019
International Conference on Systems of Collaboration Big Data, Internet of Things & Security (SysCoBIoTS), Dec. 2019, pp. 1–4.
doi: 10.1109/SysCoBIoTS48768.2019.9028015.
[23] A. A. Portillo, M. Frye, and C. Qian, “Particle swarm optimization for PID tuning of a BLDC motor,” in 2009 IEEE International
Conference on Systems, Man and Cybernetics, Oct. 2009, pp. 3917–3922. doi: 10.1109/ICSMC.2009.5346655.
[24] A. Ali, S. F. Ahmed, K. A. Kadir, M. K. Joyo, and R. N. S. Yarooq, “Fuzzy PID controller for upper limb rehabilitation robotic
system,” in 2018 IEEE International Conference on Innovative Research and Development (ICIRD), May 2018, pp. 1–5. doi:
10.1109/ICIRD.2018.8376291.
[25] A. Varshney, D. Gupta, and B. Dwivedi, “Speed response of brushless DC motor using fuzzy PID controller under varying load
condition,” Journal of Electrical Systems and Information Technology, vol. 4, no. 2, pp. 310–321, Sep. 2017, doi:
10.1016/j.jesit.2016.12.014.
[26] M. A. Ibrahim, A. K. Mahmood, and N. S. Sultan, “Optimal PID controller of a brushless dc motor using genetic algorithm,”
International Journal of Power Electronics and Drive Systems (IJPEDS), vol. 10, no. 2, pp. 822–830, Jun. 2019, doi:
10.11591/ijpeds.v10.i2.pp822-830.
[27] C.-T. Chao, N. Sutarna, J.-S. Chiou, and C.-J. Wang, “Equivalence between Fuzzy PID Controllers and Conventional PID
Controllers,” Applied Sciences, vol. 7, no. 6, p. 513, Jun. 2017, doi: 10.3390/app7060513.
[28] V. K. R. Singh Patel and A. K. Pandey, “Modeling and Performance Analysis of PID Controlled BLDC Motor and Different
Schemes of PWM Controlled,” International Journal of Scientific and Research Publications, vol. 3, no. 4, pp. 1–14, 2013,
[Online]. Available: www.ijsrp.org
[29] O. Aguilar-Mejia, H. Minor-Popocalt, and R. Tapia-Olvera, “Parameter Tuning of a PID Controller with Reactive Bio-Inspired
for PMSM,” in 2018 IEEE International Autumn Meeting on Power, Electronics and Computing (ROPEC), Nov. 2018, pp. 1–6.
doi: 10.1109/ROPEC.2018.8661429.
[30] S.-Y. Chen, B.-C. Yang, T.-A. Pu, C.-H. Chang, and R.-C. Lin, “Active Current Sharing of a Parallel DC-DC Converters System
Using Bat Algorithm Optimized Two-DOF PID Control,” IEEE Access, vol. 7, pp. 84757–84769, 2019, doi:
10.1109/ACCESS.2019.2925064.
[31] S. Mondal, A. Mitra, and M. Chattopadhyay, “Mathematical modeling and simulation of Brushless DC motor with ideal Back
EMF for a precision speed control,” in 2015 IEEE International Conference on Electrical, Computer and Communication
Technologies (ICECCT), Mar. 2015, pp. 1–5. doi: 10.1109/ICECCT.2015.7225944.
[32] N. C. Damasceno and O. G. Filho, “PI controller optimization for a heat exchanger through metaheuristic Bat Algorithm, Particle
Swarm Optimization, Flower Pollination Algorithm and Cuckoo Search Algorithm,” IEEE Latin America Transactions, vol. 15,
no. 9, pp. 1801–1807, 2017, doi: 10.1109/TLA.2017.8015088.
[33] D. Paliwal and D. K. Sambariya, “A Novel Control Approach for buck converter based PMBLDC motor using BAT algorithm,”
in 2020 4th International Conference on Electronics, Communication and Aerospace Technology (ICECA), Nov. 2020, pp. 159–
164. doi: 10.1109/ICECA49313.2020.9297460.
Int J Pow Elec & Dri Syst, Vol. 15, No. 1, March 2024: 127-135
Int J Pow Elec & Dri Syst ISSN: 2088-8694 135
[34] H. Jigang, F. Hui, and W. Jie, “A PI controller optimized with modified differential evolution algorithm for speed control of
BLDC motor,” Automatika, vol. 60, no. 2, pp. 135–148, Apr. 2019, doi: 10.1080/00051144.2019.1596014.
[35] S. Bharat, A. Ganguly, R. Chatterjee, B. Basak, D. K. Sheet, and A. Ganguly, “A Review on Tuning Methods for PID Controller,”
Asian Journal For Convergence In Technology (AJCT), vol. 5, no. 1, 2019.
[36] M. Mahmud, S. M. A. Motakabber, A. H. M. Alam, and A. N. Nordin, “Control BLDC Motor Speed using PID Controller,”
International Journal of Advanced Computer Science and Applications, vol. 11, no. 3, 2020, doi: 10.14569/IJACSA.2020.0110359.
[37] A. Usman and B. S. Rajpurohit, “Speed control of a BLDC Motor using Fuzzy Logic Controller,” in 2016 IEEE 1st International
Conference on Power Electronics, Intelligent Control and Energy Systems (ICPEICES), Jul. 2016, pp. 1–6. doi:
10.1109/ICPEICES.2016.7853304.
[38] S. K. Singh, N. Katal, and S. G. Modani, “Optimization of PID Controller for Brushless DC Motor by using Bio-inspired
Algorithms,” Research Journal of Applied Sciences, Engineering and Technology, vol. 7, no. 7, pp. 1302–1308, 2014.
[39] R. Arulmozhiyal and R. Kandiban, “An intelligent speed controller for Brushless DC motor,” in 2012 7th IEEE Conference on
Industrial Electronics and Applications (ICIEA), Jul. 2012, pp. 16–21. doi: 10.1109/ICIEA.2012.6360690.
[40] T. C. Bora, L. dos S. Coelho, and L. Lebensztajn, “Bat-Inspired Optimization Approach for the Brushless DC Wheel Motor
Problem,” IEEE Transactions on Magnetics, vol. 48, no. 2, pp. 947–950, Feb. 2012, doi: 10.1109/TMAG.2011.2176108.
BIOGRAPHIES OF AUTHORS
Izza Anshory holds the position of lecturer within the Electrical Engineering
Department at Universitas Muhammadiyah Sidoarjo (UMSIDA), located in Sidoarjo,
Indonesia. He obtained their Bachelor of Engineering (B.Eng.), Master of Engineering
(M.Eng.), and Doctor of Philosophy (Ph.D.) degrees in the field of Electrical Engineering
from Universitas Brawijaya Malang, Institut Teknologi Sepuluh Nopember (ITS) Surabaya,
and Institut Teknologi Sepuluh Nopember (ITS) Surabaya, respectively. Since 2015, he has
held the position of Associate Professor at UMSIDA, located in Sidoarjo, Indonesia. Presently,
he holds the esteemed position of Editor-in-Chief at the journal of electrical and electronics
engineering updates (JEEEU) while concurrently serving as the leader of the Power
Electronics System Research Group. His research interests encompass the fields of BLDC
motors, applications of renewable energy, and the domain of artificial intelligence. He can be
contacted at email: [email protected].
Arief Wisaksono holds the position of lecturer within the Electrical Engineering
Department at Universitas Muhammadiyah Sidoarjo (UMSIDA), located in Sidoarjo,
Indonesia. He obtained his Bachelor of Engineering (B.Eng.) and Master of Engineering
(M.M.) degrees in the field of Electrical Engineering from Universitas Muhammadiyah
Surabaya and Universitas Dr. Soetomo Surabaya, respectively, in the years 1992 and 2010.
Since 2013, he has held the position of Associate Professor at UMSIDA, located in Sidoarjo,
Indonesia. The researcher's areas of interest encompass the drive motor and uses of renewable
energy. He can be contacted at email: [email protected].
Ahmad Fudholi was born in Riau on April 29th, 1980. The author is listed as the
Coordinator of Renewable Energy Technology Group at the Research Center for Energy
Conversion and Conservation, National Research and Innovation Agency (BRIN), Indonesia.
Associate Professor (Lecturer/Research Fellow) at the Solar Energy Research Institute (SERI),
UKM, Malaysia. He can be contacted at email: [email protected].
Implementation of ARM STM32F4 microcontroller for speed control of BLDC motor based … (Izza Anshory)