imrishabh18/nema-23-stepper-controller
A 57 mm four-layer RP2040 NEMA23 stepper-controller PCB with USB‑C/USB‑PD power input, protected motor rail, DRV8452 dual-winding driver, bidirectional current sensing, temperature/enable interlock, optional magnetic encoder, RGB LED and buzzer status indicators, and motor/test connectors.
- Version
- 1.2.3
- License
- unset
- Stars
- 0
scripts/regenerate-routing.mjs
import { spawnSync } from "node:child_process"
import { Circuit } from "tscircuit"
import { createElement } from "react"
import { writeFileSync, mkdirSync } from "node:fs"
import Board from "../index.circuit"
import { runAllChecks } from "@tscircuit/checks"
// Regenerate routing rather than weakening the saved-route fingerprint.
const circuit = new Circuit()
let expectedInput
circuit.on("autorouting:start", (e) => { expectedInput = e.simpleRouteJson; console.log("Routing started") })
circuit.add(createElement(Board, {routingAlgorithm:null}))
await circuit.renderUntilSettled()
const json = circuit.getCircuitJson()
mkdirSync("dist/index", {recursive:true})
writeFileSync("dist/index/circuit.json", JSON.stringify(json, null, 2))
const traces = json.filter((e) => e.type === "pcb_trace" && e.connection_name).map((e) => {
const {source_trace_id, subcircuit_id, ...trace} = e
return trace
})
writeFileSync("dist/routing-draft.json", JSON.stringify({expectedInput, traces}, null, 2))
const errors = json.filter(e => e.type.endsWith("_error"))
console.log(JSON.stringify(errors, null, 2))
if (errors.length) throw new Error(`Routing has ${errors.length} errors. Draft not promoted.`)
// An asynchronous core checker can throw without adding a circuit error record.
// Independently await all checks; exceptions and error records prevent promotion.
const independentErrors=(await runAllChecks(json)).filter(e=>e.type.endsWith('_error')||e.type==='error')
if(independentErrors.length)throw new Error(JSON.stringify(independentErrors,null,2))
const powerAudit = spawnSync('bun', ['scripts/check-power-layers.mjs', 'dist/index/circuit.json'], {stdio:'inherit'})
if(powerAudit.error || powerAudit.status !== 0) throw powerAudit.error ?? Error('Outer-layer power policy failed. Draft not promoted.')
writeFileSync("routing/route-plan.json", JSON.stringify({expectedInput, traces}, null, 2))
console.log("Saved fresh routing. Run independent shorts and connectivity checks before release.")