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.
enclosure/export-3mf.py
"""Portable geometry-only 3MF; no printer/filament profile or slicing assumptions."""
from pathlib import Path
import json,zipfile,xml.etree.ElementTree as E
import trimesh
p=Path(__file__).parent/'dist'
assert json.loads((p/'mechanical-verification.json').read_text())['status']=='PASS'
ns='http://schemas.microsoft.com/3dmanufacturing/core/2015/02';E.register_namespace('',ns)
tag=lambda s:'{'+ns+'}'+s
model=E.Element(tag('model'),unit='millimeter',attrib={'xml:lang':'en-US'})
E.SubElement(model,tag('metadata'),name='Title').text='BLDC OLED154 enclosure — original M3 x 5.7 inserts and M3 x 8 PCB screws; physical fit not qualified'
res=E.SubElement(model,tag('resources'));build=E.SubElement(model,tag('build'))
placements={'base':[(70,57)],'lid':[(195,57)],'screen-holder':[(50,140)],'button-plunger':[(90+i*10,140) for i in range(5)],'speed-knob':[(181,140)],'screen-door':[(60,185)]}
for i,(name,positions) in enumerate(placements.items(),1):
mesh=trimesh.load_mesh(p/(name+'.stl'));assert mesh.is_watertight
obj=E.SubElement(res,tag('object'),id=str(i),type='model',name=name);m=E.SubElement(obj,tag('mesh'));vs=E.SubElement(m,tag('vertices'));ts=E.SubElement(m,tag('triangles'))
for x,y,z in mesh.vertices:E.SubElement(vs,tag('vertex'),x=f'{x:.6f}',y=f'{y:.6f}',z=f'{z:.6f}')
for a,b,c in mesh.faces:E.SubElement(ts,tag('triangle'),v1=str(a),v2=str(b),v3=str(c))
for x,y in positions:E.SubElement(build,tag('item'),objectid=str(i),transform=f'1 0 0 0 1 0 0 0 1 {x} {y} 0')
out=p/'bldc-enclosure.3mf'
with zipfile.ZipFile(out,'w',zipfile.ZIP_DEFLATED) as z:
z.writestr('[Content_Types].xml','<?xml version="1.0" encoding="UTF-8"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="model" ContentType="application/vnd.ms-package.3dmanufacturing-3dmodel+xml"/></Types>')
z.writestr('_rels/.rels','<?xml version="1.0" encoding="UTF-8"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Target="/3D/3dmodel.model" Id="rel0" Type="http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel"/></Relationships>')
z.writestr('3D/3dmodel.model',E.tostring(model,encoding='utf-8',xml_declaration=True))
with zipfile.ZipFile(out) as z:
assert z.testzip() is None;r=E.fromstring(z.read('3D/3dmodel.model'));assert len(r.find(tag('build')))==10
print(out)