psargaco-creator/lunara-no-battery

A 5V hold-up power board using a Schottky-isolated 1F supercapacitor, 3.3V regulator, ESP32 power-fail sensing, and MOSFET-switched LED output.

Version
0.0.1
License
unset
Stars
0

Use with the tscircuit CLI

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

tsci clone psargaco-creator/lunara-no-battery  # download the package files into ./lunara-no-battery
tsci add psargaco-creator/lunara-no-battery    # add it to your project as @tsci/psargaco-creator.lunara-no-battery

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.tsx

PCBPCB preview for index.tsx
SchematicSchematic preview for index.tsx
const devKitLeftPins = Array.from(
  { length: 15 },
  (_, index) => ({
    pin: index + 1,
    y: 17.78 - index * 2.54,
  }),
)

const devKitRightPins = Array.from(
  { length: 15 },
  (_, index) => ({
    pin: index + 16,
    y: 17.78 - index * 2.54,
  }),
)

const DevKit30PinFootprint = () => (
  <footprint>
    {devKitLeftPins.map(({ pin, y }) => (
      <platedhole
        key={`left-${pin}`}
        portHints={[`pin${pin}`]}
        pcbX="-12.7mm"
        pcbY={`${y}mm`}
        outerDiameter="1.8mm"
        holeDiameter="1mm"
        shape="circle"
      />
    ))}

    {devKitRightPins.map(({ pin, y }) => (
      <platedhole
        key={`right-${pin}`}
        portHints={[`pin${pin}`]}
        pcbX="12.7mm"
        pcbY={`${y}mm`}
        outerDiameter="1.8mm"
        holeDiameter="1mm"
        shape="circle"
      />
    ))}

    <silkscreenpath
      route={[
        { x: -14, y: -25.5 },
        { x: 14, y: -25.5 },
        { x: 14, y: 25.5 },
        { x: -14, y: 25.5 },
        { x: -14, y: -25.5 },
      ]}
    />

    <silkscreentext
      text="ESP32 DEVKIT V1"
      pcbX={0}
      pcbY={0}
      fontSize="1mm"
      anchorAlignment="center"
    />

    <silkscreentext
      text="ANTENNA"
      pcbX={0}
      pcbY={22}
      fontSize="0.8mm"
      anchorAlignment="center"
    />

    <silkscreentext
      text="USB"
      pcbX={0}
      pcbY={-22}
      fontSize="0.8mm"
      anchorAlignment="center"
    />
  </footprint>
)

import { SmdUsbC } from "@tsci/imrishabh18.usb-c"

