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.

circuit/schematic-notes.tsx

import { Fragment } from "react"
import notes from "../data/schematic-notes.json"

type Note = { text: string; x: number; y: number; fontSize: number; anchor: string }
/**
 * Titles, section labels and reference notes on every schematic sheet (drawing only, no nets).
 * The wording is in data/schematic-notes-content.json; tools/sch-notes.py works out where each text goes
 * from the built schematic and writes data/schematic-notes.json, which this file draws.
 */
export const SchematicNotes = () => (
  <>
    {Object.entries(notes as Record<string, Note[]>).map(([sheet, items]) => (
      <Fragment key={sheet}>
        {/* pcbX / pcbY: a group with no board position makes the board re-pack its parts (it moved 169 of them) */}
        <group name={`NOTES_${sheet}`} schSheetName={sheet} schLayout={{ layoutMode: "relative" }} pcbX={0} pcbY={0}>
          {items.map((t, i) => (
            <Fragment key={i}><schematictext text={t.text} schX={t.x} schY={t.y} fontSize={t.fontSize} anchor={t.anchor as any} color={t.fontSize >= 0.4 ? "#202020" : t.fontSize >= 0.3 ? "#0b4f8a" : "#444444"} /></Fragment>
          ))}
        </group>
      </Fragment>
    ))}
  </>
)

const BOXES: [number, number, string, string, string][] = [
  [-15.6, 8, "PD IN (JPD)", "USB-C PD charger: 20 V, 60 W", "Power input: sheet 2"],
  [-5.2, 8, "INPUT eFUSE", "TPS16630, 5.45 A limit", "Power input: sheet 2"],
  [5.2, 8, "5 V AND 3.3 V", "TPS54560B 5 V, AP2112K always-on 3.3 V", "Power input: sheet 2"],
  [15.6, 8, "PD OUT 1-4", "TPS55288 5-20 V + eFuse 3.5 A", "Power ports: sheets 6-9"],
  [-15.6, 2, "LINUX COMPUTER", "Allwinner T113-S3, microSD boot", "Sheets 10-12, debug 15"],
  [-5.2, 2, "USB HUB", "CH338F: USB 1-4 and CAM", "Hub 13, ports 14"],
  [5.2, 2, "SUPERVISORS A / B", "STM32G0B1: USB-PD, two ports each", "Sheets 4-5"],
  [15.6, 2, "SAFETY", "Stop button, watchdog, enable latch", "Sheet 3"],
]
const GUIDE_NOTES: [number, string, string][] = [
  [-3.2, "CONNECT", "Charger -> PD IN (left side). Devices -> PD OUT 1-4 (power, 5 to 20 V) and USB 1-4 (data + 5 V) on the right side."],
  [-3.9, "", "Right side from the bottom up: USB 1, PD OUT 1, USB 2, PD OUT 2, USB 3, PD OUT 3, USB 4, PD OUT 4."],
  [-4.6, "", "Camera -> CAM (5 V up to 1 A + USB data). Computer -> PC (the Linux chip as a USB device; FEL when no card is in)."],
  [-5.9, "STOP", "Stop button pressed (or STOP IN open): all four PD OUT ports switch off in hardware. USB, CAM and Linux stay on."],
  [-6.6, "", "Power comes back only after the button is released and Linux re-arms the ports. A Linux crash trips the watchdog the same way."],
  [-7.9, "PROGRAM", "Linux: microSD card. No card: FEL on the PC port. Supervisors: SWD A and SWD B (3-pin: SWCLK, GND, SWDIO)."],
  [-8.6, "", "Console: debug UART (RX, GND, TX), 3.3 V. Linux also switches each USB port's 5 V (PD0-PD4) and resets the hub (PG3)."],
  [-10.0, "", "Matching net labels join sections and sheets. Each sheet names the datasheet circuit it follows."],
  [-10.7, "", "Engineering prototype: not built or tested yet. Layout notes: ROUTING.txt."],
]
/** Sheet 1: what connects to what, and which sheet holds each block (drawing only). */
export const SchematicGuide = ({ total }: { total: number }) => (
  <group name="GUIDE" schSheetName="guide" schLayout={{ layoutMode: "relative" }} pcbX={0} pcbY={0}>
    <schematictext text={`1 / ${total} — Connection guide`} schX={0} schY={12.8} fontSize={0.42} anchor="center" color="#202020" />
    <schematictext text="POWER FLOW" schX={-20} schY={10.8} fontSize={0.4} anchor="left" color="#0b4f8a" />
    <schematictext text="CONTROL" schX={-20} schY={4.8} fontSize={0.4} anchor="left" color="#0b4f8a" />
    {BOXES.map(([x, y, title, what, where]) => (
      <Fragment key={title}>
        <schematicbox schX={x} schY={y} width={9} height={3.6} />
        <schematictext text={title} schX={x} schY={y + 1.1} fontSize={0.35} anchor="center" color="#202020" />
        <schematictext text={what} schX={x} schY={y + 0.2} fontSize={0.26} anchor="center" color="#444444" />
        <schematictext text={where} schX={x} schY={y - 0.6} fontSize={0.26} anchor="center" color="#0b4f8a" />
      </Fragment>
    ))}
    {/* power flow arrows between the top boxes */}
    {[-10.4, 0, 10.4].map((x) => (
      <Fragment key={x}>
        <schematicline x1={x - 0.7} y1={8} x2={x + 0.7} y2={8} strokeWidth={0.05} color="#b05a00" />
        <schematicline x1={x + 0.7} y1={8} x2={x + 0.35} y2={8.25} strokeWidth={0.05} color="#b05a00" />
        <schematicline x1={x + 0.7} y1={8} x2={x + 0.35} y2={7.75} strokeWidth={0.05} color="#b05a00" />
      </Fragment>
    ))}
    {GUIDE_NOTES.map(([y, head, text]) => (
      <Fragment key={y}>
        {head && <schematictext text={head} schX={-20} schY={y} fontSize={0.34} anchor="left" color="#0b4f8a" />}
        <schematictext text={text} schX={-15.5} schY={y} fontSize={0.3} anchor="left" color="#333333" />
      </Fragment>
    ))}
  </group>
)