Projects / Dual motor driver

Power electronics · 2026

Open Dual Motor Driver

A 50 × 60 mm dual H-bridge driver for brushed DC motors, built around the RP2350 and TI DRV8412, with current sensing, encoder input and a desktop tuning GUI.

Supply
4–40 V (tested to 31 V)
Current
3 A per motor, 6 A peak
Bridge
TI DRV8412, 20 kHz PWM
MCU
RP2350 (Pico 2 module)
Sensing
2× ACS722, AS5600 encoder
Host link
USB, UART, I²C (0x16)
Board
50 × 60 mm, 4-layer
The driver board on a desk, wired to two DC motors on 3D-printed stands

Hardware

The 4-layer board has three sections. The power section holds input filtering, bulk capacitance and the DRV8412, run in PWM mode with one PWM line per half-bridge. The sensing section puts an ACS722 hall-effect current sensor in line with each H-bridge output, measures the input voltage through a 100 k / 10 k divider, and brings the DRV8412 fault and over-temperature warning lines to the MCU. The compute section is a Raspberry Pi Pico 2 module with an AS5600 magnetic encoder and a PCA9633 RGB status LED on I²C0, software-switched I²C pull-ups, a UART header, an SPI header (routed but not used by the firmware) and an I²C slave port.

The two outputs can be tied together to drive one larger motor, and power and I²C have daisy-chain connectors. Schematics, Gerbers, the PCB project and the BOM are in the repository; the BOM, errata and requirement list are also kept in a linked Google Sheet.

The assembled board
The assembled board

Firmware

The firmware is an Arduino sketch on the Earle Philhower RP2040/RP2350 core, split into single-purpose classes: bridge control and fault handling, the AS5600 driver (multi-turn unwrapping and a filtered velocity estimate), a header-only PID with integral clamp and conditional anti-windup, a cascaded position → speed → output controller, the command processor, and the status LED.

  • Control period 4 ms; PWM at 20 kHz with duty capped at 95 %
  • Speed reference up to ±3840 rpm; position reference up to about ±244 turns
  • The same ASCII and binary command set on USB CDC, UART (115200 baud) and the I²C slave at 0x16

Enabling bridge 0 and driving it at 25 % from a serial terminal:

M200 H0 S1
M203 H0 S250

The full command reference, including binary opcodes, status payload layout and error codes, is in Firmware/API_REFERENCE.md.

Desktop GUI

A PySide6 application talks to the board over USB serial. It has manual drive sliders, fault and over-temperature indicators, current and input-voltage gauges, live oscilloscope-style plots, and a closed-loop tab for editing the speed and position PID gains and setting references.

The PySide6 GUI with manual drive controls and live plots
The PySide6 GUI with manual drive controls and live plots