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

import c93Body from "./c93-model.json"
import { BoardButton, SpeedControl } from "./controls"
import { ServicePads } from "./service-pads"
import { MCT8329A1IREER } from "../imports/MCT8329A1IREER"
import { A_24_243_4 } from "../imports/A_24_243_4/A_24_243_4"
import { AOD2610E } from "../imports/AOD2610E"
import { schAt, pcbRotations, net, Passives, Npn,  BlockTitle, type Passive } from "./helpers"

export const motorPassives: Passive[] = [
  { name: "R85", kind: "R", value: "100k", a: "THROTTLE_IN", b: "GND", x: 29, y: -42 },
  { name: "R86", kind: "R", value: "10k", a: "V3V3", b: "ARM_REQUEST_N", x: -16, y: -39 },
  { name: "C82", kind: "C", value: "100nF", a: "ARM_REQUEST_N", b: "GND", x: -16, y: -43 },
  { name: "R83", kind: "R", value: "47k", a: "PD_OK2_N", b: "PD_INHIBIT_B", x: -17, y: -28 },
  { name: "R84", kind: "R", value: "100k", a: "PD_INHIBIT_B", b: "GND", x: -17, y: -23 },
  { name: "C70", kind: "C", value: "100nF", a: "VMOTOR", b: "GND", x: 0, y: -10, volts: 50, footprint: "0402" },
  { name: "C71", kind: "C", value: "10uF", a: "VMOTOR", b: "GND", x: 6, y: -10, volts: 50, footprint: "1210" },
  { name: "C72", kind: "C", value: "470nF", a: "MCT_CPH", b: "MCT_CPL", x: 12, y: -10, volts: 50, footprint: "0805" },
  { name: "C73", kind: "C", value: "22uF", a: "MCT_GVDD", b: "GND", x: 20, y: -10, volts: 35, footprint: "1210" },
  { name: "C74", kind: "C", value: "1uF", a: "MCT_BSTA", b: "PHASE_U", x: 21, y: -16, volts: 25, footprint: "0805" },
  { name: "C75", kind: "C", value: "1uF", a: "MCT_BSTB", b: "PHASE_V", x: 21, y: -21, volts: 25, footprint: "0805" },
  { name: "C76", kind: "C", value: "1uF", a: "MCT_BSTC", b: "PHASE_W", x: 21, y: -26, volts: 25, footprint: "0805" },
  { name: "C77", kind: "C", value: "1uF", a: "MCT_AVDD", b: "GND", x: 4, y: -27 },
  { name: "C78", kind: "C", value: "1uF", a: "MCT_DVDD", b: "GND", x: 4, y: -22, footprint: "0402" },
  { name: "C79", kind: "C", value: "10uF", a: "V3V3", b: "GND", x: 0, y: -16, volts: 10, footprint: "0805" },
  // VREG bypass: 1.54 mm pad-centre spacing, <1 mm exposed copper. TI specifies
  // close placement; 1.6 mm lets the router's centre-distance check model this.
  // Pin 1 connects to U7.VREG (V3V3) through MCT_REGULATOR_BYPASS in MotorCopper.
  { name: "C80", kind: "C", value: "1uF", a: "V3V3", b: "GND", x: 0, y: -21, volts: 10, footprint: "0402", maxDecouplingTraceLength: 1.6, connections: { pin2: "net.GND" } },
  { name: "R70", kind: "R", value: "10k", a: "MCT_AVDD", b: "MCT_DRVOFF", x: 10, y: -29 },
  { name: "R71", kind: "R", value: "4.7k", a: "MOTOR_ARM", b: "ARM_BASE", x: -7, y: -28 },
  { name: "R72", kind: "R", value: "100k", a: "ARM_BASE", b: "GND", x: -7, y: -33 },
  { name: "R73", kind: "R", value: "10k", a: "MOTOR_SPEED", b: "GND", x: -6, y: -23 },
  { name: "R74", kind: "R", value: "10k", a: "MCT_DIR", b: "GND", x: 14, y: -31, footprint: "0402" },
  { name: "R75", kind: "R", value: "10k", a: "MCT_BRAKE", b: "GND", x: 20, y: -31, footprint: "0402" },
  { name: "R76", kind: "R", value: "10k", a: "V3V3", b: "MOTOR_FAULT_N", x: 9, y: -37 },
  { name: "R77", kind: "R", value: "10k", a: "V3V3", b: "MOTOR_FG", x: 14, y: -37 },
  { name: "R78", kind: "R", value: "4.7k", a: "V3V3", b: "MCT_SDA", x: 4, y: -37 },
  { name: "R79", kind: "R", value: "4.7k", a: "V3V3", b: "MCT_SCL", x: -1, y: -37 },
  { name: "R80", kind: "R", value: "1k", a: "THROTTLE_IN", b: "ADC_THROTTLE", x: 20, y: -37 },
  { name: "C81", kind: "C", value: "10nF", a: "ADC_THROTTLE", b: "GND", x: 25, y: -37 },
  { name: "R81", kind: "R", value: "0.01", a: "LS_RETURN", b: "GND", x: 49, y: -42, footprint: "2512", note: "1 W minimum; sense pads must use Kelvin connections" },
  { name: "R82", kind: "R", value: "100k", a: "MCT_EXTCLK", b: "GND", x: 4, y: -32 },
]

