diff --git a/docs/tutorials/pi-hats/usb-power-delivery-trigger-hat.mdx b/docs/tutorials/pi-hats/usb-power-delivery-trigger-hat.mdx new file mode 100644 index 00000000..a0e970c8 --- /dev/null +++ b/docs/tutorials/pi-hats/usb-power-delivery-trigger-hat.mdx @@ -0,0 +1,170 @@ +--- +title: Building a USB Power Delivery Trigger HAT +description: Build a Raspberry Pi HAT that negotiates USB-C Power Delivery voltages and exposes a protected, filtered terminal-block output. +--- + +import CircuitPreview from "@site/src/components/CircuitPreview" + +## Overview + +This tutorial designs a USB-C Power Delivery trigger HAT. The board uses a USB-C receptacle and a PD trigger controller such as the CH224K, FP28XX, or PD2001 to request a fixed voltage from a USB-C charger. The negotiated rail is filtered and exposed on a terminal block for external loads. + +Use this HAT when a project needs a convenient 9 V, 12 V, 15 V, or 20 V rail from a USB-C charger. **Do not connect the negotiated high-voltage rail directly to Raspberry Pi 5 V pins.** The terminal block output is for external loads or a separate regulator stage. + +## Requirements + +- USB-C receptacle with VBUS, GND, CC1, and CC2 connected to the PD controller. +- USB PD trigger/controller such as CH224K, FP28XX, or PD2001. +- Voltage-selection pins or resistors for 5 V, 9 V, 12 V, 15 V, or 20 V negotiation. +- Terminal block output for the negotiated rail. +- Status LED with current-limiting resistor. +- Input and output filtering capacitors. +- Wide VBUS/output copper and clear voltage silkscreen. + +## Voltage negotiation plan + +PD trigger chips differ in their exact pin names, but the design pattern is the same: + +| Target output | Controller config example | Use case | +| --- | --- | --- | +| 5 V | default/no high-voltage request | logic rails and low-power loads | +| 9 V | select pin mode for 9 V | small motors, LEDs, regulators | +| 12 V | select pin mode for 12 V | fans, relays, buck regulators | +| 15 V | select pin mode for 15 V | higher-power regulators | +| 20 V | select pin mode for 20 V | only when the downstream circuit is rated for it | + +Always check the datasheet for your exact controller. The schematic below labels the selection pins generically as `CFG1` and `CFG2` so you can map them to the exact resistor strap table for CH224K, FP28XX, or PD2001. + +## Step 1: Add the HAT board + +```tsx +import { RaspberryPiHatBoard } from "@tscircuit/common" + +export default () => ( + + {/* USB PD trigger circuit goes here */} + +) +``` + +## Step 2: Add USB-C and PD controller parts + +```tsx + + +``` + +## Step 3: Add configuration, status, and output filtering + +```tsx + + + + + + + +``` + +## Schematic and 3D preview + + ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +) +`} /> + +## Bill of materials + +| Ref | Part | Notes | +| --- | --- | --- | +| J1 | USB-C receptacle | Must expose VBUS, GND, CC1, CC2 | +| U1 | CH224K / FP28XX / PD2001 | USB PD trigger/controller | +| R1/R2 | Configuration resistors | Match values to the controller datasheet voltage table | +| J2 | 2-pin terminal block | Negotiated output and ground | +| LED1/RLED | Green LED + 2.2 kΩ resistor | Output-present indicator | +| CIN | 10 µF capacitor | Input VBUS filtering | +| COUT | 47 µF capacitor | Output bulk filtering | + +## Example voltage-selection code/comments + +Most fixed-voltage trigger chips do not need firmware; they use resistor straps or mode pins. If you are documenting the board in code, keep the selected voltage explicit: + +```ts +const pdTriggerConfig = { + controller: "CH224K", + requestedVoltage: "12V", + warning: "PD_OUT is not connected to Raspberry Pi 5V pins", +} +``` + +If your design uses a microcontroller-controlled PD sink instead of a fixed trigger chip, initialize the controller for the same voltage before enabling the downstream load: + +```cpp +// Pseudocode: use the library for your actual PD sink controller. +pd.begin(); +pd.requestFixedVoltage(12); // request 12 V PDO +if (pd.contractReady()) { + enableLoadSwitch(); +} +``` + +## PCB layout guidance + +- Route `VBUS` and `PD_OUT` with wide traces or pours sized for the expected current. +- Keep CC1 and CC2 short and away from noisy switching nodes. +- Place `CIN` close to the PD controller VBUS pin and `COUT` close to the terminal block/load path. +- Put the selected voltage on silkscreen next to the terminal block. +- Keep the high-voltage terminal output physically separated from Raspberry Pi GPIO pins. +- Add mounting holes or strain relief if the terminal block will drive moving wires. + +## Bring-up and testing procedure + +1. Before plugging in USB-C, check continuity: no short from `VBUS`/`PD_OUT` to ground. +2. Plug into a current-limited USB-C PD source if available. +3. Measure `PD_OUT` with no load and confirm it matches the selected voltage. +4. Confirm the status LED turns on only when output is present. +5. Test first with a dummy load sized for the selected voltage. +6. Only connect project hardware after confirming voltage, polarity, and current draw. + +## Safety notes + +- A 20 V PD output can destroy 5 V electronics instantly. Label the selected voltage clearly. +- Use capacitors with voltage ratings above the requested PD voltage. +- Do not backfeed the Raspberry Pi through GPIO, 5 V, or USB ports from `PD_OUT` unless you add a proper regulator and power-path design.