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-motherboardIn 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/check_fit.py
"""Static fit check: does any board part overlap a printed part when everything is assembled?
tscircuit's own explosion check skips board models that are not closed meshes (the microSD socket, the
eFuse chips, ...). Here every mesh of every board part in board.glb is wrapped in its convex hull (always a
closed solid, and never smaller than the part) and intersected with the exported base, lid and cap.
A hull is conservative: a reported overlap can be a false alarm for a hollow or concave part, so each one
is listed for review. Run after `bun build.tsx`: .venv/bin/python check_fit.py
"""
from pathlib import Path
import json
import manifold3d as mf
import numpy as np
import trimesh
ROOT = Path(__file__).parent
DIST = ROOT / "dist"
# Contact by design (zero-volume touching faces are not reported anyway); real overlaps above this are listed.
MIN_VOLUME = 0.01 # mm^3
# Known, intended overlaps of a convex hull with a printed part: the cap's socket wraps the switch post.
EXPECTED = {("SWSTOP", "stop-cap")}
def manifold_of(mesh):
return mf.Manifold(mf.Mesh(vert_properties=np.asarray(mesh.vertices, dtype=np.float32), tri_verts=np.asarray(mesh.faces, dtype=np.uint32)))
def main():
printed = {name: manifold_of(trimesh.load_mesh(DIST / f"{name}-assembled.stl")) for name in ("base", "lid", "stop-cap")}
scene = trimesh.load(ROOT / "board.glb", force="scene")
# board.glb frame: (X, Y, Z) = (-pcb x, pcb z, pcb y). Enclosure frame: (pcb x, pcb y, pcb z).
to_board = np.array([[-1, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1]], dtype=float)
findings, checked = [], 0
for node in scene.graph.nodes_geometry:
transform, geom_name = scene.graph[node]
geom = scene.geometry[geom_name]
if not isinstance(geom, trimesh.Trimesh) or len(geom.vertices) < 4:
continue
pts = trimesh.transform_points(geom.vertices, to_board @ transform)
part = node.split("_")[0] if node not in scene.graph.nodes else node
try:
hull = mf.Manifold.hull_points(pts.astype(np.float32))
except Exception:
continue
if hull.volume() <= 0:
continue
checked += 1
for pname, solid in printed.items():
v = (hull ^ solid).volume()
if v > MIN_VOLUME:
findings.append({"node": node, "printedPart": pname, "overlapMm3": round(v, 3),
"bounds": [list(np.round(pts.min(0), 2)), list(np.round(pts.max(0), 2))]})
for f in findings:
name = f["node"]
f["expected"] = any(name.startswith(a) and f["printedPart"] == b for a, b in EXPECTED)
unexpected = [f for f in findings if not f["expected"]]
(DIST / "fit-check.json").write_text(json.dumps({"meshesChecked": checked, "findings": findings, "status": "PASS" if not unexpected else "REVIEW"}, indent=2) + "\n")
print(f"{checked} board meshes checked against base, lid and cap")
for f in findings:
print((" expected " if f["expected"] else " OVERLAP ") + f"{f['node']} x {f['printedPart']}: {f['overlapMm3']} mm³ {f['bounds']}")
print("PASS" if not unexpected else "REVIEW: overlaps listed above")
if __name__ == "__main__":
main()