Skip to the content
2 layers67.5 × 71 mmDriver board, the printed circuit board in 3D

A PID-based motor control system for the STM32F411 Black Pill microcontroller, designed to control 4 DC motors with encoders via H-bridge drivers (e.g., TI DRV8874).

Size
67.5 × 71 mm
Copper layers
2
Thickness
1.6 mm
Parts
26
Nets
66
Pads
143
Tracks, vias
303, 50
Pours
1
Routed
Yes
KiCad
KiCad 9.0 (file 20241229)
Created
14 Dec 2025
Updated
4 Jul 2026

Overview

Driver board is an open-source printed circuit board by jacko465, from the jacko465/stm32_blackpill_pid_controller repository on GitHub. It is a 2-layer board of 67.5 × 71 mm with 26 parts on 66 nets, routed with 303 tracks and 50 vias.

Its parts include 6 resistors, 1 IC and 1 connector.

README

readme.md

STM32 Black Pill PID Motor Controller

Example v1 PID controller deployment

v1 deployment of the PID controller. With Pololu 4035 driver modules

A PID-based motor control system for the STM32F411 Black Pill microcontroller, designed to control 4 DC motors with encoders via H-bridge drivers (e.g., TI DRV8874).

Features

  • High-frequency PID control: 1 kHz PID loop running on TIM10 interrupt
  • Encoder feedback: 100 Hz encoder updates (quadrature decoding)
  • 4 independent motor channels: Each with PWM speed control and direction control
  • Configurable PID gains: Kp, Ki, Kd parameters per motor
  • Anti-windup protection: Integral clamping to prevent windup

Hardware Configuration

Motor Specifications

  • Encoder: 11 PPR (basic) × 4 (quadrature) × 35.5 (gear ratio) = 1562 counts/revolution
  • PWM Frequency: Configured via TIM1 = 20kHz
  • Control Loop: 1 ms update period (1 kHz)
  • Encoder Reading: 10 ms update period (100 Hz)

System Clock

  • 84 MHz SYSCLK derived from 25 MHz HSE crystal
  • Configured with PLL (PLLM=25, PLLN=336, PLLP=4)

Pinout

Pinout Diagram

FunctionPinTimer/Channel
Motor 1 PWMPA8TIM1 CH1
Motor 2 PWMPA9TIM1 CH2
Motor 3 PWMPA10TIM1 CH3
Motor 4 PWMPA11TIM1 CH4
Motor 1 DIRPB0GPIO
Motor 2 DIRPB1GPIO
Motor 3 DIRPB2GPIO
Motor 4 DIRPB10GPIO
Motor 1 Encoder APA0TIM5 CH1
Motor 1 Encoder BPA1TIM5 CH2
Motor 2 Encoder APA6TIM3 CH1
Motor 2 Encoder BPA7TIM3 CH2
Motor 3 Encoder APB6TIM4 CH1
Motor 3 Encoder BPB7TIM4 CH2
Motor 4 Encoder APA5TIM2 CH1
Motor 4 Encoder BPB3TIM2 CH2
USART2 TXPA2USART2
USART2 RXPA3USART2
LEDPC13GPIO (onboard)

PID Configuration

Default PID gains (defined in motor.h):

  • Kp: 0.1
  • Ki: 0.125
  • Kd: 0.0
  • Integral Limit: 5.0 (anti-windup)
  • Output Range: -1.0 to 1.0 (bidirectional control)

Motor Control Functions

This project has been coded for EN/PH driver control mode

The motor.c module provides:

  • Motor_SetTargetRPM(): Set target velocity in RPM
  • Motor_Forward(): Drive motor forward with duty cycle
  • Motor_Reverse(): Drive motor in reverse with duty cycle
  • Motor_Break(): Active braking (both H-bridge outputs high)
  • Motor_Coast(): Free-running coast (both outputs low)

Building

This project uses PlatformIO. To build and upload

Error Handling

The Error_Handler() function provides visual feedback via fast blinking of the onboard LED (PC13) if system initialization fails.

Parts

26
QtyValueFootprintReferences
6R_Small_USResistor_THT:R_Axial_DIN0309_L9.0mm_D3.2mm_P12.70mm_HorizontalR1, R2, R3, R4, R5, R6
2Screw_Terminal_01x02TerminalBlock:TerminalBlock_MaiXu_MX126-5.0-02P_1x02_P5.00mm5V_IN1, VBAT1
1Conn_01x03_PinConnector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_VerticalJ1
1M1_C1Connector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_VerticalM1_C1
1M1_C2Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalM1_C2
1M2_C1Connector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_VerticalM2_C1
1M2_C2Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalM2_C2
1M3_C1Connector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_VerticalM3_C1
1M3_C2Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalM3_C2
1M4_C1Connector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_VerticalM4_C1
1M4_C2Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalM4_C2
1MOTOR1Custom_Footprint_Library:Pololu_4035_DRV8874_Motor_DriverMOTOR1
1MOTOR2Custom_Footprint_Library:Pololu_4035_DRV8874_Motor_DriverMOTOR2
1MOTOR3Custom_Footprint_Library:Pololu_4035_DRV8874_Motor_DriverMOTOR3
1MOTOR4Custom_Footprint_Library:Pololu_4035_DRV8874_Motor_DriverMOTOR4
1~Custom_Footprint_Library:STM32 Black PillU5

The 22 most common of 26 parts.

Similar boards

  • 2 layers57.3 × 19 mm11ua, the printed circuit board in 3D

    11ua

    rene-dev/stmbl

    AC Servo Driver for STM32F4

    26 parts990GPL-3.0
  • 2 layers98 × 59.5 mmMCP23017 PCB, the printed circuit board in 3D

    MCP23017 PCB

    hackclub/OnBoard

    💡 Join 1,000 teenagers and make your first PCB with a $100 grant!

    26 parts915
  • 2 layers142.9 × 98.5 mmCantor MX, the printed circuit board in 3D

    Cantor MX

    diepala/cantor

    Cantor keyboard, a 42 key diodeless split keyboard.

    26 parts756GPL-3.0
  • 2 layers103.8 × 50 mmGalagino pcb set, the printed circuit board in 3D

    Galagino pcb set

    harbaum/galagino

    A Galaga, Pac-Man and Donkey Kong arcade emulator for the ESP32

    26 parts558
  • 2 layers20.3 × 34.8 mmL0 ESP32, the printed circuit board in 3D

    L0 ESP32

    Luos-io/luos_engine

    Open-source and real-time orchestrator for cyber-physical-systems, to easily design, test and deploy embedded applications and digital twins.

    26 parts546MIT
  • 2 layers40.6 × 50.8 mmWALTsm, the printed circuit board in 3D

    WALTsm

    google/walt

    A device for measuring latency of physical sensors and outputs on phones and computers

    26 parts474Apache-2.0
  • 2 layers158.5 × 75 mmDoj v2, the printed circuit board in 3D

    Doj v2

    kelu124/echomods

    Open source ultrasound processing modules and building blocks

    26 parts463

Questions

How big is the Driver board PCB?

It measures 67.5 × 71 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Driver board use?

26 parts. 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 Driver board KiCad files?

From the jacko465/stm32_blackpill_pid_controller repository on GitHub, at the commit this page was made from: the board is Kicad_PCB/driver_board.kicad_pcb and its schematic Kicad_PCB/driver_board.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Driver board design in my own project?

Its repository states no licence, so its author keeps all rights: ask jacko465 before reusing the design.