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