
Single-Stage Planetary Layout
Executive Summary
Purpose: Turn a target ratio, a number of planets and a module into a planetary gear set that meshes, assembles and fits: tooth counts, profile shifts, centre distance, speeds, and the space left between the planets and around the sun bore and ring.
What it does: tooth_count_candidates lists every sun/planet/ring combination near the target ratio that satisfies the coaxial, assembly and neighbour conditions. PlanetarySet.build picks profile shifts so the sun is not undercut and both meshes share one centre distance, and shortens the ring tips where they would dig into the planet roots. module_limits turns the envelope diameter and the sun shaft into the smallest and largest module that fit.
Arrangement: ring gear fixed, sun is the input, carrier is the output (the usual single-stage reducer). Ratio \(i = n_s/n_c = 1 + z_r/z_s\).
How It Fits Into the Gear Design Workflow
Upstream: gears.involute (GearGeometry, mesh_check, centre distance and shift relations).
Downstream: gears.rating (loads and stresses of the two meshes), gears.components (planet pin, bearing and carrier at the centre distance and planet bore found here), gears.design (the search over modules and tooth counts).
Tooth Counts: Theory
With sun \(z_s\), planets \(z_p\), ring \(z_r\) and \(N\) equally spaced planets:
- Ratio (ring fixed): \(i = 1 + z_r/z_s\).
- Coaxial condition. Both meshes must have the same centre distance. With unshifted gears that needs \(z_r = z_s + 2z_p\). Profile shift lets the ring differ by one tooth, \(z_r = z_s + 2z_p + \delta\) with \(\delta = \pm 1\), which opens up more ratios; the shifts then absorb the half-module mismatch.
- Assembly condition. \(N\) planets can be put in at equal angles only if \((z_s + z_r)/N\) is a whole number.
- Neighbour condition. Adjacent planets must not touch: \(2a_w\sin(\pi/N) > d_{a,p} + c\), where \(c\) is the gap you need for oil and for the carrier posts that pass between the planets.
- Undercut. A hobbed sun below about 17 teeth needs a positive shift; this module adds it automatically, so \(z_s\) down to about 12 is allowed.
- Hunting teeth (preferred, not required): if \(z_s\) and \(z_p\) share no common factor, and neither do \(z_p\) and \(z_r\), every tooth meets every mating tooth and wear evens out.
The figure shows these quantities on the 18/27/72 set with three planets.
Candidate search. tooth_count_candidates loops over the sun tooth count \(z_s\) in the allowed range and, for each one, over ring counts \(z_r\) near \((i_{target} - 1)\,z_s\). A combination is kept when
\[e = \frac{(1 + z_r/z_s) - i_{target}}{i_{target}},\quad |e| \le \text{tol};\qquad \frac{z_s + z_r}{N} \in \mathbb{Z};\qquad z_p = \frac{z_r - z_s - \delta}{2} \in \mathbb{Z},\ z_p \ge z_{p,min},\]
and the neighbour condition holds with unshifted tip diameters \(d_{a,p} = (z_p + 2)\,m\) and the centre distance \(a = (z_s + z_p)\,m/2\), both divided by \(m\):
\[(z_s + z_p)\sin(\pi/N) \ge z_p + 2 + c^*,\]
with \(c^*\) the required gap in modules (neighbour_gap, default 1). PlanetarySet repeats the neighbour check with the final shifts. Candidates are sorted by \(|e|\) in steps of 0.5 %, then unshifted sets (\(\delta = 0\)) first, then hunting-tooth sets, then the smaller sun.
Speeds. The Willis equation relates the speeds of sun, ring and carrier:
\[\frac{n_s - n_c}{n_r - n_c} = -\frac{z_r}{z_s}.\]
With the ring fixed (\(n_r = 0\)) this gives
\[i = \frac{n_s}{n_c} = 1 + \frac{z_r}{z_s},\qquad n_{p/c} = -(n_s - n_c)\,\frac{z_s}{z_p},\qquad n_p = n_{p/c} + n_c,\]
where \(n_{p/c}\) is the planet speed on its pin (relative to the carrier, which sets the bearing speed) and \(n_p\) its absolute speed. Both meshes run at the tooth-mesh frequency
\[f_z = \frac{\lvert n_s - n_c\rvert\, z_s}{60}\ \text{[Hz]}.\]
The speed (Kutzbach) diagram shows where these come from: tangential speed grows linearly with radius on each member, and the planet has zero speed where it touches the fixed ring, so its centre (and the carrier pin) moves at half the speed of the sun’s pitch point.

