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