A PYTHON-BASED SIMULATION AND EMBEDDED IMPLEMENTATION OF SPACEVECTOR PULSE WIDTH MODULATION ON STM32 CONTROLLERS | Hưng | TNU Journal of Science and Technology

A PYTHON-BASED SIMULATION AND EMBEDDED IMPLEMENTATION OF SPACEVECTOR PULSE WIDTH MODULATION ON STM32 CONTROLLERS

About this article

Received: 24/06/25                Revised: 26/11/25                Published: 26/11/25

Authors

Nguyen Tien Hung Email to author, TNU - University of Technology

Abstract


This paper presents a detailed approach to developing and validating the space-vector pulse width modulation technique using the Python programming environment. The proposed simulation framework is implemented entirely in Python scripts and models a two-level, three-phase voltage-source inverter. It includes essential functions such as Clarke and Park transformations, sector determination, and duty cycle computation based on vector time decomposition. Unlike traditional simulation tools that rely on graphical user interfaces, the script-based method offers greater transparency and control over algorithmic implementation, enabling users to better understand each computational step involved in pulse generation. Although this approach may be less familiar to users accustomed to commercial block-diagram environments, it enhances comprehension of modulation principles and inverter behavior. Additionally, the Python script is designed with portability in mind, allowing straightforward conversion into embedded C code for real-time execution on STM32G431 microcontrollers. Experimental results confirm that the proposed method offers fast simulation times and reduced code complexity compared to conventional simulation tool chains. 

Keywords


Space-vector pulse width modulation; Three-phase voltage inverter; Python programming; Python simulation; STM32G431 microcontroller

Full Text:

PDF

References


[1] G. Ala, N. Campagna, M. Caruso, V. Castiglia, A. O. D. Tommaso, R. Miceli, C. Nevoloso, G. Schettino, F. Viola, and M. Nguyen, “Stability of Microgrids: An Application of Virtual Synchronous Generator,” In Proc. International Conference on Engineering Research and Applications ’602, 2022, pp. 873-880.

[2] H. T. Do, T.D. Vu, K. N. Nguyen, E. Semail, and M. T. Nguyen, “High Quality Torque for Five-Phase Open-End Winding Non-sinusoidal PMSM Drives,” In Proc. International Conference on Engineering Research and Applications ’944, 2024, pp. 9-19.

[3] B. Wu, High-power converters and AC drives. Wiley-IEEE Press, 2006.

[4] M. H. Rashid, Power electronics: devices, circuits, and applications. Pearson, 2014.

[5] H. Abu-Rub, A. Iqbal, and J. Guzinski, High performance control of AC drives with Matlab/Simulink models. Wiley, 2012.

[6] M. M. Gaballah, “Design and implementation of space vector PWM inverter based on a low cost microcontroller,” Arabian Journal for Science and Engineering, vol. 38, pp. 3059–3070, 2013.

[7] H. Zhang, Y. Meng, L. Ning, Y. Zou, X. Wang, and X. Wang, “Fast and simple space vector modulationmethod for multilevel converters,” IET Power Electronics, vol. 13, pp. 14–22, 2020.

[8] A. Khaliq, S. A. R. Kashif, F. Ahmad, M. Anwar, Q. Shaheen, R. Akhtar, M. A. Shah, and A. Abdelmaboud, “Indirect vector control of linear induction motors using space vector pulse width modulation,” Computers, Materials and Continua, vol. 74, pp. 6263–6287, 2022.

[9] L. Tiitinen, M. Hinkkanen, and L. Harnefors, “Design framework for sensorless control of synchronous machine drives,” IEEE Transactions on Industrial Electronics, vol. 72, pp. 1379–1390, 2025.

[10] Z. Liu, W. Zhang, C. Li, X. Wang, and H. Qin, “Improved virtual SVPWM algorithm for CMV reduction and NPV oscillationelimination in three-level NPC inverter,” International Journal of Electrical Power and Energy Systems, vol. 155, Part A, January 2024, Art. no. 109533, doi: 10.1016/j.ijepes.2023.109533.

[11] L. Tiitinen, M. Hinkkanen, and L. Harnefors, “Sensorless flux-vector control framework: An extension forinduction machines,” IEEE Transactions on Industrial Electronics, vol. 99, pp. 1-6, 2025, doi: 10.1109/TIE.2025.3559958.

[12] V. Kumar, R. K. Behera, D. Joshi, and R. Bansal, Power electronics, drives, and advanced applications. CRC Press, 2020.

[13] N. P. Quang and J.-A. Dittrich, Vector control of three-phase AC machines: System development in the practice. Springer Berlin Heidelberg, 2008.

[14] STMicroelectronics, “STM32G4 series advanced ARM-based 32-bit MCUs,” 2020. [Online]. Available: https://www.farnell.com/datasheets/3182254.pdf. [Accessed Jun. 10, 2025].

[15] STMicroelectronics, “STM32G431x6 STM32G431x8 STM32G431xB Datasheets,” 2019. [Online]. Available: https://www.st.com/resource/en/datasheet/stm32g431c6.pdf. [Accessed Jun. 10, 2025].




DOI: https://doi.org/10.34238/tnu-jst.13117

Refbacks

  • There are currently no refbacks.
TNU Journal of Science and Technology
Rooms 408, 409 - Administration Building - Thai Nguyen University
Tan Thinh Ward - Thai Nguyen City
Phone: (+84) 208 3840 288 - E-mail: jst@tnu.edu.vn
Based on Open Journal Systems
©2018 All Rights Reserved