imrishabh18/rp2040-motor-controller
An RP2040-based NEMA17 stepper-motor controller with USB-C programming and PD motor-power negotiation, DRV8825 dual H-bridge drive, current/temperature telemetry, protected power filtering, status RGB LED, buzzer alarm, and optional magnetic encoder.
- Version
- 1.0.41
- License
- unset
- Stars
- 3
index.circuit.tsx
PCB
Schematic
import { PdVoltageControlSection } from "./schematic/PdVoltageControlSection";
import jlcClearanceRules from "./engineering/jlcpcb-clearance-rules.json";
import { ChipDescriptions } from "./schematic/ChipDescriptions";
import { tscircuitBottomLogo } from "./assets/tscircuit-logo-bottom";
import { Drv8825ThermalCopper } from "./schematic/Drv8825ThermalCopper";
import { OptionalEncoderSection } from "./schematic/OptionalEncoderSection";
import { installGroundPourFinalization } from "./routing/ground-pour-selection";
import { CurrentTelemetrySection } from "./schematic/CurrentTelemetrySection";
import { StatusLedSection } from "./schematic/StatusLedSection";
import { ProductionTestPoints } from "./schematic/ProductionTestPoints";
import { FeedbackSection } from "./schematic/FeedbackSection";
import nema17Outline from "./mechanical/nema17-outline.json";
import { savedRouting } from "./routing/saved-routing";
import { ControllerSections } from "./schematic/ControllerSections";
import {
MotorDriverController,
MotorDriverControlTraces,
MotorDriverGroundTraces,
MotorDriverPassives,
MotorDriverPowerTraces,
MotorDriverPrimaryGroundTraces,
MotorDriverSenseAndControlTraces,
} from "./schematic/MotorDriverCoreSection";
import {
MotorOutputConnectors,
MotorOutputTraces,
} from "./schematic/MotorOutputsSection";
import {
MotorPowerFilteringComponents,
MotorPowerFilteringGroundTrace,
MotorPowerFilteringSupplyTrace,
} from "./schematic/MotorPowerFilteringSection";
import {
MotorPowerPdConnectorGroundTraces,
MotorPowerPdControllers,
MotorPowerPdInputTraces,
MotorPowerPdPassives,
MotorPowerPdPrimaryGroundTrace,
MotorPowerPdProtocolTraces,
MotorPowerPdSupportGroundTraces,
} from "./schematic/MotorPowerPdNegotiationSection";
import { SchematicSheets } from "./schematic/SchematicSheets";
import { ThermalProtectionComponents, ThermalProtectionTraces } from "./schematic/ThermalProtectionSection";
export default function Rp2040MotorController({
routingDisabled = false,
routingAlgorithm = savedRouting,
finalizeGroundPours = true,
}: {
routingDisabled?: boolean;
routingAlgorithm?: typeof savedRouting;
finalizeGroundPours?: boolean;
} = {}) {
// The DRV8825 footprint intentionally has thermal vias inside its exposed pad.
// Core's placement check treats via-in-pad as a collision and skips routing.
return (
<board
{...(!routingDisabled && finalizeGroundPours ? {ref: installGroundPourFinalization} : {})}
routingDisabled={routingDisabled}
placementDrcChecksDisabled
layers={4}
thickness="1.6mm"
outline={nema17Outline}
minViaHoleDiameter="0.3mm"
minViaPadDiameter="0.5mm"
minViaHoleEdgeToViaHoleEdgeClearance="0.2mm"
minPlatedHoleDrillEdgeToDrillEdgeClearance="0.45mm"
minViaEdgeToPadEdgeClearance="0.125mm"
minTraceWidth={jlcClearanceRules.minimumMm.traceWidth}
minTraceToPadEdgeClearance={jlcClearanceRules.minimumMm.padToTrace}
// Native checks currently reuse this field for via-to-pad spacing.
// checkJlcClearances separately enforces 0.15 mm between component pads.
minPadEdgeToPadEdgeClearance={jlcClearanceRules.minimumMm.viaToPad}
minBoardEdgeClearance={jlcClearanceRules.minimumMm.copperToBoardEdge}
autorouterEffortLevel="2x"
autorouterVersion="beta_pipeline7"
autorouter={{
local: true,
algorithmFn: routingAlgorithm,
groupMode: "subcircuit",
}}
>
<net name="GND" />
{/* Explicit net names keep labels consistent across the MCU subcircuit and sheets. */}
<net name="DRIVER_STEP" connectsTo=".MCU > .U1 > .GPIO18" />
<net name="DRIVER_DIR" connectsTo=".MCU > .U1 > .GPIO19" />
<net name="DRIVER_RESET" connectsTo=".MCU > .U1 > .GPIO20" />
<net name="MCU_ENABLE" connectsTo=".MCU > .U1 > .GPIO22" />
<net name="TEMP_SDA" connectsTo=".MCU > .U1 > .GPIO26_ADC0" />
<net name="TEMP_SCL" connectsTo=".MCU > .U1 > .GPIO27_ADC1" />
<SchematicSheets />
<group pcbX={-5.625} pcbY={-8.25}>
<ControllerSections />
<MotorDriverController />
<MotorPowerPdControllers />
<MotorOutputConnectors />
<MotorPowerFilteringComponents />
<MotorPowerPdPassives />
<MotorDriverPassives />
<ThermalProtectionComponents />
<MotorDriverControlTraces />
<MotorPowerPdInputTraces />
<MotorPowerFilteringSupplyTrace />
<MotorPowerPdProtocolTraces />
<MotorDriverPowerTraces />
<MotorDriverPrimaryGroundTraces />
<MotorPowerPdPrimaryGroundTrace />
<MotorPowerPdConnectorGroundTraces />
<MotorPowerFilteringGroundTrace />
<MotorPowerPdSupportGroundTraces />
<MotorDriverGroundTraces />
<MotorOutputTraces />
<MotorDriverSenseAndControlTraces />
<ThermalProtectionTraces />
</group>
<copperpour
name="GND_TOP"
layer="top"
connectsTo="net.GND"
clearance="0.21mm"
padMargin="0.2mm"
traceMargin="0.2mm"
boardEdgeMargin="0.3mm"
coveredWithSolderMask
/>
<copperpour
name="GND_BOTTOM"
layer="bottom"
connectsTo="net.GND"
clearance="0.21mm"
padMargin="0.2mm"
traceMargin="0.2mm"
boardEdgeMargin="0.3mm"
coveredWithSolderMask
/>
<group pcbX={0} pcbY={0} schX={0} schY={0}>
{[-15.5,15.5].flatMap(x => [-15.5,15.5].map(y => (
<group key={`${x}:${y}`} pcbX={0} pcbY={0} schX={0} schY={0}>
<chip doNotPlace name={`MH${(x > 0 ? 2 : 0) + (y > 0 ? 1 : 0) + 1}`} pcbX={x} pcbY={y} schSheetName="motor_power" schX={x > 0 ? 11 : 8} schY={y > 0 ? -4 : -6}
pinLabels={{pin1:["GND"]}} connections={{pin1:"net.GND"}}
footprint={<footprint><platedhole portHints={["pin1"]} shape="circle" holeDiameter="3.3mm" outerDiameter="5.6mm" /></footprint>} />
</group>
)))}
{/* Upper-left branding, viewed from underneath. Clear of vias without aperture cutouts. */}
<silkscreengraphic imageUrl={tscircuitBottomLogo} width="9mm" height="9.340763mm"
layer="bottom" pcbX={13.5} pcbY={7.5} />
<silkscreentext text="Made with tscircuit" layer="bottom"
pcbX={13.5} pcbY={0.3} fontSize="0.9mm" />
{/* Vertical caution in the marked left-edge strip (board/top coordinates). */}
<silkscreentext text="For evaluation only;" layer="bottom"
pcbX={-18.95} pcbY={1} pcbRotation={270} fontSize="0.85mm" />
<silkscreentext text="not FCC approved for resale" layer="bottom"
pcbX={-20.05} pcbY={1} pcbRotation={270} fontSize="0.85mm" />
{/* Large port labels stay visible beside the USB-C shells. */}
<silkscreentext text="DATA" pcbX={-13.73} pcbY={19.35} fontSize="1.8mm" isKnockout knockoutPadding="0.18mm" />
<silkscreentext text="PWR" pcbX={14.1} pcbY={19.35} fontSize="1.8mm" isKnockout knockoutPadding="0.18mm" />
<silkscreentext text="RP2040 NEMA17" pcbX={0} pcbY={20} fontSize="0.8mm" />
</group>
{/* Explicit source joins also give the MCU sheet the same net labels. */}
<trace name="LABEL_STEP" from=".MCU > .U1 > .GPIO18" to="net.DRIVER_STEP" schDisplayLabel="DRIVER_STEP" />
<trace name="LABEL_DIR" from=".MCU > .U1 > .GPIO19" to="net.DRIVER_DIR" schDisplayLabel="DRIVER_DIR" />
<trace name="LABEL_RESET" from=".MCU > .U1 > .GPIO20" to="net.DRIVER_RESET" schDisplayLabel="DRIVER_RESET" />
<trace name="LABEL_ENABLE" from=".MCU > .U1 > .GPIO22" to="net.MCU_ENABLE" schDisplayLabel="MCU_ENABLE" />
<trace name="LABEL_TEMP_SDA" from=".MCU > .U1 > .GPIO26_ADC0" to="net.TEMP_SDA" schDisplayLabel="TEMP_SDA" />
<trace name="LABEL_TEMP_SCL" from=".MCU > .U1 > .GPIO27_ADC1" to="net.TEMP_SCL" schDisplayLabel="TEMP_SCL" />
<FeedbackSection />
<CurrentTelemetrySection />
<StatusLedSection />
<ProductionTestPoints />
<OptionalEncoderSection />
<Drv8825ThermalCopper />
<ChipDescriptions />
<PdVoltageControlSection />
</board>
);
}
