aj0070/bldc-driver

A 3‑phase BLDC motor controller PCB featuring an STM32G431 MCU, DRV8323 gate driver, six N‑MOSFET power stage, shunt current sensing, 3.3‑V regulator, protection, headers, and status LED.

Version
1.0.0
License
unset
Stars
0

Use with the tscircuit CLI

tsci is the tscircuit CLI. Install it with npm install -g tscircuit.

tsci clone aj0070/bldc-driver  # download the package files into ./bldc-driver
tsci add aj0070/bldc-driver    # add it to your project as @tsci/aj0070.bldc-driver

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.

index.circuit.tsx

PCBPCB preview for index.circuit.tsx
SchematicSchematic preview for index.circuit.tsx
import React from "react"
import { DRV8323HRTAR } from "./imports/DRV8323HRTAR"
import { HKTG48N10 } from "./imports/HKTG48N10"
import { OKI_78SR_3_3_1_5_W36H_C } from "./imports/OKI_78SR_3_3_1_5_W36H_C"
import { STM32G431CBT6 } from "./imports/STM32G431CBT6"
import { WJ500V_5_08_03P_14_00A } from "./imports/WJ500V_5_08_03P_14_00A"
import { KT_0603R } from "./imports/KT_0603R"

interface NfetProps {
  name: string
  gate: string
  drain: string
  source: string
  pcbX: number
  pcbY: number
  schX: number
  schY: number
  schSheetName?: string
  schSectionName?: string
}

const Nfet = ({
  name,
  gate,
  drain,
  source,
  pcbX,
  pcbY,
  schX,
  schY,
  schSheetName,
  schSectionName,
}: NfetProps) => (
  <HKTG48N10
    name={name}
    pcbX={pcbX}
    pcbY={pcbY}
    schX={schX}
    schY={schY}
    schSheetName={schSheetName}
    schSectionName={schSectionName}
    pinAttributes={{
      G: { isInput: true },
      D1: { requiresPower: true },
      D2: { requiresPower: true },
      D3: { requiresPower: true },
      D4: { requiresPower: true },
      D5: { requiresPower: true },
      S1: { providesPower: true },
      S2: { providesPower: true },
      S3: { providesPower: true },
    }}
    connections={{
      G: gate,
      D1: drain,
      D2: drain,
      D3: drain,
      D4: drain,
      D5: drain,
      S1: source,
      S2: source,
      S3: source,
    }}
  />
)

