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/system-diagram.tsx

import { systemblock } from "tscircuit"

/**
 * System diagrams (tscircuit systemblock pages), as in rp2040-bldc-motor-controller.
 * Documentation only: these elements create no nets. With linkToPcb, blocks point at the real PCB parts.
 * Rendered to docs/system-diagram/*.png by tools/render-system-diagram.tsx.
 */
export function BoardSystemDiagrams({ linkToPcb = false } = {}) {
  const refs = (...names: string[]) => (linkToPcb ? { pcbComponentNames: names } : {})
  const ports = (prefix: string, ...suffixes: string[]) => [1, 2, 3, 4].flatMap((i) => suffixes.map((s) => `${prefix}${i}${s}`))
  return <>
    <systemblock.page name="how_it_works" displayName="USB-C PD port hub: how it works" direction="down"
      description="One USB-C charger powers everything (the hub asks for 20 V: 60 W with a normal 3 A cable). On the right edge, four USB-C power ports (PD OUT, 5 to 20 V) alternate with four USB data ports (USB). A Linux computer inside talks to the devices over USB. Orange: power; blue: data and control.">
      <systemblock.component name="charger" displayName="USB-C PD charger" description="External · a normal 60 W (20 V × 3 A) charger and cable" />
      <systemblock.component name="pc" displayName="Computer" description="External · setup, logs, firmware" />
      <systemblock.component name="camera" displayName="USB camera" description="External · 5 V, up to 1 A" />
      <systemblock.component name="devices" displayName="Your devices" description="External · power from PD OUT 1–4, data from USB 1–4; a device can use one or both" />
      <systemblock.component name="extStop" displayName="Wired stop button (optional)" description="External · normally-closed, on STOP IN (remove the RSTOPEXT link)" />
      <systemblock.group name="hub" displayName="Hub board · 90 × 98 mm, in the printed enclosure">
        <systemblock.component name="pdIn" displayName="PD IN · power input" description="CH224Q asks the charger for 20 V; TPS16630 eFuse and TVS protect the board" {...refs("JPD", "UPDIN", "UIN", "DIN_TVS", "QINKILL")} />
        <systemblock.component name="rails" displayName="5 V and 3.3 V supplies" description="TPS54560 5 V; always-on 3.3 V; small converters for the Linux chip" {...refs("U5V", "UAON", "UB33", "UBCORE", "UBDRAM", "U1V8")} />
        <systemblock.component name="linux" displayName="Linux computer" description="Allwinner T113-S3 with 128 MB, boots from microSD" {...refs("UMPU", "JSD", "YHSE", "URST")} />
        <systemblock.component name="usbHub" displayName="USB hub" description="CH338F: one link from Linux to USB 1–4 and CAM" {...refs("UHUB", "YHUB")} />
        <systemblock.component name="dataPorts" displayName="USB 1–4 and CAM" description="Data plus a switched 5 V (0.5 A; CAM 1 A) on each port, turned on by Linux; ESD protection" {...refs("JUSB1", "JUSB2", "JUSB3", "JUSB4", "JCAM", ...ports("UUSB", "PWR", "ESD"), "UCAMPWR", "UCAMESD")} />
        <systemblock.component name="supervisors" displayName="Power supervisors A and B" description="Two STM32G0 chips; each runs USB-PD for two outputs and sets their voltage and current limit; A also measures the input current" {...refs("USUPA", "USUPB")} />
        <systemblock.component name="outputs" displayName="PD OUT 1–4 · power outputs" description="TPS55288 buck-boost (5–20 V), eFuse (about 3.5 A trip) and USB-C PD on each port" {...refs("JOUT1", "JOUT2", "JOUT3", "JOUT4", ...ports("UP", "BB", "EF", "CC", "AND"))} />
        <systemblock.component name="safety" displayName="Safety interlock" description="Stop button, Linux watchdog and input power-good must all be OK, then Linux arms the outputs" {...refs("SWSTOP", "JESTOP", "UKILL", "ULATCH", "UWDT")} />
        <systemblock.component name="pcPort" displayName="PC port" description="USB-C to the Linux chip's USB OTG" {...refs("JPC", "UPCESD")} />
      </systemblock.group>
      <systemblock.connection from="charger" to="pdIn" label="USB-C PD, 20 V" kind="power" />
      <systemblock.connection from="pdIn" to="rails" label="VIN_SYS" kind="power" />
      <systemblock.connection from="pdIn" to="outputs" label="VIN_SYS" kind="power" />
      <systemblock.connection from="rails" to="linux" label="3.3 / 1.8 / 1.5 / 0.95 V" kind="power" />
      <systemblock.connection from="linux" to="usbHub" label="USB 2.0" direction="both" />
      <systemblock.connection from="usbHub" to="dataPorts" label="5 × USB 2.0" direction="both" />
      <systemblock.connection from="linux" to="dataPorts" label="5 V on / off, one line per port" />
      <systemblock.connection from="dataPorts" to="devices" label="USB 1–4 · data + 5 V" direction="both" />
      <systemblock.connection from="dataPorts" to="camera" label="CAM · video" direction="both" />
      <systemblock.connection from="pc" to="pcPort" label="USB-C" direction="both" />
      <systemblock.connection from="pcPort" to="linux" label="USB OTG" direction="both" />
      <systemblock.connection from="linux" to="supervisors" label="I2C · port requests and status" direction="both" />
      <systemblock.connection from="supervisors" to="outputs" label="Voltage, current limit, PD contract" />
      <systemblock.connection from="outputs" to="devices" label="PD OUT 1–4 · 5–20 V" kind="power" />
      <systemblock.connection from="extStop" to="safety" label="STOP IN" />
      <systemblock.connection from="linux" to="safety" label="Watchdog kick, ARM" />
      <systemblock.connection from="safety" to="outputs" label="All outputs off" color="#d92d20" />
    </systemblock.page>

    <systemblock.page name="example_system" displayName="Example system: a motor test bench" direction="right"
      description="One use of the hub. PD OUT 1 + USB 1: a motor controller (MustafaMulla29/rp2040-bldc-motor-controller) at 15 V. USB 2: a thrust sensor (data only, powered by the port's 5 V). PD OUT 2: a 12 V LED light and PD OUT 3: a phone at 9 V (power only). All PD OUT ports share the charger's 60 W. Charger, laptop, camera, light, phone, sensor and motor are examples.">
      <systemblock.component name="charger" displayName="60 W USB-C PD charger" description="20 V × 3 A, normal USB-C cable" />
      <systemblock.component name="laptop" displayName="Laptop" description="Setup and monitoring, on PC" />
      <systemblock.component name="camera" displayName="USB camera" description="Records the test; CAM gives it 5 V" />
      <systemblock.component name="hub" displayName="USB-C PD port hub" description="Linux computer, 4 PD OUT + 4 USB ports, stop button" />
      <systemblock.group name="bench" displayName="Motor test bench">
        <systemblock.component name="ctrl" displayName="Motor controller" description="Your rp2040 BLDC board, using its PWR and DATA ports" />
        <systemblock.component name="motor" displayName="BLDC motor + propeller" description="2212 motor on a thrust stand" />
        <systemblock.component name="sensor" displayName="Thrust sensor" description="Load cell + microcontroller board" />
        <systemblock.component name="light" displayName="LED light" description="12 V, lights the stand" />
      </systemblock.group>
      <systemblock.component name="phone" displayName="Phone" description="Charges at 9 V" />
      <systemblock.connection from="charger" to="hub" label="PD IN · 20 V" kind="power" />
      <systemblock.connection from="laptop" to="hub" label="PC" direction="both" />
      <systemblock.connection from="hub" to="camera" label="CAM · 5 V + video" direction="both" />
      <systemblock.connection from="hub" to="ctrl" label="PD OUT 1 · 15 V" kind="power" />
      <systemblock.connection from="hub" to="ctrl" label="USB 1" direction="both" />
      <systemblock.connection from="hub" to="sensor" label="USB 2 · data + 5 V" direction="both" />
      <systemblock.connection from="hub" to="light" label="PD OUT 2 · 12 V" kind="power" />
      <systemblock.connection from="hub" to="phone" label="PD OUT 3 · 9 V" kind="power" />
      <systemblock.connection from="ctrl" to="motor" label="U / V / W" kind="power" />
      <systemblock.connection from="motor" to="sensor" label="Thrust (load cell)" />
    </systemblock.page>

    <systemblock.page name="stop_chain" displayName="How the stop button cuts power" direction="right"
      description="Hardware only, no software in the path: if the stop loop opens, the Linux watchdog times out or the input power is bad, the latch clears and all four PD OUT ports switch off. USB 1–4, CAM and Linux stay powered. Power returns only when everything is OK again and Linux sends a fresh ARM pulse.">
      <systemblock.component name="button" displayName="Stop button on the lid" description="Push on / push off; opens the stop loop" {...refs("SWSTOP")} />
      <systemblock.component name="wired" displayName="STOP IN (optional)" description="Wired normally-closed button in the same loop; remove the RSTOPEXT link to use it" {...refs("JESTOP", "RSTOPEXT")} />
      <systemblock.component name="watchdog" displayName="Linux watchdog" description="TPS3823: Linux must kick it every 1.6 s" {...refs("UWDT")} />
      <systemblock.component name="inputOk" displayName="Input power good" description="From the input eFuse" {...refs("UIN")} />
      <systemblock.component name="and" displayName="All OK? (3-input AND)" description="KILL_N" {...refs("UKILL")} />
      <systemblock.component name="latch" displayName="Enable latch" description="Cleared at once by a stop; set only by an ARM pulse from Linux" {...refs("ULATCH")} />
      <systemblock.component name="linux" displayName="Linux computer" description="Sends ARM when it is safe to run" {...refs("UMPU")} />
      <systemblock.component name="efuses" displayName="PD OUT 1–4 eFuses" description="Each output also needs its supervisor's OK" {...refs("UP1EF", "UP2EF", "UP3EF", "UP4EF", "UP1AND", "UP2AND", "UP3AND", "UP4AND")} />
      <systemblock.component name="light" displayName="OUT ON light" description="Lit while outputs are allowed" {...refs("LEDHWEN")} />
      <systemblock.connection from="button" to="and" label="Stop loop" color="#d92d20" />
      <systemblock.connection from="wired" to="and" label="Stop loop" color="#d92d20" lineStyle="dashed" />
      <systemblock.connection from="watchdog" to="and" label="Watchdog OK" />
      <systemblock.connection from="inputOk" to="and" label="Power good" />
      <systemblock.connection from="and" to="latch" label="KILL_N clears" color="#d92d20" />
      <systemblock.connection from="linux" to="latch" label="ARM pulse" />
      <systemblock.connection from="latch" to="efuses" label="PORT_HW_EN" />
      <systemblock.connection from="latch" to="light" label="Status" />
    </systemblock.page>
  </>
}