Better clip-in top mechanism

This commit is contained in:
2026-03-23 19:22:46 +01:00
parent 1486fe13f2
commit 502ea786b0

View File

@@ -1,37 +1,35 @@
"""
IMU Pointer Enclosure — v6
IMU Pointer Enclosure — v8
============================
Fixes from v5 (diagnosed from rendered images):
Changes from v7:
1. BOTTOM HOLE:
v5 built the bottom shell from a full-height box (0→H) then trimmed
at SPLIT_Z. The taper wedge interacted badly with the split cut near
X=0 leaving a hole in the floor. Fix: build bottom outer solid only
to SPLIT_Z height — no trimming step needed, no interaction.
1. SNAP-LOCK JOINT:
Removed the flex notches that were cutting through the tongue (they were
weakening it without providing any positive lock). Replaced with a snap
ridge system: a small rectangular bump is added to the OUTER face of the
tongue on each long side at mid-tongue height. The top-shell groove gets a
matching recess (undercut) so the ridge clicks in when the top is pushed
down. To release, flex the shell sides slightly outward.
2. TOP SHELL WALLS PROTRUDING BELOW SPLIT:
v5 top_outer started at SPLIT_Z but the cavity inside started at
SPLIT_Z + WALL, leaving WALL=3.5mm of solid wall below the groove —
visually protruding past the bottom shell. Fix: the top shell outer
solid starts at SPLIT_Z. The groove is cut starting exactly at SPLIT_Z
so there is zero protrusion below the split line.
2. LARGER BUTTON APERTURE:
BTN_HOLE_R increased from 8 mm → 10 mm (⌀20 mm contact face).
Cap shaft/rim scale accordingly. Makes it much harder to miss the button.
3. BUTTON CAP NOT FLUSH / SITTING PROUD:
Aperture cylinder had arithmetic-derived Z that could miss the top wall
faces after filleting. Fix: aperture runs from Z=SPLIT_Z (well inside
the cavity) all the way to Z=H+2 — brute-force punch, impossible to miss.
4. CAP RIM SITS UNDER OUTER FACE (not above it):
Cap is placed so shaft top = H (flush). Rim hangs BELOW the top face
inside the cavity — correct retention geometry. The cap shaft top is
exactly flush with H. No part of the cap protrudes above H.
3. FOUR SCREW POSTS FOR BUTTON DAUGHTERBOARD:
Previous design had 2 posts only in Y. Replaced with 4 posts in a 2×2
grid centred under the button. Pin pitch 2 mm c-to-c → posts at
(BTN_X ± 1 mm, BTN_CY ± 1 mm). Screw hole ⌀0.9 mm (just under 1 mm),
post OD 4 mm for adequate wall thickness around the hole.
Split joint design:
- Bottom shell has a TONGUE that projects UP from SPLIT_Z.
The tongue is a thin rectangular frame (inner perimeter of the walls).
- Top shell has a matching GROOVE cut into the inside of its lower edge,
starting exactly at SPLIT_Z (the bottom face of the top shell).
- Two flex notches cut through the tongue on the long sides allow snap fit.
- Bottom shell TONGUE projects UP from SPLIT_Z (thin rectangular frame).
- SNAP RIDGE: small box bump on the outer long-side faces of the tongue,
at ~mid tongue height. Ridge stands proud of the tongue outer face by
RIDGE_PROUD (0.4 mm), so the groove wall deflects it inward during
insertion and snaps into RIDGE_RECESS cut into the groove wall.
- Top shell GROOVE cut into the inside of its lower edge.
- RIDGE RECESS: matching pocket cut into the outer face of the groove to
receive the snap ridge.
"""
import FreeCAD as App
@@ -40,7 +38,7 @@ import Part
import math
from FreeCAD import Base
doc = App.newDocument("pointer_v7")
doc = App.newDocument("pointer_v8")
# ─────────────────────────────────────────────────────────────────────────────
# DIMENSIONS
@@ -48,13 +46,12 @@ doc = App.newDocument("pointer_v7")
L = 115.0 # length (X): front=0, back=L
W = 36.0 # width (Y)
H = 22.0 # height (Z): bottom=0, top=H
WALL = 4.5 # wall thickness (+1 mm vs v6 — closes taper floor gap)
WALL = 4.5 # wall thickness
CR = 5.0 # corner fillet radius (vertical edges)
TOL = 0.25 # fit tolerance
# Taper: front of bottom shell is TAPER_RISE mm shorter than back.
# Applied only to the BOTTOM shell (it's where the ergonomic taper lives).
TAPER_RISE = 0.0 # no taper — removed per user request
# Taper: removed per user request
TAPER_RISE = 0.0
TAPER_LEN = 100.0 # unused but kept to avoid NameError
# Split plane
@@ -69,9 +66,13 @@ TONGUE_T = 1.2 # tongue wall thickness
GROOVE_H = TONGUE_H + TOL
GROOVE_T = TONGUE_T + TOL
# Flex notch through tongue (for snap release)
NOTCH_W = 8.0
NOTCH_H = TONGUE_H + 0.5
# Snap ridge on tongue long sides
# Ridge sits on the OUTER face of the tongue (the face against the groove wall)
# at mid-tongue height. The groove wall has a matching recess.
RIDGE_W = 12.0 # length of ridge along X (centred on enclosure)
RIDGE_H = 0.8 # height of the ridge bump
RIDGE_PROUD = 0.4 # how far ridge protrudes beyond tongue outer face
RIDGE_Z_OFF = (TONGUE_H - RIDGE_H) / 2.0 # centres ridge vertically in tongue
# ─────────────────────────────────────────────────────────────────────────────
# IMU BOARD
@@ -99,16 +100,16 @@ BAT_Y = (W - BAT_W) / 2.0
BAT_CLIP_Y = 8.0
# ─────────────────────────────────────────────────────────────────────────────
# BUTTON
# BUTTON — enlarged aperture for easier contact
# ─────────────────────────────────────────────────────────────────────────────
BTN_X = 28.0
BTN_CY = W / 2.0
BTN_HOLE_R = 8.0
CAP_SHAFT_R = BTN_HOLE_R - 0.4 # 0.4 mm radial clearance in hole
CAP_SHAFT_H = WALL # shaft fills top wall → top face flush
CAP_RIM_R = BTN_HOLE_R + 2.0 # 2 mm wider than hole → retention
BTN_HOLE_R = 10.0 # ⌀20 mm — up from ⌀16 mm for easier press
CAP_SHAFT_R = BTN_HOLE_R - 0.4 # 0.4 mm radial clearance
CAP_SHAFT_H = WALL # shaft fills top wall → top face flush
CAP_RIM_R = BTN_HOLE_R + 2.0 # 2 mm wider than hole → retention
CAP_RIM_H = 1.5
NUBBIN_R = 1.8
NUBBIN_R = 2.2 # slightly larger nubbin to match bigger cap
NUBBIN_H = 2.0
# Switch geometry (adjust to match your Omron)
@@ -126,9 +127,14 @@ if PCB_BOT_Z < floor_top_shell + 0.5:
PCB_TOP_Z = PCB_BOT_Z + PCB_T
POST_H = PCB_BOT_Z - floor_top_shell
POST_OD = 4.0; POST_R = POST_OD / 2.0
POST_ID = 1.9; POST_IR = POST_ID / 2.0
POST_SEP = 3.0
# ── Screw posts ──────────────────────────────────────────────────────────────
# 4 posts in a 2×2 grid centred under the button.
# Pin pitch 2 mm c-to-c → offsets ±1 mm in both X and Y from button centre.
POST_OD = 4.0; POST_R = POST_OD / 2.0
POST_ID = 0.9; POST_IR = POST_ID / 2.0 # just under ⌀1 mm
POST_PITCH = 2.0 # 2 mm centre-to-centre
POST_OFFS = POST_PITCH / 2.0 # ±1 mm from centre
BPCB_L = 16.0
BPCB_W = 16.0
@@ -204,10 +210,8 @@ def make_clip(cx, cy, ix, iy):
bot_outer = box(L, W, SPLIT_Z)
bot_outer = fillet_vert(bot_outer, CR, min_len=SPLIT_Z * 0.4)
# Fillet the long horizontal edges the user holds.
# These are the 4 edges running in X at Z≈0 and Z≈SPLIT_Z, on both long sides.
# Same fillet applied to equivalent edges on the top shell later.
EDGE_FILLET = 2.5 # mm — soft and comfortable, visible but not decorative
# Fillet the bottom long horizontal edges (comfort grip)
EDGE_FILLET = 2.5
try:
h_edges = []
for e in bot_outer.Edges:
@@ -217,8 +221,6 @@ try:
dx = abs(v0.X - v1.X)
dz = abs(v0.Z - v1.Z)
dy = abs(v0.Y - v1.Y)
# Long edge in X, horizontal, on a long side face —
# but ONLY at Z≈0 (bottom face). Exclude Z≈SPLIT_Z (the join edge).
z_mid = (v0.Z + v1.Z) / 2.0
if dx > L * 0.5 and dz < 0.5 and dy < 0.5 and z_mid < 1.0:
h_edges.append(e)
@@ -230,33 +232,47 @@ try:
except Exception as exc:
print(f"Bottom shell horizontal fillet skipped: {exc}")
# No taper wedge — removed per user request
# 3. Inner cavity — floor at WALL, ceiling at SPLIT_Z (open top, no ceiling)
# 3. Inner cavity
bot_cav_lx = L - WALL * 2
bot_cav_ly = W - WALL * 2
bot_cav_lz = SPLIT_Z - WALL # floor(WALL) → SPLIT_Z
bot_cav_lz = SPLIT_Z - WALL
bot_inner = box(bot_cav_lx, bot_cav_ly, bot_cav_lz, WALL, WALL, WALL)
bot_shell = bot_outer.cut(bot_inner)
# 4. Tongue (projects UP from SPLIT_Z, inner perimeter frame)
# Outer edge of tongue = inner face of outer wall = WALL from outside
# Inner edge of tongue = WALL + TONGUE_T from outside
t_slab = box(bot_cav_lx, bot_cav_ly, TONGUE_H,
WALL, WALL, SPLIT_Z)
t_cut = box(bot_cav_lx - TONGUE_T*2, bot_cav_ly - TONGUE_T*2, TONGUE_H + 1,
WALL + TONGUE_T, WALL + TONGUE_T, SPLIT_Z - 0.5)
tongue = t_slab.cut(t_cut)
# Flex notches on the two long sides (parallel to X)
nx0 = L / 2.0 - NOTCH_W / 2.0
for ny_start in [WALL, W - WALL - TONGUE_T]:
tongue = tongue.cut(
box(NOTCH_W, TONGUE_T + 0.5, NOTCH_H,
nx0, ny_start - 0.1, SPLIT_Z - 0.1))
# 5. Snap ridges on the tongue outer long-side faces
# The tongue outer face sits at Y=WALL and Y=W-WALL (bottom shell outer wall
# inner face). We add a small proud bump to each long side (the Y faces).
#
# Long sides run in X. The tongue outer face in -Y direction is at Y=WALL,
# outer face in +Y direction is at Y=W-WALL.
#
# Ridge box for -Y side:
# X: centred on L/2, width RIDGE_W
# Y: from (WALL - RIDGE_PROUD) to WALL (proud outward = -Y direction)
# Z: from (SPLIT_Z + RIDGE_Z_OFF) height RIDGE_H
#
# Ridge box for +Y side:
# Y: from (W - WALL) to (W - WALL + RIDGE_PROUD)
#
ridge_x0 = L / 2.0 - RIDGE_W / 2.0
ridge_z0 = SPLIT_Z + RIDGE_Z_OFF
ridge_neg_y = box(RIDGE_W, RIDGE_PROUD, RIDGE_H,
ridge_x0, WALL - RIDGE_PROUD, ridge_z0)
ridge_pos_y = box(RIDGE_W, RIDGE_PROUD, RIDGE_H,
ridge_x0, W - WALL, ridge_z0)
tongue = tongue.fuse(ridge_neg_y).fuse(ridge_pos_y)
bot_shell = bot_shell.fuse(tongue)
# 5. IMU clips
# 6. IMU clips
for cx, cy, ix, iy in [
(BRD_X, BRD_Y, +1, +1),
(BRD_X + BRD_L, BRD_Y, -1, +1),
@@ -265,15 +281,14 @@ for cx, cy, ix, iy in [
]:
bot_shell = bot_shell.fuse(make_clip(cx, cy, ix, iy))
# 6. USB-C slot — starts at X = -WALL*3 so it punches through the rounded
# front face cleanly regardless of fillet radius
# 7. USB-C slot
bot_shell = bot_shell.cut(
rounded_slot(WALL * 6, USBC_W, USBC_H,
-WALL * 3,
W / 2.0 - USBC_W / 2.0,
USBC_Z))
# 7. Battery bay
# 8. Battery bay
bot_shell = bot_shell.cut(box(BAT_L, BAT_W, 3.0, BAT_X, BAT_Y, WALL))
cy0 = BAT_Y + BAT_W / 2.0 - BAT_CLIP_Y / 2.0
bot_shell = bot_shell.fuse(box(2.0, BAT_CLIP_Y, BAT_H * 0.55, BAT_X - 2.0, cy0, WALL))
@@ -288,8 +303,7 @@ top_h = H - SPLIT_Z # = 7.5 mm
top_outer = box(L, W, top_h, 0, 0, SPLIT_Z)
top_outer = fillet_vert(top_outer, CR, min_len=top_h * 0.4)
# Fillet the long horizontal edges of the top shell —
# the top edges (Z≈H) are the ones selected in blue in the user's screenshot.
# Fillet the top long horizontal edges
try:
th_edges = []
for e in top_outer.Edges:
@@ -299,8 +313,6 @@ try:
dx = abs(v0.X - v1.X)
dz = abs(v0.Z - v1.Z)
dy = abs(v0.Y - v1.Y)
# Long edge in X, horizontal, on a long side face —
# ONLY at Z≈H (top face). Exclude Z≈SPLIT_Z (the join edge).
z_mid = (v0.Z + v1.Z) / 2.0
if dx > L * 0.5 and dz < 0.5 and dy < 0.5 and z_mid > H - 1.0:
th_edges.append(e)
@@ -312,20 +324,15 @@ try:
except Exception as exc:
print(f"Top shell horizontal fillet skipped: {exc}")
# 2. Inner cavity: side walls WALL thick, CEILING at H-WALL (WALL-thick roof),
# FLOOR open (starts at SPLIT_Z — nothing blocks the bottom opening).
# Cavity box: X from WALL→L-WALL, Y from WALL→W-WALL, Z from SPLIT_Z→H-WALL
# 2. Inner cavity
top_cav_lx = L - WALL * 2
top_cav_ly = W - WALL * 2
top_cav_lz = top_h - WALL # = 7.5 - 3.5 = 4.0 mm interior height
top_cav_lz = top_h - WALL
top_inner = box(top_cav_lx, top_cav_ly, top_cav_lz,
WALL, WALL, SPLIT_Z) # starts exactly at SPLIT_Z
WALL, WALL, SPLIT_Z)
top_shell = top_outer.cut(top_inner)
# 3. Groove at the bottom of the top shell, starting at SPLIT_Z
# The groove is a frame-shaped recess cut into the inner face of the walls.
# It goes from Z=SPLIT_Z up to Z=SPLIT_Z+GROOVE_H.
# Width = GROOVE_T (slightly wider than tongue).
# 3. Groove at the bottom of the top shell
g_slab = box(top_cav_lx, top_cav_ly, GROOVE_H,
WALL, WALL, SPLIT_Z)
g_cut = box(top_cav_lx - GROOVE_T*2, top_cav_ly - GROOVE_T*2, GROOVE_H + 1,
@@ -333,12 +340,35 @@ g_cut = box(top_cav_lx - GROOVE_T*2, top_cav_ly - GROOVE_T*2, GROOVE_H + 1,
groove = g_slab.cut(g_cut)
top_shell = top_shell.cut(groove)
# 4. Button aperture — brute-force: run cylinder from Z=SPLIT_Z to Z=H+2.
# It will punch through the ceiling regardless of any topology.
# 4. Ridge recess in the groove wall — matches the snap ridges on the tongue.
# The groove outer wall in -Y direction is the inner face of the top shell
# wall at Y=WALL. The recess is cut OUTWARD from the groove wall face,
# i.e. the wall material between groove and outside.
#
# Recess for -Y groove wall face (inner face sits at Y = WALL + GROOVE_T):
# We need to cut from the groove outer face inward.
# The groove outer face (toward -Y) is at Y = WALL.
# Recess: box RIDGE_W wide in X, RIDGE_PROUD + TOL deep in Y (into wall),
# RIDGE_H + TOL tall, at ridge_z0.
#
# Note: the groove wall is only GROOVE_T = 1.45 mm wide; cutting RIDGE_PROUD
# (0.4 mm) + TOL (0.25 mm) = 0.65 mm is well within that.
#
recess_depth = RIDGE_PROUD + TOL
recess_h = RIDGE_H + TOL
recess_z0 = ridge_z0 - TOL / 2.0 # slight vertical oversize for tolerance
recess_neg_y = box(RIDGE_W, recess_depth, recess_h,
ridge_x0, WALL - recess_depth, recess_z0)
recess_pos_y = box(RIDGE_W, recess_depth, recess_h,
ridge_x0, W - WALL, recess_z0)
top_shell = top_shell.cut(recess_neg_y).cut(recess_pos_y)
# 5. Button aperture — brute-force punch through ceiling
top_shell = top_shell.cut(
cyl(BTN_HOLE_R, H - SPLIT_Z + 2, BTN_X, BTN_CY, SPLIT_Z))
# 5. Button PCB shelf frame
# 6. Button PCB shelf frame
shelf_ox = BTN_X - BPCB_L / 2.0
shelf_oy = BTN_CY - BPCB_W / 2.0
shelf_h = 1.5
@@ -351,13 +381,17 @@ shelf = shelf_slab.cut(shelf_hole)
if floor_top_shell < PCB_BOT_Z < H - WALL:
top_shell = top_shell.fuse(shelf)
# 6. Screw posts on top-shell floor
# 7. Four screw posts (2×2 grid) for button daughterboard
# Grid centred at (BTN_X, BTN_CY), 2 mm pitch → offsets ±POST_OFFS
if POST_H > 0.5:
for py in [BTN_CY - POST_SEP/2.0, BTN_CY + POST_SEP/2.0]:
p = cyl(POST_R, POST_H, BTN_X, py, floor_top_shell)
ph = cyl(POST_IR, POST_H + 1.0, BTN_X, py, floor_top_shell)
top_shell = top_shell.fuse(p)
top_shell = top_shell.cut(ph)
for px_off in [-POST_OFFS, +POST_OFFS]:
for py_off in [-POST_OFFS, +POST_OFFS]:
px = BTN_X + px_off
py = BTN_CY + py_off
p = cyl(POST_R, POST_H, px, py, floor_top_shell)
ph = cyl(POST_IR, POST_H + 1.0, px, py, floor_top_shell)
top_shell = top_shell.fuse(p)
top_shell = top_shell.cut(ph)
# ═════════════════════════════════════════════════════════════════════════════
# BUTTON CAP (separate printed part)
@@ -368,14 +402,11 @@ if POST_H > 0.5:
# Nubbin: Z = -CAP_RIM_H-NUBBIN_H → Z = -CAP_RIM_H
#
# Placed so shaft top = H → flush with top face.
# Rim is entirely inside the cavity. No part protrudes above H.
# ═════════════════════════════════════════════════════════════════════════════
cap_shaft = cyl(CAP_SHAFT_R, CAP_SHAFT_H)
cap_rim = cyl(CAP_RIM_R, CAP_RIM_H, 0, 0, -CAP_RIM_H)
cap_nub = cyl(NUBBIN_R, NUBBIN_H, 0, 0, -CAP_RIM_H - NUBBIN_H)
cap_raw = cap_shaft.fuse(cap_rim).fuse(cap_nub)
# No fillet on cap top rim — cap sits flush inside aperture so a fillet
# would create a visible chamfer ring against the hole edge.
cap_placed = cap_raw.copy()
cap_placed.translate(Base.Vector(BTN_X, BTN_CY, H - CAP_SHAFT_H))
@@ -405,7 +436,7 @@ Gui.SendMsgToActiveView("ViewFit")
# SUMMARY
# ═════════════════════════════════════════════════════════════════════════════
print("=" * 62)
print("IMU Pointer v7")
print("IMU Pointer v8")
print("=" * 62)
print(f"Body: {L:.0f} × {W:.0f} mm")
print(f"Height: {H:.0f} mm uniform (no taper)")
@@ -416,15 +447,18 @@ print(f"Top shell interior height: {top_cav_lz:.1f} mm (Z {SPLIT_Z:.1f} → {H
print()
print(f"Tongue H/T: {TONGUE_H:.1f} / {TONGUE_T:.1f} mm")
print(f"Groove H/T: {GROOVE_H:.2f} / {GROOVE_T:.2f} mm")
print(f"Snap ridge: {RIDGE_W:.0f} mm long × {RIDGE_H:.1f} mm tall × {RIDGE_PROUD:.1f} mm proud")
print(f"Ridge recess: {RIDGE_W:.0f} mm long × {recess_h:.2f} mm tall × {recess_depth:.2f} mm deep")
print()
print(f"Button hole: ⌀{BTN_HOLE_R*2:.0f} mm X={BTN_X} Y={BTN_CY:.0f}")
print(f"Button hole: ⌀{BTN_HOLE_R*2:.0f} mm X={BTN_X} Y={BTN_CY:.0f} (was ⌀16 mm)")
print(f"Cap shaft: ⌀{CAP_SHAFT_R*2:.1f} mm × {CAP_SHAFT_H:.1f} mm (flush, Z {H-WALL:.1f}→{H:.1f})")
print(f"Cap rim: ⌀{CAP_RIM_R*2:.0f} mm × {CAP_RIM_H:.1f} mm (retention, below top face)")
print(f"Cap rim: ⌀{CAP_RIM_R*2:.0f} mm × {CAP_RIM_H:.1f} mm (retention)")
print()
print(f"PCB top Z: {PCB_TOP_Z:.2f} mm (above split floor {floor_top_shell:.1f} mm)")
print(f"PCB bot Z: {PCB_BOT_Z:.2f} mm")
print(f"Post H: {POST_H:.2f} mm ⌀{POST_OD:.0f}/{POST_ID:.1f} mm sep={POST_SEP:.0f} mm c-to-c")
print(f"Post H: {POST_H:.2f} mm ⌀{POST_OD:.0f}/{POST_ID:.1f} mm pitch={POST_PITCH:.0f} mm")
print(f"Posts (4×): (BTN_X±{POST_OFFS:.0f}, BTN_CY±{POST_OFFS:.0f})")
print()
print(f"Switch stack: body={SWITCH_BODY_H} + stem={STEM_H} + gap={GAP} mm")
print(" Adjust SWITCH_BODY_H / STEM_H if your Omron differs.")
print("=" * 62)
print("=" * 62)