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
scripts/expand-revision-routes.ts
import { AutoroutingPipelineSolver } from '@tscircuit/capacity-autorouter';
import { readFileSync,writeFileSync } from 'node:fs';
const file=process.argv[2] ?? 'dist/revision/route-plan.json';
const plan=JSON.parse(readFileSync(file,'utf8'));
const input:any=structuredClone(plan.expectedInput);input.traces=structuredClone(plan.traces);
const pipeline=new AutoroutingPipelineSolver(input);
const phase=pipeline.pipelineDef.find(x=>x.solverName==='powerTraceExpansionSolver')!;
const power=process.argv.includes('--power');
const names=input.connections.filter((x:any)=>power ? (x.nominalTraceWidth??0)>=0.5 : (x.nominalTraceWidth??0)>=0.15 && (x.nominalTraceWidth??0)<0.5).map((x:any)=>x.name);
const connectionArg=process.argv.find(arg=>arg.startsWith('--connections='));
if(connectionArg){const requested=new Set(connectionArg.split('=')[1].split(','));names.splice(0,names.length,...names.filter((name:string)=>requested.has(name)));}
const solver=new (phase.solverClass as any)(input,{onlyConnectionNames:names,powerTraceToPadClearance:0.15,allowNewVias:false});
// The default 8M budget rolls back in-flight expansion on this dense four-layer board.
solver.powerTraceExpanderSolver.MAX_ITERATIONS=40_000_000;
solver.MAX_ITERATIONS=40_000_001;
console.log('Expanding',names.length,power?'power':'signal','connections');
let last=Date.now();
while(!solver.solved&&!solver.failed){solver.step();if(Date.now()-last>15000){last=Date.now();console.log(solver.iterations,JSON.stringify(solver.stats));}}
console.log('DONE',solver.solved,solver.error,JSON.stringify(solver.stats));
if(!solver.solved)process.exit(1);
plan.traces=solver.getOutput();
writeFileSync(file,JSON.stringify(plan,null,2));