diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..50ba420 --- /dev/null +++ b/LICENSE @@ -0,0 +1,26 @@ +Copyright 2019 Adrian Schlatter + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors +may be used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.rst b/README.rst index c16ad85..70fbca1 100644 --- a/README.rst +++ b/README.rst @@ -1,14 +1,101 @@ -PET-Bottle Waterrocket Fins +threadlib +++++++++++++++++++++++++++ -This is a CAD-model of fins intended to be screwed onto a PET bottle to create a -water rocket. To create the rocket, you need: +threadlib is a library of standard threads for OpenSCAD. It is based on Helges +excellent `threadprofile.scad +`__ +to create nice threads with lead-in / lead-out tapers. Check out his `article on +generating nice threads +`__ on +Hackaday. -- bottle with PCO-1881 threading (e.g. a 1.5-l Coke bottle) -- this part -- Gardena tap connector G 1" -- launcher +In contrast to other thread libraries, threadlib does not make you look up +diameters and pitches and maybe even thread-profiles in tables and norms: It has +these tables built in. -(+ water + pressurized air). +Creating a thread is as simple as + +.. code-block:: OpenSCAD + + thread("G1/2-ext", turns=10, higbee_arc=20); + +to create a British Standard Pipe parallel external thread. Furthermore, +threadlib allows for production tolerances by choosing thread dimensions well +inside the ranges allowed by the norms. + + +Usage +=========================== + +To create a bolt (without head) with 10 turns of G1-inch thread: + +.. code-block:: OpenSCAD + + bolt("G1", turns=10); + +A nut: + +.. code-block:: OpenSCAD + + nut("G1", turns=10, Douter=40); + +Note that for a nut you also have to specify an outer diameter. The inner +diameter is implicitly given by the thread designator ("G1" in this case). + +If you only need the threads alone: + +.. code-block:: OpenSCAD + + thread("G2 1/2-ext", turns=5); + +Then, add the support you want. In the simplest case, a cylinder (which is what +nut(...) uses): + +.. code-block:: OpenSCAD + + specs = thread_specs("G2 1/2-ext"); + P = specs[0]; Rrot = specs[1]; Dsupport = specs[2]; + section_profile = specs[3]; + H = (5 + 1) * P; + translate([0, 0, -P / 2]) + cylinder(h=H, d=Dsupport, $fn=120); + +Here, we have used the function thread_specs(...) to look up the threads +specifications - including the recommended diameter of the support structure. + + +List of supported threads +=========================== + +Currently, threadlib knows these threads: + +- British Standard Pipe Parallel Threadss G1/16 to G6 + + +Extensibility +=========================== + +Don't find some of the threads you need for your project? Don't worry: You can +add your own: + +.. code-block:: OpenSCAD + + use + + MY_THREAD_TABLE = [ + ["special", [pitch, Rrot, Dsupport, + [[r0, z0], [r1, z1], ..., [rn, zn]]]] + ]; + + thread("special", turns=15, table=MY_THREAD_TABLE); + +Care to share? Safe others from repeating the valuable work you have already +accomplished and get the fame you deserve: Send in your tried and tested threads +for addition to threadlib! + + +Change Log +=========================== + +- 0.1: Initial release supporting BSP parallel thread -Use at your own risk. diff --git a/THREAD_TABLE.scad b/THREAD_TABLE.scad new file mode 100644 index 0000000..c0e36af --- /dev/null +++ b/THREAD_TABLE.scad @@ -0,0 +1,52 @@ +/* This script is auto-generated - do not edit + :License: 3-clause BSD. See LICENSE. */ + +THREAD_TABLE = [["G1/16-int", [0.907, 3.98, 7.92, [[0, 0.42515625], [0, -0.42515625], [-0.560841406, -0.12426807], [-0.560841406, 0.12426807 ]]]], +["G1/8-int", [0.907, 4.98138486, 9.93, [[0, 0.42515625], [0, -0.42515625], [-0.560841406, -0.12426807], [-0.560841406, 0.12426807 ]]]], +["G1/4-int", [1.337, 6.743577241, 13.43, [[0, 0.62671875], [0, -0.62671875], [-0.826730937, -0.18318237], [-0.826730937, 0.18318237 ]]]], +["G3/8-int", [1.337, 8.496077241, 16.94, [[0, 0.62671875], [0, -0.62671875], [-0.826730937, -0.18318237], [-0.826730937, 0.18318237 ]]]], +["G1/2-int", [1.814, 10.69426972, 21.32, [[0, 0.8503125], [0, -0.8503125], [-1.121682812, -0.24853614], [-1.121682812, 0.24853614 ]]]], +["G5/8-int", [1.814, 11.67226972, 23.27, [[0, 0.8503125], [0, -0.8503125], [-1.121682812, -0.24853614], [-1.121682812, 0.24853614 ]]]], +["G3/4-int", [1.814, 13.43726972, 26.80, [[0, 0.8503125], [0, -0.8503125], [-1.121682812, -0.24853614], [-1.121682812, 0.24853614 ]]]], +["G7/8-int", [1.814, 15.31726972, 30.56, [[0, 0.8503125], [0, -0.8503125], [-1.121682812, -0.24853614], [-1.121682812, 0.24853614 ]]]], +["G1-int", [2.309, 16.90027607, 33.71, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609 ]]]], +["G1 1/8-int", [2.309, 19.22427607, 38.36, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609 ]]]], +["G1 1/4-int", [2.309, 21.23077607, 42.37, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609 ]]]], +["G1 1/2-int", [2.309, 24.17727607, 48.26, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609 ]]]], +["G1 3/4-int", [2.309, 27.14877607, 54.21, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609 ]]]], +["G2-int", [2.309, 30.08277607, 60.07, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609 ]]]], +["G2 1/4-int", [2.309, 33.14002607, 66.19, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609 ]]]], +["G2 1/2-int", [2.309, 37.87702607, 75.66, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609 ]]]], +["G2 3/4-int", [2.309, 41.05202607, 82.01, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609 ]]]], +["G3-int", [2.309, 44.22702607, 88.36, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609 ]]]], +["G3 1/2-int", [2.309, 50.45002607, 100.81, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609 ]]]], +["G4-int", [2.309, 56.80002607, 113.51, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609 ]]]], +["G4 1/2-int", [2.309, 63.15002607, 126.21, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609 ]]]], +["G5-int", [2.309, 69.50002607, 138.91, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609 ]]]], +["G5 1/2-int", [2.309, 75.85002607, 151.61, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609 ]]]], +["G6-int", [2.309, 82.20002607, 164.31, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609 ]]]], +["G1/16-ext", [0.907, 3.21661514, 6.47, [[0, -0.42515625], [0, 0.42515625], [0.578008291, 0.12426807], [0.578008291, -0.12426807 ]]]], +["G1/8-ext", [0.907, 4.21911514, 8.474528838, [[0, -0.42515625], [0, 0.42515625], [0.578008291, 0.12426807], [0.578008291, -0.12426807 ]]]], +["G1/4-ext", [1.337, 5.619922759, 11.29335287, [[0, -0.62671875], [0, 0.62671875], [0.852036477, 0.18318237], [0.852036477, -0.18318237 ]]]], +["G3/8-ext", [1.337, 7.372422759, 14.79835287, [[0, -0.62671875], [0, 0.62671875], [0.852036477, 0.18318237], [0.852036477, -0.18318237 ]]]], +["G1/2-ext", [1.814, 9.16973028, 18.41205768, [[0, -0.8503125], [0, 0.8503125], [1.156016582, 0.24853614], [1.156016582, -0.24853614 ]]]], +["G5/8-ext", [1.814, 10.14773028, 20.36805768, [[0, -0.8503125], [0, 0.8503125], [1.156016582, 0.24853614], [1.156016582, -0.24853614 ]]]], +["G3/4-ext", [1.814, 11.91273028, 23.89805768, [[0, -0.8503125], [0, 0.8503125], [1.156016582, 0.24853614], [1.156016582, -0.24853614 ]]]], +["G7/8-ext", [1.814, 13.79273028, 27.65805768, [[0, -0.8503125], [0, 0.8503125], [1.156016582, 0.24853614], [1.156016582, -0.24853614 ]]]], +["G1-ext", [2.309, 14.95972393, 30.01185511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609 ]]]], +["G1 1/8-ext", [2.309, 17.28372393, 34.65985511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609 ]]]], +["G1 1/4-ext", [2.309, 19.29022393, 38.67285511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609 ]]]], +["G1 1/2-ext", [2.309, 22.23672393, 44.56585511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609 ]]]], +["G1 3/4-ext", [2.309, 25.20822393, 50.50885511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609 ]]]], +["G2-ext", [2.309, 28.14222393, 56.37685511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609 ]]]], +["G2 1/4-ext", [2.309, 31.19947393, 62.49135511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609 ]]]], +["G2 1/2-ext", [2.309, 35.93647393, 71.96535511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609 ]]]], +["G2 3/4-ext", [2.309, 39.11147393, 78.31535511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609 ]]]], +["G3-ext", [2.309, 42.28647393, 84.66535511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609 ]]]], +["G3 1/2-ext", [2.309, 48.50947393, 97.11135511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609 ]]]], +["G4-ext", [2.309, 54.85947393, 109.8113551, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609 ]]]], +["G4 1/2-ext", [2.309, 61.20947393, 122.5113551, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609 ]]]], +["G5-ext", [2.309, 67.55947393, 135.2113551, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609 ]]]], +["G5 1/2-ext", [2.309, 73.90947393, 147.9113551, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609 ]]]], +["G6-ext", [2.309, 80.25947393, 160.6113551, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609]]]], +]; diff --git a/autogenerate.awk b/autogenerate.awk new file mode 100644 index 0000000..305f800 --- /dev/null +++ b/autogenerate.awk @@ -0,0 +1,5 @@ +BEGIN { print "/* This script is auto-generated - do not edit" + print " :License: 3-clause BSD. See LICENSE. */" + printf "\nTHREAD_TABLE = [" } +/^G/ { print "[\"" $1 "\", [" $2 ", " $3 ", " $4 ", [[" $5 ", " $6 "], [" $7 ", " $8 "], [" $9 ", " $10 "], [" $11 ", " $12 "]]]],"} +END { print "];" } diff --git a/img/BSPthread.jpg b/img/BSPthread.jpg new file mode 100644 index 0000000..c7f6818 Binary files /dev/null and b/img/BSPthread.jpg differ diff --git a/test.scad b/test.scad new file mode 100644 index 0000000..443015c --- /dev/null +++ b/test.scad @@ -0,0 +1,25 @@ +/* +Test and demonstrate thread library + +:Author: Adrian Schlatter +:Date: 2019-04-07 +:License: 3-Clause BSD. See LICENSE. +*/ + +use + +echo ("threadlib version: ", __THREADLIB_VERSION()); + +type = "G1"; +turns = 5; +Douter = thread_specs(str(type, "-int"))[2] * 1.2; + +intersection() { + color("Green") + translate([-100, 0, -100]) + cube(200, 200, 200); + union() { + bolt(type, turns); + nut(type, turns, Douter); + }; +}; diff --git a/threadlib.scad b/threadlib.scad new file mode 100644 index 0000000..8754604 --- /dev/null +++ b/threadlib.scad @@ -0,0 +1,62 @@ +/* +threadlib ++++++++++ + +Create threads easily. + +:Author: Adrian Schlatter +:Date: 2019-04-07 +:License: 3-Clause BSD. See LICENSE. +*/ + +function __THREADLIB_VERSION() = 0.1; + +use +include + +function thread_specs(designator, table=THREAD_TABLE) = + /* Returns thread specs of thread-type 'designator' as a vector of + [pitch, Rrotation, Dsupport, section_profile] */ + + table[search([designator], table, num_returns_per_match=1, + index_col_num=0)[0]][1]; + +module thread(designator, turns, higbee_arc=20, fn=120, table=THREAD_TABLE) +{ + specs = thread_specs(designator, table=table); + P = specs[0]; Rrotation = specs[1]; section_profile = specs[3]; + straight_thread( + section_profile=section_profile, + higbee_arc=higbee_arc, + r=Rrotation, + turns=turns, + pitch=P); +} + +module bolt(designator, turns, higbee_arc=20, fn=120, table=THREAD_TABLE) { + union() { + specs = thread_specs(str(designator, "-ext"), table=table); + P = specs[0]; Dsupport = specs[2]; + H = (turns + 1) * P; + thread(str(designator, "-ext"), turns=turns, higbee_arc=higbee_arc, fn=fn, table=table); + translate([0, 0, -P / 2]) + cylinder(h=H, d=Dsupport, $fn=fn); + }; +}; + +module nut(designator, turns, Douter, higbee_arc=20, fn=120, table=THREAD_TABLE) { + union() { + specs = thread_specs(str(designator, "-int"), table=table); + P = specs[0]; Dsupport = specs[2]; + H = (turns + 1) * P; + rotate(180) + thread(str(designator, "-int"), turns=turns, higbee_arc=higbee_arc, fn=fn, table=table); + + translate([0, 0, -P / 2]) + difference() { + cylinder(h=H, d=Douter, $fn=fn); + translate([0, 0, -0.1]) + cylinder(h=H+0.2, d=Dsupport, $fn=fn); + }; + }; +}; diff --git a/threads.xlsx b/threads.xlsx new file mode 100644 index 0000000..e281569 Binary files /dev/null and b/threads.xlsx differ