Calculating Change Gears

What are Change Gears?

I have an 8x14 mini lathe I purchased from www.lathemaster.com (CQ6120x320). Like most metal working lathes it has a leadscrew that can move the tool saddle along as it turns. The spindle of the lathe is geared to the leadscrew so that a single revolution of the spindle causes the leadscrew to revolve by a fixed amount, hence, the cutting tool moves a fixed amount for each spindle rotation.

By changing the gearing between the spindle and the leadscrew you can change the amount the saddle moves for every revolution of the spindle. In this way it is possible to cut threads with various pitches. ie- the distance between the threads, typically expressed as a distance, or as threads per inch.

Setting Up for Thread Cutting

The idea is simple: When you want to cut a thread with a certain pitch you look at a handy table that is printed on the lathe and it will tell you the configuration and size of the gears that should be used to achieve the desired pitch. There's only one problem: not all the thread pitches you may want to cut are printed on the table. When this happens you are left scratching your head. Determining a gear configuration for a desired pitch is no simple task. Certainly the math is straight forward, but since there are 16 gears and 4 basic configurations each involving multiple gears, the problem search space is quite large.

Defining The Problem Search Space

There are 16 change gears of various sizes- They have 30, 35, 40, 45, 48, 50, 60, 66, 68, 70, 70, 72, 75, 80, 90 and 100 teeth. Since these gears must mesh with one another the tooth pitch of all gears is the same.

There are 4 gear configurations (from spindle to leadscrew): Where:

1st order analysis might suggest there are:

( 16 x 15 x 14 x 13 x 12 ) +
( 16 x 15 x 14 x 13 ) +
( 16 x 15 x 14 x 13 ) +
( 16 x 15 x 14 )
= 614880 gear configurations

While this is correct, most of these gear configurations violate the geometric constraints the lathe places on the gears. ie- They interfere with each other, or other parts of the lathe. In fact only around 77,000 gear configurations can be physically installed on the lathe.

Finding Solutions

What to do? Get a computer to solve the problem! The process is straight forward. Write a computer program that:
  1. Generates all possible permutations of gear configurations.
  2. Uses geometric constraints to eliminate invalid configurations.
  3. Calculates the pitch for all valid configurations.
  4. Reports the gear configuration closest to the desired pitch.

While this is clearly the "hit it with a big hammer" approach to solving the problem, it turns out to be very tractable on an average PC (circa 2003) when the program is expressed in C code. It takes less than 100ms to go through every gear combination and return the closest match to the desired pitch. Good enough!

The code for this program can be found here. I haven't made this code particularly presentable or fast. Unless you have the same lathe as me, you would need to understand the code and then change it to match the gear configurations available on your lathe.

Solutions

By stepping through the possible pitches we can build a complete table of gear configurations.

Here are the inch solutions.
Here are the metric solutions.

Notes

  1. When I took this same code and expressed it in PHP (an interpreted server side scripting language) the program ran into a wall. CPU utilization went up to 100% and stayed there while the script cranked through the 614880 gear combinations. If a script runs for more than a fixed period of time (30s default), the PHP scripting engine pulls the plug on it- interpreting excessive computation time as an error. So much for dumb algorithms that have an n-P-k search space.
  2. The algorithm first generates combinations of a certain set size and then permutates the members of that set. Since the gears are mostly unique, a plain old permutation is suitable. If more gears were duplicates, permutations of a multiset would be the way to go. Knuth has quite a bit of material on algorithms for this.
  3. I haven't tried all of the gear configurations, and some of them may violate physical constraints I have not identified. It is a small matter to add any new constraints to the code thereby further reducing the set of possible gear configurations.