How to increase stepper motor speed

Hi all! I am working on a small automation project where I use several stepper motors with DM556 driver at 800pulse/rev. The first step is to home the steppers until they trigger the limit switch. The homing process is extremely slow and it won't change even if I increase the speed value in the program. Can anyone tell me what am I doing wrong and how to increase the rpm on those steppers? Here is my code.

Appreciate any help.



#include "AccelStepper.h" 
// Library created by Mike McCauley at http://www.airspayce.com/mikem/arduino/AccelStepper/

// AccelStepper Setup GRIPPER
AccelStepper stepper_GR(1, 5, 4);   // 1 = Easy Driver interface
                                  // MEGA Pin 5 connected to STEP pin of Easy Driver
                                  // MEGA Pin 4 connected to DIR pin of Easy Driver

// AccelStepper Setup STATION2
AccelStepper stepper_ST2(1, 2, 3);   // 1 = Easy Driver interface
                                  // MEGA Pin 2 connected to STEP pin of Easy Driver
                                  // MEGA Pin 3 connected to DIR pin of Easy Driver


// AccelStepper Setup STATION1
AccelStepper stepper_ST1(1, 7, 6);   // 1 = Easy Driver interface
                                  // MEGA Pin 7 connected to STEP pin of Easy Driver
                                  // MEGA Pin 6 connected to DIR pin of Easy Driver


// AccelStepper Setup STATION3
AccelStepper stepper_ST3(1, 8, 9);   // 1 = Easy Driver interface
                                  // MEGA Pin 8 connected to STEP pin of Easy Driver
                                  // MEGA Pin 9 connected to DIR pin of Easy Driver

// AccelStepper Setup TRANSPORT
AccelStepper stepper_TR(1, 10, 11);   // 1 = Easy Driver interface
                                  // MEGA Pin 10 connected to STEP pin of Easy Driver
                                  // MEGA Pin 11 connected to DIR pin of Easy Driver
// Define the Pins used
#define GR_home_SW 22
#define GR_end_SW 23
#define ST1_home_SW 24
#define ST1_end_SW 25
#define ST3_home_SW 37
#define ST3_end_SW 38
#define ST2_home_SW 52 // Pin 52 connected to Home Switch (MicroSwitch)
#define TR_home_SW 39
#define TR_pos2_SW 40
#define TR_pos3_SW 41
#define StartButton 53 // Start the rotating 
#define echoPin_St1 34 // attach pin D34 Arduino to pin Echo of HC-SR04. Station 1
#define trigPin_St1 36 //attach pin D36 Arduino to pin Trig of HC-SR04. Station 1
#define echoPin_St2 32 // attach pin D32 Arduino to pin Echo of HC-SR04. Station 2
#define trigPin_St2 33 //attach pin D33 Arduino to pin Trig of HC-SR04. Station 2
#define echoPin_St3 30 // attach pin D30 Arduino to pin Echo of HC-SR04. Station 3
#define trigPin_St3 29 //attach pin D29 Arduino to pin Trig of HC-SR04. Station 3
#define LED_St1 35 //Checking if Station1 is clear
#define LED_St2 31 //Checking if Station2 is clear
#define LED_St3 28 //Checking if Station3 is clear
#define LED 50
#define LED1 51
#define Gripper 12 // Gripper piston valve

// Stepper Travel Variables
long Travel_ST2;  // Used to store the X value entered in the Serial Monitor
int move_finished=1;  // Used to check if move is completed
long initial_homing_ST2=-1;  // Used to Home Stepper at startup
long initial_homing_GR=-1;  // Used to Home Stepper at startup
long initial_homing_ST1=-1;  // Used to Home Stepper at startup
long initial_homing_ST3=-1;  // Used to Home Stepper at startup
long initial_homing_TR=-1;  // Used to Home Stepper at startup
long end_position_ST1=1; // Used to go towards end switch
long end_position_GR=1; // Used to go towards end switch
long second_position_TR=1; // Used to go towards the Second station switch
long third_position_TR=1; // Used to go towards the Third station switch
long end_position_ST3=1; // USed to go towards the end switch
int deg; // setting up the 40deg on Station 2
int deg_ST3; //Setting up to move down one tray
long duration_St1; // variable for the duration of sound wave travel
int distance_St1; // variable for the distance measurement
long duration_St2; // variable for the duration of sound wave travel
int distance_St2; // variable for the distance measurement
long duration_St3; // variable for the duration of sound wave travel
int distance_St3; // variable for the distance measurement

