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