sang-it/base_board_pin_header

This code defines a PCB layout featuring mounted pin headers, mounting holes, and a Xiao RP2040 socket, including their physical footprints, drilled hole specifications, and interconnecting traces on a green FR4 board.

Version
1.0.0
License
unset
Stars
0

index.circuit.tsx

PCBPCB preview for index.circuit.tsx
SchematicSchematic preview for index.circuit.tsx
const headerHole = (pin: number, pcbX: number, outerDiameter: string) => (
  <platedhole
    name={String(pin)}
    portHints={[String(pin)]}
    shape="circle"
    holeDiameter="1mm"
    outerDiameter={outerDiameter}
    pcbX={pcbX}
    pcbY={0}
  />
);

const twoPinHeaderFootprint = () => (
  <footprint>
    {headerHole(1, -1.27, "1.6mm")}
    {headerHole(2, 1.27, "1.6mm")}
  </footprint>
);

const eightPinHeaderFootprint = () => (
  <footprint>
    {headerHole(1, 8.89, "1.8mm")}
    {headerHole(2, 6.35, "1.8mm")}
    {headerHole(3, 3.81, "1.8mm")}
    {headerHole(4, 1.27, "1.8mm")}
    {headerHole(5, -1.27, "1.8mm")}
    {headerHole(6, -3.81, "1.8mm")}
    {headerHole(7, -6.35, "1.8mm")}
    {headerHole(8, -8.89, "1.8mm")}
  </footprint>
);

const mountingHoles = () => (
  <>
    <hole name="H1" diameter="3.1mm" pcbX={-46} pcbY={31} />
    <hole name="H2" diameter="3.1mm" pcbX={70} pcbY={31} />
    <hole name="H3" diameter="3.1mm" pcbX={70} pcbY={-31} />
    <hole name="H4" diameter="3.1mm" pcbX={-46} pcbY={-31} />
  </>
);

const twoPinFemaleHeaderCadModel = () => ({
  objUrl: "https://modelcdn.tscircuit.com/easyeda_models/download?pn=C49661",
  rotationOffset: { x: 0, y: 0, z: 0 },
  positionOffset: { x: 0, y: 0, z: 0 },
});

const eightPinFemaleHeaderCadModel = () => ({
  objUrl: "https://modelcdn.tscircuit.com/easyeda_models/download?pn=C27439",
  rotationOffset: { x: 0, y: 0, z: 0 },
  positionOffset: { x: 0, y: 0, z: 4.25 },
});

const xiaoSocketHole = (
  pin: number,
  pinHints: readonly string[],
  pcbX: number,
  pcbY: number,
) => (
  <platedhole
    name={String(pin)}
    portHints={[String(pin), ...pinHints]}
    shape="circle"
    holeDiameter="0.889mm"
    outerDiameter="1.524mm"
    pcbX={pcbX}
    pcbY={pcbY}
  />
);

const xiaoPinLabels = {
  pin1: ["D0", "A0", "GPIO26"],
  pin2: ["D1", "A1", "GPIO27"],
  pin3: ["D2", "A2", "GPIO28"],
  pin4: ["D3", "A3", "GPIO29"],
  pin5: ["D4", "SDA", "GPIO6"],
  pin6: ["D5", "SCL", "GPIO7"],
  pin7: ["D6", "UART_TX", "GPIO0"],
  pin8: ["D7", "GPIO1", "UART_RX"],
  pin9: ["D8", "GPIO2", "SPI0_SCK"],
  pin10: ["D9", "GPIO4", "SPI0_MISO"],
  pin11: ["D10", "GPIO3", "SPI0_MOSI"],
  pin12: ["3V3", "V3_3_OUT"],
  pin13: ["GND"],
  pin14: ["VBUS"],
} as const;

const xiaoRp2040Footprint = () => (
  <footprint>
    {xiaoSocketHole(1, xiaoPinLabels.pin1, 7.62, 7.62)}
    {xiaoSocketHole(2, xiaoPinLabels.pin2, 5.08, 7.62)}
    {xiaoSocketHole(3, xiaoPinLabels.pin3, 2.54, 7.62)}
    {xiaoSocketHole(4, xiaoPinLabels.pin4, 0, 7.62)}
    {xiaoSocketHole(5, xiaoPinLabels.pin5, -2.54, 7.62)}
    {xiaoSocketHole(6, xiaoPinLabels.pin6, -5.08, 7.62)}
    {xiaoSocketHole(7, xiaoPinLabels.pin7, -7.62, 7.62)}
    {xiaoSocketHole(8, xiaoPinLabels.pin8, -7.62, -7.62)}
    {xiaoSocketHole(9, xiaoPinLabels.pin9, -5.08, -7.62)}
    {xiaoSocketHole(10, xiaoPinLabels.pin10, -2.54, -7.62)}
    {xiaoSocketHole(11, xiaoPinLabels.pin11, 0, -7.62)}
    {xiaoSocketHole(12, xiaoPinLabels.pin12, 2.54, -7.62)}
    {xiaoSocketHole(13, xiaoPinLabels.pin13, 5.08, -7.62)}
    {xiaoSocketHole(14, xiaoPinLabels.pin14, 7.62, -7.62)}
  </footprint>
);

