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