chiark / gitweb /
scaffold-clamp-cleat: wip
[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;
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 bolt_gap = 1.0; // total, on both sides
26
27 // ---------- vhook ----------
28
29 vhook_th = 14;
30
31 // ---------- cleat ----------
32
33 cleat_frames = 10;
34 cleat_curve_r = 200;
35 cleat_horn_l = 60;
36 cleat_horn_d_min = [8, 10];
37 cleat_horn_d_max = [10, 12];
38 cleat_height = 25;
39 cleat_stem_l = 20;
40
41 // ---------- hhook ----------
42
43 hhook_inside = 40;
44 hhook_th = 4;
45 hhook_l = 40;
46
47 // ========== defaults ==========
48
49 pin_head_th = th/2;
50 pin_dia = th;
51 pin_hole_dia = pin_dia/2;
52 pin_tail = pin_hole_dia + pin_head_th + hinge_z_gap*3;
53
54 // ========== calculated ==========
55
56 TAU = PI*2;
57
58 hole_dia = th + pin_gap;
59
60 bolt_hole_r = (bolt_dia + bolt_gap)/2;
61
62 main_r = tube_dia/2 + th;
63
64 hinge_gap = pin_gap;
65
66 hinge_o_r = 0.5 * hole_dia + th;
67
68 hinge_x = -0.5 * tube_dia - hinge_o_r;
69 bolt_x = 0.5 * tube_dia + th + bolt_flat * 0.5;
70 max_x = bolt_x + max(bolt_hole_r + th, 0.5 * bolt_flat/2);
71
72 flats_y = open_gap/2 + th;
73
74 stride_z = hinge_unit*2 + hinge_z_gap*2;
75 total_z = hinge_units * stride_z - hinge_z_gap;
76
77 min_z = -total_z/2;
78 max_z = +total_z/2;
79
80 pin_flatten = pin_dia/2 * (1 - cos(45));
81
82 bolt_stride = total_z / nbolts;
83
84 // calculated - vhook
85
86 vhook_inside = 15;
87
88 vhook_theta = atan2( smooth_r, main_r );
89
90 vhook_y0 = -max(main_r, (tube_dia/2 + vhook_th));
91 vhook_ctr = vhook_y0 - vhook_inside/2;
92 vhook_outer_dia = vhook_inside + vhook_th*2;
93
94 // calculated - hhook
95
96 hhook_outer_dia = hhook_inside + hhook_th*2;
97
98 hhook_ctr = -max(main_r + hhook_inside/2,
99                  tube_dia/2 + hhook_outer_dia/2);
100
101 $fa = 3;
102 $fs = 0.1;
103
104 module SmoothPlan(){
105   offset(r=-smooth_r) offset(delta=smooth_r) children(0);
106 }
107
108 module TubePlan(){ circle(r = tube_dia/2); }
109 module MainCirclePlan(){ circle(r = main_r); }
110
111 module PlanWeldMainCircle(){
112   intersection(){
113     difference(){
114       SmoothPlan(){
115         union(){
116           MainCirclePlan();
117           children(0);
118         }
119       }
120       TubePlan();
121     }
122     rotate(-135) square(100);
123   }
124 }
125
126 module MainPlan(flatten=false) {
127   difference(){
128     SmoothPlan()
129       union(){
130       translate([hinge_x, 0]) circle(r= hinge_o_r);
131       MainCirclePlan();
132       rectfromto([0,           -flats_y],
133                  [max_x,       +flats_y]);
134     }
135     TubePlan();
136     rectfromto([0,       -open_gap/2],
137                [max_x+1, +open_gap/2]);
138     translate([hinge_x, 0]) {
139       intersection(){
140         circle(r= hole_dia/2);
141         if (flatten)
142           translate([ pin_flatten, 0 ])
143           square(center=true, [hole_dia, hole_dia + 1]);
144       }
145     }
146   }
147 }
148
149 module Portion(d=0) {
150   translate([hinge_x, 0]) circle(r= hinge_o_r + d);
151   rectfromto([hinge_x*2, 0],
152              [max_x+10, -(tube_dia/2+th+10)]);
153 }
154
155 module MainPlanA(flatten){
156   intersection(){
157     MainPlan(flatten);
158     Portion(0);
159   }
160 }
161
162 module MainPlanB(flatten){
163   difference(){
164     MainPlan(flatten);
165     Portion(hinge_gap);
166   }
167 }
168
169 module HalfClampX(flatten=false){
170   difference(){
171     translate([0,0, min_z]) {
172       linextr(0, total_z) mirror([0,1]) MainPlanB();
173       for (i=[0 : hinge_units-1]) {
174         translate([0,0, stride_z*i])
175           linextr(0, hinge_unit) MainPlanA(flatten);
176       }
177     }
178     for (j=[0:nbolts-1]) {
179       translate([ bolt_x, 0, min_z + (j + 0.5) * bolt_stride ]) {
180         translate([0, -tube_dia/2, 0])
181           rotate([-90,0,0])
182           cylinder(r= bolt_hole_r, h= tube_dia);
183         translate([0, -flats_y, 0])
184           rotate([90,0,0])
185           cylinder(r= bolt_flat/2, h= tube_dia/2);
186       }
187     }
188   }
189 }
190
191 // ---------- vhook ----------
192
193 module VHookProfile() {
194   translate([0, -vhook_inside/2 - vhook_th/2])
195     circle(r = vhook_th/2);
196 }
197
198 module VHookHookMain(outer=false){ ////toplevel
199   rotate([0,90,0])
200     rotate_extrude(convexity=10)
201     rotate([0,0,90])
202     hull(){
203       VHookProfile();
204       if (outer) {
205         translate([0,-vhook_outer_dia]) square(center=true, vhook_th);
206       }
207     }
208 }
209
210 module VHookA(){ ////toplevel
211   DummyA();
212
213   translate([0, vhook_ctr, 0]){
214     for (m=[0,1]) {
215       mirror([0, m, 0]) {
216         linextr(-0.1, vhook_outer_dia/2)
217           VHookProfile();
218         translate([0, -vhook_inside/2 -vhook_th/2, vhook_outer_dia/2])
219           sphere(r= vhook_th/2);
220       }
221     }
222
223     intersection(){
224       VHookHookMain(outer=true);
225       linextr_y_xz(0, vhook_outer_dia/2) hull(){
226         VHookProfile();
227         translate([0,-0.1]) square(center=true, [vhook_th, 0.2]);
228       }
229     }
230
231     intersection(){
232       VHookHookMain();
233       translate([0,0, -vhook_outer_dia])
234         cube(center=true, vhook_outer_dia*2);
235     }
236   }
237
238   //translate([0, vhook_y0, 50]) rotate([0,0,-90]) color("black") cube(10);
239   // translate([0,0,-150]) rotate([0,0,180 + theta]) color("blue") cube(100);
240 }
241
242 module VHookPlanDemo(){
243   MainPlanA();
244   translate([0, vhook_ctr, 5])
245     for (m=[0,1]) {
246       mirror([0,m])
247         color("blue") VHookProfile();
248     }
249 }
250
251 // ---------- cleat ----------
252
253 function cleat_frame_theta(s) = s * cleat_horn_l / cleat_curve_r * 360/TAU;
254 function cleat_frame_z(s) = cleat_curve_r * (1 - cos(cleat_frame_theta(s)));
255 function cleat_frame_x(s) = cleat_curve_r * sin(cleat_frame_theta(s));
256 function cleat_frame_r(s) = ( cleat_horn_d_min * s +
257                               cleat_horn_d_max * (1-s) ) * 0.5;
258
259 module CleatFrameSphere(r) {
260   scale([1, r[1]/r[0], 1])
261     sphere(r= r[0]);
262 }
263
264 module CleatFrame(s) {
265   r = cleat_frame_r(s);
266   translate([cleat_frame_x(s), 0, cleat_frame_z(s)])
267     rotate([0, 90, 0])
268     CleatFrameSphere(r);
269 }
270
271
272 module CleatHorn(){
273   for (si=[0 : cleat_frames-2]) {
274     s0 = si / (cleat_frames-1);
275     s1 = (si+1) / (cleat_frames-1);
276     //hull(){
277       CleatFrame(s0);
278       CleatFrame(s1);
279     //}
280   }
281 }
282
283 module CleatBase(){
284   frames = cleat_frames/2;
285   se = cleat_stem_l/2 / cleat_horn_l;
286   r = cleat_frame_r(se);
287
288   for (si=[0: frames-2]) {
289     s0 = se * si / (frames-1);
290     s1 = se * (si+1) / (frames-1);
291     hull(){
292       for (z= [-(cleat_height + tube_dia/2),
293                cleat_frame_z(se)]) {
294         translate([cleat_frame_x(se), 0, z])
295           CleatFrameSphere(r);
296       }
297     }
298   }
299
300   for (si=[0 : cleat_frames-2]) {
301     s0 = si / (cleat_frames-1);
302     s1 = (si+1) / (cleat_frames-1);
303     //hull(){
304       CleatFrame(s0);
305       CleatFrame(s1);
306     //}
307   }
308 }
309
310 module VCleatA(){ ////toplevel
311   %DummyA();
312
313   translate([0, -(main_r + cleat_height), 0]) {
314     rotate([0, -90, 90]) {
315       for (m=[0,1]) {
316         mirror([m,0,0]) {
317           CleatHorn();
318         }
319         mirror([m,0,0]) {
320           CleatBase();
321         }
322       }
323     }
324   }
325 }
326
327 // ---------- hhook ----------
328
329 module HHookHookPlan(){
330   translate([0, hhook_ctr]){
331     difference(){
332       circle(r = hhook_outer_dia/2);
333       circle(r = hhook_inside/2);
334       rectfromto([+hhook_outer_dia, -hhook_outer_dia],
335                  [0,                +hhook_outer_dia]);
336     }
337     translate([0, -(hhook_inside/2 + hhook_th/2)]){
338       hull(){
339         for (x=[-0.1, hhook_l]) {
340           translate([x,0]) square(center=true, hhook_th);
341         }
342       }
343     }
344   }
345 }
346
347 module HHookA(){ ////toplevel
348   DummyA();
349   linextr(min_z, max_z) {
350     HHookHookPlan();
351   }
352 }
353
354 module HHookPlanDemo(){
355   MainPlanA();
356   HHookHookPlan();
357 }
358
359 // ---------- misc ----------
360
361 module PinSitu(){ ////toplevel
362   difference(){
363     union(){
364       translate([0,0, -pin_head_th])
365         cylinder(r= pin_dia/2, h = total_z + pin_head_th + pin_tail);
366       mirror([0,0,1])
367         cylinder(r= hinge_o_r - pin_gap, h = pin_head_th);
368     }
369     translate([0,0, total_z + pin_tail/2])
370       rotate([0,90,0])
371       translate([0,0, -pin_dia])
372       cylinder(r= pin_hole_dia/2, h=pin_dia*2);
373     translate([pin_dia/2 * cos(45), -50, -pin_head_th*2])
374       cube([50,100, total_z*2]);
375   }
376 }
377
378 module Pin(){ ////toplevel
379   rotate([0,90,0]) {
380     PinSitu();
381   }
382 }
383
384 module GeneralB(){ ////toplevel
385   HalfClampX(true);
386 }
387
388 module DummyA(){ ////toplevel
389   HalfClampX();
390 }
391
392 module PlanDemo(){ ////toplevel
393   MainPlan();
394   translate([0,0,-4]) color("red") Portion(1);
395   translate([0,0,-2]) color("grey") Portion(0);
396
397   translate([0, tube_dia*1.5]) {
398     MainPlanB();
399     MainPlanA();
400   }
401
402   translate([0, -tube_dia*1.5]) {
403     VHookPlanDemo();
404   }
405   translate([tube_dia*4, 0]) {
406     HHookPlanDemo();
407   }
408 //  translate([max_x - hinge_x + 20, 0]) color("blue") MainPlanA();
409 }
410
411 module DemoA(){ DummyA(); }
412
413 module Demo(){ ////toplevel
414   color("red") rotate([180,0,0]) GeneralB();
415   color("blue") DemoA();
416   color("orange") translate([hinge_x, 0, min_z - hinge_z_gap])
417     rotate([0,0,180]) PinSitu();
418 }
419
420 //PlanDemo();
421 //HalfClamp();