From b12b413bf6b4f38c730425ce4c5ed981eeee5f98 Mon Sep 17 00:00:00 2001 From: 2ManyProjects Date: Mon, 22 Sep 2025 00:23:57 -0500 Subject: [PATCH] proper relative stepper movement --- sketch/sketch.ino | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/sketch/sketch.ino b/sketch/sketch.ino index a9448d9..fa84a6f 100644 --- a/sketch/sketch.ino +++ b/sketch/sketch.ino @@ -41,7 +41,7 @@ #define Z_MIN_PIN 46 #define Z_MAX_PIN 40 #define E_HOME_PIN 48 -#define ELECTROMAGNET_RELAY_PIN 10 +#define ELECTROMAGNET_RELAY_PIN 22 #define LATCH_PIN 11 //Mem addresses @@ -208,37 +208,45 @@ void calibrateAndHome() { Serial.println("Starting calibration"); - calibrateEndEffectorCarousal(); - delay(2500); + // calibrateEndEffectorCarousal(); + // delay(500); // moveEffectorIndex(1); - // delay(2500); + // delay(500); // moveEffectorIndex(2); - // delay(2500); + // delay(500); // moveEffectorIndex(3); - // delay(2500); + // delay(500); // moveEffectorIndex(4); - // delay(2500); + // delay(500); // moveEffectorIndex(5); - // delay(2500); - // moveEffectorIndex(2); - // delay(2500); - // moveEffectorIndex(0); - - + // delay(500); + // moveEffectorIndex(0); //base position + // delay(500); calibrateXaxis(); calculateStepsPerCM(); - moveToXCM(X_TRAVEL_CM / 2); + moveToXCM((X_TRAVEL_CM / 2) - 0.5); + delay(2500); calibrateZaxis(); calculateStepsPerCM(); - moveToZCM(Z_TRAVEL_CM / 2); + moveToZCM(Z_TRAVEL_CM / 4); delay(2500); calibrateYaxis(); calculateStepsPerCM(); - moveToYCM(Y_TRAVEL_CM / 2); + moveToYCM((Y_TRAVEL_CM / 6) * 5); delay(2500); + + // Move Align with effector + + moveToXCM((X_TRAVEL_CM / 2) - 0.5); + moveToZCM(Z_TRAVEL_CM / 4); + moveToYCM((Y_TRAVEL_CM / 6) * 5); + moveToZCM(Z_TRAVEL_CM - 3.5); + moveToYCM((Y_TRAVEL_CM / 6) * 4); + connectElectromagnet(); + moveToYCM((Y_TRAVEL_CM / 6) * 5); saveCalibrationData(); @@ -504,6 +512,8 @@ void moveToXCM(float xCM){ long xTarget = cmToStepsX(xCM); Serial.print("Moving to: X="); Serial.print(xCM); Serial.println("cm"); + Serial.print("Moving to: X="); Serial.print(xTarget); Serial.println("step"); + Serial.print("Current Pos: X="); Serial.print(stepperX.currentPosition()); Serial.println("step"); stepperX.moveTo(xTarget); @@ -602,8 +612,9 @@ void connectElectromagnet() { } void disconnectElectromagnet() { + Serial.println("disconnectElectromagnet"); digitalWrite(ELECTROMAGNET_RELAY_PIN, LOW); - Serial.println("Electromagnet OFF - End effector disconnected"); + Serial.println("Electromagnet OFF"); } @@ -662,8 +673,6 @@ void latch() servo.write(LATCH_ANGLE); delay(500); } -// cur 5 goal 2 -// void moveEffectorIndex(short index) {