MustafaMulla29/usb-pd-motherboard

4-layer USB-C PD hub motherboard with 20 V USB-C input, Linux T113-S3 computer, CH338F USB hub, four individually controlled 5–20 V PD outputs, USB data/camera ports, regulated rails, and hardware watchdog/E-stop safety interlock.

Version
1.0.24
License
unset
Stars
0

Use with the tscircuit CLI

tsci is the tscircuit CLI. Install it with npm install -g tscircuit.

tsci clone MustafaMulla29/usb-pd-motherboard  # download the package files into ./usb-pd-motherboard
tsci add MustafaMulla29/usb-pd-motherboard    # add it to your project as @tsci/MustafaMulla29.usb-pd-motherboard

In a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.

enclosure/README.md

# Printed enclosure

Built the same way as the `MustafaMulla29/rp2040-bldc-motor-controller` enclosure: the printed parts are
jscad-fiber JSX (`parts.tsx`), shown in tscircuit as an `assembly.device` with `assembly.printedpart`s
(`enclosure.circuit.tsx`, and with the board in `../enclosed-system.circuit.tsx`), and exported to STL with the
Manifold solid kernel (`export_solid.py`). The layout is the accepted concept v1 (`v1/`), with three changes:
no text or colour marks (labels will be UV printed later), STOP IN is a closed knock-out, and the lid is held by
four M2 screws put in from underneath (instead of snap hooks), so the lid top has no screw holes.

## Files

| File | What it is |
| --- | --- |
| `reference-board.json` | Board facts the enclosure uses (outline, corner holes, connector and button positions), extracted from `../dist/index/circuit.json` by `measure-reference.ts` |
| `dimensions.ts` | Every enclosure dimension, with the reason for it |
| `parts.tsx` | Base, lid and stop button cap |
| `enclosure.circuit.tsx` | tscircuit assembly: the three printed parts and the service explosion (cap off, then lid up) |
| `build.tsx` | Checks the board still matches `reference-board.json`, builds the parts and the assembly, then runs `export_solid.py` |
| `export_solid.py` | JSCAD plan → Manifold solid → STL; checks each part is one closed solid and matches JSCAD's bounds and volume |
| `viewer.html`, `render-server.ts` | Renders the PNG views in `renders/` from the exported parts and `board.glb` |
| `example/` | Example system and explainer video: the hub driving four `rp2040-bldc-motor-controller` units (below) |

## Commands (from the project root)

```
bun run enclosure:setup      # once: Python venv with manifold3d, trimesh, numpy
bun run enclosure:measure    # after any board change, then review the enclosure
bun run enclosure:build      # enclosure/dist: STL (print orientation), assembled GLB, reports
bun run build:enclosed       # board + enclosure in one tscircuit assembly (fit check)
bun run enclosure:renders    # then open http://localhost:4317/ and call renderAll() in the console
```
`board.glb` comes from `tsci export index.circuit.tsx -f glb -o enclosure/board.glb` (48 MB, not pushed).

## Example system and explainer video

The reviewer asked what you could connect, so `example/` shows one use: a small motor test bench. A 60 W
charger on PD IN, a laptop on PC, a USB camera on CAM; on the right edge PD OUT 1 + USB 1 feed a
`MustafaMulla29/rp2040-bldc-motor-controller` (15 V) driving a 2212 motor with a propeller on a thrust stand,
USB 2 a thrust sensor (data only), PD OUT 2 a 12 V LED light and PD OUT 3 a phone at 9 V (power only).
The video (about 3 min 29 s) has these chapters: the ports (they alternate: USB 1, PD OUT 1, USB 2 … PD OUT 4),
the left side and back, what the test bench is for, who does what (the motor controller drives the motor through
3 motor wires; the propeller is bolted on the motor and has no wires; the load cell's 4 wires go to the thrust
sensor on USB 2), which port goes where (close-up with every port labelled), 1 power, 2 data, 3 a test run (set speed over USB 1, read
thrust over USB 2, the supervisor measures PD OUT 1 volts and amps, readings saved on the microSD card), 4 the camera
(its own view, recorded with the same timestamps), 5 safety (stop button, re-arm, watchdog) and the optional wired
STOP IN button (closed knock-out; remove RSTOPEXT to use it), inside the box, 6 programming (microSD, FEL on the PC
port, SWD for supervisors A and B, reset pinhole), 7 the debug UART (Linux console) and the system diagram
(`../docs/system-diagram/example_system.svg`; the PNG copies that `bun tools/render-system-diagram.tsx` also writes
are not pushed, to stay under the registry's upload limit).
Every statement about the hub in the video is checked against the board source; the list is at the top of
`example/system-video.html`. Stills from the video are in `../docs/example-system/`.

```
.venv/bin/python example/build_bldc_unit.py   # once: example/source/bldc-circuit.json -> example/bldc-unit.glb
bun run enclosure:renders                       # then open http://localhost:4317/enclosure/example/system-video.html
```
In the browser console: `still(44, "name")` saves one frame to `renders/name.png`; `makeVideo()` saves the
209 s video to `renders/explainer.mp4` (H.264, 1280 × 720, made in the browser with WebCodecs, streamed to disk).
`example/source/bldc-circuit.json` is that project's published `dist/index/circuit.json` (10 MB, not pushed;
`example/bldc-unit.glb`, made from it, is pushed);
its enclosure parts are JSCAD plans, evaluated with the same Manifold kernel as ours.
The charger, laptop, camera, light, phone, thrust sensor, stand, motor, emergency stop button, USB-serial adapter and SWD probe are simple stand-ins; test numbers, the laptop app and the console text are examples.

