create-rulecad 0.3.12 → 0.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/index.mjs +54 -3
- package/machines/arm/projects/arm/assemblies/arm.json +103 -0
- package/machines/arm/projects/arm/drawings/test.svg +1 -0
- package/machines/arm/projects/arm/firmware/arm/arm.ino +149 -0
- package/machines/arm/projects/arm/objects/base.js +18 -0
- package/machines/arm/projects/arm/objects/base.json +41 -0
- package/machines/arm/projects/arm/objects/bridge.js +15 -0
- package/machines/arm/projects/arm/objects/bridge.json +32 -0
- package/machines/arm/projects/arm/objects/clip.js +9 -0
- package/machines/arm/projects/arm/objects/clip.json +20 -0
- package/machines/arm/projects/arm/objects/forearm.js +20 -0
- package/machines/arm/projects/arm/objects/forearm.json +44 -0
- package/machines/arm/projects/arm/objects/holder.js +23 -0
- package/machines/arm/projects/arm/objects/holder.json +50 -0
- package/machines/arm/projects/arm/objects/horn.js +9 -0
- package/machines/arm/projects/arm/objects/horn.json +17 -0
- package/machines/arm/projects/arm/objects/housing.js +22 -0
- package/machines/arm/projects/arm/objects/housing.json +39 -0
- package/machines/arm/projects/arm/objects/output.js +12 -0
- package/machines/arm/projects/arm/objects/output.json +28 -0
- package/machines/arm/projects/arm/objects/pen.js +9 -0
- package/machines/arm/projects/arm/objects/pen.json +17 -0
- package/machines/arm/projects/arm/objects/planet.js +9 -0
- package/machines/arm/projects/arm/objects/planet.json +20 -0
- package/machines/arm/projects/arm/objects/speck.js +5 -0
- package/machines/arm/projects/arm/objects/speck.json +17 -0
- package/machines/arm/projects/arm/objects/spindle.js +17 -0
- package/machines/arm/projects/arm/objects/spindle.json +34 -0
- package/machines/arm/projects/arm/objects/sun.js +10 -0
- package/machines/arm/projects/arm/objects/sun.json +22 -0
- package/machines/arm/projects/arm/objects/upper.js +34 -0
- package/machines/arm/projects/arm/objects/upper.json +73 -0
- package/machines/arm/projects/arm/project.json +19 -0
- package/machines/arm/projects/arm/send.mjs +70 -0
- package/machines/arm/rules/arm.json +44 -0
- package/machines/leg/projects/leg/assemblies/stand.json +101 -0
- package/machines/leg/projects/leg/objects/bridge.js +15 -0
- package/machines/leg/projects/leg/objects/bridge.json +32 -0
- package/machines/leg/projects/leg/objects/carriage.js +14 -0
- package/machines/leg/projects/leg/objects/carriage.json +34 -0
- package/machines/leg/projects/leg/objects/clip.js +9 -0
- package/machines/leg/projects/leg/objects/clip.json +20 -0
- package/machines/leg/projects/leg/objects/collar.js +11 -0
- package/machines/leg/projects/leg/objects/collar.json +19 -0
- package/machines/leg/projects/leg/objects/foot.js +11 -0
- package/machines/leg/projects/leg/objects/foot.json +21 -0
- package/machines/leg/projects/leg/objects/housing.js +22 -0
- package/machines/leg/projects/leg/objects/housing.json +39 -0
- package/machines/leg/projects/leg/objects/output.js +12 -0
- package/machines/leg/projects/leg/objects/output.json +28 -0
- package/machines/leg/projects/leg/objects/pad.js +14 -0
- package/machines/leg/projects/leg/objects/pad.json +27 -0
- package/machines/leg/projects/leg/objects/planet.js +9 -0
- package/machines/leg/projects/leg/objects/planet.json +20 -0
- package/machines/leg/projects/leg/objects/scale.js +5 -0
- package/machines/leg/projects/leg/objects/scale.json +15 -0
- package/machines/leg/projects/leg/objects/shin.js +17 -0
- package/machines/leg/projects/leg/objects/shin.json +35 -0
- package/machines/leg/projects/leg/objects/speck.js +5 -0
- package/machines/leg/projects/leg/objects/speck.json +17 -0
- package/machines/leg/projects/leg/objects/spindle.js +17 -0
- package/machines/leg/projects/leg/objects/spindle.json +34 -0
- package/machines/leg/projects/leg/objects/sun.js +10 -0
- package/machines/leg/projects/leg/objects/sun.json +22 -0
- package/machines/leg/projects/leg/objects/thigh.js +29 -0
- package/machines/leg/projects/leg/objects/thigh.json +53 -0
- package/machines/leg/projects/leg/objects/tie.js +10 -0
- package/machines/leg/projects/leg/objects/tie.json +19 -0
- package/machines/leg/projects/leg/project.json +21 -0
- package/machines/leg/rules/leg.json +42 -0
- package/package.json +6 -1
- package/template/AGENTS.md +21 -0
package/README.md
CHANGED
|
@@ -11,3 +11,19 @@ ribs and drain slots, every measurement a variable that names its rule. `--no-in
|
|
|
11
11
|
running `npm install`. It asks how you'll share models: short links keep each shared model in a secret GitHub Gist
|
|
12
12
|
(needs the `gh` command, signed in); long links carry the model and upload nothing. `--share gist` or `--share long`
|
|
13
13
|
answers in advance (without either, and with no one to ask, links stay long).
|
|
14
|
+
|
|
15
|
+
## A machine to start from
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm create rulecad my-arm --machine arm --sheet a5 --accuracy 0.3
|
|
19
|
+
cd my-arm
|
|
20
|
+
npx cad check arm/arm
|
|
21
|
+
npx cad plot arm/arm projects/arm/drawings/test.svg
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`--machine arm` also makes a two-link arm that draws: sized for a landscape A6, A5 or A4 sheet (`--sheet`, default A5) and an
|
|
25
|
+
accuracy at the pen (`--accuracy` in mm, default 0.3), with its task, bought items, wires, plates, a test drawing fitted to the
|
|
26
|
+
sheet, and the streamer for an Uno. `--machine leg` makes a leg on a test stand, for a robot of `--robot` kg (default 1.5). In a
|
|
27
|
+
terminal with neither given it asks; given a flag, or with no terminal, it uses the defaults without asking. The arm and the leg
|
|
28
|
+
are explained part by part in EXAMPLES chapters 12 and 14, and [the machines guide](https://jonibach.github.io/rulecad/docs/machines/)
|
|
29
|
+
walks the arm from task to drawing.
|
package/index.mjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// npm create rulecad [folder]: a new rulecad workspace with a design to start from (a soap tray), then npm install.
|
|
3
|
+
// --machine arm | leg start from a whole machine instead: the arm drawn on a sheet (EXAMPLES chapter 12) or a leg on a stand
|
|
4
|
+
// (chapter 14), sized when it is made, with its task, bought parts, wires and firmware
|
|
5
|
+
// --sheet a5 --accuracy 0.3 (for --machine arm), --robot 1.5 (for --machine leg): the sizes it is made to
|
|
3
6
|
// --no-install make the files only
|
|
4
7
|
// --share gist short model links: each model you share is stored in a secret GitHub Gist (needs gh, signed in)
|
|
5
8
|
// --share long links that carry the whole model (nothing is uploaded; too long for chat on bigger models)
|
|
@@ -11,8 +14,12 @@ import readline from 'node:readline/promises';
|
|
|
11
14
|
import { fileURLToPath } from 'node:url';
|
|
12
15
|
|
|
13
16
|
const args = process.argv.slice(2), install = !args.includes('--no-install');
|
|
14
|
-
|
|
15
|
-
const
|
|
17
|
+
const VALUED = new Set(['--share', '--machine', '--sheet', '--accuracy', '--robot']);
|
|
18
|
+
const optionValue = (name) => (args.includes(name) ? args[args.indexOf(name) + 1] ?? '' : null);
|
|
19
|
+
// The folder is the argument that isn't an option, or an option's value
|
|
20
|
+
const dir = path.resolve(args.find((a, i) => !a.startsWith('--') && !VALUED.has(args[i - 1])) || 'my-designs'), name = path.basename(dir);
|
|
21
|
+
const machine = optionValue('--machine'), MACHINES = ['arm', 'leg'];
|
|
22
|
+
if (machine !== null && !MACHINES.includes(machine)) { console.error(`--machine is ${MACHINES.join(' or ')} (got "${machine}")`); process.exit(1); }
|
|
16
23
|
if (fs.existsSync(dir) && fs.readdirSync(dir).length) { console.error(`${dir} isn't empty: name a new folder (npm create rulecad my-designs)`); process.exit(1); }
|
|
17
24
|
|
|
18
25
|
const TEMPLATE = fileURLToPath(new URL('./template/', import.meta.url));
|
|
@@ -34,6 +41,49 @@ fs.writeFileSync(path.join(dir, 'package.json'), `${JSON.stringify({
|
|
|
34
41
|
|
|
35
42
|
console.log(`made ${path.relative(process.cwd(), dir) || '.'}: a soap tray to start from, in projects/home`);
|
|
36
43
|
|
|
44
|
+
// A machine: copy it in, and size it to what was asked
|
|
45
|
+
const SHEETS = { a6: [148, 105], a5: [210, 148], a4: [297, 210] };
|
|
46
|
+
async function sized() {
|
|
47
|
+
const arm = machine === 'arm', o = { sheet: optionValue('--sheet'), accuracy: optionValue('--accuracy'), robot: optionValue('--robot') };
|
|
48
|
+
const asking = process.stdin.isTTY && process.stdout.isTTY && o.sheet === null && o.accuracy === null && o.robot === null;
|
|
49
|
+
if (asking) {
|
|
50
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
51
|
+
if (arm) { o.sheet = (await rl.question('Sheet to draw on (a6, a5, a4) [a5]: ')).trim() || null; o.accuracy = (await rl.question('Accuracy at the pen, in mm [0.3]: ')).trim() || null; } else o.robot = (await rl.question('Robot this leg is for, in kg [1.5]: ')).trim() || null;
|
|
52
|
+
rl.close();
|
|
53
|
+
}
|
|
54
|
+
const sheet = (o.sheet || 'a5').toLowerCase(), accuracy = o.accuracy == null ? 0.3 : Number(o.accuracy), robot = o.robot == null ? 1.5 : Number(o.robot);
|
|
55
|
+
fs.cpSync(fileURLToPath(new URL(`./machines/${machine}/`, import.meta.url)), dir, { recursive: true });
|
|
56
|
+
if (machine === 'leg') {
|
|
57
|
+
if (!(robot > 0)) { console.error(`--robot is a mass in kg (got "${o.robot}")`); process.exit(1); }
|
|
58
|
+
const file = path.join(dir, 'rules/leg.json'), rules = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
59
|
+
rules.rules.robot = { ...rules.rules.robot, value: robot };
|
|
60
|
+
fs.writeFileSync(file, `${JSON.stringify(rules, null, 2)}\n`);
|
|
61
|
+
return console.log(` a leg on its stand, for a ${robot} kg robot; its share of the weight is ${robot / 2} kg: rules/leg.json`);
|
|
62
|
+
}
|
|
63
|
+
if (!SHEETS[sheet]) { console.error(`--sheet is ${Object.keys(SHEETS).join(', ')} (got "${o.sheet}"; a larger sheet's links wouldn't fit a 256 mm bed)`); process.exit(1); }
|
|
64
|
+
if (!(accuracy > 0)) { console.error(`--accuracy is above 0 mm (got "${o.accuracy}")`); process.exit(1); }
|
|
65
|
+
const [w, h] = SHEETS[sheet], near = 70;
|
|
66
|
+
// Reach from the sheet: the far corner at 88% of the links' stretch, the shortest forearm that folds to the near edge (EXAMPLES chapter 12)
|
|
67
|
+
const far = Math.hypot(near + h, w / 2), reach = Math.round(far / 0.88);
|
|
68
|
+
let fore = 60; for (; fore < reach; fore += 5) { const upper = reach - fore; if (Math.sqrt(upper ** 2 + fore ** 2 - 2 * upper * fore * Math.cos((20 * Math.PI) / 180)) <= near) break; }
|
|
69
|
+
const upper = reach - fore;
|
|
70
|
+
const rulesFile = path.join(dir, 'rules/arm.json'), set = JSON.parse(fs.readFileSync(rulesFile, 'utf8')), label = sheet.toUpperCase();
|
|
71
|
+
Object.assign(set.rules.sheet_w, { value: w, rule: `A ${label} sheet's long side, across the arm's front` });
|
|
72
|
+
Object.assign(set.rules.sheet_h, { value: h, rule: `A ${label} sheet's short side, away from the arm` });
|
|
73
|
+
Object.assign(set.rules.upper, { value: upper }); Object.assign(set.rules.fore, { value: fore });
|
|
74
|
+
fs.writeFileSync(rulesFile, `${JSON.stringify(set, null, 2)}\n`);
|
|
75
|
+
const file = path.join(dir, 'projects/arm/assemblies/arm.json');
|
|
76
|
+
fs.writeFileSync(file, fs.readFileSync(file, 'utf8').replace('"size": "a5"', `"size": "${sheet}"`).replace('"accuracy": 0.3', `"accuracy": ${accuracy}`));
|
|
77
|
+
// A test drawing that fits the sheet: a square, and a circle in it
|
|
78
|
+
const side = Math.round(Math.min(w, h) * 0.675), svg = path.join(dir, 'projects/arm/drawings/test.svg');
|
|
79
|
+
fs.writeFileSync(svg, `<svg xmlns="http://www.w3.org/2000/svg" width="${w}mm" height="${h}mm" viewBox="0 0 ${w} ${h}"><rect id="square" x="${(w - side) / 2}" y="${(h - side) / 2}" width="${side}" height="${side}" fill="none"/><circle id="circle" cx="${w / 2}" cy="${h / 2}" r="${Math.round(side * 0.35)}" fill="none"/></svg>\n`);
|
|
80
|
+
console.log(` an arm for a landscape ${label} sheet at ${accuracy} mm: upper arm ${upper} mm, forearm ${fore} mm: rules/arm.json`);
|
|
81
|
+
}
|
|
82
|
+
if (machine) {
|
|
83
|
+
await sized();
|
|
84
|
+
fs.appendFileSync(readme, `\n## The machine\n\nA ${machine === 'arm' ? 'two-link arm that draws' : 'leg on a test stand'}, in \`projects/${machine}\`, made by \`--machine ${machine}\`: its task, bought parts, wires and firmware are in the assembly (EXAMPLES chapters 12 and 14 explain every part). \`npx cad check ${machine === 'arm' ? 'arm/arm' : 'leg/stand'}\` first.\n`);
|
|
85
|
+
}
|
|
86
|
+
|
|
37
87
|
// How models are shared: short links need somewhere to keep the model (a secret Gist); long links carry it
|
|
38
88
|
let share = args.includes('--share') ? args[args.indexOf('--share') + 1] || '' : null;
|
|
39
89
|
if (share !== null && !['gist', 'long'].includes(share)) { console.error(`--share is gist or long (got "${share}")`); process.exit(1); }
|
|
@@ -53,4 +103,5 @@ if (share === 'gist') {
|
|
|
53
103
|
: 'short links are on, but the gh command isn\'t installed or signed in: install it from cli.github.com and run gh auth login');
|
|
54
104
|
} else console.log(`model links carry the whole model${share ? '' : ' (no --share given)'}; for short ones later, add "shorten": "gist" to "targets" in cad.config.json`);
|
|
55
105
|
if (install) execSync('npm install', { cwd: dir, stdio: 'inherit' });
|
|
56
|
-
|
|
106
|
+
const start = machine === 'arm' ? 'arm/arm' : machine === 'leg' ? 'leg/stand' : 'home/soap-tray';
|
|
107
|
+
console.log(`\n cd ${path.relative(process.cwd(), dir)}\n npx cad check ${start}\n npx cad preview ${start}${machine === 'arm' ? '\n npx cad plot arm/arm projects/arm/drawings/test.svg' : ''}\n\nREADME.md says what's where.`);
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://jonibach.github.io/rulecad/schemas/assembly.schema.json",
|
|
3
|
+
"title": "SCARA arm that draws",
|
|
4
|
+
"kind": "fit",
|
|
5
|
+
"description": "A two-link arm on a bench, an A5 sheet in front of it. The task, the wires, the drivers and the supply are all here: one assembly, every output.",
|
|
6
|
+
"uses": ["arm"],
|
|
7
|
+
"items": [
|
|
8
|
+
{ "id": "base", "object": "base" },
|
|
9
|
+
{ "id": "m1", "motor": { "model": "17HS4401", "drives": "drive", "speed": 300, "duty": 0.3, "driver": "d1", "current": 0.5, "microsteps": 8 } },
|
|
10
|
+
{ "id": "housing", "object": "housing", "at": [0, 0, "arm.face"] },
|
|
11
|
+
{ "id": "sun", "object": "sun" },
|
|
12
|
+
{ "id": "carrier", "object": "speck" },
|
|
13
|
+
{ "id": "p1", "object": "planet" }, { "id": "p2", "object": "planet" }, { "id": "p3", "object": "planet" },
|
|
14
|
+
{ "id": "output", "object": "output" },
|
|
15
|
+
{ "id": "spindle", "object": "spindle" },
|
|
16
|
+
{ "id": "bridge", "object": "bridge", "at": [0, 0, "arm.bridge_low"] },
|
|
17
|
+
{ "id": "b1", "bought": "bearing-6800", "at": [0, 0, "arm.bridge_low + arm.bridge - arm.bearing_width"] },
|
|
18
|
+
{ "id": "upper", "object": "upper" },
|
|
19
|
+
{ "id": "m2", "motor": { "model": "nema14", "drives": "edrive", "speed": 300, "duty": 0.3, "driver": "d2", "current": 0.5, "microsteps": 8 } },
|
|
20
|
+
{ "id": "esun", "object": "sun", "set": { "tip": 11.7 } },
|
|
21
|
+
{ "id": "ecarrier", "object": "speck" }, { "id": "ering", "object": "speck" },
|
|
22
|
+
{ "id": "ep1", "object": "planet" }, { "id": "ep2", "object": "planet" }, { "id": "ep3", "object": "planet" },
|
|
23
|
+
{ "id": "eoutput", "object": "output" },
|
|
24
|
+
{ "id": "clip1", "object": "clip" }, { "id": "clip2", "object": "clip" }, { "id": "clip3", "object": "clip" },
|
|
25
|
+
{ "id": "forearm", "object": "forearm" },
|
|
26
|
+
{ "id": "holder", "object": "holder" },
|
|
27
|
+
{ "id": "servo", "motor": { "model": "sg90", "drives": "lift_servo", "duty": 0.05 } },
|
|
28
|
+
{ "id": "horn", "object": "horn" },
|
|
29
|
+
{ "id": "pen", "object": "pen" },
|
|
30
|
+
{ "id": "es1", "bought": "endstop-10t85" },
|
|
31
|
+
{ "id": "es2", "bought": "endstop-10t85" },
|
|
32
|
+
{ "id": "d1", "bought": "drv8825", "at": [-300, -30, 8] },
|
|
33
|
+
{ "id": "d2", "bought": "drv8825", "at": [-300, 0, 8] },
|
|
34
|
+
{ "id": "shield", "bought": "cnc-shield-v3", "at": [-300, 0, 0] },
|
|
35
|
+
{ "id": "psu", "bought": "supply-24v", "variant": "LRS-50-24", "at": [-330, 150, 0] }
|
|
36
|
+
],
|
|
37
|
+
"joints": [
|
|
38
|
+
{ "id": "m1_on", "type": "fixed", "parent": "housing.motor", "child": "m1.face" },
|
|
39
|
+
{ "id": "drive", "type": "revolute", "parent": "housing.axis", "child": "sun.axis", "min": -4570, "max": 4588, "label": "Shoulder motor" },
|
|
40
|
+
{ "id": "turn", "type": "revolute", "parent": "housing.axis", "child": "carrier.axis", "min": -4570, "max": 4588 },
|
|
41
|
+
{ "id": "s1", "type": "revolute", "parent": "carrier.a", "child": "p1.axis", "min": -30000, "max": 30000 },
|
|
42
|
+
{ "id": "s2", "type": "revolute", "parent": "carrier.b", "child": "p2.axis", "min": -30000, "max": 30000 },
|
|
43
|
+
{ "id": "s3", "type": "revolute", "parent": "carrier.c", "child": "p3.axis", "min": -30000, "max": 30000 },
|
|
44
|
+
{ "id": "out", "type": "revolute", "parent": { "item": "housing", "at": [0, 0, "arm.plate + arm.gear + arm.ring_gap"], "axis": [0, 0, 1] }, "child": "output.axis", "min": -116, "max": 125, "label": "Shoulder", "support": { "bearings": ["b1"] },
|
|
45
|
+
"errors": { "play": "arm.play_shoulder", "twist": "arm.twist_shoulder" }, "home": { "endstop": "es1.lever", "direction": -1 } },
|
|
46
|
+
{ "id": "spindle_on", "type": "fixed", "parent": "output.flange", "child": "spindle.down" },
|
|
47
|
+
{ "id": "upper_on", "type": "fixed", "parent": "spindle.seat", "child": "upper.hub" },
|
|
48
|
+
{ "id": "m2_on", "type": "fixed", "parent": "upper.motor", "child": "m2.face" },
|
|
49
|
+
{ "id": "edrive", "type": "revolute", "parent": "upper.elbow", "child": "esun.axis", "min": -5900, "max": 180, "label": "Elbow motor" },
|
|
50
|
+
{ "id": "ering_on", "type": "fixed", "parent": "upper.elbow", "child": "ering.axis" },
|
|
51
|
+
{ "id": "eturn", "type": "revolute", "parent": "upper.elbow", "child": "ecarrier.axis", "min": -5900, "max": 180 },
|
|
52
|
+
{ "id": "es1a", "type": "revolute", "parent": "ecarrier.a", "child": "ep1.axis", "min": -30000, "max": 30000 },
|
|
53
|
+
{ "id": "es2a", "type": "revolute", "parent": "ecarrier.b", "child": "ep2.axis", "min": -30000, "max": 30000 },
|
|
54
|
+
{ "id": "es3a", "type": "revolute", "parent": "ecarrier.c", "child": "ep3.axis", "min": -30000, "max": 30000 },
|
|
55
|
+
{ "id": "elbow", "type": "revolute", "parent": "upper.output", "child": "eoutput.axis", "min": 0, "max": 160, "label": "Elbow", "support": { "clips": ["clip1", "clip2", "clip3"], "pitch": 74 },
|
|
56
|
+
"errors": { "play": "arm.play_elbow", "twist": "arm.twist_elbow" }, "home": { "endstop": "es2.lever", "direction": 1 } },
|
|
57
|
+
{ "id": "c1_on", "type": "fixed", "parent": "upper.clip1", "child": "clip1.post" },
|
|
58
|
+
{ "id": "c2_on", "type": "fixed", "parent": "upper.clip2", "child": "clip2.post" },
|
|
59
|
+
{ "id": "c3_on", "type": "fixed", "parent": "upper.clip3", "child": "clip3.post" },
|
|
60
|
+
{ "id": "forearm_on", "type": "fixed", "parent": "eoutput.flange", "child": "forearm.hub" },
|
|
61
|
+
{ "id": "holder_on", "type": "fixed", "parent": "forearm.holder", "child": "holder.mount" },
|
|
62
|
+
{ "id": "servo_on", "type": "fixed", "parent": "holder.servo", "child": "servo.face" },
|
|
63
|
+
{ "id": "lift_servo", "type": "revolute", "parent": "holder.horn", "child": "horn.axis", "min": 0, "max": 20, "label": "Pen lift" },
|
|
64
|
+
{ "id": "lift", "type": "prismatic", "parent": "holder.pen", "child": "pen.tip", "min": 0, "max": 5, "follow": "lift_servo", "ratio": 0.25 },
|
|
65
|
+
{ "id": "es1_on", "type": "fixed", "parent": "base.switch", "child": "es1.left" },
|
|
66
|
+
{ "id": "es2_on", "type": "fixed", "parent": "upper.switch", "child": "es2.left" }
|
|
67
|
+
],
|
|
68
|
+
"planetary": [
|
|
69
|
+
{ "sun": "sun", "carrier": "carrier", "ring": "housing", "planets": ["p1", "p2", "p3"], "drive": "sun", "module": 1, "teeth": [18, 18, 54], "output": { "ring": "output", "planet": 21, "teeth": 57 } },
|
|
70
|
+
{ "sun": "esun", "carrier": "ecarrier", "ring": "ering", "planets": ["ep1", "ep2", "ep3"], "drive": "sun", "module": 1, "teeth": [18, 18, 54], "output": { "ring": "eoutput", "planet": 21, "teeth": 57 } }
|
|
71
|
+
],
|
|
72
|
+
"fits": [
|
|
73
|
+
{ "a": "m1", "b": "housing", "fastens": true, "min": -0.1, "note": "The shoulder motor, on its four screws, its boss seated in the plate's pocket" },
|
|
74
|
+
{ "a": "m1", "b": "sun", "shaft": true, "note": "The shaft in the sun" },
|
|
75
|
+
{ "a": "m2", "b": "esun", "shaft": true, "note": "The elbow motor's shaft in its sun" },
|
|
76
|
+
{ "a": "m2", "b": "upper", "fastens": true, "min": -0.1, "note": "The elbow motor, on its four screws, its boss seated in the plate's pocket" },
|
|
77
|
+
{ "a": "housing", "b": "base", "fastens": true, "min": 0, "note": "The housing, on the base's three columns" },
|
|
78
|
+
{ "a": "bridge", "b": "housing", "fastens": true, "min": 0, "note": "The bridge, on the housing's posts" },
|
|
79
|
+
{ "a": "b1", "b": "bridge", "seat": "press", "note": "The 6800 in its seat" },
|
|
80
|
+
{ "a": "es1", "b": "base", "fastens": true, "min": -0.1, "note": "The home switch on its post, 0.1 mm of resting contact allowed" },
|
|
81
|
+
{ "a": "es2", "b": "upper", "fastens": true, "min": -0.1, "note": "The elbow's home switch on its post" },
|
|
82
|
+
{ "a": "es1", "b": "upper", "min": -30, "note": "The arm's flag on the home switch's lever at the end of the range" },
|
|
83
|
+
{ "a": "es2", "b": "forearm", "min": -30, "note": "The forearm's flag on the elbow switch's lever" },
|
|
84
|
+
{ "a": "horn", "b": "holder", "min": -30, "note": "The horn lifts the shuttle's lug: drawn at rest, the lug doesn't rise here" },
|
|
85
|
+
{ "a": "ecarrier", "b": "ering", "min": -1, "note": "Two specks: neither is printed" },
|
|
86
|
+
{ "a": "d1", "b": "shield", "fastens": true, "min": -20, "note": "Plugged in" },
|
|
87
|
+
{ "a": "d2", "b": "shield", "fastens": true, "min": -20, "note": "Plugged in" }
|
|
88
|
+
],
|
|
89
|
+
"wires": [
|
|
90
|
+
{ "id": "shoulder", "from": "m1.connector", "to": "shield.X", "via": ["base.cable"], "gauge": "awg24", "colour": "black, red, green, blue", "connectors": ["JST-XH 4 pin", "screw terminal"], "note": "From the motor's own lead, down through the base" },
|
|
91
|
+
{ "id": "elbow", "from": "m2.connector", "to": "shield.Y", "via": ["upper.cable", "base.cable"], "gauge": "awg24", "colour": "black, red, green, blue", "connectors": ["JST-XH 4 pin", "screw terminal"] },
|
|
92
|
+
{ "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" },
|
|
93
|
+
{ "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"] },
|
|
94
|
+
{ "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"] },
|
|
95
|
+
{ "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" }
|
|
96
|
+
],
|
|
97
|
+
"loads": [
|
|
98
|
+
{ "joint": "out", "torque": "arm.shoulder_torque", "note": "The pen's drag at its reach, the arm's inertia at 500 mm/s², the bias" },
|
|
99
|
+
{ "joint": "elbow", "torque": "arm.elbow_torque", "note": "The pen's drag, the forearm's inertia, the bias" }
|
|
100
|
+
],
|
|
101
|
+
"task": { "tool": "holder.tool", "sheet": { "size": "a5", "landscape": true, "at": ["arm.near + arm.sheet_h / 2", 0, 0], "u": [0, 1, 0] }, "speed": 50, "accuracy": 0.3, "accel": 500, "elbow": "left", "deflection": "arm.deflection", "pen": { "up": 20, "down": 0 } },
|
|
102
|
+
"poses": { "rest": { "drive": -1530, "edrive": -4586, "lift_servo": 0 } }
|
|
103
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<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>
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// A streamer for an arm on an Arduino Uno with a CNC Shield V3: it takes synchronised step blocks over serial and moves.
|
|
2
|
+
// Not a general firmware. It knows nothing of the arm: cad plot does the maths and send.mjs sends the result.
|
|
3
|
+
// 115200 baud, one command a line. Every line is answered "ok" once it is taken, or "error: ..." if it can't be; send the
|
|
4
|
+
// next line only after the answer: that is the flow control, and the buffer can never overrun.
|
|
5
|
+
//
|
|
6
|
+
// e drivers on (the motors hold)
|
|
7
|
+
// d drivers off
|
|
8
|
+
// h <axis> <dir> <rate> <back> home axis 0, 1 or 2: step towards dir (1 or -1) at rate steps/s until its endstop
|
|
9
|
+
// closes, then come back off it by back steps. Answers "ok" when done, "error: endstop" if none in 60 s
|
|
10
|
+
// p <deg> <ms> the pen servo to deg, then wait ms before anything after it
|
|
11
|
+
// w <ms> wait
|
|
12
|
+
// m <a> <b> <c> <entry> <peak> <exit> <accel> <up> <down>
|
|
13
|
+
// a block: signed steps per axis, then the major axis's step rate at entry, peak and exit
|
|
14
|
+
// (steps/s), its acceleration (steps/s²), and the major steps spent speeding up and slowing down
|
|
15
|
+
// ? prints "q <pos0> <pos1> <pos2> <blocks queued>" (positions in steps, as of the last block finished)
|
|
16
|
+
// ! stop at once, empty the queue, drivers stay on: answers "ok"
|
|
17
|
+
//
|
|
18
|
+
// Timing: steps are timed in the main loop from micros(), with serial read between them, so the servo library keeps its
|
|
19
|
+
// timer. Rates of up to about 8000 steps/s on the major axis are within reach of a 16 MHz Uno. Compiled for the Uno and
|
|
20
|
+
// exercised with send.mjs --dry-run here; moving hardware is a bench test (the machine's measured milestone).
|
|
21
|
+
#include <Servo.h>
|
|
22
|
+
|
|
23
|
+
const uint8_t STEP[3] = { 2, 3, 4 }, DIR[3] = { 5, 6, 7 }, LIMIT[3] = { 9, 10, 12 }, ENABLE_PIN = 8, PEN_PIN = 11;
|
|
24
|
+
const uint8_t QUEUE = 12;
|
|
25
|
+
const long MIN_RATE = 80; // steps/s: slower than this a block would take seconds to start
|
|
26
|
+
|
|
27
|
+
enum Kind : uint8_t { MOVE, PEN, WAIT };
|
|
28
|
+
struct Block { Kind kind; long steps[3]; long major, entry, peak, exit_, accel, up, down; };
|
|
29
|
+
Block queue[QUEUE];
|
|
30
|
+
uint8_t head = 0, tail = 0;
|
|
31
|
+
inline uint8_t count() { return head >= tail ? head - tail : head + QUEUE - tail; }
|
|
32
|
+
|
|
33
|
+
Servo pen;
|
|
34
|
+
long position[3] = { 0, 0, 0 };
|
|
35
|
+
char line[96];
|
|
36
|
+
uint8_t len = 0;
|
|
37
|
+
bool pending = false; // a whole line is waiting for room in the queue
|
|
38
|
+
|
|
39
|
+
// The block being run
|
|
40
|
+
bool running = false;
|
|
41
|
+
Block cur;
|
|
42
|
+
long done = 0, acc[3];
|
|
43
|
+
unsigned long nextAt = 0, waitUntil = 0;
|
|
44
|
+
bool waiting = false;
|
|
45
|
+
float rate = 0;
|
|
46
|
+
|
|
47
|
+
void setup() {
|
|
48
|
+
Serial.begin(115200);
|
|
49
|
+
for (uint8_t i = 0; i < 3; i++) { pinMode(STEP[i], OUTPUT); pinMode(DIR[i], OUTPUT); pinMode(LIMIT[i], INPUT_PULLUP); }
|
|
50
|
+
pinMode(ENABLE_PIN, OUTPUT);
|
|
51
|
+
digitalWrite(ENABLE_PIN, HIGH); // off until asked: the shield's enable is active low
|
|
52
|
+
pen.attach(PEN_PIN);
|
|
53
|
+
Serial.println(F("arm ready"));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
void pulse(uint8_t axis) { digitalWrite(STEP[axis], HIGH); delayMicroseconds(3); digitalWrite(STEP[axis], LOW); }
|
|
57
|
+
|
|
58
|
+
bool home(uint8_t axis, int dir, long hz, long back) {
|
|
59
|
+
digitalWrite(DIR[axis], dir > 0 ? HIGH : LOW);
|
|
60
|
+
unsigned long gap = 1000000UL / hz, start = millis();
|
|
61
|
+
while (digitalRead(LIMIT[axis]) == HIGH) {
|
|
62
|
+
if (millis() - start > 60000UL) return false;
|
|
63
|
+
pulse(axis); delayMicroseconds(gap);
|
|
64
|
+
}
|
|
65
|
+
digitalWrite(DIR[axis], dir > 0 ? LOW : HIGH);
|
|
66
|
+
for (long i = 0; i < back; i++) { pulse(axis); delayMicroseconds(gap); }
|
|
67
|
+
position[axis] = 0;
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Reads longs from a line, space separated
|
|
72
|
+
const char *cursor;
|
|
73
|
+
long nextLong() { char *end; long v = strtol(cursor, &end, 10); cursor = end; return v; }
|
|
74
|
+
|
|
75
|
+
// True if the line was dealt with; false if it has to wait for room in the queue
|
|
76
|
+
bool obey() {
|
|
77
|
+
char c = line[0];
|
|
78
|
+
cursor = line + 1;
|
|
79
|
+
if (c == 'e') { digitalWrite(ENABLE_PIN, LOW); Serial.println(F("ok")); return true; }
|
|
80
|
+
if (c == 'd') { digitalWrite(ENABLE_PIN, HIGH); Serial.println(F("ok")); return true; }
|
|
81
|
+
if (c == '!') { head = tail = 0; running = false; waiting = false; Serial.println(F("ok")); return true; }
|
|
82
|
+
if (c == '?') { Serial.print(F("q ")); for (uint8_t i = 0; i < 3; i++) { Serial.print(position[i]); Serial.print(' '); } Serial.println(count()); return true; }
|
|
83
|
+
if (c == 'h') {
|
|
84
|
+
if (running || count()) return false; // home only when everything before it is finished
|
|
85
|
+
long axis = nextLong(), dir = nextLong(), hz = nextLong(), back = nextLong();
|
|
86
|
+
if (axis < 0 || axis > 2 || hz <= 0) { Serial.println(F("error: home")); return true; }
|
|
87
|
+
Serial.println(home(axis, dir, hz, back) ? F("ok") : F("error: endstop"));
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
if (c != 'm' && c != 'p' && c != 'w') { Serial.println(F("error: command")); return true; }
|
|
91
|
+
if (count() >= QUEUE - 1) return false;
|
|
92
|
+
Block &b = queue[head];
|
|
93
|
+
if (c == 'm') {
|
|
94
|
+
b.kind = MOVE;
|
|
95
|
+
for (uint8_t i = 0; i < 3; i++) b.steps[i] = nextLong();
|
|
96
|
+
b.entry = nextLong(); b.peak = nextLong(); b.exit_ = nextLong(); b.accel = nextLong(); b.up = nextLong(); b.down = nextLong();
|
|
97
|
+
b.major = max(max(labs(b.steps[0]), labs(b.steps[1])), labs(b.steps[2]));
|
|
98
|
+
if (b.major == 0 || b.peak <= 0 || b.accel <= 0) { Serial.println(F("error: block")); return true; }
|
|
99
|
+
} else if (c == 'p') { b.kind = PEN; b.major = nextLong(); b.up = nextLong(); }
|
|
100
|
+
else { b.kind = WAIT; b.up = nextLong(); }
|
|
101
|
+
head = (head + 1) % QUEUE;
|
|
102
|
+
Serial.println(F("ok"));
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
void readSerial() {
|
|
107
|
+
if (pending) { if (obey()) pending = false; else return; }
|
|
108
|
+
while (Serial.available()) {
|
|
109
|
+
char c = Serial.read();
|
|
110
|
+
if (c == '\n' || c == '\r') {
|
|
111
|
+
if (!len) continue;
|
|
112
|
+
line[len] = 0; len = 0;
|
|
113
|
+
if (!obey()) pending = true;
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (len < sizeof(line) - 1) line[len++] = c;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
void start() {
|
|
121
|
+
cur = queue[tail];
|
|
122
|
+
tail = (tail + 1) % QUEUE;
|
|
123
|
+
if (cur.kind == PEN) { pen.write(cur.major); waitUntil = millis() + cur.up; waiting = true; return; }
|
|
124
|
+
if (cur.kind == WAIT) { waitUntil = millis() + cur.up; waiting = true; return; }
|
|
125
|
+
for (uint8_t i = 0; i < 3; i++) { digitalWrite(DIR[i], cur.steps[i] < 0 ? LOW : HIGH); acc[i] = cur.major / 2; }
|
|
126
|
+
rate = max(cur.entry, MIN_RATE);
|
|
127
|
+
done = 0; running = true; nextAt = micros();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
void tick() {
|
|
131
|
+
if ((long)(micros() - nextAt) < 0) return;
|
|
132
|
+
for (uint8_t i = 0; i < 3; i++) {
|
|
133
|
+
acc[i] += labs(cur.steps[i]);
|
|
134
|
+
if (acc[i] >= cur.major) { acc[i] -= cur.major; pulse(i); position[i] += cur.steps[i] < 0 ? -1 : 1; }
|
|
135
|
+
}
|
|
136
|
+
done++;
|
|
137
|
+
if (done >= cur.major) { running = false; return; }
|
|
138
|
+
// Constant acceleration: dv = a dt, dt = 1 / v
|
|
139
|
+
if (done < cur.up) { rate += (float)cur.accel / rate; if (rate > cur.peak) rate = cur.peak; }
|
|
140
|
+
else if (done >= cur.major - cur.down) { rate -= (float)cur.accel / rate; float floor_ = max(cur.exit_, MIN_RATE); if (rate < floor_) rate = floor_; }
|
|
141
|
+
nextAt += (unsigned long)(1000000.0 / rate);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
void loop() {
|
|
145
|
+
readSerial();
|
|
146
|
+
if (waiting) { if ((long)(millis() - waitUntil) >= 0) waiting = false; return; }
|
|
147
|
+
if (running) { tick(); return; }
|
|
148
|
+
if (count()) start();
|
|
149
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// A plate with three columns and a post: first layer one square with four holes.
|
|
2
|
+
import jscad from '@jscad/modeling'
|
|
3
|
+
const { cylinder, cuboid, roundedRectangle } = jscad.primitives
|
|
4
|
+
const { extrudeLinear } = jscad.extrusions
|
|
5
|
+
const { translate, rotateZ } = jscad.transforms
|
|
6
|
+
|
|
7
|
+
export function main (v) {
|
|
8
|
+
const plate = extrudeLinear({ height: v.foot }, roundedRectangle({ size: [v.side, v.side], roundRadius: v.corner, segments: v.segments }))
|
|
9
|
+
const angles = [v.c1, v.c2, v.c3].map((a) => a * v.rad)
|
|
10
|
+
const at = (r, a) => [r * Math.cos(a), r * Math.sin(a)]
|
|
11
|
+
const columns = angles.map((a) => cylinder({ radius: v.column / 2, height: v.column_top, center: [...at(v.column_r, a), v.column_top / 2], segments: v.segments }))
|
|
12
|
+
const pilots = angles.map((a) => cylinder({ radius: v.pilot / 2, height: v.pilot_depth, center: [...at(v.column_r, a), v.column_top - v.pilot_depth / 2], segments: v.segments }))
|
|
13
|
+
const a = v.post_a * v.rad
|
|
14
|
+
const post = translate([...at(v.post_r, a), 0], rotateZ(a, cuboid({ size: [v.post_w, v.post_d, v.post_top], center: [0, 0, v.post_top / 2] })))
|
|
15
|
+
const pads = [-1, 1].map((s) => cylinder({ radius: v.switch_pilot / 2, height: v.switch_depth, center: [...at(v.post_r + s * v.switch_pitch / 2, a), v.post_top - v.switch_depth / 2], segments: v.segments }))
|
|
16
|
+
const holes = [[1, 1], [-1, 1], [1, -1], [-1, -1]].map(([x, y]) => cylinder({ radius: v.bolt / 2, height: v.foot + 1, center: [x * v.bolt_at, y * v.bolt_at, v.foot / 2], segments: v.segments }))
|
|
17
|
+
return v.ops.subtract(v.ops.union(plate, columns, post), pilots, pads, holes)
|
|
18
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://jonibach.github.io/rulecad/schemas/object.schema.json",
|
|
3
|
+
"name": "base",
|
|
4
|
+
"title": "Base: plate and motor stand",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"uses": ["x1c", "arm", "m2", "m3", "m5"],
|
|
7
|
+
"engine": "manifold",
|
|
8
|
+
"orientation": "The plate on the bed, columns up",
|
|
9
|
+
"description": "A square plate that bolts down through four corner holes, flat on the bench or upright on a stand, with three columns round the motor carrying the shoulder housing and a post for the home switch.",
|
|
10
|
+
"anchors": {
|
|
11
|
+
"top": {"at": [0, 0, "column_top"], "axis": [0, 0, 1]},
|
|
12
|
+
"cable": {"at": ["0 - side / 2", 0, "foot"], "axis": [0, 0, 1]},
|
|
13
|
+
"switch": {"at": ["(post_r + switch_pitch / 2) * cosd(post_a)", "(post_r + switch_pitch / 2) * sind(post_a)", "post_top + switch_half"], "axis": [0, 0, 1], "ref": ["0 - cosd(post_a)", "0 - sind(post_a)", 0]}
|
|
14
|
+
},
|
|
15
|
+
"variables": {
|
|
16
|
+
"side": {"value": 96, "unit": "mm", "rule": "The plate's side: round the columns, with room for the bolts", "label": "Plate", "show": true},
|
|
17
|
+
"foot": {"value": "arm.foot", "unit": "mm", "rule": "The plate's thickness"},
|
|
18
|
+
"corner": {"value": 8, "unit": "mm", "rule": "The plate's corners, rounded"},
|
|
19
|
+
"bolt": {"value": "m5.clearance", "unit": "mm", "rule": "Bolts through to the bench, or an upright stand"},
|
|
20
|
+
"bolt_at": {"value": 38, "unit": "mm", "rule": "Half the bolts' square: the same pattern on a bench and on a stand"},
|
|
21
|
+
"column_top": {"value": "arm.face", "unit": "mm", "rule": "Up to the shoulder motor's mounting face"},
|
|
22
|
+
"column_r": {"value": 37, "unit": "mm", "rule": "Round the motor's corners"},
|
|
23
|
+
"column": {"value": 10, "unit": "mm", "rule": "Solid, stiff enough for the arm's tipping load: section against 2 x the arm's weight in the chapter"},
|
|
24
|
+
"pilot": {"value": 2.9, "unit": "mm", "rule": "An M3 screw self-tapped into the column's top", "kind": "community"},
|
|
25
|
+
"pilot_depth": {"value": 16, "unit": "mm", "rule": "For an M3 × 20 through the housing's plate"},
|
|
26
|
+
"post_r": {"value": 50, "unit": "mm", "rule": "The switch post, outside the housing's posts", "interface": true},
|
|
27
|
+
"post_a": {"value": 235, "unit": "°", "rule": "Round from the front: where the upper arm's flag meets the switch's lever at the shoulder's home, -116°", "interface": true},
|
|
28
|
+
"post_w": {"value": 14, "unit": "mm", "rule": "The post's width along the radius, for the switch's two screws"},
|
|
29
|
+
"post_d": {"value": 12, "unit": "mm", "rule": "The post's depth, tangential"},
|
|
30
|
+
"post_top": {"value": "arm.bridge_low + arm.bridge - 6", "unit": "mm", "rule": "The switch lies on the post, its lever under the arm's flag"},
|
|
31
|
+
"switch_pilot": {"value": "m2.clearance - 0.6", "unit": "mm", "rule": "An M2 screw self-tapped into the post", "kind": "community"},
|
|
32
|
+
"switch_pitch": {"value": "arm.switch_pitch", "unit": "mm", "rule": "The switch's screw spacing"},
|
|
33
|
+
"switch_depth": {"value": 10, "unit": "mm", "rule": "Pilot depth for M2 × 8"},
|
|
34
|
+
"segments": {"value": 64, "rule": "Round enough"},
|
|
35
|
+
"rad": {"value": 0.017453293, "rule": "Radians in a degree"},
|
|
36
|
+
"c1": {"value": 90, "unit": "°", "rule": "First column, between the motor's corners"},
|
|
37
|
+
"c2": {"value": 210, "unit": "°", "rule": "Second column"},
|
|
38
|
+
"c3": {"value": 330, "unit": "°", "rule": "Third column"},
|
|
39
|
+
"switch_half": {"value": 3, "unit": "mm", "rule": "Half the switch's thickness: it lies on the post, its screws straight down"}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// A three-armed plate over the gearbox, the bearing's seat in the middle.
|
|
2
|
+
import jscad from '@jscad/modeling'
|
|
3
|
+
const { cylinder, cuboid } = jscad.primitives
|
|
4
|
+
const { rotateZ } = jscad.transforms
|
|
5
|
+
|
|
6
|
+
export function main (v) {
|
|
7
|
+
const posts = [v.p1, v.p2, v.p3].map((a) => a * v.rad), at = (a) => [v.post_r * Math.cos(a), v.post_r * Math.sin(a)]
|
|
8
|
+
const hub = cylinder({ radius: v.hub / 2, height: v.thick, center: [0, 0, v.thick / 2], segments: v.segments * 2 })
|
|
9
|
+
const arms = posts.map((a) => rotateZ(a, cuboid({ size: [v.post_r, v.lobe, v.thick], center: [v.post_r / 2, 0, v.thick / 2] })))
|
|
10
|
+
const lobes = posts.map((a) => cylinder({ radius: v.lobe / 2, height: v.thick, center: [...at(a), v.thick / 2], segments: v.segments }))
|
|
11
|
+
const seat = v.shapes.bearingSeat({ bore: v.bore, outer_diameter: v.outer, width: v.width }, { fit: 'press', relief: v.relief, through: true, printer: v.x1c, at: [0, 0, v.thick], into: '-z', lead: 0 })
|
|
12
|
+
const screws = posts.map((a) => cylinder({ radius: v.screw / 2, height: v.thick + 1, center: [...at(a), v.thick / 2], segments: v.segments }))
|
|
13
|
+
const heads = posts.map((a) => cylinder({ radius: v.head / 2, height: v.head_depth + 1, center: [...at(a), v.thick - (v.head_depth - 1) / 2], segments: v.segments }))
|
|
14
|
+
return v.ops.subtract(v.ops.union(hub, arms, lobes), seat, screws, heads)
|
|
15
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://jonibach.github.io/rulecad/schemas/object.schema.json",
|
|
3
|
+
"name": "bridge",
|
|
4
|
+
"title": "Bridge: the 6800's seat",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"uses": ["x1c", "arm", "m3"],
|
|
7
|
+
"engine": "manifold",
|
|
8
|
+
"orientation": "Upside to the sky, as it goes on: the pocket opens upward and its ledge prints flat",
|
|
9
|
+
"description": "Three arms across the housing's posts, holding the bearing that takes the output's tipping load.",
|
|
10
|
+
"anchors": {
|
|
11
|
+
"seat": {"at": [0, 0, "thick - width"], "axis": [0, 0, 1]},
|
|
12
|
+
"under": {"at": [0, 0, 0], "axis": [0, 0, 1]}
|
|
13
|
+
},
|
|
14
|
+
"variables": {
|
|
15
|
+
"thick": {"value": "arm.bridge", "unit": "mm", "rule": "The bearing's width and a ledge", "interface": true},
|
|
16
|
+
"bore": {"value": "arm.bearing_bore", "unit": "mm", "rule": "The 6800's bore"},
|
|
17
|
+
"outer": {"value": "arm.bearing_outer", "unit": "mm", "rule": "The 6800's outside"},
|
|
18
|
+
"width": {"value": "arm.bearing_width", "unit": "mm", "rule": "The 6800's width"},
|
|
19
|
+
"relief": {"value": "thick - width", "unit": "mm", "rule": "Through the ledge, so the seat prints without a bridge"},
|
|
20
|
+
"hub": {"value": 34, "unit": "mm", "rule": "Round the pocket, three lines and more of wall"},
|
|
21
|
+
"post_r": {"value": 37, "unit": "mm", "rule": "On the housing's posts"},
|
|
22
|
+
"lobe": {"value": 12, "unit": "mm", "rule": "Each arm's width"},
|
|
23
|
+
"p1": {"value": 30, "unit": "°", "rule": "First post"},
|
|
24
|
+
"p2": {"value": 150, "unit": "°", "rule": "Second post"},
|
|
25
|
+
"p3": {"value": 270, "unit": "°", "rule": "Third post"},
|
|
26
|
+
"rad": {"value": 0.017453293, "rule": "Radians in a degree"},
|
|
27
|
+
"screw": {"value": "m3.clearance + x1c.hole_comp", "unit": "mm", "rule": "M3 clearance"},
|
|
28
|
+
"head": {"value": "m3.head + 2 * x1c.fit + x1c.hole_comp", "unit": "mm", "rule": "The screw head's counterbore"},
|
|
29
|
+
"head_depth": {"value": "m3.head_height + x1c.layer", "unit": "mm", "rule": "A socket head's height, sunk, so the arm passes over"},
|
|
30
|
+
"segments": {"value": 64, "rule": "Round enough"}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// A flat tab screwed to a post, its nose over the flange.
|
|
2
|
+
import jscad from '@jscad/modeling'
|
|
3
|
+
const { cuboid, cylinder } = jscad.primitives
|
|
4
|
+
const { subtract } = jscad.booleans
|
|
5
|
+
|
|
6
|
+
export function main (v) {
|
|
7
|
+
const tab = cuboid({ size: [v.reach + v.back, v.wide, v.thick], center: [(v.back - v.reach) / 2, 0, v.thick / 2] })
|
|
8
|
+
return subtract(tab, cylinder({ radius: v.hole / 2, height: v.thick + 1, center: [0, 0, v.thick / 2], segments: v.segments }))
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://jonibach.github.io/rulecad/schemas/object.schema.json",
|
|
3
|
+
"name": "clip",
|
|
4
|
+
"title": "Retaining clip",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"uses": ["x1c", "m3"],
|
|
7
|
+
"orientation": "Flat on the bed",
|
|
8
|
+
"description": "Holds the elbow's output ring from dropping off its posts.",
|
|
9
|
+
"anchors": {
|
|
10
|
+
"post": {"at": [0, 0, 0], "axis": [0, 0, 1], "ref": [1, 0, 0]}
|
|
11
|
+
},
|
|
12
|
+
"variables": {
|
|
13
|
+
"reach": {"value": 6, "unit": "mm", "rule": "In over the flange's edge, 4 mm"},
|
|
14
|
+
"back": {"value": 4, "unit": "mm", "rule": "Round the post"},
|
|
15
|
+
"wide": {"value": 8, "unit": "mm", "rule": "As wide as the post and a little"},
|
|
16
|
+
"thick": {"value": 3, "unit": "mm", "rule": "Fifteen layers"},
|
|
17
|
+
"hole": {"value": "m3.clearance + x1c.hole_comp", "unit": "mm", "rule": "M3 clearance"},
|
|
18
|
+
"segments": {"value": 24, "rule": "Small round hole"}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// A short bar from the elbow's output to a yoke round the pen holder's block.
|
|
2
|
+
import jscad from '@jscad/modeling'
|
|
3
|
+
const { cylinder, cuboid, circle, rectangle } = jscad.primitives
|
|
4
|
+
const { translate } = jscad.transforms
|
|
5
|
+
const { extrudeLinear } = jscad.extrusions
|
|
6
|
+
const { hull } = jscad.hulls
|
|
7
|
+
|
|
8
|
+
export function main (v) {
|
|
9
|
+
const endWide = v.block + v.cheek * 2, tip = v.long + v.reach
|
|
10
|
+
const dot = (r, x) => translate([x, 0], circle({ radius: r, segments: v.segments }))
|
|
11
|
+
const bar = extrudeLinear({ height: v.bar }, hull(dot(v.wide / 2, 0), rectangle({ size: [1, endWide], center: [tip - 1 / 2, 0] })))
|
|
12
|
+
const boss = cylinder({ radius: v.boss_d / 2, height: v.boss, center: [0, 0, v.boss / 2], segments: v.segments * 2 })
|
|
13
|
+
const slot = cuboid({ size: [tip + 1 - (v.long - v.slot_from), v.block + v.slot_fit, v.bar + 1], center: [(tip + 1 + v.long - v.slot_from) / 2, 0, v.bar / 2] })
|
|
14
|
+
const holes = [-1, 1].map((s) => v.shapes.teardropHole({ d: v.screw, length: endWide + 1, at: [v.long + s * v.pitch, 0 - endWide / 2 - 1 / 2, v.mid], into: '+y', through: true }))
|
|
15
|
+
const bolts = Array.from({ length: v.bolts }, (_, k) => cylinder({ radius: v.screw / 2, height: v.boss + 1, center: [v.bolt * Math.cos(k * v.quarter), v.bolt * Math.sin(k * v.quarter), v.boss / 2], segments: v.segments }))
|
|
16
|
+
const heads = Array.from({ length: v.bolts }, (_, k) => cylinder({ radius: v.head / 2, height: v.head_depth + 1, center: [v.bolt * Math.cos(k * v.quarter), v.bolt * Math.sin(k * v.quarter), (v.head_depth - 1) / 2], segments: v.segments }))
|
|
17
|
+
const flag = cuboid({ size: [v.flag_wide, v.flag_thick, v.flag_h], center: [v.flag_x, v.flag_y, v.bar + v.flag_h / 2] })
|
|
18
|
+
const band = cylinder({ radius: v.bias_d / 2, height: v.bar + 1, center: [v.bias_at, 0, v.bar / 2], segments: v.segments })
|
|
19
|
+
return v.ops.subtract(v.ops.union(bar, boss, flag), slot, holes, bolts, heads, band)
|
|
20
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://jonibach.github.io/rulecad/schemas/object.schema.json",
|
|
3
|
+
"name": "forearm",
|
|
4
|
+
"title": "Forearm",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"uses": ["x1c", "arm", "m3"],
|
|
7
|
+
"engine": "manifold",
|
|
8
|
+
"orientation": "The bar flat on the bed, the boss and flag up",
|
|
9
|
+
"anchors": {
|
|
10
|
+
"hub": {"at": [0, 0, "boss"], "axis": [0, 0, -1], "ref": [1, 0, 0]},
|
|
11
|
+
"holder": {"at": ["long", 0, "mid"], "axis": [0, 1, 0], "ref": [1, 0, 0]},
|
|
12
|
+
"flag": {"at": ["flag_x", "flag_y", "bar + flag_h"], "axis": [0, 0, 1]},
|
|
13
|
+
"cable": {"at": ["long / 2", 0, "bar"], "axis": [0, 0, 1]}
|
|
14
|
+
},
|
|
15
|
+
"variables": {
|
|
16
|
+
"long": {"value": "arm.fore - pen_x", "unit": "mm", "rule": "To the holder's bolts: the 110 mm link less the holder's own reach", "label": "Forearm", "show": true, "interface": true},
|
|
17
|
+
"pen_x": {"value": 54, "unit": "mm", "rule": "From the holder's bolts to the pen, its own reach"},
|
|
18
|
+
"bar": {"value": 8, "unit": "mm", "rule": "Thickness, sized in the chapter"},
|
|
19
|
+
"wide": {"value": 20, "unit": "mm", "rule": "Width by the boss"},
|
|
20
|
+
"mid": {"value": "arm.arm_mid", "unit": "mm", "rule": "Half the thickness"},
|
|
21
|
+
"boss": {"value": "arm.boss", "unit": "mm", "rule": "The bar passes under the elbow's clips, the boss above reaches the flange"},
|
|
22
|
+
"boss_d": {"value": 46, "unit": "mm", "rule": "Round the 40 mm bolt circle"},
|
|
23
|
+
"screw": {"value": "m3.clearance + x1c.hole_comp", "unit": "mm", "rule": "M3 clearance"},
|
|
24
|
+
"head": {"value": "m3.head + 2 * x1c.fit + x1c.hole_comp", "unit": "mm", "rule": "The screw's head, counterbored in the bed side"},
|
|
25
|
+
"head_depth": {"value": "m3.head_height + x1c.layer", "unit": "mm", "rule": "Sunk"},
|
|
26
|
+
"bolt": {"value": 20, "unit": "mm", "rule": "The output's bolt circle, radius"},
|
|
27
|
+
"bolts": {"value": 4, "rule": "On the bolt circle"},
|
|
28
|
+
"quarter": {"value": 1.57079633, "rule": "A quarter turn in radians"},
|
|
29
|
+
"block": {"value": 16, "unit": "mm", "rule": "The holder's thickness, between the cheeks"},
|
|
30
|
+
"cheek": {"value": 6, "unit": "mm", "rule": "Each cheek's thickness"},
|
|
31
|
+
"slot_fit": {"value": "x1c.fit + x1c.hole_comp", "unit": "mm", "rule": "Across the slot, over the holder"},
|
|
32
|
+
"slot_from": {"value": 8, "unit": "mm", "rule": "The slot runs back this far before the holder's bolts"},
|
|
33
|
+
"reach": {"value": 7, "unit": "mm", "rule": "Past the bolts, to the slot's end: stops before the servo's tab"},
|
|
34
|
+
"pitch": {"value": 4, "unit": "mm", "rule": "Half the spacing between the holder's two bolts"},
|
|
35
|
+
"flag_x": {"value": 44.75, "unit": "mm", "rule": "The home flag, along the arm"},
|
|
36
|
+
"flag_y": {"value": 9.5, "unit": "mm", "rule": "On the cheek's far edge, past the elbow's posts: about 46 mm from the elbow"},
|
|
37
|
+
"flag_h": {"value": 12, "unit": "mm", "rule": "Up to the elbow switch's lever"},
|
|
38
|
+
"flag_wide": {"value": 5.5, "unit": "mm", "rule": "Along the arm"},
|
|
39
|
+
"flag_thick": {"value": 4, "unit": "mm", "rule": "Sideways"},
|
|
40
|
+
"segments": {"value": 64, "rule": "Round enough"},
|
|
41
|
+
"bias_d": {"value": 4, "unit": "mm", "rule": "A hole for the elbow's rubber band"},
|
|
42
|
+
"bias_at": {"value": 30, "unit": "mm", "rule": "Clear of the boss"}
|
|
43
|
+
}
|
|
44
|
+
}
|