chiark / gitweb /
poster-tube-lid: Break out SomeStrap (nfc)
[reprap-play.git] / poster-tube-lid.scad
1 // -*- C -*-
2
3 coarse = false;
4
5 main_dia = 71.2 + 0.50 - 2.26;
6 top_thick_middle = 4;
7 top_thick_by_oring = 3.0;
8 top_middle_dr = 11;
9
10 main_cnr = 6.0;
11
12 min_wall = 3;
13
14 rivet_posn = 6.0 + 0.30;
15 rivet_thick = 1.67;
16 rivet_width = 4.15 + 1.0;
17 rivet_tall = 5.51 + 1.49;
18
19 over_rivet_wall = 1.0;
20 side_rivet_gap = 1.5;
21 inside_rivet_gap = 1.5;
22
23 bayo_interf = 0.30;
24 bayo_behind = 3.5;
25 bayo_interf_width = 2.0;
26 bayo_interf_slope = 0.5;
27
28 oring_thick = 5.0;
29 oring_bore = 62.0;
30
31 oring_upper_embed_angle = 80;
32 oring_compress = 0.1; // proportion
33 oring_compress_more = 0.2;
34
35 oring_rm_beside = 8;
36 oring_rm_scale = 2.0;
37 oring_rm_angle = 20;
38
39 side_taper = 1.0;
40
41 bayo_gap = 6.0;
42
43 bayo_entry = bayo_behind/3;
44
45 bayo_slice_size = coarse ? 5 : 1;
46
47 brace_hole_width = 1.0;
48 brace_above_below = 1.2;
49 brace_end_shorter = 0.3;
50
51 jig_thick = 1.4;
52 jig_hole_dia = 3.0;
53 jig_rim = 5;
54 jig_mark = 5;
55
56 strap_hoop_thick = 6;
57 strap_hoop_inside = 10;
58 strap_hoop_strlen = 10;
59 strap_hoop_elevation = 45;
60
61 sm_inner_circum = 218 - 1.90 - 1.00 - 0.50;
62 sm_main_thick = 2.0;
63 sm_main_width = 20;
64
65 sm_bolt_dia = 3.5 + 0.1;
66 sm_bolt_shaft = 21.9;
67 sm_bolt_head_dia = 6.94 + 1.0;
68 sm_bolt_head_thick = 2.14;
69 sm_bolt_nut_width = 5.89 + 0.25;
70 sm_bolt_nut_thick = 3.68;
71 sm_bolt_tighten_allow = 2.0;
72
73 sm_bolt_y_clear = 0.75;
74 sm_bolt_y_over = 0.5;
75
76 sm_closure_cnr = 3.0;
77
78 catch_stem_h = 3;
79 catch_stem_len = 50;
80 catch_stem_th = 3;
81
82 catch_knob_dia = 6;
83 catch_knob_above_gap = 8;
84 catch_pin_height = 7;
85
86 catch_stem_below_gap = 1.0;
87 catch_stem_beside_gap = 2.0;
88 catch_pin_gap = 0.5;
89 catch_hook_slope = 0.15;
90
91 // calculated
92
93 TAU = PI*2;
94
95 bayo_entry_x = bayo_entry;
96 bayo_entry_z = bayo_entry;
97 bayo_inramp_x = bayo_entry;
98 bayo_inramp_z = bayo_entry;
99
100 oring_mid_dia = oring_bore + oring_thick;
101 oring_outer_dia = oring_mid_dia + oring_thick;
102
103 oring_oblate = (1 - oring_compress);
104
105 oring_y_rad = oring_thick/2 * oring_oblate;
106 oring_x_rad = oring_thick/2 / oring_oblate;
107
108 by_oring_z = oring_y_rad * (1 + cos(oring_upper_embed_angle));
109
110 side_height = rivet_posn + bayo_behind + rivet_thick/2;
111 side_thick = rivet_tall + over_rivet_wall;
112
113 top_z = top_thick_by_oring + oring_y_rad + by_oring_z;
114
115 middle_bot_z = top_z - top_thick_middle;
116
117 bayo_entry = bayo_behind / 3.0;
118 bayo_top_z = bayo_behind + bayo_gap;
119
120 rivet_entry_width = rivet_width + side_rivet_gap;
121
122 jig_mark_rad = jig_mark + main_dia/2 + jig_thick;
123
124 handling_dia = oring_bore + oring_thick*2 + min_wall*2;
125 handling_angle = 45;
126
127 sm_inner_rad = (sm_inner_circum + sm_bolt_tighten_allow/2) / TAU;
128 sm_outer_rad = sm_inner_rad + sm_main_thick;
129
130 smc_pos = [ 0, sm_inner_rad, 0 ];
131
132 smc_bolt_nut_dia = sm_bolt_nut_width / cos(30);
133 smc_bolt_nut_eff_thick = sm_bolt_nut_thick + sm_bolt_tighten_allow;
134
135 smc_bolt_y = sm_bolt_dia/2 + sm_bolt_y_clear;
136 smc_max_y = smc_bolt_y + sm_bolt_y_over
137   + max(sm_bolt_head_dia/2, smc_bolt_nut_dia/2);
138 smc_cnr_c_x = sm_bolt_shaft/2 - sm_closure_cnr
139   + sm_bolt_head_thick/2 + smc_bolt_nut_eff_thick/2;
140
141 catch_cr = catch_knob_dia/2 + catch_stem_beside_gap;
142 catch_strap_width = sm_main_width;
143 catch_strap_thick = sm_main_thick;
144 catch_stem_end_h = catch_stem_h;
145 catch_pin_width = rivet_entry_width - catch_pin_gap;
146
147 cppy6 = -catch_strap_width/2;
148 cppxC = 0.34 * sm_inner_rad * TAU;
149 cppB = [ catch_pin_width/2,
150          cppy6
151          + catch_stem_below_gap
152          + catch_pin_height
153          + catch_knob_dia/2 ];
154 cpp0 = [ 0,
155          cppB[1]
156          + catch_knob_dia
157          + catch_knob_above_gap ];
158 cpp12 = cpp0 + [1,0] * (catch_pin_height * catch_hook_slope);
159 cpp1 = cpp0 + [0,1] * catch_pin_height;
160 cpp2 = cpp1 + [1,0] * catch_pin_width;
161 cpp4 = cpp0 + [0,-1] * catch_stem_end_h;
162 cpp3 = [ cpp2[0], cpp4[1] ];
163 cpp5 = [ cpp0[0] - catch_stem_len,
164          -catch_stem_h ];
165 cpp6 = [ cpp5[0], catch_cr ];
166 cpp7 = cppB + [1,-1] * catch_knob_dia/2
167             + [ catch_stem_beside_gap, -catch_stem_below_gap ]
168             + [ 0, -catch_pin_height ]
169             + [-1,1] * catch_cr;
170 cpp11 = cpp7 + [1,0] * catch_cr;
171 cpp10 = [ cpp11[0], 0 - catch_cr ];
172 cpp8 = cpp10 + [1,0] * catch_cr;
173 cpp9 = cpp8 + [0,1] * catch_cr;
174 cppC = [ cppxC, cpp9[1] ];
175 cppA = [ -cppxC, 0 ];
176 cppD = cppC + [0,-1] * catch_strap_width;
177 cppE = [ cppA[0], cppD[1] ];
178
179 $fs= coarse ? 2.5 : 0.5;
180 $fa= coarse ? 5 : 1;
181
182 include <poster-tube-lid-parametric.scad>
183
184 // bayonet definition
185
186 bayo_a = [ bayo_entry_x, 0 ];
187 bayo_p = [ 0, bayo_entry_z ];
188 bayo_n = [ 0, bayo_behind-bayo_inramp_z ];
189 bayo_m = [ bayo_inramp_x, bayo_behind ];
190 bayo_l = bayo_m + bayo_interf * [ 1/bayo_interf_slope,  1 ];
191 bayo_k = bayo_l + [ bayo_interf_width, 0 ];
192 bayo_j = bayo_k + bayo_interf * [ 1/bayo_interf_slope, -1 ];
193 bayo_i = bayo_j + [ rivet_width + inside_rivet_gap, 0 ];
194 bayo_h = [ bayo_i[0], bayo_behind + bayo_gap + bayo_interf ];
195 bayo_g = [ bayo_m[0] - rivet_width, bayo_h[1] ];
196
197 bayo_e = [-bayo_p[0], bayo_p[1]] - [rivet_entry_width,0];
198 bayo_d = [-bayo_a[0], bayo_a[1]] - [rivet_entry_width,0];
199 bayo_c = bayo_d + [0,-5];
200 bayo_b = bayo_a + [0,-5];
201
202 bayo_f = [ bayo_e[0], bayo_g[1] + (bayo_e[0] - bayo_g[0]) ];
203
204 bayo_polygon = [ bayo_a,
205                  bayo_b,
206                  bayo_c,
207                  bayo_d,
208                  bayo_e,
209                  bayo_f,
210                  bayo_g,
211                  bayo_h,
212                  bayo_i,
213                  bayo_j,
214                  bayo_k,
215                  bayo_l,
216                  bayo_m,
217                  bayo_n,
218                  bayo_p ];
219
220 echo(bayo_polygon);
221
222 module MainProfile(){
223   main_cnr_pos = [ side_thick, top_z ] - [1,1]*main_cnr;
224   difference(){
225     union(){
226       translate(main_cnr_pos){
227         intersection(){
228           difference(){
229             circle(r = main_cnr);
230             circle(r = main_cnr * 0.5);
231           }
232           square([10,10]);
233         }
234       }
235       polygon([[ -top_middle_dr,        middle_bot_z      ],
236                [ -top_middle_dr,        top_z             ],
237                [ main_cnr_pos[0],       top_z             ],
238                [ side_thick,            main_cnr_pos[1]   ],
239                [ side_thick,            -side_height      ],
240                [ side_taper,            -side_height      ],
241                [ 0,                     -rivet_posn       ],
242                [ 0,                     by_oring_z        ],
243                [ -oring_x_rad,          by_oring_z        ],
244                ],
245               convexity=10);
246     }
247     translate([ oring_mid_dia/2 - main_dia/2, 0 ])
248       hull(){
249       translate([ 0, oring_y_rad ])
250         scale([ 1/oring_oblate * (oring_compress_more+1) , oring_oblate ])
251         circle(oring_thick/2);
252       translate([ 0, oring_y_rad*2 - oring_thick/2 ])
253         circle(oring_thick/2);
254     }
255   }
256 }
257
258 module StrapHoopProfile(){
259   circle(r = strap_hoop_thick/2);
260 }
261
262 module StrapHoop(){ ////toplevel
263   bigrad = strap_hoop_inside/2 + strap_hoop_thick/2;
264   extralen = strap_hoop_thick * 5;
265
266   intersection(){
267     rotate([strap_hoop_elevation, 0,0]){
268       for (x= [ -1, +1 ] * bigrad) {
269         translate([x, -extralen, 0])
270           rotate([-90,0,0])
271           linear_extrude(height= extralen + strap_hoop_strlen + 0.1,
272                          convexity=10)
273           StrapHoopProfile();
274       }
275       translate([0, strap_hoop_strlen, 0]){
276         intersection(){
277           rotate_extrude(convexity=10)
278             translate([bigrad, 0,0])
279             StrapHoopProfile();
280           translate([0,50,0])
281             cube([100,100,100], center=true);
282         }
283       }
284     }
285     translate([0, 50, 0])
286       cube(100, center=true);
287   }
288 }
289
290 module RotateProjectSlice(offset, slice_size, nom_rad, real_rad){
291   // nom_rad > real_rad
292   rotate([0,0, atan2(offset, nom_rad) ]){
293     intersection(){
294       translate([-offset, -10, 0])
295         rotate([90,0,0])
296         linear_extrude(height= nom_rad*2)
297         children(0);
298       translate([0,0, -25])
299         cylinder(h=50, r= real_rad);
300       translate([0,0, -25])
301         linear_extrude(height= 50)
302         polygon([ [ 0,0 ],
303                   [ -slice_size, -real_rad*2 ],
304                   [ +slice_size, -real_rad*2 ] ]);
305     }
306   }
307 }
308
309 module RotateProject(x_min, x_max, slice_size, nom_rad, real_rad){
310   offs = [ for (i=[ x_min :
311                     slice_size :
312                     x_max + slice_size ]) i ];
313   echo (offs);
314   for (off=offs)
315     RotateProjectSlice(off, slice_size, nom_rad, real_rad)
316     children(0);
317 }
318
319 module BayonetCutout(){
320   RotateProject(bayo_c[0], bayo_i[0], bayo_slice_size,
321                 main_dia/2 + side_thick, 
322                 main_dia/2 + rivet_tall)
323     translate([-0.5 * (bayo_a[0] + bayo_d[0]), 0])
324     polygon(bayo_polygon, convexity=10);
325 }
326
327 module ProfilesDemo(){ ////toplevel
328   translate([-10,0]) MainProfile();
329   translate([+10, -side_height]) polygon(bayo_polygon, convexity=10);
330 }
331
332 module LimitForHandling(){ ////toplevel
333   hull() for (r=[0,180])
334     rotate([0,0,r]) {
335       for (rs=[-1,+1]) {
336         for (xd=[0,1]) {
337           rotate([0,0, rs * handling_angle/2]) {
338             translate([rs * xd * main_dia/2 * tan(handling_angle/2),
339                        main_dia/2 + side_thick - main_cnr,
340                        top_z - main_cnr]) {
341               mirror([0,0,1])
342                 cylinder(r= main_cnr, h=50);
343               sphere(main_cnr);
344             }
345           }
346         }
347       } 
348     }
349   hull() rotate_extrude(){
350     translate([ handling_dia/2 - main_cnr, top_z - main_cnr ]) {
351       circle(r = main_cnr);
352       mirror([0,1]) square([ main_cnr, 50 ]);
353     }
354   }
355   //cylinder(r= handling_dia/2, h=20);
356 }
357
358 module Cover(){ ////toplevel
359   render() difference(){
360     intersection(){
361       union(){
362         rotate_extrude(convexity=10)
363           translate([main_dia/2, 0])
364           MainProfile();
365         translate([0,0, middle_bot_z])
366           cylinder(h= top_thick_middle, r = main_dia/2 - top_middle_dr + 1);
367       }
368       LimitForHandling();
369     }
370     for (r=[0,180]){
371       rotate([0,0, r])
372         translate([0,0, -side_height])
373         BayonetCutout();
374       rotate([0,0, r + asin((-oring_rm_beside) / (main_dia/2))])
375         translate([0,
376                    oring_mid_dia/2 + oring_thick/4 * oring_rm_scale,
377                    oring_y_rad * 1.5])
378         rotate([-oring_rm_angle, 0, 0])
379         mirror([0,0,1])
380         cylinder(r = oring_thick/4 * oring_rm_scale, h=20);
381     }
382     for (r=[0 : 60 : 179]) {
383       rotate([0,0, r]) {
384         height = top_thick_middle - brace_above_below*2;
385         translate([0,0, middle_bot_z + brace_above_below + height/2 ])
386         cube(center=true, [ oring_bore - brace_end_shorter,
387                             brace_hole_width, height ]);
388       }
389     }
390   }
391   for (r=[0,180])
392     rotate([0,0,r])
393       translate([-implheadcup_large_dia * .5 - implheadcup_thick/2,
394                  -implheadcup_large_dia * .0,
395                  middle_bot_z + 0.1])
396       ImplHeadCup();
397 //  translate(strap_hoop_thick * [-0.5, 0, +1])
398 //    translate([handling_dia/2, 0, -side_height])
399 //    rotate([0,180,0]) rotate([0,0,90])
400 //    StrapHoop();
401 }
402
403 module SavingHole(){
404   translate([0,0, -10])
405     cylinder(r= main_dia/2 - jig_rim, h=20);
406 }
407
408 module Jig(){ ////toplevel
409   difference(){
410     union(){
411       translate([0,0, -side_height]){
412         cylinder(r= main_dia/2 + jig_thick, h= side_height + jig_thick);
413       }
414       translate([-jig_mark_rad, 0, jig_thick - jig_mark])
415         cube([jig_mark_rad*2, jig_mark, jig_mark]);
416     }
417     translate([0,0, -side_height-1])
418       cylinder(r= main_dia/2, h= side_height + 1);
419     SavingHole();
420     translate([0,0, -rivet_posn])
421       rotate([90, 0,0])
422       translate([0,0, -100])
423       cylinder(r= jig_hole_dia/2, h = 200);
424   }
425 }
426
427 module CoverTest2(){ ////toplevel
428   difference(){
429     Cover();
430     SavingHole();
431   }
432 }
433
434 module CoverTest1(){ ////toplevel
435   difference(){
436     CoverTest2();
437     difference(){
438       for (r= [ 40, 147 ]){
439         rotate([0,0, r]){
440           translate([0,0, -10]) {
441             cube([ main_dia*3, main_dia * .53, 18], center=true);
442           }
443         }
444       }
445 //      translate([ 50, 0, 0 ])
446 //      cube([ 100,
447 //             strap_hoop_inside + strap_hoop_thick*2 + 1,
448 //             100 ],
449 //           center=true);
450     }
451   }
452 }
453
454 module ImplHeadCupTest(){ ////toplevel
455   for (r=[0,180])
456     rotate([0,0,r])
457       translate([-17,0,0])
458       ImplHeadCup();
459 }
460
461 module SomeStrap(){
462   // children(0) is to add, (1) subtract
463   difference(){
464     union(){
465       cylinder(r=sm_outer_rad, h=sm_main_width);
466       StrapMountProtrusion(smc_cnr_c_x + sm_closure_cnr,
467                            smc_max_y,
468                            sm_closure_cnr);
469       children(0);
470     }
471     translate([0,0,-1])
472       cylinder(r=sm_inner_rad, h=sm_main_width+2);
473     translate(smc_pos)
474       StrapMountBolt(10);
475     translate(smc_pos)
476       cube([ sm_bolt_tighten_allow, 40,100 ], center=true);
477     children(1);
478   }
479 }
480
481 module StrapMountBolt(l_delta){ ///toplevel
482   // positioned relative to smc_pos
483   translate([(smc_bolt_nut_eff_thick - sm_bolt_head_thick)/2,
484              smc_bolt_y,
485              sm_main_width/2]){
486     translate([ -sm_bolt_shaft/2-1, 0,0 ]){
487       rotate([0,90,0]) cylinder(r= sm_bolt_dia/2, h= sm_bolt_shaft+2);
488     }
489     translate([ -sm_bolt_shaft/2, 0,0 ])
490       rotate([0,-90,0])
491       cylinder($fn=6, r=smc_bolt_nut_dia/2,
492                h=smc_bolt_nut_eff_thick + l_delta);
493     translate([ sm_bolt_shaft/2, 0,0 ])
494       rotate([0,90,0])
495       cylinder(r=sm_bolt_head_dia/2, h=sm_bolt_head_thick + l_delta);
496   }
497 }
498
499 module StrapMountProtrusion(half_x, max_y, cnr){
500   translate(smc_pos){
501     linear_extrude(height=sm_main_width, convexity=10){
502       hull(){
503         for (m = [0,1]) mirror([m,0,0]) {
504           translate([-(half_x - cnr), max_y - cnr])
505             circle(r=cnr);
506           translate([-half_x, -sm_inner_rad])
507             square([1,1]);
508         }
509       }
510     }
511   }
512 }
513
514 module StrapMount(){ ////toplevel
515   SomeStrap(){
516     rotate([0,0,180]){
517       StrapMountProtrusion(strap_hoop_inside/2 + strap_hoop_thick,
518                            strap_hoop_thick,
519                            sm_closure_cnr);
520       translate(smc_pos +
521                 [0,0, sm_main_width] +
522                 strap_hoop_thick * [ 0, 0.5, -1.0 ])
523         StrapHoop();
524     }
525     union(){ };
526   }
527 }
528
529 module CatchCoreProfile(){ ////toplevel
530   hull(){
531     translate(cppB) circle(r= catch_knob_dia/2);
532     polygon([cpp4,
533              cppB,
534              cpp3]);
535   }
536   translate(cpp8)
537     circle(catch_cr);
538   polygon([
539            cpp4,
540            cppB,
541            cpp3,
542            cpp2,
543            cpp1,
544            cpp12,
545            ]);
546   difference(){
547     polygon([ cpp4,
548               cpp3,
549               cpp12,
550               cppA,
551               cppE,
552               cppD,
553               cppC,
554               cpp9,
555               cpp10,
556               cpp11,
557               cpp7,
558               cpp5,
559               ], convexity=10);
560     hull(){
561       translate(cpp7) circle(r= catch_cr);
562       polygon([ cpp7,
563                 cpp5,
564                 cpp11 ]);
565     }
566     hull(){
567       translate(cpp6) circle(catch_cr);
568       polygon([ cppA,
569                 cpp0,
570                 cpp1 ]);
571     }
572   }
573 }
574
575 module CatchPreDistort(){ /////toplevel
576   scale(100 / sm_inner_rad)
577     rotate([90,0,0])
578     linear_extrude(height=catch_strap_thick, convexity=10)
579     CatchCoreProfile();
580 }
581
582 module CatchAssembly(){ /////toplevel
583   scale(sm_inner_rad / 100)
584     import(str("poster-tube-lid,CatchPostDistort-fa",
585                (coarse ? 20 : 1),
586                ".stl"),
587            convexity=20);
588 }
589
590 //ProfilesDemo();
591 //BayonetCutout();
592 //MainProfile();
593 //Cover();
594 //Jig();
595 //CoverTest();