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