@rulecad/cad 0.7.62 → 0.7.65

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/AGENTS.md CHANGED
@@ -275,6 +275,10 @@ EXAMPLES chapter 12 builds one from start to finish.
275
275
  State why the current is what it is: the torque it needs, the driver's rating without a heat sink, the motor's heat.
276
276
  - **Everything bought is an item.** Motors, drivers, bearings, switches, the supply: `bought` items and `wires` make the
277
277
  shopping list (`cad list`), the wiring sheet (`cad wires`) and the firmware's settings (`cad machine`) from one assembly.
278
+ Ask the person what they already have, and mark those items `"have": true`: `cad list` and the kit then list them as
279
+ in hand, apart from what is to buy. Design for the parts they have before asking them to buy others.
280
+ - **The supply sets the speed.** A stepper's torque at speed is worked out at the volts of the assembly's bought supply
281
+ (24 V where it has none): give the supply they will really use, and report `motor.torque` at that voltage.
278
282
  - Before moving anything: `cad plot` the drawing and watch the preview. It refuses a stroke that leaves the sheet.
279
283
  - **A gait is the same idea for a body.** Give an assembly a `gait` (`legs`, `pattern`, `stride`, `lift`, `period`, `height`, `mass`): the body at the world origin, the hips at z = 0, the feet as anchors. One leg on a stand is a gait of one leg (`"pattern": { "duty": 0.6, "phase": [0] }`). Anchor a round foot at its centre, so the contact rolls with the shin and the height stays true. Report a gait's numbers as they are: quasi-static, the torque from the weight alone, no dynamics.
