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