-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path18650_Project.scad
341 lines (276 loc) · 11.3 KB
/
18650_Project.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
/* ***************************************************************************** *\
18650_Project.scad
-----------------------------------------------------------------------------
Developed by: Richard A. Milewski
Description:
Version: 1.0
Creation Date: 10 Nov 2022
Modification Date: 21 Jan 2023
Email: [email protected]
Copyright ©2022 by Richard A. Milewski
License Mozilla Public License v2.0
\* ***************************************************************************** */
/* ***************************************************************************** *\
NOTES
The variable iwall_fudge may need to be adjusted to account for printer
over or under extrusion. It should be set to provide a snug fit for the pcb.
Decrease it for a tighter fit, increase it to loosen the fit.
\* ***************************************************************************** */
/* ***************************************************************************** *\
CONFIGURATION
\* ***************************************************************************** */
include <BOSL2/std.scad>
part = "box"; // [box, lid, button, window, test]
// Add Charging Indication Window
window = true; // [true, false]
// Batteries are spot welded together
welded = false; // [true, false]
// Show phantom PCB
phPCB = false; // [true, false]
// Show phantom batteries
phBat = false; // [true, false]
battery_count = 4;
battery_spacing = 1;
buffer = 5;
wall = 2;
corner = 8;
iwall_fudge = 1.25;
module hide_variables () {} // variables below hidden from Customizer
$fn = 72;
epsilon = 0.1 ;
2buffer = buffer*2;
battery = [18, 65, 18];
pcb = [30, 53.5, 1.3];
pcb_box = [30, 54, 11.4];
floor = wall;
icorner = corner - wall;
icorner2 = 1.5 * corner; //Non std value to make fillet for screw post
battery_space = [(battery_count * (battery.x + battery_spacing)) + buffer * 2, battery.y + 2 * buffer, battery.z + buffer];
ibox = [pcb.x + wall + battery_space.x, battery_space.y, battery_space.z];
battery_center = [ibox.x/2 - battery_space.x/2, 0, buffer + battery.z/2];
box = [ibox.x + wall * 2, ibox.y + wall * 2, ibox.z];
stacker = [box.x, box.y, buffer];
screw_post = [6, undef, stacker.z]; // post_dia, undef, post.z
screw_spacing = [ibox.x - wall - 5, ibox.y - wall - 5];
screw_hole = 2.5; //dia
// Key Locations
pcb_lift = floor + 3;
internal_wall_loc = [-ibox.x/2 + pcb.x + wall/2 + iwall_fudge, 0, floor];
pcb_center = [-ibox.x/2 + pcb.x/2, 0, floor + pcb_lift + pcb.z/2];
pcb_ctr_left = pcb_center + [-pcb.x/2 , 0, 0];
pcb_back_left = pcb_ctr_left + [0, pcb.y/2, 0];
pcb_back_left_floor = pcb_back_left + [0, 0, -(pcb_lift + pcb.z/2)];
pcb_front_left = pcb_ctr_left + [0, -pcb.y/2, 0];
pcb_front_left_floor = pcb_front_left + [0, 0, -(pcb_lift + pcb.z/2)];
pcb_top = pcb_center + [0, 0, pcb.z/2];
pcb_bot = pcb_center + [0, 0, -pcb.z/2];
pcb_hole = 1.7;
pcb_post = [5, undef, pcb_lift]; // d, undef, l
pcb_post_rounding = [-3, 1.5]; // rounding1, rounding2
pcb_front_post_loc = pcb_front_left_floor + [11 + pcb_hole/2, 3.5 + pcb_hole/2, 0];
pcb_back_post_loc = pcb_back_left_floor + [13 + pcb_hole/2, -(10.25 + pcb_hole/2), 0];
pcb_support = [4, 4.5, pcb_lift];
pcb_front_support_loc = pcb_front_left_floor + [2, 1.5, 0];
pcb_back_support_loc = pcb_back_left_floor + [2, -1.5, 0];
pcb_right_support = [ 5, 5, pcb_lift];
pcb_right_support_loc = pcb_back_left_floor + [pcb.x - 5, -10, 0];
pcb_stop = [8, 2, pcb_lift + 4];
pcb_front_stop_loc = pcb_front_left_floor + [2, -1.25, 0];
pcb_back_stop_loc = pcb_back_left_floor + [2, 1.25, 0];
// Hole sizes and positions
// usbC and lightning connectors centered under usbA connectors
led = [11, 5, 5];
led_loc = pcb_back_left + [0, -6.85, led.z/2 - 1];
led2 = [4, 17, floor + 2 * epsilon];
led2_loc = pcb_back_post_loc + [0, -(led2.y/2 + 7.5), -floor - epsilon ];
usbA = [10.2, 13.5, 6];
usbAlift = 1.44; //connector height above pcb
usbA_loc1 = pcb_back_left + [0, -14.25 - usbA.y/2, usbA.z/2 + usbAlift];
usbA_loc2 = pcb_front_left + [0, 8 + usbA.y/2, usbA.z/2 + usbAlift];
usbC = [7.5, 9.2, 3.3];
usbC_loc = [usbA_loc1.x, usbA_loc1.y , pcb_bot.z - usbC.z/2];
lightning = [8.73, 10, 3.5];
lightning_loc = [usbA_loc2.x, usbA_loc2.y, pcb_bot.z - lightning.z/2];
buttonhole = [4, 6, 4];
buttonhole_loc = [-ibox.x/2 + 19.5, ibox.y/2, pcb_center.z];
button = [3.5, 3.5, 6.5]; // button.z is doubled in the button() module.
button_support = [8, 8, pcb_lift + 5];
button_support_loc = [-ibox.x/2 + 19.5, pcb_back_left.y + 7, floor];
button_channel = [4.1, 12, 4.1];
button_channel_loc = button_support_loc + [0, 0, pcb_lift - pcb.z] ;
/* ***************************************************************************** *\
Main
\* ***************************************************************************** */
if(part == "box") {
box();
}
if(part == "button") {
button();
}
if(part == "lid") {
lid();
}
if(part == "window") {
window();
}
if(part == "test") {
left_half(s = 200, x = internal_wall_loc.x + 2)
bottom_half(s = 200, z = box.z * .75)
box();
}
/* ***************************************************************************** *\
Modules
\* ***************************************************************************** */
module box() {
color_this("lightgrey") shell();
internal_wall();
if(part != "test") battery_bay();
color_this("dodgerblue") stacker_with_posts(true);
if($preview && part != "test" && phPCB) pcb();
}
module button() {
cuboid([button.x * 2, button.x * 2, 1], rounding = 2, edges = "Z", anchor = BOT);
up(1) cuboid(button, rounding = -0.5, edges = BOT, anchor = BOT);
up(1 + button.z) cuboid(button, rounding = 1.5, edges = TOP, anchor = BOT);
}
module floor() {
cuboid([box.x, box.y, floor], rounding = corner, edges = "Z", anchor = BOT);
}
module shell() {
difference() {
union() {
floor();
up(floor) rect_tube(h = box.z, size = [box.x, box.y],
wall = wall, rounding = corner, irounding = icorner2, anchor = BOT);
}
//shell holes
union() {
color_this("red") {
move(led_loc) xcyl(d = led.z, l = led.x);
if(window) {
move(led2_loc) cuboid(led2, rounding = 1, edges = "Z", anchor = BOT);
}
move(buttonhole_loc) cuboid(buttonhole, rounding = 1, edges = "Y");
move(usbA_loc1) cuboid(usbA, rounding = 1, edges = "X");
move(usbA_loc2) cuboid(usbA, rounding = 1, edges = "X");
move(usbC_loc) cuboid(usbC, rounding = 0.5, edges = "X");
move(lightning_loc) cuboid(lightning, rounding = 0.5, edges = "X");
}
}
}
color_this("dodgerblue") {
difference() {
union () {
move (pcb_front_post_loc)
cyl(h = pcb_post.z, d = pcb_post.x, rounding1 = pcb_post_rounding.x,
rounding2 = pcb_post_rounding.y, anchor = BOT);
move (pcb_back_post_loc)
cyl(h = pcb_post.z, d = pcb_post.x, rounding1 = pcb_post_rounding.x,
rounding2 = pcb_post_rounding.y, anchor = BOT);
}
union() {
move(pcb_back_post_loc) cyl(h=pcb_post.z, d = pcb_hole, anchor = BOT);
move(pcb_front_post_loc) cyl(h=pcb_post.z, d = pcb_hole, anchor = BOT);
}
}
move (pcb_front_support_loc) cuboid(pcb_support, anchor = BOT);
move (pcb_back_support_loc) cuboid(pcb_support, anchor = BOT);
move (pcb_right_support_loc) cuboid(pcb_right_support, rounding = 2, edges = "Z", anchor = BOT);
move (pcb_front_stop_loc) cuboid(pcb_stop, anchor = BOT);
move (pcb_back_stop_loc) cuboid(pcb_stop, anchor = BOT);
difference() {
move (button_support_loc) cuboid(button_support, anchor = BOT);
move (button_channel_loc) color_this("red") cuboid(button_channel, anchor = BOT);
}
}
}
module lid() {
difference () {
floor();
grid_copies(n = 2, spacing = screw_spacing)
cyl(h = screw_post.z, d = screw_hole + 1, anchor = BOT);
}
up(floor) stacker(false);
}
module battery() {
ycyl(d = battery.x, l = battery.y);
}
module battery_bay() {
up(floor){
difference() {
union() {
move([battery_center.x, battery_center.y, floor*2])
ycopies(box.y/2) cuboid([battery_space.x, wall, battery_space.z/2]);
}
union() {
move (battery_center) {
xcopies(battery_spacing + battery.x, n = battery_count)
if (phBat) #battery(); else battery();
if(welded) {
down(battery.z/2)
ycopies(box.y/2) cuboid([battery_space.x - battery.x * 1.5, wall + epsilon, battery_space.z/2], anchor = BOT);
}
}
}
}
}
}
module internal_wall () {
difference() {
move(internal_wall_loc) cuboid([wall, ibox.y, ibox.z + stacker.z], anchor = BOT);
union() {
move(pcb_center) { // Wire pass-through holes
move([pcb.x/2 + wall, pcb.y/2, 6]) xcyl(d = 3, h = 5);
move([pcb.x/2 + wall, -pcb.y/2, 6]) xcyl(d = 3, h = 5);
}
}
}
}
module stacker_with_posts(is_male) { //stacker with screw posts
up(box.z + floor){
difference () {
union() {
stacker(is_male);
grid_copies(n = 2, spacing = screw_spacing)
color_this("white") cyl(h = screw_post.z, d = screw_post.x, rounding1 = screw_post.x/2, anchor = BOT);
}
grid_copies(n = 2, spacing = screw_spacing)
cyl(h = screw_post.z, d = screw_hole, anchor = BOT);
}
}
}
module stacker(is_male) { // Interface ring to stack box
//note non-standard irounding (icorner2) in male stacker to provide screw post fillet.
A = [box.x - 2 * wall/4, box.y - 2 * wall/4];
B = [box.x - 4 * wall/4, box.y - 4 * wall/4];
C = [box.x - 2 * wall, box.y - 2 * wall];
if(is_male) {
rect_tube ( size1 = A, size2 = B, isize = C,
h=stacker.z, rounding = corner, irounding = icorner2); //non-standard irounding
} else {
difference() {
rect_tube(h = stacker.z, size = [stacker.x, stacker.y], wall = wall,
rounding = corner, irounding = icorner, anchor = BOT);
rect_tube(size1 = B, size2 = A, isize = C,
h=stacker.z, rounding = corner, irounding = icorner);
}
}
}
module pcb() {
move(pcb_center) {
if($preview) #cuboid(pcb, anchor = BOT);
}
}
module window() {
/* ******************* IMPORTANT ********************
This part must be printed with transparent filament.
Use 4 perimeters, ZERO infill, ZERO bottom layers
and 4 top layers with a rectilinear top fill pattern.
*/
cuboid (led2 + [2, 2, pcb_lift - floor], anchor = BOT);
up (led2.z + pcb_lift - floor)
cuboid (led2 - [0.1, 0.1, 0], rounding = 1, edges = "Z", anchor = BOT);
}
module echo2(arg) {
echo(str("\n\n", arg, "\n\n" ));
}