Fix steppers connection. #13
This commit is contained in:
@@ -38,9 +38,9 @@ const ARM = {
|
||||
d2: 12.9, // half separation; M1 at (-d2, 0), M2 at (+d2, 0)
|
||||
l1: 85.0, // proximal link length (mm)
|
||||
l2: 110.0, // distal link length (mm)
|
||||
STEPS_PER_REV: 2048,
|
||||
STEP_ANGLE_DEG: 360 / 2048, // ≈ 0.17578125 °/step
|
||||
HOME_STEPS: { m1: 1024, m2: 0 }, // M1 (Left) at +180°, M2 (Right) at 0° (arms folded outward)
|
||||
STEPS_PER_REV: 4096,
|
||||
STEP_ANGLE_DEG: 360 / 4096, // ≈ 0.087890625 °/step
|
||||
HOME_STEPS: { m1: 2048, m2: 0 }, // M1 (Left) at +180°, M2 (Right) at 0° (arms folded outward)
|
||||
};
|
||||
|
||||
// ── WORKSPACE CONSTRAINTS ─────────────────────────────────────────
|
||||
@@ -279,13 +279,13 @@ function radToSteps(rad) {
|
||||
|
||||
function radToStepsAbsolute(rad, motor) {
|
||||
let steps = radToSteps(rad);
|
||||
// Motor 1 (Left) is constrained near 1536 steps (90 deg, UP)
|
||||
// Motor 2 (Right) is constrained near -512 steps (90 deg, UP)
|
||||
const center = motor === 1 ? 1536 : -512;
|
||||
// Motor 1 (Left) is constrained near 3072 steps (90 deg, UP)
|
||||
// Motor 2 (Right) is constrained near -1024 steps (90 deg, UP)
|
||||
const center = motor === 1 ? 3072 : -1024;
|
||||
// Snap the step position to the closest equivalent angle around the center.
|
||||
// This guarantees we always take the "top" physical path and never wrap through the bottom.
|
||||
while (steps - center > 1024) steps -= 2048;
|
||||
while (steps - center < -1024) steps += 2048;
|
||||
while (steps - center > 2048) steps -= 4096;
|
||||
while (steps - center < -2048) steps += 4096;
|
||||
return steps;
|
||||
}
|
||||
function stepsToDeg(steps) {
|
||||
|
||||
Reference in New Issue
Block a user