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.
tools/plane-connectivity.ts
/**
* Pad-to-pour connectivity per plane net, the way tsci's checker sees it: a pad with no trace counts as
* connected only if EVERY pad of its net ends up in one copper component (pours + traces + vias).
* Prints pads outside the main component and isolated pours. bun tools/plane-connectivity.ts [nets]
* (Uses an internal of @tscircuit/checks, re-exported from a temporary copy of its bundle.)
*/
import { readFileSync, writeFileSync, rmSync } from "node:fs"
import { getFullConnectivityMapFromCircuitJson } from "circuit-json-to-connectivity-map"
const dir = "node_modules/@tscircuit/checks/dist", tmp = `${dir}/_plane_conn.js`
const src = readFileSync(`${dir}/index.js`, "utf8").replace(" return {\n getIsolatedPours() {",
" return {\n __rootsByPort: rootsByPort, __portsByNet: portsByNet,\n getIsolatedPours() {")
writeFileSync(tmp, src + "\nexport { getCopperPourConnectivity as __gcpc }\n")
const { __gcpc } = await import(`${process.cwd()}/${tmp}`); rmSync(tmp)
const cj = JSON.parse(readFileSync(process.env.CJ ?? "dist/index/circuit.json", "utf8")), cm = getFullConnectivityMapFromCircuitJson(cj)
const pc = __gcpc(cj, cm)
const sp = new Map(cj.filter((e: any) => e.type === "source_port").map((p: any) => [p.source_port_id, p]))
const sc = new Map(cj.filter((e: any) => e.type === "source_component").map((c: any) => [c.source_component_id, c.name]))
const pp = new Map(cj.filter((e: any) => e.type === "pcb_port").map((p: any) => [p.pcb_port_id, p]))
for (const name of (process.argv[2] ?? "GND,VIN_SYS,V5V0").split(",")) {
const n = cj.find((e: any) => e.type === "source_net" && e.name === name), net = cm.getNetConnectedToId(n.source_net_id)
const ports: string[] = pc.__portsByNet.get(net) ?? [], count = new Map<number, number>()
for (const p of ports) for (const r of pc.__rootsByPort.get(p) ?? []) count.set(r, (count.get(r) ?? 0) + 1)
const main = [...count].sort((a, b) => b[1] - a[1])[0]
const out = ports.filter((p) => !pc.__rootsByPort.get(p)?.has(main?.[0]))
console.log(`${name}: ${ports.length} pads, ${out.length} outside the main copper component`)
for (const id of out) { const p: any = pp.get(id), s: any = sp.get(p.source_port_id); console.log(` ${sc.get(s?.source_component_id) ?? "(via)"}.${s?.name} (${p.x.toFixed(2)}, ${p.y.toFixed(2)})`) }
}
console.log(`isolated pours: ${pc.getIsolatedPours().length}`)