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