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.

tools/netcopper.ts

// Per-net copper summary: bun tools/netcopper.ts NETREGEX  (CJ env = circuit json)
import { readFileSync } from "node:fs"
import { getFullConnectivityMapFromCircuitJson } from "circuit-json-to-connectivity-map"
const cj=JSON.parse(readFileSync(process.env.CJ ?? "dist/index/circuit.json","utf8")); const cm=getFullConnectivityMapFromCircuitJson(cj)
const nk=new Map<string,string>(); for(const n of cj.filter((e:any)=>e.type==="source_net")){const k=cm.getNetConnectedToId(n.source_net_id); if(k&&!nk.has(k))nk.set(k,n.name)}
const name=(t:any)=>{for(const id of [t.pcb_trace_id,t.source_trace_id]){const k=id&&cm.getNetConnectedToId(id); if(k)return nk.get(k)??k}}
const re=new RegExp(process.argv[2])
for(const t of cj.filter((e:any)=>e.type==="pcb_trace")){const n=name(t); if(!n||!re.test(n))continue
 const r=t.route; const segs:string[]=[]
 for(let i=0;i+1<r.length;i++){const a=r[i],b=r[i+1]; if(a.route_type!=="wire"||b.route_type!=="wire"||a.layer!==b.layer)continue
  const L=Math.hypot(b.x-a.x,b.y-a.y); if(L<0.05)continue; segs.push(`${a.layer[0]}${a.layer.slice(-1)} w${b.width??a.width} ${L.toFixed(1)}mm (${a.x.toFixed(1)},${a.y.toFixed(1)})->(${b.x.toFixed(1)},${b.y.toFixed(1)})`)}
 const vias=r.filter((p:any)=>p.route_type==="via").length
 console.log(n,t.pcb_trace_id,"vias",vias); for(const s of segs)console.log("   ",s)}