imrishabh18/nema-23-stepper-controller
A 4-layer NEMA23 stepper-motor controller PCB combining an RP2040 MCU, DRV8452 dual-winding driver, USB-C PD power input, eFuse/TVS protection, current sensing, temperature/enable interlocks, status LEDs, buzzer, and optional magnetic encoder.
- Version
- 1.3.4
- License
- unset
- Stars
- 1
scripts/check-heatsink-clearance.mjs
import {readFileSync,writeFileSync} from 'node:fs'
import assert from 'node:assert/strict'
const json=JSON.parse(readFileSync('dist/index/circuit.json','utf8'))
const part=name=>{
const source=json.find(e=>e.type==='source_component'&&e.name===name)
return json.find(e=>e.type==='pcb_component'&&e.source_component_id===source.source_component_id)
}
const driver=part('DRIVER'),bulk=part('C_BULK')
const circle=json.find(e=>e.type==='pcb_courtyard_circle'&&e.pcb_component_id===bulk.pcb_component_id)
const outline=json.find(e=>e.type==='pcb_courtyard_outline'&&e.pcb_component_id===driver.pcb_component_id).outline
const segmentDistance=(p,a,b)=>{
const dx=b.x-a.x,dy=b.y-a.y
const t=Math.max(0,Math.min(1,((p.x-a.x)*dx+(p.y-a.y)*dy)/(dx*dx+dy*dy||1)))
return Math.hypot(p.x-a.x-t*dx,p.y-a.y-t*dy)
}
const separation=Math.min(...outline.map((a,i)=>segmentDistance(circle.center,a,outline[(i+1)%outline.length])))-circle.radius
assert.ok(separation>=6,`Bulk capacitor crowds driver: ${separation} mm between assembly courtyards`)
const thermalVias=json.filter(e=>e.type==='pcb_via'&&Math.abs(e.outer_diameter-.6096)<1e-6&&Math.abs(e.hole_diameter-.3048)<1e-6&&Math.abs(e.x-driver.center.x)<=2.501&&Math.abs(e.y-driver.center.y)<=1.001)
assert.equal(thermalVias.length,18,'Driver thermal-via array changed')
const movedNames=['C_BULK','D_TVS','R_BLEED','R_ILIM','TP_VMOTOR','TP_PD_GND']
const report={checkedAt:new Date().toISOString(),status:'passed',driverCenter:driver.center,bulkCenter:bulk.center,bulkCourtyardDiameterMm:circle.radius*2,driverToBulkCourtyardGapMm:separation,driverThermalVias:thermalVias.length,placements:Object.fromEntries(movedNames.map(name=>[name,part(name).center])),heatsinkSizeSpecified:false,notes:['More room for a top-mounted heatsink; this is not approval of an unspecified heatsink footprint or mounting method.','Driver bypass capacitors remain close to their pins. Check heatsink base height and electrically insulating thermal interface against these low components and the IC leads.','Mounting screws, clips or dedicated heatsink holes have not been added.']}
writeFileSync('checks/heatsink-clearance.json',JSON.stringify(report,null,2)+'\n')
console.log(`PASS: ${separation.toFixed(2)} mm between driver and bulk-capacitor assembly courtyards; all 18 driver thermal vias retained.`)