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.
circuit/routing-plan.tsx
import { Fragment } from "react"
import netPhases from "../data/net-phases.json"
import { HUB_PORT_OF } from "./usb"
/**
* Net classes for the router. Widths are routing targets; copper current
* capacity is checked separately in docs/power-budget.md, not implied by DRC.
*/
const pdOutPorts = [1, 2, 3, 4].map((i) => `P${i}`)
const highCurrent = [
"VBUS_IN", "VIN_SYS", "V5V0",
...pdOutPorts.flatMap((p) => [`${p}_VBB_PRE`, `${p}_VBB`, `${p}_VBUS`, `${p}_SW1`, `${p}_SW2`]),
"BUCK5_SW",
]
const mediumCurrent = ["VDDCORE", "VDD_DDR", "VDD", "V3V3", "V3V3_AON", "B33_SW", "BCORE_SW", "BDRAM_SW",
"USB1_VBUS", "USB2_VBUS", "USB3_VBUS", "USB4_VBUS", "CAM_VBUS"]
/**
* USB 2.0 pairs: 0.22 mm lines. The router lays the two lines of a pair 0.35 mm apart centre to centre
* (0.13 mm gap), which JLCPCB's impedance calculator puts at 90 ohm differential on their default 4-layer
* stackup (JLC04161H-7628, 0.2104 mm from the top layer to the inner1 GND plane). 0.1 mm lines, sized for the
* old 6-layer stackup, would be about 104 ohm here.
*/
export const USB_PAIR_WIDTH = 0.22
const usbPairNets = ["USBH", "OTG", "USB1", "USB2", "USB3", "USB4", "CAM"].flatMap((p) => [`${p}_DP`, `${p}_DM`])
/** New nets added after data/net-phases.json was generated (series resistors on the debug connectors). */
const extraNets = ["SUPA_SWCLK_J", "SUPA_SWDIO_J", "SUPB_SWCLK_J", "SUPB_SWDIO_J", "DBG_UART_TX_J", "DBG_UART_RX_J",
"ESTOP_LOOP", "ESTOP_NC", "ESTOP_NO", "HUB_AVDDK", "HUB_DVDDK", "HUB_PDDIS"]
/** Nets of the USB2517I hub that the CH338F does not have (still listed in data/net-phases.json). */
const goneNets = ["HUB_1V8", "HUB_1V8PLL", "HUB_RBIAS", "HUB_STRAP", "HUB_HSIND", "HUB_SUSPIND", "HUB_LEDB3"]
/** One routing phase for the whole board: tools/router/ routes everything in one context (circuit/fast-routing.ts). */
export const ROUTING_PHASES = ["ALL"]
export const RoutingPlan = ({ hiW = 1.0, medW = 0.4 }: { hiW?: number; medW?: number } = {}) => (
<>
{[...Object.keys(netPhases as Record<string, number | null>), ...extraNets].filter((name) => !goneNets.includes(name)).map((name) => (
<Fragment key={name}><net name={name} isGroundNet={name === "GND"}
isPowerNet={highCurrent.includes(name) || mediumCurrent.includes(name)}
nominalTraceWidth={highCurrent.includes(name) ? hiW : mediumCurrent.includes(name) ? medW : usbPairNets.includes(name) ? USB_PAIR_WIDTH : undefined}
routingPhaseIndex={1} /></Fragment>
))}
</>
)
/** USB 2.0 pairs, routed first. <differentialpair> crashes FortyFiveDegreeSimplificationSolver in
* capacity-autorouter@0.0.1156 (reproduced in tests/dp2.circuit.tsx), so each pair is a 2-member
* length-matched bus. */
const pairs: [string, string, string][] = [
["USBH", "UMPU.USB1_DP", "UMPU.USB1_DM"], ["OTG", "UMPU.USB0_DP", "UMPU.USB0_DM"],
...Object.entries(HUB_PORT_OF).map(([name, port]) => [name, `UHUB.DP${port}`, `UHUB.DM${port}`] as [string, string, string]),
]
export const HighSpeed = () => (
<>
{pairs.map(([name, p, m]) => (
<Fragment key={name}><bus name={`PAIR_${name}`} connections={[p, m]} routingPhaseIndex={1} /></Fragment>
))}
</>
)