chiark / gitweb /
mic-table-clamp: Break out StemWith (nfc)
[reprap-play.git] / mic-table-clamp.scad
1 // -*- C -*-
2
3 // print Stem and Wingnut on High Detail
4 // but adjust shell thickness to 2mm
5
6 // others on Standard
7
8 include <utils.scad>
9 include <threads.scad>
10 include <camera-mount.scad>
11
12 positive_dia = inch * 3/8. - 0.375;
13 positive_l = inch * 1/2.;
14
15 stem_l = 40;
16 stem_dia = 12;
17 stem_th = 3;
18 stem_ceil = 2;
19 stem_base_th  = 4;
20 stem_base_dia = 25;
21 stem_inner_l = 15;
22
23 thread_nom = 8;
24 thread_pitch = 1.25;
25 thread_act = thread_nom + 0.600;
26
27 clamp_l = 40;
28 clamp_top_th = 7;
29 clamp_bot_th = 10;
30 clamp_bot_tooth_h = 2.5;
31 clamp_bot_tooth_d  = 10;
32 clamp_bot_collar = 20;
33 clamp_bot_collar_th = 3.0;
34 clamp_reg_sz1 = 3;
35 clamp_reg_sz2 = 5;
36 clamp_w = 15;
37 clamp_max_table_th = 35;
38
39 clamp_hole_dia = thread_nom + 0.30;
40
41 clamp_reg_clear_x = 2.5;
42 clamp_reg_clear_y = 0.75; // each side
43 clamp_reg_extra_x = 4;
44
45 //ct_h = 7;
46
47 wingnut_th = 5;
48 wingnut_wall = 4;
49 wingnut_wing_mindia = 17.0;
50 wingnut_wing_xrad = 8;
51 wingnut_wing_xh = 5;
52 wingnut_wing_th = 3;
53
54 $test= true;
55 ///$test= false;
56
57 //$fa= 3;
58 //$fs= 0.2;
59
60 // calculated
61
62 wingnut_cnr = wingnut_wing_th/2 -0.1;
63
64 clamp_reg_bot_x_min = -stem_base_dia/2 -clamp_reg_clear_x -clamp_reg_sz2;
65 clamp_collar_r = thread_nom/2 + clamp_bot_collar_th;
66
67 module OurThread(l){
68   translate([0,0,-0.01])
69     metric_thread(diameter=thread_act, pitch=thread_pitch,
70                   leadin=3, internal=true,
71                   test=$test, length=l);
72 }
73
74 module StemWith(){
75   translate([0,0, stem_l -0.1])
76     children();
77
78   difference(){
79     union(){
80       cylinder(r= stem_dia/2 * 1/(0.5 * sqrt(3)),
81                h = stem_l,
82                $fn=6);
83       cylinder(r= stem_base_dia/2,
84                h = stem_base_th);
85     }
86     OurThread(stem_inner_l);
87   }
88 }  
89
90 module Stem(){ ////toplevel
91   StemWith()
92     english_thread(diameter=positive_dia/inch, threads_per_inch=16,
93                    leadin=1, test=$test,
94                    length= (positive_l + 0.1) / inch);
95 }
96
97 module Wingnut(){ ////toplevel
98   difference(){
99     union(){
100       cylinder(r= (thread_nom+wingnut_wall)/2,
101                h= wingnut_th);
102       minkowski(){
103         sphere(r= wingnut_cnr);
104         translate([0,0, wingnut_cnr*0.5])
105           linear_extrude(height= wingnut_wing_xh + wingnut_th
106                          - wingnut_cnr*1.5)
107           square([wingnut_wing_mindia + wingnut_wing_xrad*2 - wingnut_cnr*2,
108                   wingnut_wing_th - wingnut_cnr*2],
109                  center=true);
110       }
111     }
112     translate([0,0, wingnut_th])
113       linear_extrude(height= wingnut_wing_xh+1)
114       square(wingnut_wing_mindia, center=true);
115     translate([0,0, wingnut_th])
116       rotate([180,0,0])
117       OurThread(wingnut_th+3);
118     mirror([0,0,1])
119       linear_extrude(height=5)
120       square(center=true, wingnut_wing_mindia*2);
121   }
122 }
123
124 module ClampCollarPlan(){
125   circle(r= clamp_collar_r);
126 }
127 module ClampHolePlan(){
128   circle(r= clamp_hole_dia/2);
129 }
130 module ClampArmPlan(){
131   r = clamp_collar_r;
132   hull(){
133     rectfromto([r,       -clamp_w/2],
134                [clamp_l, +clamp_w/2]);
135     ClampCollarPlan();
136   }
137 }
138
139 module ClampTop(){ ////toplevel
140   linear_extrude(height = clamp_top_th, convexity=4) {
141     difference(){
142       union(){
143         ClampArmPlan();
144         ClampCollarPlan();
145       }
146       ClampHolePlan();
147     }
148   }
149   linear_extrude(height = clamp_reg_sz1, convexity=4) {
150     difference(){
151       for (m=[0,1]){
152         mirror([0,m,0])
153           translate([0, clamp_reg_sz2/2 + clamp_reg_clear_y, 0])
154           rectfromto([clamp_reg_bot_x_min - clamp_reg_extra_x, 0 ],
155                      [0,                           clamp_reg_sz1 ]);
156       }
157       ClampHolePlan();
158     }
159   }
160 }
161
162 module ClampBot(){ ////toplevel
163   linear_extrude(height = clamp_bot_th, convexity=4) {
164     difference(){
165       ClampArmPlan();
166       ClampHolePlan();
167     }
168   }
169   translate([clamp_l, 0, clamp_bot_th-0.1])
170     linear_extrude(height = clamp_bot_tooth_h +0.1)
171     rectfromto([ -clamp_bot_tooth_d, -clamp_w/2 ],
172                [  0,                 +clamp_w/2 ]);
173   translate([0,0, clamp_bot_th])
174     mirror([0,0,1])
175     linear_extrude(height = clamp_bot_collar)
176     difference(){
177     ClampCollarPlan();
178     ClampHolePlan();
179   }
180   translate([0, 0, clamp_bot_th]) {
181     linextr(-clamp_reg_sz2, clamp_max_table_th+clamp_reg_sz2) {
182       translate([clamp_reg_bot_x_min, 0]) {
183         rectfromto([ 0,             -clamp_reg_sz2/2 ],
184                    [ clamp_reg_sz2, +clamp_reg_sz2/2 ]);
185       }
186     }
187     linextr(-clamp_reg_sz2, 0) {
188       difference(){
189         rectfromto([ clamp_reg_bot_x_min, -clamp_reg_sz2/2 ],
190                    [  0,                  +clamp_reg_sz2/2 ]);
191         ClampHolePlan();
192       }
193     }
194   }
195 }
196
197 module Demo(){ ////toplevel
198   color("blue") translate([0,0, clamp_top_th+0.5]) Stem();
199   color("red") ClampTop();
200   color("grey") translate([0,0, -(clamp_bot_th + 5)]) ClampBot();
201   translate([0,0, -(clamp_bot_collar +10)])
202     rotate([180,0,0]) Wingnut();
203 }
204
205 //Wingnut();
206 //Stem();