astra/nema17-stepper-motor-controller-spring-clamp-rp2040
A 4-layer RP2040 controller board that negotiates USB‑C PD motor power and drives a NEMA17 stepper via a DRV8825, with current sensing, thermal shutdown, RGB status LED, buzzer alarm, optional AS5600 encoder, protection/filtering, and test points.
- Version
- 1.4.0
- License
- unset
- Stars
- 0
tests/nema17-mechanical.test.tsx
import { expect, test } from "bun:test";
import type { AnySourceComponent, PcbComponent, PcbPlatedHole } from "circuit-json";
import { Circuit } from "tscircuit";
import Board from "../index.circuit";
import originalOutline from "../mechanical/nema17-original-outline.json";
import { assertCommonGround } from "./helpers/assertCommonGround";
test("Original NEMA17 outline, four mounting drills and shared ground are preserved", async () => {
const c = new Circuit({platform:{routingDisabled:true}});
c.add(<Board routingDisabled />); await c.renderUntilSettled();
const json=c.getCircuitJson();
const board=json.find(x=>x.type==="pcb_board")!;
expect(board.outline).toEqual(originalOutline);
expect(board.width).toBeCloseTo(42.30,3);
expect(board.height).toBeCloseTo(42.32,3);
expect(board.num_layers).toBe(4);
expect(board.thickness).toBe(1.6);
const mounts=json.filter((x): x is Extract<AnySourceComponent, {type:"source_component"}> =>x.type==="source_component" && /^MH[1-4]$/.test(x.name??""));
expect(mounts).toHaveLength(4);
const centers=mounts.map(m=>{
const pc=json.find((x): x is PcbComponent =>x.type==="pcb_component" && x.source_component_id===m.source_component_id)!;
const hole=json.find((x): x is PcbPlatedHole =>x.type==="pcb_plated_hole" && x.pcb_component_id===pc.pcb_component_id)!;
if (hole.shape !== "circle") throw new Error("Mount must use a circular plated drill");
expect(hole.hole_diameter).toBe(3.3);
expect(hole.outer_diameter).toBe(5.6);
return [pc.center.x,pc.center.y];
}).sort((a,b)=>a[0]-b[0] || a[1]-b[1]);
expect(centers).toEqual([[-15.5,-15.5],[-15.5,15.5],[15.5,-15.5],[15.5,15.5]]);
expect(assertCommonGround(json).groundNetDeclarations).toBe(1);
},60000);