

Deneme2
A completely from-scratch, bare-metal implementation of Field-Oriented Control (FOC) tailored for ultra-low inductance (3 µH) drone motors (e.g., A2212).
- Size
- 100 × 100 mm
- Copper layers
- 4
- Thickness
- 1.6 mm
- Parts
- 118
- Nets
- 126
- Pads
- 412
- Tracks, vias
- 653, 217
- Pours
- 31
- Routed
- Yes
- KiCad
- KiCad 9.0 (file 20241229)
- Created
- 2 May 2026
- Updated
- 2 May 2026
Overview
Deneme2 is an open-source printed circuit board by Gokasimov, from the Gokasimov/STM32-FOC-Control repository on GitHub, published under the MIT licence. It is a 4-layer board of 100 × 100 mm with 118 parts on 126 nets, routed with 653 tracks and 217 vias.
It is built around the STM32G431RBT6, TLV9062ID and IR2110S-MNS, with the AS5047D, MP1482DS-LF-Z and SS14 among its other parts. Its parts include 50 resistors, 43 capacitors, 10 ICs, 6 transistors and 5 connectors. It belongs with the robots and motor control boards and the STM32 boards of this library.
Main components
6STM32G431RBT6
LQFP-64(10x10)-40℃~+85℃ 1.71V~3.6V 128KB 12bit 12bit 170MHz 32 Bit 32KB 52 ARM Cortex-M4F Built-in FLASH LQFP-64(10x10) Microcontrollers (MCU/MPU/SOC) ROHSSTMicroelectronicsMicrocontrollers (MCU/MPU/SOC)TLV9062ID
SOIC-8-40℃~+125℃ 0.05pA 0.5pA 1.6mV 1.8V~5.5V 103dB 10MHz 10nV/√Hz@1kHz 2 50mA 530nV/℃ 538uA 6.5V/us Enable/shutdown function、ESD protection、EMI filtering/RF suppression Rail-to-Rail Input, Rail-to-Rail Output SOIC-8 Operational Amplifier ROHSTexas InstrumentsOperational AmplifierIR2110S-MNS
SOIC-16-300milGate DriversMinosAS5047D
14-Bit On-Axis Magnetic Rotary Position Sensor with 11-Bit Decimal and Binary Incremental Pulse CountOSRAMUncategorisedMP1482DS-LF-Z
SOIC-8-40℃~+85℃@(TA) 1 2A 340kHz 4.75V~18V 923mV~15V Adjustable Buck Buck Built-in Yes SOIC-8 DC-DC Converters ROHSMonolithic Power SystemsDC-DC ConvertersSS14
SMA(DO-214AC)-55℃~+150℃ 1A 25A 300uA@40V 40V 550mV@1A Independent SMA(DO-214AC) Schottky Diodes ROHSMDDSchottky Diodes
README
readme.mdAntigravityFOC: Bare-Metal CORDIC-Accelerated Motor Controller
A completely from-scratch, bare-metal implementation of Field-Oriented Control (FOC) tailored for ultra-low inductance (~3 µH) drone motors (e.g., A2212). Built on a custom-designed STM32G4 PCB, this project bypasses heavy abstraction layers (like HAL and ST MC SDK) to achieve microsecond-level execution times and maximum hardware utilization.
🚀 Key Engineering Achievements
- Blistering 40 kHz Control Loop: Pushed the STM32G4 (150 MHz) to a 25 µs execution window.
- Extreme Execution Efficiency: Through bare-metal register manipulation, FPU caching, and eliminating heavy libraries (
fmodf), the complete FOC ISR execution time was profiled and reduced from 2700 ticks to just 1055 ticks (~7 µs). The CPU remains 72% idle even at 40 kHz. - Ultra-Low Noise Sensing: Achieved an ADC noise floor of just 1.5 LSB standard deviation by utilizing 16x hardware oversampling and triggering the Injected ADC precisely at the TIM1 PWM valley (TRGO2).
- CORDIC Hardware Acceleration: Offloaded heavy trigonometry (Clarke/Park transforms) to the on-chip CORDIC co-processor, calculating simultaneous Sine and Cosine in Q1.31 format in just 24 cycles.
🧠 System Architecture & Development Phases
1. Hardware Synchronization & Dead-Time
- TIM1 Configuration: Center-Aligned Mode 2 at 40 kHz. Dead-time is finely tuned to 45 ticks (~300 ns), verified against the PJD80N06SA-AU MOSFET specifications to ensure zero shoot-through.
- ADC Triggering: TIM1_CH5 generates a TRGO2 rising edge precisely at the PWM valley, ensuring phase currents are sampled when switching noise is mathematically zero.
2. Precision Current Sensing & VBUS Tracking
- Symmetry & Offset: The custom shunt architecture (5 mΩ + TLV9062) yielded a near-perfect hardware symmetry with a phase difference of only 21 raw counts.
- Dynamic VBUS Tracking: The system continuously monitors battery voltage and dynamically recalculates the Space Vector PWM (SVPWM) modulation limits in real-time.
3. High-Speed SPI & Angle Estimation
- Bare-Metal SPI: The AS5047D magnetic encoder is read via bit-banged SPI for maximum speed (≤ 9.375 Mbps), parsing the 14-bit absolute angle.
- Angle Extrapolation (Phase Delay Compensation): To combat the 5–8 µs calculation/ADC delay at high speeds (>5000 RPM), a predictive angle compensator ($\theta_{comp} = \theta_{measured} + \omega_{e} \times T_{delay}$) ensures the D-Q reference frame remains perfectly aligned.
4. Space Vector PWM (SVPWM)
- Implemented a highly optimized Min-Max Zero-Sequence Injection algorithm. This centers the duty cycles, maximizes DC bus utilization, and generates a mathematically perfect sine wave across the motor phases without using lookup tables.
5. Cascaded Control Loop (Custom Anti-Windup PI)
Instead of relying on standard library PID functions, the inner and outer loops are driven by a custom-written discrete PI controller architecture.
- Inner Current Loop (D-Q Axes): Targets a tight 3–5 kHz bandwidth to tame the massive $di/dt$ of the 3.08 µH motor. It features a custom Conditional Anti-Windup algorithm that smartly freezes the integrator only when the output is saturated in the direction of the error, allowing for instantaneous recovery from voltage limits.
- Outer Speed Loop: Eliminated 40 kHz high-frequency quantization noise by developing a custom Angle Accumulator with a 400x downsampling ratio (updating at 10 ms). The result is a buttery-smooth speed estimation fed into the outer PI controller, featuring a first-order setpoint ramp to prevent sudden torque steps while driving the motor up to 12,000 RPM.
📊 Hardware & Telemetry Validation
To validate the math against physical reality, a custom non-blocking RAM logger was built to export high-speed telemetry without disrupting the 25 µs control loop. Detailed analysis is available in the /Results directory.
1. Outer Loop: Critically Damped Speed Response
The motor accelerates from 0 to 4000 RPM with an industrial-grade, critically damped profile. Zero overshoot, zero ringing.
(See: Results/Figure-3.png and Results/step_response.mp4)
2. Inner Loop: D-Q Current Stability
Maintaining $I_d = 0$ (Maximum Torque Per Ampere) while injecting the exact required $I_q$ (Torque) current to accelerate the rotor.
(See: Results/Figure-4.png)
3. Oscilloscope Proofs (SVPWM)
- Phase-to-GND (Saddle Wave): Physical proof of the FPU computing the Min-Max Zero-Sequence injection. (See
Results/Figure-1.jpeg) - Line-to-Line (Pure Sine): Proof that zero-sequence harmonics cancel out, delivering a pure sine wave to the stator. (See
Results/Figure-2.jpeg)
📂 Project Structure
/Firmware- STM32CubeIDE project workspace containing the complete bare-metal C source code (/Core), CORDIC integration, and custom PI controllers./Hardware/Kicad_Files- Source files for the custom PCB design.Board.jpeg- Photo of the physical PCB prototype.Board_3DView.jpg- 3D render of the PCB.BOM_LIST.csv- Bill of Materials.Schematic.pdf- PDF schematic of the motor drive and MCU.
/ResultsFigure-X- Telemetry PNGs and Oscilloscope JPEGs verifying the control theory.step_response.mp4- Video of the motor achieving 4000 RPM seamlessly.readme.md- In-depth breakdown of the telemetry and scope results.
📝 License
This project is open-source and available under the MIT License.
Parts
118| Qty | Value | Footprint | References |
|---|---|---|---|
| 16 | 0.1uF | Capacitor_SMD:C_0805_2012Metric | C3, C6, C10, C11, C15, C16, C23, C24, C25, C26, C34, C35, C36, C37, C38, C39 |
| 8 | 24k | Resistor_SMD:R_0805_2012Metric | R3, R11, R23, R36, R37, R48, R49, R50 |
| 7 | 10k | Resistor_SMD:R_0805_2012Metric | R5, R6, R9, R10, R15, R16, R29 |
| 6 | 10 | Resistor_SMD:R_0805_2012Metric | R1, R2, R7, R8, R13, R14 |
| 6 | 1k | Resistor_SMD:R_0805_2012Metric | R4, R12, R21, R22, R34, R35 |
| 6 | 1nF | Capacitor_SMD:C_0805_2012Metric | C30, C31, C32, C44, C45, C46 |
| 6 | SUD50N06 | Package_TO_SOT_SMD:TO-252-2 | Q1, Q2, Q3, Q4, Q5, Q6 |
| 5 | 1uF | Capacitor_SMD:C_0805_2012Metric | C1, C7, C12, C20, C21 |
| 4 | 100n | Capacitor_SMD:C_0805_2012Metric | C40, C41, C42, C43 |
| 4 | 22K | Resistor_SMD:R_0805_2012Metric | R40, R42, R44, R46 |
| 4 | 3.3K | Resistor_SMD:R_0805_2012Metric | R41, R43, R45, R47 |
| 3 | 1n | Capacitor_SMD:C_0805_2012Metric | C8, C9, C13 |
| 3 | 22 | Resistor_SMD:R_0805_2012Metric | R30, R31, R38 |
| 3 | 270 | Resistor_SMD:R_0805_2012Metric | R26, R27, R39 |
| 3 | 470u | Capacitor_THT:CP_Radial_D10.0mm_P5.00mm | C2, C4, C5 |
| 3 | 5m | Resistor_SMD:R_Shunt_Vishay_WSK2512_6332Metric_T1.19mm | R19, R28, R33 |
| 3 | Conn_01x01_Pin | Connector_Wire:SolderWire-2sqmm_1x01_D2mm_OD3.9mm | J2, J3, J4 |
| 3 | IR2110S | Package_SO:SOIC-16W_7.5x10.3mm_P1.27mm | U1, U2, U3 |
| 3 | SS14 | Diode_SMD:D_SMA | D1, D2, D3 |
| 3 | TLV9062 | Package_SO:SOIC-8_3.9x4.9mm_P1.27mm | U4, U9, U10 |
| 2 | 10K | Resistor_SMD:R_0805_2012Metric | R25, R32 |
| 2 | 22u | Capacitor_SMD:C_0805_2012Metric | C28, C29 |
| 1 | 0.1u | Capacitor_SMD:C_0805_2012Metric | C19 |
| 1 | 100k | Resistor_SMD:R_0805_2012Metric | R17 |
| 1 | 10n | Capacitor_SMD:C_0805_2012Metric | C14 |
| 1 | 10u | Capacitor_SMD:C_0805_2012Metric | C22 |
| 1 | 10u | Inductor_SMD:L_7.3x7.3_H3.5 | L1 |
| 1 | 12k | Resistor_SMD:R_0805_2012Metric | R20 |
| 1 | 26.1k | Resistor_SMD:R_0805_2012Metric | R24 |
| 1 | 3.3n | Capacitor_SMD:C_0805_2012Metric | C27 |
| 1 | 5.6k | Resistor_SMD:R_0805_2012Metric | R18 |
| 1 | AS5047D | Package_SO:TSSOP-14_4.4x5mm_P0.65mm | U6 |
| 1 | Conn_01x02_Pin | Connector_AMASS:AMASS_XT60-M_1x02_P7.20mm_Vertical | J1 |
| 1 | Conn_01x04_Pin | Connector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_Vertical | J6 |
| 1 | LM7812_TO220 | Package_TO_SOT_THT:TO-220-3_Vertical | U8 |
| 1 | MP1482DS-LF-Z | Package_SO:SOIC-8_3.9x4.9mm_P1.27mm | U7 |
| 1 | STM32G431RBT6 | Package_QFP:LQFP-64_10x10mm_P0.5mm | U5 |
Similar boards
- 2 layers85.3 × 50.3 mm

