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