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