imrishabh18/rp2040-motor-controller
This circuit integrates a Raspberry Pi RP2040 microcontroller with multiple power management components, USB interface, drivers, sensors (including an AS5600 encoder), protection elements, and various passive and active components to facilitate device control, measurement, and communication.
- Version
- 1.0.18
- 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 { assertCommonGround } from "./helpers/assertCommonGround";
test("NEMA 17 perimeter, 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.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);