Rotate two steppers with LCD menu

Hello Friends,

I have two stepper motors and M524 drivers.

I'm trying to rotate both steppers at same time with very accurately using Arduino. I want to use LCD menu and buttons for change the speed of steppers.

I have write a code for menu with help of LiquidMenu library.

I used fallowing functions for get accurate speed.

float rpm;
unsigned int stepDelayUp;
unsigned int lastStepTimeUp = 0;

void calcStepDelay(float v) {
  //RPM=V/(r*0.10472)-v in m/s...r in m
  rpm = v / 0.088; //(0.088=0.014*0.1047*60)
  stepDelayUp = 60000000.0F / (rpm * 4000.0F);  //4000.0 is pulse per revolution

}

void moveUp()
{
  if (micros() - lastStepTimeUp >= stepDelayUp) {
    lastStepTimeUp = micros();
    digitalWrite(STEP_UP, HIGH);
    delayMicroseconds(100);
    digitalWrite(STEP_UP, LOW);
    delayMicroseconds(100);
  }
}

it's works fine only separately from LCD menu codes.When I use this function with LCD menu controlling, motor dose not get accurate speed as calculated.

Please suggest a way for get accurate speed.

Thank in advance

Please suggest a way for get accurate speed.

Write some decent code.

When I use this function with LCD menu controlling, motor dose not get accurate speed as calculated.

When you run some code you didn't show, something happens that is not what you want.

But, you couldn't be bothered describing what the code you didn't post actually does, or how that differs from what you want. Well, good luck.

You need to post your complete program

If you want a responsive program do not use delay() anywhere as it blocks the Arduino until it finishes. Have a look at how millis() and micros() is used to manage timing without blocking in the second example in this Simple Stepper Code.

You may also like to have a look at the demo Several Things at a Time which illustrates the use of millis() to manage timing without blocking. It may help with understanding the technique.

Have a look at Using millis() for timing. A beginners guide if you need more explanation.

...R
Stepper Motor Basics