const cladTestBreakerTraces = () => (
  <>
    {/* J5 is the CLAD's buried fanout to the four corner test breakers. */}
    {/* Monotonic pin order keeps the upper and lower four-wire fans uncrossed. */}
    <trace name="D3_J5_1" from="U1.D3" to="J5.pin1" thickness="0.3mm" />
    <trace name="D2_J5_2" from="U1.D2" to="J5.pin2" thickness="0.3mm" />
    <trace name="D1_J5_3" from="U1.D1" to="J5.pin3" thickness="0.3mm" />
    <trace name="D0_J5_4" from="U1.D0" to="J5.pin4" thickness="0.3mm" />
    <trace name="D10_J5_5" from="U1.D10" to="J5.pin5" thickness="0.3mm" />
    <trace name="D9_J5_6" from="U1.D9" to="J5.pin6" thickness="0.3mm" />
    <trace name="D8_J5_7" from="U1.D8" to="J5.pin7" thickness="0.3mm" />
    <trace name="D7_J5_8" from="U1.D7" to="J5.pin8" thickness="0.3mm" />
  </>
);

const xiaoRp2040Socket = () => (
  <>
    <chip
      name="U1"
      pinLabels={xiaoPinLabels}
      pinAttributes={{
        VBUS: { requiresPower: true },
        GND: { requiresGround: true },
      }}
      footprint={xiaoRp2040Footprint()}
      cadModel={null}
      pcbX={63.5}
      pcbY={0}
    />
    <silkscreenrect
      width="21mm"
      height="17.8mm"
      filled={false}
      stroke="solid"
      strokeWidth="0.2mm"
      pcbX={63.5}
      pcbY={0}
    />
    <silkscreentext
      text="USB"
      fontSize="0.7mm"
      pcbX={72.7}
      pcbY={0}
      pcbRotation={90}
    />
  </>
);

export default () => (
  <board
    width="124mm"
    height="70mm"
    outlineOffsetX={12}
    thickness="1.6mm"
    layers={2}
    material="fr4"
    solderMaskColor="green"
    silkscreenColor="white"
  >
    {mountingHoles()}
    <pinheader
      name="J1"
      pinCount={2}
      gender="female"
      pitch="2.54mm"
      footprint={twoPinHeaderFootprint()}
      manufacturerPartNumber="2.54-1*2PFemale"
      supplierPartNumbers={{ lcsc: ["C49661"], jlcpcb: ["C49661"] }}
      cadModel={twoPinFemaleHeaderCadModel()}
      pcbX={-42.5}
      pcbY={27.5}
      pcbRotation={45}
    />
    <pinheader
      name="J2"
      pinCount={2}
      gender="female"
      pitch="2.54mm"
      footprint={twoPinHeaderFootprint()}
      manufacturerPartNumber="2.54-1*2PFemale"
      supplierPartNumbers={{ lcsc: ["C49661"], jlcpcb: ["C49661"] }}
      cadModel={twoPinFemaleHeaderCadModel()}
      pcbX={42.5}
      pcbY={27.5}
      pcbRotation={135}
    />
    <pinheader
      name="J3"
      pinCount={2}
      gender="female"
      pitch="2.54mm"
      footprint={twoPinHeaderFootprint()}
      manufacturerPartNumber="2.54-1*2PFemale"
      supplierPartNumbers={{ lcsc: ["C49661"], jlcpcb: ["C49661"] }}
      cadModel={twoPinFemaleHeaderCadModel()}
      pcbX={42.5}
      pcbY={-27.5}
      pcbRotation={45}
    />
    <pinheader
      name="J4"
      pinCount={2}
      gender="female"
      pitch="2.54mm"
      footprint={twoPinHeaderFootprint()}
      manufacturerPartNumber="2.54-1*2PFemale"
      supplierPartNumbers={{ lcsc: ["C49661"], jlcpcb: ["C49661"] }}
      cadModel={twoPinFemaleHeaderCadModel()}
      pcbX={-42.5}
      pcbY={-27.5}
      pcbRotation={135}
    />
    <pinheader
      name="J5"
      pinCount={8}
      gender="female"
      pitch="2.54mm"
      footprint={eightPinHeaderFootprint()}
      manufacturerPartNumber="2.54-1*8P"
      supplierPartNumbers={{ lcsc: ["C27438"], jlcpcb: ["C27438"] }}
      cadModel={eightPinFemaleHeaderCadModel()}
      pcbX={47.5}
      pcbY={0}
      pcbRotation={90}
    />
    {xiaoRp2040Socket()}
    {cladTestBreakerTraces()}
  </board>
);