MustafaMulla29/rp2040-bldc-motor-controller-new

A USB‑C PD–powered RP2040 BLDC motor controller PCB with 3.3 V logic, MCT8329A sensorless commutation, three MOSFET half-bridges, protected power switching, USB data, controls, and motor connectors.

Version
0.3.82
License
unset
Stars
0

circuit/processor.tsx

import { BoardButton } from "./controls"
import { ServicePads } from "./service-pads"
import { RP2040 } from "../imports/RP2040"
import { W25Q16JVSSIQ } from "../imports/W25Q16JVSSIQ"
import { ABM8_272_T3 } from "../imports/ABM8_272_T3"
import { schAt, pcbRotations, net,  Passives, BlockTitle, type Passive } from "./helpers"

export const processorPassives: Passive[] = [
  ...[[-49,-25],[-49,-30],[-41,-21],[-34,-25],[-34,-30],[-38,-36]].map(([x,y], i): Passive =>
    ({ name: `C${40+i}`, kind: "C", value: "100nF", a: "V3V3", b: "GND", x, y, volts: 10 })),
  { name: "C46", kind: "C", value: "100nF", a: "V1V1", b: "GND", x: -45, y: -36, volts: 10 },
  { name: "C47", kind: "C", value: "100nF", a: "V1V1", b: "GND", x: -45, y: -23, volts: 10 },
  { name: "C48", kind: "C", value: "1uF", a: "V1V1", b: "GND", x: -34, y: -35, volts: 10 },
  { name: "C49", kind: "C", value: "1uF", a: "V3V3", b: "GND", x: -34, y: -40, volts: 10 },
  { name: "C50", kind: "C", value: "100nF", a: "ADC_AVDD", b: "GND", x: -38, y: -41, volts: 10 },
  { name: "C51", kind: "C", value: "100nF", a: "V3V3", b: "GND", x: -49, y: -35, volts: 10 },
  { name: "C52", kind: "C", value: "10uF", a: "V3V3", b: "GND", x: -50, y: -40, volts: 10, footprint: "0805" },
  { name: "R40", kind: "R", value: "0", a: "V3V3", b: "ADC_AVDD", x: -43, y: -41 },
  { name: "R41", kind: "R", value: "27", footprint: "0402", a: "USB_DP", b: "MCU_USB_DP", x: -53, y: -25 },
  { name: "R42", kind: "R", value: "27", footprint: "0402", a: "USB_DM", b: "MCU_USB_DM", x: -53, y: -30 },
  { name: "R43", kind: "R", value: "10k", a: "V3V3", b: "RUN", x: -57, y: -35 },
  { name: "R44", kind: "R", value: "1k", a: "QSPI_SS", b: "BOOTSEL", x: -27, y: -24 },
  { name: "R45", kind: "R", value: "10k", a: "V3V3", b: "QSPI_SS", x: -27, y: -29 },
  { name: "C53", kind: "C", value: "100nF", a: "V3V3", b: "GND", x: -29, y: -38, volts: 10 },
  { name: "R46", footprint: "0402", kind: "R", value: "1k", a: "XOUT", b: "XTAL_OUT", x: -42, y: -14 },
  { name: "C54", kind: "C", value: "15pF", a: "XIN", b: "GND", x: -49, y: -18, volts: 25, note: "10 pF crystal CL, assuming 2.5 pF stray per effective load" },
  { name: "C55", kind: "C", value: "15pF", a: "XTAL_OUT", b: "GND", x: -49, y: -13, volts: 25 },
  { name: "R47", kind: "R", value: "1k", a: "STATUS_LED", b: "LED_A", x: -57, y: -42 },
]

// Compact PCB decoupling and crystal-load footprints; electrical values are unchanged.
for (const part of processorPassives) {
  if (part.kind === "C" && part.name !== "C52") part.footprint = "0402"
}

export function Processor() {
  return <>
    <BlockTitle x={-40} y={-31}>04 / RP2040 supervisor, QSPI flash, USB and SWD</BlockTitle>
    <RP2040 name="U5" pcbRotation={pcbRotations.U5} {...schAt("U5", -46, -51)}
      noConnect={["GPIO7", "GPIO12", "GPIO10", "GPIO11", "GPIO13", "GPIO14", "GPIO15", "GPIO16", "GPIO17", "GPIO18", "GPIO19", "GPIO20", "GPIO21"]}
      connections={{ IOVDD1: net("V3V3"), IOVDD2: net("V3V3"), IOVDD3: net("V3V3"), IOVDD4: net("V3V3"), IOVDD5: net("V3V3"), IOVDD6: net("V3V3"),
        DVDD1: net("V1V1"), DVDD2: net("V1V1"), VREG_IN: net("V3V3"), VREG_VOUT: net("V1V1"), ADC_AVDD: net("ADC_AVDD"), USB_VDD: net("V3V3"),
        GND: net("GND"), TESTEN: net("GND"), XIN: net("XIN"), XOUT: net("XOUT"), SWCLK: net("SWCLK"), SWD: net("SWDIO"), RUN: net("RUN"),
        USB_DP: net("MCU_USB_DP"), USB_DM: net("MCU_USB_DM"), QSPI_SS: net("QSPI_SS"), QSPI_SCLK: net("QSPI_SCLK"),
        QSPI_SD0: net("QSPI_SD0"), QSPI_SD1: net("QSPI_SD1"), QSPI_SD2: net("QSPI_SD2"), QSPI_SD3: net("QSPI_SD3"),
        GPIO0: net("MCT_SDA"), GPIO1: net("MCT_SCL"), GPIO2: net("MOTOR_SPEED"), GPIO3: net("MOTOR_ARM"), GPIO4: net("MOTOR_FAULT_N"), GPIO5: net("MOTOR_FG"),
        GPIO9: net("PROG_PRESENT"), GPIO8: net("ARM_REQUEST_N"), GPIO6: net("PD_OK2_N"), GPIO22: net("PD_SDA"), GPIO23: net("PD_SCL"), GPIO24: net("PD_ALERT_N"), GPIO25: net("STATUS_LED"),
        GPIO26_ADC0: net("ADC_VBUS"), GPIO27_ADC1: net("ADC_VMOTOR"), GPIO28_ADC2: net("ADC_IIN"), GPIO29_ADC3: net("ADC_THROTTLE") }} />
    <W25Q16JVSSIQ name="U6" pcbRotation={pcbRotations.U6} {...schAt("U6", -24, -42)} connections={{
      pin1: net("QSPI_SS"), pin2: net("QSPI_SD1"), IO2: net("QSPI_SD2"), GND: net("GND"), pin5: net("QSPI_SD0"), CLK: net("QSPI_SCLK"), IO3: net("QSPI_SD3"), VCC: net("V3V3") }} />
    <ABM8_272_T3 name="Y1" {...schAt("Y1", -25, -51)} connections={{ pin1: net("XIN"), pin2: net("GND"), pin3: net("XTAL_OUT"), pin4: net("GND") }} />
    <ServicePads bank="J2" />
    <BoardButton name="SW1" signal="BOOTSEL" />
    <BoardButton name="SW2" signal="RUN" />
    <led pcbStyle={{silkscreenTextVisibility: "hidden"}} name="LED1" color="green" footprint="0603" schRotation={-90} {...schAt("LED1", -11, -58)}
      pcbRotation={180} pinLabels={{ pin1: ["cathode", "neg"], pin2: ["anode", "pos"] }}
      connections={{ anode: net("LED_A"), cathode: net("GND") }} />
    <Passives parts={processorPassives} sx={-57} sy={-76} />
  </>
}