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.

index.circuit.tsx

PCBPCB preview for index.circuit.tsx
SchematicSchematic preview for index.circuit.tsx
import { Fragment } from "react"
import type { BoardProps } from "@tscircuit/props"
import { PdOutputPort } from "./circuit/pd-output-port"
import { Supervisor } from "./circuit/supervisor"
import { PowerInput } from "./circuit/power-input"
import { Safety } from "./circuit/safety"
import { UsbSection } from "./circuit/usb"
import { Processor } from "./circuit/processor"
import { Planes } from "./circuit/planes"
import { PowerCopper } from "./circuit/power-copper"
import { RoutingPlan, HighSpeed } from "./circuit/routing-plan"
import { Sheets, SHEET_COUNT } from "./circuit/sheets"
import { SchematicNotes, SchematicGuide } from "./circuit/schematic-notes"
import { PORT_X, PORT_Y, DATA_Y } from "./circuit/port-positions"
import { fastRouting } from "./circuit/fast-routing"
import { BoardSystemDiagrams } from "./circuit/system-diagram"

/**
 * 4-Port USB-C PD Control Motherboard
 * Allwinner T113-S3 Linux SoC (128 MB DDR3 in package), microSD boot, discrete SoC power.
 * Right edge, one line top to bottom: PD OUT 4, USB 4, PD OUT 3, USB 3, ... USB 1 (port 1 is the lowest).
 * The ports are general USB-C PD outputs and USB 2.0 data ports. Part and net names: PD output N uses the
 * prefix P<N> (connector JOUT<N>), data port N uses USB<N> (connector JUSB<N>).
 * Left edge (inputs): PD_INPUT, PC_DATA, microSD. Top edge: USB_CAMERA, external stop connector.
 * Bottom edge: no connectors; status LEDs, reset button and the on-board stop button.
 * 4 copper layers (top signal / GND / power / bottom signal), every component on TOP.
 * Engineering prototype: not verified for fabrication (see docs/).
 */
export default function Motherboard(props: Partial<BoardProps> = {}) {
  return (
    <board
      title="4-Port USB-C PD Control Motherboard"
      schLayout={{ layoutMode: "relative" }}
      width={90} height={98} layers={4} thickness="1.6mm" borderRadius={2} routeRemaining={false}
      minTraceWidth={0.1} minTraceToPadEdgeClearance={0.1} minViaEdgeToPadEdgeClearance={0.1}
      minViaHoleDiameter="0.3mm" minViaPadDiameter="0.45mm"
      // Vias are allowed inside pads: the router uses this only for ground vias inside a chip's centre pad
      // (the CH338F hub's centre pad is its only ground pin and is ringed by its pins: tools/router/fastroute.cpp).
      isViaInPadAllowed
      pcbStyle={{ viaHoleDiameter: "0.3mm", viaPadDiameter: "0.45mm" }}
      {...props}
    >
      <Sheets />
      {/* schematic drawings only: the connection guide (sheet 1) and the titles, section labels and notes on each sheet */}
      <SchematicGuide total={SHEET_COUNT} />
      <SchematicNotes />
      <RoutingPlan hiW={0.5} medW={0.3} />
      <HighSpeed />
      <autoroutingphase name="ALL" phaseIndex={1} algorithmFn={fastRouting("ALL")} />
      <Planes />
      <PowerCopper />
      <PowerInput />
      <Safety />
      {/* Ports are numbered bottom-up (circuit/port-positions.ts). Each supervisor's first PD channel is the
          upper of its two ports: A = ports 4, 3 (converter addresses 0x74, 0x75), B = ports 2, 1 (0x74, 0x75). */}
      <Supervisor id="A" ports={[4, 3]} x={-38} y={2} />
      {/* moved 2026-11-28 (0.45 mm via migration): under the lowest power stage, next to the ports it controls */}
      <Supervisor id="B" ports={[2, 1]} x={10} y={-40.8} />
      <PdOutputPort i={1} x={PORT_X} y={PORT_Y[1]} addr={0x75} />
      <PdOutputPort i={2} x={PORT_X} y={PORT_Y[2]} addr={0x74} />
      <PdOutputPort i={3} x={PORT_X} y={PORT_Y[3]} addr={0x75} />
      <PdOutputPort i={4} x={PORT_X} y={PORT_Y[4]} addr={0x74} />
      <Processor />
      <UsbSection />
      {[[-41.5, 46.0], [41.5, 46.0], [-41.5, -46.0], [41.5, -46.0]].map(([x, y], k) => (
        <Fragment key={k}><hole name={`H${k + 1}`} diameter={3.2} pcbX={x} pcbY={y} /></Fragment>
      ))}
      <silkscreentext text="PD IN" pcbX={-33.2} pcbY={39.0} fontSize={1} />
      <silkscreentext text="PC" pcbX={-33.2} pcbY={27.5} fontSize={1} />
      <silkscreentext text="CAM" pcbX={-5.95} pcbY={39.6} fontSize={1} />
      {[1, 2, 3, 4].map((i) => (
        <Fragment key={i}><silkscreentext text={`PD OUT ${i}`} pcbX={31.0} pcbY={PORT_Y[i] + 4.6} fontSize={0.8} /></Fragment>
      ))}
      {[1, 2, 3, 4].map((i) => (
        <Fragment key={i}><silkscreentext text={`USB ${i}`} pcbX={31.0} pcbY={DATA_Y[i] + 4.0} fontSize={0.8} /></Fragment>
      ))}
      <silkscreentext text="E-STOP" pcbX={1.0} pcbY={47.7} fontSize={0.8} />
      {/* System diagrams (documentation only, no nets): how it works, an example system, the stop chain.
          Each block links to its real parts on this board. */}
      {/* SCH_ONLY=1 (tools/build-schematic.ts): a schematic-only render has no PCB parts for the diagrams to link to */}
      {!process.env.SCH_ONLY && <BoardSystemDiagrams linkToPcb />}
    </board>
  )
}