Skip to the content
2 layers36.5 × 56 mmFoc driver, the printed circuit board in 3D

Open-source Motion Control Platform

Size
36.5 × 56 mm
Copper layers
2
Thickness
1.6 mm
Parts
132
Nets
142
Pads
539
Tracks, vias
1,028, 213
Pours
16
Routed
Yes
KiCad
KiCad 10.0 (file 20260206)
Created
8 Aug 2026
Updated
5 Nov 2026

Overview

Foc driver is an open-source printed circuit board by sirojudinMunir, from the sirojudinMunir/sf-motion repository on GitHub, published under the MIT licence. It is a 2-layer board of 36.5 × 56 mm with 132 parts on 142 nets, routed with 1,028 tracks and 213 vias.

It is built around the INA240A1PW, AS5047D and LM321, with the LP2985-33DBV, TJA1051TK/3/1 and USBLC6-2SC6 among its other parts. Its parts include 51 capacitors, 37 resistors, 11 connectors, 10 ICs and 6 transistors. It belongs with the robots and motor control boards and the STM32 boards of this library.

Main components

8

README

README.md

SF-Motion

Open-source BLDC/PMSM motor control platform based on STM32 and Field-Oriented Control (FOC).

The project includes:

  • FOC firmware
  • Custom motor driver hardware
  • KiCad schematic and PCB design
  • Gerber and BOM files
  • Python communication and control tools
  • PyQt/PyQtGraph GUI for motor monitoring and testing

⚠️ This project is under active development. Hardware and firmware may change between versions.

Hardware Prerequisites

You will need:

  • FOC Driver Board
  • ST-Link programmer/debugger with 3-pin Molex pico-blade P1.25mm connector
  • DC power supply
  • BLDC/PMSM motor
  • diametrical magnet
  • USB type-C cable
  • power cable with XT-30 female connector

The hardware design is available in:

text
Hardware/
├── production/        # Gerber manufacturing files
├── .kicad_sch         # Schematic
├── .kicad_pcb         # PCB design
└── ...

Software Prerequisites

1. STM32CubeMX

Used to configure the STM32 peripherals and generate the initial project configuration.

Download: https://www.st.com/en/development-tools/stm32cubemx.html

2. Visual Studio Code

Used as the main development environment.

Download: https://code.visualstudio.com/

3. PlatformIO

PlatformIO is used to build and upload the firmware.

Install PlatformIO through the VS Code extension:

  1. Open VS Code.
  2. Open Extensions.
  3. Search for PlatformIO IDE.
  4. Install the extension.
  5. Restart VS Code if required.

Verify the installation:

bash
pio --version

If pio is not recognized in the terminal, use the PlatformIO terminal inside VS Code or add the PlatformIO CLI directory to your system PATH.

4. Python

Python is required for the communication tools and GUI.

Recommended version:

text
Python 3.10+

Download: https://www.python.org/downloads/

Check the installation:

bash
python --version

Create a virtual environment (recommended):

bash
python -m venv .venv

Activate it on Windows:

bash
.venv\Scripts\activate

Activate it on Linux/macOS:

bash
source .venv/bin/activate

Install the required packages:

bash
pip install numpy pyserial PyQt5 pyqtgraph

Getting Started

Clone the repository using Git:

bash
git clone https://github.com/sirojudinMunir/sf-motion.git

Enter the project directory:

bash
cd SF-Motion

Building the Firmware

Open the project in VS Code with PlatformIO installed.

Build the firmware:

bash
pio run

If the build is successful, the firmware binary will be generated by PlatformIO.

Upload Firmware

Connect the ST-Link to the FOC Driver board using the 3-pin PicoBlade connector.

The board can be powered from a 6–24 V external power supply. For the initial test, it is recommended to use USB Type-C as the power source if applicable.

Upload the firmware:

bash
pio run -t upload

You can also use the Upload button in the PlatformIO interface in VS Code.

For the first test