void setup() {
   Serial.begin(9600);  // Start the Serial monitor with speed of 9600 Bauds

   pinMode (GR_home_SW, INPUT_PULLUP);
   pinMode (GR_end_SW, INPUT_PULLUP);
   pinMode(ST2_home_SW, INPUT_PULLUP);
   pinMode(ST1_home_SW, INPUT_PULLUP);
   pinMode(ST1_end_SW, INPUT_PULLUP);
   pinMode(ST3_home_SW, INPUT_PULLUP);
   pinMode(ST3_end_SW, INPUT_PULLUP);
   pinMode(TR_home_SW, INPUT_PULLUP);
   pinMode(TR_pos2_SW, INPUT_PULLUP);
   pinMode(TR_pos3_SW, INPUT_PULLUP);
   pinMode(StartButton, INPUT_PULLUP); 
   pinMode (LED, OUTPUT) ;
   pinMode (LED1, OUTPUT);
   pinMode(trigPin_St1, OUTPUT); // Sets the trigPin as an OUTPUT
   pinMode(echoPin_St1, INPUT); // Sets the echoPin as an INPUT
   pinMode (LED_St1, OUTPUT);
   pinMode(trigPin_St2, OUTPUT); // Sets the trigPin as an OUTPUT
   pinMode(echoPin_St2, INPUT); // Sets the echoPin as an INPUT
   pinMode (LED_St2, OUTPUT);
   pinMode(trigPin_St3, OUTPUT); // Sets the trigPin as an OUTPUT
   pinMode(echoPin_St3, INPUT); // Sets the echoPin as an INPUT
   pinMode (LED_St3, OUTPUT);
   pinMode (Gripper, OUTPUT);

   
   delay(5);  // Wait for EasyDriver wake up

   //  Set Max Speed and Acceleration of each Steppers at startup for homing
  stepper_GR.setSpeed(10000.0);      // Set Max Speed of Stepper GRIPPER(Slower to get better accuracy)
  stepper_GR.setAcceleration(1000.0);  // Set Acceleration of Stepper GRIPPER  
  stepper_ST2.setSpeed(100.0);      // Set Max Speed of Stepper STATION 2(Slower to get better accuracy)
  stepper_ST2.setAcceleration(100.0);  // Set Acceleration of Stepper STATION 2
  stepper_ST1.setSpeed(10000.0);      // Set Max Speed of Stepper STATION 1(Slower to get better accuracy)
  stepper_ST1.setAcceleration(1000.0);  // Set Acceleration of Stepper STATION 1
  stepper_ST3.setSpeed(10000.0);      // Set Max Speed of Stepper STATION 3(Slower to get better accuracy)
  stepper_ST3.setAcceleration(1000.0);  // Set Acceleration of Stepper STATION 3
  stepper_TR.setSpeed(10000.0);      // Set Max Speed of Stepper TRANSPORT(Slower to get better accuracy)
  stepper_TR.setAcceleration(1000.0);  // Set Acceleration of Stepper TRANSPORT

 //-------------------------------------------------GRIPPER HOMING------------------------------------------------------

// Start Homing procedure of Stepper Motor at startup - GRIPPER

 // Serial.print("Stepper Gripper is Homing . . . . . . . . . . . ");
//Serial.println(deg);
  while (!digitalRead(GR_home_SW)) {  // Make the Stepper move CW until the switch is activated. ! = revese direction  
    stepper_GR.moveTo(initial_homing_GR);  // Set the position to move to
    initial_homing_GR++;  // Decrease by 1 for next move if needed
    stepper_GR.run();  // Start moving the stepper
    delay(5);
}

  stepper_GR.setCurrentPosition(0);  // Set the current position as zero for now
  stepper_GR.setSpeed(10000.0);      // Set Max Speed of Stepper (Slower to get better accuracy)
  stepper_GR.setAcceleration(1000.0);  // Set Acceleration of Stepper
  initial_homing_GR=1;

  while (digitalRead(GR_home_SW)) { // Make the Stepper move CCW until the switch is deactivated
    stepper_GR.moveTo(initial_homing_GR);  
    stepper_GR.run();
    initial_homing_GR--;
    delay(5);
  }
  
  stepper_GR.setCurrentPosition(0);
 // Serial.println("Homing Completed");
 // Serial.println("");
  stepper_GR.setSpeed(10000.0);      // Set Max Speed of Stepper (Faster for regular movements)
  stepper_GR.setAcceleration(1000.0);  // Set Acceleration of Stepper

//}
//----------------------------------------------------STATION2 HOMING---------------------------------------------------

// Start Homing procedure of Stepper Motor at startup - STATION 2

//  Serial.print("Stepper Station 2 is Homing . . . . . . . . . . . ");
//Serial.println(deg);
  while (digitalRead(ST2_home_SW)) {  // Make the Stepper move CCW until the switch is activated   
    stepper_ST2.moveTo(initial_homing_ST2);  // Set the position to move to
    initial_homing_ST2--;  // Decrease by 1 for next move if needed
    stepper_ST2.run();  // Start moving the stepper
    delay(5);
}

  stepper_ST2.setCurrentPosition(0);  // Set the current position as zero for now
  stepper_ST2.setMaxSpeed(100.0);      // Set Max Speed of Stepper (Slower to get better accuracy)
  stepper_ST2.setAcceleration(100.0);  // Set Acceleration of Stepper
  initial_homing_ST2=1;

  while (!digitalRead(ST2_home_SW)) { // Make the Stepper move CW until the switch is deactivated
    stepper_ST2.moveTo(initial_homing_ST2);  
    stepper_ST2.run();
    initial_homing_ST2++;
    delay(5);
  }
  
  stepper_ST2.setCurrentPosition(0);
 // Serial.println("Homing Completed");
 // Serial.println("");
  stepper_ST2.setMaxSpeed(100.0);      // Set Max Speed of Stepper (Faster for regular movements)
  stepper_ST2.setAcceleration(100.0);  // Set Acceleration of Stepper

//--------------------------------------------------STATION1 HOMING-----------------------------------------------------
// Start Homing procedure of Stepper Motor at startup - STATION 1

 // Serial.print("Stepper Station 1 is Homing . . . . . . . . . . . ");
//Serial.println(deg);
  while (!digitalRead(ST1_home_SW)) {  // Make the Stepper move CW (!) until the switch is activated   
    stepper_ST1.moveTo(initial_homing_ST1);  // Set the position to move to
    initial_homing_ST1--;  // Decrease by 1 for next move if needed
    stepper_ST1.run();  // Start moving the stepper
    delay(5);
}

  stepper_ST1.setCurrentPosition(0);  // Set the current position as zero for now
  stepper_ST1.setSpeed(1000.0);      // Set Max Speed of Stepper (Slower to get better accuracy)
  stepper_ST1.setAcceleration(100.0);  // Set Acceleration of Stepper
  initial_homing_ST1=1;

  while (digitalRead(ST1_home_SW)) { // Make the Stepper move CCW until the switch is deactivated
    stepper_ST1.moveTo(initial_homing_ST1);  
    stepper_ST1.run();
    initial_homing_ST1++;
    delay(5);
  }
  
  stepper_ST1.setCurrentPosition(0);
 // Serial.println("Homing Completed");
 // Serial.println("");
  stepper_ST1.setSpeed(1000.0);      // Set Max Speed of Stepper (Faster for regular movements)
  stepper_ST1.setAcceleration(1000.0);  // Set Acceleration of Stepper


//------------------------------------------------------STATION3 HOMING-------------------------------------------------
// Start Homing procedure of Stepper Motor at startup - STATION 3

 // Serial.print("Stepper Station 3 is Homing . . . . . . . . . . . ");
//Serial.println(deg);
  while (digitalRead(ST3_home_SW)) {  // Make the Stepper move CW (!) until the switch is activated   
    stepper_ST3.moveTo(initial_homing_ST3);  // Set the position to move to
    initial_homing_ST3--;  // Decrease by 1 for next move if needed
    stepper_ST3.run();  // Start moving the stepper
    delay(5);
}

  stepper_ST3.setCurrentPosition(0);  // Set the current position as zero for now
  stepper_ST3.setSpeed(10000.0);      // Set Max Speed of Stepper (Slower to get better accuracy)
  stepper_ST3.setAcceleration(1000.0);  // Set Acceleration of Stepper
  initial_homing_ST3=1;

  while (!digitalRead(ST3_home_SW)) { // Make the Stepper move CCW until the switch is deactivated
    stepper_ST3.moveTo(initial_homing_ST3);  
    stepper_ST3.run();
    initial_homing_ST3++;
    delay(5);
  }
  
  stepper_ST3.setCurrentPosition(0);
  //Serial.println("Homing Completed");
  //Serial.println("");
  stepper_ST3.setSpeed(10000.0);      // Set Max Speed of Stepper (Faster for regular movements)
  stepper_ST3.setAcceleration(1000.0);  // Set Acceleration of Stepper

//---------------------------------------------------TRANSPORT HOMING----------------------------------------------------
// Start Homing procedure of Stepper Motor at startup - TRANSPORT

  //Serial.print("Stepper Transport is Homing . . . . . . . . . . . ");
//Serial.println(deg);
  while (digitalRead(TR_home_SW)) {  // Make the Stepper move CCW until the switch is activated   
    stepper_TR.moveTo(initial_homing_TR);  // Set the position to move to
    initial_homing_TR--;  // Decrease by 1 for next move if needed
    stepper_TR.run();  // Start moving the stepper
    delay(5);
}

  stepper_TR.setCurrentPosition(0);  // Set the current position as zero for now
  stepper_TR.setSpeed(10000.0);      // Set Max Speed of Stepper (Slower to get better accuracy)
  stepper_TR.setAcceleration(1000.0);  // Set Acceleration of Stepper
  initial_homing_TR=1;

  while (!digitalRead(TR_home_SW)) { // Make the Stepper move CW until the switch is deactivated
    stepper_TR.moveTo(initial_homing_TR);  
    stepper_TR.run();
    initial_homing_TR++;
    delay(5);
  }
  
  stepper_TR.setCurrentPosition(0);
  //Serial.println("Homing Completed");
//  Serial.println("");
  stepper_TR.setSpeed(10000.0);      // Set Max Speed of Stepper (Faster for regular movements)
  stepper_TR.setAcceleration(1000.0);  // Set Acceleration of Stepper


}
void loop(){
   // Clears the trigPin condition. STATION1
  digitalWrite(trigPin_St1, LOW);
  delayMicroseconds(2);
  // Sets the trigPin HIGH (ACTIVE) for 10 microseconds
  digitalWrite(trigPin_St1, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin_St1, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration_St1 = pulseIn(echoPin_St1, HIGH);

    // Clears the trigPin condition. STATION2
  digitalWrite(trigPin_St2, LOW);
  delayMicroseconds(2);
  // Sets the trigPin HIGH (ACTIVE) for 10 microseconds
  digitalWrite(trigPin_St2, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin_St2, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration_St2 = pulseIn(echoPin_St2, HIGH);
  
  // Clears the trigPin condition. STATION3
  digitalWrite(trigPin_St3, LOW);
  delayMicroseconds(2);
  // Sets the trigPin HIGH (ACTIVE) for 10 microseconds
  digitalWrite(trigPin_St3, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin_St3, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration_St3 = pulseIn(echoPin_St3, HIGH);
  // Calculating the distance
  distance_St1 = duration_St1 * 0.034 / 2; // Speed of sound wave divided by 2 (go and back)
  distance_St2 = duration_St2 * 0.034 / 2; // Speed of sound wave divided by 2 (go and back)
  distance_St3 = duration_St3 * 0.034 / 2; // Speed of sound wave divided by 2 (go and back)
//  Serial.println("Station1 occupied");
//  Serial.println(distance_St1);
//  Serial.println("");
//  Serial.println("Station2 occupied");
//  Serial.println(distance_St2);
//  Serial.println("");
//    Serial.println("Station3 occupied");
//  Serial.println(distance_St3);
//  Serial.println("");
  
  
//Check if all stations clear
   if (distance_St1 < 10)
{digitalWrite(LED_St1, HIGH);

}
else {
  
  digitalWrite(LED_St1, LOW);
  
if (distance_St2 < 10)
{digitalWrite(LED_St2, HIGH);

}
else {
  
  digitalWrite(LED_St2, LOW);

if (distance_St3 < 10)
{digitalWrite(LED_St3, HIGH);

}
else {
  
  digitalWrite(LED_St3, LOW);
  
   if (digitalRead(StartButton) == LOW)
  {
    // ------------------------------------------- STATION1 FEED THE TRAY ---------------------------------------------
  stepper_ST1.setSpeed(10000.0);      // Set Max Speed of Stepper (Slower to get better accuracy)
  stepper_ST1.setAcceleration(1000.0);  // Set Acceleration of Stepper
  
     while (digitalRead(ST1_end_SW)) {  // Make the Stepper move CW until the switch is activated. ! = revese direction  
    stepper_ST1.moveTo(end_position_ST1);  // Set the position to move to
    end_position_ST1--;  // Decrease by 1 for next move if needed
    stepper_ST1.run();  // Start moving the stepper
    delay(5);
}
//
//  stepper_ST1.setCurrentPosition(0);  // Set the current position as zero for now
//  stepper_ST1.setMaxSpeed(1000.0);      // Set Max Speed of Stepper (Slower to get better accuracy)
//  stepper_ST1.setAcceleration(1000.0);  // Set Acceleration of Stepper
//  end_position_ST1=1;
//
//  while (digitalRead(ST1_end_SW)) { // Make the Stepper move CCW until the switch is deactivated
//    stepper_ST1.moveTo(end_position_ST1);  
//    stepper_ST1.run();
//    end_position_ST1++;
//    delay(5);
//  }
//  
//  stepper_ST1.setCurrentPosition(0);

      // ------------------------------------------ GRIPPER INTO POSITION ------------------------------------------
  stepper_GR.setSpeed(10000.0);      // Set Max Speed of Stepper (Slower to get better accuracy)
  stepper_GR.setAcceleration(1000.0);  // Set Acceleration of Stepper
  
     while (digitalRead(GR_end_SW)) {  // Make the Stepper move CW until the switch is activated. ! = revese direction  
    stepper_GR.moveTo(end_position_GR);  // Set the position to move to
    end_position_GR++;  // Decrease by 1 for next move if needed
    stepper_GR.run();  // Start moving the stepper
    delay(5);
// Serial.print("end_position_GR . . . . . . . . . . . ");
// Serial.println(end_position_GR);
//  Serial.print("");
}
  stepper_GR.setCurrentPosition(0);  // Set the current position as zero for now

//    stepper_GR.setCurrentPosition(0);  // Set the current position as zero for now
//    stepper_GR.setMaxSpeed(1000.0);      // Set Max Speed of Stepper (Slower to get better accuracy)
//    stepper_GR.setAcceleration(1000.0);  // Set Acceleration of Stepper
//    end_position_GR=1;

//    while (digitalRead(GR_end_SW)) { // Make the Stepper move CCW until the switch is deactivated
//      stepper_GR.moveTo(end_position_GR);  
//      stepper_GR.run();
//      end_position_GR++;
//      delay(5);
//  }
  
//  stepper_GR.setCurrentPosition(0);

      // ------------------------------------------ GRIPPING PROCESS -------------------------------------------------
        delay(1000);
        digitalWrite(Gripper, HIGH);
        delay (1000);
       // ------------------------------------------ GRIPPER LIFTING PROCESS ------------------------------------------
   initial_homing_GR = -1;
   while (digitalRead(GR_home_SW)) {  // Make the Stepper move CW until the switch is activated. ! = revese direction  
    stepper_GR.moveTo(initial_homing_GR);  // Set the position to move to
    initial_homing_GR--;  // Decrease by 1 for next move if needed
    stepper_GR.run();  // Start moving the stepper
    delay(5);
//    Serial.print("initial_homing_GR . . . . . . . . . . . ");
//    Serial.println(initial_homing_GR);
//    Serial.print("");
    }
  stepper_GR.setCurrentPosition(0);  // Set the current position as zero for now
        // ------------------------------------------ TRANSPORT TO STATION2 ------------------------------------------
stepper_TR.setMaxSpeed(4000.0); 
         while (digitalRead(TR_pos2_SW)) {  // Make the Stepper move CW until the switch is activated. ! = revese direction  
   //stepper_TR.runToNewPosition (second_position_TR);
   stepper_TR.moveTo(second_position_TR);  // Set the position to move to
    second_position_TR++;  // Decrease by 1 for next move if needed
    stepper_TR.run();  // Start moving the stepper
    delay(5);
         }
     stepper_TR.setCurrentPosition(0);
    
         // ------------------------------------------ GRIPPER INTO POSITION ------------------------------------------
  end_position_GR = 1;
  delay(1000); //Dwell time
   while (digitalRead(GR_end_SW)) {  // Make the Stepper move CW until the switch is activated. ! = revese direction  
    stepper_GR.moveTo(end_position_GR);  // Set the position to move to
    end_position_GR++;  // Decrease by 1 for next move if needed
    stepper_GR.run();  // Start moving the stepper
    delay(5);
//    Serial.print("end_position_GR . . . . . . . . . . . ");
// Serial.println(end_position_GR);
//  Serial.print("");
}
  stepper_GR.setCurrentPosition(0);  // Set the current position as zero for now
          // ------------------------------------------ GRIPPER RELEASE PROCESS ------------------------------------------
        delay(1000);
        digitalWrite(Gripper, LOW);
        delay (1000);
      // ------------------------------------------ STATION2 FILLING PROCESS ------------------------------------------
      
       deg = 355;
    
    stepper_ST2.runToNewPosition(deg);
    delay (1000);
    digitalWrite(LED, HIGH);
    delay (2000);
    digitalWrite(LED, LOW);
    delay (1000);
    deg += 355;
    
    stepper_ST2.runToNewPosition(deg);
    for (int i = 0; i < 7; i++)
    {
      delay (1000);
      digitalWrite(LED, HIGH);
      delay (2000);
      digitalWrite(LED, LOW);
      delay (1000);
      deg += 355;
     // stepper_ST2.moveTo(deg); //rotate another 40 degree
     stepper_ST2.runToNewPosition(deg);
    }
  
  delay (1000);
  digitalWrite(LED1, HIGH);
    delay (2000);
    digitalWrite(LED1, LOW);
    delay (1000);
   // ------------------------------------------ GRIPPING PROCESS -------------------------------------------------
        delay(1000);
        digitalWrite(Gripper, HIGH);
        delay (5);
       // ------------------------------------------ GRIPPER LIFTING PROCESS ------------------------------------------
  delay(1000); //Dwell time
   initial_homing_GR = -1;
   while (digitalRead(GR_home_SW)) {  // Make the Stepper move CW until the switch is activated. ! = revese direction  
    stepper_GR.moveTo(initial_homing_GR);  // Set the position to move to
    initial_homing_GR--;  // Decrease by 1 for next move if needed
    stepper_GR.run();  // Start moving the stepper
    delay(5);
//    Serial.print("initial_homing_GR . . . . . . . . . . . ");
// Serial.println(initial_homing_GR);
//  Serial.print("");
    }
  stepper_GR.setCurrentPosition(0);  // Set the current position as zero for now
        // ------------------------------------------ TRANSPORT TO STATION3 ------------------------------------------
stepper_GR.setSpeed(9000.0); 
         while (digitalRead(TR_pos3_SW)) {  // Make the Stepper move CW until the switch is activated. ! = revese direction  
    stepper_TR.moveTo(third_position_TR);  // Set the position to move to
    third_position_TR++;  // Decrease by 1 for next move if needed
    stepper_TR.run();  // Start moving the stepper
    delay(5);}
         // ------------------------------------------ GRIPPER INTO POSITION ------------------------------------------
  delay(1000); //Dwell time
   while (digitalRead(GR_end_SW)) {  // Make the Stepper move CW until the switch is activated. ! = revese direction  
    stepper_GR.moveTo(end_position_GR);  // Set the position to move to
    end_position_GR++;  // Decrease by 1 for next move if needed
    stepper_GR.run();  // Start moving the stepper
    delay(5);
//    Serial.print("end_position_GR . . . . . . . . . . . ");
//    Serial.println(end_position_GR);
//    Serial.print("");
}
  stepper_GR.setCurrentPosition(0);  // Set the current position as zero for now
  
          // ------------------------------------------ GRIPPER RELEASE PROCESS ------------------------------------------
        delay(1000);
        digitalWrite(Gripper, LOW);
        delay (1000);

     // ------------------------------------------ STATION 3 MOVES ONE STATION DOWN ------------------------------------------
         deg_ST3 = 700;
    
    stepper_ST3.runToNewPosition(deg_ST3);
    delay (1000);
    deg_ST3 += 700;

         // ------------------------------------------ GRIPPER LIFTING PROCESS PREPARING FOR HOME------------------------------------------
  delay(1000); //Dwell time
   initial_homing_GR = -1;
   while (digitalRead(GR_home_SW)) {  // Make the Stepper move CW until the switch is activated. ! = revese direction  
    stepper_GR.moveTo(initial_homing_GR);  // Set the position to move to
    initial_homing_GR--;  // Decrease by 1 for next move if needed
    stepper_GR.run();  // Start moving the stepper
    delay(5);
//    Serial.print("initial_homing_GR . . . . . . . . . . . ");
// Serial.println(initial_homing_GR);
//  Serial.print("");
    }
  stepper_GR.setCurrentPosition(0);  // Set the current position as zero for now
 
  //---------------------------------------------------TRANSPORT HOMING----------------------------------------------------
   stepper_TR.setMaxSpeed(1000000.0); 
  while (digitalRead(TR_home_SW)) {  // Make the Stepper move CCW until the switch is activated   
    stepper_TR.moveTo(initial_homing_TR);  // Set the position to move to
    initial_homing_TR--;  // Decrease by 1 for next move if needed
    stepper_TR.run();  // Start moving the stepper
    delay(5);
}

  stepper_TR.setCurrentPosition(0);  // Set the current position as zero for now
    
  }
  
}}}
}
 


Yes, Homing is a slow process. It needs to be to avoid over shooting the limit switch which would defeat the purpose of homing which is to determine the precise position of the stepper.

Since faster speed is not the answer. here are some tips to avoid spending too much time in the homing process.

• Only Home once at the start of the program. after that you know where the stepper is. if you don't you are losing steps during use and that is what needs to be corrected.

• Always return to the home position before turning off the device. this ensures there is little time spent rehoming next time.

Hi,
I have come across in the industrial world, where there have only been two speeds available to the drive device.
Homing was done at HIGH speed until a "pre" limit switch was encountered not far in position from the home switch.
At this point the motor switched to LOW speed to the home switch.

Tom... :grinning: :+1: :coffee: :australia:

Or you can go fast to the limit switch, knowing it will overshoot, forwards fast until the limit switch clears again, then slowly backwards until the switch operates once more.

Depending on how much faster 'fast' is than 'slow', it can be pretty quick, even though it sounds more complicated.

Thnx for the answers. The problem is that the speed is about 30rpm when homing and it takes like 5 minutes. The other issue that the stepper runs the same rpm during normal run, after it homed. Is there any code for the fast run? I have values for speed in my code but increasing those values doesn't seem to increase the speed.
Thanks

You need to figure out why. Perhaps write something simpler to experiment with different speeds.

I see you have a delay in your homing loop - that's likely a problem.

1 Like

With the delay(5) in your while loop you cannot go faster then 200 steps/sec. No matter what speed you set.
N.B. If you use the run() method you must set the speed with setMaxSpeed(). set Speed() is internally used by the run method itself.

2 Likes

So if I remove the delay it will go faster? Don't have access to my laptop at the moment to try it out

Yes.

The run() method creates at most one step ( or no step, if no step is due ). With your delay(5) in the while loop you cannot create more than one step every 5ms.

Hi,

What are you driving with the stepper, what gearbox have you got between the stepper and the device you want to home?
Can you please post a picure(s) of your project.

If it takes 5 minutes for 30rpm.
If you want to home in 1minute would be 5 * 30 = 150rpm
If you want, for example, 10seconds then 150 * 60/10 = 900rpm.

Now work out the step rate, and if your stepper motor and driver is capable of it.

Tom... :grinning: :+1: :coffee: :australia:

It worked. Removing the delays I got the speed I wanted. Thanks all for help. I attached the picture of the setup.
Thanks again

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.