]> www.fi.muni.cz Git - things.git/blob - rocket.scad
rocket.scad: slightly wider motor hole
[things.git] / rocket.scad
1
2 // The Estes A8-3 and C6-7 motors have diameter of 17.7 mm,
3 // length 69.5 mm. The Estes Alpha launch pad has rod diameter 3.4 mm.
4
5 motor_diam = 17.7 + 0.6; // add some tolerance
6 motor_len  = 69.5 + 0.5;
7
8 segment_overlap = 15;
9
10 loose_fit_diam_diff = 0.5; // cylinder with outer diameter d1
11         // will fit loosely into the hole with inner diameter
12         // d1 + loose_fit_diam_diff
13 tight_fit_diam_diff = 0.25; // cylinder with outer diameter d1
14         // will fit tightly into the hole with inner diameter
15         // d1 + tight_fit_diam_diff
16
17 thin_wall = 0.9; // depends on the print width
18 thick_wall = 2*thin_wall + loose_fit_diam_diff/2;
19         // motor_diam + 2*thick_wall is the outer diameter of the rocket
20 motor_wall = thick_wall; // above the motor
21
22 clip_height = 3.5;
23 clip_clearance = segment_overlap/4;
24 clip_inner_space = motor_diam/2 - 1.5;
25
26 rod_diam = 3.4 + 1;
27 rubber_beam_height = 3;
28
29 fin_thickness = 1;
30
31 eps = 0.01;
32 infty = 1000;
33
34 //----------------- MOTOR MODULE -----------------------------
35
36 module fin() {
37         assign(h1 = 2*motor_len/3, // near end height
38                 h2 = 20,        // far end height
39                 h_off = motor_len, // height offset of the far height
40                 w = 30, // distance of the far height
41                 fin_w = fin_thickness)
42         translate([0, -fin_w/2, -h1])
43         hull() { 
44                 cube([eps, fin_w, h1]); // near end
45                 translate([w, 0, h_off]) // far end
46                         cube([eps, fin_w, h2]);
47         };
48 };
49
50 // alternative fin layout
51 module fin2() {
52         assign(h1 = motor_len/2, // near end height
53                 w2 = 23,        // bottom/far end width
54                 h_off = 60, // height offset of the far height
55                 w = 30, // distance of the far height
56                 fin_w = fin_thickness)
57         translate([0, -fin_w/2, -h1])
58         hull() { 
59                 cube([eps, fin_w, h1]); // near end
60                 translate([w-w2, 0, h_off]) // far end
61                         cube([w2, fin_w, eps]);
62         };
63 };
64
65 rod_hole_height = 20;
66 rod_hole_side = 1.5*(rod_diam + thin_wall);
67
68 module motor_module_solid()
69 {
70         // cone from loose_fit to tight fit, 1/3 of segment overlap
71         cylinder(r1 = motor_diam/2 + thin_wall,
72                 r2 = motor_diam/2 + thick_wall - thin_wall - tight_fit_diam_diff/2,
73                 h = segment_overlap/3 + eps);
74
75         // tight fit cylinder, 2/3 of segment overlap
76         translate([0, 0, segment_overlap/3])
77                 cylinder(r = motor_diam/2 + thick_wall - thin_wall - tight_fit_diam_diff/2,
78                 h = 2*segment_overlap/3 + eps);
79
80         // conical joint between the two cylinders
81         translate([0, 0, segment_overlap - thick_wall + thin_wall])
82                 cylinder(r1 = motor_diam/2 + thick_wall - thin_wall - tight_fit_diam_diff/2,
83                         r2 = motor_diam/2 + thick_wall,
84                         h = thick_wall - thin_wall + eps);
85
86         // the thick cylinder above it
87         translate([0, 0, segment_overlap])
88                 cylinder(r = motor_diam/2 + thick_wall,
89                 h = motor_len + motor_wall - segment_overlap);
90
91         // fins
92         for (a = [60, 180, 300]) {
93                 rotate([0, 0, a])
94                 translate([motor_diam/2 + thick_wall-thin_wall, 0, motor_wall + motor_len])
95                         // fin();
96                         fin2();
97         };
98
99         // rod hole holder
100         hull() {
101                 translate([motor_diam/2 + thick_wall - rod_diam/2 - thin_wall,
102                         0, segment_overlap])
103                         scale([1, 1.4, 1])
104                         cylinder(r = rod_diam/2 + thin_wall, h = eps);
105                 translate([motor_diam/2 + thick_wall + thin_wall + rod_diam/2, 0, segment_overlap + rod_hole_side])
106                         scale([1, 1.1, 1])
107                         cylinder(r = rod_diam/2 + thin_wall, h = rod_hole_height);
108                 translate([motor_diam/2 + thick_wall - rod_diam/2 - thin_wall,
109                         0, segment_overlap + 2*rod_hole_side + rod_hole_height])
110                         scale([1, 1.4, 1])
111                         cylinder(r = rod_diam/2 + thin_wall, h = eps);
112         };
113
114         // motor clip
115         rotate([0, 0, 120]) intersection() {
116                 translate([clip_inner_space, -infty/2,
117                         motor_len + motor_wall + clip_clearance])
118                         cube([thin_wall, infty, clip_height]);
119                 rotate([0, 0, -60])
120                         translate([-infty/2, 0, 0]) cube(infty);
121                 rotate([0, 0, -120])
122                         translate([-infty/2, 0, 0]) cube(infty);
123         };
124 };
125         
126 module motor_module() {
127         difference() {
128                 motor_module_solid();
129
130                 // top ring to hold the motor inside
131                 translate([0, 0, -eps])
132                         cylinder(r = motor_diam/2 - motor_wall,
133                                 h = motor_wall + 2*eps);
134
135                 // motor hole
136                 translate([0, 0, motor_wall - eps])
137                         cylinder(r = motor_diam/2, h = motor_len + 2*eps);
138
139                 // three rails inside the motor hole
140                 translate([0, 0, segment_overlap + thick_wall]) difference() {
141                         union() {
142                                 cylinder(r = motor_diam/2 + thin_wall,
143                                         h = motor_len - segment_overlap - 2*thick_wall + eps);
144                                 translate([0, 0, motor_len - segment_overlap - 2*thick_wall])
145                                         cylinder(r1 = motor_diam/2 + thin_wall, r2 = motor_diam/2, h = thick_wall + eps);
146                         };
147                         for (a = [0, 120, 240]) rotate([0, 0, a])
148                                 translate([motor_diam/2 + 2.5, 0, -eps])
149                                         cylinder(r = 3, h = infty);
150                 };
151
152                 // rod hole
153                 translate([motor_diam/2 + thick_wall + thin_wall + eps + rod_diam/2, 0, 0])
154                         cylinder(r = rod_diam/2, h = infty);
155         };
156 };
157
158 // -------------------- CENTRAL TUBE ---------------------
159
160 central_tube_h = 85;
161
162 central_clip_r = 12;
163 central_clip_w = 4;
164 central_clip_clearance = 1.5;
165
166 module central_tube_solid() {
167         cylinder(r = motor_diam/2 + thick_wall, h = central_tube_h);
168 };
169
170 module central_tube() {
171         difference() {
172                 central_tube_solid();
173                 translate([0, 0, -eps])
174                         cylinder(r = motor_diam/2 + thick_wall - thin_wall,
175                                 h = infty);
176         };
177         // rubber band holder
178         intersection() {
179                 cylinder(r = motor_diam/2 + thick_wall - eps, h = central_tube_h);
180 /*
181                 translate([motor_diam/2 - thick_wall, -infty/2,
182                         segment_overlap + thick_wall])
183                         cube([thin_wall, infty, rubber_beam_height]);
184 */
185                 translate([-central_clip_w/2,
186                         central_clip_r + motor_diam/2 + thick_wall - 2*thin_wall - central_clip_clearance,
187                         central_tube_h/3]) rotate([0, 90, 0]) difference() {
188                         cylinder(r = central_clip_r, h = central_clip_w);
189                         translate([0, 0, -eps])
190                                 cylinder(r = central_clip_r - thin_wall, h = central_clip_w + 2*eps);
191                 }
192         };
193 };
194
195 //------------------------- FRONT CONE -----------------------
196 cone_h = 45;
197 cone_resolution = 40;
198 cone_solid_h = 10;
199
200 function bez_i4(t, ctls) =
201         (pow(1-t, 3) * ctls[0])
202         + (3 * t * pow(1-t, 2) * ctls[1])
203         + (3 * pow(t, 2) * (1-t) * ctls[2])
204         + (pow(t, 3) * ctls[3]);
205
206 module bezier_cone(cps, res)
207 {
208         for (t = [0:1:res])
209                 translate([0, 0, (bez_i4(t/res, cps))[0]])
210                         cylinder(r1 = (bez_i4(t/res, cps))[1],
211                                 r2 = (bez_i4((t + 1)/res, cps))[1],
212                                 h = (bez_i4((t + 1)/res, cps))[0]
213                                     - (bez_i4(t/res, cps))[0] + eps);
214 };
215
216 module front_cone_body() {
217         translate([0, 0, segment_overlap])
218                 bezier_cone([
219                         [ 0, motor_diam/2 + thick_wall ], // start
220                         [ cone_h/2, motor_diam/2 + thick_wall ], // cp 1
221                         [ cone_h - motor_diam/2 - thick_wall, motor_diam/2 + thick_wall ], // cp 2
222                         [ cone_h, 0 ],
223                 ], 40);
224
225         translate([0, 0, segment_overlap-thick_wall+thin_wall])
226                 cylinder(r1 = motor_diam/2+thin_wall,
227                         r2 = motor_diam/2 + thick_wall,
228                         h = thick_wall - thin_wall + eps);
229
230         cylinder(r = motor_diam/2+thin_wall, h = segment_overlap + eps);
231 };
232
233 module front_cone() {
234         difference() {
235                 front_cone_body();
236                 intersection() {
237                         translate([0, 0, segment_overlap])
238                                 bezier_cone([
239                                         [ 0.7*thin_wall, motor_diam/2 + thick_wall - thin_wall ], // start
240                                 [ cone_h/2-0.7*thin_wall, motor_diam/2 + thick_wall - thin_wall], // cp 1
241                                 [ cone_h - motor_diam/2 - thick_wall + thin_wall - 1.4*thin_wall, motor_diam/2 + thick_wall - thin_wall ], // cp 2
242                                 [ cone_h - 1.4*thin_wall, 0 ],
243                         ], 40);
244                         cylinder(r = motor_diam/2 + thick_wall + eps,
245                                 h = cone_h + segment_overlap - cone_solid_h);
246                 };
247
248                 translate([0, 0, segment_overlap-thick_wall+1.7*thin_wall])
249                         cylinder(r1 = motor_diam/2,
250                                 r2 = motor_diam/2 + thick_wall-thin_wall,
251                                 h = thick_wall-thin_wall + eps);
252
253                 translate([0, 0, -eps])
254                         cylinder(r = motor_diam/2, h = segment_overlap + 2*eps);
255         };
256         // rubber band holder
257         intersection() {
258                 cylinder(r = motor_diam/2 + thin_wall/2, h = segment_overlap);
259                 translate([motor_diam/3-thin_wall/2, -infty/2,
260                         segment_overlap - rubber_beam_height/2 - eps])
261                         cube([thin_wall, infty, rubber_beam_height]);
262         };
263 };
264
265 module thread_holder() {
266         rotate([0, 90, 0]) {
267                 translate([0, 0, -1.5]) difference() {
268                         cylinder(r = 10, h = 3);
269                         translate([0, 0, -eps])
270                                 cylinder(r = 8, h = 3 + 2*eps);
271                 };
272         };
273 }
274
275 // thread_holder();
276
277 /*
278 // debug
279 difference() {
280         // front_cone();
281         // central_tube();
282         motor_module();
283
284         translate([0, 0, -eps]) cube(infty);
285 };
286 */
287
288 // production
289 $fn = 128;
290
291 translate([motor_diam + thick_wall, 0, 0])
292         motor_module();
293
294 rotate([0, 0, 120])
295 translate([motor_diam + thick_wall, 0, 0])
296         central_tube();
297
298 rotate([0, 0, 240])
299 translate([motor_diam + thick_wall, 0, 0])
300         front_cone();