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