818dd661 |
1 | /* GNU AGPLv3 (or later at your option) |
2 | see bottom for more license info */ |
3 | |
4 | /* spin thing that erin likes */ |
cc410ed6 |
5 | $fn = 50; |
6 | |
5f8325d2 |
7 | layer_height = 0.35; |
818dd661 |
8 | |
9 | weight = "penny"; |
10 | // weight = "608zz"; |
3e3691aa |
11 | bearing = "608zz"; |
cc410ed6 |
12 | weight_lip_overhang = 0.3; |
13 | bearing_lip_overhang = weight_lip_overhang; |
14 | // TODO: switch wall_thickness -> wall |
15 | wall_thickness = 3; |
16 | wall = 3; |
2645ef26 |
17 | penny_thickness = 1.52; |
818dd661 |
18 | penny_radius = 19.05 / 2; |
7f1519fb |
19 | |
20 | _608zz_radius = 22 / 2; |
21 | _608zz_inner_radius = 8.1 / 2; |
22 | _608zz_cover_radius = 19.4 / 2; |
23 | _608zz_cap_footprint_radius = 12 / 2; |
24 | _608zz_thickness = 7; |
25 | |
818dd661 |
26 | weight_radius = (weight == "penny") ? penny_radius : _608zz_radius; |
2645ef26 |
27 | weight_thickness = (weight == "penny") ? |
28 | penny_thickness * 5 : _608zz_thickness; |
7f1519fb |
29 | |
3e3691aa |
30 | bearing_radius = (bearing == "608zz") ? _608zz_radius : 1/0; |
7f1519fb |
31 | bearing_inner_radius = (bearing == "608zz") ? _608zz_inner_radius : 1/0; |
32 | bearing_cover_radius = (bearing == "608zz") |
cc410ed6 |
33 | ? _608zz_cover_radius + wall |
7f1519fb |
34 | : 1/0; |
35 | bearing_cap_footprint_radius = |
36 | (bearing == "608zz") ? _608zz_cap_footprint_radius : 1/0; |
2645ef26 |
37 | bearing_thickness = (bearing == "608zz") ? _608zz_thickness : 1/0; |
7f1519fb |
38 | |
39 | spinner_height = penny_thickness * 5 + 2; |
818dd661 |
40 | arms = 3; |
41 | |
7f1519fb |
42 | module cap(bearing_inner_radius, |
43 | bearing_cap_footprint_radius, |
44 | bearing_cover_radius, |
45 | bearing_thickness) { |
46 | footprint_height = 1.6; |
47 | footprint_radius_safety = 0.25; |
48 | cap_height = 3; |
49 | bearing_cover_radius_safety = 0.75; |
50 | bearing_thickness_safety = 0.2; |
51 | |
52 | difference() { |
53 | union() { |
54 | cylinder(r1 = bearing_cover_radius - tan(30) * cap_height, |
55 | r2 = bearing_cover_radius, |
56 | h = cap_height); |
57 | linear_extrude(height = cap_height + footprint_height) { |
58 | circle(bearing_cap_footprint_radius - footprint_radius_safety); } |
59 | linear_extrude(height = cap_height |
60 | + footprint_height |
61 | + bearing_thickness / 2 |
62 | - bearing_thickness_safety) { |
63 | circle(bearing_inner_radius); } } |
64 | translate([0, 0, -0.01]) { |
65 | cylinder(r1 = bearing_inner_radius + tan(30) * (cap_height - 1), |
66 | r2 = bearing_inner_radius, |
67 | h = cap_height - 1); } } } |
68 | |
cc410ed6 |
69 | module fillet(r) { |
70 | offset(r = -r) { offset(delta = r) { children(); } } } |
71 | |
cc410ed6 |
72 | module mirrored(axis) { |
73 | children(); |
74 | mirror(axis) children(); } |
2645ef26 |
75 | |
5f8325d2 |
76 | module spin_slice(weight_radius, |
77 | bearing_radius, |
78 | round_extra, |
79 | wall, |
80 | arms) { |
81 | joiner_radius = (bearing_radius + weight_radius) / 2; |
82 | |
83 | bearing_xy = [0, 0]; |
84 | // a = side along x axis |
85 | a = bearing_radius + weight_radius + wall; |
86 | // b = side from center to joiner |
87 | b = bearing_radius + joiner_radius + round_extra; |
88 | // c = side between joiner and arm center |
89 | c = joiner_radius + weight_radius + round_extra; |
90 | |
91 | weight_xy = [a, 0]; |
92 | |
93 | cos_C = (pow(a, 2) + pow(b, 2) - pow(c, 2)) / (2 * a * b); |
94 | sin_C = sqrt(1 - pow(cos_C, 2)); |
95 | |
96 | joiner_xy = [cos_C, sin_C] * b; |
97 | |
98 | for(arm = [0 : arms - 1]) { |
99 | rotate(arm * (360 / arms)) { |
100 | difference() { |
101 | union() { |
102 | translate(bearing_xy) { |
103 | circle(bearing_radius + round_extra); } |
104 | translate(weight_xy) { |
105 | circle(weight_radius + round_extra); } |
106 | mirrored([0, 1]) { |
107 | polygon([bearing_xy, weight_xy, joiner_xy]); } } |
108 | mirrored([0, 1]) { |
109 | translate(joiner_xy) { |
110 | circle(joiner_radius); } } } } } } |
111 | |
112 | module spin_slices(weight_radius, |
113 | weight_thickness, |
114 | bearing_radius, |
115 | bearing_thickness, |
116 | weight_lip_overhang = 0.3, |
117 | bearing_lip_overhang = 0.3, |
118 | wall = 3, |
119 | arms = 3, |
120 | layer_height = 0.15) { |
cc410ed6 |
121 | thicker_thickness = (bearing_thickness > weight_thickness) ? |
122 | bearing_thickness : weight_thickness; |
123 | calculated_height = thicker_thickness + 2 * wall; |
124 | layers = 2 * ceil(ceil(calculated_height / layer_height) / 2); |
125 | actual_height = layers * layer_height; |
126 | round_radius = actual_height / 2; |
127 | |
5f8325d2 |
128 | /* rounding the outside edge of the spinner with a semi-circle leads |
129 | to a shape that an overhang on the second layer several times the |
130 | thickness of a printed extrusion width. |
131 | |
132 | rather than using a full semi-circle, this code aims to use just the |
133 | portion in the middle, where the overhang is less severe */ |
e1a02727 |
134 | old_start = 0; |
135 | old_end = (layers / 2) - 1; |
136 | |
5f8325d2 |
137 | /* add one to have some thickness all around weight holes |
138 | for first layer */ |
139 | new_start = old_end / 8 + 1; |
e1a02727 |
140 | new_end = old_end; |
141 | |
142 | old_range = old_end - old_start; |
143 | new_range = new_end - new_start; |
144 | |
145 | factor = new_range / old_range; |
146 | |
5f8325d2 |
147 | /* initial adjacent is adjusted to (new start - 1) to allow some |
148 | thickness all around weight holes on first layer */ |
149 | initial_adjacent = round_radius - ((new_start - 1) * layer_height); |
e1a02727 |
150 | initial_angle = acos(initial_adjacent / round_radius); |
151 | initial_round_extra = initial_adjacent * tan(initial_angle); |
5f8325d2 |
152 | |
153 | difference() { |
154 | mirrored([0, 0, 1]) { |
155 | for(layer = [0 : (layers / 2) - 1]) { |
156 | translate([0, 0, layer * layer_height - actual_height / 2]) { |
157 | linear_extrude(height = layer_height) { |
158 | new_layer = (layer - old_start) * factor + new_start; |
159 | adjacent = round_radius - (new_layer * layer_height); |
160 | angle = acos(adjacent / round_radius); |
161 | round_extra = adjacent * tan(angle) - initial_round_extra; |
162 | spin_slice(weight_radius, |
163 | bearing_radius, |
164 | round_extra, |
165 | wall, |
166 | arms); } } } } |
167 | cylinder(h = actual_height + 0.1, |
168 | r = bearing_radius - bearing_lip_overhang, |
169 | center = true); |
170 | cylinder(h = bearing_thickness + 0.1, |
171 | r = bearing_radius + 0.1, |
172 | center = true); |
173 | for(arm = [0 : arms - 1]) { |
174 | rotate(arm * (360 / arms)) { |
175 | translate([bearing_radius + wall + weight_radius, 0]) { |
176 | cylinder(h = actual_height + 0.1, |
177 | r = weight_radius - weight_lip_overhang, |
178 | center = true); |
179 | cylinder(h = weight_thickness + 0.1, |
180 | r = weight_radius + 0.1, |
181 | center = true); } } } } } |
818dd661 |
182 | |
183 | /* |
184 | This file is part of 3d-printables. |
185 | |
186 | 3d-printables is free software: you can redistribute it and/or modify |
187 | it under the terms of the GNU Affero General Public License as published by |
188 | the Free Software Foundation, either version 3 of the License, or |
189 | (at your option) any later version. |
190 | |
191 | 3d-printables is distributed in the hope that it will be useful, |
192 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
193 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
194 | GNU Affero General Public License for more details. |
195 | |
196 | You should have received a copy of the GNU Affero General Public License |
197 | along with challenge-bot. If not, see <http://www.gnu.org/licenses/>. |
198 | */ |