- 2 layers96.5 × 81.3 mm

- 2 layers110.3 × 110.3 mm

H Bridge PCB
reinto1234/H_Bridge_PCB
The project consists of two main components: 1. HBridgePCBDesign — KiCad PCB layout and schematic. 2. HBridgePCBCode — Firmware for the ESP32 controller.
124 parts - 8 layers163.5 × 123.5 mm

- 8 layers123.5 × 58 mm

BLDC MC V1.0
AhmedAbo-Eita/BLDC_Motor_Driver
BLDC Motor Driver hardware and firmware project including power stage, gate driver, protection circuits, and control firmware for sensor-based and/or sensorless BLDC motors.
234 parts1 - 6 layers62 × 77 mm

Black Body Temperature Sensor PCB
DylanLockyer/Black_Body
Electrical system for black body MKID tester
217 parts1MIT - 4 layers100 × 100 mm

- 2 layers79 × 60 mm

Questions
How big is the Deneme2 PCB?
It measures 100 × 100 mm and has 4 copper layers, 1.6 mm thick.
What parts does the Deneme2 use?
118 parts, built around the STM32G431RBT6, TLV9062ID, IR2110S-MNS and AS5047D. 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 Deneme2 KiCad files?
From the Gokasimov/STM32-FOC-Control repository on GitHub, at the commit this page was made from: the board is Hardware/Kicad_Files/deneme2.kicad_pcb and its schematic Hardware/Kicad_Files/CurrentSensor.kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Can I use the Deneme2 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).