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