chiark / gitweb /
poster-tube-lid: fix braces (again)
[reprap-play.git] / poster-tube-lid.scad
1 // -*- C -*-
2
3 main_dia = 71.2 + 0.50 - 2.26;
4 top_thick_middle = 4;
5 top_thick_by_oring = 2.5;
6 top_middle_dr = 11;
7
8 main_cnr = 4.0;
9
10 rivet_posn = 6.0;
11 rivet_thick = 1.67;
12 rivet_width = 4.15 + 1.0;
13 rivet_tall = 5.51 + 0.49;
14
15 over_rivet_wall = 0.5;
16 side_rivet_gap = 1.5;
17
18 bayo_interf = 1.25;
19 bayo_behind = 3.5;
20 bayo_interf_width = 2.0;
21 bayo_interf_slope = 0.75;
22
23 oring_thick = 5.0;
24 oring_bore = 62.0;
25
26 oring_upper_embed_angle = 80;
27 oring_compress = 0.1; // proportion
28
29 side_taper = 1.0;
30
31 bayo_above_gap = 1.0;
32
33 bayo_entry = bayo_behind/3;
34
35 bayo_slice_size = 1;
36
37 brace_hole_width = 1.0;
38 brace_above_below = 1.2;
39 brace_end_shorter = 0.3;
40
41 jig_thick = 1.4;
42 jig_hole_dia = 3.0;
43 jig_rim = 5;
44 jig_mark = 5;
45
46 // calculated
47
48 bayo_entry_x = bayo_entry;
49 bayo_entry_z = bayo_entry;
50 bayo_inramp_x = bayo_entry;
51 bayo_inramp_z = bayo_entry;
52
53 oring_mid_dia = oring_bore + oring_thick;
54 oring_outer_dia = oring_mid_dia + oring_thick;
55
56 oring_oblate = (1 - oring_compress);
57
58 oring_y_rad = oring_thick/2 * oring_oblate;
59 oring_x_rad = oring_thick/2 / oring_oblate;
60
61 seal_thick = oring_y_rad * (1 + cos(oring_upper_embed_angle));
62
63 side_height = rivet_posn + bayo_behind + rivet_thick/2;
64 side_thick = rivet_tall + over_rivet_wall;
65
66 top_thick = max(top_thick_middle,
67                 top_thick_by_oring + oring_y_rad);
68
69 top_z = top_thick + seal_thick;
70
71 middle_bot_z = top_z - top_thick_middle;
72
73 bayo_entry = bayo_behind / 3.0;
74 bayo_top_z = bayo_behind + rivet_thick + bayo_above_gap;
75 bayo_entry_ramp = bayo_entry + bayo_interf;
76
77 rivet_entry_width = rivet_width + side_rivet_gap;
78
79 jig_mark_rad = jig_mark + main_dia/2 + jig_thick;
80
81 $fs=0.5;
82 $fa=1;
83
84 // bayonet definition
85
86 bayo_a = [ bayo_entry_x, 0 ];
87 bayo_p = [ 0, bayo_entry_z ];
88 bayo_n = [ 0, bayo_behind-bayo_inramp_z ];
89 bayo_m = [ bayo_inramp_x, bayo_behind ];
90 bayo_l = bayo_m + bayo_interf * [ 1/bayo_interf_slope,  1 ];
91 bayo_k = bayo_l + [ bayo_interf_width, 0 ];
92 bayo_j = bayo_k + bayo_interf * [ 1/bayo_interf_slope, -1 ];
93 bayo_i = bayo_j + [ rivet_width, 0 ];
94 bayo_h = [ bayo_i[0], bayo_behind + rivet_thick
95                       + bayo_above_gap + bayo_interf ];
96 bayo_g = [ bayo_m[0] - rivet_width, bayo_h[1] ];
97
98 bayo_e = [-bayo_p[0], bayo_p[1]] - [rivet_entry_width,0];
99 bayo_d = [-bayo_a[0], bayo_a[1]] - [rivet_entry_width,0];
100 bayo_c = bayo_d + [0,-5];
101 bayo_b = bayo_a + [0,-5];
102
103 bayo_f = [ bayo_e[0], bayo_g[1] + (bayo_e[0] - bayo_g[0]) ];
104
105 bayo_polygon = [ bayo_a,
106                  bayo_b,
107                  bayo_c,
108                  bayo_d,
109                  bayo_e,
110                  bayo_f,
111                  bayo_g,
112                  bayo_h,
113                  bayo_i,
114                  bayo_j,
115                  bayo_k,
116                  bayo_l,
117                  bayo_m,
118                  bayo_n,
119                  bayo_p ];
120
121 echo(bayo_polygon);
122
123 module MainProfile(){
124   main_cnr_pos = [ side_thick, top_z ] - [1,1]*main_cnr;
125   difference(){
126     union(){
127       translate(main_cnr_pos){
128         intersection(){
129           difference(){
130             circle(r = main_cnr);
131             circle(r = main_cnr * 0.5);
132           }
133           square([10,10]);
134         }
135       }
136       polygon([[ -top_middle_dr,        middle_bot_z      ],
137                [ -top_middle_dr,        top_z             ],
138                [ main_cnr_pos[0],       top_z             ],
139                [ side_thick,            main_cnr_pos[1]   ],
140                [ side_thick,            -side_height      ],
141                [ side_taper,            -side_height      ],
142                [ 0,                     -rivet_posn       ],
143                [ 0,                     seal_thick        ],
144                [ -oring_x_rad,          seal_thick        ],
145                ],
146               convexity=10);
147     }
148     translate([ oring_mid_dia/2 - main_dia/2, 0 ])
149       hull(){
150       translate([ 0, oring_y_rad ])
151         scale([ 1/oring_oblate, oring_oblate ])
152         circle(oring_thick/2);
153       translate([ 0, oring_y_rad*2 - oring_thick/2 ])
154         circle(oring_thick/2);
155     }
156   }
157 }
158
159 module RotateProjectSlice(offset, slice_size, nom_rad, real_rad){
160   // nom_rad > real_rad
161   rotate([0,0, atan2(offset, nom_rad) ]){
162     intersection(){
163       translate([-offset, -10, 0])
164         rotate([90,0,0])
165         linear_extrude(height= nom_rad*2)
166         children(0);
167       translate([0,0, -25])
168         cylinder(h=50, r= real_rad);
169       translate([0,0, -25])
170         linear_extrude(height= 50)
171         polygon([ [ 0,0 ],
172                   [ -slice_size, -real_rad*2 ],
173                   [ +slice_size, -real_rad*2 ] ]);
174     }
175   }
176 }
177
178 module RotateProject(x_min, x_max, slice_size, nom_rad, real_rad){
179   offs = [ for (i=[ x_min :
180                     slice_size :
181                     x_max + slice_size ]) i ];
182   echo (offs);
183   for (off=offs)
184     RotateProjectSlice(off, slice_size, nom_rad, real_rad)
185     children(0);
186 }
187
188 module BayonetCutout(){
189   RotateProject(bayo_c[0], bayo_i[0], bayo_slice_size,
190                 main_dia/2 + side_thick, 
191                 main_dia/2 + rivet_tall)
192     polygon(bayo_polygon, convexity=10);
193 }
194
195 module ProfilesDemo(){ ////toplevel
196   translate([-10,0]) MainProfile();
197   translate([+10,0]) polygon(bayo_polygon, convexity=10);
198 }
199
200 module Cover(){ ////toplevel
201   render() difference(){
202     union(){
203       rotate_extrude(convexity=10)
204         translate([main_dia/2, 0])
205         MainProfile();
206       translate([0,0, middle_bot_z])
207         cylinder(h= top_thick_middle, r = main_dia/2 - top_middle_dr + 1);
208     }
209     for (r=[0,180])
210       rotate([0,0, r])
211         translate([0,0, -side_height])
212         BayonetCutout();
213     for (r=[0 : 60 : 179]) {
214       rotate([0,0, r]) {
215         height = top_thick_middle - brace_above_below*2;
216         translate([0,0, middle_bot_z + brace_above_below + height/2 ])
217         cube(center=true, [ oring_bore - brace_end_shorter,
218                             brace_hole_width, height ]);
219       }
220     }
221   }
222 }
223
224 module SavingHole(){
225   translate([0,0, -10])
226     cylinder(r= main_dia/2 - jig_rim, h=20);
227 }
228
229 module Jig(){ ////toplevel
230   difference(){
231     union(){
232       translate([0,0, -side_height]){
233         cylinder(r= main_dia/2 + jig_thick, h= side_height + jig_thick);
234       }
235       translate([-jig_mark_rad, 0, jig_thick - jig_mark])
236         cube([jig_mark_rad*2, jig_mark, jig_mark]);
237     }
238     translate([0,0, -side_height-1])
239       cylinder(r= main_dia/2, h= side_height + 1);
240     SavingHole();
241     translate([0,0, -rivet_posn])
242       rotate([90, 0,0])
243       translate([0,0, -100])
244       cylinder(r= jig_hole_dia/2, h = 200);
245   }
246 }
247
248 module CoverTest2(){ ////toplevel
249   difference(){
250     Cover();
251     SavingHole();
252   }
253 }
254
255 module CoverTest1(){ ////toplevel
256   difference(){
257     CoverTest2();
258     translate([0,0, -10])
259       cube([ main_dia*3, main_dia * .85, 20], center=true);
260   }
261 }
262
263 //ProfilesDemo();
264 //BayonetCutout();
265 //MainProfile();
266 //Cover();
267 //Jig();
268 //CoverTest();