After uploading the firmware, follow these steps:

  1. Make sure the D3 LED is blinking after the firmware starts.

  2. Connect the BLDC/PMSM motor wires to the FOC Driver board. Make sure the diametrical magnet is securely mounted on the motor shaft and properly aligned with the magnetic encoder on the FOC Driver board. The board should be positioned directly beneath the magnet.

  3. If you are using an external power supply, set the current limit to 1 A for the initial test. This helps prevent damage if there is an unexpected issue with the board or motor.

  4. Connect the USB Type-C cable to the board.

  5. Run the Python motor control program:

    python
    python communication/motor.py
  6. Select the correct COM port and click Connect.

  7. Before running the motor, set the correct motor pole pairs:

    python
    motor.set_pole_pairs(<your_motor_pole_pairs>)

    Replace <your_motor_pole_pairs> with the actual number of pole pairs of your motor.

  8. Run the self-commissioning process:

    python
    motor.self_commissioning()

    The self-commissioning process measures the motor resistance and inductance and calibrates the magnetic encoder.

    Important: During encoder calibration, make sure the motor rotates counter-clockwise (CCW). If the motor rotates in the opposite direction, swap any two motor wires to reverse the rotation. Automatic motor direction detection will be implemented in a future version.

  9. Save configuration

    python
    motor.set_save_config()
  10. Test the FOC motor modes using:

    python
    motor.set_motor_mode(<mode>)

    Available modes:

    0 -> for current control mode
    1 -> for speed control mode
    2 -> for position control mode
    5 -> for open-loop mode
    6 -> for disable the motor

⚠️ Keep the power supply current limit low during the first test. Do not increase the voltage or current limit until the board, encoder, and motor are confirmed to be working correctly.


Support SF-Motion

If you find this project useful and would like to support its development, you can become a sponsor:

GitHub Sponsors

Your support helps fund hardware development, testing, documentation, and future improvements to SF-Motion.

Parts

132
QtyValueFootprintReferences
19100nFCapacitor_SMD:C_0402_1005Metric_Pad0.74x0.62mm_HandSolderC1, C2, C3, C4, C5, C10, C11, C21, C31, C37, C40, C41, C45, C47, C48, C49 +3
1710uFCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC12, C16, C17, C25, C26, C27, C28, C29, C30, C32, C33, C34, C35, C38, C39, C43 +1
91kResistor_SMD:R_0402_1005Metric_Pad0.72x0.64mm_HandSolderR2, R4, R5, R14, R20, R24, R32, R33, R34
7TestPointTestPoint:TestPoint_Pad_D1.0mmTP1, TP2, TP3, TP4, TP5, TP6, TP7
610RResistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolderR12, R15, R17, R21, R22, R25
6WSD30100DN56Package_TO_SOT_SMD:TDSON-8-1Q1, Q2, Q3, Q4, Q5, Q6
4RResistor_SMD:R_0402_1005Metric_Pad0.72x0.64mm_HandSolderR7, R8, R10, R11
30.01RResistor_SMD:R_Shunt_Ohmite_LVK20R13, R19, R23
31nFCapacitor_SMD:C_0402_1005Metric_Pad0.74x0.62mm_HandSolderC36, C42, C46
31uFCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderC18, C20, C22
32kResistor_SMD:R_0402_1005Metric_Pad0.72x0.64mm_HandSolderR35, R36, R37
3Conn_01x01Connector_Wire:SolderWire-0.25sqmm_1x01_D0.65mm_OD2mmJ4, J5, J6
3Conn_01x03_MountingPinConnector_Molex:Molex_PicoBlade_53261-0371_1x03-1MP_P1.25mm_HorizontalJ1, J8, J9
3INA240A1PWPackage_SO:TSSOP-8_4.4x3mm_P0.65mmU4, U6, U7
20.1uFCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderC13, C15
2100RResistor_SMD:R_0402_1005Metric_Pad0.72x0.64mm_HandSolderR27, R28
210kResistor_SMD:R_0402_1005Metric_Pad0.72x0.64mm_HandSolderR1, R3
230RResistor_SMD:R_0402_1005Metric_Pad0.72x0.64mm_HandSolderR29, R31
233pFCapacitor_SMD:C_0402_1005Metric_Pad0.74x0.62mm_HandSolderC8, C9
2Conn_01x02Connector_AMASS:AMASS_XT30PW-M_1x02_P2.50mm_HorizontalJ2, J3
2LED REDLED_SMD:LED_0603_1608Metric_Pad1.05x0.95mm_HandSolderD1, D2
2MBR0530Diode_SMD:D_SOD-123D4, D5
110nFCapacitor_SMD:C_0402_1005Metric_Pad0.74x0.62mm_HandSolderC24
1120RResistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolderR30
112MHzCrystal:Crystal_SMD_3225-4Pin_3.2x2.5mmY1
118kResistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolderR6
11k8Resistor_SMD:R_0402_1005Metric_Pad0.72x0.64mm_HandSolderR26
11uFCapacitor_SMD:C_0402_1005Metric_Pad0.74x0.62mm_HandSolderC6
12.2uFCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderC23
122uHcustom_LCR:L_SMD_4X4L1
12k2Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolderR18
139kResistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolderR16
13k3Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolderR9
14.7uFCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC14
147nFCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderC19
1AS5047DPackage_SO:TSSOP-14_4.4x5mm_P0.65mmU10
1Conn_01x05_MountingPinConnector_Molex:Molex_PicoBlade_53261-0571_1x05-1MP_P1.25mm_HorizontalJ11
1Conn_01x06_MountingPinConnector_Molex:Molex_PicoBlade_53261-0671_1x06-1MP_P1.25mm_HorizontalJ10
1DRV8323RHRGZRDRV8323RHRGZR:QFN50P700X700X100-49NU2
1LED GREENLED_SMD:LED_0603_1608Metric_Pad1.05x0.95mm_HandSolderD3
1LM321Package_TO_SOT_SMD:SOT-23-5U5
1LP2985-3.3Package_TO_SOT_SMD:SOT-23-5U3
1NetTie_2NetTie:NetTie-2_SMD_Pad0.5mmNT1
1STM32F405RGTxPackage_QFP:LQFP-64_10x10mm_P0.5mmU1
1SolderJumper_3_OpenJumper:SolderJumper-3_P1.3mm_Open_RoundedPad1.0x1.5mmJP1
1TJA1051TK-3Package_SON:HVSON-8-1EP_3x3mm_P0.65mm_EP1.6x2.4mmU9
1USBLC6-2SC6Package_TO_SOT_SMD:SOT-23-6U8
1USB_C_Receptacle_USB2.0_16PConnector_USB:USB_C_Receptacle_G-Switch_GT-USB-7010ASVJ7
1fcm 1608-0603Inductor_SMD:L_0603_1608Metric_Pad1.05x0.95mm_HandSolderFB1

