Files
threadlib/design/metric_thread.awk
Adrian Schlatter 315d3b96fb Release 0.3
Enhancements
===========

- Unified Inch Screw Threads

Fixes
===========

- PCO-1881 internal (minor diameter was too small)
- Dpitch problem with G-ext threads

Improvements
===========

- developer docs
- build system
- unit tests
- user does not need to rotate internal threads by 180 deg anymore
to fit external thread

!! Incompatibel changes !!
====================

We take the liberty to do this while the major version is still 0:

- internal thread is rotated by 180 deg (see improvements). nut() and bolt() are not affected by this
2019-11-13 21:17:52 +01:00

72 lines
1.8 KiB
Awk

function tan(x) {
return(sin(x) / cos(x))
}
function min(x, y) {
if (x < y) return(x)
else return(y)
}
function calculateThreadlibSpecs() {
Designator = $3;
P = $4;
H = P / 2 / tan(phi / 2);
DPitchExt = ($8 + $9) / 2;
DSupportExt = ($10 + $11) / 2;
DValleyExt = $11;
DCrestExt = ($6 + $7) / 2;
ZValleyExt = (DPitchExt + H - DValleyExt) / 2 * tan(phi / 2);
ZCrestExt = (DPitchExt + H - DCrestExt) / 2 * tan(phi / 2);
DPitchInt = ($15 + $16) / 2;
DSupportInt = ($17 + $18) / 2;
DValleyInt = $18;
DCrestInt = ($13 + $14) / 2;
# for some reason, the data sometimes has dRMax > H. We have to fix this:
dRMax = min((DValleyInt - DPitchInt + H) / 2, 0.99 * H);
DValleyInt = DPitchInt - H + 2 * dRMax;
# now, continue as usual
ZValleyInt = dRMax * tan(phi / 2);
ZCrestInt = (DCrestInt - DPitchInt + H) / 2 * tan(phi / 2);
}
BEGIN {
FS = "\t";
pi = atan2(0, -1);
deg = pi / 180;
phi = 60 * deg;
}
/^[^#]/ {
calculateThreadlibSpecs();
# External thread:
printf Designator "-ext," # designator
printf P "," # pitch
printf "%.4f,", DValleyExt / 2 # Rrot
printf "%.4f,", DSupportExt # Dsupport
printf 0 "," # r0
printf "%.4f,", -ZValleyExt # z0
printf 0 "," # r1
printf "%.4f,", +ZValleyExt # z1
printf "%.4f,", (DCrestExt - DValleyExt) / 2 # r2
printf "%.4f,", +ZCrestExt # z2
printf "%.4f,", (DCrestExt - DValleyExt) / 2 # r3
printf "%.4f\n", -ZCrestExt; # z3
# Internal thread:
printf Designator "-int," # designator
printf P "," # pitch
printf "%.4f,", -DValleyInt / 2 # Rrot
printf "%.4f,", DSupportInt # Dsupport
printf 0 "," # r0
printf "%.4f,", +ZValleyInt # z0
printf 0 "," # r1
printf "%.4f,", -ZValleyInt # z1
printf "%.4f,", -(DCrestInt - DValleyInt) / 2 # r2
printf "%.4f,", -ZCrestInt # z2
printf "%.4f,", -(DCrestInt - DValleyInt) / 2 # r3
printf "%.4f\n", +ZCrestInt; # z3
}