Преглед изворни кода

added more giess-o-mat stuff

Thomas Buck пре 1 година
родитељ
комит
e88b722286
3 измењених фајлова са 521 додато и 0 уклоњено
  1. 51
    0
      giessomat/bottlecap.scad
  2. 88
    0
      giessomat/hose_filter.scad
  3. 382
    0
      giessomat/threads.scad

+ 51
- 0
giessomat/bottlecap.scad Прегледај датотеку

@@ -0,0 +1,51 @@
1
+include <threads.scad>
2
+
3
+outer_dia = 32;
4
+thread_dia = 28.3;
5
+thread_pitch = 3.5;
6
+thread_width = 4.0;
7
+thread_angle = 45 + 15;
8
+thread_height = thread_pitch * 2;
9
+thread_min_dia = 26;
10
+height = 15;
11
+top_wall = 2;
12
+hose_hole = 6.7;
13
+air_hole = 2.0;
14
+bot_height = height - top_wall - thread_height;
15
+
16
+show_cutout = false;
17
+
18
+$fn = 42;
19
+
20
+module cutout() {
21
+    translate([0, 0, -0.01])
22
+    cylinder(d = thread_dia, h = bot_height + 0.02);
23
+    
24
+    cylinder(d = thread_min_dia, h = bot_height + thread_height);
25
+    
26
+    translate([0, 0, bot_height])
27
+    metric_thread(diameter=thread_dia, pitch=thread_pitch, length=thread_height, internal=true, thread_size=thread_width, rectangle=0, angle=thread_angle);
28
+    
29
+    translate([0, 0, bot_height + thread_height - 1]) {
30
+        translate([3, 0, 0])
31
+        cylinder(d = hose_hole, h = top_wall + 2);
32
+        
33
+        translate([-5, 0, 0])
34
+        cylinder(d = air_hole, h = top_wall + 2);
35
+    }
36
+}
37
+
38
+module bottlecap() {
39
+    difference() {
40
+        cylinder(d = outer_dia, h = height);
41
+        cutout();
42
+    }
43
+}
44
+
45
+if (show_cutout) {
46
+    cutout();
47
+} else {
48
+    translate([0, 0, height])
49
+    rotate([180, 0, 0])
50
+    bottlecap();
51
+}

+ 88
- 0
giessomat/hose_filter.scad Прегледај датотеку

@@ -0,0 +1,88 @@
1
+pipe_od = 4.0;
2
+pipe_id = 2.0;
3
+pipe_od_max = 6.0;
4
+barb_height = 4;
5
+barb_count = 2;
6
+barb_off = 1;
7
+pipe_height = 15;
8
+filter_height = 8;
9
+filter_dia = 15;
10
+filter_wall = 2.0;
11
+filter_hole_dia = filter_dia - 2 * filter_wall;
12
+hole_count_x = 20;
13
+hole_count_y = 1;
14
+hole_width = 0.8;
15
+hole_height = filter_height - 2 * filter_wall;
16
+hole_off = filter_wall;
17
+adapter_height = 4;
18
+
19
+show_open = false;
20
+
21
+$fn = 42;
22
+
23
+module pipe() {
24
+    difference() {
25
+        union() {
26
+            cylinder(d = pipe_od, h = pipe_height);
27
+            
28
+            for (i = [1 : barb_count]) {
29
+                translate([0, 0, i * (pipe_height / (barb_count + 1)) - barb_off])
30
+                cylinder(d1 = pipe_od_max, d2 = pipe_od, h = barb_height);
31
+            }
32
+        }
33
+        
34
+        translate([0, 0, -1])
35
+        cylinder(d = pipe_id, h = pipe_height + 2);
36
+    }
37
+}
38
+
39
+module filter() {
40
+    difference() {
41
+        cylinder(d = filter_dia, h = filter_height);
42
+        
43
+        translate([0, 0, hole_off])
44
+        for (i = [1 : hole_count_x]) {
45
+            for (j = [0 : hole_count_y - 1]) {
46
+                translate([0, 0, (hole_height + hole_off) * j])
47
+                rotate([0, 0, 360 / hole_count_x * i])
48
+                cube([hole_width, filter_dia, hole_height]);
49
+            }
50
+        }
51
+        
52
+        translate([0, 0, filter_wall])
53
+        cylinder(d = filter_hole_dia, h = filter_height - filter_wall + 1);
54
+        
55
+        translate([0, 0, filter_height - filter_wall - 1])
56
+        cylinder(d = pipe_id, h = filter_wall + 2);
57
+    }
58
+}
59
+
60
+module adapter() {
61
+    difference() {
62
+        cylinder(d1 = filter_dia, d2 = pipe_od, h = adapter_height);
63
+        
64
+        translate([0, 0, -0.1])
65
+        cylinder(d1 = filter_hole_dia, d2 = pipe_id, h = adapter_height + 0.2);
66
+    }
67
+}
68
+
69
+module part() {
70
+    difference() {
71
+        union() {
72
+            filter();
73
+            
74
+            translate([0, 0, filter_height])
75
+            adapter();
76
+            
77
+            translate([0, 0, filter_height + adapter_height])
78
+            pipe();
79
+        }
80
+        
81
+        if (show_open) {
82
+            translate([-50, -filter_dia, -50])
83
+            cube([100, filter_dia, 100]);
84
+        }
85
+    }
86
+}
87
+
88
+part();

