Add enclosure and reference CAD assets
This commit is contained in:
@@ -0,0 +1,168 @@
|
||||
"""RS-15-5 + Heltec WiFi LoRa 32 V4.3.1 enclosure, units mm.
|
||||
Requires CadQuery 2.6+. Run: python build_enclosure.py
|
||||
Source dimensions and assembly limitations are in README.md.
|
||||
"""
|
||||
from pathlib import Path
|
||||
import cadquery as cq
|
||||
import json
|
||||
from math import sqrt
|
||||
OUT=Path(__file__).resolve().parent
|
||||
L,W,H=122.,116.,48.
|
||||
WALL=3.; FLOOR=3.; LID=3.
|
||||
FLANGE_EXTENSION=18.; FLANGE_THICKNESS=4.5
|
||||
MOUNT_HOLE_D=4.5; KEYHOLE_HEAD_D=9.; KEYHOLE_TRAVEL=5.5
|
||||
GLAND_PITCH=1.5; GLAND_DIAMETER=16.; GLAND_DEPTH=6.
|
||||
# Radial FDM clearance: 0.20 mm = 0.40 mm on diameter. Test before full print.
|
||||
THREAD_RADIAL_CLEARANCE=0.20
|
||||
PSU_X,PSU_Y,PSU_Z=46.,13.,8.
|
||||
BOARD_X,BOARD_Y,BOARD_BOTTOM=12.,83.,35.
|
||||
# Hole coordinates relative to PCB left edge / lower edge.
|
||||
BOARD_HOLES=[(16.879,5.7),(45.879,5.7),(16.879,19.7),(45.879,19.7)]
|
||||
LID_HOLES=[(6,6),(116,6),(6,110),(116,110)]
|
||||
CARRIER_HOLES=[(15,80),(65,109)]
|
||||
def box(x,y,z,dx,dy,dz):
|
||||
return cq.Workplane('XY').box(dx,dy,dz,centered=False).translate((x,y,z))
|
||||
def cyl(x,y,z,d,h):
|
||||
return cq.Workplane('XY').circle(d/2).extrude(h).translate((x,y,z))
|
||||
def rr(x,y,z,dx,dy,dz,r):
|
||||
return box(x,y,z,dx,dy,dz).edges('|Z').fillet(r)
|
||||
def xhole(x,y,z,d,length):
|
||||
return cq.Workplane('YZ').circle(d/2).extrude(length).translate((x,y,z))
|
||||
def yhole(x,y,z,d,length):
|
||||
return cq.Workplane('XZ').circle(d/2).extrude(-length).translate((x,y,z))
|
||||
def hexcut(x,y,z,af,h):
|
||||
return cq.Workplane('XY').polygon(6,af/0.8660254038).extrude(h).translate((x,y,z))
|
||||
def gland_thread_tool():
|
||||
# Right-handed, single-start 60-degree metric internal thread, with flat roots.
|
||||
pitch=GLAND_PITCH
|
||||
major=GLAND_DIAMETER/2+THREAD_RADIAL_CLEARANCE
|
||||
minor=major-5*sqrt(3)*pitch/16
|
||||
overlap=.05
|
||||
profile=cq.Workplane('XZ').polyline([
|
||||
(minor-overlap,-3*pitch/8-overlap/sqrt(3)),
|
||||
(major,-pitch/16),(major,pitch/16),
|
||||
(minor-overlap,3*pitch/8+overlap/sqrt(3))]).close()
|
||||
path=cq.Wire.makeHelix(pitch,GLAND_DEPTH+2*pitch,minor)
|
||||
groove=profile.sweep(path,isFrenet=True).translate((0,0,-pitch))
|
||||
cutter=cyl(0,0,-pitch,2*minor,GLAND_DEPTH+2*pitch).union(groove)
|
||||
cutter=cutter.union(cq.Workplane(obj=cq.Solid.makeCone(major+.2,minor,.75)))
|
||||
cutter=cutter.union(cq.Workplane(obj=cq.Solid.makeCone(minor,major+.1,.5)).translate((0,0,GLAND_DEPTH-.5)))
|
||||
return cutter.rotate((0,0,0),(0,1,0),90)
|
||||
thread_tool=gland_thread_tool()
|
||||
# Main shell and full-height wiring divider.
|
||||
base=rr(0,0,0,L,W,H,5).cut(rr(3,3,3,L-6,W-6,H,2))
|
||||
base=base.union(box(3,72,3,L-6,3,H-3))
|
||||
# Integral bottom flanges, coplanar with the floor for flat printing.
|
||||
# Both keyhole necks point +Y: orient +Y upward for gravity-assisted hanging.
|
||||
for flange_y,hole_y,entry_y in [(-FLANGE_EXTENSION,-9.,-10.),(W-3,W+9.,W+8.)]:
|
||||
flange=rr(0,flange_y,0,L,FLANGE_EXTENSION+3,FLANGE_THICKNESS,5)
|
||||
for x in [16.,L-16.]:
|
||||
flange=flange.cut(cyl(x,hole_y,-1,MOUNT_HOLE_D,FLANGE_THICKNESS+2))
|
||||
slot=cyl(L/2,entry_y,-1,KEYHOLE_HEAD_D,FLANGE_THICKNESS+2)
|
||||
slot=slot.union(box(L/2-MOUNT_HOLE_D/2,entry_y,-1,MOUNT_HOLE_D,KEYHOLE_TRAVEL,FLANGE_THICKNESS+2))
|
||||
slot=slot.union(cyl(L/2,entry_y+KEYHOLE_TRAVEL,-1,MOUNT_HOLE_D,FLANGE_THICKNESS+2))
|
||||
base=base.union(flange.cut(slot))
|
||||
# Lid pilots: M3 plastic-tapping screw or carefully hand-tapped M3.
|
||||
for x,y in LID_HOLES:
|
||||
base=base.union(cyl(x,y,3,10,H-3))
|
||||
base=base.cut(cyl(x,y,H-12,2.7,13))
|
||||
# PSU underside holes: 39.1 pitch; max 3 mm screw intrusion.
|
||||
psu_holes=[(PSU_X+8.75,PSU_Y+25.25),(PSU_X+47.85,PSU_Y+25.25)]
|
||||
for x,y in psu_holes:
|
||||
base=base.union(cyl(x,y,3,12,PSU_Z-3))
|
||||
base=base.cut(cyl(x,y,-1,3.6,PSU_Z+2))
|
||||
# Support pads prevent rocking; contact metal base only.
|
||||
for x in [PSU_X+3,PSU_X+57]:
|
||||
for y in [PSU_Y+3,PSU_Y+45]:
|
||||
base=base.union(box(x,y,3,3,3,PSU_Z-3))
|
||||
# Carrier pedestals.
|
||||
for x,y in CARRIER_HOLES:
|
||||
base=base.union(cyl(x,y,3,9,19))
|
||||
base=base.cut(cyl(x,y,12,2.7,11))
|
||||
# Integral 24 mm boss: 6 mm total threaded wall depth, extending inward.
|
||||
base=base.union(xhole(0,49,22,24,GLAND_DEPTH))
|
||||
base=base.cut(thread_tool.translate((0,49,22)))
|
||||
# Matching fit coupon, with its thread horizontal as in the case print.
|
||||
thread_coupon=box(0,-14,0,GLAND_DEPTH,28,30).union(box(0,-14,0,20,28,3))
|
||||
thread_coupon=thread_coupon.cut(thread_tool.translate((0,0,16)))
|
||||
# SMA bulkhead on opposite wall (low voltage bay).
|
||||
base=base.cut(xhole(L-4,94,32,6.5,5))
|
||||
# USB opening sized for plug overmould, not just metal connector. Support locally.
|
||||
base=base.cut(rr(-1,88,33,5,15.4,10,1.5))
|
||||
# DC passage takes a grommet with a nominal 8 mm panel cutout.
|
||||
base=base.cut(yhole(109,71,18,8,5))
|
||||
# Small vertical side vents, only opposite the terminal bank.
|
||||
for y in range(17,65,6):
|
||||
for z in [10,29]:
|
||||
base=base.cut(box(L-4,y,z,5,2,12))
|
||||
# Cable tie anchors are raised blocks with horizontal 5 x 2.5 passages.
|
||||
for x,y in [(24,15),(109,66),(89,103)]:
|
||||
anchor=box(x-4,y-3,3,8,6,5).cut(box(x-2.5,y-4,4.5,5,8,2.5))
|
||||
base=base.union(anchor)
|
||||
# Removable carrier, print plate flat with four small supports upright.
|
||||
carrier=rr(12,77,22,60,36,3,2)
|
||||
for x,y in CARRIER_HOLES:
|
||||
carrier=carrier.cut(cyl(x,y,21,3.4,5))
|
||||
for hx,hy in BOARD_HOLES:
|
||||
x,y=BOARD_X+hx,BOARD_Y+hy
|
||||
carrier=carrier.union(cyl(x,y,25,4.4,BOARD_BOTTOM-25))
|
||||
carrier=carrier.cut(cyl(x,y,21,2.1,BOARD_BOTTOM-20))
|
||||
# M1.6 nut recess open underneath, 3.5 mm AF / 1.5 mm deep.
|
||||
carrier=carrier.cut(hexcut(x,y,21.9,3.5,1.6))
|
||||
# Lid in assembled coordinates, simple face-down print orientation on export.
|
||||
lid=rr(0,0,H,L,W,LID,5)
|
||||
for x,y in LID_HOLES:
|
||||
lid=lid.cut(cyl(x,y,H-1,3.4,5))
|
||||
# Registration tabs avoid tall corner posts and the divider.
|
||||
for x in [22,87]:
|
||||
lid=lid.union(box(x,3.3,H-2,15,1.5,2.1))
|
||||
lid=lid.union(box(x,W-4.8,H-2,15,1.5,2.1))
|
||||
for y in [17,80]:
|
||||
lid=lid.union(box(3.3,y,H-2,1.5,10,2.1))
|
||||
lid=lid.union(box(L-4.8,y,H-2,1.5,10,2.1))
|
||||
# Exhaust slots above the metal PSU body, no slots above its terminals.
|
||||
for x in range(61,106,5):
|
||||
for y in [20,43]:
|
||||
lid=lid.cut(rr(x,y,H-1,2,16,5,0.8))
|
||||
# Two lid options. Windowed version requires a separately fitted clear pane.
|
||||
lid_window=lid.cut(rr(31,87,H-1,25,17,5,1.5))
|
||||
# Recess on underside for a 30 x 22 x 1 mm clear polycarbonate pane.
|
||||
lid_window=lid_window.cut(rr(28.5,84.5,H-.1,30,22,1.2,1.5))
|
||||
# Models used ONLY for clearance checks/preview, never included in print STLs.
|
||||
psu_ref=box(PSU_X,PSU_Y,PSU_Z,62.5,51,28)
|
||||
terminal_ref=box(PSU_X-13,PSU_Y+2,PSU_Z+8,13,47,13)
|
||||
board_ref=box(BOARD_X,BOARD_Y,BOARD_BOTTOM,51.7,25.4,1.56)
|
||||
# PCB underside relief, header pins and screen approximations are explicitly illustrative.
|
||||
screen_ref=box(BOARD_X+15,BOARD_Y+3.3,BOARD_BOTTOM+1.56,33,18.8,5.5)
|
||||
parts={'base':base,'lid_solid':lid,'lid_window':lid_window,'board_carrier':carrier,'M16_thread_test':thread_coupon}
|
||||
report={}
|
||||
for name,part in parts.items():
|
||||
s=part.val(); assert s.isValid(),name+' invalid'
|
||||
assert len(s.Solids())==1,name+' not one solid'
|
||||
printable=part
|
||||
if name.startswith('lid'):
|
||||
printable=part.rotate((0,0,0),(1,0,0),180).translate((0,W,H+LID))
|
||||
elif name=='board_carrier': printable=part.translate((0,0,-22))
|
||||
cq.exporters.export(printable,str(OUT/(name+'.stl')),tolerance=0.03,angularTolerance=0.12)
|
||||
cq.exporters.export(part,str(OUT/(name+'.step')))
|
||||
b=printable.val().BoundingBox()
|
||||
report[name]={'valid':True,'solids':1,'volume_mm3':round(s.Volume(),2),'print_bounds_mm':[round(b.xlen,3),round(b.ylen,3),round(b.zlen,3)],'print_zmin':round(b.zmin,5)}
|
||||
# Pairwise exact solid intersections (touching surfaces permitted).
|
||||
for a,b in [('base','lid_solid'),('base','lid_window'),('base','board_carrier'),('board_carrier','lid_solid')]:
|
||||
vol=parts[a].intersect(parts[b]).val().Volume()
|
||||
report[a+' vs '+b]={'intersection_mm3':round(vol,7)}
|
||||
assert vol<1e-5,(a,b,vol)
|
||||
for name,ref in [('PSU',psu_ref),('terminals',terminal_ref),('PCB',board_ref),('screen',screen_ref)]:
|
||||
for pname in ['base','board_carrier','lid_solid']:
|
||||
vol=parts[pname].intersect(ref).val().Volume()
|
||||
report[pname+' vs '+name]={'intersection_mm3':round(vol,7)}
|
||||
assert vol<1e-5,(pname,name,vol)
|
||||
assy=cq.Assembly(name='RS15_Heltec_V4_housing')
|
||||
for name in ['base','board_carrier','lid_solid']:
|
||||
assy.add(parts[name],name=name,color=cq.Color(0.24,0.32,0.39) if name=='base' else cq.Color(0.8,0.84,0.85))
|
||||
assy.save(str(OUT/'housing_assembly.step'))
|
||||
(OUT/'validation.json').write_text(json.dumps(report,indent=2))
|
||||
# Cache original shapes for deterministic previews without rebuilding.
|
||||
for name,part in {**parts,'psu_reference':psu_ref,'terminal_reference':terminal_ref,'board_reference':board_ref,'screen_reference':screen_ref}.items():
|
||||
part.val().exportBrep(str(OUT/(name+'.brep')))
|
||||
print(json.dumps(report,indent=2))
|
||||
Reference in New Issue
Block a user