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-controllerIn 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/check-review-hardware.mjs
/** Check compiled wiring against manufacturer pin tables and exercise the
* interlock's ideal logic. Electrical timing and fault injection need hardware.
*/
import {readFileSync,writeFileSync,mkdirSync} from 'node:fs'
import {createHash} from 'node:crypto'
import assert from 'node:assert/strict'
const input=process.argv[2]??'dist/index/circuit.json'
const raw=readFileSync(input),c=JSON.parse(raw)
const ns=new Map(c.filter(x=>x.type==='source_component').map(x=>[x.source_component_id,x.name]))
const nets=new Map(c.filter(x=>x.type==='source_net').map(x=>[x.subcircuit_connectivity_map_key,x.name]))
const pins=new Map(c.filter(x=>x.type==='source_port').map(x=>[`${ns.get(x.source_component_id)}.${x.pin_number}`,nets.get(x.subcircuit_connectivity_map_key)??null]))
const expected={
'J20.1':'ENC_3V3','J20.2':'GND','J20.3':'ENC_A_EXT','J20.4':'ENC_B_EXT','J20.5':'ENC_Z_EXT','J20.6':'GND','J20.7':'GND',
'F2.1':'V3V3','F2.2':'ENC_3V3','D10.1':'ENC_PULLUP','D10.2':'V3V3',
// TI DCU package: 1A=1, 1Y=7, 2A=3, 2Y=5, 3A=6, 3Y=2.
'U14.1':'ENC_A_FILTER','U14.7':'ENC_A','U14.3':'ENC_B_FILTER','U14.5':'ENC_B',
'U14.6':'ENC_Z_FILTER','U14.2':'ENC_Z','U14.4':'GND','U14.8':'V3V3',
'U5.31':'ENC_A','U5.32':'ENC_B','U5.9':'ENC_Z',
'D9.1':'ENC_A_EXT','D9.2':'ENC_B_EXT','D9.4':'ENC_Z_EXT','D9.5':'ENC_3V3','D9.3':'GND','D9.8':'GND',
'D9.6':null,'D9.7':null,'D9.9':null,'D9.10':null,
// Nexperia SOT505-2 pin table, NOT inferred from symbol placement.
'U15.1':'REARM_CLOCK','U15.2':'V3V3','U15.3':'REARM_INHIBIT','U15.4':'GND',
'U15.5':null,'U15.6':'REARM_RESET_N','U15.7':'V3V3','U15.8':'V3V3',
'U16.1':'GND','U16.2':'REARM_RESET_N','U16.3':'V3V3',
'U17.1':null,'U17.2':'ARM_REQUEST_N','U17.3':'GND','U17.4':'REARM_CLOCK','U17.5':'V3V3',
'SW4.4':'GND','SW4.5':'REARM_RESET_N','SW4.6':null,
'R170.1':'REARM_INHIBIT','R170.2':'REARM_INHIBIT_B','R171.1':'REARM_INHIBIT_B','R171.2':'GND',
'R172.1':'MOTOR_ARM','R172.2':'GND','R173.1':'V3V3','R173.2':'REARM_RESET_N',
'Q9.1':'REARM_INHIBIT_B','Q9.2':'GND','Q9.3':'ARM_BASE',
'R71.1':'MOTOR_ARM','R71.2':'ARM_BASE','Q5.1':'ARM_BASE','Q5.2':'GND','Q5.3':'MCF_DRVOFF',
'Q6.3':'ARM_BASE','R70.1':'MCF_AVDD','R70.2':'MCF_DRVOFF',
}
for(const [i,ch] of ['A','B','Z'].entries()){
expected[`R${160+i}.1`]=`ENC_${ch}_EXT`;expected[`R${160+i}.2`]=`ENC_${ch}_FILTER`
expected[`R${163+i}.1`]='ENC_PULLUP';expected[`R${163+i}.2`]=`ENC_${ch}_FILTER`
expected[`C${160+i}.1`]=`ENC_${ch}_FILTER`;expected[`C${160+i}.2`]='GND'
}
for(const [pin,net] of Object.entries(expected))assert.equal(pins.get(pin),net,pin)
for(const [name,mpn] of [['U14','SN74LVC3G17DCUR'],['U15','74LVC1G74DP-Q100H'],['U16','TLV803SDBZR'],['U17','SN74LVC1G14DBVR'],['J20','S5B-PH-SM4-TB(LF)(SN)'],['F2','BSMD1206-010-60V']])
assert.equal(c.find(x=>x.type==='source_component'&&x.name===name)?.manufacturer_part_number,mpn,name)
// Datasheet truth table: asynchronous reset dominates; D=1 is captured only
// by U17's positive clock edge (= a new physical ARM press).
function latch(){let q=0,lastButton=false;return ({on=true,good=true,button=false,command=false,pd=true})=>{
if(!on||!good)q=0
else if(button&&!lastButton)q=1
lastButton=button
return Boolean(on&&good&&q&&command&&pd)
}}
const scenarios={
startup:[[{},false],[{command:true},false],[{command:true,button:true},true]],
quickOffOn:[[{command:true,button:true},true],[{command:true,button:false},true],[{on:false,command:true},false],[{command:true},false]],
knobZeroCannotRearm:[[{button:true,command:true},true],[{on:false},false],[{},false],[{command:true},false],[{},false],[{command:true},false]],
heldButtonCannotRearm:[[{button:true,command:true},true],[{on:false,button:true,command:true},false],[{button:true,command:true},false],[{command:true},false],[{button:true,command:true},true]],
pressWhileOff:[[{on:false,button:true},false],[{on:true,button:true,command:true},false],[{button:false,command:true},false],[{button:true,command:true},true]],
brownout:[[{button:true,command:true},true],[{good:false,command:true},false],[{good:true,command:true},false],[{button:true,command:true},true]],
independentMcuAndPdDisable:[[{button:true,command:true},true],[{command:false},false],[{command:true,pd:false},false]],
}
for(const [name,steps] of Object.entries(scenarios)){const apply=latch();for(const [state,want] of steps)assert.equal(apply(state),want,name)}
// Check the review's physical gate-routing requirement in compiled copper.
const sourceTraceNames=new Map(c.filter(x=>x.type==='source_trace').map(x=>[x.source_trace_id,x.name]))
const gateConnections=Array.from({length:6},(_,i)=>{
const name=`gate_direct_${i}`
const traces=c.filter(x=>x.type==='pcb_trace'&&sourceTraceNames.get(x.source_trace_id)===name)
assert.equal(traces.length,1,`${name}: one direct physical path required`)
const route=traces[0].route
assert.ok(route.every(p=>p.route_type==='wire'&&p.layer==='top'&&p.width>=0.4),`${name}: top-only 0.4 mm copper required`)
const lengthMm=route.slice(1).reduce((sum,p,j)=>sum+Math.hypot(p.x-route[j].x,p.y-route[j].y),0)
assert.ok(lengthMm<=3,`${name}: resistor-to-MOSFET path exceeds 3 mm`)
return {from:`R${90+2*i}.2`,to:`Q${10+i}.G`,lengthMm,layer:'top',vias:0,minimumWidthMm:0.4}
})
const report={status:'PASS',input,sha256:createHash('sha256').update(raw).digest('hex'),checkedPins:Object.keys(expected).length,logicScenarios:Object.keys(scenarios),
gateConnections,
limitation:'Ideal logic and compiled connectivity only. Reset pulse timing, contact bounce, brownout, EMC and live motor behavior require bench qualification.'}
mkdirSync('.tscircuit/checks',{recursive:true});writeFileSync('.tscircuit/checks/review-hardware.json',JSON.stringify(report,null,2)+'\n');console.log(JSON.stringify(report,null,2))