280
284
  - **Say what the machine weighs.** A robot built from these parts is heavier than the first sizing said it was: list `cad list`'s grams and set the gait's `mass` to that, and report the torque margin at the real mass.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,41 @@ print (a hole's diameter, a seat's depth, a part's outline). Each release lists
5
5
  its reason. A **fasten** is an entry in an assembly's `"fasten"` list: one screwed joint, naming the screw by thread
6
6
  and head, the parts it passes through and the part it ends in.
7
7
 
8
+ ## 0.7.65: the arm on the parts its builder has
9
+
10
+ ### Changed
11
+
12
+ - A stepper's torque at speed (`motor.torque`, `motor.mount`, `fasten.load`, `motor.accel`, `task.time`, a gait's
13
+ torque, the motor's curve in the preview) is worked out at the volts of the assembly's bought supply, where it has
14
+ one; before, always at `@rulecad/motors`' default 24 V. On 12 V a 17HS4401 at 300 rpm gives 0.269 N m at full
15
+ current, not 0.283. A stepper with no `speed` works at its corner speed at that supply (286 rpm on 12 V, not 571).
16
+ `motor.torque` says it: `..., at 300 rpm on its supply's 12 V`, and its values carry `supply` and `rpm`. An
17
+ assembly with no supply checks as before.
18
+ - A motor named by its variant (`17HS4401`) is listed by it: `nema17 (17HS4401)` on `cad list`, the kit and the
19
+ `bought.item` line.
20
+
21
+ ### Added
22
+
23
+ - `"have": true` on a motor or bought item: in hand, so `cad list` lists it under `Bought, in hand` apart from what is
24
+ to buy (`have: true` on its line in `--json`, and out of the bought cost), the kit's `buy.csv` gives it the kind `in
25
+ hand`, and the kit's build page a table of its own. On a printed or beam item it is refused, by name.
26
+
27
+ ### The bench arm (examples/bench/projects/arm and EXAMPLES chapters 12 and 13)
28
+
29
+ - The elbow's motor is a 17HS4401, the shoulder's, on the same `v.motors` mount: printed sizes moved in `upper`, the
30
+ elbow motor's four M3 holes and their counterbores from the NEMA 14's 26 mm square to the 17HS4401's 31 mm square,
31
+ so the motor the builder has bolts on (the part weighs 126.1 g, as before). The supply is a 12 V bench supply with
32
+ its limit at 1.5 A; the drivers stay at 0.5 A and 1/8 step, the upright arm's shoulder at 0.8 A. Rules moved:
33
+ `arm.shoulder_torque` 0.2 to 0.22 N m, `lift.upper_mass` 0.376 to 0.466 kg.
34
+
35
+ ## 0.7.64: no import loops (#278)
36
+
37
+ ### Fixed
38
+
39
+ - `wiresFor`, `wireTubesOf` and `wireRoutesOf` moved from `lib/assembly.mjs` to `lib/wires.mjs`, so `lib/list.mjs` no
40
+ longer imports `lib/assembly.mjs` back (a loop of imports, issue #278). `lib/assembly.mjs` re-exports all three
41
+ under the same names. No printed size moved.
42
+
8
43
  ## 0.7.62: commands that write projects and assemblies, and belt guides (Frames 4)
9
44
 
10
45
  ### Added
package/EXAMPLES.md CHANGED
@@ -1647,9 +1647,15 @@ and what the error budget has to say. This chapter is a whole machine, so it is
1647
1647
  `examples/bench/projects/arm` written out in full: the tests write every file here and run every command.
1648
1648
 
1649
1649
  The arm is a compound planetary at the shoulder (chapter 11's gearbox, on a 17HS4401) and the same gearbox at the
1650
- elbow on a smaller motor. Its joints are vertical, so gravity never loads a motor. The base can bolt flat on a
1650
+ elbow on a second 17HS4401. Its joints are vertical, so gravity never loads a motor. The base can bolt flat on a
1651
1651
  bench to draw, or upright on a stand later, on the same four holes.
1652
1652
 
1653
+ It is built from parts already on the bench: Usongshine 17HS4401 steppers, DRV8825 drivers on a CNC Shield V3 over an
1654
+ Arduino Uno R3, microstepping set to 1/8 by the M0 and M1 jumpers (1600 steps a turn), a 12 V bench supply with a
1655
+ current limit, and one SG90. The assembly marks each of those `"have": true`, so `cad list` lists them as in hand and
1656
+ everything else as to buy: the 6800 bearing, the two home switches, the screws and the wire. Two rubber bands bias the
1657
+ joints (below); the assembly does not count them, so buy those too.
1658
+
1653
1659
  ### The task, and where the sheet goes
1654
1660
 
1655
1661
  A sheet can face the arm either way. Portrait, the far corners are 290 mm from the shoulder; landscape, 242 mm, for the
@@ -1689,13 +1695,16 @@ Three ways to turn the elbow:
1689
1695
  |---|---|---|---|---|
1690
1696
  | Direct | NEMA 17 on the joint, no gears | 0.225° × 115 mm = 0.45 mm at 1/8 step | 280 g | over the 0.3 mm budget from one term |
1691
1697
  | Belt to the base | Motor at the base, a belt up to a pulley | depends on the ratio: 3:1 at most from pulleys that fit | No belt in the catalogue yet; the elbow couples to the shoulder and the sag of the belt is an error of its own | later |
1692
- | Geared | NEMA 14 through the 38:1 gearbox | 0.0059° × 115 mm = 0.012 mm at 1/8 step | 190 g; the gearbox's play and twist | the choice |
1698
+ | Geared | 17HS4401 through the 38:1 gearbox | 0.0059° × 115 mm = 0.012 mm at 1/8 step | 280 g; the gearbox's play and twist | the choice |
1693
1699
 
1694
1700
  The geared elbow uses the shoulder's gearbox unchanged, so the sun, the planets and the output ring are the same prints
1695
- and the same bench test measures both. NEMA 14 rather than a second 17 because the torque the elbow needs is tiny: 0.08 N m
1696
- at the elbow (the pen's drag, the forearm's inertia, the bias) against 2.27 N m the small motor gives through 38:1,
1697
- and it weighs 90 g less at the end of a 160 mm link. The fixed ring is printed into the upper arm itself: the elbow costs
1698
- a sun, three planets, an output ring and three clips.
1701
+ and the same bench test measures both. Its motor is the shoulder's too: a 17HS4401 on the same `v.motors` mount, so one
1702
+ motor, one driver setting and one spare cover both joints. The torque the elbow needs is tiny: 0.08 N m at the elbow
1703
+ (the pen's drag, the forearm's inertia, the bias) against 1.6 N m the 17HS4401 gives through 38:1 at 0.5 A on 12 V.
1704
+ A NEMA 14 would do the same 90 g lighter; those 90 g sit at the end of the 160 mm upper arm, and the shoulder pays for
1705
+ them: its arm's inertia goes from 0.019 to 0.024 kg m², the bearing's load from 89 to 108 N, and it still has seven
1706
+ times the torque it needs. The fixed ring is printed into the upper arm itself: the elbow costs a sun, three planets, an
1707
+ output ring and three clips.
1699
1708
 
1700
1709
  ### The bearing
1701
1710
 
@@ -1729,8 +1738,8 @@ The rules: the reach, the stack of parts from the bench up, and what the budget
1729
1738
  "twist_elbow": {"value": 0.01, "unit": "°", "rule": "The elbow's gear train twisting, the same", "kind": "estimate", "source": "A guess: bench test 15", "checked": "2026-11-09"},
1730
1739
  "deflection": {"value": 0.02, "unit": "mm", "rule": "The links bending sideways at the pen under its drag, from beam formulas", "kind": "estimate", "source": "0.3 N of drag on the forearm and holder as cantilevers: bench test 17 measures the whole budget at once", "checked": "2026-11-09"},
1731
1740
  "drag": {"value": 0.3, "unit": "N", "rule": "A pen's drag on paper, about, pulled sideways at the tip", "kind": "estimate", "source": "A hand guess from a pen on a spring scale: measure yours", "checked": "2026-11-09"},
1732
- "shoulder_torque": {"value": 0.2, "unit": "N m", "rule": "What the shoulder must do at the task's speed and accel: the pen's drag at 240 mm, the arm's inertia and the bias", "kind": "estimate", "source": "Drag 0.07 N m + inertia about 0.03 N m + the rubber band's bias 0.1 N m", "checked": "2026-11-09"},
1733
- "elbow_torque": {"value": 0.08, "unit": "N m", "rule": "What the elbow must do: the pen's drag at 110 mm, the forearm's inertia and the bias", "kind": "estimate", "source": "Drag 0.03 N m + inertia 0.01 N m + the rubber band's bias 0.04 N m", "checked": "2026-11-09"},
1741
+ "shoulder_torque": {"value": 0.22, "unit": "N m", "rule": "What the shoulder must do at the task's speed and accel: the pen's drag at 242 mm, the arm's inertia and the bias", "kind": "estimate", "source": "Drag 0.3 N x 0.242 m = 0.073 N m + inertia 0.024 kg m2 (motor.accel's, with the 17HS4401 at the elbow) x 2.07 rad/s2 (500 mm/s2 at 242 mm) = 0.05 N m + the rubber band's bias 0.1 N m", "checked": "2026-11-22"},
1742
+ "elbow_torque": {"value": 0.08, "unit": "N m", "rule": "What the elbow must do: the pen's drag at 115 mm, the forearm's inertia and the bias", "kind": "estimate", "source": "Drag 0.3 N x 0.115 m = 0.035 N m + inertia 0.0006 kg m2 (motor.accel's forearm) x 4.35 rad/s2 (500 mm/s2 at 115 mm) = 0.003 N m + the rubber band's bias 0.04 N m, 0.077 N m: the elbow's motor rides on the upper arm, so the change of motor leaves it", "checked": "2026-11-22"},
1734
1743
  "foot": {"value": 6, "unit": "mm", "rule": "The base plate's thickness", "kind": "default", "source": "Stiff enough for four M5 screws", "checked": "2026-11-09"},
1735
1744
  "room": {"value": 2, "unit": "mm", "rule": "Air between the shoulder motor's back and the base plate", "kind": "default", "source": "Design", "checked": "2026-11-09"},
1736
1745
  "motor17": {"value": 40, "unit": "mm", "rule": "The 17HS4401's body length", "kind": "community", "source": "nema17 variant 17HS4401 (https://market.samm.com/17hs4401-nema17-step-motor-en)", "checked": "2026-11-09"},
@@ -2284,7 +2293,8 @@ hexagon's socket, the elbow's fixed ring and posts. The elbow's motor bolts to t
2284
2293
 
2285
2294
  ```js projects/arm/objects/upper.js
2286
2295
  // The upper arm, drawn as it prints: its top face on the bed, the elbow's ring standing on it, the hub's socket opening
2287
- // upward. The elbow's NEMA 14 bolts on the bed side, its shaft up through the plate, as chapter 11's housing does.
2296
+ // upward. The elbow's 17HS4401, the shoulder's motor, bolts on the bed side, its shaft up through the plate, on the same
2297
+ // v.motors mount as the shoulder's housing.
2288
2298
  // The screws' holes are v.fixings': an M3 clearance hole through the socket's floor for the screw into the spindle,
2289
2299
  // an M3 pilot in each post for its clip, and the elbow switch's M2 pilots.
2290
2300
  import jscad from '@jscad/modeling'
@@ -2295,7 +2305,7 @@ const { hull } = jscad.hulls
2295
2305
 
2296
2306
  export function main (v) {
2297
2307
  const screw = v.fixings.holeModel('M3').diameter, pilot = v.fixings.holeModel('M3', { kind: 'pilot' }).diameter, switchPilot = v.fixings.holeModel('M2', { kind: 'pilot' }).diameter
2298
- const motor = v.motors.motorModel('nema14')
2308
+ const motor = v.motors.motorModel('17HS4401')
2299
2309
  const at = (r, a) => [v.long + r * Math.cos(a), r * Math.sin(a)]
2300
2310
  const posts = [v.p1, v.p2, v.p3].map((a) => a * v.rad)
2301
2311
  const round = (r, c) => translate([c, 0], circle({ radius: r, segments: v.segments }))
@@ -2612,7 +2622,7 @@ so an M3x30, the longest sold, reaches its nut on the far one.
2612
2622
  "uses": ["arm"],
2613
2623
  "items": [
2614
2624
  { "id": "base", "object": "base" },
2615
- { "id": "m1", "motor": { "model": "17HS4401", "drives": "drive", "speed": 300, "duty": 0.3, "driver": "d1", "current": 0.5, "microsteps": 8 } },
2625
+ { "id": "m1", "motor": { "model": "17HS4401", "drives": "drive", "speed": 300, "duty": 0.3, "driver": "d1", "current": 0.5, "microsteps": 8 }, "have": true },
2616
2626
  { "id": "housing", "object": "housing", "at": [0, 0, "arm.face"] },
2617
2627
  { "id": "sun", "object": "sun" },
2618
2628
  { "id": "carrier", "object": "speck" },
@@ -2622,7 +2632,7 @@ so an M3x30, the longest sold, reaches its nut on the far one.
2622
2632
  { "id": "bridge", "object": "bridge", "at": [0, 0, "arm.bridge_low"] },
2623
2633
  { "id": "b1", "bought": "bearing-6800", "at": [0, 0, "arm.bridge_low + arm.bridge - arm.bearing_width"] },
2624
2634
  { "id": "upper", "object": "upper" },
2625
- { "id": "m2", "motor": { "model": "nema14", "drives": "edrive", "speed": 300, "duty": 0.3, "driver": "d2", "current": 0.5, "microsteps": 8 } },
2635
+ { "id": "m2", "motor": { "model": "17HS4401", "drives": "edrive", "speed": 300, "duty": 0.3, "driver": "d2", "current": 0.5, "microsteps": 8 }, "have": true },
2626
2636
  { "id": "esun", "object": "sun", "set": { "tip": 11.7 } },
2627
2637
  { "id": "ecarrier", "object": "speck" }, { "id": "ering", "object": "speck" },
2628
2638
  { "id": "ep1", "object": "planet" }, { "id": "ep2", "object": "planet" }, { "id": "ep3", "object": "planet" },
@@ -2630,15 +2640,15 @@ so an M3x30, the longest sold, reaches its nut on the far one.
2630
2640
  { "id": "clip1", "object": "clip" }, { "id": "clip2", "object": "clip" }, { "id": "clip3", "object": "clip" },
2631
2641
  { "id": "forearm", "object": "forearm" },
2632
2642
  { "id": "holder", "object": "holder" },
2633
- { "id": "servo", "motor": { "model": "sg90", "drives": "lift_servo", "duty": 0.05 } },
2643
+ { "id": "servo", "motor": { "model": "sg90", "drives": "lift_servo", "duty": 0.05 }, "have": true },
2634
2644
  { "id": "horn", "object": "horn" },
2635
2645
  { "id": "pen", "object": "pen" },
2636
2646
  { "id": "es1", "bought": "endstop-10t85" },
2637
2647
  { "id": "es2", "bought": "endstop-10t85" },
2638
- { "id": "d1", "bought": "drv8825", "at": [-300, -30, 8] },
2639
- { "id": "d2", "bought": "drv8825", "at": [-300, 0, 8] },
2640
- { "id": "shield", "bought": "cnc-shield-v3", "at": [-300, 0, 0] },
2641
- { "id": "psu", "bought": "supply-24v", "variant": "LRS-50-24", "at": [-330, 150, 0] }
2648
+ { "id": "d1", "bought": "drv8825", "at": [-300, -30, 8], "have": true },
2649
+ { "id": "d2", "bought": "drv8825", "at": [-300, 0, 8], "have": true },
2650
+ { "id": "shield", "bought": "cnc-shield-v3", "at": [-300, 0, 0], "have": true },
2651
+ { "id": "psu", "bought": "supply-12v", "set": { "output_current": 1.5 }, "at": [-330, 150, 0], "have": true }
2642
2652
  ],
2643
2653
  "joints": [
2644
2654
  { "id": "m1_on", "type": "fixed", "parent": "housing.motor", "child": "m1.face" },
@@ -2712,7 +2722,7 @@ so an M3x30, the longest sold, reaches its nut on the far one.
2712
2722
  { "id": "pen", "from": "servo.connector", "to": "shield.Z", "via": ["forearm.cable", "upper.cable", "base.cable"], "gauge": "awg26", "colour": "brown, red, orange", "conductors": 3, "current": 0.7, "connectors": ["Servo JR 3 pin", "D11, 5 V, GND"], "note": "D11 is the Z limit pin on a V3.00 shield: arm.ino uses it for the servo" },
2713
2723
  { "id": "home1", "from": "es1.left", "to": "shield.X", "via": ["base.cable"], "gauge": "awg26", "colour": "white, black", "conductors": 2, "connectors": ["Crimped spade", "X limit and GND"] },
2714
2724
  { "id": "home2", "from": "es2.left", "to": "shield.Y", "via": ["upper.cable", "base.cable"], "gauge": "awg26", "colour": "white, black", "conductors": 2, "connectors": ["Crimped spade", "Y limit and GND"] },
2715
- { "id": "power", "from": "psu.terminals", "to": "shield.top", "gauge": "awg22", "colour": "red, black", "conductors": 2, "current": 2, "connectors": ["Ring terminal", "Screw terminal"], "note": "24 V into the shield's motor terminals" }
2725
+ { "id": "power", "from": "psu.terminals", "to": "shield.top", "gauge": "awg22", "colour": "red, black", "conductors": 2, "current": 2, "connectors": ["Ring terminal", "Screw terminal"], "note": "12 V from the bench supply, its current limit at 1.5 A, into the shield's motor terminals" }
2716
2726
  ],
2717
2727
  "loads": [
2718
2728
  { "joint": "out", "torque": "arm.shoulder_torque", "note": "The pen's drag at its reach, the arm's inertia at 500 mm/s², the bias" },
@@ -2723,14 +2733,25 @@ so an M3x30, the longest sold, reaches its nut on the far one.
2723
2733
  }
2724
2734
  ```
2725
2735
 
2726
- Why each driver is set where it is: both motors run at 0.5 A a coil, under the 17HS4401's 1.5 A and the NEMA 14's
2727
- 0.8 A, and the number comes from what they must do rather than what they can. The shoulder needs 0.011 N m at the motor's
2728
- shaft for the task (0.2 N m through 38:1 at 47%) and has about 0.09 N m at 0.5 A, turning, eight times over. More current
2729
- would only heat the motor and the PLA it is bolted to. It also sets the worst the arm can do to itself: stalled against
2730
- something, 0.5 A puts about 2.4 N m on the shoulder's output, and that is 12 MPa of shear in the spindle's printed 10 mm
2731
- shaft, against PLA's 22, about twice over (at the current the shoulder could take, the shaft would break first). A
2732
- DRV8825 runs 0.5 A with no heat sink. Set each trimmer to what `cad check` says for these 0.1 Ω sense resistors (0.25 V):
2733
- read the resistors on your own board first, because clones differ.
2736
+ Why each driver is set where it is: both motors run at 0.5 A a coil, a third of the 17HS4401's 1.5 A, and the number
2737
+ comes from what they must do rather than what they can. On 12 V the motor's torque is flat up to its corner speed,
2738
+ 60 × 12 V / (2 × 4.2 mH × 1.5 A × 200 steps) = 286 rpm, and falls as one over the speed past it; `motor.torque` reads the
2739
+ volts from the supply item. At the 300 rpm the task runs at, that is 0.2694 N m at full current and 0.0898 N m at 0.5 A.
2740
+ The shoulder needs 0.012 N m at the motor's shaft (0.22 N m through 38:1 at 47%), seven times under that; the elbow
2741
+ 0.0045 N m, twenty times under. More current would only heat the motor and the PLA it is bolted to. It also sets the
2742
+ worst the arm can do to itself: stalled against something, 0.5 A puts about 2.4 N m on the shoulder's output, and that
2743
+ is 12 MPa of shear in the spindle's printed 10 mm shaft, against PLA's 22, about twice over (at the current the shoulder
2744
+ could take, the shaft would break first). A DRV8825 runs 0.5 A with no heat sink. The machine draws 0.5 A from the
2745
+ 12 V supply: set the bench supply's current limit to 1.5 A, which is three times that and still under 2 A.
2746
+
2747
+ Setting each driver's trimmer, the Pololu DRV8825 carrier's way (the `drv8825` rule set's source): the current limit is
2748
+ twice the reference voltage, Vref = I / 2, for its 0.1 Ω sense resistors, so 0.5 A is 0.25 V. Read the two small
2749
+ resistors beside the chip first (R100 is 0.1 Ω): clones differ, and a different one changes the formula. With the
2750
+ motors unplugged and the power off, seat the drivers, then switch on the 12 V supply and plug the Uno into USB. Set the
2751
+ meter to DC volts, put its black probe on the shield's GND and its red probe on the trimmer's metal top, and turn the
2752
+ trimmer with a small plastic or ceramic screwdriver until it reads 0.25 V. Switch off before plugging in each motor:
2753
+ plugging or unplugging a motor with the power on can destroy the driver. A trimmer whose reading will not move is a
2754
+ faulty driver: set it aside.
2734
2755
 
2735
2756
  ```xml projects/arm/drawings/test.svg
2736
2757
  <svg xmlns="http://www.w3.org/2000/svg" width="210mm" height="148mm" viewBox="0 0 210 148"><rect id="square" x="55" y="24" width="100" height="100" fill="none"/><circle id="circle" cx="105" cy="74" r="35" fill="none"/></svg>
@@ -2759,21 +2780,27 @@ it without `--json` and read them. What it says:
2759
2780
  The worst case is 81% of the budget, under the 100% where the check would fail, over the 80% where it stops saying pass.
2760
2781
  Bench test 14 (play) and 17 (repeatability) decide whether this arm draws to 0.3 mm or to 0.5.
2761
2782
  - The rules that are guesses are named in one warning line, `uses estimates, not measurements`, and each settles with `cad measured arm/arm <name>=<value>`.
2762
- - `joint.moment` puts 88.6 N equivalent on the 6800, against its 925 N static rating, ten times over; `fit.seat` says the
2783
+ - `joint.moment` puts 108.1 N equivalent on the 6800, against its 925 N static rating, 8.6 times over (89 N with a
2784
+ NEMA 14 at the elbow); `fit.seat` says the
2763
2785
  pocket is drawn 19.038 mm, a press fit, with a 1.11 mm lip on the outer race and clear of the inner.
2764
- - `m1 into out` gives 8.4 times the 0.2 N m the task asks at the shoulder, at the 0.5 A chosen, and `m2 into elbow` 17.7
2765
- times its 0.08 N m. Both joints hold with the power off: 38:1 at 47% can't be driven backwards.
2786
+ - `m1 into out` gives 7.3 times the 0.22 N m the task asks at the shoulder, at the 0.5 A chosen, and `m2 into elbow` 20
2787
+ times its 0.08 N m, both at 300 rpm on the supply's 12 V. (On 24 V, with a NEMA 14 at the elbow and 0.2 N m asked at
2788
+ the shoulder, they were 8.4 and 17.7 times.) Both joints hold with the power off: 38:1 at 47% can't be driven backwards.
2789
+ - `motor.accel` and `task.time`: the 12 V torque still accelerates the pen at up to 5898 mm/s² (7174 on 24 V), twelve
2790
+ times the 500 the task plans, so a move across the sheet takes 5.24 s either way: the speed sets it, not the torque.
2766
2791
  - Each `fasten` is followed screw by screw: the holes line up, each far end is a pilot (an M3's 2.9 mm, `x1c.pilot_m3`,
2767
2792
  measured; an M2's 2.1 mm, `m2.pilot`, a community figure) or the yoke's nut, the length is the shortest sold that fits
2768
2793
  (M3x8 into the base's columns, M3x10 into the posts, M3x8 countersunk into the output's flange, M3x12 into the elbow's,
2769
2794
  M3x16 down into the spindle, M3x30 through the yoke, M2x10 for the switches, and an M3x3 set screw that clamps the
2770
2795
  pen), each cap screw in a pilot has the thread its rule set's `pilot_depth` asks, and a hex key reaches every head,
2771
2796
  the bridge's and the spindle's before the parts above them go on.
2772
- - `motor.driver` gives 0.25 V on each trimmer for 0.5 A. `power.supply`: the machine draws under 1 A at 24 V, and an
2773
- LRS-50-24 gives 2.2 A.
2774
- - `cad list` is the shopping list: 440 g of printing in 20 parts, about 8 hours, and everything bought, the screws
2775
- included: 33 of them and the yoke's two nuts, 30 g, each length the one the check chose. `cad wires` is the
2776
- wiring sheet: each wire's length through the arm's whole range, its gauge, its colours and its board pins.
2797
+ - `motor.driver` gives 0.25 V on each trimmer for 0.5 A at 1/8 step. `power.supply`: the machine draws 0.5 A at 12 V
2798
+ (6 W), and the bench supply, its limit at 1.5 A, gives three times that.
2799
+ - `cad list` is the shopping list: 439 g of printing in 20 parts, about 8 hours, and everything bought, the screws
2800
+ included: 33 of them and the yoke's two nuts, 30 g, each length the one the check chose. What is to buy comes first
2801
+ (the 6800 and the two 10T85 switches, the screws, the wire), then what is in hand (the two 17HS4401s, the drivers,
2802
+ the shield, the supply, the SG90). `cad wires` is the wiring sheet: each wire's length through the arm's whole range,
2803
+ its gauge, its colours and its board pins, the supply's two wires carrying 12 V into the shield.
2777
2804
  - `cad machine` writes `exports/arm/arm.machine.json`: steps per degree, 168.9 at 1/8 step through 38:1, the rates and the
2778
2805
  homing. `cad plot` plans the test drawing, a 100 mm square and a circle, in 15 s, and the preview in `.preview/arm/`
2779
2806
  animates it. `cad plot --calibrate` writes the calibration drawing the same way.
@@ -2798,20 +2825,20 @@ The task is a box of points in front of the arm, 80 mm deep and 120 mm tall, wit
2798
2825
 
2799
2826
  | | Drawing (chapter 12) | Lifting (this chapter) |
2800
2827
  |---|---|---|
2801
- | Load on the shoulder | 0.2 N m of pen drag, inertia and bias, no gravity | 1.02 N m, the arm's own weight and 100 g, at the far end of the box |
2802
- | Shoulder motor at 0.5 A | 8 times over | 1.7 times over: under the 2 times the check asks for |
2803
- | Current | 0.5 A a coil | 0.8 A a coil for the shoulder, 2.65 times over; the elbow stays at 0.5 A |
2804
- | What the links do | 0.3 N of drag sideways, about 0.02 mm | 5.7 N of weight in their plane: the tool drops 1.8 mm, the biggest term in the budget |
2805
- | What the 6800 sees | The pen's drag | 0.134 N m of tipping and 5.7 N across it: 24 N equivalent, against 925 N |
2828
+ | Load on the shoulder | 0.22 N m of pen drag, inertia and bias, no gravity | 1.15 N m, the arm's own weight and 100 g, at the far end of the box |
2829
+ | Shoulder motor at 0.5 A, 12 V | 7.3 times over | 1.4 times over: under the 2 times the check asks for |
2830
+ | Current | 0.5 A a coil | 0.8 A a coil for the shoulder, 2.2 times over; the elbow stays at 0.5 A |
2831
+ | What the links do | 0.3 N of drag sideways, about 0.02 mm | 6.6 N of weight in their plane: the tool drops 2.1 mm, the biggest term in the budget |
2832
+ | What the 6800 sees | The pen's drag | 0.189 N m of tipping and 6.6 N across it: 33 N equivalent, against 925 N |
2806
2833
  | The budget | 0.3 mm | 2.5 mm: a gripper, not a pen |
2807
2834
 
2808
- The shoulder has to hold the arm up, and the way to read that is the worst pose: the arm stretched forward with its elbow up, the tool at the box's far side, the masses all as far out as they get. `motor.torque` looks at each loaded joint with its motor run through its range, and at each pose of the assembly. The assembly is drawn in that far pose (named `reach`), so that sweep passes through it. The shoulder needs 1.016 N m and has 2.69 N m at 0.8 A through the 38:1 gearbox: 2.65 times over. The kit's other torque figure, `motor.accel`, is worked out across all the box's sampled points: at the worst of them there is still 0.104 N m left at the motor to accelerate with.
2835
+ The shoulder has to hold the arm up, and the way to read that is the worst pose: the arm stretched forward with its elbow up, the tool at the box's far side, the masses all as far out as they get. `motor.torque` looks at each loaded joint with its motor run through its range, and at each pose of the assembly. The assembly is drawn in that far pose (named `reach`), so that sweep passes through it. The shoulder needs 1.153 N m and has 2.56 N m at 0.8 A on 12 V through the 38:1 gearbox: 2.2 times over. The kit's other torque figure, `motor.accel`, is worked out across all the box's sampled points: at the worst of them there is still 0.089 N m left at the motor to accelerate with. (With a NEMA 14 at the elbow on 24 V the shoulder needed 1.016 N m and had 2.69: 2.65 times. The 17HS4401's 90 g more at the elbow, 0.14 N m at 160 mm, and the 12 V supply's lower torque at 300 rpm take that down to 2.2.)
2809
2836
 
2810
- Why 0.8 A and not more. Chapter 12 set the current from what the arm has to do, and the same reasoning sets it here. It also sets what the arm can do to itself when it stalls: at 0.8 A the shoulder can give about 3.8 N m stalled, and that is 19 MPa of shear in the spindle's printed 10 mm shaft, against PLA's 22. A person running this arm at 0.8 A should print the spindle in PETG or put a steel shaft through it. That is the first thing that changes in the parts, and it's the sort of number a check can't fix for you.
2837
+ Why 0.8 A and not more. Chapter 12 set the current from what the arm has to do, and the same reasoning sets it here: the shoulder gives 3.2 N m an amp at 300 rpm on 12 V, so 0.72 A is the least that keeps it over the check's 2 times, and 0.8 A rounds that up. It also sets what the arm can do to itself when it stalls: at 0.8 A the shoulder can give about 3.8 N m stalled, and that is 19 MPa of shear in the spindle's printed 10 mm shaft, against PLA's 22. At 1 A the torque would be 2.8 times over, but stalled it would put about 4.8 N m on the output, 24 MPa, past PLA's 22: the shaft would break before the motor slipped. Set the shoulder's trimmer to 0.4 V (0.8 A) and the elbow's to 0.25 V, the way chapter 12 says. The machine draws 0.64 A from the 12 V supply, so the same 1.5 A limit covers it. A person running this arm at 0.8 A should print the spindle in PETG or put a steel shaft through it. That is the first thing that changes in the parts, and it's the sort of number a check can't fix for you.
2811
2838
 
2812
2839
  The loads are written in the assembly as three masses at anchors, from the mass table that `joint.moment` prints:
2813
2840
 
2814
- - `lift.upper_mass` 0.376 kg at `upper.elbow`: the upper arm, the elbow's gears and motor, treated as all at the elbow, which overstates it a little: the shoulder's figure is on the safe side.
2841
+ - `lift.upper_mass` 0.466 kg at `upper.elbow` (0.376 kg with a NEMA 14): the upper arm, the elbow's gears and motor, treated as all at the elbow, which overstates it a little: the shoulder's figure is on the safe side.
2815
2842
  - `lift.fore_mass` 0.07 kg at `forearm.cable`, about halfway along the forearm: the forearm and the elbow's output gear.
2816
2843
  - `lift.tool_mass` 0.148 kg at `gripper.tool`: the gripper, its servo and the 100 g payload.
2817
2844
 
@@ -2822,11 +2849,11 @@ The loads are written in the assembly as three masses at anchors, from the mass
2822
2849
  | Real efficiency | Backward efficiency | Back at the motor | Against the 0.025 N m detent |
2823
2850
  |---|---|---|---|
2824
2851
  | 47% (the estimate) | under 0 | 0, it can't turn backwards | holds |
2825
- | 60% | 33% | 0.009 N m | holds, 2.8 times over |
2826
- | 75% | 67% | 0.018 N m | holds, 1.4 times over |
2827
- | 85% | 82% | 0.022 N m | just holds |
2852
+ | 60% | 33% | 0.010 N m | holds, 2.5 times over |
2853
+ | 75% | 67% | 0.020 N m | holds, 1.2 times over |
2854
+ | 85% | 82% | 0.025 N m | on the edge |
2828
2855
 
2829
- The back torque there is the shoulder's 1.016 N m worst load through 38:1, times the backward efficiency: the motor's own detent torque, 0.025 N m (the catalogue's figure, an `estimate`), carries it even if the gears run much freer than anything printed is likely to. The elbow, 0.233 N m through the same box against the NEMA 14's 0.008 N m detent, holds by the same arithmetic up to 85% too, with little in hand there.
2856
+ The back torque there is the shoulder's 1.153 N m worst load through 38:1, times the backward efficiency: the motor's own detent torque, 0.025 N m (the catalogue's figure, an `estimate`), carries it even if the gears run much freer than anything printed is likely to. The elbow, 0.233 N m through the same box against the 17HS4401's 0.025 N m detent, holds by the same arithmetic five times over at 85%: the bigger motor's detent leaves more in hand there than the NEMA 14's 0.008 N m did.
2830
2857
 
2831
2858
  Three things could hold the arm with the power off: the gears' friction, a counter-spring, or a brake. A counter-spring from `@rulecad/flexures` is the usual way to take gravity off a shoulder, and it earns its place when a joint is back-drivable; it would cost a leaf spring strong enough for a newton metre across 90° of swing, a large part, for a joint that already holds. A brake is a bought part and a coil to wire for a problem the gears already solve. So the chapter chooses friction, marks it `estimate`, and bench test 14 in `examples/bench/projects/benchmarks/MEASURE.md` (the gearbox's play, measured at both directions) is where a person learns whether the efficiency is what the figures assume.
2832
2859
 
@@ -2852,7 +2879,7 @@ The rules these figures come from:
2852
2879
  "name": "lift",
2853
2880
  "rules": {
2854
2881
  "payload": {"value": 0.1, "unit": "kg", "rule": "The most the arm is rated to carry at the tool", "kind": "default", "source": "Design: the top of the range the arm is for, 50 to 100 g", "checked": "2026-11-09"},
2855
- "upper_mass": {"value": 0.376, "unit": "kg", "rule": "The upper arm, the elbow's gears, the elbow's motor and the switch: as the shoulder sees them", "kind": "derived", "source": "joint.moment's carried mass in chapter 13, less what's beyond the elbow", "checked": "2026-11-09"},
2882
+ "upper_mass": {"value": 0.466, "unit": "kg", "rule": "The upper arm, the elbow's gears, the elbow's motor (a 17HS4401, 280 g) and the switch: as the shoulder sees them", "kind": "derived", "source": "joint.moment's carried mass in chapter 13, less what's beyond the elbow: 0.376 kg with a 190 g NEMA 14, 90 g more with the 17HS4401", "checked": "2026-11-22"},
2856
2883
  "fore_mass": {"value": 0.07, "unit": "kg", "rule": "The forearm and the elbow's output gear, about", "kind": "derived", "source": "joint.moment's carried mass in chapter 13", "checked": "2026-11-09"},
2857
2884
  "tool_mass": {"value": 0.148, "unit": "kg", "rule": "The gripper with its servo and horn, and the payload", "kind": "derived", "source": "joint.moment's carried mass in chapter 13", "checked": "2026-11-09"},
2858
2885
  "grip_horn": {"value": 12.3, "unit": "mm", "rule": "The horn's lever at full close, where it's smallest (18 mm reach × cos 47°): what the servo's torque turns into the push on each finger", "kind": "derived", "source": "gripper's reach and close_a", "checked": "2026-11-09"},
@@ -3402,7 +3429,7 @@ The project lists the new objects:
3402
3429
 
3403
3430
  ### The upright assembly
3404
3431
 
3405
- `arm-upright` is `arm` from chapter 12 with five differences: the base, the housing, the bridge and its bearing are rotated 90° about the x axis and the rest follows through the joints (their positions become `[0, "0 - arm.face", 0]` and so on: a rotation of x, y, z to x, -z, y); the pen holder is replaced by the gripper on the forearm's same anchor; the task is a box of points with `payload` and `grip`; `gravity` is set to `[0, 0, -1]` as the check needs the word down; and the elbow folds only to 140°, not 160°, for the reason under the commands below. Its one pose, `reach`, is the far corner of the box: the assembly is drawn there because the shoulder's load is worst there, and "drawn" is what `motor.torque` sweeps its motor from. The fingers are straight in it, as every flexure here is. Its `fasten` list is chapter 12's, with the yoke's two screws and their nuts through the gripper where they went through the pen holder, and no set screw, since there is no pen to clamp. The check chooses each screw's length and `cad list` counts it; chapter 15 explains `fasten` in full.
3432
+ `arm-upright` is `arm` from chapter 12 with five differences: the base, the housing, the bridge and its bearing are rotated 90° about the x axis and the rest follows through the joints (their positions become `[0, "0 - arm.face", 0]` and so on: a rotation of x, y, z to x, -z, y); the pen holder is replaced by the gripper on the forearm's same anchor; the task is a box of points with `payload` and `grip`; `gravity` is set to `[0, 0, -1]` as the check needs the word down; and the elbow folds only to 140°, not 160°, for the reason under the commands below. Its one pose, `reach`, is the far corner of the box: the assembly is drawn there because the shoulder's load is worst there, and "drawn" is what `motor.torque` sweeps its motor from. The fingers are straight in it, as every flexure here is. Its gripper's SG90 is the pen lift's, moved across: the upright arm has no pen to lift, so the one SG90 on the bench serves both builds, and `"have": true` keeps it off the buy list. Its `fasten` list is chapter 12's, with the yoke's two screws and their nuts through the gripper where they went through the pen holder, and no set screw, since there is no pen to clamp. The check chooses each screw's length and `cad list` counts it; chapter 15 explains `fasten` in full.
3406
3433
 
3407
3434
  ```json projects/arm/assemblies/arm-upright.json
3408
3435
  {
@@ -3414,7 +3441,7 @@ The project lists the new objects:
3414
3441
  "uses": ["arm", "lift"],
3415
3442
  "items": [
3416
3443
  { "id": "base", "object": "base", "rotate": [90, 0, 0] },
3417
- { "id": "m1", "motor": { "model": "17HS4401", "drives": "drive", "speed": 300, "duty": 0.3, "driver": "d1", "current": 0.8, "microsteps": 8 } },
3444
+ { "id": "m1", "motor": { "model": "17HS4401", "drives": "drive", "speed": 300, "duty": 0.3, "driver": "d1", "current": 0.8, "microsteps": 8 }, "have": true },
3418
3445
  { "id": "housing", "object": "housing", "at": [0, "0 - arm.face", 0], "rotate": [90, 0, 0] },
3419
3446
  { "id": "sun", "object": "sun" },
3420
3447
  { "id": "carrier", "object": "speck" },
@@ -3424,7 +3451,7 @@ The project lists the new objects:
3424
3451
  { "id": "bridge", "object": "bridge", "at": [0, "0 - arm.bridge_low", 0], "rotate": [90, 0, 0] },
3425
3452
  { "id": "b1", "bought": "bearing-6800", "at": [0, "0 - (arm.bridge_low + arm.bridge - arm.bearing_width)", 0], "rotate": [90, 0, 0] },
3426
3453
  { "id": "upper", "object": "upper" },
3427
- { "id": "m2", "motor": { "model": "nema14", "drives": "edrive", "speed": 300, "duty": 0.3, "driver": "d2", "current": 0.5, "microsteps": 8 } },
3454
+ { "id": "m2", "motor": { "model": "17HS4401", "drives": "edrive", "speed": 300, "duty": 0.3, "driver": "d2", "current": 0.5, "microsteps": 8 }, "have": true },
3428
3455
  { "id": "esun", "object": "sun", "set": { "tip": 11.7 } },
3429
3456
  { "id": "ecarrier", "object": "speck" }, { "id": "ering", "object": "speck" },
3430
3457
  { "id": "ep1", "object": "planet" }, { "id": "ep2", "object": "planet" }, { "id": "ep3", "object": "planet" },
@@ -3432,14 +3459,14 @@ The project lists the new objects:
3432
3459
  { "id": "clip1", "object": "clip" }, { "id": "clip2", "object": "clip" }, { "id": "clip3", "object": "clip" },
3433
3460
  { "id": "forearm", "object": "forearm" },
3434
3461
  { "id": "gripper", "object": "gripper" },
3435
- { "id": "gservo", "motor": { "model": "sg90", "drives": "squeeze", "duty": 0.05 } },
3462
+ { "id": "gservo", "motor": { "model": "sg90", "drives": "squeeze", "duty": 0.05 }, "have": true },
3436
3463
  { "id": "ghorn", "object": "ghorn" },
3437
3464
  { "id": "es1", "bought": "endstop-10t85" },
3438
3465
  { "id": "es2", "bought": "endstop-10t85" },
3439
- { "id": "d1", "bought": "drv8825", "at": [-300, -30, 8] },
3440
- { "id": "d2", "bought": "drv8825", "at": [-300, 0, 8] },
3441
- { "id": "shield", "bought": "cnc-shield-v3", "at": [-300, 0, 0] },
3442
- { "id": "psu", "bought": "supply-24v", "variant": "LRS-50-24", "at": [-330, 150, 0] }
3466
+ { "id": "d1", "bought": "drv8825", "at": [-300, -30, 8], "have": true },
3467
+ { "id": "d2", "bought": "drv8825", "at": [-300, 0, 8], "have": true },
3468
+ { "id": "shield", "bought": "cnc-shield-v3", "at": [-300, 0, 0], "have": true },
3469
+ { "id": "psu", "bought": "supply-12v", "set": { "output_current": 1.5 }, "at": [-330, 150, 0], "have": true }
3443
3470
  ],
3444
3471
  "joints": [
3445
3472
  { "id": "m1_on", "type": "fixed", "parent": "housing.motor", "child": "m1.face" },
@@ -3512,7 +3539,7 @@ The project lists the new objects:
3512
3539
  { "id": "grip", "from": "gservo.connector", "to": "shield.Z", "via": ["gripper.cable", "forearm.cable", "upper.cable", "base.cable"], "gauge": "awg26", "colour": "brown, red, orange", "conductors": 3, "current": 0.7, "connectors": ["Servo JR 3 pin", "D11, 5 V, GND"] },
3513
3540
  { "id": "home1", "from": "es1.left", "to": "shield.X", "via": ["base.cable"], "gauge": "awg26", "colour": "white, black", "conductors": 2, "connectors": ["Crimped spade", "X limit and GND"] },
3514
3541
  { "id": "home2", "from": "es2.left", "to": "shield.Y", "via": ["upper.cable", "base.cable"], "gauge": "awg26", "colour": "white, black", "conductors": 2, "connectors": ["Crimped spade", "Y limit and GND"] },
3515
- { "id": "power", "from": "psu.terminals", "to": "shield.top", "gauge": "awg22", "colour": "red, black", "conductors": 2, "current": 2, "connectors": ["Ring terminal", "Screw terminal"], "note": "24 V into the shield's motor terminals" }
3542
+ { "id": "power", "from": "psu.terminals", "to": "shield.top", "gauge": "awg22", "colour": "red, black", "conductors": 2, "current": 2, "connectors": ["Ring terminal", "Screw terminal"], "note": "12 V from the bench supply, its current limit at 1.5 A, into the shield's motor terminals" }
3516
3543
  ],
3517
3544
  "loads": [
3518
3545
  { "mass": "lift.upper_mass", "at": "upper.elbow", "note": "The upper arm, the elbow's gears and its motor, worst placed at the elbow" },
@@ -4287,21 +4314,21 @@ npx cad list arm/arm-upright
4287
4314
 
4288
4315
  What it says:
4289
4316
 
4290
- - `motor.torque` passes at 2.65 and 6.1 times over at the far pose; the shoulder needs 0.8 A here, not chapter 12's 0.5, and both figures rest on the catalogue's community motor figures, an estimate until measured.
4317
+ - `motor.torque` passes at 2.22 and 6.88 times over at the far pose, on 12 V (2.65 and 6.1 on 24 V with a NEMA 14 at the elbow); the shoulder needs 0.8 A here, not chapter 12's 0.5, and both figures rest on the catalogue's community motor figures, an estimate until measured.
4291
4318
  - `motor.holds` passes both joints with the power off, on the gears' 47% (an estimate): the table above says how much that figure can rise before it stops being true, and the detent torque carries it by a wide margin.
4292
- - `joint.moment` gives the shoulder's 6800 38 times over, the elbow's clips 35. They aren't the limits; the arm's sag is.
4293
- - `link.deflection` gives 1.8 mm at full stretch from coarse FE on the whole link, an `estimate` (see above): it's the largest error in the stack, and `task.accuracy` warns at 2.08 mm worst case against the 2.5 mm budget.
4319
+ - `joint.moment` gives the shoulder's 6800 28 times over (38 with the lighter NEMA 14), the elbow's clips 35. They aren't the limits; the arm's sag is.
4320
+ - `link.deflection` gives 2.1 mm at full stretch from coarse FE on the whole link, an `estimate` (see above), 1.8 mm with the NEMA 14: the elbow motor's 90 g more bends the upper arm. It's the largest error in the stack, and `task.accuracy` warns at 2.36 mm worst case against the 2.5 mm budget (2.08 before).
4294
4321
  - `task.reach` passes with 48.9 mm in hand.
4295
4322
  - `tool.grip` warns at 100 g (1.2 times over) on `arm-upright` and passes on `gripper-check` at 50 g (2.3 times over). `tool.strain` passes at 10% of PETG's strength at full close, in the leaf the check reads as a plain cantilever (`leafModel`).
4296
4323
  - The Z axis gives 512 steps a mm, 15.5 N of force at 6 times over its 2.45 N load, and holds with the power off because of the motor's gearbox. The belt gives 102.4 steps a mm and 5.1 N, 2 times over, with 0.07 mm of stretch in the budget.
4297
4324
  - `fasten` chooses every screw and passes each: the housing's three M3x8 caps into the base, the spindle's four M3x8 countersunk, the bridge's and the clips' six M3x10, the forearm's four M3x12, the upper arm's M3x16 into the hexagon, the home switches' four M2x10, and two M3x30 with their nuts through the yoke and the gripper. Each head has room for its hex key. The one warning, the twist on the hexagon's screw, is above.
4298
- - `cad list` prints the same 444.2 g printed as `check`'s mass table, with the gripper's 37 g in it, and buys those screws with the motors' own (4 M3x6 and 4 M3x12 from their mounts): 30.3 g of fixings. The whole machine weighs about 1.3 kg before the wires and the wall.
4325
+ - `cad list` prints the same 444.2 g printed as `check`'s mass table, with the gripper's 37 g in it, and buys those screws with the motors' own (4 M3x6 and 4 M3x12 from their mounts): 30.3 g of fixings. To buy: the 6800, the two switches, the screws and the wire; in hand: the two 17HS4401s, the drivers, the shield, the bench supply and the one SG90. The whole machine weighs about 1.05 kg before the wires and the wall (the supply, the drivers and the shield have no mass in their sets).
4299
4326
 
4300
4327
  `npx cad check arm/arm-upright --sweep` swings each joint of the arm through its range and finds nothing colliding, with the finger-flat contact allowed by its `fits` entry. It earned its keep: with chapter 12's limit of 160° of fold, the sweep found the gripper's servo hitting the shoulder housing and the output ring, because the gripper is 32 mm longer than the pen holder and its servo stands up from the print. The elbow is limited to 140° here, which clears with room to spare and costs nothing, since the box needs at most about 113°. Like chapter 12's sweep it is slow, half an hour on a busy laptop, so the replay leaves it out.
4301
4328
 
4302
4329
  ### What a person would change
4303
4330
 
4304
- Read the check's output and the table at the top together, and three things stand out: the current (0.8 A against the shaft, and PETG or steel in the spindle if the arm will ever stall); the upper arm's in-plane stiffness (the 1.8 mm figure, which a person would refine by measuring, and fix by moving the elbow motor back along the arm or thickening the link across its 22 mm); the gripper's friction and grip, which rate the arm for 50 g reliably and 100 g with a pad on the jaws; and the elbow's home switch, which sits at 160° of fold, past the new 140° limit. As drawn, this arm can't home its elbow on that switch with the gripper on: a person would move the switch post and the forearm's flag to about 130°, or home the elbow against the opposite end of its travel. It's left unchanged here so that the arm's parts stay chapter 12's, and it's the one thing that stops this arm being built as it stands.
4331
+ Read the check's output and the table at the top together, and three things stand out: the current (0.8 A against the shaft, and PETG or steel in the spindle if the arm will ever stall); the upper arm's in-plane stiffness (the 2.1 mm figure, which a person would refine by measuring, and fix by moving the elbow motor back along the arm or thickening the link across its 22 mm); the gripper's friction and grip, which rate the arm for 50 g reliably and 100 g with a pad on the jaws; and the elbow's home switch, which sits at 160° of fold, past the new 140° limit. As drawn, this arm can't home its elbow on that switch with the gripper on: a person would move the switch post and the forearm's flag to about 130°, or home the elbow against the opposite end of its travel. It's left unchanged here so that the arm's parts stay chapter 12's, and it's the one thing that stops this arm being built as it stands.
4305
4332
 
4306
4333
  ### What waits on the bench
4307
4334
 
package/README.md CHANGED
@@ -628,6 +628,8 @@ An item can be a motor instead of a printed object: `{ "id": "drive", "motor": {
628
628
  - `"loads"` at the top of the assembly say what it has to do: `{ "joint": "elbow", "torque": 0.5 }` (N m), `{ "joint": "slide", "force": 12 }` (N), or `{ "mass": 0.2, "at": "forearm.tip" }` (kg, a mass carried at an anchor, whose torque at each joint comes from where the pose puts it; the check runs the motor through its range and reports the worst). `"gravity": [0, -1, 0]` says which way is down, if not `-z`.
629
629
  - A compound planetary is a `planetary` with `"output": { "ring", "planet", "teeth" }`: a second ring on the planets' second step, following them in phase.
630
630
  - `motor.torque`: what reaches the joint through the gears, against the load: a fail under 1 times, a warning under the margin. It says what its figures rest on. `motor.speed`: how fast it moves and how long its range takes. Stages pass on `stageEfficiency` of the power (0.95 a mesh, an estimate).
631
+ - A stepper's torque at speed is worked out at its driver's supply: the volts of the assembly's bought supply item (`supply-12v`, `supply-24v`), or 24 V where it has none. A stepper's torque is flat to its corner speed, 60 V / (2 L I × full steps a turn), and falls as one over the speed past it, so a 17HS4401 at 300 rpm gives 0.269 N m at full current on 12 V against 0.283 on 24 V. `motor.torque` says the volts and the rpm it read (`values.supply`, `values.rpm`).
632
+ - `"have": true` on a motor or bought item marks it as in hand: `cad list` lists it under `Bought, in hand`, apart from what is to buy (and leaves it out of the bought cost), the kit's `buy.csv` gives it the kind `in hand`, and its build page a table of its own. A printed item is refused.
631
633
  - `motor.holds`: with the power on (holding torque, or stall torque) and off (detent torque, a built-in gearbox's friction, a worm that locks, gears under 50% efficient, or `"brake": "a ratchet and pawl"` on the joint). Dropping with the power off is a warning: it may be what you want.
632
634
  - `motor.mount`: the part a motor is fastened to (a `fasten` into the motor, or a fit that `fastens`), read as drawn: how thick it is at the screw holes against the screws' size, the screws' engagement in the motor's tapped holes (the screws as bought: their length past the plate, held to the motor's `mount_hole_depth`, at least one diameter, `engagement.steel`, or it fails; a motor item's `"screw"` may name a whole screw, `"M3x8 cap"`, to check that one), and the screws' bearing on the plastic under the motor's full torque. Its screws are counted in `cad list` and `cad order` (at the length sold that stays in the motor's thread, with the key that turns them). Then the whole part bent, by FE on the part as drawn (cubes, two across the plate at the screws): the motor's weight at its centre, along `gravity` in the pose it's checked in, and its full torque (the larger of its working and holding torque), both carried into the plate where the screws clamp it. The part is held at the joint that carries it, if one does; else where it meets the printed parts it's fastened to that sit below it; failing both, on its lowest face. It reports how far the shaft's tip moves (against the driven joint's seat, where that is on the same part, since the two move together), against the printer's `fit` clearance (or the motor's `"deflection"` in mm), and the peak stress against the material's `strength`; under 2 times either fails, and says what fixes it: the plate thickness that would do (bending goes with its cube), ribs, or how much stiffer a material would have to be. Cells this coarse read a plate 10 to 20% stiff, and a cell's stress is read at its centre, so the peak is scaled up to the surface; it's an estimate, said as one. Kept in `.cache/mount`.
633
635
  - `motor.heat`: the motor's case against the softening point of the material the project prints in. Too hot says the current to set the driver to; the motor item's `current` set to it is read (the maker's rise at rated current, scaled by the current squared, as the heat is), so the check then passes.
package/lib/assembly.mjs CHANGED
@@ -39,7 +39,7 @@ import { ops as booleans } from '@rulecad/shapes';
39
39
  import { motorBuilt, motorDrives, shaftFits, loadsOf, motorChecks, shaftFit, axisOf } from './motors.mjs';
40
40
  import { runningChecks, seatFit } from './seats.mjs';
41
41
  import { seatSize } from '@rulecad/shapes';
42
- import { wiresOf, wireChecks, wireRows, wireTubes, wireRoutes } from './wires.mjs';
42
+ import { wiresOf, wireChecks } from './wires.mjs';
43
43
  import { printedParts } from './list.mjs';
44
44
  import { taskOf, taskChecks } from './task.mjs';
45
45
  import { powerChecks } from './power.mjs';
@@ -234,6 +234,7 @@ export async function buildAssembly(ref, stack = [], overrides = {}, opts = {})
234
234
  // placed by at and rotate, or by the joint whose child it is.
235
235
  const placed = []; // [it, copy], each a motion item, in order
236
236
  for (const [it, copies] of placing) {
237
+ if (it.have != null && !it.bought && !it.motor) throw new Error(`item ${it.id}: "have" marks a bought part or a motor as in hand, and ${it.id} is ${it.object ? `printed (object ${it.object})` : it.beam ? 'a beam, cut from the bar on the cut list' : 'neither'}`);
237
238
  if (it.place === false) { // built only for its values ("place": false): a board a print plate's case is sized from
238
239
  for (const c of copies) if (!c.src.sub) objects.push({ id: c.id, objName: c.src.objName, version: c.src.version, built: c.src.b, role: c.src.role, unplaced: true });
239
240
  continue;
@@ -252,7 +253,7 @@ export async function buildAssembly(ref, stack = [], overrides = {}, opts = {})
252
253
  for (const n of sub.seen) seen.add(n);
253
254
  items.push({ ...it, id, sub, role: 'part' });
254
255
  } else {
255
- objects.push({ id, objName: src.objName, version: src.version, built: src.b, role: src.role, ...(src.set ? { set: src.set } : {}), ...(src.variant ? { variant: src.variant } : {}), ...(src.bought ? { bought: src.bought } : {}), ...(src.motor ? { motor: src.motor } : {}), ...(src.beam ? { beam: src.beam } : {}), ...(src.fitting ? { fitting: src.fitting } : {}), ...(src.panel ? { panel: src.panel } : {}) });
256
+ objects.push({ id, objName: src.objName, version: src.version, built: src.b, role: src.role, ...(src.set ? { set: src.set } : {}), ...(src.variant ? { variant: src.variant } : {}), ...(src.bought ? { bought: src.bought } : {}), ...(src.motor ? { motor: src.motor } : {}), ...(src.beam ? { beam: src.beam } : {}), ...(src.fitting ? { fitting: src.fitting } : {}), ...(src.panel ? { panel: src.panel } : {}), ...(it.have === true ? { have: true } : {}) }); // ("have" on the object: a repeat's copies and a component's parts keep it)
256
257
  items.push({ ...it, id, objName: src.objName, built: src.b, version: src.version, role: src.role, ...(src.beam ? { beam: src.beam } : {}) });
257
258
  }
258
259
  }
@@ -338,6 +339,10 @@ export async function buildAssembly(ref, stack = [], overrides = {}, opts = {})
338
339
  const v = jointValues(motion, p), moved = partsAt(placeItems(motion, v));
339
340
  return { ...s, parts: moved, fastened: null, pose: typeof p === 'string' ? p : null, jointValues: v, polygons: moved.flatMap((x) => x.polygons), triangles: moved.flatMap((x) => x.triangles) };
340
341
  };
342
+ // A stepper's torque at speed follows its driver's supply: the bought supply's volts, where the assembly has one
343
+ // (power.mjs holds the same supply against the draw); with none, @rulecad/motors' default
344
+ const psu = objects.find((o) => o.bought?.part === 'supply' && !o.unplaced)?.built.values.output_voltage;
345
+ if (psu > 0) for (const d of motion?.drives ?? []) if (d.model?.type === 'stepper') d.supply = psu;
341
346
  const s = { a, project, name, items, parts, objects, fits, requires, values, num, seen, motion, wires, task, gait, fastened, hardware, joins, generated, panels, mounts, runs, guides, pose: typeof pose === 'string' ? pose : null, jointValues: jv, at,
342
347
  polygons: parts.flatMap((p) => p.polygons), triangles: parts.flatMap((p) => p.triangles) };
343
348
  return s;
@@ -741,9 +746,7 @@ export function anchorsAt(s, values = s.jointValues) {
741
746
 
742
747
  // keyCentres(layout): each key's centre, from lib/layout.mjs (kept under this name for older callers)
743
748
  export { keyCentres };
744
- export const wiresFor = (s) => wireRows(s, { placeItems, jointValues, mul });
745
- export const wireTubesOf = (s) => wireTubes(s, { placeItems, mul });
746
- export const wireRoutesOf = (s) => wireRoutes(s, { placeItems, mul });
749
+ export { wiresFor, wireTubesOf, wireRoutesOf } from './wires.mjs'; // (there, so list.mjs needn't import this module back: #278)
747
750
 
748
751
  // ---------- checks ----------
749
752
  export { closest };
@@ -651,7 +651,7 @@ function rackCheck(s, fm, f, { restsJoins, restsOn }) {
651
651
  */
652
652
  export function excitesOf(s) {
653
653
  const excites = [];
654
- for (const d of s.motion.drives ?? []) if (d.model?.stepAngle) { const rpm = workingSpeed(d.model, d.spec), at = (rpm / 60) * (360 / d.model.stepAngle); excites.push({ kind: 'step', what: `${d.id}'s full steps at ${n3(rpm, 1)} rpm`, Hz: at, from: d.spec.speed != null ? 'the motor item\'s speed' : `the working speed of a ${d.model.name}` }); }
654
+ for (const d of s.motion.drives ?? []) if (d.model?.stepAngle) { const rpm = workingSpeed(d.model, d.spec, d.supply), at = (rpm / 60) * (360 / d.model.stepAngle); excites.push({ kind: 'step', what: `${d.id}'s full steps at ${n3(rpm, 1)} rpm`, Hz: at, from: d.spec.speed != null ? 'the motor item\'s speed' : `the working speed of a ${d.model.name}` }); }
655
655
  if (s.task?.speed) { const acc = s.task.accel ?? FRAME_CHECK.ramp.value, t = s.task.speed / acc; excites.push({ kind: 'move', what: `the task's moves, ramping to ${n3(s.task.speed, 1)} mm/s in ${n3(t, 3)} s`, Hz: 1 / t, from: s.task.accel != null ? 'the task\'s speed and accel' : 'the task\'s speed and frame.ramp' }); }
656
656
  return excites;
657
657
  }
package/lib/gait.mjs CHANGED
@@ -43,7 +43,7 @@ export function gaitChecks(s, f, { jointValues, placeItems, sweepOne }) {
43
43
  for (const [id, t] of Object.entries(r.summary.torque)) {
44
44
  const j = motion.joints.find((x) => x.id === id), tr = j && trainFrom(motion, id), d = tr && motion.drives.find((x) => x.joint === tr.root);
45
45
  if (!d) { f('warn', `gait: nothing drives ${id}, so its ${n3(t, 3)} N m through the cycle isn't checked`, `gait: ${id} undriven`, { code: 'gait.torque', refs: { joint: id } }); continue; }
46
- const speed = workingSpeed(d.model, d.spec), avail = atCurrent(d.model, d.spec, performance(d.model, { speed }).motor.torque) * tr.ratio * tr.efficiency, margin = avail / t, level = margin < 1 ? 'fail' : margin < 2 ? 'warn' : 'pass';
46
+ const speed = workingSpeed(d.model, d.spec, d.supply), avail = atCurrent(d.model, d.spec, performance(d.model, { speed, supply: d.supply }).motor.torque) * tr.ratio * tr.efficiency, margin = avail / t, level = margin < 1 ? 'fail' : margin < 2 ? 'warn' : 'pass';
47
47
  f(level, `gait: ${id} needs ${n3(t, 3)} N m at its worst in the cycle, and ${d.id} gives ${n3(avail, 3)} N m there, ${n3(margin, 1)} times over`, level === 'pass' ? null : `gait: ${id} ${n3(margin, 1)}×`, { code: 'motor.torque', refs: { joint: id, item: d.id }, values: { needed: t, available: avail, margin } });
48
48
  }
49
49
  // Leg against leg, leg against body: the cycle as a sweep
package/lib/kit.mjs CHANGED
@@ -102,7 +102,7 @@ export async function writeKit(s, findings, { pictures = false, preview = null }
102
102
  // buy.csv: one row a line to buy
103
103
  const rows = [['kind', 'quantity', 'what', 'buy', 'for']];
104
104
  for (const st of list.cut?.stock ?? []) for (const b of st.buy) rows.push(['bar', b.count, `${st.profile} x ${mm(b.length)} mm`, `${b.count} x ${mm(b.length)} mm`, `the cut list's marks ${[...new Set(st.bars.flatMap((x) => x.cuts.map((c) => c.mark)))].join(', ')}`]);
105
- for (const b of list.bought.filter((x) => x.part !== 'beam')) rows.push(['bought', b.qty, `${b.set}${b.variant ? ` (${b.variant})` : ''}${b.size ? ` cut ${b.size[0]} x ${b.size[1]} mm` : ''}`, b.cost != null ? `${b.cost} ${b.currency} each` : '', b.items.join(' ')]);
105
+ for (const b of list.bought.filter((x) => x.part !== 'beam')) rows.push([b.have ? 'in hand' : 'bought', b.qty, `${b.set}${b.variant ? ` (${b.variant})` : ''}${b.size ? ` cut ${b.size[0]} x ${b.size[1]} mm` : ''}`, b.have ? 'none: in hand' : b.cost != null ? `${b.cost} ${b.currency} each` : '', b.items.join(' ')]);
106
106
  for (const f of list.fasteners) rows.push([f.kind ?? 'fixing', f.qty, f.fastener, f.packs ? `${f.packs} pack${f.packs > 1 ? 's' : ''} of ${list.totals.pack.size}` : '', f.from.join('; ')]);
107
107
  put(path.join(dir, 'buy.csv'), `${csv(rows)}\n`);
108
108
 
@@ -131,8 +131,9 @@ export async function writeKit(s, findings, { pictures = false, preview = null }
131
131
  out.push('### Bars', '', `Cut to the cut list below. Each cut takes the saw's ${mm(list.cut.rules.kerf.value)} mm kerf, and ${mm(list.cut.rules.trim.value)} mm is trimmed off each bar's first end.`, '');
132
132
  out.push(...table(['Profile', 'Buy', 'Left over, mm'], list.cut.stock.map((st) => [st.profile, st.buy.map((b) => `${b.count} x ${mm(b.length)} mm`).join(', '), mm(st.offcut ?? 0)])), '');
133
133
  }
134
- const bought = list.bought.filter((b) => b.part !== 'beam');
134
+ const bought = list.bought.filter((b) => b.part !== 'beam' && !b.have), inHand = list.bought.filter((b) => b.part !== 'beam' && b.have);
135
135
  if (bought.length) out.push('### Bought parts', '', ...table(['Qty', 'Part', 'What', 'Price each', 'Where it goes'], bought.map((b) => [b.qty, `${b.set}${b.variant ? ` (${b.variant})` : ''}${b.size ? `, cut ${b.size[0]} x ${b.size[1]} mm` : ''}`, b.part, b.cost != null ? `${b.cost} ${b.currency}` : 'not given', b.items.join(', ')])), '');
136
+ if (inHand.length) out.push('### In hand', '', 'Marked `"have"` in the assembly: nothing to buy for these.', '', ...table(['Qty', 'Part', 'What', 'Where it goes'], inHand.map((b) => [b.qty, `${b.set}${b.variant ? ` (${b.variant})` : ''}`, b.part, b.items.join(', ')])), '');
136
137
  if (list.fasteners.length) out.push('### Screws, nuts and inserts', '', ...table(['Qty', 'Fixing', 'Buy', 'Where it goes'], list.fasteners.map((f) => [f.qty, f.fastener, f.packs ? `${plural(f.packs, 'pack')} of ${list.totals.pack.size}, ${f.spare} spare` : '', f.from.join('; ')])), '');
137
138
  if (list.totals.pack) out.push(`Packs of ${list.totals.pack.size} are ${list.totals.pack.kind === 'estimate' ? 'an estimate' : `${list.totals.pack.kind}`} (${list.totals.pack.rule}).`, '');
138
139
 
package/lib/list.mjs CHANGED
@@ -11,7 +11,7 @@ import { paths } from './workspace.mjs';
11
11
  import { readJson } from './host.mjs';
12
12
  import path from 'node:path';
13
13
  import { volume } from './mesh.mjs';
14
- import { wiresFor } from './assembly.mjs';
14
+ import { wiresFor } from './wires.mjs';
15
15
  import { companions } from './fittings.mjs';
16
16
  import { cutListOf, cutListData } from './beams.mjs';
17
17
  import { cutListText, printedCost } from '@rulecad/frames';
@@ -46,8 +46,9 @@ export function shoppingList(s) {
46
46
  for (const o of s.objects) if (o.bought && !o.unplaced) {
47
47
  // (a beam by its profile and length: one line for each length cut, lib/beams.mjs)
48
48
  // (a panel by its sheet and size: lib/panels.mjs)
49
- const len = o.bought.length != null ? Number(o.bought.length.toFixed(2)) : null, size = o.bought.size ?? null, key = `${o.bought.set}|${o.bought.variant ?? ''}|${len ?? ''}|${size ?? ''}`;
50
- const line = bought.get(key) ?? { set: o.bought.set, variant: o.bought.variant, part: o.bought.part, ...(len != null ? { length: len } : {}), ...(size ? { size } : {}), qty: 0, grams: o.bought.mass != null ? o.bought.mass * 1000 : null, ...(o.bought.cost ? { cost: o.bought.cost.value, currency: o.bought.cost.unit } : {}), items: [] };
49
+ const len = o.bought.length != null ? Number(o.bought.length.toFixed(2)) : null, size = o.bought.size ?? null, inHand = o.have === true, // ("have": in hand, not to buy; set on each copy and on a component's parts by lib/assembly.mjs)
50
+ key = `${o.bought.set}|${o.bought.variant ?? ''}|${len ?? ''}|${size ?? ''}|${inHand}`;
51
+ const line = bought.get(key) ?? { set: o.bought.set, variant: o.bought.variant, part: o.bought.part, ...(len != null ? { length: len } : {}), ...(size ? { size } : {}), ...(inHand ? { have: true } : {}), qty: 0, grams: o.bought.mass != null ? o.bought.mass * 1000 : null, ...(o.bought.cost ? { cost: o.bought.cost.value, currency: o.bought.cost.unit } : {}), items: [] };
51
52
  line.qty++; line.items.push(o.id); bought.set(key, line);
52
53
  }
53
54
  // fasten.count: the hardware a fasten placed (a component's too), one part a piece; a motor's mounting screws; and a fit
@@ -83,17 +84,24 @@ export function shoppingList(s) {
83
84
  const fixingsGrams = fixings.reduce((t, f) => t + (f.mass ?? 0), 0);
84
85
  // what it costs, where prices are given: the bought items' by their sets, the printed parts' plastic by the material's
85
86
  // price a kilogram; fixings and bars are not priced, and the list says which lines have no price
86
- const priced = boughtList.filter((b) => b.cost != null), currencies = [...new Set(priced.map((b) => b.currency))];
87
+ const priced = boughtList.filter((b) => b.cost != null && !b.have), currencies = [...new Set(priced.map((b) => b.currency))];
87
88
  const plastic = printedGrams > 0 ? printedCost(printedGrams, { name: mat.name, rules: mat.cost ? { cost: mat.cost } : {} }) : null;
88
89
  const cost = priced.length || plastic ? { bought: priced.length && currencies.length === 1 ? n(priced.reduce((t, b) => t + b.cost * b.qty, 0), 2) : null, currency: currencies.length === 1 ? currencies[0] : plastic?.unit ?? null, ...(currencies.length > 1 ? { currencies } : {}),
89
- unpriced: [...new Set(boughtList.filter((b) => b.cost == null).map((b) => b.set))], printed: plastic ? n(plastic.value, 2) : null, ...(plastic ? { printedUnit: plastic.unit, printedRule: plastic.rule } : {}) } : null;
90
+ unpriced: [...new Set(boughtList.filter((b) => b.cost == null && !b.have).map((b) => b.set))], printed: plastic ? n(plastic.value, 2) : null, ...(plastic ? { printedUnit: plastic.unit, printedRule: plastic.rule } : {}) } : null;
90
91
  return { bought: boughtList, fasteners: fixings, wires: [...wires.values()], printed, cut, ...(cost ? { cost } : {}), totals: { printedGrams: n(printedGrams), boughtGrams: n(boughtGrams), fixingsGrams: n(fixingsGrams), machineGrams: n(printedGrams + boughtGrams + fixingsGrams), ...(pack && fixings.some((f) => f.packs) ? { pack } : {}), minutes: n(printed.reduce((t, p) => t + p.minutes, 0), 0), material: mat.name, ...(mat.assumed ? { densityAssumed: true } : {}), ...(unknown.length ? { noMassFor: unknown } : {}) } };
91
92
  }
92
93
 
93
94
  export function listText(ref, l) {
94
95
  const out = [`${ref}: what it takes to build`];
95
96
  const row = (a) => out.push(a.join(' '));
96
- if (l.bought.length) { out.push('', 'Bought'); for (const b of l.bought) row([` ${String(b.qty).padStart(3)} ×`, `${b.set}${b.variant ? ` (${b.variant})` : ''}${b.length != null ? ` x ${b.length} mm` : ''}${b.size ? ` cut ${b.size[0]} x ${b.size[1]} mm` : ''}`, `a ${b.part}`, b.grams != null ? `${b.grams} g each` : 'mass not given', ...(b.cost != null ? [`${b.cost} ${b.currency} each`] : []), b.items.join(', ')]); }
97
+ // (with parts in hand, those to buy come first, then what is in hand: neither is left off the list)
98
+ const boughtRow = (b) => row([` ${String(b.qty).padStart(3)} ×`, `${b.set}${b.variant ? ` (${b.variant})` : ''}${b.length != null ? ` x ${b.length} mm` : ''}${b.size ? ` cut ${b.size[0]} x ${b.size[1]} mm` : ''}`, `a ${b.part}`, b.grams != null ? `${b.grams} g each` : 'mass not given', ...(b.cost != null ? [`${b.cost} ${b.currency} each`] : []), b.items.join(', ')]);
99
+ const toBuy = l.bought.filter((b) => !b.have), inHand = l.bought.filter((b) => b.have);
100
+ if (l.bought.length && !inHand.length) { out.push('', 'Bought'); toBuy.forEach(boughtRow); }
101
+ else if (l.bought.length) {
102
+ out.push('', toBuy.length ? 'Bought, to buy' : 'Bought: nothing to buy, all in hand'); toBuy.forEach(boughtRow);
103
+ out.push('', 'Bought, in hand (marked "have" in the assembly)'); inHand.forEach(boughtRow);
104
+ }
97
105
  if (l.cut) { out.push('', `Cut list (kerf ${l.cut.rules.kerf.value} mm, trim ${l.cut.rules.trim.value} mm; a sheet for each mark: cad beams ${ref})`, ...cutListText(l.cut)); }
98
106
  if (l.fasteners.length) {
99
107
  out.push('', 'Fasteners');
package/lib/loads.mjs CHANGED
@@ -188,8 +188,8 @@ export function accelChecks(s, f, helpers, masses, payload) {
188
188
  for (const m of masses) if (beyond(motion, j, m.item)) { const X = rowsAt(base[m.item], m.centre), r = sub(X, axis.O), rad = norm(sub(r, scale(axis.Z, dot(r, axis.Z)))); I += m.kg * rad * rad; }
189
189
  if (payload && beyond(motion, j, payload.item)) { const X = rowsAt(base[payload.item], payload.point), r = sub(X, axis.O), rad = norm(sub(r, scale(axis.Z, dot(r, axis.Z)))); I += payload.kg * rad * rad; }
190
190
  for (const p of posesOf(s, jointValues).slice(0, 30)) gravity = Math.max(gravity, Math.abs(loadAt(motion, masses, payload, placeItems(motion, p.values), j, mul).torque));
191
- const m = d.model, speed = workingSpeed(m, d.spec), ratio = t.ratio, eff = t.efficiency, rotor = (m.figures.rotor_inertia?.value ?? 0) * 0.1, kgmm2 = I / (ratio * ratio * eff) + rotor; // kg mm²
192
- const avail = atCurrent(m, d.spec, performance(m, { speed }).motor.torque), left = avail - gravity / (ratio * eff), refs = { joint: id, item: d.id }, at = axis.O;
191
+ const m = d.model, speed = workingSpeed(m, d.spec, d.supply), ratio = t.ratio, eff = t.efficiency, rotor = (m.figures.rotor_inertia?.value ?? 0) * 0.1, kgmm2 = I / (ratio * ratio * eff) + rotor; // kg mm²
192
+ const avail = atCurrent(m, d.spec, performance(m, { speed, supply: d.supply }).motor.torque), left = avail - gravity / (ratio * eff), refs = { joint: id, item: d.id }, at = axis.O;
193
193
  if (left <= 0) { f('fail', `${id} stalls: ${d.id} gives ${n3(avail, 3)} N m at ${n3(speed, 0)} rpm, and the load takes ${n3(gravity / (ratio * eff), 3)} N m of it through ${n3(ratio, 1)}:1`, `${id}: stalls`, { code: 'motor.accel', at, refs, values: { available: avail, gravity } }); limits.push(0); continue; }
194
194
  const alphaMotor = (left * 1e6) / kgmm2, alpha = (alphaMotor / ratio) * (180 / Math.PI); // rad/s² at the motor, deg/s² at the joint
195
195
  limits.push(alpha);
package/lib/machine.mjs CHANGED
@@ -17,7 +17,7 @@ export function machineOf(s) {
17
17
  const t = trainFrom(motion, id), d = motion.drives.find((x) => x.joint === t.root), j = motion.joints.find((x) => x.id === id), spec = specs.get(id) ?? {};
18
18
  if (!d?.model.stepAngle) throw new Error(`${s.project}/${s.name}: joint ${id} has no stepper driving it, and a step file needs one`);
19
19
  const micro = d.spec.microsteps ?? 16, per = (360 / d.model.stepAngle) * micro, stepsPerUnit = j.type === 'prismatic' ? (per * t.ratio) / t.slide / 360 : (per * t.ratio) / 360;
20
- const rpm = workingSpeed(d.model, d.spec), maxRate = (rpm / 60) * per, home = spec.home;
20
+ const rpm = workingSpeed(d.model, d.spec, d.supply), maxRate = (rpm / 60) * per, home = spec.home;
21
21
  const homing = home ? { endstop: home.endstop, direction: home.direction ?? -1, rate: Math.round(maxRate / 8), back: Math.round(stepsPerUnit * 3) } : null;
22
22
  return { name: id, joint: id, motor: d.id, model: d.model.name, driver: d.spec.driver ?? null, stepAngle: d.model.stepAngle, microsteps: micro, ratio: r6(t.ratio), stepsPerUnit: r6(stepsPerUnit), unit: j.type === 'prismatic' ? 'mm' : 'deg', limits: (j.limits ?? j.dofs[0].slice(0, 2)).map(r6), maxRate: Math.round(maxRate), homing,
23
23
  _why: { stepAngle: `${d.model.name}.step_angle`, microsteps: d.spec.microsteps != null ? `the motor item's "microsteps" (resolution only, not accuracy)` : 'the default, 1/16 (resolution only, not accuracy)', ratio: t.stages.length ? `the train from ${t.root} to ${id}` : 'direct', maxRate: `${n3(rpm, 1)} rpm, ${d.spec.speed != null ? 'the motor item\'s speed' : `the working speed of a ${d.model.name}`}` } };
package/lib/motors.mjs CHANGED
@@ -30,7 +30,7 @@ export function motorBuilt(spec, num, id) {
30
30
  const anchors = Object.fromEntries(Object.entries(model.anchors).map(([k, a]) => [k, { at: a.origin, axis: a.axis }]));
31
31
  const values = Object.fromEntries(Object.entries(model.figures).filter(([, f]) => typeof f.value === 'number').map(([k, f]) => [k, f.value]));
32
32
  const entries = Object.entries(model.figures).map(([k, f]) => ({ name: `${model.name}.${k}`, value: f.value, unit: f.unit, rule: f.rule, kind: f.kind, source: f.source, checked: f.checked, set: model.name }));
33
- return referenceBuilt({ id, key: 'motor', objName: `motor:${model.name}`, name: model.name, parts, anchors, entries, values, extra: { motor: model, spec, bought: { set: model.name, variant: null, part: 'motor', mass: model.mass ?? null } } });
33
+ return referenceBuilt({ id, key: 'motor', objName: `motor:${model.name}`, name: model.name, parts, anchors, entries, values, extra: { motor: model, spec, bought: { set: model.name, variant: String(spec.model).toLowerCase() === model.name.toLowerCase() ? null : String(spec.model), part: 'motor', mass: model.mass ?? null } } });
34
34
  }
35
35
 
36
36
  // Which joint each motor drives, checked by name; a servo's range and a stepper's step go on the joint. The shaft
@@ -154,12 +154,13 @@ export const atCurrent = (m, spec, torque) => (m.type === 'stepper' && spec.curr
154
154
  * assembly's, else workingSpeed), at the current it's set to. motor.torque, motor.mount and fasten.load all read this one.
155
155
  * @param {{ model: object, spec: object }} d a drive (an assembly's motor item) @returns {number} N m
156
156
  */
157
- export const mountTorque = (d) => atCurrent(d.model, d.spec, performance(d.model, { speed: workingSpeed(d.model, d.spec) }).motor.torque);
157
+ export const mountTorque = (d) => atCurrent(d.model, d.spec, performance(d.model, { speed: workingSpeed(d.model, d.spec, d.supply), supply: d.supply }).motor.torque);
158
158
 
159
- // A motor's speed if the assembly doesn't say: its corner speed, its rated speed, or half its free speed
160
- export function workingSpeed(model, spec) {
159
+ // A motor's speed if the assembly doesn't say: its corner speed, its rated speed, or half its free speed (a stepper's
160
+ // at its driver's supply, volts: the assembly's, else the package's default)
161
+ export function workingSpeed(model, spec, supply) {
161
162
  if (spec.speed != null) return spec.speed;
162
- const p = performance(model, {});
163
+ const p = performance(model, { supply });
163
164
  return model.type === 'dc' ? p.limit / 2 : model.figures.pull_in_torque ? p.limit : model.type === 'servo' ? p.limit : model.type === 'brushless' ? p.limit / 4 : p.limit / 5;
164
165
  }
165
166
 
@@ -184,9 +185,9 @@ export function motorChecks(s, f, helpers, materialName) {
184
185
  else f('pass', `${d.id}'s shaft is on ${d.joint}'s axis`, null, { code: 'motor.axis', at: S });
185
186
  // Everything it drives that carries a load
186
187
  const driven = motion.joints.filter((x) => trainFrom(motion, x.id).root === d.joint).map((x) => ({ j: x, t: trainFrom(motion, x.id), load: worstLoad(motion, loads, x, d, helpers) })).filter((x) => x.load.torque > 0);
187
- const motorSpeed = workingSpeed(m, d.spec), loaded = driven.length ? driven : [];
188
+ const motorSpeed = workingSpeed(m, d.spec, d.supply), loaded = driven.length ? driven : [];
188
189
  if (!loaded.length) {
189
- const here = performance(m, { speed: motorSpeed });
190
+ const here = performance(m, { speed: motorSpeed, supply: d.supply });
190
191
  f('info', `${d.id} gives ${n3(here.motor.torque)} N m at ${n3(motorSpeed, 1)} rpm; no loads on what it drives, so nothing to check that against (add "loads")`, null, { code: 'motor.torque' });
191
192
  continue;
192
193
  }
@@ -207,12 +208,12 @@ export function motorChecks(s, f, helpers, materialName) {
207
208
  back += (still / reduction) * ηback; backOn += still / reduction;
208
209
  lines.push({ x, t, load, unit, reduction, atLead, η });
209
210
  }
210
- const speedOut = motorSpeed / loaded[0].t.ratio, rated = performance(m, { speed: motorSpeed }), avail = mountTorque(d), margin = need ? avail / need : Infinity;
211
+ const speedOut = motorSpeed / loaded[0].t.ratio, rated = performance(m, { speed: motorSpeed, supply: d.supply }), avail = mountTorque(d), margin = need ? avail / need : Infinity;
211
212
  const main = lines[0], what = main.unit === 'N m' ? `${n3(main.load.torque)} N m` : `${n3(main.load.torque, 2)} N`, gives = main.unit === 'N m' ? `${n3(avail * main.reduction * main.η)} N m` : `${n3((avail * main.reduction * main.η * Math.PI * 1000) / (main.t.slide * 180), 1)} N`;
212
213
  const trust = rated.rests.filter((k) => k !== 'spec' && k !== 'measured'), caveat = trust.length ? ` (rests on ${trust.join(' and ')} figures: measure it)` : '';
213
214
  const level = margin < 1 ? 'fail' : margin < K ? 'warn' : 'pass', fix = margin < 1 && main.t.slide == null ? ` A ratio of ${n3((main.reduction * K) / margin, 1)}:1 would give it ${K} times` : '';
214
- f(level, `${d.id} into ${main.x.id}${lines.length > 1 ? ` and ${lines.length - 1} more` : ''}: ${gives} there against ${what} needed${main.load.where ? ` (worst: ${main.load.where})` : ''}, ${n3(margin, 2)} times over${caveat}.${fix}`, level === 'pass' ? null : `${d.id}: ${n3(margin, 2)}× torque`, { code: 'motor.torque', at: at(main.x), refs: { item: d.id, joint: main.x.id }, values: { available: avail * main.reduction * main.η, needed: main.load.torque, margin } });
215
- if (d.spec.speed != null && performance(m, { speed: motorSpeed }).findings.some((x) => x.code === 'motor.speed')) f('fail', `${d.id} is asked for ${motorSpeed} rpm, past what a ${m.name} does`, `${d.id}: too fast`, { code: 'motor.speed', refs: { item: d.id } });
215
+ f(level, `${d.id} into ${main.x.id}${lines.length > 1 ? ` and ${lines.length - 1} more` : ''}: ${gives} there against ${what} needed${main.load.where ? ` (worst: ${main.load.where})` : ''}, ${n3(margin, 2)} times over${d.supply ? `, at ${n3(motorSpeed, 1)} rpm on its supply's ${n3(d.supply, 1)} V` : ''}${caveat}.${fix}`, level === 'pass' ? null : `${d.id}: ${n3(margin, 2)}× torque`, { code: 'motor.torque', at: at(main.x), refs: { item: d.id, joint: main.x.id }, values: { available: avail * main.reduction * main.η, needed: main.load.torque, margin, ...(d.supply ? { supply: d.supply, rpm: motorSpeed } : {}) } });
216
+ if (d.spec.speed != null && performance(m, { speed: motorSpeed, supply: d.supply }).findings.some((x) => x.code === 'motor.speed')) f('fail', `${d.id} is asked for ${motorSpeed} rpm, past what a ${m.name} does`, `${d.id}: too fast`, { code: 'motor.speed', refs: { item: d.id } });
216
217
  else {
217
218
  const slideRate = main.x.type === 'prismatic' ? (speedOut * 360 * main.t.slide) / 60 : null, span = slideRate ? main.x.dofs[0][1] - main.x.dofs[0][0] : 0, time = slideRate ? span / slideRate : 60 / speedOut; // along a slide's travel, or a turn
218
219
  f('info', `${main.x.id} moves at ${slideRate ? `${n3(slideRate, 2)} mm/s` : `${n3(speedOut, 2)} rpm`} with ${d.id} at ${n3(motorSpeed, 1)} rpm: ${slideRate ? 'its whole range' : 'a turn'} in ${n3(time, 1)} s`, null, { code: 'motor.speed', at: at(main.x), values: { rpm: speedOut, time } });
package/lib/motorsvg.mjs CHANGED
@@ -32,7 +32,7 @@ export function motorWork(s) {
32
32
  // The motor's curve at its output, the load and the working speed marked
33
33
  export function workCurve(w) {
34
34
  const slide = w.train.slide != null;
35
- return curve(w.drive.model, { ratio: w.train.ratio, efficiency: w.train.efficiency, ...(w.rpm != null ? { at: { speed: w.rpm, ...(slide ? {} : { load: w.needed }) } } : {}) });
35
+ return curve(w.drive.model, { ratio: w.train.ratio, efficiency: w.train.efficiency, ...(w.drive.supply ? { supply: w.drive.supply } : {}), ...(w.rpm != null ? { at: { speed: w.rpm, ...(slide ? {} : { load: w.needed }) } } : {}) });
36
36
  }
37
37
 
38
38
  // The torque through the train: from the motor's shaft, stage by stage, to the joint with the load; the load's need
package/lib/task.mjs CHANGED
@@ -101,7 +101,7 @@ function jointSpeeds(s, c) {
101
101
  return c.names.map((id) => {
102
102
  const t = trainFrom(motion, id), d = motion.drives.find((x) => x.joint === t.root);
103
103
  if (!d) return null;
104
- const rpm = workingSpeed(d.model, d.spec), output = (rpm / t.ratio) * 6; // deg/s at the joint
104
+ const rpm = workingSpeed(d.model, d.spec, d.supply), output = (rpm / t.ratio) * 6; // deg/s at the joint
105
105
  return t.slide != null ? output * t.slide : output;
106
106
  });
107
107
  }
package/lib/wires.mjs CHANGED
@@ -2,6 +2,7 @@
2
2
  // poses. A wire that won't reach the elbow at full stretch, or is too thin for what it carries, is found here rather than
3
3
  // on the bench. "wires": [{ "from": "elbow.connector", "to": "board.Y", "via": ["upper.cable"], "gauge": "awg22" }]
4
4
  import { peekRuleSet as loadRuleSet } from './rules.mjs';
5
+ import { placeItems, jointValues, mul } from '@rulecad/model-link';
5
6
 
6
7
  const n3 = (x, d = 1) => String(Number(x.toFixed(d)));
7
8
  const GAUGE = /^awg(\d{1,2})$/i;
@@ -130,3 +131,10 @@ export function wiringSheet(rows) {
130
131
  return [line(['Wire', 'From', 'To', 'Length (mm)', 'Gauge', 'Conductors', 'Colour', 'Connectors', 'Board pins', 'Carries']), line(['---', '---', '---', '---:', '---', '---:', '---', '---', '---', '---']),
131
132
  ...rows.map((w) => line([w.id, w.from, w.to, w.length, w.gauge ?? '', w.conductors, w.colour ?? '', Array.isArray(w.connectors) ? w.connectors.join(' to ') : w.connectors ?? '', w.pins ?? '', `${n3(w.current, 2)} A, ${w.why}`]))].join('\n');
132
133
  }
134
+
135
+ // An assembly's wires with model-link's placing: their rows (lengths, gauges, pins), tubes to draw and routes. Here
136
+ // rather than in assembly.mjs, which re-exports them, so list.mjs can use them without importing assembly.mjs back
137
+ // (a loop of imports, issue #278).
138
+ export const wiresFor = (s) => wireRows(s, { placeItems, jointValues, mul });
139
+ export const wireTubesOf = (s) => wireTubes(s, { placeItems, mul });
140
+ export const wireRoutesOf = (s) => wireRoutes(s, { placeItems, mul });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulecad/cad",
3
- "version": "0.7.62",
3
+ "version": "0.7.65",
4
4
  "description": "The cad command: JSCAD designs from traceable rules, checked for printing and fit, versioned by what fits, shared as links and exported as Bambu 3MF.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -70,8 +70,8 @@
70
70
  "three": "^0.186.1",
71
71
  "@rulecad/fea": "^0.2.11",
72
72
  "@rulecad/topopt": "^0.3.0",
73
- "@rulecad/flexures": "^0.5.3",
74
- "@rulecad/gears": "^0.3.2",
73
+ "@rulecad/flexures": "^0.5.4",
74
+ "@rulecad/gears": "^0.3.3",
75
75
  "@rulecad/motors": "^0.1.6",
76
76
  "@rulecad/fixings": "^0.1.5",
77
77
  "@rulecad/robots": "^0.1.2",
@@ -60,6 +60,7 @@
60
60
  "to": { "$ref": "#/$defs/vec3", "description": "A beam's end b, with from its end a" },
61
61
  "roll": { "$ref": "#/$defs/expr", "description": "Degrees a beam placed by its ends turns about its own axis, a toward b; at 0 its top faces up (+z), or +y when it stands upright" },
62
62
  "place": {},
63
+ "have": { "type": "boolean", "description": "A bought part or a motor already in hand: cad list, the kit's buy.csv and its build page list it as in hand, apart from what is to buy. Only on a bought or motor item" },
63
64
  "from": { "description": "For a beam: its end a, [x, y, z]. For an object: inputs worked out from items built before it, { input: expression }" },
64
65
  "repeat": {
65
66
  "type": "object",