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/pcb-audit/audit-usb.py
"""USB route/reference geometry gate; not an impedance solver or USB certification."""
from pathlib import Path
import collections,hashlib,json,math,os,sys
from shapely.geometry import LineString,Polygon
from shapely import union_all
USB={'USB_DP','USB_DM','MCU_USB_DP','MCU_USB_DM'}
BRIDGES={'layout_J1_7_J1_9','layout_J1_8_J1_10'}
def analyze(c):
nets={r['source_net_id']:r['name'] for r in c if r['type']=='source_net'}
keys={r['subcircuit_connectivity_map_key']:r['name'] for r in c if r['type']=='source_net'}
st={r['source_trace_id']:r for r in c if r['type']=='source_trace'}
planes=[]
for r in c:
if r['type']=='pcb_copper_pour' and r['layer']=='inner1' and nets.get(r['source_net_id'])=='GND':
b=r['brep_shape'];planes.append(Polygon([(v['x'],v['y']) for v in b['outer_ring']['vertices']], [[(v['x'],v['y']) for v in a['vertices']] for a in b.get('inner_rings',[])]))
ground=union_all(planes);fail=[];lengths=collections.defaultdict(float);routes=[];bridges=[]
for r in c:
if r['type']=='pcb_via' and (nets.get(r.get('source_net_id')) or keys.get(r.get('subcircuit_connectivity_map_key'))) in USB:
fail.append({'issue':'USB signal via','id':r['pcb_via_id']})
if r['type']!='pcb_trace':continue
net=nets.get(r.get('connection_name')) or keys.get(st.get(r.get('source_trace_id'),{}).get('subcircuit_connectivity_map_key'))
if net not in USB:continue
rid=r['pcb_trace_id'];routes.append(rid);length=0
for a,b in zip(r['route'],r['route'][1:]):
if a['route_type']!=b['route_type'] or a['route_type']!='wire':continue
line=LineString([(a['x'],a['y']),(b['x'],b['y'])]);length+=line.length
expected=.125 if rid in BRIDGES else .15
if a['layer']!='top' or b['layer']!='top':fail.append({'issue':'USB not entirely on top','id':rid})
if any(abs(q['width']-expected)>1e-6 for q in [a,b]):fail.append({'issue':'USB width changed','id':rid})
# Copper beneath the track plus 0.10 mm on each side must remain continuous.
# This is a geometric guard, not a field-solver return-current calculation.
missing=line.buffer(max(a['width'],b['width'])/2+.1,quad_segs=32).difference(ground)
if missing.area>1e-6:fail.append({'issue':'L2 ground reference gap','id':rid,'uncoveredAreaMm2':missing.area})
lengths[net]+=length
if rid in BRIDGES:
bridges.append({'id':rid,'lengthMm':length,'widthMm':.125})
if length>2.5:fail.append({'issue':'Type-C breakout neck exceeds 2.5 mm','id':rid})
if set(lengths)!=USB:fail.append({'issue':'Missing USB nets','found':sorted(lengths)})
if len(bridges)!=2:fail.append({'issue':'Type-C breakout bridges missing'})
return {'scope':'Top-layer/width/no-via/continuous-L2 geometry only; 90 ohm impedance and USB operation require factory/bench review.',
'failures':fail,'routes':routes,'netCopperLengthMm':dict(lengths),'connectorBridges':bridges,
'referenceLayer':'inner1 GND','referenceCheckExtraWidthEachSideMm':.1,'usbSignalVias':sum(x['issue']=='USB signal via' for x in fail)}
if __name__=='__main__':
path=Path(sys.argv[1] if len(sys.argv)>1 else 'dist/index/circuit.json');raw=path.read_bytes();r=analyze(json.loads(raw))
r['sha256']=hashlib.sha256(raw).hexdigest();out=Path(os.environ.get('PCB_AUDIT_OUTPUT','assembly/dist/results'));out.mkdir(parents=True,exist_ok=True)
(out/'usb-routing.json').write_text(json.dumps(r,indent=2)+'\n');print(json.dumps(r,indent=2));sys.exit(bool(r['failures']))