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/spring-connector.test.ts
import {test,expect} from 'bun:test';
import {readFileSync} from 'node:fs';
test('WAGO lever terminal has four isolated motor potentials and the eight manufacturer-specified solder tails',()=>{
const j:any[]=JSON.parse(readFileSync(process.env.CIRCUIT_JSON_PATH??'dist/index/circuit.json','utf8'));
const sc=j.find(e=>e.type==='source_component'&&e.name==='J1');
expect(sc.manufacturer_part_number).toBe('2601-1104');
const pc=j.find(e=>e.type==='pcb_component'&&e.source_component_id===sc.source_component_id);
const holes=j.filter(e=>e.type==='pcb_plated_hole'&&e.pcb_component_id===pc.pcb_component_id);
expect(holes).toHaveLength(8);
expect(holes.every(h=>h.hole_diameter===1.2&&h.outer_diameter===2.2)).toBe(true);
expect([...new Set(holes.map(h=>Number(h.x.toFixed(6))))].sort((a,b)=>a-b)).toEqual([13.4,18.4]);
const ys=[...new Set(holes.map(h=>Number(h.y.toFixed(6))))].sort((a,b)=>a-b);
for(let i=1;i<ys.length;i++)expect(ys[i]-ys[i-1]).toBeCloseTo(3.5,8);
const parent=new Map<string,string>();
const root=(x:string):string=>{if(!parent.has(x))parent.set(x,x);if(parent.get(x)!==x)parent.set(x,root(parent.get(x)!));return parent.get(x)!};
for(const e of j){const ids=e.type==='source_trace'?[...e.connected_source_port_ids,...e.connected_source_net_ids]:e.type==='source_component_internal_connection'?e.source_port_ids:[];for(const p of ids.slice(1))parent.set(root(p),root(ids[0]));}
const port=(n:number)=>j.find(e=>e.type==='source_port'&&e.source_component_id===sc.source_component_id&&e.pin_number===n);
const nets=[1,2,3,4].map(n=>root(port(n).source_port_id));
expect(new Set(nets).size).toBe(4);
for(let n=1;n<=4;n++)expect(root(port(n+4).source_port_id)).toBe(nets[n-1]);
const ground=j.find(e=>e.type==='source_net'&&e.name==='GND');
expect(nets.includes(root(ground.source_net_id))).toBe(false);
});