hbridge-motor-driver
PublicLoading 3D model… large boards can take a moment.
H-bridge motor driver
A two-channel brushed DC motor driver on a 74.00 x 55.75 mm two-layer board, built around a Raspberry Pi Pico. Each channel is a full H-bridge of logic-level MOSFETs with its own current sense, quadrature encoder header, and gate drivers. Designed in KiCad 10.
Why it exists
Off-the-shelf driver modules hide the parts that matter. The L298N wastes about 2 V across its bipolar output stage, gives you no current feedback, and no encoder path, so you cannot close a velocity loop or detect a stall. This board replaces the module with discrete MOSFETs, adds a shunt and an amplifier per channel, and brings the encoder signals onto the same PCB as the Pico.
The design is at v4. Versions v1 to v3 are kept in Hardware/ so the layout progression stays visible.
Board
| Size | 74.00 x 55.75 mm |
| Layers | 2 (F.Cu, B.Cu) |
| Controller | Raspberry Pi Pico (RP2040) |
| Channels | 2 |
| Mounting | 4 x M3 |
Circuit
Each channel repeats the same block. Channel 1 is on sheet ch1.kicad_sch, channel 2 on ch2.kicad_sch.
Output stage. Four IRLZ44N logic-level N-channel MOSFETs form the bridge, Q1 to Q4 on channel 1 and Q5 to Q8 on channel 2. Logic-level gates matter here because the Pico drives the gate drivers from 3.3 V.
Gate drive. Two IR2104 half-bridge drivers per channel. Each has a 1N4148 bootstrap diode and a 100 nF bootstrap capacitor to hold the high-side gate above the source rail. The IR2104 also provides shoot-through protection through its internal deadtime, so both MOSFETs in a leg cannot conduct at once. Gate resistors R1 to R4 and R9 to R14 set the switching edge rate.
Current sense. A low-side shunt (R5 on channel 1, R8 on channel 2) feeds an MCP6001 op-amp, U3 and U5. The R_f and R_g pair sets the gain into the Pico ADC. This is what makes stall detection and torque limiting possible.
Encoder. A 4-pin header per channel, J_ENC_CH1 and J_ENC_CH2, carrying power, ground, and the A and B channels. Each signal has a 10k pull-up and a 1 nF filter capacitor, R16 to R19 and C12 to C15.
Board temperature. An NTC thermistor TH1 sits in a divider with a 10k resistor R15, read on a Pico ADC pin. It reads the board, not the die, so it lags the MOSFET junction.
Power. A 100 uF bulk capacitor C11 at the input, 100 nF decoupling at every driver. Screw terminals: J_PWR1 in, J_MOT1 and J_MOT2 out.
Schematic
Root sheet, with both channel sheets below it.
Channel 2 is identical. The full three-sheet set is in Images/schematic.pdf.
Version history
| Version | Change |
|---|---|
| v1 | First working layout. |
| v2 | Smaller board. Silkscreen DRC warnings remain. |
| v3 | Smaller again. DRC clean, no errors and no warnings. |
| v4 | Adds quadrature encoder inputs, the NTC thermistor, and M3 mounting holes. |
Thermal model
CAD/ holds STEP exports for thermal analysis. v4.step includes only the footprints that matter thermally, which keeps the mesh cell count down in Icepak. HBridge.emn and HBridge.emp are the IDF board and library files for tools that import board outline and component placement directly.
Repository layout
Hardware/HBridge/ v1 KiCad project
Hardware/HBridge-v2/ v2
Hardware/HBridge-v3/ v3
Hardware/HBridge-v4/ v4, current
CAD/ STEP and IDF exports for thermal work
Images/ Renders and schematic plots used by this README
Not yet done
Read this before you build one.
- Passive values are still placeholders in the schematic.
R_gate,R_shunt,R_f, andR_gcarry symbolic values, not resistances. Pick them before ordering. - The motor supply voltage and the target continuous current are not fixed, so the shunt and the copper pour width have not been sized against a real number.
- No board has been assembled or measured. Nothing here is bench-verified.
- No firmware. The Pico side is unwritten.
Regenerating the images
Every image in Images/ comes out of kicad-cli. Run these from Hardware/HBridge-v4/.
K="$HOME/AppData/Local/Programs/KiCad/10.0/bin/kicad-cli.exe"
"$K" sch export pdf -o ../../Images/schematic.pdf HBridge.kicad_sch
"$K" sch export svg --exclude-drawing-sheet -o ../../Images/sch HBridge.kicad_sch
"$K" pcb render -o ../../Images/pcb_top.png --side top --zoom 0.9 \
-w 1600 --height 1200 --background opaque --quality high HBridge.kicad_pcb
"$K" pcb render -o ../../Images/pcb_3d.png --side top --rotate "-30,0,25" --zoom 0.85 \
-w 1600 --height 1200 --background opaque --quality high --perspective HBridge.kicad_pcb
kicad-cli writes the schematic SVGs with a transparent background, which makes
them unreadable on a dark page. Add a white rectangle to each one after export:
for f in ../../Images/sch/*.svg; do
sed -i 's|\(viewBox="[^"]*">\)|\n<rect width="100%" height="100%" fill="#FFFFFF"/>|' "$f"
done
Written against kicad-cli 10.0.3.
License
MIT. See LICENSE.
No comments yet. Be the first to ask about this board.