Microcontrollers

Build a $29 Open-Source STM32F405 FOC Driver for BLDC Motors

Build a $29 Open-Source STM32F405 FOC Driver for BLDC Motors

Three chips do most of the work in a field-oriented control driver, and Sirojudin Munir’s new SF-Motion board picks good ones: an STMicroelectronics STM32F405 for the math, a Texas Instruments DRV8323RH gate driver for the three-phase bridge, and a TI INA240A1 to read phase current. Add an AS5047 magnetic encoder for rotor position and the control loop is complete. Munir priced the bill of materials at about $28.58 from LCSC, PCB and assembly not included, which puts a proper FOC driver well under the cost of most off-the-shelf boards.

A second attempt, not a first

Munir had already built an FOC driver once. That one took several rounds of trial and error before it behaved, so rather than patch it he started over with a fresh schematic, a reworked current-sensing section, new firmware, and a different communication scheme. The part he singles out as most improved is current sensing, which is exactly the section most homebrew FOC drivers get wrong.

Everything is open. The KiCad hardware files and the firmware sit on GitHub under the MIT license, along with a client-side package for calibration and tuning. A permissive license on a motor driver is rare enough to be worth noting.

Why an F405 and not something smaller

Field-oriented control holds the stator field at 90 degrees to the rotor field, which is where the smooth torque and high efficiency come from. Holding that angle means running Clarke and Park transforms plus a pair of PI loops on every PWM cycle, typically at 20 kHz or faster. The STM32F405 carries a hardware floating-point unit, so those transforms run in single-precision float instead of hand-tuned fixed point. Its ADC handles the current sense, its advanced timers generate complementary PWM for the inverter, and SPI talks to the magnetic encoder. USB and CAN sit on the same die, so a bench link and a robot bus both come free.

The DRV8323RH earns its place twice over: it drives the six MOSFETs of the inverter and also acts as the buck regulator for the logic rail, which removes a whole cluster of parts from the board.

If you want to build one

Read the design walkthrough on Munir’s video and the full write-up at Hackster, then pull the KiCad project before ordering a thing. Shunt placement and gate-drive layout decide whether this works, more than the parts list does. For a first FOC build, order the PCB assembled, keep a current-limited supply on the bench, and start the motor unloaded. A miswired half-bridge fails loudly and expensively. Gimbal motors and 2204-size BLDCs are the friendly starting point, and you can pick them up along with the connectors and encoders at Circuit.Rocks.

Frequently Asked Questions

What chips does the SF-Motion FOC driver use?

An STMicroelectronics STM32F405 runs the control loop, a Texas Instruments DRV8323RH drives the three-phase MOSFET bridge and doubles as the logic-rail regulator, a TI INA240A1 amplifies the current-sense shunt signal, and an AS5047 magnetic sensor reports rotor position over SPI.

How much does it cost to build one?

Munir puts the component cost at roughly $28.58 using LCSC pricing, which excludes the bare PCB, assembly, shipping, and taxes. Budget more if you order the board assembled, and add the motor and encoder magnet on top of that.

What will I learn if I build this?

You get hands-on with three-phase inverter topology, shunt-based current sensing, and SPI encoder feedback, plus the Clarke and Park transforms behind field-oriented control. On the layout side you practise gate-drive routing and power-ground separation in KiCad, which are the skills that carry straight into a thesis-level robotics or drive project.

This article was inspired by reporting from Hackster. Find the parts and modules to build it at Circuitrocks.

// written by Ann Arandia

Ann Arandia covers community projects and maker events for the Circuitrocks blog. She writes about local workshops, kid-friendly electronics, and the Philippine maker scene — the people, the meet-ups, the projects that come out of them.