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