chiark / gitweb /
scaffold-clamp: wip vhook
[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 // calculated
22
23 pin_dia = th;
24 hole_dia = th + pin_gap;
25
26 main_r = tube_dia/2 + th;
27
28 hinge_gap = pin_gap;
29
30 hinge_o_r = 0.5 * hole_dia + th;
31
32 hinge_x = -0.5 * tube_dia - hinge_o_r;
33 bolt_x = 0.5 * tube_dia + th + bolt_flat * 0.5;
34 max_x = bolt_x + max(0.5 + bolt_dia + th, 0.5 * bolt_flat/2);
35
36 flats_y = open_gap/2 + th;
37
38 stride_z = hinge_unit*2 + hinge_z_gap*2;
39 total_z = hinge_units * stride_z - hinge_z_gap;
40
41 min_z = -total_z/2;
42 max_z = +total_z/2;
43
44 pin_flatten = pin_dia/2 * (1 - cos(45));
45
46 $fa = 3;
47 $fs = 0.1;
48
49 module SmoothPlan(){
50   offset(r=-smooth_r) offset(delta=smooth_r) children(0);
51 }
52
53 module TubePlan(){ circle(r = tube_dia/2); }
54 module MainCirclePlan(){ circle(r = main_r); }
55
56 module PlanWeldMainCircle(){
57   intersection(){
58     difference(){
59       SmoothPlan(){
60         union(){
61           MainCirclePlan();
62           children(0);
63         }
64       }
65       TubePlan();
66     }
67     rotate(-135) square(100);
68   }
69 }
70
71 module MainPlan(flatten=false) {
72   difference(){
73     SmoothPlan()
74       union(){
75       translate([hinge_x, 0]) circle(r= hinge_o_r);
76       MainCirclePlan();
77       rectfromto([0,           -flats_y],
78                  [max_x,       +flats_y]);
79     }
80     TubePlan();
81     rectfromto([0,       -open_gap/2],
82                [max_x+1, +open_gap/2]);
83     translate([hinge_x, 0]) {
84       intersection(){
85         circle(r= hole_dia/2);
86         if (flatten)
87           translate([ pin_flatten, 0 ])
88           square(center=true, [hole_dia, hole_dia + 1]);
89       }
90     }
91   }
92 }
93
94 module Portion(d=0) {
95   translate([hinge_x, 0]) circle(r= hinge_o_r + d);
96   rectfromto([hinge_x*2, 0],
97              [max_x+10, -(tube_dia/2+th+10)]);
98 }
99
100 module MainPlanA(flatten){
101   intersection(){
102     MainPlan(flatten);
103     Portion(0);
104   }
105 }
106
107 module MainPlanB(flatten){
108   difference(){
109     MainPlan(flatten);
110     Portion(hinge_gap);
111   }
112 }
113
114 module HalfClampX(flatten=false){
115   difference(){
116     translate([0,0, min_z]) {
117       linextr(0, total_z) mirror([0,1]) MainPlanB();
118       for (i=[0 : hinge_units-1]) {
119         translate([0,0, stride_z*i])
120           linextr(0, hinge_unit) MainPlanA(flatten);
121       }
122     }
123     for (dz=[-1,+1]) {
124       translate([ bolt_x, 0, dz * total_z/4 ]) {
125         translate([0, -tube_dia/2, 0])
126           rotate([-90,0,0])
127           cylinder(r= bolt_dia/2, h= tube_dia);
128         translate([0, -flats_y, 0])
129           rotate([90,0,0])
130           cylinder(r= bolt_flat/2, h= tube_dia/2);
131       }
132     }
133   }
134 }
135
136 module GeneralPlanDemo(){ ////toplevel
137   MainPlan();
138   translate([0,0,-4]) color("red") Portion(1);
139   translate([0,0,-2]) color("grey") Portion(0);
140
141   translate([0, tube_dia*1.5]) {
142     MainPlanB();
143     MainPlanA();
144   }
145 //  translate([max_x - hinge_x + 20, 0]) color("blue") MainPlanA();
146 }
147
148 module GeneralB(){ ////toplevel
149   HalfClampX(true);
150 }
151
152 module DummyA(){ ////toplevel
153   HalfClampX();
154 }
155
156 module Demo(){ ////toplevel
157   color("red") rotate([180,0,0]) GeneralB();
158   color("blue") DummyA();
159 }
160
161 //PlanDemo();
162 //HalfClamp();