export default () => (
  <board
    width="110mm"
    height="80mm"
    layers={2}
    minTraceWidth={0.2}
    nominalTraceWidth={0.3}
    minViaPadDiameter={0.7}
    minViaHoleDiameter={0.3}
    pcbStyle={{
      viaPadDiameter: 0.7,
      viaHoleDiameter: 0.3,
    }}
  >
    <schematicsheet
      name="Main"
      displayName="LUNARA Controller"
      sheetIndex={0}
    >
      {/* =====================================================
          NETS
          ===================================================== */}

      <net name="V5_RAW" isPowerNet />
      <net name="V5_HOLD" isPowerNet />
      <net name="SUPERCAP_POS" isPowerNet />
      <net name="DEVKIT_VIN" isPowerNet />
      <net name="DEVKIT_3V3" isPowerNet />

      <net name="POWER_SENSE_NODE" />

      <net name="I2C_SDA" />
      <net name="I2C_SCL" />

      <net name="LED_DATA_3V3" />
      <net name="LED_DATA_5V" />

      <net name="GND" isGroundNet />

      {/* =====================================================
          USB-C 5 V POWER INPUT
          ===================================================== */}

      <SmdUsbC
        name="USB1"
        pcbY={0}
        pcbX={-50}
        pcbRotation={270}
        schX={-22}
        schY={10}        
      />

{/* 

<connector
name="J1"
footprint="pinrow2_p2.54"
pinLabels={{
pin1: "V5_RAW",
pin2: "GND",
}}
pcbX={-51}
pcbY={0}
/>

<trace
  name="INPUT_5V"
  from="net.V5_RAW"
  to=".J1 > .V5_RAW"
/>

<trace
  name="INPUT_GND"
  from="net.GND"
  to=".J1 > .GND"
/>

--------------------- */}

{/* --------------------- */}
      
      {/*
        Resettable input fuse.

        3 A holding-current value is a functional placeholder.
        Choose the physical fuse according to the real power supply.
      */}

      <resistor
        name="F1"
        resistance="0.05"
        footprint="1206"
        pcbX={-42}
        pcbY={0}
        schX={-15}
        schY={10}
      />

      <capacitor
        name="C1"
        capacitance="10uF"
        footprint="0805"
        pcbX={-38}
        pcbY={4}
        schX={-12}
        schY={7}
      />

      <capacitor
        name="C2"
        capacitance="100nF"
        footprint="0603"
        pcbX={-38}
        pcbY={-4}
        schX={-12}
        schY={4}
      />

      {/* =====================================================
          HOLD-UP SUPPLY
          ===================================================== */}

      {/*
        D1 isolates the external raw 5 V input from the hold-up rail.
      */}

      <diode
        name="D1"
        manufacturerPartNumber="SS14"
        footprint="sod123"
        pcbX={-33}
        pcbY={0}
        schX={-9}
        schY={10}
      />

      {/*
        R3 limits supercapacitor charging current.

        22 Ω gives approximately 227 mA initial current from 5 V.
        The physical resistor must be adequately power-rated.
      */}

      <resistor
        name="R3"
        resistance="22"
        footprint="1206"
        pcbX={-27}
        pcbY={7}
        schX={-6}
        schY={5}
      />

      {/*
        C3 is the hold-up supercapacitor.

        Suggested prototype value:
        1 F / 5 V.

        The footprint is provisional and must be replaced by the
        footprint of the selected physical component.
      */}

      <capacitor
        name="C3"
        manufacturerPartNumber="PB-5R0V105-R"
        capacitance="1F"
        footprint="pinrow2_p2.54"
        pcbX={-19}
        pcbY={13}
        schX={-1}
        schY={2}
      />

      {/*
        D2 bypasses R3 during supercapacitor discharge.

        C3 positive -> D2 anode
        V5_HOLD     -> D2 cathode
      */}

      <diode
        name="D2"
        manufacturerPartNumber="SS14"
        footprint="sod123"
        pcbX={-24}
        pcbY={1}
        pcbRotation={180}
        schX={-4}
        schY={10}
      />

      {/*
        D3 isolates the DevKit VIN input.

        This prevents USB power applied to the DevKit from feeding
        back into the external hold-up circuit.
      */}

      <diode
        name="D3"
        manufacturerPartNumber="SS14"
        footprint="sod123"
        pcbX={-15}
        pcbY={0}
        schX={3}
        schY={10}
      />

      {/* =====================================================
          ESP32 DEVKIT V1, 30 PINS
          ===================================================== */}

      <chip
        name="MOD1"
        manufacturerPartNumber="DOIT-ESP32-DEVKIT-V1-30PIN"
        footprint={<DevKit30PinFootprint />}
        pinLabels={{
          pin1: "EN",
          pin2: "GPIO36_VP",
          pin3: "GPIO39_VN",
          pin4: "GPIO34",
          pin5: "GPIO35",
          pin6: "GPIO32",
          pin7: "GPIO33_POWER_SENSE",
          pin8: "GPIO25_LED_DATA",
          pin9: "GPIO26",
          pin10: "GPIO27",
          pin11: "GPIO14",
          pin12: "GPIO12",
          pin13: "GPIO13",
          pin14: "GND_LEFT",
          pin15: "VIN",

          pin16: "GPIO23",
          pin17: "GPIO22_SCL",
          pin18: "GPIO1_TX0",
          pin19: "GPIO3_RX0",
          pin20: "GPIO21_SDA",
          pin21: "GPIO19",
          pin22: "GPIO18",
          pin23: "GPIO5",
          pin24: "GPIO17_TX2",
          pin25: "GPIO16_RX2",
          pin26: "GPIO4",
          pin27: "GPIO2",
          pin28: "GPIO15",
          pin29: "GND_RIGHT",
          pin30: "V3_3",
        }}
        pinAttributes={{
          VIN: {
            requiresPower: true,
            mustBeConnected: true,
          },
          V3_3: {
            providesPower: true,
          },
          GND_LEFT: {
            requiresGround: true,
            mustBeConnected: true,
          },
          GND_RIGHT: {
            requiresGround: true,
            mustBeConnected: true,
          },
        }}
        schPinArrangement ={{
          leftSide: {
            direction: "top-to-bottom",
            pins: [
              "VIN",
              "V3_3",
              "EN",
              "GPIO33_POWER_SENSE",
              "GPIO25_LED_DATA",
            ],
          },
          rightSide: {
            direction: "top-to-bottom",
            pins: [
              "GPIO21_SDA",
              "GPIO22_SCL",
              "GND_LEFT",
              "GND_RIGHT",
            ],
          },
        }}
        pcbX={18}
        pcbY={0}
        schX={15}
        schY={7}
      />

      {/* =====================================================
          POWER-FAIL DETECTION
          ===================================================== */}

      {/*
        68 kΩ / 100 kΩ divider:

        5 V x 100 / (68 + 100) = approximately 2.98 V.
      */}

      <resistor
        name="R4"
        resistance="68k"
        footprint="0603"
        pcbX={-31}
        pcbY={-13}
        schX={-8}
        schY={-3}
      />

      <resistor
        name="R5"
        resistance="100k"
        footprint="0603"
        pcbX={-25}
        pcbY={-16}
        schX={-3}
        schY={-7}
      />

      <resistor
        name="R6"
        resistance="1k"
        footprint="0603"
        pcbX={-18}
        pcbY={-13}
        schX={2}
        schY={-3}
      />

      <capacitor
        name="C4"
        capacitance="10nF"
        footprint="0603"
        pcbX={-12}
        pcbY={-16}
        schX={6}
        schY={-7}
      />

      {/* =====================================================
          WS2812B POWER AND DATA CONNECTOR
          ===================================================== */}

      <connector
        name="J2"
        footprint="pinrow3_p2.54"
        pinLabels={{
          pin1: "LED_5V",
          pin2: "LED_DATA",
          pin3: "LED_GND",
        }}
        pcbX={-47}
        pcbY={31}
        pcbRotation={90}
        schX={-10}
        schY={-14}
      />

      {/*
        Bulk capacitor close to the LED power connector.

        The footprint is provisional.
      */}

      <capacitor
        name="C5"
        capacitance="1000uF"
        footprint="pinrow2_p2.54"
        pcbX={-37}
        pcbY={29}
        schX={-5}
        schY={-17}
      />

      {/* =====================================================
          WS2812B LEVEL SHIFTER
          ===================================================== */}

      <chip
        name="U1"
        manufacturerPartNumber="74AHCT1G125"
        footprint="sot23_5"
        pinLabels={{
          pin1: "OE_N",
          pin2: "A",
          pin3: "GND",
          pin4: "Y",
          pin5: "VCC",
        }}
        pinAttributes={{
          VCC: {
            requiresPower: true,
            mustBeConnected: true,
          },
          GND: {
            requiresGround: true,
            mustBeConnected: true,
          },
          Y: {
            mustBeConnected: true,
          },
        }}
        pcbX={34}
        pcbY={27}
        schX={18}
        schY={-8}
      />

      <capacitor
        name="C6"
        capacitance="100nF"
        footprint="0603"
        pcbX={20}
        pcbY={27}
        schX={15}
        schY={-12}
      />

      <resistor
        name="R7"
        resistance="330"
        footprint="0603"
        pcbX={40}
        pcbY={27}
        schX={22}
        schY={-8}
      />

      {/* =====================================================
          OLED SSD1306 CONNECTOR

          Pin order:
          GND, 3V3, SCL, SDA
          ===================================================== */}

      <connector
        name="J3"
        footprint="pinrow4_p2.54"
        pinLabels={{
          pin1: "OLED_GND",
          pin2: "OLED_3V3",
          pin3: "OLED_SCL",
          pin4: "OLED_SDA",
        }}
        pcbX={48}
        pcbY={17}
        pcbRotation={90}
        schX={28}
        schY={2}
      />

      {/* =====================================================
          USB-C TRACES
          ===================================================== */}

      
      {/* =====================================================
          RAW 5 V FILTER
          ===================================================== */}

      <trace
        name="RAW_5V_C1"
        from="net.V5_RAW"
        to=".C1 > .pin1"
      />

      <trace
        name="C1_GROUND"
        from=".C1 > .pin2"
        to="net.GND"
      />

      <trace
        name="RAW_5V_C2"
        from="net.V5_RAW"
        to=".C2 > .pin1"
      />

      <trace
        name="C2_GROUND"
        from=".C2 > .pin2"
        to="net.GND"
      />

      {/* =====================================================
          SUPERCAPACITOR HOLD-UP TRACES
          ===================================================== */}

      <trace
        name="RAW_5V_TO_D1"
        from="net.V5_RAW"
        to=".D1 > .anode"
      />

      <trace
        name="D1_TO_HOLD_5V"
        from=".D1 > .cathode"
        to="net.V5_HOLD"
      />

      <trace
        name="HOLD_5V_TO_R3"
        from="net.V5_HOLD"
        to=".R3 > .pin1"
      />

      <trace
        name="R3_TO_SUPERCAP_NET"
        from=".R3 > .pin2"
        to="net.SUPERCAP_POS"
      />

      <trace
        name="SUPERCAP_NET_TO_C3"
        from="net.SUPERCAP_POS"
        to=".C3 > .pin1"
      />

      <trace
        name="SUPERCAP_GROUND"
        from=".C3 > .pin2"
        to="net.GND"
      />

      <trace
        name="SUPERCAP_TO_D2"
        from="net.SUPERCAP_POS"
        to=".D2 > .anode"
      />

      <trace
        name="D2_TO_HOLD_5V"
        from=".D2 > .cathode"
        to="net.V5_HOLD"
      />

      <trace
        name="HOLD_5V_TO_D3"
        from="net.V5_HOLD"
        to=".D3 > .anode"
      />

      <trace
        name="D3_TO_DEVKIT_VIN_NET"
        from=".D3 > .cathode"
        to="net.DEVKIT_VIN"
      />

      <trace
        name="DEVKIT_VIN_POWER"
        from="net.DEVKIT_VIN"
        to=".MOD1 > .VIN"
      />

      {/* =====================================================
          DEVKIT GROUND AND 3.3 V
          ===================================================== */}

      <trace
        name="DEVKIT_GND_LEFT"
        from=".MOD1 > .GND_LEFT"
        to="net.GND"
      />

      <trace
        name="DEVKIT_GND_RIGHT"
        from=".MOD1 > .GND_RIGHT"
        to="net.GND"
      />

      <trace
        name="DEVKIT_3V3_OUTPUT"
        from=".MOD1 > .V3_3"
        to="net.DEVKIT_3V3"
      />

      {/* =====================================================
          POWER-FAIL DETECTION
          ===================================================== */}

      <trace
        name="RAW_5V_TO_POWER_SENSE"
        from="net.V5_RAW"
        to=".R4 > .pin1"
      />

      <trace
        name="POWER_SENSE_TOP"
        from=".R4 > .pin2"
        to="net.POWER_SENSE_NODE"
      />

      <trace
        name="POWER_SENSE_BOTTOM"
        from="net.POWER_SENSE_NODE"
        to=".R5 > .pin1"
      />

      <trace
        name="POWER_SENSE_GROUND"
        from=".R5 > .pin2"
        to="net.GND"
      />

      <trace
        name="POWER_SENSE_SERIES_INPUT"
        from="net.POWER_SENSE_NODE"
        to=".R6 > .pin1"
      />

      <trace
        name="POWER_SENSE_TO_ESP32"
        from=".R6 > .pin2"
        to=".MOD1 > .GPIO33_POWER_SENSE"
      />

      <trace
        name="POWER_SENSE_FILTER"
        from=".R6 > .pin2"
        to=".C4 > .pin1"
      />

      <trace
        name="POWER_SENSE_FILTER_GROUND"
        from=".C4 > .pin2"
        to="net.GND"
      />

      {/* =====================================================
          WS2812B POWER
          ===================================================== */}

      <trace
        name="LED_RAW_5V_POWER"
        from="net.V5_RAW"
        to=".J2 > .LED_5V"
      />

      <trace
        name="LED_GROUND_POWER"
        from=".J2 > .LED_GND"
        to="net.GND"
      />

      <trace
        name="LED_BULK_CAPACITOR_POWER"
        from="net.V5_RAW"
        to=".C5 > .pin1"
      />

      <trace
        name="LED_BULK_CAPACITOR_GROUND"
        from=".C5 > .pin2"
        to="net.GND"
      />

      {/* =====================================================
          WS2812B LEVEL SHIFTER
          ===================================================== */}

      <trace
        name="ESP32_LED_DATA"
        from=".MOD1 > .GPIO25_LED_DATA"
        to="net.LED_DATA_3V3"
      />

      <trace
        name="LED_DATA_TO_LEVEL_SHIFTER"
        from="net.LED_DATA_3V3"
        to=".U1 > .A"
      />

      <trace
        name="LEVEL_SHIFTER_VCC"
        from="net.V5_RAW"
        to=".U1 > .VCC"
      />

      <trace
        name="LEVEL_SHIFTER_GROUND"
        from=".U1 > .GND"
        to="net.GND"
      />

      <trace
        name="LEVEL_SHIFTER_ENABLE"
        from=".U1 > .OE_N"
        to="net.GND"
      />

      <trace
        name="LEVEL_SHIFTER_DECOUPLING"
        from="net.V5_RAW"
        to=".C6 > .pin1"
      />

      <trace
        name="LEVEL_SHIFTER_DECOUPLING_GROUND"
        from=".C6 > .pin2"
        to="net.GND"
      />

      <trace
        name="LEVEL_SHIFTER_OUTPUT"
        from=".U1 > .Y"
        to="net.LED_DATA_5V"
      />

      <trace
        name="LED_DATA_SERIES_RESISTOR"
        from="net.LED_DATA_5V"
        to=".R7 > .pin1"
      />

      <trace
        name="LED_DATA_TO_CONNECTOR"
        from=".R7 > .pin2"
        to=".J2 > .LED_DATA"
      />

      {/* =====================================================
          OLED SSD1306
          ===================================================== */}

      <trace
        name="OLED_3V3_POWER"
        from="net.DEVKIT_3V3"
        to=".J3 > .OLED_3V3"
      />

      <trace
        name="OLED_GROUND"
        from=".J3 > .OLED_GND"
        to="net.GND"
      />

      <trace
        name="ESP32_I2C_SCL"
        from=".MOD1 > .GPIO22_SCL"
        to="net.I2C_SCL"
      />

      <trace
        name="I2C_SCL_TO_OLED"
        from="net.I2C_SCL"
        to=".J3 > .OLED_SCL"
      />

      <trace
        name="ESP32_I2C_SDA"
        from=".MOD1 > .GPIO21_SDA"
        to="net.I2C_SDA"
      />

      <trace
        name="I2C_SDA_TO_OLED"
        from="net.I2C_SDA"
        to=".J3 > .OLED_SDA"
      />
    </schematicsheet>
  </board>
)