-
Notifications
You must be signed in to change notification settings - Fork 5
/
rack.scad
402 lines (384 loc) · 14.4 KB
/
rack.scad
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
/*
**
** Rack Module
**
*/
// Generic computer rack by using mounting plates that can support any small computer boards
//
// Author: Steven Nemetz
//
// Current version GitHub: https://github.com/snemetz/OpenSCAD-Modules/tree/master/cluster-rack
// Thingiverse Customizable: http://www.thingiverse.com/thing:1538381
/*
REVISION HISTORY
v0.3 Add modular connectors
v0.2 Add cutout designs and cutout controls
v0.1 Initial working version
*/
// TODO:
// Future ideas:
// known board/hd U heights
// see about designing to not need support
// modular with clips: 1 side holes, 1 side clips - do for side & top/bottom
// options: either, both, none. Only clips/holes for ends
// Create cable managements clips and/or clip strips. Adjustable sizes for different amounts of cables
// possible to add another hole on bottom side of back if needed
//
// build: 10 x 4 or 5 x 2 x4
// START CUSTOMIZER DATA
// What to print?
PrintDesign = "Rack"; // [Rack, ClipCenter: Clip Center, ClipEnd:Clip End]
// Number of rack slots
Slots = 2; // [1:12]
SlotHeight = 28.5; // Space between slots or space including slot
// Add slot to allow units to connect to each other
Modular = true; // [true, false]
/* [Mount Plate Info] */
// Length
PlateX = 112;
// Width
PlateY = 80;
// Thickness
PlateZ = 1.5;
// Standoff posts height
PostHeight = 5;
/* [Info on what is mounted on plate] */
/* [Case Designs] */
// Left side cutout design
LeftDesign = "Open"; // [Open, Grid, Honeycomb, Solid, Voronoi]
// Length: only applies to Open design
LeftLength = 85;
// Right side cutout design
RightDesign = "Open"; // [Open, Grid, Honeycomb, Solid, Voronoi]
// Length: only applies to Open design
RightLength = 85;
// Back cutout design
BackDesign = "Open"; // [Open, Grid, Honeycomb, Solid, Voronoi]
// Top and Bottom End cutout design
EndDesign = "Solid"; // [Grid, Honeycomb, Solid, Voronoi]
/* [Hidden] */
Ledge = 4;
Wall = 2;
BackWall = Wall*2;
Designs = [LeftDesign, BackDesign, RightDesign, EndDesign];
DesignLens = [LeftLength, RightLength];
PlateDim = [PlateX, PlateY, PlateZ];
BoardHeight = 18; // RPiB+
//U = BoardHeight + wall + PlateZ + PostHeight; // + headroom
// 18 + 1.5 + 5 = 24.5 // Board + plate height
// + wall*2 = 28.5
//preview[view:east, tilt:top]
//port_height=11;
//port_len=61;
// END CUSTOMIZER DATA
use <../patterns/design-patterns.scad>;
// Design Cutouts
// Parameters
// design : design name
// width : design width
// length : design length
// thickness : design thickness
module design(design, width, length, thickness) {
//echo(str("D:",design,"\tW:",width,"\tL:",length,"\tT:",thickness));
if (design == "Open") {
cube([width, length, thickness]);
} else if (design == "Grid") {
translate([width/2, length/2, 0])
gridCutout(width, length, 6, 1.8, thickness);
} else if (design == "Honeycomb") {
translate([width/2, length/2, 0])
honeycombCutout(width, length, 6, 1.2, thickness);
} else if (design == "Voronoi") {
translate([width/2, length/2, 0])
voronoiCutout(width, length, thickness);
}
}
module connectorSlot() {}
// Parameters: wall thickness,
// TODO: change all to vars & Parameters & calc
module connectorClip(x,y,z) {
thickness = 2;
union(){
// back support - will be on solid wall, but might need to make thicker
translate([0, 0, -z*1.5+thick/2])
cube(size=[thickness, y, z*3]); // z too much
//translate([0,y/2,0]) rotate ([0,90,0]) cylinder(h=z/2,r=y/2);
// wall thickness to clip
cube(size=[x, y, thickness]);
// height of clip end
translate([x, 0, 0])
cube(size=[thickness, y, z]);
// slant end for easier insertion
translate([x, 0, z]) resize([thickness, y, thickness])
rotate([180, -90, 90])
linear_extrude(height=1)
polygon([[0, 0], [0, 2.0], [1.5, 2.0]]);
}
}
module dovetail(width=9, height=10, male=true) {
w= (male==true) ? width*0.975 : width;
translate([2.4, 0, 0])
union(){
rotate([0, 0, -30])
translate([-w/2, -sqrt(3)*w/6, -height/2])
linear_extrude(height=height)
polygon(points=[[0,0],[w,0],[w/2,sqrt(3)*w/2]]);
translate([-4.5, 0, 0])
cube([4.2, width*1.5, height], center=true);
}
}
//clip(7,20,20);
// Redo all calc if use. Need absolute sizing
// Create a rack end
// TODO:
// module clips (hole/clip) to connect cases together
// force design to Solid if clips are selected
// look at possible connector designs
// clip, lego, external clips (might be best - like CD drawers), slide joint(dovetail?)
// Add space on ends to give space for modular connectors
// union difference cube (same size as end) cube (center cutout just leave 4 edges)
// Parameters
// plateDim : [x, y, z]
// wall : wall thickness
// backWall : back wall thickness
// ledge : rack slide width
// tolerance : printer tolerance gap to ensure smooth sliding
// design : design name
module rackEnd(plateDim, wall, backWall, ledge, tolerance, design) {
difference () {
// clip = wall*2 // don't be relative to wall
cube([plateDim[1]+2*wall+tolerance, plateDim[0]+wall*2+backWall, wall]);
translate([wall+ledge, 2*wall, -0.001])
design(design, plateDim[1]-2*ledge, plateDim[0], 2*wall);
}
}
module modularSpacer(plateDim, wall, backWall, ledge, tolerance, height) {
// create 4 sides to match walls
// FIX: front wall too thick (4mm? reduce to 2 or 3?) - done
// TODO: reduce hieght of front wall or remove ?
// TEMP: +/- 4 to remove front during testing
difference () {
cube([plateDim[1]+2*wall+tolerance, plateDim[0]+wall*2+backWall, height]); // z = spacer height
translate([wall, wall-4, -0.001])
cube([plateDim[1]+tolerance, plateDim[0]+2*wall+4, height*2]); // z = spacer height *2
}
}
// Create the top half of the rack slide
// Parameters
// plateDim : [x, y, z]
// ledge : rack slide width
// wall : wall thickness
// backWall : back wall thickness
// left : Is this the left side? (Boolean)
module rack_slide_top(plateDim, ledge, wall, backWall, left) {
// TODO: make thicker or widther top slide to make flex clip stronger
// TODO: reduce clip height. sm size sykinder but merge higher into slide
// now doesn't lock in enough - Make stick out more wall/2 -> wall/3 ??
// clip = wall*2 // r = wall // don't be relative to wall
cutWidth = 0.5;
cutLen = 30;
offsetCut = (left) ? 0 : ledge-cutWidth;
offsetClip = (left) ? cutWidth : 0;
union() {
difference() {
cube([ledge, plateDim[0]+wall*2+backWall, wall+1]);
// cut slot, so end can flex
translate([offsetCut, -0.01, -0.01])
cube([cutWidth, cutLen, wall+1.02]);
}
// Add end clip
translate([offsetClip, wall, wall/3]) rotate([90,0,90])
difference() {
// height = flex clip width
cylinder(r=wall, h=ledge-cutWidth, center=false, $fn=50);
translate([-wall, -0, -0.01])
cube([wall*2, wall*2, wall*4]);
}
}
}
// Create 1 unit of a rack case
// Parameters
// plateDim : [x, y, z]
// wall : wall thickness
// backWall : back wall thickness
// uHeight : height of 1 unit
// ledge : rack slide width
// tolerance : printer tolerance gap to ensure smooth sliding
// designs : Vector of design names [left, back, right, ends]
// designLens: [left, right]
module rack1U(plateDim, wall, backWall, uHeight, ledge, tolerance=0.25, designs, designLens) {
// back is wall*3
// TODO: Reduce wall thickness by wall
//boardLen = 85; //Rpi 92 //BPi
//portHeight = 12; // cacl same as back height
postHeight = 5;
minSlideGap = 2.15;
gap = (plateDim[2]+tolerance < minSlideGap) ? minSlideGap - plateDim[2] : tolerance;
clip = wall*2;
union() {
difference(){
// 1 U block
cube([plateDim[1]+2*wall+tolerance, plateDim[0]+clip+backWall, uHeight]);
// Main Area cut out. Turn into a tray. No top or front
translate([wall, -0.001, wall])
cube([plateDim[1]+tolerance, plateDim[0]+clip+wall, uHeight]); // why wall*3 ? -> clip
// Floor cut out. Only leave ledge
translate([wall+ledge, -wall, -wall])
cube([plateDim[1]-2*ledge, plateDim[0]+wall*4, 3*wall]); // why wall*4 ? -> clip
// Back cut out
translate([wall+ledge, plateDim[0]+wall*2+0.001, wall+gap+postHeight+plateDim[2]])
rotate([0,-90,-90])
design(designs[1], uHeight-gap-wall-postHeight, plateDim[1]-ledge*2, 2*backWall);
// FIX: lower sides & back slightly and increase height- Reduce by 1?
// Right cut out
rightLen = (designs[2] == "Open") ? designLens[1] : plateDim[0];
translate([plateDim[1]+2*wall+1, plateDim[0]-rightLen+clip+wall, wall+plateDim[2]+gap+postHeight])
rotate([0,-90,0])
design(designs[2], uHeight-gap-wall-postHeight, rightLen, 2*wall);
// Left cut out
leftLen = (designs[0] == "Open") ? designLens[0] : plateDim[0];
translate([wall+0.001, plateDim[0]-leftLen+clip+wall, wall+plateDim[2]+gap+postHeight])
rotate([0,-90,0])
design(designs[0], uHeight-gap-wall-postHeight, leftLen, 2*wall);
}
// Add slides with flex clip ends to hold plate
translate([wall, 0, gap+wall+plateDim[2]])
rack_slide_top(plateDim, ledge, wall, backWall, true);
translate([wall+plateDim[1]+tolerance-ledge, 0, gap+wall+plateDim[2]])
rack_slide_top(plateDim, ledge, wall, backWall, false);
}
}
// Cut slots for modular connection clips
// Parameters
// plateDim : [x, y, z]
// wall : wall thickness
// backWall : back wall thickness
// clip : [clipLen, clipHeight, clipWall]
// tolerance : side wall tolerance
// top : is placement of slots for top or bottom?
module modularSlots(plateDim, wall, backWall, clip, tolerance, top) {
// TODO: fix exact placement
// FIX: cut holes slightly deeper - clips don't fit flush
offsetZ = (top) ? wall+clip[1]/2 - tolerance : -clip[1]/2 + tolerance;
// Side Modular Slots
// FIX: sides are 1mm short - Check after not rotate and + 1
// Issue with rotate or printer (z axis accuracy)?
// side slot is now big - need to check if it is 1mm or less
for (x=[-0.001, plateDim[1]+2*tolerance]) {
for (y=[10, plateDim[0]+backWall+2*wall-10-clip[0]]) {
translate([x, y, offsetZ])
cube([clip[2]+wall, clip[0]+tolerance+0.5, clip[1]]);
}
}
/* for (x=[wall+clip[2]-0.001, plateDim[1]+wall+clip[2]+2*tolerance]) {
for (y=[10, plateDim[0]+backWall+2*wall-10-clip[0]]) {
translate([x, y, offsetZ]) rotate([0, 0, 90])
cube([clip[0]+tolerance, clip[2]+wall, clip[1]]); // x needs to be larger on sides than end for some reason
// maybe change dim instead of rotate?
}
}*/
// Back Modular Slots
for (x=[10, plateDim[1]+wall*2+tolerance*2-clip[0]-10]) {
translate([x, plateDim[0]+backWall+wall-clip[2], offsetZ]) // Fix y calc reduce slightly
cube([clip[0]+tolerance, (clip[2]+wall)*2, clip[1]]);
}
}
// Create a rack case
// Parameters
// plateDim : [x, y, z]
// wall : wall thickness
// backWall : back wall thickness
// slots : number of rack slots
// slotHeight: height of 1 unit
// ledge : rack slide width
// designs : Vector of design names [left, back, right, ends]
// designLens: [left, right]
// ADD: modular
// TODO:
// add spacing at ends for clip space - create module for
// match top wider part of clip depth = clipHeight/2
// add cutouts for clips - if using external clips
// 12.5 from end X, 5 from end y
// cut 12.1 x (clipLen+tolerance), clipHeight/2 z - match top wider part of clip depth
module rack(plateDim, wall, backWall, slots, slotHeight, ledge, designs, designLens, modular) {
tolerance = 0.25;
clipHeight = 8;
clipLen = 11.5;
clipWall = 1.8;
clip = [clipLen, clipHeight, clipWall];
translate([])
difference() {
union() {
rackEnd(plateDim, wall, backWall, ledge, tolerance, designs[3]);
translate([0,0,wall])
modularSpacer(plateDim, wall, backWall, ledge, tolerance, clipHeight);
}
if (modular) modularSlots(plateDim, wall, backWall, clip, tolerance, false);
}
translate([0,0,wall+clipHeight])
for(i=[1:slots]){
translate([0,0,(i-1)*slotHeight])
rack1U(plateDim, wall, backWall, slotHeight, ledge, tolerance, designs, designLens);
}
translate([0,0,slots*slotHeight+wall+clipHeight])
difference() {
union() {
modularSpacer(plateDim, wall, backWall, ledge, tolerance, clipHeight);
translate([0,0,clipHeight])
rackEnd(plateDim, wall, backWall, ledge, tolerance, designs[3]);
}
if (modular) modularSlots(plateDim, wall, backWall, clip, tolerance, true);
}
}
// External clips
module clipEndWall(clipLen, clipHeight, clipWall) {
// add bumb to end to lock in place
// round/slant top edge for easier insert ?
rotate ([90,0,0])
difference() {
cube([clipLen, clipHeight, clipWall]);
translate([clipLen, 5, -0.001]) rotate([0,0,45]) cube(5);
}
}
module clipEnd(clipLen=11.5, clipHeight=8, clipWall=1.8, caseWall=2, center=false) {
clipWidth = caseWall*2 + clipWall*2;
centerCut = (center) ? 1 : 2;
// sides
translate([0,clipWall,0]) clipEndWall(clipLen, clipHeight, clipWall);
translate([0,clipWidth,0]) clipEndWall(clipLen, clipHeight, clipWall);
// top - 2
difference() {
cube([clipLen, clipWidth, clipHeight / 2]); // z ? clipHeight / 2 = 4 ~ (1.925) 4.15 ?
// Cut center
translate([1.4, clipWall+caseWall*0.25, centerCut])
cube([clipLen, caseWall*1.5, clipHeight]);
// Cut end
translate([clipLen-0.7, clipWall+caseWall*0.25, -0.7])
rotate([0,-45,0])
cube([caseWall*3, caseWall*1.5, caseWall*3]);
}
}
module clipCenter(caseWall) {
clipWall = 1.8;
clipWidth = caseWall*2+clipWall*2;
rotate([0,-90,0])
clipEnd(caseWall=caseWall, center=true);
translate([0, clipWidth, 0])
rotate([0,-90,180])
clipEnd(caseWall=caseWall, center=true);
}
// Customizer code
if (PrintDesign == "ClipCenter") {
clipCenter(Wall);
} else if (PrintDesign == "ClipEnd") {
clipEnd(caseWall=Wall);
} else if (PrintDesign == "Rack") {
// rotate to make printable
// fix to account for added modularSpacer
//translate([(Slots*SlotHeight)/2,-(PlateDim[1]+2*Wall)/2,PlateDim[0]+BackWall+Wall*2])
//rotate([-90,0,90])
rack(PlateDim, Wall, BackWall, Slots, SlotHeight, Ledge, Designs, DesignLens, Modular);
} else {
echo("ERROR: unknown design to print");
}
// END