@rulecad/motors 0.1.4 → 0.1.6
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/CHANGELOG.md +35 -0
- package/README.md +20 -5
- package/motors.d.mts +24 -9
- package/motors.mjs +62 -29
- package/package.json +3 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Changelog: @rulecad/motors
|
|
2
|
+
|
|
3
|
+
What changed in each release, for someone upgrading a workspace. A **printed size** is a dimension of a part you
|
|
4
|
+
print (a hole's diameter, a seat's depth, a part's outline). Each release says whether any printed size moved, and
|
|
5
|
+
why.
|
|
6
|
+
|
|
7
|
+
## 0.1.6: motors mount through fixings (Fixings 3)
|
|
8
|
+
|
|
9
|
+
### What reads fixings now
|
|
10
|
+
|
|
11
|
+
- `mountModel` and `mount()` take their screw from `@rulecad/fixings` (`fixingModel`), and cut fixings' clearance hole
|
|
12
|
+
and counterbore. The package's own private table of thread names is gone, so a motor's screw and a design's screw
|
|
13
|
+
are the same model, with the same sourced figures.
|
|
14
|
+
- `screw` is a fixing's name: a thread (`'M3'`), whose length is worked out from the plate, or a whole screw
|
|
15
|
+
(`'M3x8 cap'`), whose length is checked as it is.
|
|
16
|
+
- New dependency: `@rulecad/fixings`.
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- `mount.engagement`: the screw's length past the plate, held to the motor's `mount_hole_depth`, must be at least one
|
|
21
|
+
diameter (`engagement.steel` in `@rulecad/rules`). So an M3x6 through a 6 mm plate into a NEMA 17 fails: it ends at
|
|
22
|
+
the motor's face.
|
|
23
|
+
- A thread the motor's tapped holes do not take is refused by name, with the thread they do take.
|
|
24
|
+
|
|
25
|
+
### Printed sizes that moved
|
|
26
|
+
|
|
27
|
+
None. The solid `mount()` cuts is the same for every motor in the kit: a test holds each one's volume and bounds to
|
|
28
|
+
the figures recorded before the change.
|
|
29
|
+
|
|
30
|
+
### What a workspace should change
|
|
31
|
+
|
|
32
|
+
- A design that passed a screw name the motor's holes do not take (an M4 screw for an M3-tapped NEMA 17) is now
|
|
33
|
+
refused: name the motor's own thread.
|
|
34
|
+
- A plate too thin or too thick for a sold screw to reach the motor's thread now gets a `mount.engagement` failure,
|
|
35
|
+
where it used to pass. Change the plate's thickness or name a whole screw that reaches.
|
package/README.md
CHANGED
|
@@ -30,11 +30,11 @@ const gearBore = bore(m, { depth: 8 }); // and this from y
|
|
|
30
30
|
```text
|
|
31
31
|
stepper 5 31 0.59 spec
|
|
32
32
|
22.5 3.5 M3 9
|
|
33
|
-
5.
|
|
33
|
+
5.2 4.7 0
|
|
34
34
|
16.69 600 spec
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
So the 48 mm NEMA 17 gets a 22.5 mm pocket for its boss and 3.5 mm holes for M3 × 9 screws, a D-bore 5.
|
|
37
|
+
So the 48 mm NEMA 17 gets a 22.5 mm pocket for its boss and 3.5 mm holes for M3 × 9 screws, a D-bore 5.2 mm across and
|
|
38
38
|
4.8 mm over its flat, and 16.7 N m at the output of 50:1 gears turning at 12 rpm.
|
|
39
39
|
|
|
40
40
|
## The motors
|
|
@@ -66,9 +66,24 @@ package's `vocabulary.json`), handed in where the name goes.
|
|
|
66
66
|
## Holding a motor
|
|
67
67
|
|
|
68
68
|
`mount(model, { plate, printer?, screw?, counterbore?, recess? }, ops?)` is the negative a part subtracts; `mountModel`
|
|
69
|
-
gives the same as numbers, with what's wrong (a plate too thin for its screws, a boss pocket as deep as the plate
|
|
70
|
-
Clearances come from the printer's rules (`fit`, `hole_comp`)
|
|
71
|
-
|
|
69
|
+
gives the same as numbers, with what's wrong (a plate too thin for its screws, a boss pocket as deep as the plate, a
|
|
70
|
+
screw that does not hold in the motor's thread). Clearances come from the printer's rules (`fit`, `hole_comp`). The
|
|
71
|
+
screws are `@rulecad/fixings` models (`fixingModel`), and their holes and counterbores are its `hole` (a clearance hole)
|
|
72
|
+
and `counterbore`, so a printer of your own or a screw you've measured carries through.
|
|
73
|
+
|
|
74
|
+
`screw` is a fixing's name: a thread (`'M3'`), whose length is worked out from the plate, or a whole screw
|
|
75
|
+
(`'M3x8 cap'`), whose length is checked as it is. Where the motor's holes are tapped, the screw is on their thread
|
|
76
|
+
(`mount_hole_thread`), and a screw of another thread is refused by name. Its engagement is checked as
|
|
77
|
+
`mount.engagement`:
|
|
78
|
+
|
|
79
|
+
| What | Formula | Source |
|
|
80
|
+
|---|---|---|
|
|
81
|
+
| Length worked out | L = floor(t + min(d_tap, 2.5 d)), t the plate under the head (less the head's height where it is counterbored) | Into the motor's thread as far as it goes, up to 2.5 diameters |
|
|
82
|
+
| Thread engaged | e = min(L - t, d_tap), d_tap the motor's `mount_hole_depth` | The screw's length past the plate, held to the depth the maker tapped |
|
|
83
|
+
| Fails | e < 1 × d | `engagement.steel` in `@rulecad/rules`: about one diameter is the least any metal is given (Nord-Lock, Bossard); a motor's face is metal, and its maker's depth is all there is |
|
|
84
|
+
|
|
85
|
+
So an M3x6 through a 6 mm plate into a NEMA 17 fails (it ends at the motor's face), and the M3x9 worked out for a
|
|
86
|
+
5 mm plate passes, with 4 mm of the motor's 4.5 mm of thread.
|
|
72
87
|
|
|
73
88
|
Where the part goes: on the shaft's side of the mounting face, z from 0 to `plate`, so the boss enters a pocket and the
|
|
74
89
|
shaft passes through. A servo goes through the part instead: its body down a slot, its tabs on top, z from `-plate` to 0.
|
package/motors.d.mts
CHANGED
|
@@ -42,14 +42,19 @@ export function motorParts(m: Motor, ops?: {
|
|
|
42
42
|
shaft: object | null;
|
|
43
43
|
};
|
|
44
44
|
/**
|
|
45
|
-
* What a part needs to hold a motor, as numbers: the pocket, the holes, the screws. mount() cuts it.
|
|
45
|
+
* What a part needs to hold a motor, as numbers: the pocket, the holes, the screws. mount() cuts it. The screws are
|
|
46
|
+
* @rulecad/fixings' models, their holes and seats its clearance hole and counterbore. Where the motor's holes are
|
|
47
|
+
* tapped, the screw's engagement in them is checked (mount.engagement): the length past the plate, held to the
|
|
48
|
+
* motor's mount_hole_depth, against one screw diameter (engagement.steel, the least any metal is given).
|
|
46
49
|
* @param {Motor} m
|
|
47
50
|
* @param {{ plate: number, printer?: object, screw?: string, counterbore?: boolean, recess?: number }} p
|
|
48
|
-
* plate: the part's thickness at the mount (mm); printer: its fit, hole_comp, layer; screw: the screws
|
|
49
|
-
* a motor's plain holes
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
51
|
+
* plate: the part's thickness at the mount (mm); printer: its fit, hole_comp, layer; screw: the screws, by a fixing's
|
|
52
|
+
* name: a thread ('M3', for a motor's plain holes; the size they take if not said) or a whole screw with its length
|
|
53
|
+
* and head ('M3x8 cap'), whose length is then checked rather than worked out; counterbore: sink the screw heads;
|
|
54
|
+
* recess: let the body into the part this far as well
|
|
55
|
+
* @returns {{ plate: number, side: 1 | -1, pocket: number, pocketDepth: number, shaftHole: number, holes: { at: number[], diameter: number }[], screw: { thread: string, name: string, clearance: number, head: number, headHeight: number, model: object }, screwLength: number, head: number | null, recess: number, engaged: number | null, printer: object, findings: object[] }}
|
|
56
|
+
* side: which side of the mounting face the plate is on, +1 above it (a motor's face against the part), -1 below it
|
|
57
|
+
* (a servo through it); screw.model: the fixing (fixingModel); engaged: the thread engaged in the motor (mm), where its holes are tapped
|
|
53
58
|
*/
|
|
54
59
|
export function mountModel(m: Motor, p: {
|
|
55
60
|
plate: number;
|
|
@@ -67,16 +72,26 @@ export function mountModel(m: Motor, p: {
|
|
|
67
72
|
at: number[];
|
|
68
73
|
diameter: number;
|
|
69
74
|
}[];
|
|
70
|
-
screw:
|
|
71
|
-
|
|
75
|
+
screw: {
|
|
76
|
+
thread: string;
|
|
77
|
+
name: string;
|
|
78
|
+
clearance: number;
|
|
79
|
+
head: number;
|
|
80
|
+
headHeight: number;
|
|
81
|
+
model: object;
|
|
82
|
+
};
|
|
83
|
+
screwLength: number;
|
|
72
84
|
head: number | null;
|
|
73
85
|
recess: number;
|
|
86
|
+
engaged: number | null;
|
|
87
|
+
printer: object;
|
|
74
88
|
findings: object[];
|
|
75
89
|
};
|
|
76
90
|
/**
|
|
77
91
|
* The negative a part subtracts to hold a motor. For most motors the plate sits on the mounting face, on the shaft's
|
|
78
92
|
* side (z from 0 to plate); a servo's plate is under its tabs, with the body through a slot (z from -plate to 0). The
|
|
79
|
-
* part goes where the motor's mounting face is.
|
|
93
|
+
* part goes where the motor's mounting face is. The screws' holes and their counterbores are @rulecad/fixings' hole
|
|
94
|
+
* and counterbore; a servo's pilots are sized from its tabs' own holes.
|
|
80
95
|
* @param {Motor} m @param {{ plate: number, printer?: object, screw?: string, counterbore?: boolean, recess?: number }} p as mountModel
|
|
81
96
|
* @param {{ union: Function, subtract: Function }} [ops] the design's v.ops
|
|
82
97
|
* @returns {object} a JSCAD solid to subtract
|
package/motors.mjs
CHANGED
|
@@ -15,10 +15,8 @@ import sg90 from '@rulecad/rules/sg90.json' with { type: 'json' };
|
|
|
15
15
|
import mg90s from '@rulecad/rules/mg90s.json' with { type: 'json' };
|
|
16
16
|
import bldc2204 from '@rulecad/rules/bldc2204.json' with { type: 'json' };
|
|
17
17
|
import x1c from '@rulecad/rules/x1c.json' with { type: 'json' };
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import m3 from '@rulecad/rules/m3.json' with { type: 'json' };
|
|
21
|
-
import m4 from '@rulecad/rules/m4.json' with { type: 'json' };
|
|
18
|
+
import engagementSet from '@rulecad/rules/engagement.json' with { type: 'json' };
|
|
19
|
+
import { fixingModel, threads, holeModel, hole, counterboreModel, counterbore } from '@rulecad/fixings';
|
|
22
20
|
|
|
23
21
|
export { driver, setting, powerBudget, DRIVER_EFFICIENCY } from './drivers.mjs';
|
|
24
22
|
|
|
@@ -28,7 +26,6 @@ const { translate } = jscad.transforms;
|
|
|
28
26
|
const booleans = { union: jscad.booleans.union, subtract: jscad.booleans.subtract };
|
|
29
27
|
|
|
30
28
|
const CATALOGUE = Object.fromEntries([nema17, nema14, byj, n20, sg90, mg90s, bldc2204].map((s) => [s.name, s]));
|
|
31
|
-
const SCREWS = { 'M1.6': m1_6, M2: m2, M3: m3, M4: m4 };
|
|
32
29
|
const key = (s) => String(s).toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
33
30
|
const ALIASES = { ...Object.fromEntries(Object.keys(CATALOGUE).map((n) => [key(n), n])), byj48: '28byj48', '28byj': '28byj48', mg90: 'mg90s', '2204': 'bldc2204', gimbal2204: 'bldc2204', n20gearmotor: 'n20' };
|
|
34
31
|
for (const s of Object.values(CATALOGUE)) for (const v of Object.keys(s.variants || {})) ALIASES[key(v)] = s.name;
|
|
@@ -40,7 +37,7 @@ for (const s of Object.values(CATALOGUE)) for (const v of Object.keys(s.variants
|
|
|
40
37
|
export const DEFAULTS = {
|
|
41
38
|
running: { value: Math.SQRT1_2, unit: '× holding torque', rule: 'A stepper moving, against holding torque: holding has both phases at full current, and a driver moving it keeps the vector the size of one phase, 1/√2 of that', kind: 'spec' },
|
|
42
39
|
supply: { value: 24, unit: 'V', rule: 'The stepper driver\'s supply, if you don\'t say: above the motor\'s rated volts, as a chopper drive needs, and what a printer\'s board runs at', kind: 'default' },
|
|
43
|
-
fit: { value: 0.
|
|
40
|
+
fit: { value: 0.05, unit: 'mm', rule: 'Gap each side of a shaft in its bore, with the printed hole\'s shrinkage allowed for, so it slides on and no more: measured on the fit bar, a 5 mm D-shaft sliding in a bore drawn 5.2 mm', kind: 'measured' },
|
|
44
41
|
press: { value: -0.02, unit: 'mm', rule: 'Each side of a shaft in a press-fit bore as printed: a hair tight, 0.8% strain on a 5 mm shaft, well inside what PLA stretches to before it cracks. A D flat does the driving', kind: 'estimate' },
|
|
45
42
|
grip: { value: 1.5, unit: '× shaft diameter', rule: 'The shortest length of bore worth trusting to drive a gear', kind: 'community' }
|
|
46
43
|
};
|
|
@@ -190,53 +187,87 @@ export function motorParts(m, ops = booleans) {
|
|
|
190
187
|
|
|
191
188
|
// The printer's clearances, from its rule set, with a design's own printer laid over them
|
|
192
189
|
function printerOf(p) { return { fit: p?.fit ?? x1c.rules.fit.value, holeComp: p?.hole_comp ?? x1c.rules.hole_comp.value, layer: p?.layer ?? x1c.rules.layer.value, line: p?.line ?? x1c.rules.line.value }; }
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
190
|
+
const an = (thread) => `${/^(M|8-)/.test(thread) ? 'an' : 'a'} ${thread}`;
|
|
191
|
+
// The screw that holds a motor, from @rulecad/fixings: on the thread its holes are tapped (a stepper's face), else the
|
|
192
|
+
// one asked for, else the size its plain holes take. A screw asked for by its whole name ('M3x8 cap') brings its length
|
|
193
|
+
// and head; a thread alone ('M3') is a cap screw, its length worked out from the plate
|
|
194
|
+
function screwOf(what, m, said) {
|
|
195
|
+
const h = m.mount, made = (name) => { try { return fixingModel(name, {}, { anyLength: true }); } catch (e) { throw new Error(`${what}: ${String(e.message).replace(/^fixingModel: /, '')}`); } };
|
|
196
|
+
if (said != null && (typeof said !== 'string' || !said.trim())) throw new Error(`${what}: screw is a screw's name ('M3', or 'M3x8 cap' with its length and head), not ${shown(said)}`);
|
|
197
|
+
const asked = said == null ? null : made(said);
|
|
198
|
+
if (asked && asked.item !== 'thread' && asked.item !== 'screw') throw new Error(`${what}: screw is a screw's name ('M3', or 'M3x8 cap' with its length and head), and "${said}" is ${asked.item === 'insert' ? 'an' : 'a'} ${asked.item}`);
|
|
199
|
+
const thread = h.thread ?? asked?.thread ?? (h.diameter >= 4 ? 'M4' : h.diameter >= 3 ? 'M3' : 'M2');
|
|
200
|
+
if (h.thread && asked && asked.thread !== h.thread) throw new Error(`${what}: ${m.name}'s holes are tapped ${h.thread} (${m.name}.mount_hole_thread), so ${an(asked.thread)} screw does not go in them: give ${h.thread}, or leave screw out`);
|
|
201
|
+
if (!threads().includes(thread)) throw new Error(`${what}: no screw "${thread}" (${threads().join(', ')})`);
|
|
202
|
+
return asked?.item === 'screw' ? asked : made(`${thread} cap`);
|
|
196
203
|
}
|
|
204
|
+
// The engagement rule a screw in a motor's tapped hole is held to: the least any metal is given, as the motor's own
|
|
205
|
+
// thread is metal and its depth is the maker's
|
|
206
|
+
const LEAST = engagementSet.rules.steel;
|
|
207
|
+
// fixings' cutters start this far outside the face they enter by (its draw.mjs OUT), so a cut drawn from over the
|
|
208
|
+
// face starts where the motor's own cutters always have
|
|
209
|
+
const LIP = 0.1;
|
|
197
210
|
|
|
198
211
|
/**
|
|
199
|
-
* What a part needs to hold a motor, as numbers: the pocket, the holes, the screws. mount() cuts it.
|
|
212
|
+
* What a part needs to hold a motor, as numbers: the pocket, the holes, the screws. mount() cuts it. The screws are
|
|
213
|
+
* @rulecad/fixings' models, their holes and seats its clearance hole and counterbore. Where the motor's holes are
|
|
214
|
+
* tapped, the screw's engagement in them is checked (mount.engagement): the length past the plate, held to the
|
|
215
|
+
* motor's mount_hole_depth, against one screw diameter (engagement.steel, the least any metal is given).
|
|
200
216
|
* @param {Motor} m
|
|
201
217
|
* @param {{ plate: number, printer?: object, screw?: string, counterbore?: boolean, recess?: number }} p
|
|
202
|
-
* plate: the part's thickness at the mount (mm); printer: its fit, hole_comp, layer; screw: the screws
|
|
203
|
-
* a motor's plain holes
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
218
|
+
* plate: the part's thickness at the mount (mm); printer: its fit, hole_comp, layer; screw: the screws, by a fixing's
|
|
219
|
+
* name: a thread ('M3', for a motor's plain holes; the size they take if not said) or a whole screw with its length
|
|
220
|
+
* and head ('M3x8 cap'), whose length is then checked rather than worked out; counterbore: sink the screw heads;
|
|
221
|
+
* recess: let the body into the part this far as well
|
|
222
|
+
* @returns {{ plate: number, side: 1 | -1, pocket: number, pocketDepth: number, shaftHole: number, holes: { at: number[], diameter: number }[], screw: { thread: string, name: string, clearance: number, head: number, headHeight: number, model: object }, screwLength: number, head: number | null, recess: number, engaged: number | null, printer: object, findings: object[] }}
|
|
223
|
+
* side: which side of the mounting face the plate is on, +1 above it (a motor's face against the part), -1 below it
|
|
224
|
+
* (a servo through it); screw.model: the fixing (fixingModel); engaged: the thread engaged in the motor (mm), where its holes are tapped
|
|
207
225
|
*/
|
|
208
226
|
export function mountModel(m, p) {
|
|
209
227
|
const what = 'mount';
|
|
210
228
|
isModel(what, m);
|
|
211
229
|
if (!p || typeof p !== 'object') throw new Error(`${what}: give the part's { plate } (its thickness at the mount, mm), not ${shown(p)}`);
|
|
212
|
-
const plate = positive(what, 'plate', p.plate), pr = printerOf(p.printer), { mount: h, boss, shaft } = m, out = [], f = (level, text, code) => out.push({ level, text, code });
|
|
213
|
-
const
|
|
214
|
-
|
|
230
|
+
const plate = positive(what, 'plate', p.plate), pr = printerOf(p.printer), { mount: h, boss, shaft } = m, out = [], f = (level, text, code, extra = {}) => out.push({ level, text, code, ...extra });
|
|
231
|
+
const fx = screwOf(what, m, p.screw), thread = fx.thread, d = fx.major, values = { fit: pr.fit, hole_comp: pr.holeComp, layer: pr.layer };
|
|
232
|
+
const clear = holeModel(fx, { kind: 'clearance', printer: values }), seat = p.counterbore ? counterboreModel(fx, { printer: values }) : null;
|
|
233
|
+
const screw = { thread, name: fx.name, clearance: clear.nominal, head: fx.head.across, headHeight: fx.head.height, model: fx };
|
|
215
234
|
const pocket = boss.diameter ? boss.diameter + 2 * pr.fit + pr.holeComp : 0, pocketDepth = boss.height ? boss.height + 2 * pr.layer : 0;
|
|
216
235
|
const shaftHole = shaft.diameter + 2 * pr.fit + pr.holeComp + 0.4;
|
|
217
|
-
const
|
|
218
|
-
const
|
|
219
|
-
const head = p.counterbore ? screw.head + 2 * pr.fit + pr.holeComp : null;
|
|
236
|
+
const holeD = m.type === 'servo' ? h.diameter - 0.4 + pr.holeComp : clear.diameter;
|
|
237
|
+
const head = seat ? seat.diameter : null;
|
|
220
238
|
if (pocketDepth >= plate && m.mount.side === 1) f('fail', `the plate is ${plate} mm thick and the boss's pocket ${pocketDepth} mm deep: it needs to be thicker than that, or it's only a hole`, 'mount.plate');
|
|
221
239
|
const thickest = h.thread ? h.depth : 0;
|
|
222
|
-
// a screw's length: through the plate, into the thread, its head sunk or not
|
|
240
|
+
// a screw's length: through the plate, into the thread, its head sunk or not; or the one asked for
|
|
223
241
|
const under = plate - (p.counterbore ? screw.headHeight : 0);
|
|
224
|
-
const screwLength = h.thread ? Math.floor(under + Math.min(thickest, 2.5 *
|
|
242
|
+
const screwLength = fx.length ?? (h.thread ? Math.floor(under + Math.min(thickest, 2.5 * d)) : Math.ceil(plate + (h.earThickness || h.tabThickness) + 2));
|
|
225
243
|
if (m.mount.side === 1 && h.thread && under + thickest < screwLength) f('warn', `an ${thread} × ${screwLength} would bottom out in the motor's ${thickest} mm of thread`, 'mount.screw');
|
|
226
|
-
if (plate < 1.5 *
|
|
227
|
-
|
|
244
|
+
if (plate < 1.5 * d) f('warn', `a ${plate} mm plate is thin for ${thread} screws: at least ${1.5 * d} mm, or the head pulls through`, 'mount.plate');
|
|
245
|
+
// the screw's thread in the motor's: what passes the plate, up to the depth the motor is tapped
|
|
246
|
+
let engaged = null;
|
|
247
|
+
if (m.mount.side === 1 && h.thread && thickest > 0) {
|
|
248
|
+
engaged = +Math.max(0, Math.min(screwLength - under, thickest)).toFixed(3);
|
|
249
|
+
const least = +(LEAST.value * d).toFixed(3), n = h.holes.length, name = `${thread}x${+screwLength.toFixed(3)} ${fx.head.form}`, depthRule = `${m.name}.mount_hole_depth`;
|
|
250
|
+
const lengths = fx.figures.lengths?.value ?? [], fits = [...lengths].reverse().find((L) => L - under <= thickest + 1e-9 && L - under >= least - 1e-9);
|
|
251
|
+
const dia = (x) => `${+x.toFixed(2)} diameter${+x.toFixed(2) === 1 ? '' : 's'}`, An = an(thread).replace(/^a/, 'A'), fix = fits ? ` ${An}x${fits} ${fx.head.form} would engage ${+(fits - under).toFixed(3)} mm` : ` No length sold reaches ${least} mm of thread and stops short of the motor's ${thickest} mm: a ${p.counterbore ? 'deeper counterbore' : 'counterbore'} or a thinner plate at the screws`;
|
|
252
|
+
const said = `${n} ${name} screw${n > 1 ? 's' : ''} through ${+under.toFixed(3)} mm of plate`, vals = { values: { engaged, depth: thickest, least, length: screwLength, under: +under.toFixed(3), count: n }, refs: { screw: name, rule: depthRule, least: 'engagement.steel', kind: LEAST.kind } };
|
|
253
|
+
if (screwLength - under <= 1e-9) f('fail', `${said} do not reach the motor's thread: ${name} ends ${under - screwLength > 1e-9 ? `${+(under - screwLength).toFixed(3)} mm short of` : 'at'} its face.${fix}`, 'mount.engagement', vals);
|
|
254
|
+
else if (engaged < least - 1e-9) f('fail', `${said} engage ${engaged} mm of the motor's ${thickest} mm of ${thread} thread (${depthRule}), ${dia(engaged / d)}: less than the ${least} mm (engagement.steel, ${LEAST.value} diameter, the least any metal is given), so the thread strips before the screw holds.${fix}`, 'mount.engagement', vals);
|
|
255
|
+
else f('pass', `${said} engage ${engaged} mm of the motor's ${thickest} mm of ${thread} thread (${depthRule}), ${dia(engaged / d)}, at least the ${least} mm engagement.steel gives any metal`, 'mount.engagement', vals);
|
|
256
|
+
}
|
|
257
|
+
return { plate, side: h.side, pocket: r3(pocket), pocketDepth: r3(pocketDepth), shaftHole: r3(shaftHole), holes: h.holes.map((at) => ({ at, diameter: r3(holeD) })), screw, screwLength, head, recess: p.recess ?? 0, engaged, printer: pr, findings: out };
|
|
228
258
|
}
|
|
229
259
|
|
|
230
260
|
/**
|
|
231
261
|
* The negative a part subtracts to hold a motor. For most motors the plate sits on the mounting face, on the shaft's
|
|
232
262
|
* side (z from 0 to plate); a servo's plate is under its tabs, with the body through a slot (z from -plate to 0). The
|
|
233
|
-
* part goes where the motor's mounting face is.
|
|
263
|
+
* part goes where the motor's mounting face is. The screws' holes and their counterbores are @rulecad/fixings' hole
|
|
264
|
+
* and counterbore; a servo's pilots are sized from its tabs' own holes.
|
|
234
265
|
* @param {Motor} m @param {{ plate: number, printer?: object, screw?: string, counterbore?: boolean, recess?: number }} p as mountModel
|
|
235
266
|
* @param {{ union: Function, subtract: Function }} [ops] the design's v.ops
|
|
236
267
|
* @returns {object} a JSCAD solid to subtract
|
|
237
268
|
*/
|
|
238
269
|
export function mount(m, p, ops = booleans) {
|
|
239
|
-
const g = mountModel(m, p), { plate, pocket, pocketDepth, shaftHole, holes, recess, printer: pr } = g, { body
|
|
270
|
+
const g = mountModel(m, p), { plate, pocket, pocketDepth, shaftHole, holes, recess, printer: pr } = g, { body } = m, [cx, cy] = body.centre, cuts = [], over = 0.5;
|
|
240
271
|
if (m.type === 'servo') {
|
|
241
272
|
// the body through a slot, with the fit all round; the screws' pilot holes in the plate
|
|
242
273
|
cuts.push(box(cx - body.width / 2 - pr.fit, cx + body.width / 2 + pr.fit, cy - body.depth / 2 - pr.fit, cy + body.depth / 2 + pr.fit, -plate - over, over));
|
|
@@ -245,9 +276,11 @@ export function mount(m, p, ops = booleans) {
|
|
|
245
276
|
}
|
|
246
277
|
if (pocket && pocketDepth) cuts.push(disc(pocket, -over, pocketDepth));
|
|
247
278
|
cuts.push(disc(shaftHole, -over, plate + over));
|
|
279
|
+
// each screw's hole down through the plate, from over its top face to under the motor's, its head's seat at the top
|
|
280
|
+
const values = { fit: pr.fit, hole_comp: pr.holeComp, layer: pr.layer }, top = plate + over - LIP, length = plate + 2 * (over - LIP), fx = g.screw.model;
|
|
248
281
|
for (const x of holes) {
|
|
249
|
-
|
|
250
|
-
|
|
282
|
+
const at = [x.at[0], x.at[1], top];
|
|
283
|
+
cuts.push(g.head ? counterbore(fx, { printer: values, at, depth: g.screw.headHeight + over - LIP, length, into: '-z' }) : hole(fx, { kind: 'clearance', printer: values, at, depth: length, into: '-z' }));
|
|
251
284
|
}
|
|
252
285
|
if (recess) {
|
|
253
286
|
if (body.shape === 'round') cuts.push(disc(body.width + 2 * pr.fit + pr.holeComp, -recess - over, 0, [cx, cy]));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulecad/motors",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Motors for printed machines: steppers, DC gear motors, servos and brushless motors from their datasheets, as models with sourced figures, solids to place in an assembly, the mounts and D-bores a part takes for them, and what torque and speed reach the output.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"motors.d.mts",
|
|
23
23
|
"diagram.d.mts",
|
|
24
24
|
"README.md",
|
|
25
|
+
"CHANGELOG.md",
|
|
25
26
|
"LICENSE"
|
|
26
27
|
],
|
|
27
28
|
"license": "MIT",
|
|
@@ -33,5 +34,5 @@
|
|
|
33
34
|
"bugs": { "url": "https://github.com/JoniBach/rulecad/issues" },
|
|
34
35
|
"scripts": { "test": "node --test" },
|
|
35
36
|
"peerDependencies": { "@jscad/modeling": "^2.12.0" },
|
|
36
|
-
"dependencies": { "@rulecad/rules": "^0.3.
|
|
37
|
+
"dependencies": { "@rulecad/rules": "^0.3.11", "@rulecad/fixings": "^0.1.3" }
|
|
37
38
|
}
|