export function MotorControl() {
  return <>
    <BlockTitle x={16} y={2}>05 / MCT8329A sensorless commutation</BlockTitle>
    <MCT8329A1IREER name="U7" {...schAt("U7", 16, -15)} noConnect={["GCTRL", "pin33"]}
      connections={{ DGND: net("GND"), VREG: net("V3V3"), GND: net("GND"), PVDD: net("VMOTOR"), CPL: net("MCT_CPL"), CPH: net("MCT_CPH"), GVDD: net("MCT_GVDD"),
        BSTA: net("MCT_BSTA"), SHA: net("PHASE_U"), GHA: net("GHA"), GLA: net("GLA"),
        BSTB: net("MCT_BSTB"), SHB: net("PHASE_V"), GHB: net("GHB"), GLB: net("GLB"),
        BSTC: net("MCT_BSTC"), SHC: net("PHASE_W"), GHC: net("GHC"), GLC: net("GLC"),
        LSS: net("LS_RETURN"), SP: net("LS_RETURN"), SN: net("GND"), DRVOFF: net("MCT_DRVOFF"), AGND: net("GND"), AVDD: net("MCT_AVDD"),
        pin27: net("MOTOR_SPEED"), FG: net("MOTOR_FG"), SDA: net("MCT_SDA"), SCL: net("MCT_SCL"), DIR: net("MCT_DIR"), EXT_CLK: net("MCT_EXTCLK"),
        BRAKE: net("MCT_BRAKE"), nFAULT: net("MOTOR_FAULT_N"), DVDD: net("MCT_DVDD"), PAD: net("GND") }} />
    <Npn name="Q6" base="PD_INHIBIT_B" collector="ARM_BASE" x={-13} y={-33} sx={31} sy={-3} />
    <Npn name="Q5" base="ARM_BASE" collector="MCT_DRVOFF" x={-1} y={-29} sx={31} sy={-8} />
    <SpeedControl />
    <BoardButton name="SW3" signal="ARM_REQUEST_N" />
    <ServicePads bank="J5" />
    <ServicePads bank="J6" />
    <Passives parts={motorPassives} sx={4} sy={-39} />
  </>
}

export function MotorBridge() {
  return <>
    <BlockTitle x={59} y={65}>06 / Three half bridges and motor leads</BlockTitle>
    {(["U", "V", "W"] as const).map((phase, i) => {
      const letter = ["A", "B", "C"][i]
      const y = 8 - i * 17
      const sy = 51 - i * 24
      const high = `GH${letter}_GATE`, low = `GL${letter}_GATE`
      return <group key={phase} name={`phase_${phase}`} pcbX={0} pcbY={0} schX={0} schY={0}>
        <AOD2610E name={`Q${10 + i * 2}`} {...schAt(`Q${10 + i * 2}`, 53, sy)} connections={{ G: net(high), D: net("VMOTOR"), S: net(`PHASE_${phase}`) }} />
        <AOD2610E name={`Q${11 + i * 2}`} {...schAt(`Q${11 + i * 2}`, 53, sy - 10)} connections={{ G: net(low), D: net(`PHASE_${phase}`), S: net("LS_RETURN") }} />
        <resistor name={`R${90 + i * 4}`} pcbRotation={pcbRotations[`R${90 + i * 4}`] ?? 0} resistance="10" footprint="0603" {...schAt(`R${90 + i * 4}`, 44, sy)}
          connections={{ pin1: net(`GH${letter}`), pin2: net(high) }} />
        <resistor name={`R${91 + i * 4}`} pcbRotation={pcbRotations[`R${91 + i * 4}`] ?? 0} schRotation={i === 1 ? 90 : -90} resistance="100k" footprint="0603" {...schAt(`R${91 + i * 4}`, 64, sy)}
          connections={{ pin1: net(high), pin2: net(`PHASE_${phase}`) }} />
        <resistor name={`R${92 + i * 4}`} pcbRotation={pcbRotations[`R${92 + i * 4}`] ?? 0} resistance="10" footprint="0603" {...schAt(`R${92 + i * 4}`, 44, sy - 10)}
          connections={{ pin1: net(`GL${letter}`), pin2: net(low) }} />
        <resistor name={`R${93 + i * 4}`} pcbRotation={pcbRotations[`R${93 + i * 4}`] ?? 0} resistance="100k" footprint="0603" {...schAt(`R${93 + i * 4}`, 64, sy - 10)}
          connections={{ pin1: net(low), pin2: net("LS_RETURN") }} />
        {/* One insulated female socket per phase; both solder legs are the same contact. */}
        <A_24_243_4 name={`J${10+i}`} {...schAt(`J${10+i}`, 18, 7-i*3)} allowOffBoard
          connections={{ pin1: net(`PHASE_${phase}`), pin2: net(`PHASE_${phase}`) }} />
        <capacitor name={`C${90+i}`} capacitance="1uF" schRotation={-90} pcbRotation={180} maxVoltageRating={50} footprint="0805" {...schAt(`C${90+i}`, 73, sy + 3)}
          connections={{ pin1: net("VMOTOR"), pin2: net("GND") }} />
      </group>
    })}
    <capacitor name="C93" cadModel={{jscad:c93Body}} capacitance="470uF" schRotation={-90} polarized maxVoltageRating={50} {...schAt("C93", 56, -30)}
      footprint={<footprint>
        <platedhole portHints={["pin1"]} shape="circle" holeDiameter={0.9} outerDiameter={2} pcbX={-2.5} pcbY={0} />
        <platedhole portHints={["pin2"]} shape="circle" holeDiameter={0.9} outerDiameter={2} pcbX={2.5} pcbY={0} />
        <silkscreencircle pcbX={0} pcbY={0} radius={6.25} />
        <courtyardcircle pcbX={0} pcbY={0} radius={6.75} />

        <silkscreentext text="+" pcbX={-4} pcbY={3.5} fontSize={1.2} />
      </footprint>} connections={{ pin1: net("VMOTOR"), pin2: net("GND") }} />
    <ServicePads bank="J7" />
  </>
}