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