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_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) {