Build an Open-Source USB-C PD Lab Power Supply
A pocket bench supply that runs off your laptop charger. 0–20 V, 0–5 A, knob-driven, and totally hackable. Total cost: less than dinner for two.
Why USB-C PD changed bench supplies
USB Power Delivery 3.1 negotiates up to 28 V at 5 A from a generic laptop brick. That means your bench supply doesn't need a transformer, a fuse box, or a metal chassis. The work shifts from generating the rail to shaping it — a tiny buck converter, a current sense resistor, a microcontroller, and a rotary encoder.
Architecture in one picture
Bill of materials
| Part | Why | Cost |
|---|---|---|
| CH224K PD trigger IC | Negotiates up to 20 V over CC pins | $0.80 |
| TPS54331 buck | Wide input, adjustable, 28 V/3 A | $2.20 |
| INA226 current sensor | 16-bit V and I over I²C | $1.40 |
| MCP4725 DAC | Sets buck feedback reference | $1.10 |
| RP2040 + 0.96" OLED | UI, encoder, USB-C config | $5.50 |
| Rotary encoders ×2 + knob caps | Voltage + current | $3 |
| 3D-printed shell + binding posts | PETG works | $5 |
| JLCPCB 4-layer board (qty 5) | $2/m² POE deal | $8 |
Total $27 for the rev-1 board, ~$40 with a printed enclosure and decent banana posts.
Firmware, the smart part
Each rotary tick changes the DAC code; the MCP4725 sets the feedback divider on the TPS54331. The INA226 reads back V and I twice per encoder tick, and a PI loop closes voltage regulation. A "constant current" mode kicks in when measured current exceeds setpoint — drop the DAC to taste.
// MicroPython on RP2040
from machine import I2C, Pin
ina = INA226(i2c, addr=0x40)
dac = MCP4725(i2c, addr=0x60)
v_set, i_set = 5.00, 0.500
while True:
enc = read_encoders()
v_set += enc.v_delta * 0.01
i_set += enc.i_delta * 0.005
v, i = ina.bus_voltage, ina.current_a
if i > i_set: # CC mode
dac.write(max(0, dac.last - 1))
else: # CV mode
target = int(v_set / 20.0 * 4095)
dac.write(target + pi.step(v_set - v))
oled.show(v, i, mode="CC" if i>=i_set else "CV")
Calibration in 90 seconds
Hook a known-good DMM in series and parallel. Run a 7-point sweep at 1 V, 5 V, 9 V, 12 V, 15 V, 18 V, 20 V. The RP2040 fits a 2-segment linear correction in flash. Repeat for current at 100 mA, 500 mA, 1 A, 2 A, 4 A. After this, your unit reads to ±0.5 % across the range — better than most $250 store-bought supplies.
Where to take it
Add a USB serial protocol so a desktop app can sweep V and log I — instant battery analyser. Add a second channel and you have a dual-rail supply for $60. Sell it on Tindie at $129 with a printed shell and you've shipped your first hardware product.
Comments
Post a Comment