Similar boards

  • 4 layers100 × 100 mmRev6.0 flat powerstage, the printed circuit board in 3D

    Rev6.0 flat powerstage

    oresat/oresat-adcs-hardware

    Controller PCB for OreSat reaction wheels, magnetorquers, IMU, and magnetometers

    267 parts21GPL-2.0
  • 2 layers127 × 36.2 mmIo board, the printed circuit board in 3D

    Io board

    vedderb/rise_sdvp

    The RISE Self-Driving Model Vehicle Platform

    88 parts144GPL-3.0
  • 2 layers80 × 50 mmLcd dual, the printed circuit board in 3D

    Lcd dual

    Novin3dp/7inch-hdmi-screen

    این برد دولایه (۶۸×۴۲ میلی‌متر) همان پنل ۷ اینچ AT070TN92 و تاچ GT915 را این بار از پورت DSI رزبری‌پای راه می‌اندازد. نسخه‌ی HDMI در پوشه‌ی hardware/ دست‌نخورده باقی مانده است.

    127 parts1
  • 4 layers74.1 × 130 mmBadge secsea V1 1, the printed circuit board in 3D

    Badge secsea V1 1

    cchaloin/HIP_SecSea

    Hack In Provence badge for SecSea

    132 parts
  • 4 layers65 × 56 mmEWS, the printed circuit board in 3D

    EWS

    eiten/EWS

    Universal 3D-Printer HAT for SBC with CAN-Interface and USB Hub

    124 parts1
  • 2 layers60 × 60 mmHighPower Mechaduino, the printed circuit board in 3D

    HighPower Mechaduino

    pointhi/HighPower-Mechaduino

    Mechaduino derivative which drives up to 10A, drawn using KiCad

    140 parts31
  • 4 layers52.1 × 55.6 mmFOCdriver, the printed circuit board in 3D

    FOCdriver

    I-M-Robotics-Lab/Curl-Drive-Hardware

    Brushless Motor FOC Controller

    168 parts14GPL-3.0

Questions

How big is the Foc driver PCB?

It measures 36.5 × 56 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Foc driver use?

132 parts, built around the INA240A1PW, AS5047D, LM321 and LP2985-33DBV. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Foc driver KiCad files?

From the sirojudinMunir/sf-motion repository on GitHub, at the commit this page was made from: the board is Hardware/foc_driver.kicad_pcb and its schematic Hardware/Communications.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Foc driver design in my own project?

Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).