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