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/verify_usb.py

"""USB enclosure checks against the exported cable meshes, not smaller stand-ins.
The library plugs are representative 12 x 6 mm bodies, not purchased cable samples.
"""
import json
import numpy as np
import trimesh
import manifold3d as mf

def box(lo,hi):
 lo=np.asarray(lo,dtype=float);hi=np.asarray(hi,dtype=float)
 return mf.Manifold.cube((hi-lo).tolist(),center=True).translate(((hi+lo)/2).tolist())

def verify_usb(out,solids,pcb,envelopes,check,condition,metric):
 report=json.loads((out/'build-report.json').read_text())
 case=solids['base']+solids['lid']
 scene=trimesh.load(out/'connected-system.glb',force='scene')
 # Same registered CAD-to-PCB transform used by the enclosure viewer.
 transform=np.array([[-1,0,0,0],[0,0,1,0],[0,1,0,0],[0,0,0,1]])
 bodies={};body_bounds={};shells={}
 for name in scene.graph.nodes_geometry:
  if not name.startswith(('USB_PD_CABLE / A-','USB_DATA_CABLE / A-')):continue
  suffix=name.split(' / ')[1]
  if suffix not in ['A-overmold','A-shell','A-strain-relief']:continue
  T,g=scene.graph[name];mesh=scene.geometry[g].copy();mesh.apply_transform(transform@T)
  mesh.merge_vertices() # GLB duplicates vertices at material/normal seams.
  if suffix=='A-overmold':
   condition(name+' mesh is closed',mesh.is_watertight)
   solid=mf.Manifold(mf.Mesh(np.asarray(mesh.vertices,dtype=np.float32),np.asarray(mesh.faces,dtype=np.uint32)))
   condition(name+' solid is valid',solid.status()==mf.Error.NoError)
   check(name+' actual mesh / case',(solid^case).volume())
  else:
   # Shell/strain-relief GLBs contain open seams. Their full outer boxes are a
   # conservative clearance test; do not silently accept invalid mesh booleans.
   condition(name+' measured bounds nonempty',bool(np.all(mesh.extents>0)))
   solid=box(*mesh.bounds)
   check(name+' outer bounds / case',(solid^case).volume())
  cable=name.split(' / ')[0]
  if suffix=='A-overmold':
   bodies[cable]=solid;body_bounds[cable]=mesh.bounds
   condition(cable+' verifies full 12 x 6 mm model, not old 10.4 mm envelope',mesh.extents[1]>=12-1e-4 and mesh.extents[2]>=6-1e-4)
  elif suffix=='A-shell':shells[cable]=mesh.bounds
 condition('Both exported USB cable bodies and shells checked',len(bodies)==2 and len(shells)==2)
 if len(bodies)!=2 or len(shells)!=2:raise ValueError('USB mating meshes missing')
 paths={};allowance=.2;travel=25
 for name,solid in bodies.items():
  lo,hi=body_bounds[name];expanded_lo=lo-allowance;expanded_hi=hi+allowance
  # A single bounding prism contains every position along straight withdrawal.
  sweep_lo=expanded_lo.copy();sweep_lo[0]-=travel
  sweep=box(sweep_lo,expanded_hi);paths[name]=sweep
  for label,obstacle in [('case',case),('PCB',pcb),*[(n,e) for n,e in envelopes.items() if n not in ['J1','J19']]]:
   check(name+' full withdrawal with 0.2 mm allowance / '+label,(sweep^obstacle).volume())
  other=next(k for k in bodies if k!=name)
  other_lo,other_hi=body_bounds[other]
  check(name+' withdrawal / other seated plug with allowance',(sweep^box(other_lo-allowance,other_hi+allowance)).volume())
  # The metal shell may mate inside its own socket; only check its case path.
  shell_lo,shell_hi=shells[name];shell_lo=shell_lo.copy();shell_lo[0]-=travel
  check(name+' shell withdrawal / case',(box(shell_lo-allowance,shell_hi+allowance)^case).volume())
  # Top/bottom grip pads on the part of each body that remains outside the case.
  yy=(lo[1]+hi[1])/2
  for side,z0,z1 in [('top',hi[2],hi[2]+4),('bottom',lo[2]-4,lo[2])]:
   pad=box([-73,yy-3,z0],[-67,yy+3,z1])
   check(name+' external '+side+' grip / case',(pad^case).volume())
   check(name+' external '+side+' grip / other plug',(pad^bodies[other]).volume())
 centres=sorted((a[0][1]+a[1][1])/2 for a in body_bounds.values())
 widths=[a[1][1]-a[0][1] for a in body_bounds.values()]
 gap=centres[1]-centres[0]-sum(widths)/2
 metric('USB nominal gap between two cable bodies',gap,.5-1e-5)
 metric('USB body gap after 0.2 mm per-body allowance',gap-2*allowance,.1-1e-5)
 opening=next(p for p in report['portOpenings'] if p['name']=='USB')
 # Continuous wall under the shared opening, including the former divider line.
 wall=report['body']['x']-report['body']['width']/2
 land=box([wall+1.2,opening['y']-opening['depth']/2+.4,report['design']['floorTop']+.1],
          [wall+report['design']['wall']-.1,opening['y']+opening['depth']/2-.4,opening['bottom']-.1])
 check('USB recess lower wall closed by base tongue',(land-solids['base']).volume())
 return {'sharedOpeningMm':[round(opening['depth'],3),round(opening['top']-opening['bottom'],3)],
  'modeledBodyMm':[12,6],'bodyAllowanceEachSideMm':allowance,'continuousWithdrawalMm':travel,
  'nominalGapBetweenCableBodiesMm':round(gap,3),'gapAfterAllowanceMm':round(gap-2*allowance,3),
  'scope':'Exported representative plug solids, straight swept bounds, simultaneous fit and exterior grip envelopes. Actual cable dimensions, print tolerances and unplug force require a physical fit check; larger overmolds are not qualified.'}