Skip to content

Latest commit

 

History

History
145 lines (117 loc) · 7.97 KB

CreatingThreadSpecs.md

File metadata and controls

145 lines (117 loc) · 7.97 KB

Creating Thread Specs

In the following, we explain how a thread spec (i.e., an entry in THREAD_TABLE.scad) is created. First, we will explain the basics of threads and how they are specified in the norms. Then, we will elaborate on how to translate those into threadlib thread specs.

Thread Basics

As an example, we use British Standard Pipe parallel (BSPP) thread (see drawing below). The black curve shows the parting line between internal and external thread. In an ideal world, both threads are created according to the parting line. For BSP thread it is based on a fundamental triangle with a 55-degree angle rounded to a radius r.

BSPP thread drawing

 BSPP thread drawing. Source: Maryland Metrics.

Reality is a bit more complicated: If one of the threads deviates only a little in the wrong direction, the threads collide. Therefore, the pitch radius r_pitch (radius where distance between falling and rising edges is exactly P/2) of the external thread has to be reduced a little bit (and vice versa for the internal thread). Also, major- and minor radii are adjusted so that the real thread is guaranteed to remain on its own side of the theoretical parting line.

Of course, it is not ok to introduce arbitrarily large allowances: The norm (BS EN ISO 228-1: 2003 in this case) gives the necessary constraints. Quoting Maryland Metrics thread data charts for BSP thread (which used to be here):

Tolerances on pitch diametera Tolerance on minor diameter Tolerance on major diameter
Diameters Internal thread TD2 External thread Td2 Internal thread TD1 External thread Td
Desig-nation of thread Number of threads in 25.4 mm Pitch P Height of thread h major d = D pitch d2 = D2 minor d1 = D1 Lower deviation Upper deviation Lower deviation Class A Lower deviation Class B Upper deviation Lower deviation Upper deviation Lower deviation Upper deviation
1/16 28 0.907 0.581 7.723 7.142 6.561 0 0.107 -0.107 -0.214 0 0 0.282 -0.214 0
1/8 28 0.907 0.581 9.728 9.147 8.566 0 0.107 -0.107 -0.214 0 0 0.282 -0.214 0
1/4 19 1.337 0.856 13.157 12.301 11.445 0 0.125 -0.125 -0.25 0 0 0.445 -0.25 0

Deriving threadlib Specs

We want to approximate the thread profile by straight-line segments as shown in the sketch in red and blue (internal and external thread, respectively).

It is clear that we have to match the pitch exactly. Therefore, threadlib's P is equal to the pitch in the norm (for G1/16: 0.907 mm).

Then, we choose the pitch diameter to be in the center of the given tolerance range. For G1/16 this is (7.723 + 0.107/2) mm.

To explain the choice of r_major and r_minor for both external and internal threads simultaneously, we use the terms r_crest and r_valley. r_crest is the major/minor radius (external/internal) and r_valley is the minor/major radius (external/internal). The norm does not give limits for r_valley. But threadlib requires that the thread profile covers less than 1 pitch of thread. Therefore, we arbitrarily choose a small but finite width of "valley floor" that leaves ample clearance to the parting line. For r_crest, we to take into account

  1. the allowed deviations given in the norm
  2. the rounding

The former is simple: We aim for the center. The latter requires a little math: We want our piecewise linear profile to remain on one side of the (true) BSP profile. Therefore, our crest radius has to be equal to the radius where the straight rising edge of the BSP profile touches the circle of the rounding (see sketch at the top of this page).

Adding Specs to threadlib

To get the threads into threadlib, we do the following:

  • Tabulate specs as given in norm => design/newthreads.csv
  • Write design/newthreads.awk => translates design/newthreads.csv to tabular threadlib specs (see next step).
  • Add instructions to Makefile: cat design/newthreads.csv | awk -f design/newthreads.awk >> design/THREAD_TABLE.csv Now, make will automatically run the script.
  • design/autogenerate.awk will translate the resulting THREAD_TABLE.csv into the final THREAD_TABLE.scad (same as the .csv but with added quoting and bracketing). This script is already there, you should not need to modify it.

The format of THREAD_TABLE.csv is:

DESIGNATOR, P, Rrot, Dsup, dr_0, z0, dr_1, z_1, dr_2, z_2, dr_3, z_3

The meaning of these values is explained in Design of Threadlib.

Adding Tests

Furthermore, we should extend tests/test_table.awk to test our newly created threads. The very minimum is to add a test for the thread angles. Perform the tests by running make test in the top-level directory or make inside the tests subdirectory. If it prints "TESTS SUCCESSFUL" you are probably fine. Note: If you have a thread spec that is not tested at all, the tests will fail, too.

For more information on testing, see Unit Tests.