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.

enclosure/measure-reference.py

"""Measure the verified native PCB GLB in PCB-world axes."""
from pathlib import Path
import json,struct,hashlib,os
import numpy as np
ROOT=Path(__file__).parent
layout=os.environ.get('ENCLOSURE_OUTPUT_DIR')=='layout-dist'
OUT=ROOT/'layout-dist' if layout else ROOT/'reference-models'
if layout:
 report=json.loads((OUT/'build-report.json').read_text())
 b=(ROOT/report['pcbInput']).read_bytes();rows=json.loads(b)
 assert json.loads((OUT/'build-report.json').read_text())['pcbSha256']==hashlib.sha256(b).hexdigest()
 data=(OUT/'board.glb').read_bytes()
else:
 b=(ROOT/'../dist/pcb/circuit.json').read_bytes(); rows=json.loads(b)
 prov=json.loads((ROOT/'../assembly/dist/assets/compact-board.provenance.json').read_text())
 assert prov['sha256']==hashlib.sha256(b).hexdigest()
 data=(ROOT/'../assembly/dist/assets/compact-board.glb').read_bytes()
n=struct.unpack_from('<I',data,12)[0];g=json.loads(data[20:20+n]);binary=data[28+n:]
bounds={};detail={}
for node in g['nodes']:
 if 'mesh' not in node:continue
 assert 'rotation' not in node and 'matrix' not in node and 'scale' not in node,node.get('name')
 arrays=[]
 for prim in g['meshes'][node['mesh']]['primitives']:
  a=g['accessors'][prim['attributes']['POSITION']];v=g['bufferViews'][a['bufferView']]
  if not a['count']:continue
  assert a['componentType']==5126
  points=np.ndarray((a['count'],3),np.float32,buffer=binary,offset=v.get('byteOffset',0)+a.get('byteOffset',0),strides=(v.get('byteStride',12),4)).astype(float)
  points+=node.get('translation',[0,0,0]);points=points[:,[0,2,1]];points[:,0]*=-1;arrays.append(points)
 if not arrays:continue
 points=np.concatenate(arrays);bounds[node['name']]={'min':points.min(0).tolist(),'max':points.max(0).tolist()}
 if node['name'] in ['RV1','DISP1']:
  threshold={'RV1':8.7,'SW4':4.7,'DISP1':7.1}[node['name']];top=points[points[:,2]>threshold]
  detail[node['name']]={'above':threshold,'min':top.min(0).tolist(),'max':top.max(0).tolist()}
OUT.mkdir(exist_ok=True)
(OUT/'current-bounds.json').write_text(json.dumps(bounds,indent=2)+'\n')
(OUT/'controls-measurements.json').write_text(json.dumps(detail,indent=2)+'\n')
keep={'pcb_board','pcb_hole','pcb_component','cad_component','source_component'}
(OUT/'reference-board.json' if layout else ROOT/'reference-board.json').write_text(json.dumps([r for r in rows if r['type'] in keep],separators=(',',':'))+'\n')
print(json.dumps(detail,indent=2));print('Measured',len(bounds),'named models')