summaryrefslogtreecommitdiff
path: root/box/box.scad
blob: 13ce38afefd4dfedf3b01095da589008efe56bcc (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
IN = 25.4;
origin_x = 3.85 * IN;
origin_y = 4.85 * IN;

include <YAPPgenerator_v14.scad>

// Overrides

//-- which half do you want to print?
printBaseShell      = true;
printLidShell       = true;

//-- Edit these parameters for your own board dimensions
wallThickness       = 1.6;
basePlaneThickness  = 1.6;
lidPlaneThickness   = 1.6;

//-- Label depths
baseLabelDepth      = 0.4;
lidLabelDepth       = 0.4;
leftLabelDepth      = 0.4;
rightLabelDepth     = 0.4;
frontLabelDepth     = 0.4;
backLabelDepth      = 0.4;

//-- Total height of box = basePlaneThickness + lidPlaneThickness 
//--                     + baseWallHeight + lidWallHeight
//-- space between pcb and lidPlane :=
//--      (bottonWallHeight+lidWallHeight) - (standoffHeight+pcbThickness)
baseWallHeight      = 8;
lidWallHeight       = 14.4;

//-- ridge where base and lid off box can overlap
//-- Make sure this isn't less than lidWallHeight
ridgeHeight         = 3.0;
ridgeSlack          = 0.2;
roundRadius         = 3.0;

//-- pcb dimensions
pcbLength           = 2.4 * IN;
pcbWidth            = 1.8 * IN;
pcbThickness        = 1.6;

//-- How much the PCB needs to be raised from the base
//-- to leave room for solderings and whatnot
standoffHeight      = 3.9; //4.3;
pinDiameter         = 2.7;
standoffDiameter    = 6;
                            
//-- padding between pcb and inside wall
paddingFront        = 49.4;
paddingBack         = 0.1;
paddingRight        = 0.1;
paddingLeft         = 0.1;

//-- pcb_standoffs  -- origin is pcb[0,0,0]
// (0) = posx
// (1) = posy
// (2) = { yappBoth | yappLidOnly | yappBaseOnly }
// (3) = { yappHole, YappPin }
pcbStands =    [
    [ 4 * IN - origin_x, -4.7 * IN + origin_y, yappBoth, yappPin ],
    [ 4 * IN - origin_x, -3.2 * IN + origin_y, yappBoth, yappPin ],
    [ 6.1 * IN - origin_x, -3.2 * IN + origin_y, yappBoth, yappPin ],
    [ 6.1 * IN - origin_x, -4.7 * IN + origin_y, yappBoth, yappPin ]
];

//-- Lid plane    -- origin is pcb[0,0,0]
// (0) = posx
// (1) = posy
// (2) = width
// (3) = length
// (4) = angle
// (5) = { yappRectangle | yappCircle }
// (6) = { yappCenter }
cutoutsLid  =   [
    [4.8 * IN - origin_x + 1.27, -4.5 * IN + origin_y, 5, 5, 0, yappCircle]
];

//-- front plane  -- origin is pcb[0,0,0]
// (0) = posy
// (1) = posz
// (2) = width
// (3) = height
// (4) = angle
// (5) = { yappRectangle | yappCircle }
// (6) = { yappCenter }
cutoutsFront =  [
    //[-3.67 * IN + origin_y - 9/2, 0, 9, 3.3, 0, yappRectangle]
];

//-- back plane  -- origin is pcb[0,0,0]
// (0) = posy
// (1) = posz
// (2) = width
// (3) = height
// (4) = angle
// (5) = { yappRectangle | yappCircle }
// (6) = { yappCenter }
cutoutsBack =   [
    [21.96, 0, 15.6, 12.7, 0, yappRectangle],
    [9.3, 0, 9, 11, 0, yappRectangle]
];

//-- snap Joins -- origen = box[x0,y0]
// (0) = posx | posy
// (1) = width
// (2..5) = yappLeft / yappRight / yappFront / yappBack (one or more)
// (n) = { yappSymmetric }
snapJoins   =     [
    [20, 5, yappLeft, yappRight, yappSymmetric]
];

//-- origin of labels is box [0,0,0]
// (0) = posx
// (1) = posy/z
// (2) = orientation
// (3) = plane {lid | base | left | right | front | back }
// (4) = font
// (5) = size
// (6) = "label text"
labelsPlane =   [
    [12, 35, 0, "lid", "Liberation Mono:style=bold", 4, "Square Dishy 150W PoE++"],
    [35, 28, 0, "lid", "Liberation Mono:style=bold", 4, "50V DC" ],
];
                
// Reference board model
translate([pcbX - origin_x, pcbY + origin_y, pcbZ - pcbThickness / 2])
    %import("poe.stl");

// DEBUG    
//showSideBySide      = false;
onLidGap = 0;

module lid_diagrams() {
    translate([12, 27.5, -lidLabelDepth])
        linear_extrude(basePlaneThickness)
            scale([0.15, 0.15, 1])
                import("Polarity_marking_center_positive.svg");
}

module sl_plug() {
    h1 = 36;
    h2 = 3.5;
    h3 = 11;
    h4 = 55.5 - h3;
    d1 = 12;
    d2 = 10;
    d3 = 3.3;
    hull() {
        cylinder(h=h1, d1=d1, d2=d2);
        translate([0, 0, h1])
            cylinder(h=h2, d1=d2, d2=d3);
        translate([0, 5, 0]) {
            cylinder(h=h1, d1=d1, d2=d2);
            translate([0, 0, h1])
                cylinder(h=h2, d1=d2, d2=d3);
        }
    }
    hull() {
        cylinder(h=h4, d=d3);
        translate([0, 5, 0])
            cylinder(h=h4, d=d3);
    }
    translate([13, 15, -h3])
        rotate([0, 0, 90])
            linear_extrude(h3)
                mirror([1, 0, 0])
                    offset(0.2)
                        import("outline.svg");
}

module sl_shell() {
    difference() {
        hull() {
            minkowski() {
                sl_plug();
                sphere(r=2);
            }
            translate([15, 0, 0])
            minkowski() {
                sl_plug();
                sphere(r=2);
            }
        }
        sl_plug();
        translate([-25, -25, -60])
            cube(50);
        translate([-25, -25, 39.8])
            cube(50);
        hull() {
            $fn=16;
            translate([0, -0.35, 0])
                cylinder(h=50, d=3.5);
            translate([0, 5.35, 0])
                cylinder(h=50, d=3.5);
        }
        hull() {
            translate([7, -15, -4.5])
                rotate([90, 0, 45])
                    cylinder(h=10, d=7);
            translate([7, -15, -13])
                rotate([90, 0, 45])
                    cylinder(h=10, d=7);
        }
    }
}

module solidMinkowskiBox(L, W, H, rad, plane, wall)
{
    minkowski() {
        cube([L+(wall*2)-(rad*2), 
            W+(wall*2)-(rad*2), 
            (H*2)+(plane*2)-(rad*2)], 
            center=true);
        sphere(rad);
    }
}


difference() {
    union() {
        YAPPgenerate();
        difference() {
            translate([pcbX + 101, pcbY + origin_y - 3.67 * IN + 5/2, pcbZ + 3.3/2])
                rotate([180, 90, 0])
                    sl_shell();
            difference() {
                cube(400, center=true);
                translate([(shellLength/2), shellWidth/2, (baseWallHeight) + basePlaneThickness]) {
                    $fn=25;
                    solidMinkowskiBox(shellInsideLength, shellInsideWidth, baseWallHeight, 
                     roundRadius, basePlaneThickness, wallThickness);
                }
            }
            translate([0, 0, (baseWallHeight+basePlaneThickness+
                            lidWallHeight+lidPlaneThickness)])
                lidShell();
        }
    }
    
    translate([pcbX + 101, pcbY + origin_y - 3.67 * IN + 5/2, pcbZ + 3.3/2])
        rotate([180, 90, 0])
            sl_plug();

    if (printLidShell) {
        if (showSideBySide) {
            mirror([0,0,1])
            mirror([0,1,0])
            translate([0, (5 + shellWidth+(shiftLid/2))*-2, 0]) {
                lid_diagrams();
                translate([0, 0, -(baseWallHeight+basePlaneThickness+
                                lidWallHeight+lidPlaneThickness+onLidGap)])
                translate([pcbX + 101, pcbY + origin_y - 3.67 * IN + 5/2, pcbZ + 3.3/2])
        rotate([180, 90, 0])
            sl_plug();
            }
        } else {
            translate([0, 0, (baseWallHeight+basePlaneThickness+
                                lidWallHeight+lidPlaneThickness+onLidGap)])
                lid_diagrams();
            translate([pcbX + 101, pcbY + origin_y - 3.67 * IN + 5/2, pcbZ + 3.3/2])
        rotate([180, 90, 0])
            sl_plug();
        }
    }
}