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