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