@rulecad/gears 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/gears.d.mts +1 -1
- package/gears.mjs +1 -1
- package/package.json +1 -1
- package/planetary.d.mts +51 -0
- package/planetary.mjs +66 -0
package/README.md
CHANGED
|
@@ -103,6 +103,17 @@ planet's place round the carrier and the turn that puts it in phase with the sun
|
|
|
103
103
|
gives the ratio exactly, the nearest is returned and `planetary.ratio` says how far off it is (a fail past 5%).
|
|
104
104
|
`planetaryRatio({ sun, ring }, { held, input, output })` is the ratio of any teeth, any way round.
|
|
105
105
|
|
|
106
|
+
## Compound planetaries
|
|
107
|
+
|
|
108
|
+
`compoundPlanetary({ module, ratio, planets, size })` finds teeth for two rings a few teeth apart: one held, the other
|
|
109
|
+
the output, each meshing its own step of a stepped planet, so a ratio of 30 to 200 fits in one stage. The ratio is
|
|
110
|
+
Willis's twice over, `(S + R1) / S / (1 − R1 P2 / (P1 R2))` (`compoundRatio`). The planets' steps differ by what the
|
|
111
|
+
rings do, so one centre distance serves both, and every tooth count is a multiple of the planets, so identical planets
|
|
112
|
+
go in evenly and in phase. (Profile shift can't do this job alone: moving one ring by three teeth on one set of planets
|
|
113
|
+
needs a shift near two modules at the sizes that print, far past what a tooth takes.) It finds the efficiency too,
|
|
114
|
+
`compoundEfficiency`, an estimate: the rings pass power relative to the carrier many times the output's, so a high ratio is
|
|
115
|
+
well under 50%, and can't be driven backwards.
|
|
116
|
+
|
|
106
117
|
## Worms and bevel gears
|
|
107
118
|
|
|
108
119
|
A **worm** is a screw whose thread, cut along its axis, is the basic rack's tooth: `worm({ module, starts, diameter,
|
package/gears.d.mts
CHANGED
|
@@ -419,5 +419,5 @@ export type GearModel = {
|
|
|
419
419
|
};
|
|
420
420
|
};
|
|
421
421
|
import jscad from '@jscad/modeling';
|
|
422
|
-
export { planetary, planetaryRatio } from "./planetary.mjs";
|
|
422
|
+
export { planetary, planetaryRatio, compoundPlanetary, compoundRatio, compoundEfficiency } from "./planetary.mjs";
|
|
423
423
|
export { wormModel, worm, wormWheel, wormMesh } from "./worm.mjs";
|
package/gears.mjs
CHANGED
|
@@ -573,7 +573,7 @@ export function stageEfficiency(kind, o = {}) {
|
|
|
573
573
|
throw new Error(`stageEfficiency: no kind of stage ${shown(kind)} (spur, helical, herringbone, rack, internal, bevel, planetary or worm)`);
|
|
574
574
|
}
|
|
575
575
|
|
|
576
|
-
export { planetary, planetaryRatio } from './planetary.mjs';
|
|
576
|
+
export { planetary, planetaryRatio, compoundPlanetary, compoundRatio, compoundEfficiency } from './planetary.mjs';
|
|
577
577
|
// The mesh measured from the drawn teeth: backlash, transmission error, interference
|
|
578
578
|
export { contact } from './contact.mjs';
|
|
579
579
|
// A tooth's root stress by finite elements
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulecad/gears",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Gears for printed parts: involute spur gears, racks and ring gears drawn from their rules, with their numbers, how a pair meshes (centre distance, ratio, contact ratio, phase) and how they print.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
package/planetary.d.mts
CHANGED
|
@@ -34,3 +34,54 @@ export function planetary(spec: {
|
|
|
34
34
|
others: object[];
|
|
35
35
|
findings: object[];
|
|
36
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* The turns of the sun for one of the output ring, in a compound planetary with one ring held: its planets stepped,
|
|
39
|
+
* P1 teeth on the held ring and the sun, P2 on the ring that turns. The ring turns the sun's way when the result is positive.
|
|
40
|
+
* @param {{ sun: number, planet: number, planet2: number, ring: number, ring2: number }} t
|
|
41
|
+
*/
|
|
42
|
+
export function compoundRatio({ sun: S, planet: P1, planet2: P2, ring: R1, ring2: R2 }: {
|
|
43
|
+
sun: number;
|
|
44
|
+
planet: number;
|
|
45
|
+
planet2: number;
|
|
46
|
+
ring: number;
|
|
47
|
+
ring2: number;
|
|
48
|
+
}): number;
|
|
49
|
+
/**
|
|
50
|
+
* The share of the power a compound planetary passes on (printed teeth): the sun's mesh, and the rings', where the
|
|
51
|
+
* carrier-relative power is the output's times rho / |1 - rho|, rho being the rings' ratio through the planets: all of
|
|
52
|
+
* it rubbing, for a small movement out, which is why a high ratio is so much less efficient than its gears look.
|
|
53
|
+
* @param {{ sun: number, planet: number, planet2: number, ring: number, ring2: number }} t
|
|
54
|
+
* @param {number} [each] the share per mesh (default 0.95, an estimate)
|
|
55
|
+
*/
|
|
56
|
+
export function compoundEfficiency({ planet: P1, planet2: P2, ring: R1, ring2: R2 }: {
|
|
57
|
+
sun: number;
|
|
58
|
+
planet: number;
|
|
59
|
+
planet2: number;
|
|
60
|
+
ring: number;
|
|
61
|
+
ring2: number;
|
|
62
|
+
}, each?: number): number;
|
|
63
|
+
/**
|
|
64
|
+
* Teeth for a compound (split-ring) planetary: the held ring and the sun mesh the planets' P1 teeth, the output ring
|
|
65
|
+
* their P2. Two rings a few teeth apart give ratios of 30 to 200 in one stage, input and output on one axis, which is
|
|
66
|
+
* what printed robot joints use. Stepped planets (P2 = P1 + the rings' difference) keep one centre distance with no
|
|
67
|
+
* profile shift: a single planet on two rings can't, at sizes that print, without a shift far past what a tooth takes.
|
|
68
|
+
* Every tooth count is a multiple of the planets, so identical planets go in evenly and in phase on both rings.
|
|
69
|
+
* @param {{ module: number, ratio: number, planets?: number, size?: number, least?: number, most?: number, step?: number, pressureAngle?: number, backlash?: number }} spec
|
|
70
|
+
* ratio: turns of the sun for one of the output ring, in size (a negative one turns the other way); step: the rings' difference, in planets (default tries 1 and 2)
|
|
71
|
+
* @returns {{ best: object, others: object[], findings: object[] }}
|
|
72
|
+
*/
|
|
73
|
+
export function compoundPlanetary(spec: {
|
|
74
|
+
module: number;
|
|
75
|
+
ratio: number;
|
|
76
|
+
planets?: number;
|
|
77
|
+
size?: number;
|
|
78
|
+
least?: number;
|
|
79
|
+
most?: number;
|
|
80
|
+
step?: number;
|
|
81
|
+
pressureAngle?: number;
|
|
82
|
+
backlash?: number;
|
|
83
|
+
}): {
|
|
84
|
+
best: object;
|
|
85
|
+
others: object[];
|
|
86
|
+
findings: object[];
|
|
87
|
+
};
|
package/planetary.mjs
CHANGED
|
@@ -75,3 +75,69 @@ function layout({ sun: S, planet: P, ring: R, ratio }, { n, m, common, held, inp
|
|
|
75
75
|
return { sun: { teeth: S, model: sun }, planet: { teeth: P, model: planet }, ring: { teeth: R, model: ring, angle: ringAngle },
|
|
76
76
|
planets, centre: a, ratio, held, input, output, rim: ring.rim, module: m, sunMesh, ringMesh };
|
|
77
77
|
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The turns of the sun for one of the output ring, in a compound planetary with one ring held: its planets stepped,
|
|
81
|
+
* P1 teeth on the held ring and the sun, P2 on the ring that turns. The ring turns the sun's way when the result is positive.
|
|
82
|
+
* @param {{ sun: number, planet: number, planet2: number, ring: number, ring2: number }} t
|
|
83
|
+
*/
|
|
84
|
+
export function compoundRatio({ sun: S, planet: P1, planet2: P2, ring: R1, ring2: R2 }) {
|
|
85
|
+
return ((S + R1) / S) / (1 - (R1 * P2) / (P1 * R2));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The share of the power a compound planetary passes on (printed teeth): the sun's mesh, and the rings', where the
|
|
90
|
+
* carrier-relative power is the output's times rho / |1 - rho|, rho being the rings' ratio through the planets: all of
|
|
91
|
+
* it rubbing, for a small movement out, which is why a high ratio is so much less efficient than its gears look.
|
|
92
|
+
* @param {{ sun: number, planet: number, planet2: number, ring: number, ring2: number }} t
|
|
93
|
+
* @param {number} [each] the share per mesh (default 0.95, an estimate)
|
|
94
|
+
*/
|
|
95
|
+
export function compoundEfficiency({ planet: P1, planet2: P2, ring: R1, ring2: R2 }, each = 0.95) {
|
|
96
|
+
const rho = (R1 * P2) / (P1 * R2), lost = 1 - each ** 2;
|
|
97
|
+
return each / (1 + (lost * rho) / Math.abs(1 - rho));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Teeth for a compound (split-ring) planetary: the held ring and the sun mesh the planets' P1 teeth, the output ring
|
|
102
|
+
* their P2. Two rings a few teeth apart give ratios of 30 to 200 in one stage, input and output on one axis, which is
|
|
103
|
+
* what printed robot joints use. Stepped planets (P2 = P1 + the rings' difference) keep one centre distance with no
|
|
104
|
+
* profile shift: a single planet on two rings can't, at sizes that print, without a shift far past what a tooth takes.
|
|
105
|
+
* Every tooth count is a multiple of the planets, so identical planets go in evenly and in phase on both rings.
|
|
106
|
+
* @param {{ module: number, ratio: number, planets?: number, size?: number, least?: number, most?: number, step?: number, pressureAngle?: number, backlash?: number }} spec
|
|
107
|
+
* ratio: turns of the sun for one of the output ring, in size (a negative one turns the other way); step: the rings' difference, in planets (default tries 1 and 2)
|
|
108
|
+
* @returns {{ best: object, others: object[], findings: object[] }}
|
|
109
|
+
*/
|
|
110
|
+
export function compoundPlanetary(spec) {
|
|
111
|
+
const what = 'compoundPlanetary';
|
|
112
|
+
if (!spec || typeof spec !== 'object') throw new Error(`${what}: give it { module, ratio, planets, size }`);
|
|
113
|
+
const { module: m, ratio } = spec, n = spec.planets ?? 3;
|
|
114
|
+
if (!(typeof m === 'number' && m > 0)) throw new Error(`${what}: module is a size above 0 (got ${JSON.stringify(m)})`);
|
|
115
|
+
if (!(typeof ratio === 'number' && Number.isFinite(ratio) && Math.abs(ratio) > 1)) throw new Error(`${what}: ratio is turns of the sun for one of the output, more than 1 either way (got ${JSON.stringify(ratio)})`);
|
|
116
|
+
if (!(Number.isInteger(n) && n >= 2 && n <= 6)) throw new Error(`${what}: planets is a whole number from 2 to 6 (got ${JSON.stringify(n)})`);
|
|
117
|
+
const least = spec.least ?? 17, most = spec.most ?? 90, pa = spec.pressureAngle ?? 20, steps = spec.step != null ? [spec.step] : [1, -1, 2, -2];
|
|
118
|
+
const common = { module: m, pressureAngle: pa, ...(spec.backlash != null ? { backlash: spec.backlash } : {}) };
|
|
119
|
+
const multiple = (x, k) => Math.ceil(x / k) * k, sets = [];
|
|
120
|
+
for (let S = multiple(least, n); S <= most; S += n) for (let P1 = multiple(least, n); P1 <= most; P1 += n) {
|
|
121
|
+
const R1 = S + 2 * P1;
|
|
122
|
+
if (R1 - P1 < 12) continue;
|
|
123
|
+
if (2 * ((m * (S + P1)) / 2) * Math.sin(Math.PI / n) < m * (P1 + 2) + m) continue; // the planets' tips a module apart
|
|
124
|
+
for (const k of steps) {
|
|
125
|
+
const j = k * n, P2 = P1 + j, R2 = R1 + j;
|
|
126
|
+
if (P2 < least) continue;
|
|
127
|
+
const set = { sun: S, planet: P1, planet2: P2, ring: R1, ring2: R2 }, i = compoundRatio(set), rim = m * (Math.max(R1, R2) + 2.5) + 6 * m;
|
|
128
|
+
if (spec.size != null && rim > spec.size) continue;
|
|
129
|
+
sets.push({ ...set, ratio: i, efficiency: compoundEfficiency(set), off: Math.abs(i - ratio) / Math.abs(ratio), rim });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (!sets.length) throw new Error(`${what}: no teeth put together${spec.size != null ? ` within a rim of ${spec.size} mm` : ''} with ${n} planets of ${least} teeth or more: a larger size, or a smaller module`);
|
|
133
|
+
sets.sort((x, y) => x.off - y.off || x.rim - y.rim);
|
|
134
|
+
const b = sets[0], sun = gearModel({ ...common, teeth: b.sun }), planet = gearModel({ ...common, teeth: b.planet }), planet2 = gearModel({ ...common, teeth: b.planet2 }), ring = internalModel({ ...common, teeth: b.ring }), ring2 = internalModel({ ...common, teeth: b.ring2 });
|
|
135
|
+
const sunMesh = mesh(sun, planet), ringMesh = mesh(planet, ring), ring2Mesh = mesh(planet2, ring2), a = sunMesh.centre, out = [], f = (level, text, code, values) => out.push({ level, text, code, ...(values ? { values } : {}) });
|
|
136
|
+
const planets = Array.from({ length: n }, (_, k) => { const at = (360 * k) / n; return { at: [a * Math.cos(at * DEG), a * Math.sin(at * DEG)], angle: phase(sun, planet, at), place: at }; });
|
|
137
|
+
const ringAngle = (b.planet / b.ring) * planets[0].angle + phase(planet, ring, 180), ring2Angle = (b.planet2 / b.ring2) * planets[0].angle + phase(planet2, ring2, 180);
|
|
138
|
+
f(b.off < 0.05 ? 'pass' : b.off < 0.2 ? 'warn' : 'fail', `${fmt(b.ratio, 2)} : 1 (sun to the output ring, the other ring held), ${b.off < 0.01 ? 'as asked' : `${fmt(b.off * 100, 1)}% from the ${fmt(ratio)} asked`}: sun ${b.sun}, stepped planets ${b.planet}/${b.planet2} × ${n}, rings ${b.ring} and ${b.ring2}`, 'compound.ratio', { ratio: b.ratio, asked: ratio });
|
|
139
|
+
f('info', `about ${fmt(b.efficiency * 100, 0)}% efficient (an estimate): ${b.efficiency <= 0.5 ? 'under 50%, so it can\'t be driven backwards' : 'it can be driven backwards'}`, 'compound.efficiency', { efficiency: b.efficiency });
|
|
140
|
+
if (Math.abs(ring2Mesh.centre - a) > 1e-9) f('fail', `the output ring's centre distance is ${fmt(ring2Mesh.centre)} mm and the planets' ${fmt(a)} mm: the rings' difference must equal the planets'`, 'compound.centre');
|
|
141
|
+
for (const [pair, ms] of [['sun and planet', sunMesh], ['planet and held ring', ringMesh], ['planet and output ring', ring2Mesh]]) for (const x of ms.findings) out.push({ ...x, text: `${pair}: ${x.text}` });
|
|
142
|
+
return { best: { sun: { teeth: b.sun, model: sun }, planet: { teeth: b.planet, model: planet }, planet2: { teeth: b.planet2, model: planet2 }, ring: { teeth: b.ring, model: ring, angle: ringAngle }, ring2: { teeth: b.ring2, model: ring2, angle: ring2Angle }, planets, centre: a, ratio: b.ratio, efficiency: b.efficiency, rim: Math.max(ring.rim, ring2.rim), module: m }, others: sets.slice(1, 6).map(({ off, ...x }) => x), findings: out };
|
|
143
|
+
}
|