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/power.tsx
import { STUSB4500QTR } from "../imports/STUSB4500QTR"
import { SI4427BDY_T1_E3 } from "../imports/SI4427BDY_T1_E3"
import { AP63203WU_7 } from "../imports/AP63203WU_7"
import { INA180A1IDBVR } from "../imports/INA180A1IDBVR"
import { SRN6045TA_4R7M } from "../imports/SRN6045TA_4R7M"
import { B560C_13_F } from "../imports/B560C_13_F"
import { BZT52C8V2 } from "../imports/BZT52C8V2"
import { usbCFootprint, usbCPinLabels, usbCCadModel } from "./usb-c-footprint"
import { schAt, pcbRotations, net, Passives, Npn, BlockTitle, type Passive } from "./helpers"
export const pdPassives: Passive[] = [
{ name: "C1", layer: "bottom", kind: "C", value: "1uF", a: "VBUS_RAW", b: "GND", x: -60, y: 31, volts: 50, footprint: "0805" },
{ name: "C2", layer: "bottom", kind: "C", value: "1uF", a: "PD_2V7", b: "GND", x: -55, y: 31 },
{ name: "C3", layer: "bottom", kind: "C", value: "1uF", a: "PD_1V2", b: "GND", x: -50, y: 31 },
{ name: "R1", kind: "R", value: "470", a: "VBUS_RAW", b: "PD_VS", x: -45, y: 31 },
{ name: "R2", kind: "R", value: "1k", a: "PD_SWITCHED", b: "PD_DISCH", x: -40, y: 31, footprint: "1206", note: "Check discharge pulse rating" },
{ name: "R3", kind: "R", value: "22k", a: "PD_SNK_EN", b: "PD_GATE", x: -35, y: 31 },
{ name: "R4", kind: "R", value: "100k", a: "PD_COMMON_S", b: "PD_GATE", x: -30, y: 31 },
{ name: "R5", layer: "bottom", kind: "R", value: "10k", a: "PD_RESET", b: "GND", x: -60, y: 26 },
{ name: "R6", kind: "R", value: "4.7k", a: "V3V3", b: "PD_SDA", x: -55, y: 26 },
{ name: "R7", kind: "R", value: "4.7k", a: "V3V3", b: "PD_SCL", x: -50, y: 26 },
{ name: "R8", layer: "bottom", kind: "R", value: "10k", a: "V3V3", b: "PD_ALERT_N", x: -45, y: 26 },
{ name: "R9", kind: "R", value: "10k", a: "V3V3", b: "PD_OK2_N", x: -40, y: 26 },
{ name: "R10", kind: "R", value: "10k", a: "V3V3", b: "PD_ATTACH_N", x: -35, y: 26 },
{ name: "R11", kind: "R", value: "220k", a: "VBUS_RAW", b: "ADC_VBUS", x: -30, y: 26 },
{ name: "R12", kind: "R", value: "15k", a: "ADC_VBUS", b: "GND", x: -60, y: 21 },
{ name: "C4", kind: "C", value: "10nF", a: "ADC_VBUS", b: "GND", x: -55, y: 21 },
{ name: "R13", kind: "R", value: "0.02", a: "PD_SWITCHED", b: "PD9", x: -19, y: 45, footprint: "2512", note: "1 W min, Kelvin sense" },
{ name: "C5", kind: "C", value: "100nF", a: "V3V3", b: "GND", x: -24, y: 33 },
{ name: "R14", kind: "R", value: "1k", a: "IIN_RAW", b: "ADC_IIN", x: -30, y: 21 },
{ name: "C6", kind: "C", value: "10nF", a: "ADC_IIN", b: "GND", x: -35, y: 21 },
]
export function UsbPd() {
const switchPins = (drain: string) => ({
pin1: net("PD_COMMON_S"), pin2: net("PD_COMMON_S"), pin3: net("PD_COMMON_S"), pin4: net("PD_GATE"),
pin5: net(drain), pin6: net(drain), pin7: net(drain), pin8: net(drain),
})
return <>
<BlockTitle x={-42} y={66}>01 / USB-C PD input, selectable 5/9/15/20 V</BlockTitle>
<connector name="J1" standard="usb_c" manufacturerPartNumber="TYPE-C-31-M-12"
supplierPartNumbers={{ jlcpcb: ["C165948"] }} pinLabels={usbCPinLabels} footprint={usbCFootprint} cadModel={usbCCadModel} {...schAt("J1", -59, 49)} pcbRotation={270} noConnect={["SBU1", "SBU2"]}
connections={{ VBUS1: net("PROG_VBUS"), VBUS2: net("PROG_VBUS"),
GND1: net("GND"), GND2: net("GND"), EH1: net("GND"), EH2: net("GND"), EH3: net("GND"), EH4: net("GND"),
CC1: net("PROG_CC1"), CC2: net("PROG_CC2"), DP1: net("USB_DP"), DP2: net("USB_DP"), DN1: net("USB_DM"), DN2: net("USB_DM") }} />
<STUSB4500QTR name="U1" layer="bottom" {...schAt("U1", -43, 50)}
noConnect={["pin3", "GPIO", "A_B_SIDE", "POWER_OK3"]}
connections={{ CC1DB: net("CC1"), CC1: net("CC1"), CC2: net("CC2"), CC2DB: net("CC2"),
RESET: net("PD_RESET"), SCL: net("PD_SCL"), SDA: net("PD_SDA"), DISCH: net("PD_DISCH"),
GND: net("GND"), ATTACH: net("PD_ATTACH_N"), ADDR0: net("GND"), ADDR1: net("GND"), POWER_OK2: net("PD_OK2_N"),
VBUS_EN_SNK: net("PD_SNK_EN"), VBUS_VS_DISCH: net("PD_VS"), ALERT: net("PD_ALERT_N"),
VREG_1V2: net("PD_1V2"), VSYS: net("GND"), VREG_2V7: net("PD_2V7"), VDD: net("VBUS_RAW"), EP: net("GND") }} />
<SI4427BDY_T1_E3 name="Q1" {...schAt("Q1", -28, 55)} connections={switchPins("VBUS_RAW")} />
<SI4427BDY_T1_E3 name="Q2" sourceOnLeft {...schAt("Q2", -28, 45)} connections={switchPins("PD_SWITCHED")} />
<BZT52C8V2 name="D1" variant="zener" {...schAt("D1", -20, 55)}
connections={{ anode: net("PD_GATE"), cathode: net("PD_COMMON_S") }} />
<INA180A1IDBVR name="U2" schHeight={0.6} {...schAt("U2", -20, 44)}
connections={{ OUT: net("IIN_RAW"), GND: net("GND"), IN_POS: net("PD_SWITCHED"), IN_NEG: net("PD9"), VS: net("V3V3") }} />
<Passives parts={pdPassives} sx={-57} sy={31} />
</>
}
export const logicPassives: Passive[] = [
{ name: "C10", kind: "C", value: "4.7uF", a: "LOGIC_IN", b: "GND", x: -57, y: 2, volts: 50, footprint: "1206" },
{ name: "C11", footprint: "0402", kind: "C", value: "100nF", a: "LOGIC_BST", b: "LOGIC_SW", x: -51, y: 6 },
{ name: "C12", kind: "C", value: "22uF", a: "V3V3", b: "GND", x: -35, y: 5, volts: 10, footprint: "0805" },
{ name: "C13", kind: "C", value: "22uF", a: "V3V3", b: "GND", x: -35, y: 0, volts: 10, footprint: "0805" },
]
export function LogicPower() {
return <>
<BlockTitle x={-42} y={0}>02 / Always-on 3.3 V logic</BlockTitle>
<AP63203WU_7 name="U3" {...schAt("U3", -48, -6)} connections={{
FB: net("V3V3"), EN: net("LOGIC_IN"), VIN: net("LOGIC_IN"), GND: net("GND"), SW: net("LOGIC_SW"), BST: net("LOGIC_BST") }} />
<SRN6045TA_4R7M name="L1" {...schAt("L1", -32, -6)}
connections={{ pin1: net("LOGIC_SW"), pin2: net("V3V3") }} />
<B560C_13_F name="D2" layer="bottom" pcbRotation={pcbRotations.D2} variant="schottky" schRotation={90} {...schAt("D2", -57, -6)} connections={{ anode: net("VBUS_RAW"), cathode: net("LOGIC_IN") }} />
<Passives parts={logicPassives} sx={-57} sy={-15} />
</>
}