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