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