Commit | Line | Data |
---|---|---|
28ef71df CE |
1 | // Threads for acorn model |
2 | // Copyright (c) 2017 Clinton Ebadi <clinton@unknownlamer.org> | |
3 | ||
0cbf5490 | 4 | use <screw_threads.scad> // http://www.thingiverse.com/thing:1686322 |
28ef71df | 5 | |
244fc8f0 | 6 | AUTO_CALCULATE = -1; |
28ef71df | 7 | |
5d6b539a CE |
8 | acorn_parts = [ "body", "cap", "gasket" ]; |
9 | ||
0cbf5490 CE |
10 | internal_thread_tolerance = 0.3; |
11 | external_thread_tolerance = 0.2; | |
12 | thread_angle = 50; | |
28ef71df | 13 | |
5d6b539a CE |
14 | |
15 | function contains (x, lst) = len([ for (i = lst) if (x == i) i]) > 0; | |
16 | ||
244fc8f0 CE |
17 | module acorn (thread_pitch = 3.0, |
18 | thread_size = 2.5, | |
19 | thread_height = 3.5, | |
20 | thread_tooth_height = AUTO_CALCULATE, | |
28ef71df | 21 | |
244fc8f0 CE |
22 | inner_d = 24.5, |
23 | base_height = AUTO_CALCULATE, | |
24 | wall_thickness = AUTO_CALCULATE, | |
25 | outer_d = AUTO_CALCULATE, | |
28ef71df | 26 | |
244fc8f0 CE |
27 | keychain = true) { |
28 | ||
29 | // derived settings | |
30 | wall_thickness = (wall_thickness == AUTO_CALCULATE) ? thread_size : wall_thickness; | |
31 | outer_d = (outer_d == AUTO_CALCULATE) ? inner_d + wall_thickness*2 : outer_d; | |
32 | thread_tooth_height = (thread_tooth_height == AUTO_CALCULATE) ? ((thread_pitch - 0.4 > 0) ? thread_pitch - 0.4 : thread_pitch) : thread_tooth_height; | |
33 | base_height = (base_height == AUTO_CALCULATE) ? inner_d : base_height; | |
34 | ||
35 | ||
36 | module acorn_thread (outer_d = outer_d, internal = false, ring = true) { | |
37 | if (internal) { | |
38 | outer_ring_d = outer_d+max(thread_size, wall_thickness)+1; | |
39 | echo ("outer ring = ", outer_ring_d); | |
40 | ScrewHole (outer_diam=outer_d, height = thread_height, pitch = thread_pitch, tooth_height = thread_tooth_height, tooth_angle = thread_angle, tolerance=internal_thread_tolerance) { | |
41 | if (ring) cylinder (d = outer_ring_d, h = thread_height); | |
42 | } | |
28ef71df | 43 | } |
28ef71df | 44 | |
244fc8f0 CE |
45 | if (!internal) { |
46 | difference () { | |
47 | ScrewThread (outer_diam=outer_d, height = thread_height, pitch = thread_pitch, tooth_height = thread_tooth_height, tooth_angle = thread_angle, tolerance=external_thread_tolerance); | |
48 | cylinder (d = outer_d-wall_thickness-thread_size-0.01, h = thread_height * 4, center=true); | |
49 | } | |
28ef71df CE |
50 | } |
51 | } | |
28ef71df | 52 | |
244fc8f0 CE |
53 | module nut_body (h = base_height, d = outer_d, nub = false) { |
54 | translate ([0 ,0, h]) { | |
55 | intersection () { | |
56 | union () { | |
57 | resize ([d, d, h*2]) sphere (d=h*2); | |
58 | if (nub) { | |
59 | translate ([0, d/2-wall_thickness/2, -thread_height]) sphere (d=wall_thickness*2, $fs = 0.1); | |
60 | } | |
0cbf5490 | 61 | } |
244fc8f0 | 62 | translate ([0 ,0, -h/2]) cube ([d*2, d*2, h], center=true); |
0cbf5490 | 63 | } |
0cbf5490 | 64 | } |
28ef71df | 65 | } |
28ef71df | 66 | |
244fc8f0 CE |
67 | module nut () { |
68 | difference () { | |
69 | nut_body (); | |
70 | translate ([0, 0, wall_thickness + 0.01]) nut_body (d=outer_d-wall_thickness*2, nub=false); | |
71 | } | |
28ef71df | 72 | |
244fc8f0 CE |
73 | translate ([0, 0, base_height-0.1]) acorn_thread (outer_d = outer_d); |
74 | } | |
28ef71df | 75 | |
28ef71df | 76 | |
244fc8f0 CE |
77 | module cap_keychain_holes (hole_d=3, spacing=15 /*12*/) { |
78 | h=100; | |
79 | translate ([-spacing/2, 0, 0]) cylinder (d=hole_d, h=h, $fs=0.1); | |
80 | translate ([spacing/2, 0, 0]) cylinder (d=hole_d, h=h, $fs=0.1); | |
81 | } | |
28ef71df | 82 | |
244fc8f0 CE |
83 | module cap () { |
84 | scale_f = outer_d / 171; | |
85 | difference () { | |
86 | scale ([scale_f, scale_f, scale_f]) { | |
87 | difference () { | |
88 | union () { | |
89 | translate ([0, 0, -1]) import ("Acorn_Unthreaded/cap_reduced.stl"); | |
90 | echo ("h = ", thread_height/scale_f); | |
91 | cylinder (d = 180, h=thread_height/scale_f); | |
92 | } | |
93 | translate ([0, 0, -0.51]) cube ([200, 200, 1], center=true); | |
0cbf5490 | 94 | } |
0cbf5490 | 95 | } |
244fc8f0 CE |
96 | if (keychain) cap_keychain_holes (); |
97 | acorn_thread (internal = true, ring = false); | |
0cbf5490 | 98 | } |
0cbf5490 | 99 | } |
28ef71df | 100 | |
244fc8f0 CE |
101 | module gasket (gasket_height=0.9) { |
102 | cylinder (d = outer_d, h = gasket_height, center=true); | |
28ef71df CE |
103 | } |
104 | ||
244fc8f0 | 105 | module nuts () { |
5d6b539a CE |
106 | if (contains ("body", acorn_parts)) |
107 | translate ([outer_d+10, 0, 0,]) nut (); | |
108 | if (contains ("cap", acorn_parts)) | |
109 | cap (); | |
110 | if (contains ("gasket", acorn_parts)) | |
111 | translate ([-(outer_d+10), 0, 0,]) gasket (); | |
244fc8f0 | 112 | } |
28ef71df | 113 | |
244fc8f0 | 114 | nuts (); |
28ef71df | 115 | } |
244fc8f0 CE |
116 | |
117 | $fs = 1; | |
118 | $fa = 1; | |
119 | ||
120 | acorn (); |