ShiboSoftwareDev/nema8-20mm-dual-usbc-stepper-controller
A compact 4-layer USB‑C PD stepper-motor controller PCB using a CH32X035 MCU, TMC2209 driver, dual USB‑C ports, power protection/regulation, ESD/TVS diodes, current-sense resistors, and NEMA‑8 motor connector.
- Version
- 1.0.13
- License
- unset
- Stars
- 0
scripts/search-vio-detour.mjs
import fs from "node:fs"
import { runAllRoutingChecks } from "@tscircuit/checks"
const circuit = JSON.parse(fs.readFileSync("dist/index/circuit.json", "utf8"))
.filter((element) => !String(element.type).endsWith("error"))
const traceId = "source_trace_17__source_trace_18__source_trace_19__source_trace_20__source_trace_21__source_trace_22__source_trace_23__source_trace_24__source_trace_25_mst8_0"
const trace = circuit.find((element) => element.type === "pcb_trace" && element.pcb_trace_id === traceId)
if (!trace) throw new Error("VIO branch not found")
const step = Number(process.env.SEARCH_STEP ?? "0.2")
const minX = Number(process.env.SEARCH_MIN_X ?? "-0.6")
const maxX = Number(process.env.SEARCH_MAX_X ?? "1.4")
const minY = Number(process.env.SEARCH_MIN_Y ?? "3.4")
const maxY = Number(process.env.SEARCH_MAX_Y ?? "5.8")
const candidates = []
for (let x = minX; x <= maxX + 1e-6; x += step) {
for (let y = minY; y <= maxY + 1e-6; y += step) {
const waypoint = { ...trace.route[10], x: Math.round(x * 1000) / 1000, y: Math.round(y * 1000) / 1000 }
const candidate = circuit.map((element) => element.type === "pcb_trace" && element.pcb_trace_id === traceId
? { ...element, route: element.route.map((point, index) => index === 10 ? waypoint : point) }
: element)
const hard = (await runAllRoutingChecks(candidate)).filter((error) => error.type !== "pcb_trace_warning")
candidates.push({ x: waypoint.x, y: waypoint.y, total: hard.length, errors: hard })
}
}
candidates.sort((a, b) => a.total - b.total)
console.log(candidates.slice(0, 20).map(({ x, y, total }) => ({ x, y, total })))
console.log(candidates[0].errors.map((error) => `${error.type}\t${error.message}`).join("\n"))