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