From 8e2a29ab72ce4bfef0efb29c7854e4b055b34b3b Mon Sep 17 00:00:00 2001 From: silasbrookshaha Date: Fri, 3 Jul 2026 19:48:07 +0800 Subject: [PATCH 1/2] Add USB PD trigger HAT circuit --- .../pi-hat-usb-pd-trigger.circuit.tsx | 194 ++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 codetestingplayground/pi-hat-usb-pd-trigger.circuit.tsx diff --git a/codetestingplayground/pi-hat-usb-pd-trigger.circuit.tsx b/codetestingplayground/pi-hat-usb-pd-trigger.circuit.tsx new file mode 100644 index 00000000..b96bd787 --- /dev/null +++ b/codetestingplayground/pi-hat-usb-pd-trigger.circuit.tsx @@ -0,0 +1,194 @@ +import { RaspberryPiHatBoard } from "@tscircuit/common" + +export default () => ( + + {/* USB-C receptacle for the PD-capable charger input */} + + + {/* CH224K USB-PD sink controller selects a fixed PDO from the charger */} + + + {/* Three-position configuration header for 5V, 9V, 12V, 15V, or 20V PDO selection */} + + + {/* Protected output terminals for the negotiated rail */} + + + {/* Optional Pi-side logic header: enable input, power-good output, and ground */} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +) From dceeef04b5e3b11241cdcdce7876fa1541f8ae9d Mon Sep 17 00:00:00 2001 From: silasbrookshaha Date: Fri, 3 Jul 2026 19:48:58 +0800 Subject: [PATCH 2/2] Add USB PD trigger HAT tutorial --- docs/tutorials/pi-hats/usb-pd-trigger-hat.mdx | 378 ++++++++++++++++++ 1 file changed, 378 insertions(+) create mode 100644 docs/tutorials/pi-hats/usb-pd-trigger-hat.mdx diff --git a/docs/tutorials/pi-hats/usb-pd-trigger-hat.mdx b/docs/tutorials/pi-hats/usb-pd-trigger-hat.mdx new file mode 100644 index 00000000..46bc080d --- /dev/null +++ b/docs/tutorials/pi-hats/usb-pd-trigger-hat.mdx @@ -0,0 +1,378 @@ +--- +title: Building a USB Power Delivery Trigger HAT +description: >- + Build a Raspberry Pi HAT that negotiates fixed USB Power Delivery voltages + from 5V to 20V and exposes the selected rail on screw terminals. +--- + +## Overview + +This tutorial builds a Raspberry Pi HAT that acts as a USB Power Delivery sink. +It uses a CH224K-style trigger controller to request a fixed PDO from a USB-C +charger, then routes the negotiated 5V, 9V, 12V, 15V, or 20V rail to an output +terminal block. The HAT also includes status indication, input and output +filtering, and an optional GPIO header for enable and power-good monitoring. + +import CircuitPreview from "@site/src/components/CircuitPreview" +import TscircuitIframe from "@site/src/components/TscircuitIframe" + + ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +) +`} /> + +## Circuit Requirements + +The HAT should provide: + +- A USB-C receptacle connected to a PD sink controller +- Fixed-voltage negotiation for 5V, 9V, 12V, 15V, and 20V charger profiles +- A terminal block for the negotiated output voltage and ground +- Input and output capacitors close to the power path +- A power-good LED so the requested voltage can be checked at a glance +- Optional Raspberry Pi GPIO access to enable the trigger and read `PGOOD` + +## How the Trigger Works + +The CH224K is a small USB Power Delivery sink controller. It connects to the +USB-C connector's CC pins, advertises itself as a sink, and asks the charger for +one of the fixed Power Data Objects. The selected output voltage appears on the +same VBUS rail after the PD negotiation succeeds. + +The three configuration pins, represented by `CFG1`, `CFG2`, and `CFG3`, are +pulled down by default and brought to a header. You can populate solder bridges, +a DIP switch, or jumpers to encode the voltage option used by your controller +variant. Always confirm the exact truth table in the controller datasheet before +assembling hardware. + +## Building the Circuit Step by Step + +### Step 1: Start with the HAT board + +```tsx +import { RaspberryPiHatBoard } from "@tscircuit/common" + +export default () => ( + + {/* Components go here */} + +) +``` + +### Step 2: Add the USB-C input and PD controller + +The USB-C connector exposes VBUS, GND, CC1, and CC2. The controller monitors the +CC pins and negotiates the requested output voltage. + + ( + + + + + + + + +) +`} /> + +### Step 3: Add the voltage selector + +The voltage selector is modeled as a six-pin header. Three pins connect to the +controller configuration inputs, while the other side exposes rails that can be +used for jumpers or solder bridges. + +```tsx + +``` + +### Step 4: Add filtering and output terminals + +The input capacitor stabilizes VBUS near the connector and controller. The +output bulk capacitor sits near the terminal block and helps absorb load steps +when the downstream device turns on. + +```tsx + + + + + +``` + +### Step 5: Add status and Raspberry Pi monitoring + +`PGOOD` drives the status LED through `R5`. The optional `J3` header lets the Pi +pull `EN` low or read whether negotiation completed before enabling a load. + +```tsx + + + +``` + +## Voltage Selection Table + +Use the controller datasheet as the source of truth for the final jumper map. +This table is a practical layout worksheet for the HAT: + +| Target output | Typical use | Layout note | +| --- | --- | --- | +| 5V | Pi accessories, logic boards | Safest first power-up setting | +| 9V | Small motors, routers, LED drivers | Check downstream regulator rating | +| 12V | Fans, relays, light strips | Use wider copper for higher current | +| 15V | Audio boards, lab modules | Confirm capacitors are rated above 15V | +| 20V | USB-C laptop adapters, buck inputs | Use 25V or higher rated capacitors | + +## Bill of Materials + +| Ref | Part | Notes | +| --- | --- | --- | +| J1 | USB-C receptacle | Choose a footprint matching your assembly process | +| U1 | CH224K USB-PD sink controller | FP6601Q/FP28xx or PD2001 can be adapted | +| JP1 | 3-bit voltage select header | Replace with solder jumpers or a DIP switch if preferred | +| J2 | 2-pin terminal block | Rated for the maximum current you expect | +| J3 | 3-pin logic header | Optional Pi-side `EN`, `PGOOD`, and `GND` | +| C1 | 10uF, 25V or higher | VBUS input bulk capacitor | +| C2, C4 | 100nF | Local decoupling capacitors | +| C3 | 47uF, 25V or higher | Output bulk capacitor | +| R1-R3 | 100k | Default pulldowns for voltage select pins | +| R4 | 10k | Enable pullup | +| R5 | 2.2k | LED current limiting resistor | +| D1 | Green LED | Power-good indicator | + +## Example Pi Monitor + +The PD trigger works without software, but the Pi can monitor `PGOOD` before it +turns on a downstream load. + +```python +from gpiozero import DigitalInputDevice, DigitalOutputDevice +from time import sleep + +pd_enable = DigitalOutputDevice(23, active_high=True, initial_value=True) +pd_good = DigitalInputDevice(24, pull_up=False) + +while not pd_good.value: + print("Waiting for USB-PD negotiation...") + sleep(0.1) + +print("Requested USB-PD voltage is ready") +``` + +## Bring-Up and Test Procedure + +1. Leave the HAT disconnected from the Raspberry Pi and set the selector to 5V. +2. Connect a current-limited USB-C PD charger and verify that the status LED + turns on. +3. Measure `J2` with a multimeter and confirm the expected voltage and polarity. +4. Move through the 9V, 12V, 15V, and 20V settings with no load attached. +5. Add a small dummy load, then re-check voltage droop and component temperature. +6. Only connect a Raspberry Pi or downstream device after the selected voltage is + known to be safe for that load. + +## Safety Notes + +USB-PD can expose 20V on a connector that physically resembles a 5V USB port. +Clearly label the terminal block, use capacitors with enough voltage headroom, +and do not connect the negotiated rail directly to the Raspberry Pi 5V header +unless the selected profile is 5V and the power path has been reviewed.