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