chiark / gitweb /
poster-tube-lid: adjust rivet_posn (from v4)
[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.6;
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.85;
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
34 oring_rm_beside = 8;
35 oring_rm_scale = 2.0;
36 oring_rm_angle = 20;
37
38 side_taper = 1.0;
39
40 bayo_gap = 6.0;
41
42 bayo_entry = bayo_behind/3;
43
44 bayo_slice_size = coarse ? 5 : 1;
45
46 brace_hole_width = 1.0;
47 brace_above_below = 1.2;
48 brace_end_shorter = 0.3;
49
50 jig_thick = 1.4;
51 jig_hole_dia = 3.0;
52 jig_rim = 5;
53 jig_mark = 5;
54
55 // calculated
56
57 bayo_entry_x = bayo_entry;
58 bayo_entry_z = bayo_entry;
59 bayo_inramp_x = bayo_entry;
60 bayo_inramp_z = bayo_entry;
61
62 oring_mid_dia = oring_bore + oring_thick;
63 oring_outer_dia = oring_mid_dia + oring_thick;
64
65 oring_oblate = (1 - oring_compress);
66
67 oring_y_rad = oring_thick/2 * oring_oblate;
68 oring_x_rad = oring_thick/2 / oring_oblate;
69
70 by_oring_z = oring_y_rad * (1 + cos(oring_upper_embed_angle));
71
72 side_height = rivet_posn + bayo_behind + rivet_thick/2;
73 side_thick = rivet_tall + over_rivet_wall;
74
75 top_z = top_thick_by_oring + oring_y_rad + by_oring_z;
76
77 middle_bot_z = top_z - top_thick_middle;
78
79 bayo_entry = bayo_behind / 3.0;
80 bayo_top_z = bayo_behind + bayo_gap;
81
82 rivet_entry_width = rivet_width + side_rivet_gap;
83
84 jig_mark_rad = jig_mark + main_dia/2 + jig_thick;
85
86 handling_dia = oring_bore + oring_thick*2 + min_wall*2;
87 handling_angle = 45;
88
89 $fs= coarse ? 2.5 : 0.5;
90 $fa= coarse ? 5 : 1;
91
92 // bayonet definition
93
94 bayo_a = [ bayo_entry_x, 0 ];
95 bayo_p = [ 0, bayo_entry_z ];
96 bayo_n = [ 0, bayo_behind-bayo_inramp_z ];
97 bayo_m = [ bayo_inramp_x, bayo_behind ];
98 bayo_l = bayo_m + bayo_interf * [ 1/bayo_interf_slope,  1 ];
99 bayo_k = bayo_l + [ bayo_interf_width, 0 ];
100 bayo_j = bayo_k + bayo_interf * [ 1/bayo_interf_slope, -1 ];
101 bayo_i = bayo_j + [ rivet_width + inside_rivet_gap, 0 ];
102 bayo_h = [ bayo_i[0], bayo_behind + bayo_gap + bayo_interf ];
103 bayo_g = [ bayo_m[0] - rivet_width, bayo_h[1] ];
104
105 bayo_e = [-bayo_p[0], bayo_p[1]] - [rivet_entry_width,0];
106 bayo_d = [-bayo_a[0], bayo_a[1]] - [rivet_entry_width,0];
107 bayo_c = bayo_d + [0,-5];
108 bayo_b = bayo_a + [0,-5];
109
110 bayo_f = [ bayo_e[0], bayo_g[1] + (bayo_e[0] - bayo_g[0]) ];
111
112 bayo_polygon = [ bayo_a,
113                  bayo_b,
114                  bayo_c,
115                  bayo_d,
116                  bayo_e,
117                  bayo_f,
118                  bayo_g,
119                  bayo_h,
120                  bayo_i,
121                  bayo_j,
122                  bayo_k,
123                  bayo_l,
124                  bayo_m,
125                  bayo_n,
126                  bayo_p ];
127
128 echo(bayo_polygon);
129
130 module MainProfile(){
131   main_cnr_pos = [ side_thick, top_z ] - [1,1]*main_cnr;
132   difference(){
133     union(){
134       translate(main_cnr_pos){
135         intersection(){
136           difference(){
137             circle(r = main_cnr);
138             circle(r = main_cnr * 0.5);
139           }
140           square([10,10]);
141         }
142       }
143       polygon([[ -top_middle_dr,        middle_bot_z      ],
144                [ -top_middle_dr,        top_z             ],
145                [ main_cnr_pos[0],       top_z             ],
146                [ side_thick,            main_cnr_pos[1]   ],
147                [ side_thick,            -side_height      ],
148                [ side_taper,            -side_height      ],
149                [ 0,                     -rivet_posn       ],
150                [ 0,                     by_oring_z        ],
151                [ -oring_x_rad,          by_oring_z        ],
152                ],
153               convexity=10);
154     }
155     translate([ oring_mid_dia/2 - main_dia/2, 0 ])
156       hull(){
157       translate([ 0, oring_y_rad ])
158         scale([ 1/oring_oblate, oring_oblate ])
159         circle(oring_thick/2);
160       translate([ 0, oring_y_rad*2 - oring_thick/2 ])
161         circle(oring_thick/2);
162     }
163   }
164 }
165
166 module HandlingProfile(){
167 //  translate([
168 }
169
170 module RotateProjectSlice(offset, slice_size, nom_rad, real_rad){
171   // nom_rad > real_rad
172   rotate([0,0, atan2(offset, nom_rad) ]){
173     intersection(){
174       translate([-offset, -10, 0])
175         rotate([90,0,0])
176         linear_extrude(height= nom_rad*2)
177         children(0);
178       translate([0,0, -25])
179         cylinder(h=50, r= real_rad);
180       translate([0,0, -25])
181         linear_extrude(height= 50)
182         polygon([ [ 0,0 ],
183                   [ -slice_size, -real_rad*2 ],
184                   [ +slice_size, -real_rad*2 ] ]);
185     }
186   }
187 }
188
189 module RotateProject(x_min, x_max, slice_size, nom_rad, real_rad){
190   offs = [ for (i=[ x_min :
191                     slice_size :
192                     x_max + slice_size ]) i ];
193   echo (offs);
194   for (off=offs)
195     RotateProjectSlice(off, slice_size, nom_rad, real_rad)
196     children(0);
197 }
198
199 module BayonetCutout(){
200   RotateProject(bayo_c[0], bayo_i[0], bayo_slice_size,
201                 main_dia/2 + side_thick, 
202                 main_dia/2 + rivet_tall)
203     translate([-0.5 * (bayo_a[0] + bayo_d[0]), 0])
204     polygon(bayo_polygon, convexity=10);
205 }
206
207 module ProfilesDemo(){ ////toplevel
208   translate([-10,0]) MainProfile();
209   translate([+10, -side_height]) polygon(bayo_polygon, convexity=10);
210 }
211
212 module LimitForHandling(){ ////toplevel
213   hull() for (r=[0,180])
214     rotate([0,0,r]) {
215       for (rs=[-1,+1]) {
216         for (xd=[0,1]) {
217           rotate([0,0, rs * handling_angle/2]) {
218             translate([rs * xd * main_dia/2 * tan(handling_angle/2),
219                        main_dia/2 + side_thick - main_cnr,
220                        top_z - main_cnr]) {
221               mirror([0,0,1])
222                 cylinder(r= main_cnr, h=50);
223               sphere(main_cnr);
224             }
225           }
226         }
227       } 
228     }
229   hull() rotate_extrude(){
230     translate([ handling_dia/2 - main_cnr, top_z - main_cnr ]) {
231       circle(r = main_cnr);
232       mirror([0,1]) square([ main_cnr, 50 ]);
233     }
234   }
235   //cylinder(r= handling_dia/2, h=20);
236 }
237
238 module Cover(){ ////toplevel
239   render() difference(){
240     intersection(){
241       union(){
242         rotate_extrude(convexity=10)
243           translate([main_dia/2, 0])
244           MainProfile();
245         translate([0,0, middle_bot_z])
246           cylinder(h= top_thick_middle, r = main_dia/2 - top_middle_dr + 1);
247       }
248       LimitForHandling();
249     }
250     for (r=[0,180]){
251       rotate([0,0, r])
252         translate([0,0, -side_height])
253         BayonetCutout();
254       rotate([0,0, r + asin((-oring_rm_beside) / (main_dia/2))])
255         translate([0,
256                    oring_mid_dia/2 + oring_thick/4 * oring_rm_scale,
257                    oring_y_rad * 1.5])
258         rotate([-oring_rm_angle, 0, 0])
259         mirror([0,0,1])
260         cylinder(r = oring_thick/4 * oring_rm_scale, h=20);
261     }
262     for (r=[0 : 60 : 179]) {
263       rotate([0,0, r]) {
264         height = top_thick_middle - brace_above_below*2;
265         translate([0,0, middle_bot_z + brace_above_below + height/2 ])
266         cube(center=true, [ oring_bore - brace_end_shorter,
267                             brace_hole_width, height ]);
268       }
269     }
270   }
271 }
272
273 module SavingHole(){
274   translate([0,0, -10])
275     cylinder(r= main_dia/2 - jig_rim, h=20);
276 }
277
278 module Jig(){ ////toplevel
279   difference(){
280     union(){
281       translate([0,0, -side_height]){
282         cylinder(r= main_dia/2 + jig_thick, h= side_height + jig_thick);
283       }
284       translate([-jig_mark_rad, 0, jig_thick - jig_mark])
285         cube([jig_mark_rad*2, jig_mark, jig_mark]);
286     }
287     translate([0,0, -side_height-1])
288       cylinder(r= main_dia/2, h= side_height + 1);
289     SavingHole();
290     translate([0,0, -rivet_posn])
291       rotate([90, 0,0])
292       translate([0,0, -100])
293       cylinder(r= jig_hole_dia/2, h = 200);
294   }
295 }
296
297 module CoverTest2(){ ////toplevel
298   difference(){
299     Cover();
300     SavingHole();
301   }
302 }
303
304 module CoverTest1(){ ////toplevel
305   difference(){
306     CoverTest2();
307     for (r= [ 40, 147 ]){
308       rotate([0,0, r]){
309         translate([0,0, -10]) {
310           cube([ main_dia*3, main_dia * .55, 18], center=true);
311         }
312       }
313     }
314   }
315 }
316
317 //ProfilesDemo();
318 //BayonetCutout();
319 //MainProfile();
320 //Cover();
321 //Jig();
322 //CoverTest();