+ 382
- 0
giessomat/threads.scad Прегледај датотеку

@@ -0,0 +1,382 @@
1
+/*
2
+ * ISO-standard metric threads, following this specification:
3
+ *          http://en.wikipedia.org/wiki/ISO_metric_screw_thread
4
+ *
5
+ * Copyright 2020 Dan Kirshner - dan_kirshner@yahoo.com
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * See <http://www.gnu.org/licenses/>.
17
+ *
18
+ * Version 2.4.  2019-07-14  Add test option - do not render threads.
19
+ * Version 2.3.  2017-08-31  Default for leadin: 0 (best for internal threads).
20
+ * Version 2.2.  2017-01-01  Correction for angle; leadfac option.  (Thanks to
21
+ *                           Andrew Allen <a2intl@gmail.com>.)
22
+ * Version 2.1.  2016-12-04  Chamfer bottom end (low-z); leadin option.
23
+ * Version 2.0.  2016-11-05  Backwards compatibility (earlier OpenSCAD) fixes.
24
+ * Version 1.9.  2016-07-03  Option: tapered.
25
+ * Version 1.8.  2016-01-08  Option: (non-standard) angle.
26
+ * Version 1.7.  2015-11-28  Larger x-increment - for small-diameters.
27
+ * Version 1.6.  2015-09-01  Options: square threads, rectangular threads.
28
+ * Version 1.5.  2015-06-12  Options: thread_size, groove.
29
+ * Version 1.4.  2014-10-17  Use "faces" instead of "triangles" for polyhedron
30
+ * Version 1.3.  2013-12-01  Correct loop over turns -- don't have early cut-off
31
+ * Version 1.2.  2012-09-09  Use discrete polyhedra rather than linear_extrude ()
32
+ * Version 1.1.  2012-09-07  Corrected to right-hand threads!
33
+ */
34
+
35
+// Examples.
36
+//
37
+// Standard M8 x 1.
38
+// metric_thread (diameter=8, pitch=1, length=4);
39
+
40
+// Square thread.
41
+// metric_thread (diameter=8, pitch=1, length=4, square=true);
42
+
43
+// Non-standard: long pitch, same thread size.
44
+//metric_thread (diameter=8, pitch=4, length=4, thread_size=1, groove=true);
45
+
46
+// Non-standard: 20 mm diameter, long pitch, square "trough" width 3 mm,
47
+// depth 1 mm.
48
+//metric_thread (diameter=20, pitch=8, length=16, square=true, thread_size=6,
49
+//               groove=true, rectangle=0.333);
50
+
51
+// English: 1/4 x 20.
52
+//english_thread (diameter=1/4, threads_per_inch=20, length=1);
53
+
54
+// Tapered.  Example -- pipe size 3/4" -- per:
55
+// http://www.engineeringtoolbox.com/npt-national-pipe-taper-threads-d_750.html
56
+// english_thread (diameter=1.05, threads_per_inch=14, length=3/4, taper=1/16);
57
+
58
+// Thread for mounting on Rohloff hub.
59
+//difference () {
60
+//   cylinder (r=20, h=10, $fn=100);
61
+//
62
+//   metric_thread (diameter=34, pitch=1, length=10, internal=true, n_starts=6);
63
+//}
64
+
65
+
66
+// ----------------------------------------------------------------------------
67
+function segments (diameter) = min (50, max (ceil (diameter*6), 25));
68
+
69
+
70
+// ----------------------------------------------------------------------------
71
+// diameter -    outside diameter of threads in mm. Default: 8.
72
+// pitch    -    thread axial "travel" per turn in mm.  Default: 1.
73
+// length   -    overall axial length of thread in mm.  Default: 1.
74
+// internal -    true = clearances for internal thread (e.g., a nut).
75
+//               false = clearances for external thread (e.g., a bolt).
76
+//               (Internal threads should be "cut out" from a solid using
77
+//               difference ()).  Default: false.
78
+// n_starts -    Number of thread starts (e.g., DNA, a "double helix," has
79
+//               n_starts=2).  See wikipedia Screw_thread.  Default: 1.
80
+// thread_size - (non-standard) axial width of a single thread "V" - independent
81
+//               of pitch.  Default: same as pitch.
82
+// groove      - (non-standard) true = subtract inverted "V" from cylinder
83
+//                (rather thanadd protruding "V" to cylinder).  Default: false.
84
+// square      - true = square threads (per
85
+//               https://en.wikipedia.org/wiki/Square_thread_form).  Default:
86
+//               false.
87
+// rectangle   - (non-standard) "Rectangular" thread - ratio depth/(axial) width
88
+//               Default: 0 (standard "v" thread).
89
+// angle       - (non-standard) angle (deg) of thread side from perpendicular to
90
+//               axis (default = standard = 30 degrees).
91
+// taper       - diameter change per length (National Pipe Thread/ANSI B1.20.1
92
+//               is 1" diameter per 16" length). Taper decreases from 'diameter'
93
+//               as z increases.  Default: 0 (no taper).
94
+// leadin      - 0 (default): no chamfer; 1: chamfer (45 degree) at max-z end;
95
+//               2: chamfer at both ends, 3: chamfer at z=0 end.
96
+// leadfac     - scale of leadin chamfer (default: 1.0 = 1/2 thread).
97
+// test        - true = do not render threads (just draw "blank" cylinder).
98
+//               Default: false (draw threads).
99
+module metric_thread (diameter=8, pitch=1, length=1, internal=false, n_starts=1,
100
+                      thread_size=-1, groove=false, square=false, rectangle=0,
101
+                      angle=30, taper=0, leadin=0, leadfac=1.0, test=false)
102
+{
103
+   // thread_size: size of thread "V" different than travel per turn (pitch).
104
+   // Default: same as pitch.
105
+   local_thread_size = thread_size == -1 ? pitch : thread_size;
106
+   local_rectangle = rectangle ? rectangle : 1;
107
+
108
+   n_segments = segments (diameter);
109
+   h = (test && ! internal) ? 0 : (square || rectangle) ? local_thread_size*local_rectangle/2 : local_thread_size / (2 * tan(angle));
110
+
111
+   h_fac1 = (square || rectangle) ? 0.90 : 0.625;
112
+
113
+   // External thread includes additional relief.
114
+   h_fac2 = (square || rectangle) ? 0.95 : 5.3/8;
115
+
116
+   tapered_diameter = diameter - length*taper;
117
+
118
+   difference () {
119
+      union () {
120
+         if (! groove) {
121
+            if (! test) {
122
+               metric_thread_turns (diameter, pitch, length, internal, n_starts,
123
+                                    local_thread_size, groove, square, rectangle, angle,
124
+                                    taper);
125
+            }
126
+         }
127
+
128
+         difference () {
129
+
130
+            // Solid center, including Dmin truncation.
131
+            if (groove) {
132
+               cylinder (r1=diameter/2, r2=tapered_diameter/2,
133
+                         h=length, $fn=n_segments);
134
+            } else if (internal) {
135
+               cylinder (r1=diameter/2 - h*h_fac1, r2=tapered_diameter/2 - h*h_fac1,
136
+                         h=length, $fn=n_segments);
137
+            } else {
138
+
139
+               // External thread.
140
+               cylinder (r1=diameter/2 - h*h_fac2, r2=tapered_diameter/2 - h*h_fac2,
141
+                         h=length, $fn=n_segments);
142
+            }
143
+
144
+            if (groove) {
145
+               if (! test) {
146
+                  metric_thread_turns (diameter, pitch, length, internal, n_starts,
147
+                                       local_thread_size, groove, square, rectangle,
148
+                                       angle, taper);
149
+               }
150
+            }
151
+         }
152
+      }
153
+
154
+      // chamfer z=0 end if leadin is 2 or 3
155
+      if (leadin == 2 || leadin == 3) {
156
+         difference () {
157
+            cylinder (r=diameter/2 + 1, h=h*h_fac1*leadfac, $fn=n_segments);
158
+
159
+            cylinder (r2=diameter/2, r1=diameter/2 - h*h_fac1*leadfac, h=h*h_fac1*leadfac,
160
+                      $fn=n_segments);
161
+         }
162
+      }
163
+
164
+      // chamfer z-max end if leadin is 1 or 2.
165
+      if (leadin == 1 || leadin == 2) {
166
+         translate ([0, 0, length + 0.05 - h*h_fac1*leadfac]) {
167
+            difference () {
168
+               cylinder (r=diameter/2 + 1, h=h*h_fac1*leadfac, $fn=n_segments);
169
+               cylinder (r1=tapered_diameter/2, r2=tapered_diameter/2 - h*h_fac1*leadfac, h=h*h_fac1*leadfac,
170
+                         $fn=n_segments);
171
+            }
172
+         }
173
+      }
174
+   }
175
+}
176
+
177
+
178
+// ----------------------------------------------------------------------------
179
+// Input units in inches.
180
+// Note: units of measure in drawing are mm!
181
+module english_thread (diameter=0.25, threads_per_inch=20, length=1,
182
+                      internal=false, n_starts=1, thread_size=-1, groove=false,
183
+                      square=false, rectangle=0, angle=30, taper=0, leadin=0,
184
+                      leadfac=1.0, test=false)
185
+{
186
+   // Convert to mm.
187
+   mm_diameter = diameter*25.4;
188
+   mm_pitch = (1.0/threads_per_inch)*25.4;
189
+   mm_length = length*25.4;
190
+
191
+   echo (str ("mm_diameter: ", mm_diameter));
192
+   echo (str ("mm_pitch: ", mm_pitch));
193
+   echo (str ("mm_length: ", mm_length));
194
+   metric_thread (mm_diameter, mm_pitch, mm_length, internal, n_starts,
195
+                  thread_size, groove, square, rectangle, angle, taper, leadin,
196
+                  leadfac, test);
197
+}
198
+
199
+// ----------------------------------------------------------------------------
200
+module metric_thread_turns (diameter, pitch, length, internal, n_starts,
201
+                            thread_size, groove, square, rectangle, angle,
202
+                            taper)
203
+{
204
+   // Number of turns needed.
205
+   n_turns = floor (length/pitch);
206
+
207
+   intersection () {
208
+
209
+      // Start one below z = 0.  Gives an extra turn at each end.
210
+      for (i=[-1*n_starts : n_turns+1]) {
211
+         translate ([0, 0, i*pitch]) {
212
+            metric_thread_turn (diameter, pitch, internal, n_starts,
213
+                                thread_size, groove, square, rectangle, angle,
214
+                                taper, i*pitch);
215
+         }
216
+      }
217
+
218
+      // Cut to length.
219
+      translate ([0, 0, length/2]) {
220
+         cube ([diameter*3, diameter*3, length], center=true);
221
+      }
222
+   }
223
+}
224
+
225
+
226
+// ----------------------------------------------------------------------------
227
+module metric_thread_turn (diameter, pitch, internal, n_starts, thread_size,
228
+                           groove, square, rectangle, angle, taper, z)
229
+{
230
+   n_segments = segments (diameter);
231
+   fraction_circle = 1.0/n_segments;
232
+   for (i=[0 : n_segments-1]) {
233
+      rotate ([0, 0, i*360*fraction_circle]) {
234
+         translate ([0, 0, i*n_starts*pitch*fraction_circle]) {
235
+            //current_diameter = diameter - taper*(z + i*n_starts*pitch*fraction_circle);
236
+            thread_polyhedron ((diameter - taper*(z + i*n_starts*pitch*fraction_circle))/2,
237
+                               pitch, internal, n_starts, thread_size, groove,
238
+                               square, rectangle, angle);
239
+         }
240
+      }
241
+   }
242
+}
243
+
244
+
245
+// ----------------------------------------------------------------------------
246
+module thread_polyhedron (radius, pitch, internal, n_starts, thread_size,
247
+                          groove, square, rectangle, angle)
248
+{
249
+   n_segments = segments (radius*2);
250
+   fraction_circle = 1.0/n_segments;
251
+
252
+   local_rectangle = rectangle ? rectangle : 1;
253
+
254
+   h = (square || rectangle) ? thread_size*local_rectangle/2 : thread_size / (2 * tan(angle));
255
+   outer_r = radius + (internal ? h/20 : 0); // Adds internal relief.
256
+   //echo (str ("outer_r: ", outer_r));
257
+
258
+   // A little extra on square thread -- make sure overlaps cylinder.
259
+   h_fac1 = (square || rectangle) ? 1.1 : 0.875;
260
+   inner_r = radius - h*h_fac1; // Does NOT do Dmin_truncation - do later with
261
+                                // cylinder.
262
+
263
+   translate_y = groove ? outer_r + inner_r : 0;
264
+   reflect_x   = groove ? 1 : 0;
265
+
266
+   // Make these just slightly bigger (keep in proportion) so polyhedra will
267
+   // overlap.
268
+   x_incr_outer = (! groove ? outer_r : inner_r) * fraction_circle * 2 * PI * 1.02;
269
+   x_incr_inner = (! groove ? inner_r : outer_r) * fraction_circle * 2 * PI * 1.02;
270
+   z_incr = n_starts * pitch * fraction_circle * 1.005;
271
+
272
+   /*
273
+    (angles x0 and x3 inner are actually 60 deg)
274
+
275
+                          /\  (x2_inner, z2_inner) [2]
276
+                         /  \
277
+   (x3_inner, z3_inner) /    \
278
+                  [3]   \     \
279
+                        |\     \ (x2_outer, z2_outer) [6]
280
+                        | \    /
281
+                        |  \  /|
282
+             z          |[7]\/ / (x1_outer, z1_outer) [5]
283
+             |          |   | /
284
+             |   x      |   |/
285
+             |  /       |   / (x0_outer, z0_outer) [4]
286
+             | /        |  /     (behind: (x1_inner, z1_inner) [1]
287
+             |/         | /
288
+    y________|          |/
289
+   (r)                  / (x0_inner, z0_inner) [0]
290
+
291
+   */
292
+
293
+   x1_outer = outer_r * fraction_circle * 2 * PI;
294
+
295
+   z0_outer = (outer_r - inner_r) * tan(angle);
296
+   //echo (str ("z0_outer: ", z0_outer));
297
+
298
+   //polygon ([[inner_r, 0], [outer_r, z0_outer],
299
+   //        [outer_r, 0.5*pitch], [inner_r, 0.5*pitch]]);
300
+   z1_outer = z0_outer + z_incr;
301
+
302
+   // Give internal square threads some clearance in the z direction, too.
303
+   bottom = internal ? 0.235 : 0.25;
304
+   top    = internal ? 0.765 : 0.75;
305
+
306
+   translate ([0, translate_y, 0]) {
307
+      mirror ([reflect_x, 0, 0]) {
308
+
309
+         if (square || rectangle) {
310
+
311
+            // Rule for face ordering: look at polyhedron from outside: points must
312
+            // be in clockwise order.
313
+            polyhedron (
314
+               points = [
315
+                         [-x_incr_inner/2, -inner_r, bottom*thread_size],         // [0]
316
+                         [x_incr_inner/2, -inner_r, bottom*thread_size + z_incr], // [1]
317
+                         [x_incr_inner/2, -inner_r, top*thread_size + z_incr],    // [2]
318
+                         [-x_incr_inner/2, -inner_r, top*thread_size],            // [3]
319
+
320
+                         [-x_incr_outer/2, -outer_r, bottom*thread_size],         // [4]
321
+                         [x_incr_outer/2, -outer_r, bottom*thread_size + z_incr], // [5]
322
+                         [x_incr_outer/2, -outer_r, top*thread_size + z_incr],    // [6]
323
+                         [-x_incr_outer/2, -outer_r, top*thread_size]             // [7]
324
+                        ],
325
+
326
+               faces = [
327
+                         [0, 3, 7, 4],  // This-side trapezoid
328
+
329
+                         [1, 5, 6, 2],  // Back-side trapezoid
330
+
331
+                         [0, 1, 2, 3],  // Inner rectangle
332
+
333
+                         [4, 7, 6, 5],  // Outer rectangle
334
+
335
+                         // These are not planar, so do with separate triangles.
336
+                         [7, 2, 6],     // Upper rectangle, bottom
337
+                         [7, 3, 2],     // Upper rectangle, top
338
+
339
+                         [0, 5, 1],     // Lower rectangle, bottom
340
+                         [0, 4, 5]      // Lower rectangle, top
341
+                        ]
342
+            );
343
+         } else {
344
+
345
+            // Rule for face ordering: look at polyhedron from outside: points must
346
+            // be in clockwise order.
347
+            polyhedron (
348
+               points = [
349
+                         [-x_incr_inner/2, -inner_r, 0],                        // [0]
350
+                         [x_incr_inner/2, -inner_r, z_incr],                    // [1]
351
+                         [x_incr_inner/2, -inner_r, thread_size + z_incr],      // [2]
352
+                         [-x_incr_inner/2, -inner_r, thread_size],              // [3]
353
+
354
+                         [-x_incr_outer/2, -outer_r, z0_outer],                 // [4]
355
+                         [x_incr_outer/2, -outer_r, z0_outer + z_incr],         // [5]
356
+                         [x_incr_outer/2, -outer_r, thread_size - z0_outer + z_incr], // [6]
357
+                         [-x_incr_outer/2, -outer_r, thread_size - z0_outer]    // [7]
358
+                        ],
359
+
360
+               faces = [
361
+                         [0, 3, 7, 4],  // This-side trapezoid
362
+
363
+                         [1, 5, 6, 2],  // Back-side trapezoid
364
+
365
+                         [0, 1, 2, 3],  // Inner rectangle
366
+
367
+                         [4, 7, 6, 5],  // Outer rectangle
368
+
369
+                         // These are not planar, so do with separate triangles.
370
+                         [7, 2, 6],     // Upper rectangle, bottom
371
+                         [7, 3, 2],     // Upper rectangle, top
372
+
373
+                         [0, 5, 1],     // Lower rectangle, bottom
374
+                         [0, 4, 5]      // Lower rectangle, top
375
+                        ]
376
+            );
377
+         }
378
+      }
379
+   }
380
+}
381
+
382
+

Loading…
Откажи
Сачувај