more kinematics

This commit is contained in:
PROFERIS - Mi³osz Stocki
2026-07-08 12:51:45 +02:00
parent ff373deef1
commit c457910bfa
2 changed files with 40 additions and 35 deletions
+39 -34
View File
@@ -260,70 +260,75 @@ void loop() {
// ─── Homing Routines ──────────────────────────────────────────────
void performHomingAll() {
// 1. Move against limits (M1 CCW, M2 CCW)
Serial.println("[SYS] Homing all: Phase 1 (Stall UP)");
// 1. Swing BOTH motors UP to hit the mechanism housing (stall point)
// M1 (Left) swings UP by moving CW (negative)
// M2 (Right) swings UP by moving CCW (positive)
stepper1.move(-2048);
stepper2.move(2048);
while (stepper1.distanceToGo() != 0 || stepper2.distanceToGo() != 0) {
runSteppersWithNotify();
}
// 2. At this point, BOTH are stalled against the mechanism housing.
// We know the physical angles of these stall points!
// M1 stall is at +474 steps (83.3 degrees).
// M2 stall is at +530 steps (93.1 degrees).
stepper1.setCurrentPosition(474);
stepper2.setCurrentPosition(530);
Serial.println("[SYS] Homing all: Phase 2 (Move to Outward Home)");
// 3. Move BOTH motors to their outward home positions
// M1 goes to +1024 (180 degrees, pointing Left)
// M2 goes to 0 (0 degrees, pointing Right)
stepper1.moveTo(1024);
stepper2.moveTo(2048);
while (stepper1.distanceToGo() != 0 || stepper2.distanceToGo() != 0) {
runSteppersWithNotify();
}
stepper2.setCurrentPosition(0);
// 2. Move to negative limits (CW)
stepper1.moveTo(-1050);
stepper2.move(-1300);
while (stepper1.distanceToGo() != 0 || stepper2.distanceToGo() != 0) {
runSteppersWithNotify();
}
stepper1.setCurrentPosition(0);
// 3. Move to final home position
stepper1.moveTo(550);
stepper2.moveTo(-530);
stepper2.moveTo(0);
while (stepper1.distanceToGo() != 0 || stepper2.distanceToGo() != 0) {
runSteppersWithNotify();
}
// 4. Set origin relative to this final position
stepper1.setCurrentPosition(-1024);
stepper2.setCurrentPosition(0);
// 4. Disable outputs to rest
stepper1.disableOutputs();
stepper2.disableOutputs();
Serial.println("[SYS] Homing all complete.");
}
void performHoming1() {
// M1 (Left) stalls going negative (CW)
Serial.println("[S1] Homing Motor 1: Phase 1 (Stall UP)");
stepper1.move(-2048);
while (stepper1.distanceToGo() != 0) {
runSteppersWithNotify();
}
stepper1.setCurrentPosition(0);
// Move to final home position (CCW)
stepper1.moveTo(550);
stepper1.setCurrentPosition(474);
Serial.println("[S1] Homing Motor 1: Phase 2 (Move Outward)");
stepper1.moveTo(1024);
while (stepper1.distanceToGo() != 0) {
runSteppersWithNotify();
}
stepper1.setCurrentPosition(-1024);
stepper1.disableOutputs();
Serial.println("[S1] Homing complete.");
}
void performHoming2() {
// M2 (Right) stalls going positive (CCW)
Serial.println("[S2] Homing Motor 2: Phase 1 (Stall UP)");
stepper2.move(2048);
while (stepper2.distanceToGo() != 0) {
runSteppersWithNotify();
}
stepper2.setCurrentPosition(0);
// Move to final home position (CW)
stepper2.moveTo(-530);
stepper2.setCurrentPosition(530);
Serial.println("[S2] Homing Motor 2: Phase 2 (Move Outward)");
stepper2.moveTo(0);
while (stepper2.distanceToGo() != 0) {
runSteppersWithNotify();
}
stepper2.setCurrentPosition(0);
stepper2.disableOutputs();
Serial.println("[S2] Homing complete.");
}