chiark / gitweb /
sleepphone-cable-box: introduce wall_bot, 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 // calculated
79
80 TAU = PI*2;
81
82 bayo_entry_x = bayo_entry;
83 bayo_entry_z = bayo_entry;
84 bayo_inramp_x = bayo_entry;
85 bayo_inramp_z = bayo_entry;
86
87 oring_mid_dia = oring_bore + oring_thick;
88 oring_outer_dia = oring_mid_dia + oring_thick;
89
90 oring_oblate = (1 - oring_compress);
91
92 oring_y_rad = oring_thick/2 * oring_oblate;
93 oring_x_rad = oring_thick/2 / oring_oblate;
94
95 by_oring_z = oring_y_rad * (1 + cos(oring_upper_embed_angle));
96
97 side_height = rivet_posn + bayo_behind + rivet_thick/2;
98 side_thick = rivet_tall + over_rivet_wall;
99
100 top_z = top_thick_by_oring + oring_y_rad + by_oring_z;
101
102 middle_bot_z = top_z - top_thick_middle;
103
104 bayo_entry = bayo_behind / 3.0;
105 bayo_top_z = bayo_behind + bayo_gap;
106
107 rivet_entry_width = rivet_width + side_rivet_gap;
108
109 jig_mark_rad = jig_mark + main_dia/2 + jig_thick;
110
111 handling_dia = oring_bore + oring_thick*2 + min_wall*2;
112 handling_angle = 45;
113
114 sm_inner_rad = (sm_inner_circum + sm_bolt_tighten_allow/2) / TAU;
115 sm_outer_rad = sm_inner_rad + sm_main_thick;
116
117 smc_pos = [ 0, sm_inner_rad, 0 ];
118
119 smc_bolt_nut_dia = sm_bolt_nut_width / cos(30);
120 smc_bolt_nut_eff_thick = sm_bolt_nut_thick + sm_bolt_tighten_allow;
121
122 smc_bolt_y = sm_bolt_dia/2 + sm_bolt_y_clear;
123 smc_max_y = smc_bolt_y + sm_bolt_y_over
124   + max(sm_bolt_head_dia/2, smc_bolt_nut_dia/2);
125 smc_cnr_c_x = sm_bolt_shaft/2 - sm_closure_cnr
126   + sm_bolt_head_thick/2 + smc_bolt_nut_eff_thick/2;
127
128 $fs= coarse ? 2.5 : 0.5;
129 $fa= coarse ? 5 : 1;
130
131 include <poster-tube-lid-parametric.scad>
132
133 // bayonet definition
134
135 bayo_a = [ bayo_entry_x, 0 ];
136 bayo_p = [ 0, bayo_entry_z ];
137 bayo_n = [ 0, bayo_behind-bayo_inramp_z ];
138 bayo_m = [ bayo_inramp_x, bayo_behind ];
139 bayo_l = bayo_m + bayo_interf * [ 1/bayo_interf_slope,  1 ];
140 bayo_k = bayo_l + [ bayo_interf_width, 0 ];
141 bayo_j = bayo_k + bayo_interf * [ 1/bayo_interf_slope, -1 ];
142 bayo_i = bayo_j + [ rivet_width + inside_rivet_gap, 0 ];
143 bayo_h = [ bayo_i[0], bayo_behind + bayo_gap + bayo_interf ];
144 bayo_g = [ bayo_m[0] - rivet_width, bayo_h[1] ];
145
146 bayo_e = [-bayo_p[0], bayo_p[1]] - [rivet_entry_width,0];
147 bayo_d = [-bayo_a[0], bayo_a[1]] - [rivet_entry_width,0];
148 bayo_c = bayo_d + [0,-5];
149 bayo_b = bayo_a + [0,-5];
150
151 bayo_f = [ bayo_e[0], bayo_g[1] + (bayo_e[0] - bayo_g[0]) ];
152
153 bayo_polygon = [ bayo_a,
154                  bayo_b,
155                  bayo_c,
156                  bayo_d,
157                  bayo_e,
158                  bayo_f,
159                  bayo_g,
160                  bayo_h,
161                  bayo_i,
162                  bayo_j,
163                  bayo_k,
164                  bayo_l,
165                  bayo_m,
166                  bayo_n,
167                  bayo_p ];
168
169 echo(bayo_polygon);
170
171 module MainProfile(){
172   main_cnr_pos = [ side_thick, top_z ] - [1,1]*main_cnr;
173   difference(){
174     union(){
175       translate(main_cnr_pos){
176         intersection(){
177           difference(){
178             circle(r = main_cnr);
179             circle(r = main_cnr * 0.5);
180           }
181           square([10,10]);
182         }
183       }
184       polygon([[ -top_middle_dr,        middle_bot_z      ],
185                [ -top_middle_dr,        top_z             ],
186                [ main_cnr_pos[0],       top_z             ],
187                [ side_thick,            main_cnr_pos[1]   ],
188                [ side_thick,            -side_height      ],
189                [ side_taper,            -side_height      ],
190                [ 0,                     -rivet_posn       ],
191                [ 0,                     by_oring_z        ],
192                [ -oring_x_rad,          by_oring_z        ],
193                ],
194               convexity=10);
195     }
196     translate([ oring_mid_dia/2 - main_dia/2, 0 ])
197       hull(){
198       translate([ 0, oring_y_rad ])
199         scale([ 1/oring_oblate * (oring_compress_more+1) , oring_oblate ])
200         circle(oring_thick/2);
201       translate([ 0, oring_y_rad*2 - oring_thick/2 ])
202         circle(oring_thick/2);
203     }
204   }
205 }
206
207 module StrapHoopProfile(){
208   circle(r = strap_hoop_thick/2);
209 }
210
211 module StrapHoop(){ ////toplevel
212   bigrad = strap_hoop_inside/2 + strap_hoop_thick/2;
213   extralen = strap_hoop_thick * 5;
214
215   intersection(){
216     rotate([strap_hoop_elevation, 0,0]){
217       for (x= [ -1, +1 ] * bigrad) {
218         translate([x, -extralen, 0])
219           rotate([-90,0,0])
220           linear_extrude(height= extralen + strap_hoop_strlen + 0.1,
221                          convexity=10)
222           StrapHoopProfile();
223       }
224       translate([0, strap_hoop_strlen, 0]){
225         intersection(){
226           rotate_extrude(convexity=10)
227             translate([bigrad, 0,0])
228             StrapHoopProfile();
229           translate([0,50,0])
230             cube([100,100,100], center=true);
231         }
232       }
233     }
234     translate([0, 50, 0])
235       cube(100, center=true);
236   }
237 }
238
239 module HandlingProfile(){
240 //  translate([
241 }
242
243 module RotateProjectSlice(offset, slice_size, nom_rad, real_rad){
244   // nom_rad > real_rad
245   rotate([0,0, atan2(offset, nom_rad) ]){
246     intersection(){
247       translate([-offset, -10, 0])
248         rotate([90,0,0])
249         linear_extrude(height= nom_rad*2)
250         children(0);
251       translate([0,0, -25])
252         cylinder(h=50, r= real_rad);
253       translate([0,0, -25])
254         linear_extrude(height= 50)
255         polygon([ [ 0,0 ],
256                   [ -slice_size, -real_rad*2 ],
257                   [ +slice_size, -real_rad*2 ] ]);
258     }
259   }
260 }
261
262 module RotateProject(x_min, x_max, slice_size, nom_rad, real_rad){
263   offs = [ for (i=[ x_min :
264                     slice_size :
265                     x_max + slice_size ]) i ];
266   echo (offs);
267   for (off=offs)
268     RotateProjectSlice(off, slice_size, nom_rad, real_rad)
269     children(0);
270 }
271
272 module BayonetCutout(){
273   RotateProject(bayo_c[0], bayo_i[0], bayo_slice_size,
274                 main_dia/2 + side_thick, 
275                 main_dia/2 + rivet_tall)
276     translate([-0.5 * (bayo_a[0] + bayo_d[0]), 0])
277     polygon(bayo_polygon, convexity=10);
278 }
279
280 module ProfilesDemo(){ ////toplevel
281   translate([-10,0]) MainProfile();
282   translate([+10, -side_height]) polygon(bayo_polygon, convexity=10);
283 }
284
285 module LimitForHandling(){ ////toplevel
286   hull() for (r=[0,180])
287     rotate([0,0,r]) {
288       for (rs=[-1,+1]) {
289         for (xd=[0,1]) {
290           rotate([0,0, rs * handling_angle/2]) {
291             translate([rs * xd * main_dia/2 * tan(handling_angle/2),
292                        main_dia/2 + side_thick - main_cnr,
293                        top_z - main_cnr]) {
294               mirror([0,0,1])
295                 cylinder(r= main_cnr, h=50);
296               sphere(main_cnr);
297             }
298           }
299         }
300       } 
301     }
302   hull() rotate_extrude(){
303     translate([ handling_dia/2 - main_cnr, top_z - main_cnr ]) {
304       circle(r = main_cnr);
305       mirror([0,1]) square([ main_cnr, 50 ]);
306     }
307   }
308   //cylinder(r= handling_dia/2, h=20);
309 }
310
311 module Cover(){ ////toplevel
312   render() difference(){
313     intersection(){
314       union(){
315         rotate_extrude(convexity=10)
316           translate([main_dia/2, 0])
317           MainProfile();
318         translate([0,0, middle_bot_z])
319           cylinder(h= top_thick_middle, r = main_dia/2 - top_middle_dr + 1);
320       }
321       LimitForHandling();
322     }
323     for (r=[0,180]){
324       rotate([0,0, r])
325         translate([0,0, -side_height])
326         BayonetCutout();
327       rotate([0,0, r + asin((-oring_rm_beside) / (main_dia/2))])
328         translate([0,
329                    oring_mid_dia/2 + oring_thick/4 * oring_rm_scale,
330                    oring_y_rad * 1.5])
331         rotate([-oring_rm_angle, 0, 0])
332         mirror([0,0,1])
333         cylinder(r = oring_thick/4 * oring_rm_scale, h=20);
334     }
335     for (r=[0 : 60 : 179]) {
336       rotate([0,0, r]) {
337         height = top_thick_middle - brace_above_below*2;
338         translate([0,0, middle_bot_z + brace_above_below + height/2 ])
339         cube(center=true, [ oring_bore - brace_end_shorter,
340                             brace_hole_width, height ]);
341       }
342     }
343   }
344   for (r=[0,180])
345     rotate([0,0,r])
346       translate([-implheadcup_large_dia * .5 - implheadcup_thick/2,
347                  -implheadcup_large_dia * .0,
348                  middle_bot_z + 0.1])
349       ImplHeadCup();
350 //  translate(strap_hoop_thick * [-0.5, 0, +1])
351 //    translate([handling_dia/2, 0, -side_height])
352 //    rotate([0,180,0]) rotate([0,0,90])
353 //    StrapHoop();
354 }
355
356 module SavingHole(){
357   translate([0,0, -10])
358     cylinder(r= main_dia/2 - jig_rim, h=20);
359 }
360
361 module Jig(){ ////toplevel
362   difference(){
363     union(){
364       translate([0,0, -side_height]){
365         cylinder(r= main_dia/2 + jig_thick, h= side_height + jig_thick);
366       }
367       translate([-jig_mark_rad, 0, jig_thick - jig_mark])
368         cube([jig_mark_rad*2, jig_mark, jig_mark]);
369     }
370     translate([0,0, -side_height-1])
371       cylinder(r= main_dia/2, h= side_height + 1);
372     SavingHole();
373     translate([0,0, -rivet_posn])
374       rotate([90, 0,0])
375       translate([0,0, -100])
376       cylinder(r= jig_hole_dia/2, h = 200);
377   }
378 }
379
380 module CoverTest2(){ ////toplevel
381   difference(){
382     Cover();
383     SavingHole();
384   }
385 }
386
387 module CoverTest1(){ ////toplevel
388   difference(){
389     CoverTest2();
390     difference(){
391       for (r= [ 40, 147 ]){
392         rotate([0,0, r]){
393           translate([0,0, -10]) {
394             cube([ main_dia*3, main_dia * .53, 18], center=true);
395           }
396         }
397       }
398 //      translate([ 50, 0, 0 ])
399 //      cube([ 100,
400 //             strap_hoop_inside + strap_hoop_thick*2 + 1,
401 //             100 ],
402 //           center=true);
403     }
404   }
405 }
406
407 module ImplHeadCupTest(){ ////toplevel
408   for (r=[0,180])
409     rotate([0,0,r])
410       translate([-17,0,0])
411       ImplHeadCup();
412 }
413
414 module StrapMountBolt(l_delta){ ///toplevel
415   // positioned relative to smc_pos
416   translate([(smc_bolt_nut_eff_thick - sm_bolt_head_thick)/2,
417              smc_bolt_y,
418              sm_main_width/2]){
419     translate([ -sm_bolt_shaft/2-1, 0,0 ]){
420       rotate([0,90,0]) cylinder(r= sm_bolt_dia/2, h= sm_bolt_shaft+2);
421     }
422     translate([ -sm_bolt_shaft/2, 0,0 ])
423       rotate([0,-90,0])
424       cylinder($fn=6, r=smc_bolt_nut_dia/2,
425                h=smc_bolt_nut_eff_thick + l_delta);
426     translate([ sm_bolt_shaft/2, 0,0 ])
427       rotate([0,90,0])
428       cylinder(r=sm_bolt_head_dia/2, h=sm_bolt_head_thick + l_delta);
429   }
430 }
431
432 module StrapMountProtrusion(half_x, max_y, cnr){
433   translate(smc_pos){
434     linear_extrude(height=sm_main_width, convexity=10){
435       hull(){
436         for (m = [0,1]) mirror([m,0,0]) {
437           translate([-(half_x - cnr), max_y - cnr])
438             circle(r=cnr);
439           translate([-half_x, -sm_inner_rad])
440             square([1,1]);
441         }
442       }
443     }
444   }
445 }
446
447 module StrapMount(){ ////toplevel
448   difference(){
449     union(){
450       cylinder(r=sm_outer_rad, h=sm_main_width);
451       StrapMountProtrusion(smc_cnr_c_x + sm_closure_cnr,
452                            smc_max_y,
453                            sm_closure_cnr);
454       rotate([0,0,180]){
455         StrapMountProtrusion(strap_hoop_inside/2 + strap_hoop_thick,
456                              strap_hoop_thick,
457                              sm_closure_cnr);
458         translate(smc_pos +
459                   [0,0, sm_main_width] +
460                   strap_hoop_thick * [ 0, 0.5, -1.0 ])
461           StrapHoop();
462       }
463     }
464     translate([0,0,-1])
465       cylinder(r=sm_inner_rad, h=sm_main_width+2);
466     translate(smc_pos)
467       StrapMountBolt(10);
468     translate(smc_pos)
469       cube([ sm_bolt_tighten_allow, 40,100 ], center=true);
470   }
471 }
472
473 //ProfilesDemo();
474 //BayonetCutout();
475 //MainProfile();
476 //Cover();
477 //Jig();
478 //CoverTest();