proper relative stepper movement

This commit is contained in:
2ManyProjects 2025-09-22 00:23:57 -05:00
parent 0ac12e85c4
commit b12b413bf6

View file

@ -41,7 +41,7 @@
#define Z_MIN_PIN 46 #define Z_MIN_PIN 46
#define Z_MAX_PIN 40 #define Z_MAX_PIN 40
#define E_HOME_PIN 48 #define E_HOME_PIN 48
#define ELECTROMAGNET_RELAY_PIN 10 #define ELECTROMAGNET_RELAY_PIN 22
#define LATCH_PIN 11 #define LATCH_PIN 11
//Mem addresses //Mem addresses
@ -208,38 +208,46 @@ void calibrateAndHome() {
Serial.println("Starting calibration"); Serial.println("Starting calibration");
calibrateEndEffectorCarousal(); // calibrateEndEffectorCarousal();
delay(2500); // delay(500);
// moveEffectorIndex(1); // moveEffectorIndex(1);
// delay(2500); // delay(500);
// moveEffectorIndex(2); // moveEffectorIndex(2);
// delay(2500); // delay(500);
// moveEffectorIndex(3); // moveEffectorIndex(3);
// delay(2500); // delay(500);
// moveEffectorIndex(4); // moveEffectorIndex(4);
// delay(2500); // delay(500);
// moveEffectorIndex(5); // moveEffectorIndex(5);
// delay(2500); // delay(500);
// moveEffectorIndex(2); // moveEffectorIndex(0); //base position
// delay(2500); // delay(500);
// moveEffectorIndex(0);
calibrateXaxis(); calibrateXaxis();
calculateStepsPerCM(); calculateStepsPerCM();
moveToXCM(X_TRAVEL_CM / 2); moveToXCM((X_TRAVEL_CM / 2) - 0.5);
delay(2500);
calibrateZaxis(); calibrateZaxis();
calculateStepsPerCM(); calculateStepsPerCM();
moveToZCM(Z_TRAVEL_CM / 2); moveToZCM(Z_TRAVEL_CM / 4);
delay(2500); delay(2500);
calibrateYaxis(); calibrateYaxis();
calculateStepsPerCM(); calculateStepsPerCM();
moveToYCM(Y_TRAVEL_CM / 2); moveToYCM((Y_TRAVEL_CM / 6) * 5);
delay(2500); 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(); saveCalibrationData();
float zCM = 0.0; float zCM = 0.0;
@ -504,6 +512,8 @@ void moveToXCM(float xCM){
long xTarget = cmToStepsX(xCM); long xTarget = cmToStepsX(xCM);
Serial.print("Moving to: X="); Serial.print(xCM); Serial.println("cm"); 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); stepperX.moveTo(xTarget);
@ -602,8 +612,9 @@ void connectElectromagnet() {
} }
void disconnectElectromagnet() { void disconnectElectromagnet() {
Serial.println("disconnectElectromagnet");
digitalWrite(ELECTROMAGNET_RELAY_PIN, LOW); 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); servo.write(LATCH_ANGLE);
delay(500); delay(500);
} }
// cur 5 goal 2
//
void moveEffectorIndex(short index) { void moveEffectorIndex(short index) {