export default () => (
  <board
    width="60mm"
    height="45mm"
    layers={4}
    routeRemaining={true}
    defaultTraceWidth="0.2mm"
    minTraceWidth="0.15mm"
  >
    <net name="VM" isPowerNet nominalTraceWidth="1.5mm" />
    <net name="GND" isGroundNet nominalTraceWidth="1.0mm" />
    <net name="V3_3" isPowerNet nominalTraceWidth="0.5mm" />
    <net name="PHASE_A" nominalTraceWidth="1.2mm" />
    <net name="PHASE_B" nominalTraceWidth="1.2mm" />
    <net name="PHASE_C" nominalTraceWidth="1.2mm" />
    <net name="SHUNT_A_TOP" nominalTraceWidth="1.0mm" />
    <net name="SHUNT_B_TOP" nominalTraceWidth="1.0mm" />
    <net name="SHUNT_C_TOP" nominalTraceWidth="1.0mm" />
    <net name="GA_H" />
    <net name="GA_L" />
    <net name="GB_H" />
    <net name="GB_L" />
    <net name="GC_H" />
    <net name="GC_L" />
    <net name="INHA" />
    <net name="INLA" />
    <net name="INHB" />
    <net name="INLB" />
    <net name="INHC" />
    <net name="INLC" />
    <net name="nFAULT" />
    <net name="DRV_EN" />
    <net name="DRV_CAL" />
    <net name="DRV_MODE" />
    <net name="DRV_IDRIVE" />
    <net name="DRV_VDS" />
    <net name="DRV_GAIN" />
    <net name="CPL" />
    <net name="CPH" />
    <net name="VCP" />
    <net name="DVDD" />
    <net name="SPA_F" />
    <net name="SNA_F" />
    <net name="SPB_F" />
    <net name="SNB_F" />
    <net name="SPC_F" />
    <net name="SNC_F" />
    <net name="SOA" />
    <net name="SOB" />
    <net name="SOC" />
    <net name="HALL_A" />
    <net name="HALL_B" />
    <net name="HALL_C" />
    <net name="XIN" />
    <net name="XOUT" />
    <net name="NRST" />
    <net name="SWDIO" />
    <net name="SWCLK" />
    <net name="BOOT0" />
    <net name="VM_SENSE" />
    <net name="LED_N" />
    <net name="LED_A" />

    <schematicsheet name="PWR" displayName="Power input and 3.3V" sheetIndex={0} />
    <schematicsheet name="DRV" displayName="Gate driver and power stage" sheetIndex={1} />
    <schematicsheet name="MCU" displayName="MCU and clock" sheetIndex={2} />
    <schematicsheet name="IO" displayName="Headers, hall sensors, LED" sheetIndex={3} />

    <schematicsection name="PWR_IN" displayName="Input protection" />
    <schematicsection name="PWR_3V3" displayName="3.3V regulator" />
    <schematicsection name="DRV_CFG" displayName="Gate driver settings" />
    <schematicsection name="FETS" displayName="Three-phase power stage" />
    <schematicsection name="CSENSE" displayName="Low-side current sense" />
    <schematicsection name="MCU_CORE" displayName="MCU and decoupling" />
    <schematicsection name="CLOCK" displayName="8 MHz crystal" />
    <schematicsection name="CFG" displayName="Reset, boot, bus sense" />
    <schematicsection name="STATUS" displayName="Status LED" />
    <schematicsection name="HALL" displayName="Hall sensor header" />
    <schematicsection name="SWD" displayName="SWD header" />

    {/* ---------------- power input ---------------- */}
    <connector
      name="J1"
      footprint="pinrow2_nosquareplating_p5.08mm_od2mm_id1.3mm"
      pinLabels={{ pin1: "VM", pin2: "GND" }}
      schPinArrangement={{ topSide: ["VM"], bottomSide: ["GND"] }}
      pcbX={-25}
      pcbY={14}
      pcbRotation={90}
      schX={1}
      schY={16}
      schSheetName="PWR"
      schSectionName="PWR_IN"
      connections={{ pin1: "net.VM", pin2: "net.GND" }}
    >
      <footprint insertionDirection="from_above" />
    </connector>
    <diode
      name="D1"
      schRotation={90}
      variant="tvs"
      footprint="smb"
      pcbX={-15.5}
      pcbY={20}
      schX={5}
      schY={16}
      schSheetName="PWR"
      schSectionName="PWR_IN"
      connections={{ anode: "net.GND", cathode: "net.VM" }}
    />
    <capacitor
      name="C1"
      schRotation={270}
      capacitance="220uF"
      maxVoltageRating="35V"
      polarized
      footprint="electrolytic_d8mm_p3.5mm"
      pcbX={-15.3}
      pcbY={6}
      schX={9}
      schY={16}
      schSheetName="PWR"
      schSectionName="PWR_IN"
      connections={{ pin1: "net.VM", pin2: "net.GND" }}
    />
    <capacitor
      name="C2"
      schRotation={270}
      capacitance="10uF"
      maxVoltageRating="50V"
      footprint="1210"
      pcbX={-9}
      pcbY={20}
      schX={10.5}
      schY={16}
      schSheetName="PWR"
      schSectionName="PWR_IN"
      connections={{ pin1: "net.VM", pin2: "net.GND" }}
    />
    <capacitor
      name="C3"
      schRotation={270}
      capacitance="100nF"
      maxVoltageRating="50V"
      footprint="0603"
      pcbX={-5}
      pcbY={20}
      schX={12}
      schY={16}
      schSheetName="PWR"
      schSectionName="PWR_IN"
      connections={{ pin1: "net.VM", pin2: "net.GND" }}
    />

    {/* ---------------- 3.3V regulator ---------------- */}
    <OKI_78SR_3_3_1_5_W36H_C
      name="U3"
      pcbX={-21}
      pcbY={-3}
      pcbRotation={90}
      schX={2}
      schY={8}
      schSheetName="PWR"
      schSectionName="PWR_3V3"
      pinAttributes={{
        Positive_Input: { requiresPower: true },
        Common__Ground: { requiresGround: true },
        Positive_Output: { providesPower: true },
      }}
      connections={{
        Positive_Input: "net.VM",
        Common__Ground: "net.GND",
        Positive_Output: "net.V3_3",
      }}
    />
    <capacitor
      name="C4"
      schRotation={270}
      capacitance="10uF"
      maxVoltageRating="16V"
      footprint="0805"
      pcbX={-16}
      pcbY={0}
      schX={6}
      schY={8}
      schSheetName="PWR"
      schSectionName="PWR_3V3"
      connections={{ pin1: "net.V3_3", pin2: "net.GND" }}
    />
    <capacitor
      name="C5"
      schRotation={270}
      capacitance="100nF"
      maxVoltageRating="16V"
      footprint="0603"
      pcbX={-12.5}
      pcbY={0}
      schX={7.3}
      schY={8}
      schSheetName="PWR"
      schSectionName="PWR_3V3"
      connections={{ pin1: "net.V3_3", pin2: "net.GND" }}
    />

    {/* ---------------- gate driver ---------------- */}
    <DRV8323HRTAR
      name="U2"
      pcbX={0}
      pcbY={8}
      schX={5}
      schY={13}
      schSheetName="DRV"
      schSectionName="DRV_CFG"
      pinAttributes={{
        VM: { requiresPower: true },
        VDRAIN: { requiresPower: true },
        AGND: { requiresGround: true },
        PGND: { requiresGround: true },
        EP: { requiresGround: true },
      }}
      connections={{
        CPL: "net.CPL",
        CPH: "net.CPH",
        VCP: "net.VCP",
        VM: "net.VM",
        VDRAIN: "net.VM",
        GHA: "net.GA_H",
        SHA: "net.PHASE_A",
        GLA: "net.GA_L",
        SPA: "net.SPA_F",
        SNA: "net.SNA_F",
        SPB: "net.SPB_F",
        SNB: "net.SNB_F",
        GLB: "net.GB_L",
        SHB: "net.PHASE_B",
        GHB: "net.GB_H",
        GHC: "net.GC_H",
        SHC: "net.PHASE_C",
        GLC: "net.GC_L",
        SPC: "net.SPC_F",
        SNC: "net.SNC_F",
        SOC: "net.SOC",
        SOB: "net.SOB",
        SOA: "net.SOA",
        VREF: "net.V3_3",
        nFAULT: "net.nFAULT",
        MODE: "net.DRV_MODE",
        IDRIVE: "net.DRV_IDRIVE",
        VDS: "net.DRV_VDS",
        GAIN: "net.DRV_GAIN",
        ENABLE: "net.DRV_EN",
        CAL: "net.DRV_CAL",
        AGND: "net.GND",
        DVDD: "net.DVDD",
        INHA: "net.INHA",
        INLA: "net.INLA",
        INHB: "net.INHB",
        INLB: "net.INLB",
        INHC: "net.INHC",
        INLC: "net.INLC",
        PGND: "net.GND",
        EP: "net.GND",
      }}
    />
    <capacitor
      name="C6"
      capacitance="1uF"
      maxVoltageRating="16V"
      footprint="0603"
      pcbX={-2}
      pcbY={13}
      schX={1}
      schY={17}
      schSheetName="DRV"
      schSectionName="DRV_CFG"
      connections={{ pin1: "net.CPL", pin2: "net.CPH" }}
    />
    <capacitor
      name="C7"
      schRotation={270}
      capacitance="1uF"
      maxVoltageRating="50V"
      footprint="0805"
      pcbX={2}
      pcbY={13}
      schX={1}
      schY={13}
      schSheetName="DRV"
      schSectionName="DRV_CFG"
      connections={{ pin1: "net.VCP", pin2: "net.VM" }}
    />
    <capacitor
      name="C8"
      schRotation={270}
      capacitance="1uF"
      maxVoltageRating="16V"
      footprint="0603"
      pcbX={-5.5}
      pcbY={11}
      schX={1}
      schY={9}
      schSheetName="DRV"
      schSectionName="DRV_CFG"
      connections={{ pin1: "net.DVDD", pin2: "net.GND" }}
    />
    <capacitor
      name="C9"
      schRotation={270}
      capacitance="10uF"
      maxVoltageRating="50V"
      footprint="1210"
      pcbX={3.5}
      pcbY={20.5}
      schX={9}
      schY={16.6}
      schSheetName="DRV"
      schSectionName="DRV_CFG"
      connections={{ pin1: "net.VM", pin2: "net.GND" }}
    />
    <capacitor
      name="C10"
      schRotation={270}
      capacitance="100nF"
      maxVoltageRating="50V"
      footprint="0603"
      pcbRotation={180}
      pcbX={7.5}
      pcbY={20.5}
      schX={9}
      schY={15.2}
      schSheetName="DRV"
      schSectionName="DRV_CFG"
      connections={{ pin1: "net.VM", pin2: "net.GND" }}
    />
    <capacitor
      name="C11"
      schRotation={270}
      capacitance="100nF"
      maxVoltageRating="16V"
      footprint="0402"
      pcbX={5}
      pcbY={13}
      schX={9}
      schY={13}
      schSheetName="DRV"
      schSectionName="DRV_CFG"
      connections={{ pin1: "net.V3_3", pin2: "net.GND" }}
    />
    <resistor
      name="R1"
      schRotation={270}
      resistance="0"
      footprint="0402"
      pcbX={-9}
      pcbY={4.5}
      schX={2}
      schY={4}
      schSheetName="DRV"
      schSectionName="DRV_CFG"
      connections={{ pin1: "net.DRV_MODE", pin2: "net.GND" }}
    />
    <resistor
      name="R2"
      schRotation={270}
      resistance="47k"
      footprint="0402"
      pcbX={-9}
      pcbY={6}
      schX={4}
      schY={4}
      schSheetName="DRV"
      schSectionName="DRV_CFG"
      connections={{ pin1: "net.DRV_IDRIVE", pin2: "net.GND" }}
    />
    <resistor
      name="R3"
      schRotation={270}
      resistance="47k"
      footprint="0402"
      pcbX={-9}
      pcbY={7.5}
      schX={6}
      schY={4}
      schSheetName="DRV"
      schSectionName="DRV_CFG"
      connections={{ pin1: "net.DRV_VDS", pin2: "net.GND" }}
    />
    <resistor
      name="R4"
      schRotation={270}
      resistance="10k"
      footprint="0402"
      pcbX={-9}
      pcbY={9}
      schX={8}
      schY={4}
      schSheetName="DRV"
      schSectionName="DRV_CFG"
      connections={{ pin1: "net.DRV_GAIN", pin2: "net.GND" }}
    />
    <resistor
      name="R5"
      schRotation={270}
      resistance="10k"
      footprint="0402"
      pcbX={-6.5}
      pcbY={4.5}
      schX={10}
      schY={4}
      schSheetName="DRV"
      schSectionName="DRV_CFG"
      connections={{ pin1: "net.DRV_CAL", pin2: "net.GND" }}
    />
    <resistor
      name="R6"
      schRotation={270}
      resistance="100k"
      footprint="0402"
      pcbX={-6.5}
      pcbY={6}
      schX={12}
      schY={4}
      schSheetName="DRV"
      schSectionName="DRV_CFG"
      connections={{ pin1: "net.DRV_EN", pin2: "net.GND" }}
    />
    <resistor
      name="R7"
      schRotation={90}
      resistance="10k"
      footprint="0402"
      pcbRotation={180}
      pcbX={-6.5}
      pcbY={7.5}
      schX={14}
      schY={4}
      schSheetName="DRV"
      schSectionName="DRV_CFG"
      connections={{ pin1: "net.nFAULT", pin2: "net.V3_3" }}
    />

    {/* ---------------- power stage ---------------- */}
    <Nfet
      name="Q1"
      gate="net.GA_H"
      drain="net.VM"
      source="net.PHASE_A"
      pcbX={10}
      pcbY={15}
      schX={18}
      schY={16}
      schSheetName="DRV"
      schSectionName="FETS"
    />
    <Nfet
      name="Q2"
      gate="net.GB_H"
      drain="net.VM"
      source="net.PHASE_B"
      pcbX={17.5}
      pcbY={15}
      schX={22}
      schY={16}
      schSheetName="DRV"
      schSectionName="FETS"
    />
    <Nfet
      name="Q3"
      gate="net.GC_H"
      drain="net.VM"
      source="net.PHASE_C"
      pcbX={25}
      pcbY={15}
      schX={26}
      schY={16}
      schSheetName="DRV"
      schSectionName="FETS"
    />
    <Nfet
      name="Q4"
      gate="net.GA_L"
      drain="net.PHASE_A"
      source="net.SHUNT_A_TOP"
      pcbX={10}
      pcbY={5}
      schX={18}
      schY={11}
      schSheetName="DRV"
      schSectionName="FETS"
    />
    <Nfet
      name="Q5"
      gate="net.GB_L"
      drain="net.PHASE_B"
      source="net.SHUNT_B_TOP"
      pcbX={17.5}
      pcbY={5}
      schX={22}
      schY={11}
      schSheetName="DRV"
      schSectionName="FETS"
    />
    <Nfet
      name="Q6"
      gate="net.GC_L"
      drain="net.PHASE_C"
      source="net.SHUNT_C_TOP"
      pcbX={25}
      pcbY={5}
      schX={26}
      schY={11}
      schSheetName="DRV"
      schSectionName="FETS"
    />

    {/* ---------------- low-side shunts and filters ---------------- */}
    <resistor
      name="R8"
      schRotation={270}
      resistance="1m"
      footprint="2512"
      pcbX={10}
      pcbY={-3}
      pcbRotation={90}
      schX={18}
      schY={6}
      schSheetName="DRV"
      schSectionName="CSENSE"
      connections={{ pin1: "net.SHUNT_A_TOP", pin2: "net.GND" }}
    />
    <resistor
      name="R9"
      schRotation={270}
      resistance="1m"
      footprint="2512"
      pcbX={17.5}
      pcbY={-3}
      pcbRotation={90}
      schX={22}
      schY={6}
      schSheetName="DRV"
      schSectionName="CSENSE"
      connections={{ pin1: "net.SHUNT_B_TOP", pin2: "net.GND" }}
    />
    <resistor
      name="R10"
      schRotation={270}
      resistance="1m"
      footprint="2512"
      pcbX={25}
      pcbY={-3}
      pcbRotation={90}
      schX={26}
      schY={6}
      schSheetName="DRV"
      schSectionName="CSENSE"
      connections={{ pin1: "net.SHUNT_C_TOP", pin2: "net.GND" }}
    />
    <resistor
      name="R11"
      resistance="10"
      footprint="0402"
      schRotation={270}
      pcbX={8.5}
      pcbY={-9}
      schX={16}
      schY={3}
      schSheetName="DRV"
      schSectionName="CSENSE"
      connections={{ pin1: "net.SHUNT_A_TOP", pin2: "net.SPA_F" }}
    />
    <resistor
      name="R12"
      schRotation={90}
      resistance="10"
      footprint="0402"
      pcbRotation={180}
      pcbX={11.5}
      pcbY={-9}
      schX={18}
      schY={3}
      schSheetName="DRV"
      schSectionName="CSENSE"
      connections={{ pin1: "net.GND", pin2: "net.SNA_F" }}
    />
    <resistor
      name="R13"
      resistance="10"
      footprint="0402"
      schRotation={270}
      pcbX={16}
      pcbY={-9}
      schX={21}
      schY={3}
      schSheetName="DRV"
      schSectionName="CSENSE"
      connections={{ pin1: "net.SHUNT_B_TOP", pin2: "net.SPB_F" }}
    />
    <resistor
      name="R14"
      schRotation={90}
      resistance="10"
      footprint="0402"
      pcbX={19}
      pcbY={-9}
      schX={23}
      schY={3}
      schSheetName="DRV"
      schSectionName="CSENSE"
      connections={{ pin1: "net.GND", pin2: "net.SNB_F" }}
    />
    <resistor
      name="R15"
      resistance="10"
      footprint="0402"
      schRotation={270}
      pcbX={23.5}
      pcbY={-9}
      schX={26}
      schY={3}
      schSheetName="DRV"
      schSectionName="CSENSE"
      connections={{ pin1: "net.SHUNT_C_TOP", pin2: "net.SPC_F" }}
    />
    <resistor
      name="R16"
      schRotation={90}
      resistance="10"
      footprint="0402"
      pcbX={26.5}
      pcbY={-9}
      schX={28}
      schY={3}
      schSheetName="DRV"
      schSectionName="CSENSE"
      connections={{ pin1: "net.GND", pin2: "net.SNC_F" }}
    />
    <capacitor
      name="C12"
      schOrientation="vertical"
      capacitance="100nF"
      footprint="0603"
      pcbX={10}
      pcbY={-11}
      schX={17}
      schY={1}
      schSheetName="DRV"
      schSectionName="CSENSE"
      connections={{ pin1: "net.SPA_F", pin2: "net.SNA_F" }}
    />
    <capacitor
      name="C13"
      schOrientation="vertical"
      capacitance="100nF"
      footprint="0603"
      pcbX={17.5}
      pcbY={-11}
      schX={22}
      schY={1}
      schSheetName="DRV"
      schSectionName="CSENSE"
      connections={{ pin1: "net.SPB_F", pin2: "net.SNB_F" }}
    />
    <capacitor
      name="C14"
      schOrientation="vertical"
      capacitance="100nF"
      footprint="0603"
      pcbX={25}
      pcbY={-11}
      schX={27}
      schY={1}
      schSheetName="DRV"
      schSectionName="CSENSE"
      connections={{ pin1: "net.SPC_F", pin2: "net.SNC_F" }}
    />

    {/* ---------------- MCU ---------------- */}
    <STM32G431CBT6
      name="U1"
      footprint="lqfp48_w7_h7_p0.5mm"
      pcbX={-8}
      pcbY={-6}
      schX={10}
      schY={10}
      schSheetName="MCU"
      schSectionName="MCU_CORE"
      noConnect={[
        "PC14_OSC32_IN",
        "PC15_OSC32_OUT",
        "PB2",
        "PA7",
        "PB10",
        "PB11",
        "PA11",
        "PA12",
        "PA15",
        "PB3",
        "PB4",
        "PB5",
        "PB6",
        "PB7",
        "PB9",
      ]}
      connections={{
        VBAT: "net.V3_3",
        PC13: "net.LED_N",
        PF0_OSC_IN: "net.XIN",
        PF1_OSC_OUT: "net.XOUT",
        PG10_NRST: "net.NRST",
        PA0: "net.HALL_A",
        PA1: "net.HALL_B",
        PA2: "net.HALL_C",
        PA3: "net.VM_SENSE",
        PA4: "net.SOA",
        PA5: "net.SOB",
        PA6: "net.SOC",
        PB0: "net.DRV_EN",
        PB1: "net.DRV_CAL",
        VSSA: "net.GND",
        VREF_POS: "net.V3_3",
        VDDA: "net.V3_3",
        VSS1: "net.GND",
        VDD1: "net.V3_3",
        PB12: "net.nFAULT",
        PB13: "net.INLA",
        PB14: "net.INLB",
        PB15: "net.INLC",
        PA8: "net.INHA",
        PA9: "net.INHB",
        PA10: "net.INHC",
        VSS2: "net.GND",
        VDD2: "net.V3_3",
        PA13: "net.SWDIO",
        PA14: "net.SWCLK",
        PB8_BOOT0: "net.BOOT0",
        VSS3: "net.GND",
        VDD3: "net.V3_3",
      }}
    />
    <crystal
      name="Y1"
      frequency="8MHz"
      loadCapacitance="12pF"
      pinVariant="four_pin"
      footprint="crystal4_px3.2mm_py2.5mm"
      pcbRotation={180}
      pcbX={-16.5}
      pcbY={-7}
      schX={3}
      schY={8}
      schSheetName="MCU"
      schSectionName="CLOCK"
      connections={{ pin1: "net.XIN", pin3: "net.XOUT", pin2: "net.GND", pin4: "net.GND" }}
    />
    <capacitor
      name="C15"
      schRotation={270}
      capacitance="18pF"
      footprint="0402"
      pcbRotation={180}
      pcbX={-15.5}
      pcbY={-2.5}
      schX={1}
      schY={5}
      schSheetName="MCU"
      schSectionName="CLOCK"
      connections={{ pin1: "net.XIN", pin2: "net.GND" }}
    />
    <capacitor
      name="C16"
      schRotation={270}
      capacitance="18pF"
      footprint="0402"
      pcbRotation={180}
      pcbX={-21}
      pcbY={-8.5}
      schX={5}
      schY={5}
      schSheetName="MCU"
      schSectionName="CLOCK"
      connections={{ pin1: "net.XOUT", pin2: "net.GND" }}
    />
    <capacitor
      name="C17"
      schRotation={270}
      capacitance="100nF"
      footprint="0402"
      pcbX={-8}
      pcbY={2}
      schX={4}
      schY={15}
      schSheetName="MCU"
      schSectionName="MCU_CORE"
      connections={{ pin1: "net.V3_3", pin2: "net.GND" }}
    />
    <capacitor
      name="C18"
      schRotation={270}
      capacitance="100nF"
      footprint="0402"
      pcbX={-6}
      pcbY={2}
      schX={5.5}
      schY={15}
      schSheetName="MCU"
      schSectionName="MCU_CORE"
      connections={{ pin1: "net.V3_3", pin2: "net.GND" }}
    />
    <capacitor
      name="C19"
      schRotation={270}
      capacitance="100nF"
      footprint="0402"
      pcbX={-4}
      pcbY={2}
      schX={7}
      schY={15}
      schSheetName="MCU"
      schSectionName="MCU_CORE"
      connections={{ pin1: "net.V3_3", pin2: "net.GND" }}
    />
    <capacitor
      name="C20"
      schRotation={270}
      capacitance="100nF"
      footprint="0402"
      pcbRotation={180}
      pcbX={-2}
      pcbY={2}
      schX={8.5}
      schY={15}
      schSheetName="MCU"
      schSectionName="MCU_CORE"
      connections={{ pin1: "net.V3_3", pin2: "net.GND" }}
    />
    <capacitor
      name="C21"
      schRotation={270}
      capacitance="1uF"
      footprint="0603"
      pcbX={0.8}
      pcbY={2}
      schX={10}
      schY={15}
      schSheetName="MCU"
      schSectionName="MCU_CORE"
      connections={{ pin1: "net.V3_3", pin2: "net.GND" }}
    />
    <capacitor
      name="C22"
      schRotation={270}
      capacitance="100nF"
      footprint="0402"
      pcbRotation={180}
      pcbX={3.5}
      pcbY={2}
      schX={11.5}
      schY={15}
      schSheetName="MCU"
      schSectionName="MCU_CORE"
      connections={{ pin1: "net.V3_3", pin2: "net.GND" }}
    />

    {/* ---------------- reset, boot, bus sense, LED ---------------- */}
    <resistor
      name="R17"
      schRotation={90}
      resistance="10k"
      footprint="0402"
      pcbX={-20}
      pcbY={-16}
      schX={8}
      schY={4}
      schSheetName="MCU"
      schSectionName="CFG"
      connections={{ pin1: "net.NRST", pin2: "net.V3_3" }}
    />
    <capacitor
      name="C23"
      schRotation={270}
      capacitance="100nF"
      footprint="0402"
      pcbX={-22}
      pcbY={-15}
      schX={10}
      schY={4}
      schSheetName="MCU"
      schSectionName="CFG"
      connections={{ pin1: "net.NRST", pin2: "net.GND" }}
    />
    <resistor
      name="R18"
      schRotation={270}
      resistance="10k"
      footprint="0402"
      pcbRotation={180}
      pcbX={-17}
      pcbY={-14.5}
      schX={18}
      schY={8}
      schSheetName="MCU"
      schSectionName="CFG"
      connections={{ pin1: "net.BOOT0", pin2: "net.GND" }}
    />
    <resistor
      name="R19"
      resistance="100k"
      footprint="0402"
      pcbX={0}
      pcbY={-3}
      schX={20}
      schY={12}
      schSheetName="MCU"
      schSectionName="CFG"
      connections={{ pin1: "net.VM", pin2: "net.VM_SENSE" }}
    />
    <resistor
      name="R20"
      schRotation={270}
      resistance="10k"
      footprint="0402"
      pcbX={0}
      pcbY={-5.5}
      schX={22}
      schY={10}
      schSheetName="MCU"
      schSectionName="CFG"
      connections={{ pin1: "net.VM_SENSE", pin2: "net.GND" }}
    />
    <capacitor
      name="C24"
      schRotation={270}
      capacitance="100nF"
      footprint="0402"
      pcbX={2}
      pcbY={-5.5}
      schX={20}
      schY={8}
      schSheetName="MCU"
      schSectionName="CFG"
      connections={{ pin1: "net.VM_SENSE", pin2: "net.GND" }}
    />
    <resistor
      name="R21"
      resistance="1k"
      footprint="0603"
      schRotation={270}
      pcbX={-4}
      pcbY={-13.5}
      schX={23}
      schY={6}
      schSheetName="MCU"
      schSectionName="STATUS"
      connections={{ pin1: "net.LED_N", pin2: "net.LED_A" }}
    />
    <KT_0603R
      name="LED1"
      schRotation={270}
      pcbX={-0.8}
      pcbY={-13.5}
      schX={23}
      schY={4}
      schSheetName="MCU"
      schSectionName="STATUS"
      connections={{ anode: "net.LED_A", cathode: "net.GND" }}
    />

    {/* ---------------- headers ---------------- */}
    <pinheader
      name="J2"
      pinCount={5}
      pitch="2.54mm"
      footprint="pinrow5_p2.54mm"
      showSilkscreenPinLabels={false}
      schWidth={0.77}
      pinLabels={["V3_3", "GND", "HALL_A", "HALL_B", "HALL_C"]}
      pcbX={-8}
      pcbY={-20}
      schX={4}
      schY={14}
      schSheetName="IO"
      schSectionName="HALL"
      connections={{
        V3_3: "net.V3_3",
        GND: "net.GND",
        HALL_A: "net.HALL_A",
        HALL_B: "net.HALL_B",
        HALL_C: "net.HALL_C",
      }}
    />
    <resistor
      name="R22"
      schRotation={90}
      resistance="10k"
      footprint="0402"
      pcbX={-3}
      pcbY={-17}
      schX={2}
      schY={8}
      schSheetName="IO"
      schSectionName="HALL"
      connections={{ pin1: "net.HALL_A", pin2: "net.V3_3" }}
    />
    <resistor
      name="R23"
      schRotation={90}
      resistance="10k"
      footprint="0402"
      pcbX={-1}
      pcbY={-17}
      schX={4}
      schY={8}
      schSheetName="IO"
      schSectionName="HALL"
      connections={{ pin1: "net.HALL_B", pin2: "net.V3_3" }}
    />
    <resistor
      name="R24"
      schRotation={90}
      resistance="10k"
      footprint="0402"
      pcbX={1}
      pcbY={-17}
      schX={6}
      schY={8}
      schSheetName="IO"
      schSectionName="HALL"
      connections={{ pin1: "net.HALL_C", pin2: "net.V3_3" }}
    />
    <pinheader
      name="J3"
      pinCount={5}
      pitch="2.54mm"
      footprint="pinrow5_p2.54mm"
      showSilkscreenPinLabels={false}
      schWidth={0.675}
      pinLabels={["V3_3", "SWDIO", "SWCLK", "GND", "NRST"]}
      pcbX={-25}
      pcbY={-4}
      pcbRotation={90}
      schX={12}
      schY={14}
      schSheetName="IO"
      schSectionName="SWD"
      connections={{
        V3_3: "net.V3_3",
        SWDIO: "net.SWDIO",
        SWCLK: "net.SWCLK",
        GND: "net.GND",
        NRST: "net.NRST",
      }}
    />
    <WJ500V_5_08_03P_14_00A
      name="J4"
      pcbX={20}
      pcbY={-17.5}
      pcbRotation={0}
      schX={20}
      schY={14}
      schSheetName="IO"
      schSectionName="HALL"
      pinAttributes={{
        pin1: { requiresPower: true },
        pin2: { requiresPower: true },
        pin3: { requiresPower: true },
      }}
      connections={{ pin1: "net.PHASE_A", pin2: "net.PHASE_B", pin3: "net.PHASE_C" }}
    />

    {/* inner-layer planes: GND on inner1, motor bus VM on inner2 */}
    <copperpour connectsTo="net.GND" layer="inner1" clearance="0.2mm" />
    <copperpour connectsTo="net.VM" layer="inner2" clearance="0.2mm" />
  </board>
)