Open-Source FOC Driver for BLDC Motors: Sirojudin Munir’s Project
Sirojudin Munir has released an open-source FOC driver for BLDC and PMSM motors. The project includes firmware for STM32, hardware designed in KiCad, Gerber files, a BOM, and a Python GUI for control and monitoring. It is a complete resource for anyone who wants to build or study the vector control of a brushless motor. The permissive MIT license and the stated component cost of $28.58 make it accessible to many makers.
The heart of the system is the STM32F405 microcontroller, which runs the Field-Oriented Control calculations. The ADC reads current, the PWM drives the inverter, and SPI communicates with the magnetic encoder. The DRV8323RH gate driver manages the MOSFETs and also acts as a voltage regulator. The AS5047 encoder detects the rotor position, while the INA240A1 amplifier measures current with precision. All these components work together for efficient and responsive control.
How FOC control works
The firmware implements the Field-Oriented Control algorithm to manage motor torque and speed. The self-commissioning process measures motor resistance and inductance and calibrates the encoder. This way, the driver adapts to the connected motor without manual intervention. Several control modes are available: current, speed, position, open-loop, and motor disable. This flexibility makes the project suitable for many practical applications.
- Current control to manage torque
- Speed control with encoder feedback
- Position control for precision applications
- Open-loop mode for quick tests
- Full motor disable for safety
The PyQt/PyQtGraph GUI allows real-time data visualization and sending commands to the driver. The Python tools include functions for calibration and monitoring. Additionally, the improved client written by Munir simplifies system tuning. The project is designed to be studied and modified, with clear documentation and well-organized files.

Hardware and main components
The schematic and PCB are made in KiCad, with Gerber files ready for production. The board operates with voltages from 6 to 24 V and current up to 1 A. The 3-pin connector with 1.25 mm pitch makes motor connection easy. Those who want to study brushless control starting from something ready-made can look at a brushless motor driver with a Hall sensor: it does not do vector control, but it lets you see the inverter and power MOSFETs in action before making your own board. For testing, you will need a brushless motor.
The DRV8323RH gate driver is a key component: it drives the inverter MOSFETs and integrates a voltage regulator. The AS5047 magnetic encoder offers high resolution for rotor position. The INA240A1 measures current with a dedicated amplifier. These components are chosen to ensure reliable performance and good value for money.
Software tools and commissioning
The firmware compiles with PlatformIO in Visual Studio Code, starting from the STM32CubeMX configuration. The project board includes all the steps for commissioning. Self-commissioning automates the measurement of motor resistance and inductance. Encoder calibration is guided, reducing errors. Finally, the Python GUI lets you test the different control modes in real time.
Munir’s project is an excellent example of open-source technical documentation. It includes demonstration videos and clear instructions for reproduction. For those taking their first steps with brushless motors, this driver offers a solid foundation. Even those with experience can find interesting ideas in the design and firmware.
In summary, this is a complete, well-documented FOC driver with a permissive license. The component cost is low and the build quality is high. For anyone wanting to delve into brushless motor control, this is a project worth studying carefully. The combination of STM32, DRV8323RH, and AS5047 delivers remarkable performance in a compact format.
Source: https://github.com/sirojudinMunir/sf-motion