MustafaMulla29/rp2040-bldc-motor-controller

Hardware assembly metadata and PCB geometry for a controller board with a snap-off rotary-encoder section, plus four parallel 150 µF/50 V bulk electrolytic capacitors filtering the motor supply.

Version
2.0.40
License
unset
Stars
0

Use with the tscircuit CLI

tsci is the tscircuit CLI. Install it with npm install -g tscircuit.

tsci clone MustafaMulla29/rp2040-bldc-motor-controller  # download the package files into ./rp2040-bldc-motor-controller
tsci add MustafaMulla29/rp2040-bldc-motor-controller    # add it to your project as @tsci/MustafaMulla29.rp2040-bldc-motor-controller

In a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.

scripts/export-hardware-review.mjs

/** Export native engineering-review files; no order, publication, or production qualification. */
import {readFileSync,writeFileSync,mkdirSync} from 'node:fs'
import {spawnSync} from 'node:child_process'
import {createHash} from 'node:crypto'
import {resolve} from 'node:path'
import {zipSync,strToU8} from 'fflate'
import {runAllChecks} from '@tscircuit/checks'
const input='dist/index/circuit.json',raw=readFileSync(input),c=JSON.parse(raw)
const errors=[...c.filter(x=>x.type.endsWith('_error')),...(await runAllChecks(c)).filter(x=>x.type.endsWith('_error'))]
if(errors.length)throw new Error(`Refusing fabrication export: ${errors.length} DRC findings`)
const sha=createHash('sha256').update(raw).digest('hex')
const reports={}
for(const name of ['copper-connectivity','width-audit','route-cleanup','kelvin-audit','usb-routing','layout-quality','jlcpcb-preflight']){
 const bytes=readFileSync(`.tscircuit/review/audit-final/${name}.json`),report=JSON.parse(bytes)
 if(report.sha256!==sha)throw new Error(`Stale ${name}: rerun the independent copper checks`)
 reports[`checks/${name}.json`]=bytes
}
for(const name of ['drc','v2-hardware','review-hardware']){
 const bytes=readFileSync(`.tscircuit/checks/${name}.json`),report=JSON.parse(bytes)
 if((report.sha256??report.circuitSha256)!==sha||report.status!=='PASS')throw new Error(`Stale or failed ${name}`)
 reports[`checks/${name}.json`]=bytes
}
const audit=name=>JSON.parse(reports[`checks/${name}.json`])
if(Object.keys(audit('copper-connectivity').disconnected).length||audit('copper-connectivity').floating.length)throw new Error('Disconnected copper')
if(audit('width-audit').paths.some(p=>!p.pass))throw new Error('Failed width checks')
if(audit('kelvin-audit').status!=='PASS'||audit('usb-routing').failures.length||audit('layout-quality').violations.length)throw new Error('Failed geometry review')
if(Object.keys(audit('jlcpcb-preflight').findings).length||audit('jlcpcb-preflight').missing_mpn.length)throw new Error('Failed fabrication preflight')
function run(args){const r=spawnSync('bun',args,{encoding:'utf8',maxBuffer:20e6});if(r.status!==0)throw new Error((r.stdout??'')+(r.stderr??''));console.log(r.stdout)}
run(['scripts/prepare-assembly.mjs',input,'dist/assembly-review'])
mkdirSync('dist/hardware-review',{recursive:true})
run(['node_modules/.bin/tsci','export',input,'-f','gerbers','-o',resolve('dist/hardware-review/native-gerbers.zip')])
run(['scripts/check-native-stencil.mjs','dist/hardware-review/native-gerbers.zip'])
const files={...reports,'native-gerbers.zip':readFileSync('dist/hardware-review/native-gerbers.zip')}
for(const name of ['bom.csv','cpl-reviewed.csv','orientation-review.json','assembly-scope.csv','native-stencil-review.json','u7-native-paste.png'])files[name]=readFileSync('dist/assembly-review/'+name)
for(const name of ['encoder-and-rearm.md','review-validation.md'])files[name]=readFileSync('docs/'+name)
for(const name of ['review-parts-availability.json','review-parts-availability.csv','stackup.json','stencil-u7.json'])files[name]=readFileSync('manufacturing/'+name)
files['README-FIRST.txt']=strToU8(`ENGINEERING REVIEW ONLY — NOT A PRODUCTION RELEASE\nCircuit SHA-256: ${sha}\nNative tscircuit Gerbers are unmodified. Use the TOP-LEVEL bom.csv and cpl-reviewed.csv, then verify factory-library alignment and stencil processing. The generic BOM and pick_and_place.csv nested inside native-gerbers.zip are not the reviewed assembly files; the native exporter lacks supplier rotation metadata for several parts. No order quantity or purchasing authority is conveyed.\nCatalog stock includes unresolved shortages. OLED supports/header, motor adapters, encoder cable and electrical commissioning remain required; see review-validation.md. Motor firmware stays locked off.\n`)
writeFileSync('dist/hardware-review/review-package.zip',zipSync(files))
console.log('Engineering review package exported; circuit SHA-256 '+sha)