From 0f0401ed39823a1f0e498f32aa25824893bf9313 Mon Sep 17 00:00:00 2001 From: dakkar Date: Sun, 27 Mar 2022 14:43:32 +0100 Subject: comment and simplify enclosure --- enclosure/enclosure.scad | 160 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 119 insertions(+), 41 deletions(-) diff --git a/enclosure/enclosure.scad b/enclosure/enclosure.scad index 01eddd2..79837cb 100644 --- a/enclosure/enclosure.scad +++ b/enclosure/enclosure.scad @@ -5,109 +5,181 @@ * top, big hole for the screen and small holes for air * board, holds the board and the switch / button / usb / sd holes on - the sides; the co2 sensor probably goes here as well + the sides; the co2 sensor goes here as well * bottom, for battery and pm sensor */ use +// all measurements are in mm + +// thickness of bottom / top / side walls WALL_THICKNESS=1; +/* [Screws] */ +// diameter of the screws; I'm using M4 screws SCREW_DIAM=4; +// extra space between screws and box edges SCREW_PAD=0; - +// length of the bolt's stem, avoids half-empty holes in the bottom BOLT_STEM_Z=24.7; +/* [Particle sensor] */ +// width (connector side - inlet side) PM_X=40.8; +// height PM_Y=40.8; +// depth PM_Z=12.5; +// height of the window for the connector PM_CONN_Y=15.8; -PM_CONN_Z=4; +// depth of the window for the connector, from the top of the sensor PM_CONN_DEPTH=7.7; +/* [Battery] */ +// width (longest dimension) BATT_X=55; +// height BATT_Y=33.5; +// depth (shortest dimension) BATT_Z=10.8; +/* [CO2 sensor] */ +// width (connector side - other side) CO_X=28.5; +// height CO_Y=24.1; +// depth CO_Z=8; +// height of the window for the connector CO_CONN_Y=10; - +// diameter of top holes to let air into the CO2 sensor CO_HOLE_DIAM=2; -CO_HOLE_DIST=CO_HOLE_DIAM + 2; // distance between hole centres +// distance between hole centres +CO_HOLE_DIST=4; -BOT_CABLE_WELL_X=15; // just some space for the battery & pm cables -MID_CABLE_WELL_X=5; // just some space between co2 & board +/* [Cable wells] */ +// width of the space for the battery & pm cables +BOT_CABLE_WELL_X=15; +// width of the space between CO2 sensor & main board +MID_CABLE_WELL_X=5; -BOTTOM_Z=WALL_THICKNESS + PM_Z; -MIDDLE_Z=WALL_THICKNESS + CO_Z; - -DISPLAY_WIN_X=51; -DISPLAY_WIN_Y=26; -DISPLAY_X_OFF=2.5; -DISPLAY_Y_OFF=6.1; - -//PITCH=0.254; don't really care +/* [Main board] */ +// width (longest dimension) BOARD_X=66.5; +// height BOARD_Y=36.8; +// distance between display face and bottom of PCB BOARD_SINK=2.2; -BOARD_PAD=0; - -BOARD_PIN_OFF_X=2.35; BOARD_PIN_DIST_X=61.43; -BOARD_PIN_OFF_Y=2.15; BOARD_PIN_DIST_Y=32.5; - +// width offset of left mounting hole +BOARD_PIN_OFF_X=2.35; +// width distance between left and right mounting hole +BOARD_PIN_DIST_X=61.43; +// height offset of bottom mounting hole +BOARD_PIN_OFF_Y=2.15; +// height distance between bottom and top mounting hole +BOARD_PIN_DIST_Y=32.5; +// diameter of support pillars BOARD_SUPPORT_DIAM=3; +// diameter of mounting holes BOARD_SUPPORT_PIN_DIAM=2; -USB_MICRO_B_X=12; -USB_MICRO_B_Z=5.5; +/* [Display] */ +// width (longest dimension) +DISPLAY_WIN_X=51; +// height +DISPLAY_WIN_Y=26; +// width offset of view window +DISPLAY_X_OFF=2.5; +// height offset of view window +DISPLAY_Y_OFF=6.1; -USB_MICRO_B_SINK=2; +/* [USB hole] */ +// width +USB_MICRO_B_X=12; +// depth +USB_MICRO_B_Z=4.75; +// width distance between left edge of board to middle of USB socket USB_MICRO_B_OFF_X=42.7; +/* [SD space] */ +// width (bit wider than the middle dimension of the SD card) SD_X=12.5; +// height (how much the card protrudes from the PCB) SD_Y=9.5; -SD_Z=1; -SD_SINK=3; +// depth (distance between bottom of PCB and bottom of card) +SD_Z=3.5; +// width distance between left edge of board to middle of SD card SD_OFF_X=54; +/* [On/Off switch hole] */ +// width SWITCH_X=9; +// height (how much the switch protrudes) SWITCH_Y=2; +// depth (distance between bottom of PCB and bottom of switch) SWITCH_Z=4; -SWITCH_SINK=SWITCH_Z/2; +// width distance between left edge of board to middle of switch SWITCH_OFF_X=42.5; +/* [Reset button hole] */ +// width RESET_X=2.5; +// depth (distance between bottom of PCB and bottom of hole) RESET_Z=2; -RESET_SINK=1; +// width distance between left edge of board to middle of button RESET_OFF_X=51; +/* [Other button] */ +// width BUTTON_X=5; -BUTTON_Z=3; -BUTTON_SINK=1; +// depth (distance between bottom of PCB and bottom of hole) +BUTTON_Z=2.5; +// width distance between left edge of board to middle of button BUTTON_OFF_X=58; -TOP_Z=2; - -PILLAR_Y=WALL_THICKNESS*2; +module __Customizer_Limit__ () {} +// we use SWITCH_Y to offset the PCB from the edge, so the height of +// the pillars that partially cover the switch+button holes has to be +// the same +PILLAR_Y=SWITCH_Y; +// fudge factor: the pillars need to be a bit thinner than the holes +// they go into PILLAR_SHRINK=0.05; +// top layer is 2 walls thick, just because +TOP_Z=WALL_THICKNESS*2; +// middle layer needs to hold the CO2 sensor on a wall; the PCB is much thinner +MIDDLE_Z=WALL_THICKNESS + CO_Z; +// bottom layers needs to hold the PM sensor and the battery +BOTTOM_Z=WALL_THICKNESS + max(PM_Z,BATT_Z); + +// width of the whole thing: 2 walls, plus wider of the middle & bottom layers TOTAL_X=2*WALL_THICKNESS + max( PM_X + BOT_CABLE_WELL_X + BATT_X, CO_X + MID_CABLE_WELL_X + BOARD_X ); +// height of the whole thing: 2 walls, plus highest of the middle & bottom layers TOTAL_Y=2*(WALL_THICKNESS + SCREW_DIAM + SCREW_PAD) + max(PM_Y,CO_Y,BOARD_Y,BATT_Y); +// nearly all objects are centered in X&Y, and most are sitting on Z=0 + +// just like a centered cube, but sitting at Z=0 module box(v) { translate([0,0,v[2]/2]) cube(v,center=true); } +/* SCREWS */ + module screw_hole() { cylinder(h=200,d=SCREW_DIAM,center=true,$fs=0.1); } +// this is nearly copied from threads.scad: its ScrewHole subtracts +// the hole from its children, I need a thing that I can subtract +// multiple times from a single object, threads.scad doesn't expose +// that module myScrew(outer_diam, height, position=[0,0,0], rotation=[0,0,0], pitch=0, tooth_angle=30, tolerance=0.4, tooth_height=0) { extra_height = 0.001 * height; @@ -160,6 +232,8 @@ module screw_holes_threaded() { place_screw_holes() screw_hole_threaded(); } +/* all the various modules */ + module pm_sensor() { box([PM_X,PM_Y,PM_Z]); } @@ -198,7 +272,7 @@ module middle_cable_well() { } module board_well() { - cube([ BOARD_X+BOARD_PAD, BOARD_Y+BOARD_PAD, 200], center=true); + cube([ BOARD_X, BOARD_Y, 200], center=true); } module board_support() { @@ -235,16 +309,16 @@ module board_supports() { } module usb_well() { - translate([0,0,-USB_MICRO_B_SINK-USB_MICRO_B_Z/2]) box([USB_MICRO_B_X, 30, 30]); + translate([0,0,-USB_MICRO_B_Z]) box([USB_MICRO_B_X, 30, 30]); } module sd_well() { EXTRA=10; - translate([0,SD_Y/2-EXTRA/2,-SD_SINK-SD_Z/2]) box([SD_X, SD_Y+EXTRA, 30]); + translate([0,SD_Y/2-EXTRA/2,-SD_Z]) box([SD_X, SD_Y+EXTRA, 30]); } module switch_well() { - translate([0,0,-SWITCH_SINK-SWITCH_Z/2]) box([SWITCH_X, 30, 30]); + translate([0,0,-SWITCH_Z]) box([SWITCH_X, 30, 30]); } module switch_pillar() { @@ -254,7 +328,7 @@ module switch_pillar() { } module reset_well() { - translate([0,0,-RESET_SINK-RESET_Z/2]) box([RESET_X, 30, 30]); + translate([0,0,-RESET_Z]) box([RESET_X, 30, 30]); } module reset_pillar() { @@ -264,7 +338,7 @@ module reset_pillar() { } module button_well() { - translate([0,0,-BUTTON_SINK-BUTTON_Z/2]) box([BUTTON_X, 30, 30]); + translate([0,0,-BUTTON_Z]) box([BUTTON_X, 30, 30]); } module button_pillar() { @@ -273,8 +347,8 @@ module button_pillar() { cube([BUTTON_X-PILLAR_SHRINK, PILLAR_Y, H], center=true); } -// these will have matching pillars for the top piece, filling them -// down to the right depth; top piece will be printed upside-down +// these have matching outside_pillars for the top piece, filling them +// down to the right depth; top piece needs to be printed upside-down module outside_wells() { translate([-BOARD_X/2,0,0]) { translate([0,BOARD_Y/2,0]) { @@ -303,6 +377,8 @@ module display_hole() { cube([DISPLAY_WIN_X, DISPLAY_WIN_Y, 30], center=true); } +/* The Layers */ + module bottom() { PM_X_OFF=(TOTAL_X - PM_X)/2; @@ -368,6 +444,8 @@ module top() { } } +/* render! */ + translate([0, TOTAL_Y * 1.2, 0]) bottom(); //translate([0, 0, -BOTTOM_Z-2]) bottom(); -- cgit v1.2.3