tooth_count_candidates
def tooth_count_candidates(
ratio:float, n_planets:int, tol:float=0.02, zs_range:tuple[int, int]=(12, 40), zp_min:int=12,
deltas:tuple[int, ...]=(0, -1, 1), neighbour_gap:float=1.0
)->list[ToothCounts]:All tooth counts within tol of the target ratio that assemble with n_planets equally spaced planets and leave a gap of at least neighbour_gap modules between neighbouring planet tips.
Sorted by ratio error in 0.5 % steps, then unshifted sets (δ = 0) first, hunting teeth first, smaller sun first. The neighbour check uses unshifted tip diameters; PlanetarySet repeats it with the final shifts.
ToothCounts
def ToothCounts(
zs:int, zp:int, zr:int, n_planets:int, ratio:float, error:float, hunting:bool, delta:int
)->None:One sun/planet/ring combination.
zs, zp, zr : int Tooth counts n_planets : int Number of planets N ratio : float i = 1 + zr/zs error : float Relative error to the target ratio hunting : bool zs,zp and zp,zr have no common factor delta : int zr − (zs + 2 zp): 0 for an unshifted set, ±1 needs profile shift
Example
A ratio of 5 with three planets. The list does not depend on the module, so it cannot tell which sun size is best; the design search in gears.design rates each candidate at each module. Here we take the first one with at least 17 sun teeth.
cands = tooth_count_candidates(5.0, 3)
print(len(cands), "candidates")
for c in cands[:10]:
print(f"zs={c.zs:2d} zp={c.zp:2d} zr={c.zr:3d} i={c.ratio:.4f} ({c.error*100:+.2f} %) "
f"hunting={c.hunting} δ={c.delta:+d}")
best = next(c for c in cands if c.zs >= 17)
print('chosen:', best)
assert (best.zs + best.zr) % 3 == 0 and best.zr == best.zs + 2 * best.zp + best.delta77 candidates
zs=12 zp=18 zr= 48 i=5.0000 (+0.00 %) hunting=False δ=+0
zs=18 zp=27 zr= 72 i=5.0000 (+0.00 %) hunting=False δ=+0
zs=24 zp=36 zr= 96 i=5.0000 (+0.00 %) hunting=False δ=+0
zs=30 zp=45 zr=120 i=5.0000 (+0.00 %) hunting=False δ=+0
zs=36 zp=54 zr=144 i=5.0000 (+0.00 %) hunting=False δ=+0
zs=15 zp=23 zr= 60 i=5.0000 (+0.00 %) hunting=True δ=-1
zs=21 zp=31 zr= 84 i=5.0000 (+0.00 %) hunting=True δ=+1
zs=27 zp=41 zr=108 i=5.0000 (+0.00 %) hunting=True δ=-1
zs=33 zp=49 zr=132 i=5.0000 (+0.00 %) hunting=True δ=+1
zs=39 zp=59 zr=156 i=5.0000 (+0.00 %) hunting=True δ=-1
chosen: ToothCounts(zs=18, zp=27, zr=72, n_planets=3, ratio=5.0, error=0.0, hunting=False, delta=0)
Profile Shifts: Theory
The sun is the smallest gear and carries the highest bending stress, so it gets a positive shift and the planet the opposite (a zero-sum pair keeps \(a_w = a\)):
\[x_s = \max\big(0.02\,(30 - z_s),\ x_{s,min} + 0.05\big)\ \text{clipped to }[0, 0.6],\qquad x_p = \max(-x_s,\ x_{p,min} + 0.05),\]
where \(x_{min} = h_{fP}^* - \rho_{fP}^*(1-\sin\alpha) - \tfrac{z}{2}\sin^2\alpha\) is the undercut limit. The first term is a common rule for small pinions (it moves the start of active profile away from the weak root of a small gear) and is a starting point, not an optimum; you can always pass your own shifts.
The sun–planet mesh then fixes the centre distance \(a_w\). The ring shift follows from requiring the planet–ring mesh to have the same \(a_w\) (shift_sum_for_centre_distance). When the sun–planet shift sum is positive, both tips are shortened by the ISO 21771 amount \(k^* = (x_s + x_p) - (a_w - a)/m\) to keep the standard tip clearance. Finally, if the ring tip would dig into the planet fillet, or the ring tip circle falls inside its base circle, the ring tip is shortened in steps of \(0.05\,m\) until the mesh checks pass:
\[k_r^* = 0,\ 0.05,\ 0.10,\ \dots,\ 1.0:\ \text{the first value with } d_{a,r} \ge d_{b,r} + 0.02\,m \text{ that passes the planet–ring mesh check}.\]
The figure shows the sun shift chosen for each sun tooth count, against the undercut limit.

