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