seveibar/pd-dual-stepper-controller

Bottom-side PCB silkscreen artwork consisting of embedded mirrored TS Circuit SVG logos, with via-clearance-aware lower-board placement.

Version
0.1.0
License
unset
Stars
0

Files

README.md

# Dual USB-PD stepper controller

**Routed prototype β€” 55 Γ— 45 mm, 31% smaller than the previous dual board.** All 119 electrical nets are connected. Native routing checks, independent copper connectivity/clearance checks, and exported Gerber/drill audits pass. Physical and thermal testing remain outstanding.

Editable tscircuit hardware design cloned from [imrishabh18/rp2040-motor-controller](https://tscircuit.com/imrishabh18/rp2040-motor-controller), registry release **1.0.42**, then adapted for two motors. The exact downloaded release is preserved in the initial Git commit (`1e07613`); `clone-provenance.json` records every source file and release ID.

## Hardware

- RP2040 controller, crystal, external flash, BOOT/RESET and SWD from the reference.
- Two DRV8825PWPR bipolar stepper channels, each with its own STEP, DIR, reset, enable, fault, PD-gated sleep, charge pump, decoupling, reference divider and current-sense resistors.
- **1 A full-scale phase current per motor**, fixed **1/16 microstepping**. Each driver uses `VREF = 3.3 Γ— 2k/(2.4k+2k) = 1.5 V` and `I_FS = VREF/(5 Γ— 0.3 Ξ©) = 1 A`. This is a current-limit setting, not a guaranteed continuous thermal rating.
- Shared CH224K USB-PD negotiation, reset default 5 V and firmware-selectable 9/12/15/20 V. **20 V is the intended operating supply**; the DRV8825 does not operate at 5 V.
- Separate **DATA** USB-C for programming/control and logic power, and **PWR** USB-C for a USB-PD supply. The motor USB port does not power the RP2040. Both ports are needed for standalone operation unless logic is powered separately through a suitably engineered modification.
- Shared reference input protection: 2 A / 30 V resettable fuse, 2 A blocking diode, 22 V TVS and 50 V motor-rail capacitors. **The 2 A input limit is shared between both motors**, not per motor. At 20 V the nominal input ceiling is 40 W; allow conversion, diode and thermal losses and fuse derating. Use a USB-PD adapter advertising 20 V, preferably a 60 W adapter with a 3 A cable; the adapter's larger rating does not increase the board rating.
- Motor 1 retains the reference's winding-current telemetry and nearby TMP102 temperature sensor. Motor 2 has the DRV8825's internal current regulation and fault output, but no external current/temperature telemetry.
- Audible alarm and RGB status retained. The shaft-mounted magnetic encoder is removed.

## Mechanical

Four-layer PCB, **55 Γ— 45 Γ— 1.6 mm**, rectangular outline with four **3.3 mm non-plated M3 clearance holes**. Hole spacing is **47 Γ— 37 mm**. Centers are 4 mm from the edges. Coordinates in the source are `(-21,-20), (-21,17), (26,-20), (26,17)`; the board spans `x=-25…30`, `y=-24…21` mm. Each hole has a 3.2 mm radius copper keepout for the screw head. Use insulating standoffs and check the chosen screw/washer outside diameter against the 6.4 mm keepout.

Both outputs use **S4B-PH-K-S(LF)(SN) right-angle JST PH** connectors, mating outward through the right-hand board edge. The footprint and STEP model follow the manufacturer/KiCad horizontal part. The pin order is **1=A+, 2=Aβˆ’, 3=B+, 4=Bβˆ’**. There is no NEMA17 mounting constraint. See `mechanical/dual-mounting-template.svg` for a 1:1 template.

## Firmware interface

| Signal | Motor 1 | Motor 2 |
|---|---:|---:|
| STEP | GPIO18 | GPIO8 |
| DIR | GPIO19 | GPIO9 |
| nRESET | GPIO20 | GPIO10 |
| nENABLE (low enables outputs) | GPIO21 | GPIO11 |
| Sleep request (high wakes, only when PD-good) | GPIO22 | GPIO12 |
| nFAULT input (active low) | GPIO23 | GPIO13 |

PD voltage selection is GPIO4/5/6: `000=5 V`, `111=9 V`, `110=12 V`, `100=15 V`, `101=20 V`. These are MCU GPIO levels before the inverting open-collector buffers. Keep **both GPIO22 and GPIO12 low** while negotiating or changing voltage. Keep nENABLE high until the contract is stable, release nRESET, request wake, wait the DRV8825's specified wake interval, then enable stepping. Firmware must handle faults, the shared input-power budget, and safe stop behavior. The reference PG signal is a voltage-negotiation interlock; it does not measure remaining adapter power.

No application firmware is included. The board defaults to disabled/sleeping after MCU reset. Do not connect or disconnect motor coils while energized.

## Build and review

```sh
bun install --frozen-lockfile
bun run build
bun run test
bun run typecheck
```

`bun run build` regenerates the completed PCB and schematic from the guarded saved routing. The default `index.circuit.tsx` entry point also loads this routing; edits that change PCB geometry or connectivity require rerouting. `bun run verify` runs the build, type check, six tests (75 assertions), and design/routing checks.

Current outputs are in `dist/dual/`: `pcb.svg`/`pcb.png`, `schematic.svg`, combined `circuit.json`, `gerbers.zip`, assembly BOM and pick-and-place CSVs. `validation.json` records the results and artifact hashes. The original single-channel outputs are archived in `reference/`.

For the independent manufacturing audits, install Python 3 with `numpy` and `shapely`:

```sh
bun run check:manufacturing
bun run check:shorts
bun run export:manufacturing
bun run check:exports
```

The two drivers have matching placement groups, short local bypass/current-regulation loops, and 12 thermal vias each with solid inner/bottom ground contact. Motor/input load routes use outer copper with at least 0.3 mm exposed track width, widening to 0.8–1 mm where space permits. This geometry check does not establish the continuous thermal rating. Validate USB-PD behavior, both motors under load, connector and driver temperatures, and firmware fault handling on the assembled prototype before a production run. One cosmetic schematic capacitor-orientation advisory remains; PCB routing has no unresolved diagnostics.

Original supplier footprints and attribution/license files are preserved in `imports/`, `vendor/` and `mechanical/PD-Stepper-LICENSE`.