Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions THREAD_TABLE.scad
Original file line number Diff line number Diff line change
Expand Up @@ -1827,4 +1827,6 @@ THREAD_TABLE = [["G1/16-ext", [0.907, 3.1631, 6.3625, [[0, -0.4252], [0, 0.4252]
["32-UN-3/4-int", [0.79375, -9.5551, 19.1033, [[0, 0.3473], [0, -0.3473], [0.4296, -0.0992], [0.4296, 0.0992]]]],
["32-UN-13/16-ext", [0.79375, 9.8517, 19.7103, [[0, -0.2977], [0, 0.2977], [0.4296, 0.0496], [0.4296, -0.0496]]]],
["32-UN-13/16-int", [0.79375, -10.3492, 20.6914, [[0, 0.3473], [0, -0.3473], [0.4296, -0.0992], [0.4296, 0.0992]]]],
["32-UN-1-ext", [0.79375, 12.2319, 24.4707, [[0, -0.2977], [0, 0.2977], [0.4296, 0.0496], [0.4296, -0.0496]]]],
["32-UN-1-int", [0.79375, -12.7312, 25.4556, [[0, 0.3473], [0, -0.3473], [0.4296, -0.0992], [0.4296, 0.0992]]]]
];
35 changes: 19 additions & 16 deletions threadlib.scad
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ function __THREADLIB_VERSION() = 0.3;
use <thread_profile.scad>
include <THREAD_TABLE.scad>

bolt("M6", height=2.8, tol=0);

function thread_specs(designator, table=THREAD_TABLE) =
/* Returns thread specs of thread-type 'designator' as a vector of
[pitch, Rrotation, Dsupport, section_profile] */
Expand All @@ -24,56 +26,57 @@ function thread_specs(designator, table=THREAD_TABLE) =
// verify that we found something and return it:
assert(!is_undef(specs), str("Designator: '", designator, "' not found")) specs;

module thread(designator, turns, higbee_arc=20, fn=120, table=THREAD_TABLE)
module thread(designator, turns, higbee_arc=20, fn=120, table=THREAD_TABLE, tol=0)
{
specs = thread_specs(designator, table=table);
P = specs[0]; Rrotation = specs[1]; section_profile = specs[3];
P = specs[0]; Rrotation = specs[1]-tol; section_profile = specs[3];
straight_thread(
section_profile=section_profile,
higbee_arc=higbee_arc,
r=Rrotation,
turns=turns,
fn=fn,
pitch=P);
pitch=P, fn=fn); // added fn for this function : smoother thread
}

module bolt(designator, turns, higbee_arc=20, fn=120, table=THREAD_TABLE) {
module bolt(designator, turns, height=0, higbee_arc=20, fn=120, table=THREAD_TABLE, tol=0) {
union() {
specs = thread_specs(str(designator, "-ext"), table=table);
P = specs[0]; Dsupport = specs[2];
turns=turns?turns:height/P;
H = (turns + 1) * P;
thread(str(designator, "-ext"), turns=turns, higbee_arc=higbee_arc, fn=fn, table=table);
thread(str(designator, "-ext"), turns=turns, higbee_arc=higbee_arc, fn=fn, table=table, tol=tol);
translate([0, 0, -P / 2])
cylinder(h=H, d=Dsupport, $fn=fn);
cylinder(h=H, d=Dsupport-2*tol, $fn=fn);
};
};

module nut(designator, turns, Douter, higbee_arc=20, fn=120, table=THREAD_TABLE) {
module nut(designator, turns, height=0, Douter, higbee_arc=20, fn=120, table=THREAD_TABLE, tol=0.0) {
union() {
specs = thread_specs(str(designator, "-int"), table=table);
P = specs[0]; Dsupport = specs[2];
P = specs[0]; Dsupport = specs[2] + tol;
turns=turns?turns:height/P;
H = (turns + 1) * P;
thread(str(designator, "-int"), turns=turns, higbee_arc=higbee_arc, fn=fn, table=table);
thread(str(designator, "-int"), turns=turns, higbee_arc=higbee_arc, fn=fn, table=table, tol=tol);

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);
cylinder(h=H+0.2, d=Dsupport+tol, $fn=fn);
};
};
};

module tap(designator, turns, higbee_arc=20, fn=120, table=THREAD_TABLE) {
module tap(designator, turns, height=0, higbee_arc=20, fn=120, table=THREAD_TABLE, tol=0.0) {
difference() {
specs = thread_specs(str(designator, "-int"), table=table);
P = specs[0]; Dsupport = specs[2];
H = (turns + 1) * P;

turns=turns?turns:height/P;
H = (turns + 1) * P;
translate([0, 0, -P / 2]) {
cylinder(h=H, d=Dsupport, $fn=fn);
cylinder(h=H, d=Dsupport+2*tol, $fn=fn);
};

thread(str(designator, "-int"), turns=turns, higbee_arc=higbee_arc, fn=fn, table=table);
thread(str(designator, "-int"), turns=turns, higbee_arc=higbee_arc, fn=fn, table=table, tol=tol);
};
}