## Print set

| Part | Qty | Print orientation | Notes |
| --- | ---: | --- | --- |
| `dist/base.stl` | 1 | floor down | 95.2 × 103.2 × 16.6 mm |
| `dist/lid.stl` | 1 | top face down | 95.2 × 103.2 × 11.0 mm; the light-pipe holder, reset guide and insert bosses point up |
| `dist/stop-cap.stl` | 1 | top face down | Ø11 mm, red |

PETG or ASA, not PLA (PLA softens near 55 °C and the four power converters make heat).

## Bought parts

| Part | Qty | Use |
| --- | ---: | --- |
| M2 × 3 heat-set insert (Ø3.6 mm), the same part as in rp2040-bldc-motor-controller | 4 | into the lid bosses from below: drop it through the Ø3.8 mm entry bore (3.9 mm deep), then heat-set it into the Ø3.4 mm pilot |
| M2 × 14 pan-head screw (head Ø ≤ 4.2 mm, ≤ 1.5 mm tall) | 4 | from under the base, up through the standoffs and the board's corner holes into the inserts; the heads sit in Ø4.6 × 1.6 mm recesses |
| 1.5 mm clear PMMA rod (light pipe) | 3 × 11 mm | into the three lid holes over the LEDs |
| Stick-on rubber feet, Ø10 mm | 4 | under the base at x = ±33, y = ±38 mm, clear of the screw heads |

## Design notes

- Outside 95.2 × 103.2 × 18.6 mm; the stop cap stands 5.2 mm above the lid. The lid sits 9 mm above the board only
  because the stop switch body is 8.15 mm tall; every other part is under 4.3 mm.
- One set of four M2 screws, put in from underneath, clamps base, board and lid. Hardware is the case hardware of
  rp2040-bldc-motor-controller (M2 × 3 inserts, M2 pan-head screws); its M3 board hardware does not fit here, because
  the USB-C sockets sit 2.1–2.9 mm from the corner-hole centres, inside an M3 insert (Ø4.6) or head (Ø5.6). The
  screw is 14 mm long (that project uses 4 mm) because it passes through the 6 mm base and the 1.6 mm board; it
  engages the full 3 mm insert. Each insert sits 0.6 mm above the USB-C shells (z 4.7–7.7 mm), so its boss wall is
  complete; below that the boss is relieved over the sockets and two small resistors. The base standoffs are
  notched where a USB-C socket leg sticks out under the board.
- To open: turn the box over, undo the four screws, lift the lid.
- USB-C openings are 10.2 × 6.2 mm: the sockets end 0.3 mm inside the board edge, so a cable's plastic head has to
  reach through the 2.2 mm wall. With 11 mm between sockets, cable heads wider than about 10 mm will not fit side by side.
- STOP IN (JESTOP) is a knock-out: the opening is cut from inside and a 0.6 mm skin is left on the outside. Cut it
  out only when a wired stop button is fitted (and remove the RSTOPEXT link on the board).
- Stop cap: socket 2.1 × 3.05 mm onto the switch post (2.0 × 2.98 mm), 2.66 mm deep. The head lands on the lid at
  the switch's full travel (2.5 mm), so a hard press loads the lid; the shaft then stays 0.35 mm above the switch body.
- Reset: 2 mm pinhole with a 45° lead-in, and a solid Ø6 mm guide that ends 1 mm above the switch.
- No text, icons or colour marks are modelled. Plan the UV print around the holes in `renders/04-top.png`.

## Drawings

`drawings.tsx` adds three A3 drawing sheets to the package (tscircuit `assembly.drawing.*`), as in
rp2040-bldc-motor-controller: general arrangement (plan, four wall views, isometric, overall sizes), sections
(A-A stop button post, B-B PD OUT 1 opening, C-C two screw columns) and printed parts (each part with its sizes).
Every size on them is measured from the model by tscircuit. In the full package the section views also show the
board and its parts. To export one sheet without building the board (about half a minute):

    tsci export enclosure/drawings.circuit.tsx -f drawing-svg --drawing enclosure_sections -o sections.svg

Sheet names: `enclosure_general_arrangement`, `enclosure_sections`, `enclosure_printed_parts`. After a full build
the same command works on `dist/index/circuit.json`. No exploded view: the drawing export cannot draw one yet.
The header of `drawings.tsx` explains how view directions and section planes are turned in these views.

## Not checked yet

Modelled only, not printed. Unverified: printed hole sizes (insert bores, pinhole, cap socket), cable-head fit,
insert retention, light-pipe brightness through 11 mm of rod, and loaded temperature inside the closed box.