default_shifts
def default_shifts(
zs:int, zp:int
)->tuple[float, float]:Starting profile shifts (x_sun, x_planet) for a planetary set; see the theory above.
undercut_shift
def undercut_shift(
z:int, hf:float=1.25, rho_f:float=0.38, alpha:float=0.3490658503988659
)->float:Smallest profile shift that avoids undercut of a rack-generated external gear with z teeth.
for zs in (12, 15, 17, 21, 30):
print(zs, [round(v, 3) for v in default_shifts(zs, 25)], "undercut limit", round(undercut_shift(zs), 3))
assert default_shifts(12, 25)[0] > undercut_shift(12)12 [0.36, -0.36] undercut limit 0.298
15 [0.3, -0.3] undercut limit 0.123
17 [0.26, -0.26] undercut limit 0.006
21 [0.18, -0.18] undercut limit -0.228
30 [0.0, -0.0] undercut limit -0.755
PlanetarySet: Theory
PlanetarySet.build(zs, zp, zr, m, N, b) puts the steps above together:
- Profile shifts \(x_s, x_p\) from
default_shifts(or your own). - Sun–planet centre distance \(a_w\) from \(\operatorname{inv}\alpha_w = \operatorname{inv}\alpha + 2\tan\alpha\,(x_s + x_p)/(z_s + z_p)\) (
gears.involute). - Tip shortening \(k^* = (x_s + x_p) - (a_w - a)/m\) on sun and planet if it is positive.
- Ring shift \(x_r\) so that the planet–ring mesh has the same \(a_w\): \(x_r = \Sigma x(z_p, -z_r, a_w) - x_p\), with \(\Sigma x\) from
shift_sum_for_centre_distance. - Ring tip reduction \(k_r^*\) by the step search above.
The set then reports its ratio \(i = 1 + z_r/z_s\), the speeds and mesh frequency above, and the neighbour gap between planet tip circles,
\[g_N = 2a_w\sin(\pi/N) - d_{a,p}.\]
PlanetarySet.ok is true only when all of these hold:
- \((z_s + z_r)/N\) is a whole number (assembly);
- both meshes pass
MeshCheck.ok(\(\varepsilon_\alpha \ge 1.2\), no interference, positive tip clearance); - \(g_N > 0\);
- neither the sun nor the planet is undercut;
- tip thickness \(s_a > 0.25\,m\) on the sun and the planet (thinner tips through-harden and chip).
PlanetarySet
def PlanetarySet(
sun:GearGeometry, planet:GearGeometry, ring:GearGeometry, n_planets:int, sun_planet:MeshCheck,
planet_ring:MeshCheck
)->None:A ring-fixed single-stage planetary gear set (sun in, carrier out).
Attributes
sun, planet, ring : GearGeometry n_planets : int sun_planet : MeshCheck Checks of the sun–planet mesh planet_ring : MeshCheck Checks of the planet–ring mesh
Example
The best ratio-5 candidate above, module 1.5, three planets, 20 mm face width:
ps = PlanetarySet.build(best.zs, best.zp, best.zr, m=1.5, n_planets=3, b=20)
print(ps.summary())
print({k: round(v, 1) for k, v in ps.speeds(3000).items()}, f"mesh frequency {ps.mesh_frequency(3000):.0f} Hz")
assert ps.ok and math.isclose(ps.planet_ring.a_w, ps.a_w, rel_tol=1e-12)i = 5.0000, N = 3, m = 1.5 mm, a_w = 33.7500 mm
gear z x k* d da df b
sun 18 +0.240 0.000 27.000 30.720 23.970 20.0
planet 27 -0.240 0.000 40.500 42.780 36.030 20.0
ring 72 +0.240 0.200 108.000 104.880 111.030 20.0
ε_α sun–planet 1.555, planet–ring 1.825, α_w 20.000° / 20.000°, planet tip gap 15.68 mm
checks: all pass
{'sun': 3000, 'carrier': 600.0, 'planet_rel': -1600.0, 'planet_abs': -1000.0} mesh frequency 720 Hz
A set with δ = ±1 (ring one tooth off the unshifted coaxial count) still builds on one centre distance, through the shifts:
odd = next(c for c in tooth_count_candidates(5.6, 3, tol=0.03) if c.delta != 0)
ps_odd = PlanetarySet.build(odd.zs, odd.zp, odd.zr, m=1.0, n_planets=3, b=12)
print(odd)
print(ps_odd.summary())
assert math.isclose(ps_odd.planet_ring.a_w, ps_odd.a_w, rel_tol=1e-12)ToothCounts(zs=22, zp=39, zr=101, n_planets=3, ratio=5.590909090909091, error=-0.0016233766233765745, hunting=True, delta=1)
i = 5.5909, N = 3, m = 1.0 mm, a_w = 30.5000 mm
gear z x k* d da df b
sun 22 +0.160 0.000 22.000 24.320 19.820 12.0
planet 39 -0.160 0.000 39.000 40.680 36.180 12.0
ring 101 +0.628 0.200 101.000 98.145 102.245 12.0
ε_α sun–planet 1.627, planet–ring 1.819, α_w 20.000° / 17.235°, planet tip gap 12.15 mm
checks: all pass
Module Limits From the Envelope and the Sun Shaft: Theory
The module is squeezed between two radial stacks: from the shaft out to the sun root, and from the ring root out to the envelope.

