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