| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381 |
- // ============================================================
- // XIAO ePaper Display Board EE04 — 3D-Printed Case
- // OpenSCAD parametric model
- // ============================================================
- use <ee04.scad>
- use <epd_case.scad>
- /* [Preview] */
- SHOW_BOARD = true;
- SHOW_LID = true;
- SHOW_BASE = true;
- SHOW_PLUNGERS = true;
- SHOW_BATTERY = true;
- SHOW_EPD_CASE = true;
- EXPLODE = 70; // mm to pull lid out in Y- for inspection (try 40)
- /* [Board Dimensions — from EE04 STL] */
- PCB_L = 80.00; // board length (case_x axis)
- PCB_W = 41.22; // board width (case_y axis)
- PCB_T = 1.93; // PCB thickness
- // Component heights measured from PCB bottom face:
- COMP_MAX_Z = 7.29; // tallest component (XIAO module)
- COMP_SIDE_Z = 3.82; // tallest component on +Y wall (buttons, USB-C)
- /* [Sliding Lid] */
- LID_T = 1.5; // lid ceiling thickness
- FLANGE_H = 3.0; // Z height of retention flanges (base + lid); drives lid placement and Y- wall step
- FLANGE_W = FLANGE_H * tan(30); // flange width — 30° from vertical (60° from horizontal), printable without support
- SLIDE_CLEAR = 0.40; // clearance between flange/rib and groove/channel on all mating faces (0.4 mm suits typical FDM tolerances)
- // ---- Y- edge: FPC connector — notch in lid Y+ stop rib ----
- // FPC_NOTCH_W and FPC_SLOT_W match the Z- face opening of epd_case:
- // _fpc_xw = 12.5 + 5.0 = 17.5 mm (cable + 2.5 mm clearance per side)
- // slot Y-extent at z=0: sqrt(_fpc_ro² − (FPC_BEND_R−WALL)²) ≈ 4.1 mm
- // with epd_case defaults: bend_r=4, wall=2, fpc_t=0.3, tol=0.3 → _fpc_ro=4.6
- FPC_NOTCH_W = 17.5; // = _fpc_xw in epd_case (cable 12.5 + 2×2.5 mm clearance)
- FPC_U_T = LID_T; // U-rib arm and bar thickness
- FPC_SLOT_W = 4.1; // ≈ sqrt(_fpc_ro²−(FPC_BEND_R−WALL)²) at epd_case z=0
- // epd_case reference values for alignment (must match epd_case.scad)
- _EPD_CASE_W = 130.0; // case_w in epd_case (DISP_W+2×TOL+2×WALL = 125.4+0.6+4)
- _EPD_CASE_D = 108.14; // case_d in epd_case (max(cav_d+WALL+BEZEL_Y, _bend_my+WALL))
- _EPD_FPC_SLOT_CX = 65.98; // _fpc_x1 + _fpc_xw/2 in epd_case (slot X centre)
- _EPD_FPC_SLOT_Y = 102.0; // BEZEL_Y + DISP_D in epd_case (slot Y- edge)
- /* [Cutout Positions — from STL geometry, PCB-origin-relative] */
- // ---- +Y wall: Sliding power switch ----
- // TODO: measure actual switch body dimensions from STL (as done for USB-C) before next print
- PWR_CX = 10.3; // PCB-relative case_x centre
- PWR_W = 5.0; // slot width
- PWR_H = 2.5; // slot height
- PWR_CZ = 3.8; // height above PCB bottom
- PWR_COVER_T = 0.6; // exterior skin over switch pocket (switch not user-accessible)
- // ---- +Y wall: USB-C port ----
- USBC_CX = 65.65;
- USBC_W = 9.0; // port body width from STL
- USBC_H = 3.22; // port body height from STL
- USBC_CZ = 4.31;
- USBC_CBL_CLEAR = 1.5; // added per side for cable plug + routing clearance
- // ---- +Y wall: 3× user buttons + 1× reset ----
- BTN_CX = [48.4, 39.075, 29.725, 20.425]; // PCB-relative case_x centres
- BTN_D = 2.3; // HOLE_D from hat.scad: PLUNGER_D(2.0) + 2×SLIP_CLEAR(0.15)
- BTN_CZ = 3.85;
- /* [Plunger] */
- PLUNGER_D = 2.0; // body and head diameter — matches button actuator
- FLANGE_D = 2.9; // retention flange OD
- FLANGE_T = 1.2; // flange thickness (axial)
- PLUNGER_HEAD_H = 1.5; // exterior head protrusion past wall face
- /* [Case Parameters] */
- WALL = 2.0; // wall thickness
- FLOOR = 2.0; // base floor thickness (thicker for thread engagement)
- CORNER_R = 2.5; // XY corner fillet radius
- SCREW_D = 3.2; // M3 tap drill diameter
- BOSS_D = 6.0; // PCB standoff boss outer diameter
- BOSS_H = 2.0; // standoff boss height; PCB bottom sits flush on boss top
- /* [Locating Studs] */
- STUD_CLEAR = 0.10; // radial clearance per side — close (non-interference) fit in SLA resin
- STUD_H = PCB_T + 1.0; // stud cylinder height above boss top: through PCB + 1 mm proud
- STUD_R = (SCREW_D - 2*STUD_CLEAR) / 2; // stud pin radius (= cylinder + dome radius)
- /* [PCB Standoff Positions — relative to PCB origin] */
- PCB_BOSS_X1 = 2.5;
- PCB_BOSS_X2 = PCB_L - 2.5;
- PCB_BOSS_Y1 = 2.5;
- PCB_BOSS_Y2 = PCB_W - 2.5;
- /* [Interior Clearances — PCB edge to interior wall face] */
- CLR_XN = 2.0; // X- side
- CLR_XP = 44.0; // X+ side — sized so OUT_L == _EPD_CASE_W (130 − 2×WALL − CLR_XN − PCB_L)
- CLR_YN = 15.0; // Y- side (FPC routing; lid inserts from here)
- CLR_YP = 1.77; // Y+ side: calibrated contact(1.565) + rest clearance(0.20)
- CLR_LID = 3.5; // from tallest component top to lid underside
- BATT_W = 34.5; // 603449 LiPo width (X)
- BATT_D = 51.0; // 603449 LiPo depth (Y)
- BATT_T = 6.3; // 603449 LiPo thickness (Z)
- CLR_BATX = 1.5; // battery X clearance from X+ wall
- CLR_BATY = 1.5; // battery Y clearance from Y+ wall
- /* [Computed] */
- PCB_Z = FLOOR + BOSS_H;
- // Base inner height: floor to lid underside ≈ BASE_H (flange rests on groove floor)
- BASE_INNER_H = BOSS_H + COMP_MAX_Z + CLR_LID;
- BASE_H = FLOOR + BASE_INNER_H;
- PCB_OX = WALL + CLR_XN;
- PCB_OY = WALL + CLR_YN;
- CAV_L = CLR_XN + PCB_L + CLR_XP;
- CAV_W = CLR_YN + PCB_W + CLR_YP;
- OUT_L = CAV_L + 2*WALL;
- OUT_W = CAV_W + 2*WALL;
- LID_H = FLANGE_H + LID_T;
- LID_Y_LEN = CAV_W; // flange length; lid Y+ end stops against Y+ interior wall
- // FPC notch X centre — keeps lid notch aligned with epd_case slot when centred on lid
- FPC_CX = OUT_L/2 - _EPD_CASE_W/2 + _EPD_FPC_SLOT_CX - PCB_OX;
- // U-rib depth — derived so ceiling slot Y aligns with epd_case FPC slot Y
- // (3 = hardcoded rib Y thickness in lid module)
- FPC_U_DEPTH = FPC_U_T - WALL - 3 + (_EPD_CASE_D - _EPD_FPC_SLOT_Y);
- // ============================================================
- // HELPERS
- // ============================================================
- module rounded_box(l, w, h, r) {
- hull()
- for (dx = [r, l-r], dy = [r, w-r])
- translate([dx, dy, 0]) cylinder(r=r, h=h, $fn=32);
- }
- // Standoff boss: screw variant has through-hole; stud variant has locating pin instead.
- // Diagonal (X1,Y1)+(X2,Y2) → studs; (X1,Y2)+(X2,Y1) → screws.
- module pcb_boss(px, py, stud=false) {
- translate([PCB_OX + px, PCB_OY + py, FLOOR]) {
- difference() {
- cylinder(d=BOSS_D, h=BOSS_H + 0.01, $fn=24);
- if (!stud)
- translate([0, 0, -0.1])
- cylinder(d=SCREW_D * 0.7, h=BOSS_H + 0.2, $fn=18);
- }
- if (stud)
- translate([0, 0, BOSS_H]) {
- cylinder(r=STUD_R, h=STUD_H, $fn=24);
- translate([0, 0, STUD_H])
- sphere(r=STUD_R, $fn=24);
- }
- }
- }
- // Button plunger — origin at hole centre on the interior wall face.
- // At rest: flange flush with interior face, head proud of exterior face.
- module plunger() {
- color("orange") union() {
- translate([0, -FLANGE_T, 0])
- rotate([-90, 0, 0])
- cylinder(d = PLUNGER_D, h = FLANGE_T + WALL + PLUNGER_HEAD_H, $fn = 32);
- translate([0, -FLANGE_T, 0])
- rotate([-90, 0, 0])
- cylinder(d = FLANGE_D, h = FLANGE_T, $fn = 32);
- translate([0, WALL, 0])
- rotate([-90, 0, 0])
- cylinder(d = PLUNGER_D, h = PLUNGER_HEAD_H, $fn = 32);
- }
- }
- // ============================================================
- // BASE
- // ============================================================
- module base() {
- color("#004B49") {
- difference() {
- rounded_box(OUT_L, OUT_W, BASE_H, CORNER_R);
- // Interior cavity (open top)
- translate([WALL, WALL, FLOOR])
- cube([CAV_L, CAV_W, BASE_H]);
- // ---- Boss screw holes through 50 % of floor (screw diagonal only) ----
- for (pos = [[PCB_BOSS_X1, PCB_BOSS_Y2], [PCB_BOSS_X2, PCB_BOSS_Y1]])
- translate([PCB_OX + pos[0], PCB_OY + pos[1], FLOOR * 0.5 - 0.1])
- cylinder(d=SCREW_D * 0.7, h=FLOOR * 0.5 + 0.2, $fn=18);
- // ---- +Y wall cutouts ----
- // Sliding power switch pocket — closed exterior face, interior clearance only
- translate([PCB_OX + PWR_CX - PWR_W/2,
- OUT_W - WALL - 0.1,
- PCB_Z + PWR_CZ - PWR_H/2])
- cube([PWR_W, WALL - PWR_COVER_T + 0.1, PWR_H]);
- // USB-C slot
- translate([PCB_OX + USBC_CX - (USBC_W + 2*USBC_CBL_CLEAR)/2,
- OUT_W - WALL - 0.1,
- PCB_Z + USBC_CZ - (USBC_H + 2*USBC_CBL_CLEAR)/2])
- cube([USBC_W + 2*USBC_CBL_CLEAR, WALL + 0.2, USBC_H + 2*USBC_CBL_CLEAR]);
- // 4× button holes (3 user + 1 reset)
- for (bcx = BTN_CX)
- translate([PCB_OX + bcx,
- OUT_W + 0.1,
- PCB_Z + BTN_CZ])
- rotate([90, 0, 0])
- cylinder(d=BTN_D, h=WALL + 0.3, $fn=32);
- // ---- Y- wall step for lid flange clearance ----
- // Remove the full Y- wall above z=BASE_H-FLANGE_H-SLIDE_CLEAR so the lid
- // flanges can enter freely from Y-.
- translate([-0.1, -0.1, BASE_H - FLANGE_H - SLIDE_CLEAR])
- cube([OUT_L + 0.2, WALL + 0.2, FLANGE_H + SLIDE_CLEAR + 0.1]);
- }
- // Standoff bosses (added outside diff so cavity doesn't subtract them)
- pcb_boss(PCB_BOSS_X1, PCB_BOSS_Y1, stud=true); // stud diagonal
- pcb_boss(PCB_BOSS_X2, PCB_BOSS_Y2, stud=true); // stud diagonal
- pcb_boss(PCB_BOSS_X1, PCB_BOSS_Y2, stud=false); // screw diagonal
- pcb_boss(PCB_BOSS_X2, PCB_BOSS_Y1, stud=false); // screw diagonal
- }
- // Lid-retention flanges — right triangles, wide face flush with case top (z=BASE_H),
- // tip pointing down to (WALL, BASE_H-FLANGE_H). Hypotenuse faces down-into-cavity;
- // lid flanges slide underneath it for Z retention.
- color("#2C3863") {
- hull() {
- translate([WALL, WALL, BASE_H - 0.01])
- cube([FLANGE_W, CAV_W, 0.01]);
- translate([WALL, WALL, BASE_H - FLANGE_H])
- cube([0.01, CAV_W, 0.01]);
- }
- hull() {
- translate([OUT_L - WALL - FLANGE_W, WALL, BASE_H - 0.01])
- cube([FLANGE_W, CAV_W, 0.01]);
- translate([OUT_L - WALL - 0.01, WALL, BASE_H - FLANGE_H])
- cube([0.01, CAV_W, 0.01]);
- }
- // Y+ locking flanges — same angled profile as side flanges, in YZ plane;
- // split around FPC notch for cable clearance
- for (seg = [
- [WALL, PCB_OX + FPC_CX - FPC_NOTCH_W/2 - WALL],
- [PCB_OX + FPC_CX + FPC_NOTCH_W/2, OUT_L - WALL - (PCB_OX + FPC_CX + FPC_NOTCH_W/2)]
- ])
- hull() {
- translate([seg[0], OUT_W - WALL - FLANGE_W, BASE_H - 0.01])
- cube([seg[1], FLANGE_W, 0.01]);
- translate([seg[0], OUT_W - WALL - 0.01, BASE_H - FLANGE_H])
- cube([seg[1], 0.01, 0.01]);
- }
- }
- }
- // ============================================================
- // LID (slide-on; enters from Y- face, closes toward Y+)
- // Print upside-down (ceiling on build plate).
- // z=0 = bottom of flanges; z=FLANGE_H = ceiling underside.
- // Flanges sit inside cavity and ride on base retention flange hypotenuses.
- // ============================================================
- module lid() {
- // Flanges: right triangles in XZ; hypotenuse at reciprocal angle to base retention flanges.
- // Wide vertical face at x=WALL+FLANGE_W (inner), tip at bottom-wall-face — same
- // (-FLANGE_W, -FLANGE_H) hypotenuse slope as base flanges so they mate when lid slides in.
- color("#2C3863") {
- // Left (X-) flange — stops at Y+ locking flange inner face
- hull() {
- translate([WALL + FLANGE_W - SLIDE_CLEAR - 0.01, 0, 0])
- cube([0.01, LID_Y_LEN - FLANGE_W + SLIDE_CLEAR, FLANGE_H - SLIDE_CLEAR]);
- translate([WALL + SLIDE_CLEAR, 0, -0.005])
- cube([0.01, LID_Y_LEN - FLANGE_W + SLIDE_CLEAR, 0.01]);
- }
- // Right (X+) flange — stops at Y+ locking flange inner face
- hull() {
- translate([OUT_L - WALL - FLANGE_W + SLIDE_CLEAR, 0, 0])
- cube([0.01, LID_Y_LEN - FLANGE_W + SLIDE_CLEAR, FLANGE_H - SLIDE_CLEAR]);
- translate([OUT_L - WALL - SLIDE_CLEAR - 0.01, 0, -0.005])
- cube([0.01, LID_Y_LEN - FLANGE_W + SLIDE_CLEAR, 0.01]);
- }
- // Interior ribs — 2 mm wide
- translate([WALL + FLANGE_W - SLIDE_CLEAR, 0, 0])
- cube([2.0, LID_Y_LEN - FLANGE_W + SLIDE_CLEAR, FLANGE_H]);
- translate([OUT_L - WALL - FLANGE_W + SLIDE_CLEAR - 2.0, 0, 0])
- cube([2.0, LID_Y_LEN - FLANGE_W + SLIDE_CLEAR, FLANGE_H]);
- // Y+ locking flanges — angled wedge matching side-flange profile; split around FPC notch
- for (seg = [
- [FLANGE_W - SLIDE_CLEAR + 2.0,
- 2+PCB_OX + FPC_CX - FPC_NOTCH_W/2 - (WALL + FLANGE_W - SLIDE_CLEAR + 2.0)],
- [PCB_OX + FPC_CX + FPC_NOTCH_W/2,
- OUT_L - FLANGE_W + SLIDE_CLEAR - 2.0 - (PCB_OX + FPC_CX + FPC_NOTCH_W/2)]
- ]) {
- hull() {
- translate([seg[0], LID_Y_LEN - FLANGE_W + SLIDE_CLEAR - 0.01, 0])
- cube([seg[1], 0.01, FLANGE_H - SLIDE_CLEAR]);
- translate([seg[0], LID_Y_LEN - SLIDE_CLEAR - 0.01, -0.005])
- cube([seg[1], 0.01, 0.01]);
- }
- // Backing rib — 2 mm deep on cavity face of flange, matches side-rib style
- translate([seg[0], LID_Y_LEN - FLANGE_W + SLIDE_CLEAR - 2.0, 0])
- cube([seg[1], 2.0, FLANGE_H]);
- }
- }
- color("#004B49")
- difference() {
- union() {
- // Ceiling plate — matches base footprint (OUT_L × OUT_W) with CORNER_R rounding
- if (!SHOW_EPD_CASE)
- translate([0, -WALL, FLANGE_H])
- rounded_box(OUT_L, OUT_W, LID_T, CORNER_R);
- else
- translate([
- OUT_L/2 - _EPD_CASE_W/2,
- OUT_W - _EPD_CASE_D - WALL,
- LID_T
- ])
- epd_case();
- // Y- lip — same rounded_box profile clipped to the Y- wall zone so the
- // lip corners match the base exterior corners
- intersection() {
- translate([0, -WALL, -SLIDE_CLEAR])
- rounded_box(OUT_L, OUT_W, FLANGE_H + SLIDE_CLEAR, CORNER_R);
- translate([-0.1, -WALL - 0.1, -SLIDE_CLEAR - 0.1])
- cube([OUT_L + 0.2, WALL + 0.2, FLANGE_H + SLIDE_CLEAR + 0.2]);
- }
- }
- // FPC cable slot — from Y+ face of U-rib bottom bar, FPC_SLOT_W toward Y+
- translate([PCB_OX + FPC_CX - FPC_NOTCH_W/2,
- LID_Y_LEN - 3 - FPC_U_DEPTH + FPC_U_T,
- FLANGE_H - 0.1])
- cube([FPC_NOTCH_W, FPC_SLOT_W, LID_T + 0.2]);
- }
- }
- // ============================================================
- // BOARD PLACEMENT
- // EE04() XY-normalises the STL (board left/front at origin).
- // +1.925 corrects for STL native Z (PCB bottom at Z=−1.925) so
- // the PCB bottom face lands exactly at PCB_Z.
- // ============================================================
- module stl_board() {
- translate([PCB_OX, PCB_OY, PCB_Z])
- EE04();
- }
- module battery() {
- if ($preview)
- color("darkgray", 0.85)
- translate([CAV_L - BATT_W - CLR_BATX,
- CAV_W - BATT_D - CLR_BATY,
- FLOOR + 0.01])
- cube([BATT_W, BATT_D, BATT_T]);
- }
- // ============================================================
- // ASSEMBLY
- // ============================================================
- if (SHOW_BASE) base();
- if (SHOW_BATTERY) battery();
- if (SHOW_LID)
- translate([0,
- WALL - EXPLODE,
- BASE_H - FLANGE_H])
- lid();
- if (SHOW_BOARD && $preview) stl_board();
- if (SHOW_PLUNGERS)
- for (bcx = BTN_CX)
- translate([PCB_OX + bcx, OUT_W - WALL, PCB_Z + BTN_CZ])
- plunger();
|