SOLVED- Stepper moving without delay()

I have two stepper motors that I am trying to move independent of each other. If I use the delayMicroseconds() function, they move at half speed until one is finished and then the second one goes very fast. I am trying to implement the millis() delay without delay(), but I am having a few issues.

  1. The motors are much louder at the same speed as with the delayMicroseconds() function
  2. If I use 1 as my interval (speedRight and speedLeft) value, it's quieter, but too fast. a value of 2 gets very loud. Is there a way to use decimal values with this?

Here is the part of my code where I have tried this.

void opening() {
  //door OPENING stepper motor operation ////////////////////////////////////////////////////////////////////////////
  //set by app door open button
  if (openStop == 1) {
    unsigned long currentMillis1 = millis();
    unsigned long currentMillis2 = millis();    
    digitalWrite(LEFT_ENABLE, HIGH); //enable needs to be low for stepper to move
    digitalWrite(RIGHT_ENABLE, LOW); //enable needs to be low for stepper to move
    sensorRightOpen = digitalRead (STOP_SENSOR_RIGHT_CLOSED); //check status of the sensors
    sensorLeftOpen = digitalRead (STOP_SENSOR_LEFT_CLOSED);
    digitalWrite(RIGHT_DIRECTION, HIGH); //sets clockwise motor direction for right door
    digitalWrite(LEFT_DIRECTION, LOW); //sets counterclockwise motor direction for left door
    if (sensorRightOpen == LOW) { //checks sensor state of right door open sensor
      ledStatusFlagOpen = 0;
      if (currentMillis1 - previousMillis1 >= speedRight) {
        // save the last time you blinked the LED
        previousMillis1 = currentMillis1;
        digitalWrite(RIGHT_STEP, HIGH); //right stepper motor moves clockwise
      } else {
        digitalWrite(RIGHT_STEP, LOW);
      }
    } else {
      ledStatusFlagOpen = 1;
      overunFlagRightOpen = 1;
    }
    if (sensorLeftOpen == LOW) { //checks sensor state of left door open sensor
      ledStatusFlagOpen = 0;
      if (currentMillis2 - previousMillis2 >= speedLeft) {
        // save the last time you blinked the LED
        previousMillis2 = currentMillis2;
        digitalWrite(LEFT_STEP, HIGH); //left stepper motor moves counter clockwise
      } else {
        digitalWrite(LEFT_STEP, LOW);
      }
    } else {
      ledStatusFlagOpen = 1;
      overunFlagLeftOpen = 1;
    }
    if (ledStatusFlagOpen == 1) {
      if (sensorLeftOpen == HIGH && sensorRightOpen == HIGH) {
        if (overunFlagLeftOpen == 1 && overunFlagRightOpen == 1) {
          digitalWrite(LEFT_ENABLE, LOW); //disables stepper
          digitalWrite(RIGHT_ENABLE, HIGH); //disables stepper
          overunFlagLeftOpen = 0;
          overunFlagRightOpen = 0;
          overunFlagOpen = 1;
        }
        doorButtonOpen = 0;
      }
    }
  } else { //stop the door if open button is pressed a second time before the close button
  }
}

Have a look at the second example in this Simple Stepper Code. It uses millis() and micros() for non-blocking motion.

Also, you should separate the different parts of your program into short single purpose functions - for example to move the motor one step and to read the sensors. That way you can test the different parts separately. Have a look at Planning and Implementing a Program

...R

Thanks for the reply. I had found the micros() shortly after I posted this and that solved my problem.