summaryrefslogtreecommitdiffstats
path: root/case_v3.2.scad
blob: 365f5d1f68d04b1ae90eefd1263a18c3bcef2ef9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* SPDX-License-Identifier: MIT */
// Copyright (c) 2023 Janne Grunau

// tray style case for Central Scrutinizer v3.2

$fn=60;

// layer resolution for bottom chamfer
lh = 0.1;
// height of the case base
base_h = 1.2;

// height of the case without base
height = 6;
// wall thickness
wt = 1.8;

// Cutouts for USB-C/micro USB connectors
gap_c = 14 + wt;
// make the case symmetric
gap_m = gap_c; //12 + wt;

// M2 tapping bore, assume this approximation works well enough for
// self-"tapping" with regular M2 machine screws.
m2_bore = 1.85; // tapping diameter would be 1.6

// board size
size = [53, 33];
// size of the mounting hole pattern
h_pos = [38.1, 27.9];


module mirror_copy(v = [0, 1, 0]) {
    union() {
        children();
        mirror(v) children();
    }
}

module connector_cutout(width, off=0) {
    mirror_copy() translate([off, off, 0]) union() {
        difference() {
            translate([-wt/2 - 0.1, (width - wt)/4 - off]) square([wt + 0.2, (width - wt) / 2 + 2 * off], center=true);
            translate([-wt/2, (width) / 2 - wt]) square([wt / 2, wt / 2]);
        }
        translate([-wt/2, (width)/2-wt]) circle(d=wt);
        translate([-wt/2, width/2]) difference() {
            translate([-wt/4 - 0.1, -wt/4]) square([wt / 2 + 0.2, wt / 2], center=true);
            circle(d=wt);
        }
    }
}

module standoff(st_h) {
    difference() {
        union() {
            cylinder(d=5, h=st_h);
            translate([0, (size.y - h_pos.y - wt) / 2, st_h / 2]) cube([5, (size.y - h_pos.y) - wt, st_h], center=true);
        }
        cylinder(d=m2_bore, h=st_h + 0.1);
        translate([0, 0, st_h - 0.5]) cylinder(d1=m2_bore, d2=m2_bore + 0.5, h=0.51);
    }
}

union() {
    // main case without bottom
    difference() {
        hull() {
            for (x_pos = [-size.x, size.x], y_pos = [-size.y, size.y]) {
                translate([x_pos / 2, y_pos / 2, 0]) cylinder(r=wt, h=height);
            }
        
        }
        translate([0, 0, height / 2 + 0.049]) {
            translate([0, 0, 0])         cube([size.x, size.y, height+0.1], center=true);
            translate([-size.x/2, 0, 0]) cube([2 * wt + .1, gap_c, height+0.1], center=true);
            translate([ size.x/2, 0, 0]) cube([2 * wt + .1, gap_m, height+0.1], center=true);
        }
    }
    // add rounded corners to usb-c / micro usb cutouts
    mirror_copy() translate([-(size.x + wt) / 2,  gap_c / 2, 0]) cylinder(d=wt, h=height);
    mirror_copy() translate([ (size.x + wt) / 2,  gap_m / 2, 0]) cylinder(d=wt, h=height);

    // add 4 standoffs to mount the Central Scrutinizer board to
    for (xoff = [-h_pos.x, h_pos.x], yoff = [-h_pos.y, h_pos.y])
    {
        translate([xoff/2, yoff/2, 0]) 
        rotate([0, 0, (yoff < 0.0) ? 180 : 0]) standoff(4);
    }
    
    // add case bottom with chamfer and partial cutouts for the usb connectors
    mirror([0, 0, 1])  difference() {
        // base plate with chamfers
        union() for (z_off = [0:lh:base_h]) {
            translate([0, 0, z_off]) linear_extrude(height = lh) hull() {
                lsize = [size.x - z_off, size.y - z_off];
                for (x_pos = [-lsize.x, lsize.x], y_pos = [-lsize.y, lsize.y]) {
                    translate([x_pos / 2, y_pos / 2]) circle(r=wt);
                }
            }
        }
        // chamfered cutouts for usb connectors
        union() for (z_off = [0:lh:base_h]) {
            translate([-size.x/2, 0, z_off]) linear_extrude(height = lh) connector_cutout(gap_c, z_off/2);
            translate([ size.x/2, 0, z_off]) linear_extrude(height = lh) mirror([1,0,0]) connector_cutout(gap_m, z_off/2);
        }
    }
}