chiark / gitweb /
ksafe-base: wip
[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 DivideHook(){ ////toplevel
101   w = tube_th/2;
102   d = divide_gap;
103
104   translate([-1,0] * (w + d + w)){
105     for (sx=[-1,+1])
106       translate([-(w + w+d) * sx, 0]) circle(r= w);
107     difference(){
108       circle(r = 3*w + d);
109       circle(r =   w + d);
110       translate([-10*w, -10*w]) square([20*w, 10*w]);
111     }
112   }
113 }
114
115 module DivideCut(){
116   w = tube_th/2;
117   d = divide_gap;
118   br = tube_dia/2 + tube_th;
119
120   difference(){
121     offset(r=divide_gap) DivideHook();
122     DivideHook();
123     translate([-2*w,0]) mirror([0,1]) square([4*w, 4*w]);
124   }
125 }
126
127 module DivideCutB(){
128   w = tube_th/2;
129   d = divide_gap;
130   br = tube_dia/2 + tube_th;
131   
132   intersection(){
133     translate([br - tube_th/2,0]) {
134       difference(){
135         circle(r=br + d);
136         circle(r=br);
137       }
138     }
139     translate([-2*w, 0]) mirror([0,1]) square(4*w);
140   }
141 }
142
143 module DivideSurround(){
144   w = tube_th/2;
145   d = divide_gap;
146
147   offset(r= w*2) {
148     hull() {
149       DivideCut();
150       translate([-(4*w + 2*d), 8*w]) circle(r=w);
151     }
152   }
153 }
154
155 module DivideInPlace(){
156   rotate([0,0, -divide_angle])
157     translate([ -tube_dia/2 -tube_th/2, 0])
158     children();
159 }
160
161 module MainPlan(){ ////toplevel
162   difference(){
163     union(){
164       difference(){
165         union(){
166           hull(){
167             for (t=[0, tube_rear_extra_th])
168               translate([0, -t])
169                 circle(r = tube_or);
170           }
171           rotate([0,0, backflange_angle])
172             translate([-back_ohw,0]) mirror([0,1])
173             square([back_ohw*2, backflange_ymin]);
174
175           translate([0, lock_0y]){
176             oval(lock_or);
177           }
178
179           hull(){
180             JoinCircs(0.01);
181             polygon([[0,0], lock_0, [-lock_0[0], lock_0[1]]]);
182           }
183         }
184
185         rotate([0,0, backflange_angle])
186           translate([-back_gap/2,1]) mirror([0,1])
187           square([back_gap, backflange_ymin+2]);
188
189         JoinCircs(join_cr);
190       }
191
192       DivideInPlace() DivideSurround();
193     }
194     translate([0, lock_0y]){
195       oval([lock_w/2, lock_d/2]);
196     }
197
198     circle(r = tube_dia/2);
199
200     DivideInPlace() DivideCut();
201     DivideInPlace() DivideCutB();
202   }
203 }
204
205 lockshaft_or = lockshaft_r + [clip_th,clip_th];
206 cliprecess_ymax = cliprecess_h - lockshaft_r[1];
207 clip_ymin = cliprecess_ymax - total_h;
208 clip_ogap = clip_gap + clip_th*2;
209
210 module ClipElevationPositive(){
211   hull(){
212     oval(lockshaft_or);
213     translate([0, -lockshaft_or[1] * sqrt(2)])
214       square(center=true, 0.5);
215   }
216   translate([-lockshaft_or[0], 0])
217     square([lockshaft_or[0]*2, cliprecess_ymax]);
218   translate([-clip_ogap/2, 0]) mirror([0,1]) square([clip_ogap, -clip_ymin]);
219 }
220
221 module ClipElevationNegative(){
222   hull(){
223     for (y=[0, cliprecess_ymax+1])
224       translate([0, y])
225         oval(lockshaft_r);
226   }
227   translate([-clip_gap/2, 1]) mirror([0,1]) square([clip_gap, 2-clip_ymin]);
228 }
229
230 module ClipElevation(){
231   difference(){
232     ClipElevationPositive(1);
233     ClipElevationNegative(0);
234   }
235 }
236
237 module ExtrudeClipElevation(extra=0){
238   translate([0,
239              lock_0y + lock_d/2 + clip_d + extra,
240              -clip_ymin])
241     rotate([90,0,0])
242     linear_extrude(height= clip_d + extra*2, convexity=100)
243     children(0);
244 }
245
246 module ThroughHole(r, y, z, x=-50) {
247   translate([x, y, z])
248     rotate([0, 90, 0])
249     cylinder(r=r, h=100, $fn=20);
250 }
251
252 module MountingHoleCylinders(r, x=-50){
253   for (z=[ 1/4, 3/4 ]) {
254     rotate([0,0, backflange_angle])
255       ThroughHole( r,
256                    -tube_dia/2 -0.5*backflange_d + backflange_hole_dy,
257                    total_h * z,
258                    x);
259   }
260 }
261
262 module ThroughHoles(){
263   MountingHoleCylinders(mountscrew_dia/2);
264
265   ThroughHole( clipbolt_dia/2,
266                lock_0y + lock_d/2 + clip_d/2 + front_th/2,
267                total_h - cliprecess_h - clip_th - clip_d/2 );
268 }
269
270 module MainPositive(){
271   difference(){
272     union(){
273       linear_extrude(height=total_h, convexity=100) MainPlan();
274       ExtrudeClipElevation() ClipElevationPositive();
275     }
276     ExtrudeClipElevation(1) ClipElevationNegative();
277   }
278 }
279
280 module Bracket(){ ////toplevel
281   difference(){
282     MainPositive();
283     ThroughHoles();
284   }
285 }
286
287 module TestTopEdge(){ ////toplevel
288   intersection(){
289     translate([0,0, -total_h])
290       translate([0,0, 4])
291       Bracket();
292     translate([-200,-200,0])
293       cube([400,400,100]);
294   }
295 }
296
297 module TestClipBoltHole(){ ////toplevel
298   intersection(){
299     union(){
300       translate([0, 0, -5])
301         Bracket();
302       translate([-4, lock_0y + lock_d/2 + 1, 0])
303         cube([8, 4, 1.5]);
304     }
305     translate([-200, lock_0y + lock_d/2 + 0.1])
306       cube([400, 400, total_h-20]);
307   }
308 }
309
310 module Demo(){ ////toplevel
311   Bracket();
312   color("blue") MountingHoleCylinders(mountscrew_dia/2 - 0.1);
313   color("black") MountingHoleCylinders(mountscrew_washer/2,
314                                        back_ohw + 0.25);
315 }
316
317 module DivideDemo(){ ////toplevel
318   color("black") translate([0,0,-2]) MainPlan();
319   color("grey") DivideInPlace() DivideHook();
320   color("blue") translate([0,0,-4]) DivideInPlace() DivideCut();
321 }
322
323 //MainPlan();
324 //ClipElevationPositive();
325 //ClipElevation();
326 //MainPositive();
327 //%ThroughHoles();
328 //TestTopEdge();
329 //TestClipBoltHole();
330
331 //Bracket();
332