chiark / gitweb /
lock-inframe-bracket: more adjustments
[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 lockshaft_dia = 14.35;
14
15 cliprecess_h = 16;
16 total_h = 45;
17
18 back_gap = 12.5;
19 main_th = 3.50;
20 tube_th = 4.00;
21
22 midweb_d = 3;
23 clip_th = 3.5;
24 clip_gap = 2.5;
25 clip_d = 22.0;
26
27 mountscrew_dia = 4 + 0.5;
28 clipbolt_dia = 5 + 0.6;
29
30 backflange_th = 4.5;
31
32 $fn=50;
33
34 join_cr = 9;
35
36 tube_rear_extra_th = 1;
37
38 divide_shaft_w = 1.75;
39 divide_shaft_l = 1.5;
40 divide_head_dx = 1.75;
41 divide_head_th = 1.5;
42 divide_gap = 0.50;
43 divide_heads = 2;
44
45 divide_angle = 26;
46 divide_fudge_r = 4.75;
47 divide_around = 3.5;
48
49 backflange_angle = 20;
50
51 // calculated
52
53 lockshaft_r = [1, 1] * lockshaft_dia / 2;
54 front_th = main_th;
55
56 tube_or = tube_dia/2 + tube_th;
57 back_ohw = back_gap/2 + backflange_th;
58 backflange_ymin = tube_or+backflange_d;
59
60 lock_0y = tube_dia/2 + lock_d/2 + midweb_d;
61 lock_0x = lock_w/2 - lock_d/2;
62 lock_0 = [lock_0x,lock_0y];
63
64 lock_or = [lock_w, lock_d]/2 + [front_th,front_th];
65
66 module oval(sz){ // sz[0] > sz[1]
67   xr = sz[0];
68   yr = sz[1];
69   hull(){
70     for (sx=[-1,+1]) {
71       translate([sx * (xr-yr), 0])
72         circle(r=yr);
73     }
74   }
75 }
76
77 module JoinCircs(jr){
78   // http://mathworld.wolfram.com/Circle-CircleIntersection.html
79   R = tube_or + join_cr;
80   r = lock_or[1] + join_cr;
81   d = dist2d( [0,0], lock_0 );
82   x = (d*d - r*r + R*R) / (2*d);
83   y = sqrt( R*R - x*x );
84
85   echo(lock_0x, lock_0y, R,r, d, x,y);
86
87   for (m=[0,1]) {
88     mirror([m,0]) {
89       rotate(atan2(lock_0y, lock_0x)) {
90         translate([x,-y])
91           circle(r= jr);
92       }
93     }
94   }
95 }
96
97 module DividePlan(xl=10){
98   w = divide_shaft_w;
99   g = divide_gap;
100   l = divide_shaft_l + g;
101   t = divide_head_th + g;
102   dx = divide_head_dx;
103   for (m=[0,1]) mirror([m,0]) {
104     translate([w, 0]) square([xl, g]);
105     for (i=[0:divide_heads-1]) {
106       translate([w, i*(l + t)]) {
107         translate([0, 0]) square([g, l + g]);
108         translate([0, l]) square([divide_head_dx + g, g]);
109         translate([dx, l]) square([g, t + g]);
110         translate([0, l + t])
111           square([divide_head_dx + g, g]);
112       }
113     }
114     translate([-0.1, (l + t) * divide_heads])
115       square([w + g, g]);
116   }
117 }
118
119 module DividePlanInPlace(xl=10){
120   rotate([0,0, -divide_angle])
121     translate([ -tube_dia/2 -tube_th/2 - divide_fudge_r, 0])
122     DividePlan(xl);
123 }
124
125 module MainPlan(){
126   difference(){
127     union(){
128       difference(){
129         union(){
130           hull(){
131             for (t=[0, tube_rear_extra_th])
132               translate([0, -t])
133                 circle(r = tube_or);
134           }
135           rotate([0,0, backflange_angle])
136             translate([-back_ohw,0]) mirror([0,1])
137             square([back_ohw*2, backflange_ymin]);
138
139           translate([0, lock_0y]){
140             oval(lock_or);
141           }
142
143           hull(){
144             JoinCircs(0.01);
145             polygon([[0,0], lock_0, [-lock_0[0], lock_0[1]]]);
146           }
147         }
148
149         rotate([0,0, backflange_angle])
150           translate([-back_gap/2,1]) mirror([0,1])
151           square([back_gap, backflange_ymin+2]);
152
153         JoinCircs(join_cr);
154       }
155
156       hull(){
157         minkowski(){
158           DividePlanInPlace(0.1);
159           circle(divide_around);
160         }
161       }
162     }
163     translate([0, lock_0y]){
164       oval([lock_w/2, lock_d/2]);
165     }
166
167     circle(r = tube_dia/2);
168
169     DividePlanInPlace();
170   }
171 }
172
173 lockshaft_or = lockshaft_r + [clip_th,clip_th];
174 cliprecess_ymax = cliprecess_h - lockshaft_r[1];
175 clip_ymin = cliprecess_ymax - total_h;
176 clip_ogap = clip_gap + clip_th*2;
177
178 module ClipElevationPositive(){
179   hull(){
180     oval(lockshaft_or);
181     translate([0, -lockshaft_or[1] * sqrt(2)])
182       square(center=true, 0.5);
183   }
184   translate([-lockshaft_or[0], 0])
185     square([lockshaft_or[0]*2, cliprecess_ymax]);
186   translate([-clip_ogap/2, 0]) mirror([0,1]) square([clip_ogap, -clip_ymin]);
187 }
188
189 module ClipElevationNegative(){
190   hull(){
191     for (y=[0, cliprecess_ymax+1])
192       translate([0, y])
193         oval(lockshaft_r);
194   }
195   translate([-clip_gap/2, 1]) mirror([0,1]) square([clip_gap, 2-clip_ymin]);
196 }
197
198 module ClipElevation(){
199   difference(){
200     ClipElevationPositive(1);
201     ClipElevationNegative(0);
202   }
203 }
204
205 module ExtrudeClipElevation(extra=0){
206   translate([0,
207              lock_0y + lock_d/2 + clip_d + extra,
208              -clip_ymin])
209     rotate([90,0,0])
210     linear_extrude(height= clip_d + extra*2, convexity=100)
211     children(0);
212 }
213
214 module ThroughHole(r, y, z) {
215   translate([-50, y, z])
216     rotate([0, 90, 0])
217     cylinder(r=r, h=100, $fn=20);
218 }
219
220 module ThroughHoles(){
221   for (z=[ 1/4, 3/4 ]) {
222     ThroughHole( mountscrew_dia/2,
223                  -tube_or -0.5*backflange_d,
224                  total_h * z );
225   }
226
227   ThroughHole( clipbolt_dia/2,
228                lock_0y + lock_d/2 + clip_d/2 + front_th/2,
229                total_h - cliprecess_h - clip_th - clip_d/2 );
230 }
231
232 module MainPositive(){
233   difference(){
234     union(){
235       linear_extrude(height=total_h, convexity=100) MainPlan();
236       ExtrudeClipElevation() ClipElevationPositive();
237     }
238     ExtrudeClipElevation(1) ClipElevationNegative();
239   }
240 }
241
242 module Bracket(){ //// toplevel
243   difference(){
244     MainPositive();
245     ThroughHoles();
246   }
247 }
248
249 module TestTopEdge(){ //// toplevel
250   intersection(){
251     translate([0,0, -total_h])
252       translate([0,0, 4])
253       Bracket();
254     translate([-200,-200,0])
255       cube([400,400,100]);
256   }
257 }
258
259 module TestClipBoltHole(){ //// toplevel
260   intersection(){
261     union(){
262       translate([0, 0, -5])
263         Bracket();
264       translate([-4, lock_0y + lock_d/2 + 1, 0])
265         cube([8, 4, 1.5]);
266     }
267     translate([-200, lock_0y + lock_d/2 + 0.1])
268       cube([400, 400, total_h-20]);
269   }
270 }
271
272 //MainPlan();
273 //ClipElevationPositive();
274 //ClipElevation();
275 //MainPositive();
276 //%ThroughHoles();
277 //TestTopEdge();
278 //TestClipBoltHole();
279 //DividePlan();
280
281 Bracket();
282