Files
threadlib/docs/CreatingThreadSpecs.md
Adrian Schlatter 26ad35c72a Add developer docs
- explain structure of THREAD_TABLE.scad and relation to thread module
- explain threads and how to derive proper specs for inclusion in threadlib
- explain use of autogenerate.awk
- explain tests (i.e., test_table.awk)

closes #5
2019-04-30 21:45:02 +02:00

7.6 KiB

Creating Thread Specs

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

Thread Basics

To do this, we use British Standard Pipe parallel (BSPP) thread as an example (see drawing below). The bold curve shows the parting line between internal and external thread. In an ideal world, both threads are created according to the parting line. The parting line of BSP thread 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:

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

To simplify the thread profile, we want to avoid the rounding and replace it by a trapezoidal edge as shown in here (red: internal, blue external thread):

threadlib profile compared to BSP parting line

It is clear that we have to match the pitch as accurately as possible. Therefore, threadlibs 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 threadprofile 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

a) the allowed deviations given in the norm b) the rounding (that we want to leave away)

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.

Adding Specs to threadlib

To get the threads into threadlib, we currently do the following (attention: will change in the near future to avoid Excel file):

  • Add worksheet with original thread specs to design/threads.xlsx
  • Extend table in worksheet THREAD_TABLE (calculate threadlib specs from your original specs)
  • Save THREAD_TABLE worksheet as THREAD_TABLE.csv
  • Do cat THREAD_TABLE.csv | awk -f design/autogenerate.awk > THREAD_TABLE.scad in a terminal

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 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.