Commit | Line | Data |
---|---|---|
e9e8a498 AR |
1 | // Copyright 2010 D1plo1d |
2 | ||
3 | // This library is dual licensed under the GPL 3.0 and the GNU Lesser General Public License as per http://creativecommons.org/licenses/LGPL/2.1/ . | |
4 | ||
5 | //testNutsAndBolts(); | |
6 | ||
7 | module SKIPtestNutsAndBolts() | |
8 | { | |
9 | $fn = 360; | |
10 | translate([0,15])nutHole(3, proj=2); | |
11 | boltHole(3, length= 30, proj=2); | |
12 | } | |
13 | ||
14 | MM = "mm"; | |
15 | INCH = "inch"; //Not yet supported | |
16 | ||
17 | //Based on: http://www.roymech.co.uk/Useful_Tables/Screws/Hex_Screws.htm | |
18 | METRIC_NUT_AC_WIDTHS = | |
19 | [ | |
20 | -1, //0 index is not used but reduces computation | |
21 | -1, | |
22 | -1, | |
23 | 6.40,//m3 | |
24 | 8.10,//m4 | |
25 | 9.20,//m5 | |
26 | 11.50,//m6 | |
27 | -1, | |
28 | 15.00,//m8 | |
29 | -1, | |
30 | 19.60,//m10 | |
31 | -1, | |
32 | 22.10,//m12 | |
33 | -1, | |
34 | -1, | |
35 | -1, | |
36 | 27.70,//m16 | |
37 | -1, | |
38 | -1, | |
39 | -1, | |
40 | 34.60,//m20 | |
41 | -1, | |
42 | -1, | |
43 | -1, | |
44 | 41.60,//m24 | |
45 | -1, | |
46 | -1, | |
47 | -1, | |
48 | -1, | |
49 | -1, | |
50 | 53.1,//m30 | |
51 | -1, | |
52 | -1, | |
53 | -1, | |
54 | -1, | |
55 | -1, | |
56 | 63.5//m36 | |
57 | ]; | |
58 | METRIC_NUT_THICKNESS = | |
59 | [ | |
60 | -1, //0 index is not used but reduces computation | |
61 | -1, | |
62 | -1, | |
63 | 2.40,//m3 | |
64 | 3.20,//m4 | |
65 | 4.00,//m5 | |
66 | 5.00,//m6 | |
67 | -1, | |
68 | 6.50,//m8 | |
69 | -1, | |
70 | 8.00,//m10 | |
71 | -1, | |
72 | 10.00,//m12 | |
73 | -1, | |
74 | -1, | |
75 | -1, | |
76 | 13.00,//m16 | |
77 | -1, | |
78 | -1, | |
79 | -1, | |
80 | 16.00//m20 | |
81 | -1, | |
82 | -1, | |
83 | -1, | |
84 | 19.00,//m24 | |
85 | -1, | |
86 | -1, | |
87 | -1, | |
88 | -1, | |
89 | -1, | |
90 | 24.00,//m30 | |
91 | -1, | |
92 | -1, | |
93 | -1, | |
94 | -1, | |
95 | -1, | |
96 | 29.00//m36 | |
97 | ]; | |
98 | ||
99 | COURSE_METRIC_BOLT_MAJOR_THREAD_DIAMETERS = | |
100 | [//based on max values | |
101 | -1, //0 index is not used but reduces computation | |
102 | -1, | |
103 | -1, | |
104 | 2.98,//m3 | |
105 | 3.978,//m4 | |
106 | 4.976,//m5 | |
107 | 5.974,//m6 | |
108 | -1, | |
109 | 7.972,//m8 | |
110 | -1, | |
111 | 9.968,//m10 | |
112 | -1, | |
113 | 11.966,//m12 | |
114 | -1, | |
115 | -1, | |
116 | -1, | |
117 | 15.962,//m16 | |
118 | -1, | |
119 | -1, | |
120 | -1, | |
121 | 19.958,//m20 | |
122 | -1, | |
123 | -1, | |
124 | -1, | |
125 | 23.952,//m24 | |
126 | -1, | |
127 | -1, | |
128 | -1, | |
129 | -1, | |
130 | -1, | |
131 | 29.947,//m30 | |
132 | -1, | |
133 | -1, | |
134 | -1, | |
135 | -1, | |
136 | -1, | |
137 | 35.940//m36 | |
138 | ]; | |
139 | ||
140 | module nutHole(size, units=MM, tolerance = +0.0001, proj = -1) | |
141 | { | |
142 | //takes a metric screw/nut size and looksup nut dimensions | |
143 | radius = METRIC_NUT_AC_WIDTHS[size]/2+tolerance; | |
144 | height = METRIC_NUT_THICKNESS[size]+tolerance; | |
145 | if (proj == -1) | |
146 | { | |
147 | cylinder(r= radius, h=height, $fn = 6, center=[0,0]); | |
148 | } | |
149 | if (proj == 1) | |
150 | { | |
151 | circle(r= radius, $fn = 6); | |
152 | } | |
153 | if (proj == 2) | |
154 | { | |
155 | translate([-radius/2, 0]) | |
156 | square([radius*2, height]); | |
157 | } | |
158 | } | |
159 | ||
160 | module boltHole(size, units=MM, length, tolerance = +0.0001, proj = -1) | |
161 | { | |
162 | radius = COURSE_METRIC_BOLT_MAJOR_THREAD_DIAMETERS[size]/2+tolerance; | |
163 | //TODO: proper screw cap values | |
164 | capHeight = METRIC_NUT_THICKNESS[size]+tolerance; //METRIC_BOLT_CAP_HEIGHTS[size]+tolerance; | |
165 | capRadius = METRIC_NUT_AC_WIDTHS[size]/2+tolerance; //METRIC_BOLT_CAP_RADIUS[size]+tolerance; | |
166 | ||
167 | if (proj == -1) | |
168 | { | |
169 | translate([0, 0, -capHeight]) | |
170 | cylinder(r= capRadius, h=capHeight); | |
171 | cylinder(r = radius, h = length); | |
172 | } | |
173 | if (proj == 1) | |
174 | { | |
175 | circle(r = radius); | |
176 | } | |
177 | if (proj == 2) | |
178 | { | |
179 | translate([-capRadius/2, -capHeight]) | |
180 | square([capRadius*2, capHeight]); | |
181 | square([radius*2, length]); | |
182 | } | |
183 | } |