chiark / gitweb /
scaffold-clamp: wip pin
[reprap-play.git] / scaffold-clamp-common.scad
1 // -*- C -*-
2
3 include <utils.scad>
4
5 tube_dia = 48.3;
6
7 th = 7;
8
9 pin_gap = 1.5; // around
10
11 smooth_r = 15;
12
13 bolt_dia = 5 + 0.75;
14 bolt_flat = 10 + 1;
15
16 nbolts = 2;
17
18 open_gap = 10;
19
20 hinge_unit = 10;
21 hinge_z_gap = 1;
22
23 hinge_units = 4;
24
25 // ---------- vhook ----------
26
27 vhook_th = 14;
28
29 // ---------- hhook ----------
30
31 hhook_inside = 40;
32 hhook_th = 4;
33 hhook_l = 40;
34
35 // ========== defaults ==========
36
37 pin_head_th = th/2;
38 pin_dia = th;
39 pin_hole_dia = pin_dia/2;
40 pin_tail = pin_hole_dia + pin_head_th + hinge_z_gap*3;
41
42 // ========== calculated ==========
43
44 hole_dia = th + pin_gap;
45
46 main_r = tube_dia/2 + th;
47
48 hinge_gap = pin_gap;
49
50 hinge_o_r = 0.5 * hole_dia + th;
51
52 hinge_x = -0.5 * tube_dia - hinge_o_r;
53 bolt_x = 0.5 * tube_dia + th + bolt_flat * 0.5;
54 max_x = bolt_x + max(0.5 + bolt_dia + th, 0.5 * bolt_flat/2);
55
56 flats_y = open_gap/2 + th;
57
58 stride_z = hinge_unit*2 + hinge_z_gap*2;
59 total_z = hinge_units * stride_z - hinge_z_gap;
60
61 min_z = -total_z/2;
62 max_z = +total_z/2;
63
64 pin_flatten = pin_dia/2 * (1 - cos(45));
65
66 bolt_stride = total_z / nbolts;
67
68 // calculated - vhook
69
70 vhook_inside = 15;
71
72 vhook_theta = atan2( smooth_r, main_r );
73
74 vhook_y0 = -max(main_r, (tube_dia/2 + vhook_th));
75 vhook_ctr = vhook_y0 - vhook_inside/2;
76 vhook_outer_dia = vhook_inside + vhook_th*2;
77
78 // calculated - hhook
79
80 hhook_outer_dia = hhook_inside + hhook_th*2;
81
82 hhook_ctr = -max(main_r + hhook_inside/2,
83                  tube_dia/2 + hhook_outer_dia/2);
84
85 $fa = 3;
86 $fs = 0.1;
87
88 module SmoothPlan(){
89   offset(r=-smooth_r) offset(delta=smooth_r) children(0);
90 }
91
92 module TubePlan(){ circle(r = tube_dia/2); }
93 module MainCirclePlan(){ circle(r = main_r); }
94
95 module PlanWeldMainCircle(){
96   intersection(){
97     difference(){
98       SmoothPlan(){
99         union(){
100           MainCirclePlan();
101           children(0);
102         }
103       }
104       TubePlan();
105     }
106     rotate(-135) square(100);
107   }
108 }
109
110 module MainPlan(flatten=false) {
111   difference(){
112     SmoothPlan()
113       union(){
114       translate([hinge_x, 0]) circle(r= hinge_o_r);
115       MainCirclePlan();
116       rectfromto([0,           -flats_y],
117                  [max_x,       +flats_y]);
118     }
119     TubePlan();
120     rectfromto([0,       -open_gap/2],
121                [max_x+1, +open_gap/2]);
122     translate([hinge_x, 0]) {
123       intersection(){
124         circle(r= hole_dia/2);
125         if (flatten)
126           translate([ pin_flatten, 0 ])
127           square(center=true, [hole_dia, hole_dia + 1]);
128       }
129     }
130   }
131 }
132
133 module Portion(d=0) {
134   translate([hinge_x, 0]) circle(r= hinge_o_r + d);
135   rectfromto([hinge_x*2, 0],
136              [max_x+10, -(tube_dia/2+th+10)]);
137 }
138
139 module MainPlanA(flatten){
140   intersection(){
141     MainPlan(flatten);
142     Portion(0);
143   }
144 }
145
146 module MainPlanB(flatten){
147   difference(){
148     MainPlan(flatten);
149     Portion(hinge_gap);
150   }
151 }
152
153 module HalfClampX(flatten=false){
154   difference(){
155     translate([0,0, min_z]) {
156       linextr(0, total_z) mirror([0,1]) MainPlanB();
157       for (i=[0 : hinge_units-1]) {
158         translate([0,0, stride_z*i])
159           linextr(0, hinge_unit) MainPlanA(flatten);
160       }
161     }
162     for (j=[0:nbolts-1]) {
163       translate([ bolt_x, 0, min_z + (j + 0.5) * bolt_stride ]) {
164         translate([0, -tube_dia/2, 0])
165           rotate([-90,0,0])
166           cylinder(r= bolt_dia/2, h= tube_dia);
167         translate([0, -flats_y, 0])
168           rotate([90,0,0])
169           cylinder(r= bolt_flat/2, h= tube_dia/2);
170       }
171     }
172   }
173 }
174
175 // ---------- vhook ----------
176
177 module VHookProfile() {
178   translate([0, -vhook_inside/2 - vhook_th/2])
179     circle(r = vhook_th/2);
180 }
181
182 module VHookHookMain(outer=false){ ////toplevel
183   rotate([0,90,0])
184     rotate_extrude(convexity=10)
185     rotate([0,0,90])
186     hull(){
187       VHookProfile();
188       if (outer) {
189         translate([0,-vhook_outer_dia]) square(center=true, vhook_th);
190       }
191     }
192 }
193
194 module VHookPartA(){ ////toplevel
195   DummyA();
196
197   translate([0, vhook_ctr, 0]){
198     for (m=[0,1]) {
199       mirror([0, m, 0]) {
200         linextr(-0.1, vhook_outer_dia/2)
201           VHookProfile();
202         translate([0, -vhook_inside/2 -vhook_th/2, vhook_outer_dia/2])
203           sphere(r= vhook_th/2);
204       }
205     }
206
207     intersection(){
208       VHookHookMain(outer=true);
209       linextr_y_xz(0, vhook_outer_dia/2) hull(){
210         VHookProfile();
211         translate([0,-0.1]) square(center=true, [vhook_th, 0.2]);
212       }
213     }
214
215     intersection(){
216       VHookHookMain();
217       translate([0,0, -vhook_outer_dia])
218         cube(center=true, vhook_outer_dia*2);
219     }
220   }
221
222   //translate([0, vhook_y0, 50]) rotate([0,0,-90]) color("black") cube(10);
223   // translate([0,0,-150]) rotate([0,0,180 + theta]) color("blue") cube(100);
224 }
225
226 module VHookPlanDemo(){
227   MainPlanA();
228   translate([0, vhook_ctr, 5])
229     for (m=[0,1]) {
230       mirror([0,m])
231         color("blue") VHookProfile();
232     }
233 }
234
235 // ---------- hhook ----------
236
237 module HHookHookPlan(){
238   translate([0, hhook_ctr]){
239     difference(){
240       circle(r = hhook_outer_dia/2);
241       circle(r = hhook_inside/2);
242       rectfromto([+hhook_outer_dia, -hhook_outer_dia],
243                  [0,                +hhook_outer_dia]);
244     }
245     translate([0, -(hhook_inside/2 + hhook_th/2)]){
246       hull(){
247         for (x=[-0.1, hhook_l]) {
248           translate([x,0]) square(center=true, hhook_th);
249         }
250       }
251     }
252   }
253 }
254
255 module HHookPartA(){ ////toplevel
256   DummyA();
257   linextr(min_z, max_z) {
258     HHookHookPlan();
259   }
260 }
261
262 module HHookPlanDemo(){
263   MainPlanA();
264   HHookHookPlan();
265 }
266
267 // ---------- misc ----------
268
269 module PinSitu(){ ////toplevel
270   difference(){
271     union(){
272       translate([0,0, -pin_head_th])
273         cylinder(r= pin_dia/2, h = total_z + pin_head_th + pin_tail);
274       mirror([0,0,1])
275         cylinder(r= hinge_o_r - pin_gap, h = pin_head_th);
276     }
277     translate([0,0, total_z + pin_tail/2])
278       rotate([0,90,0])
279       translate([0,0, -pin_dia])
280       cylinder(r= pin_hole_dia/2, h=pin_dia*2);
281     translate([pin_dia/2 * cos(45), -50, -pin_head_th*2])
282       cube([50,100, total_z*2]);
283   }
284 }
285
286 module Pin(){ ////toplevel
287   rotate([0,90,0]) {
288     PinSitu();
289   }
290 }
291
292 module GeneralB(){ ////toplevel
293   HalfClampX(true);
294 }
295
296 module DummyA(){ ////toplevel
297   HalfClampX();
298 }
299
300 module PlanDemo(){ ////toplevel
301   MainPlan();
302   translate([0,0,-4]) color("red") Portion(1);
303   translate([0,0,-2]) color("grey") Portion(0);
304
305   translate([0, tube_dia*1.5]) {
306     MainPlanB();
307     MainPlanA();
308   }
309
310   translate([0, -tube_dia*1.5]) {
311     VHookPlanDemo();
312   }
313   translate([tube_dia*4, 0]) {
314     HHookPlanDemo();
315   }
316 //  translate([max_x - hinge_x + 20, 0]) color("blue") MainPlanA();
317 }
318
319 module Demo(){ ////toplevel
320   color("red") rotate([180,0,0]) GeneralB();
321   color("blue") DummyA();
322   color("orange") translate([hinge_x, 0, min_z - hinge_z_gap])
323     rotate([0,0,180]) PinSitu();
324 }
325
326 //PlanDemo();
327 //HalfClamp();