Brute-Force Gear Solvers
Why to Use a Brute-Force Gear Solver
When designing an orrery, or any clockwork, you will need to find a gear set whose ratio is as close to a target as possible. Very, very few astronomical rotations rates are simple ratios of another, so you’ll find yourself needing gears to go from 1 RPM to 1.5698 RPM much more often than from 1 RPM to 3 RPM. Finding what size gears and how to arrange them is not exactly trivial, but thankfully modern computers can make it a quick task. We’re going to be looking at leveraging this to best effect on this page, but if you want to read about the more traditional method of using a Stern-Brocot Tree you can find that here.
How to Set Up Single-Stage Solver
The simplest and least computationally expensive, although with the lowest accuracy and lowest range.
The first step is identifying your allowable gear range. There are a couple considerations, starting with the minimum gear size. Generally you don’t want to go under 10-12 teeth. You also don’t want to go too large, which is just a function of how much space your design have. We’ll use 100 teeth as a reasonable limit here. Lastly, consider if you can actually manufacture every tooth count in the range. For an automated process like 3D printing, laser cutting, or CNC machining this won’t be an issue but if you’re using dividing plates on a manual mill you likely won’t be able to make certain tooth counts.
Now that you have your allowable gear tooth counts you want to see what ratio every combination would give you. You’ll want to keep track of which pair of gears generated which ratio, or it will be difficult to backtrack from the decimal of the ratio. I use two matrices, gear1 and gear2 (later gear11Dim and gear21dim) for this purpose in the example.
Once you have your long list of possible gear ratios and lists of which two gears create them, you’ll need to find the closest to your target ratio. In the code on the right this is done by calculating the error that each ratio would have and selecting the minimum. One could also sort and search for the same result.
That’s the bulk of the work done, now just have your program spit out the results!
While I recommend making your own for coding practice, if this seems daunting or unclear you can use my excel-based gear finder. While this will let you work out single-stage gear ratios very fast, this approach becomes too slow for compound gear trains.
How to Set Up Two-Stage Solver
Now we’re getting into compound gear trains, and rather than looking at all pairs of gears (N^2) we’ll be looking at pairs of ratios (N^4). In reality, many of these are duplicates (such as 10:20 and 20:40) so one can increase the efficiency substantially . The basic steps are:
Generate allowable gear combos identically to single-stage
Generate resultant gear ratios for a single stage in the same manner
Look at all combinations of single stage gear ratios (these are of course multiplied together, rather than divided like a gear pair) to generate a list of compound ratios.
Find the closest match identically to a single stage
You’ll have to keep track of 4 gear counts, and will start to notice run times of a few seconds as our arrays sizes go from 8281 to 68,574,961 elements.
You are welcome to use my Two-Stage MATLAB Solver for this task
Setting up 3+stage Gear Trains
If you’ve tackled a two-stage, moving on to more complex compound trains becomes more a question of computational power and computer science. Without pentabytes of RAM you won’t be able to keep the entire solution realm in memory at once for even a modest list of gears, and will have to rely on several tools to run:
Limiting the input gear list. Reducing this will drastically reduce run-time
Evaluation of subsets of the solution space. Beyond a simple grid-search the solution array, you’ll find that the lowest error solution with occur along a diagonal determined by the target ratio. In other words, evaluating two combined high or low gear ratios is wasted effort. This will require that the considered gear ratios are sorted, however this is done with only N^2 elements and is thus relatively quick