libs/Threading/Threading.scad

Wed, 12 Sep 2018 12:48:28 +0200

author
mdd
date
Wed, 12 Sep 2018 12:48:28 +0200
changeset 0
15eac37578b7
permissions
-rw-r--r--

initial commit of FluidSwitch prototype

0
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
1 // Threading.scad - library for threadings
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
2 // Autor: Rudolf Huttary, Berlin 2016
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
3
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
4 use <Naca_sweep.scad> // http://www.thingiverse.com/thing:900137
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
5
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
6 // examples
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
7 showexample = 10; // choose your example number
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
8
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
9 example(showexample)
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
10 {
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
11 // #1 ACME thread
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
12 threading(pitch = 2, d=20, windings = 5, angle = 29);
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
13
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
14 // #2 threaded rod 20°
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
15 threading(pitch = 2, d=20, windings = 30, angle = 20, full = true);
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
16
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
17 // #3 nut for threaded rod 20°
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
18 Threading(pitch = 2, d=20, windings = 10, angle = 20, full = true);
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
19
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
20 // #4 nut for threaded rod 20°, own diameter 25 mm, hires
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
21 Threading(D = 25, pitch = 2, d=20, windings = 10, angle = 20, full = true, step = 50, $fn=100);
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
22
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
23 // #5 triple helix threaded rod
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
24 threading(pitch = 2, d=20, windings = 30, helices = 3, angle = 20, full = true);
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
25
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
26 // #6 toothed rod (no pitch)
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
27 threading(helices = 0, angle = 20, full = true);
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
28
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
29 // #7 toothed cube (no pitch)
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
30 threading(helices = 0, angle = 60, full = true, steps=4);
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
31
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
32 // #8 M8 hex bolt
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
33 union(){
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
34 threading(pitch = 1.25, d=8, windings=20, full=true); cylinder(d=14.6, h=4, $fn=6);}
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
35 // #9 M8 hex nut
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
36 Threading(D=14.6, pitch = 1.25, d=8, windings=5, full=true, $fn=6);
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
37 // #10 M8 four socket nut
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
38 Threading(D=16, pitch = 1.25, d=8, windings=5, full=true, $fn=4);
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
39 }
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
40
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
41 module example(number=0) if(number) children(number-1);
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
42
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
43 help();
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
44 module help()
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
45 {
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
46 helpstr =
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
47 "Thread library - Rudolf Huttary \n
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
48 D = {0=auto}; // Cyl diameter Threading() \n
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
49 d = 6; // outer diameter thread() \n
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
50 windings = 10; // number of windings \n
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
51 helices = 1; // number of threads \n
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
52 angle = 60; // open angle <76, bolts: 60°, ACME: 29°, toothed Racks: 20° \n
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
53 steps = 40; // resolution \n
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
54 help(); // show help in console
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
55 threading(pitch = 1, d = 6, windings = 10, helices = 1, angle = 60, steps=40, full = false) \n
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
56 Threading(D = 0, pitch = 1, r = 6, windings = 10, helices = 1, angle = 60, steps=40) \n
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
57 ";
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
58 echo (helpstr);
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
59 }
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
60
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
61 //Threading(R=12, pitch = pitch, r=radius, windings= windings, angle = angle);
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
62
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
63 module Threading(D = 0, pitch = 1, d = 12, windings = 10, helices = 1, angle = 60, steps=40)
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
64 {
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
65 R = D==0?d/2+2*pitch/PI:D/2;
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
66 translate([0,0,-pitch])
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
67 difference()
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
68 {
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
69 translate([0,0,pitch])
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
70 cylinder (r=R, h =pitch*(windings-helices));
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
71 threading(pitch, d, windings, helices, angle, steps, true);
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
72 }
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
73 }
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
74
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
75 module threading(pitch = 1, d = 12, windings = 10, helices = 1, angle = 60, steps=40, full = false)
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
76 { // tricky: glue two 180° pieces together to get a proper manifold
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
77 r = d/2;
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
78 Steps = steps/2;
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
79 Pitch = pitch*helices;
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
80 if(full) cylinder(r = r-.5-pitch/PI, h=pitch*(windings+helices), $fn=steps);
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
81 sweep(gen_dat()); // half screw
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
82 rotate([0, 0, 180]) translate([0, 0, Pitch/2])
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
83 sweep(gen_dat()); // half screw
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
84 echo(steps);
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
85 function gen_dat() = let(ang = 180, bar = R_(180, -90, 0, Ty_(-r+.5, vec3D(pitch/PI*Rack(windings, angle)))))
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
86 [for (i=[0:Steps]) Tz_(i/2/Steps*Pitch, Rz_(i*ang/Steps, bar))];
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
87
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
88 function Rack(w, angle) =
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
89 concat([[0, 2]], [for (i=[0:windings-1], j=[0:3])
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
90 let(t = [ [0, 1], [2*tan(angle/2), -1], [PI/2, -1], [2*tan(angle/2)+PI/2, 1]])
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
91 [t[j][0]+i*PI, t[j][1]]], [[w*PI, 1], [w*PI, 2]]);
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
92 }
15eac37578b7 initial commit of FluidSwitch prototype
mdd
parents:
diff changeset
93

mercurial