chiark / gitweb /
mic-table-clamp: Adjustments from blank, binary chop
[reprap-play.git] / lock-inframe-bracket.scad
1 // -*- C -*-
2
3 // use shell thickness 1.50
4 // use fill density 40%
5
6 include <funcs.scad>
7
8 tube_dia = 27.5 + 1.625 + 1.32;
9 lock_w = 42.5 + 0.5;
10 lock_d = 28.0 + 0.5;
11 main_h = 45.0;
12 backflange_d = 12;
13 backflange_hole_dy = -1;
14 lockshaft_dia = 14.35;
15
16 cliprecess_h = 16;
17 total_h = 45;
18
19 back_gap = 12.5;
20 main_th = 4.50;
21 tube_th = 5.50;
22
23 midweb_d = 3;
24 clip_th = 3.5;
25 clip_gap = 2.5;
26 clip_d = 22.0;
27
28 mountscrew_dia = 4 + 0.5;
29 clipbolt_dia = 5 + 0.6;
30
31 mountscrew_washer = 10;
32
33 backflange_th = 4.5;
34
35 $fn=50;
36
37 join_cr = 9;
38
39 tube_rear_extra_th = 1;
40
41 divide_shaft_w = 1.75;
42 divide_shaft_l = 1.5;
43 divide_head_dx = 1.75;
44 divide_head_th = 1.5;
45 divide_gap = 0.75;
46
47 divide_angle = 26;
48 divide_fudge_r = 4.75;
49
50 backflange_angle = 20;
51
52 // calculated
53
54 lockshaft_r = [1, 1] * lockshaft_dia / 2;
55 front_th = main_th;
56
57 tube_or = tube_dia/2 + tube_th;
58 back_ohw = back_gap/2 + backflange_th;
59 backflange_ymin = tube_dia/2 + backflange_d;
60
61 lock_0y = tube_dia/2 + lock_d/2 + midweb_d;
62 lock_0x = lock_w/2 - lock_d/2;
63 lock_0 = [lock_0x,lock_0y];
64
65 lock_or = [lock_w, lock_d]/2 + [front_th,front_th];
66
67 module oval(sz){ // sz[0] > sz[1]
68   xr = sz[0];
69   yr = sz[1];
70   hull(){
71     for (sx=[-1,+1]) {
72       translate([sx * (xr-yr), 0])
73         circle(r=yr);
74     }
75   }
76 }
77
78 module JoinCircs(jr){
79   // http://mathworld.wolfram.com/Circle-CircleIntersection.html
80   R = tube_or + join_cr;
81   r = lock_or[1] + join_cr;
82   d = dist2d( [0,0], lock_0 );
83   x = (d*d - r*r + R*R) / (2*d);
84   y = sqrt( R*R - x*x );
85
86   echo(lock_0x, lock_0y, R,r, d, x,y);
87
88   for (m=[0,1]) {
89     mirror([m,0]) {
90       rotate(atan2(lock_0y, lock_0x)) {
91         translate([x,-y])
92           circle(r= jr);
93       }
94     }
95   }
96 }
97
98 module DivideHook(){ ////toplevel
99   w = tube_th/2;
100   d = divide_gap;
101
102   translate([-1,0] * (w + d + w)){
103     for (sx=[-1,+1])
104       translate([-(w + w+d) * sx, 0]) circle(r= w);
105     difference(){
106       circle(r = 3*w + d);
107       circle(r =   w + d);
108       translate([-10*w, -10*w]) square([20*w, 10*w]);
109     }
110   }
111 }
112
113 module DivideCut(){
114   w = tube_th/2;
115   d = divide_gap;
116   br = tube_dia/2 + tube_th;
117
118   difference(){
119     offset(r=divide_gap) DivideHook();
120     DivideHook();
121     translate([-2*w,0]) mirror([0,1]) square([4*w, 4*w]);
122   }
123 }
124
125 module DivideCutB(){
126   w = tube_th/2;
127   d = divide_gap;
128   br = tube_dia/2 + tube_th;
129   
130   intersection(){
131     translate([br - tube_th/2,0]) {
132       difference(){
133         circle(r=br + d);
134         circle(r=br);
135       }
136     }
137     translate([-2*w, 0]) mirror([0,1]) square(4*w);
138   }
139 }
140
141 module DivideSurround(){
142   w = tube_th/2;
143   d = divide_gap;
144
145   offset(r= w*2) {
146     hull() {
147       DivideCut();
148       translate([-(4*w + 2*d), 8*w]) circle(r=w);
149     }
150   }
151 }
152
153 module DivideInPlace(){
154   rotate([0,0, -divide_angle])
155     translate([ -tube_dia/2 -tube_th/2, 0])
156     children();
157 }
158
159 module MainPlan(){ ////toplevel
160   difference(){
161     union(){
162       difference(){
163         union(){
164           hull(){
165             for (t=[0, tube_rear_extra_th])
166               translate([0, -t])
167                 circle(r = tube_or);
168           }
169           rotate([0,0, backflange_angle])
170             translate([-back_ohw,0]) mirror([0,1])
171             square([back_ohw*2, backflange_ymin]);
172
173           translate([0, lock_0y]){
174             oval(lock_or);
175           }
176
177           hull(){
178             JoinCircs(0.01);
179             polygon([[0,0], lock_0, [-lock_0[0], lock_0[1]]]);
180           }
181         }
182
183         rotate([0,0, backflange_angle])
184           translate([-back_gap/2,1]) mirror([0,1])
185           square([back_gap, backflange_ymin+2]);
186
187         JoinCircs(join_cr);
188       }
189
190       DivideInPlace() DivideSurround();
191     }
192     translate([0, lock_0y]){
193       oval([lock_w/2, lock_d/2]);
194     }
195
196     circle(r = tube_dia/2);
197
198     DivideInPlace() DivideCut();
199     DivideInPlace() DivideCutB();
200   }
201 }
202
203 lockshaft_or = lockshaft_r + [clip_th,clip_th];
204 cliprecess_ymax = cliprecess_h - lockshaft_r[1];
205 clip_ymin = cliprecess_ymax - total_h;
206 clip_ogap = clip_gap + clip_th*2;
207
208 module ClipElevationPositive(){
209   hull(){
210     oval(lockshaft_or);
211     translate([0, -lockshaft_or[1] * sqrt(2)])
212       square(center=true, 0.5);
213   }
214   translate([-lockshaft_or[0], 0])
215     square([lockshaft_or[0]*2, cliprecess_ymax]);
216   translate([-clip_ogap/2, 0]) mirror([0,1]) square([clip_ogap, -clip_ymin]);
217 }
218
219 module ClipElevationNegative(){
220   hull(){
221     for (y=[0, cliprecess_ymax+1])
222       translate([0, y])
223         oval(lockshaft_r);
224   }
225   translate([-clip_gap/2, 1]) mirror([0,1]) square([clip_gap, 2-clip_ymin]);
226 }
227
228 module ClipElevation(){
229   difference(){
230     ClipElevationPositive(1);
231     ClipElevationNegative(0);
232   }
233 }
234
235 module ExtrudeClipElevation(extra=0){
236   translate([0,
237              lock_0y + lock_d/2 + clip_d + extra,
238              -clip_ymin])
239     rotate([90,0,0])
240     linear_extrude(height= clip_d + extra*2, convexity=100)
241     children(0);
242 }
243
244 module ThroughHole(r, y, z, x=-50) {
245   translate([x, y, z])
246     rotate([0, 90, 0])
247     cylinder(r=r, h=100, $fn=20);
248 }
249
250 module MountingHoleCylinders(r, x=-50){
251   for (z=[ 1/4, 3/4 ]) {
252     rotate([0,0, backflange_angle])
253       ThroughHole( r,
254                    -tube_dia/2 -0.5*backflange_d + backflange_hole_dy,
255                    total_h * z,
256                    x);
257   }
258 }
259
260 module ThroughHoles(){
261   MountingHoleCylinders(mountscrew_dia/2);
262
263   ThroughHole( clipbolt_dia/2,
264                lock_0y + lock_d/2 + clip_d/2 + front_th/2,
265                total_h - cliprecess_h - clip_th - clip_d/2 );
266 }
267
268 module MainPositive(){
269   difference(){
270     union(){
271       linear_extrude(height=total_h, convexity=100) MainPlan();
272       ExtrudeClipElevation() ClipElevationPositive();
273     }
274     ExtrudeClipElevation(1) ClipElevationNegative();
275   }
276 }
277
278 module Bracket(){ ////toplevel
279   difference(){
280     MainPositive();
281     ThroughHoles();
282   }
283 }
284
285 module TestTopEdge(){ ////toplevel
286   intersection(){
287     translate([0,0, -total_h])
288       translate([0,0, 4])
289       Bracket();
290     translate([-200,-200,0])
291       cube([400,400,100]);
292   }
293 }
294
295 module TestClipBoltHole(){ ////toplevel
296   intersection(){
297     union(){
298       translate([0, 0, -5])
299         Bracket();
300       translate([-4, lock_0y + lock_d/2 + 1, 0])
301         cube([8, 4, 1.5]);
302     }
303     translate([-200, lock_0y + lock_d/2 + 0.1])
304       cube([400, 400, total_h-20]);
305   }
306 }
307
308 module Demo(){ ////toplevel
309   Bracket();
310   color("blue") MountingHoleCylinders(mountscrew_dia/2 - 0.1);
311   color("black") MountingHoleCylinders(mountscrew_washer/2,
312                                        back_ohw + 0.25);
313 }
314
315 module DivideDemo(){ ////toplevel
316   color("black") translate([0,0,-2]) MainPlan();
317   color("grey") DivideInPlace() DivideHook();
318   color("blue") translate([0,0,-4]) DivideInPlace() DivideCut();
319 }
320
321 //MainPlan();
322 //ClipElevationPositive();
323 //ClipElevation();
324 //MainPositive();
325 //%ThroughHoles();
326 //TestTopEdge();
327 //TestClipBoltHole();
328
329 //Bracket();
330