Largest module (envelope). If the ring gear is also the outer wall, its outside diameter is the root diameter plus two rim thicknesses \(s_R\):
\[D_{ring} \approx m\,(z_r + 2h_{fP}^*) + 2 s_R \le D_{env} - 2t_{housing}.\]
ISO 6336-3 applies no rim penalty to an internal gear when \(s_R \ge 3.5\,m\), so with \(s_R = c_R\,m\)
\[m_{max} = \frac{D_{env} - 2t_{housing}}{z_r + 2h_{fP}^* + 2c_R}.\]
Smallest module (sun bore). The sun sits on the input shaft of diameter \(d_{sh}\) with a key whose hub groove is \(t_2\) deep (DIN 6885-1). The rim between the sun root and the bottom of the key groove must be at least \(c_s\) tooth depths \(h_t = (h_{aP}^* + h_{fP}^*)m\):
\[\frac{d_{f,s}}{2} - \frac{d_{sh}}{2} - t_2 \ge c_s h_t,\qquad m_{min} = \frac{d_{sh}/2 + t_2}{z_s/2 - h_{fP}^* - c_s (h_{aP}^* + h_{fP}^*)}.\]
\(c_s = 1.2\) gives no rim penalty for an external gear; values down to 0.5 are allowed by ISO 6336-3 with a rim factor \(Y_B > 1\) on the bending stress (gears.rating applies it). A positive sun shift raises \(d_{f,s}\) and helps here; the formula ignores it and so errs on the safe side. When no module satisfies both limits, the sun has to be cut on the shaft itself (pinion shaft) or the shaft–hub joint changed (spline instead of key).
module_limits
def module_limits(
envelope_d:float, shaft_d:float, zs:int, zr:int, t2:float=0.0, housing_wall:float=0.0, ring_rim:float=3.5,
sun_rim:float=1.2, ha:float=1.0, hf:float=1.25
)->tuple[float, float]:(m_min, m_max) [mm] from the sun bore and the envelope, see the theory above.
envelope_d : outside diameter available for the ring (or ring + housing) [mm] shaft_d : shaft diameter in the sun bore [mm] t2 : hub key-groove depth [mm] (0 for a plain or splined bore) housing_wall : housing wall thickness outside the ring [mm] (0 if the ring is the housing) ring_rim : ring rim thickness under the tooth roots, in modules sun_rim : sun rim thickness above the key groove, in tooth depths
Example
A 120 mm envelope and a 14 mm keyed input shaft (DIN 6885-1 key 5 × 5, hub groove \(t_2 = 2.3\) mm). For a ratio of 5 the ring has about four times the sun’s teeth, so a small sun leaves no room for the key and a large one pushes the ring past the envelope. Only sets with enough sun teeth leave a window, and the window has to contain a standard module:
from emachines.gears.involute import standard_modulesfeasible, shown = [], 0
for c in cands:
m_lo, m_hi = module_limits(envelope_d=120, shaft_d=14, zs=c.zs, zr=c.zr, t2=2.3)
ms = standard_modules(m_lo, m_hi, series_ii=True)
if shown < 12 and (c.zs in (15, 18, 21, 24) or ms):
shown += 1
print(f"zs={c.zs:2d} zp={c.zp:2d} zr={c.zr:3d}: m from {m_lo:.3f} to {m_hi:.3f} mm standard: {ms}")
if ms:
feasible.append((c, ms))
print(f'{len(feasible)} of {len(cands)} candidates fit')
assert feasible and all(module_limits(120, 14, c.zs, c.zr, 2.3)[0] <= ms[0] for c, ms in feasible)zs=18 zp=27 zr= 72: m from 1.842 to 1.472 mm standard: []
zs=24 zp=36 zr= 96: m from 1.155 to 1.137 mm standard: []
zs=30 zp=45 zr=120: m from 0.842 to 0.927 mm standard: [0.9]
zs=36 zp=54 zr=144: m from 0.662 to 0.782 mm standard: [0.7]
zs=15 zp=23 zr= 60: m from 2.620 to 1.727 mm standard: []
zs=21 zp=31 zr= 84: m from 1.420 to 1.283 mm standard: []
zs=27 zp=41 zr=108: m from 0.974 to 1.021 mm standard: [1.0]
zs=33 zp=49 zr=132: m from 0.741 to 0.848 mm standard: [0.8]
zs=39 zp=59 zr=156: m from 0.598 to 0.725 mm standard: [0.6, 0.7]
zs=15 zp=22 zr= 60: m from 2.620 to 1.727 mm standard: []
zs=21 zp=32 zr= 84: m from 1.420 to 1.283 mm standard: []
zs=27 zp=40 zr=108: m from 0.974 to 1.021 mm standard: [1.0]
45 of 77 candidates fit
Tests
References
- Müller, H.W. (1982). Epicyclic Drive Trains. Wayne State University Press — Willis equation, assembly and neighbour conditions.
- ISO 21771:2007 — tip shortening for gear pairs with a positive shift sum.
- ISO 6336-3:2019, rim thickness factor \(Y_B\) — limits on the rim thickness of the sun and ring.
- DIN 3992:1964 — choice of profile shift coefficients for external gears.