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