I'm doing a school project using a few stepper motors driven by drv8825 drivers (actually, it will be an overhead travelling crane), with an Arduino UNO. First of all, we haven't got a huge amount of money to spend. Now, the problem is this: we are going to use a PID control, through an MPU6050 acc+gyro, that will control the speed of the motors (the load is supposed to be as firm as possible during the movements), and the only two ways to change the speed of a stepper motor are:
1) Through a delay method, for example:
for (i = 0; i<400; i++)
{
digitalWrite(StepPinB, LOW);
delayMicroseconds(500);
digitalWrite(StepPinB, HIGH);
delayMicroseconds(500);
}
Using this method, the Arduino will be busy all the time, so I will not be able to check continuously the value of the sensor, in order to reach the correct speed. Because of this, I can't use this method.
2) Through an external regulation of the drv8825's clock frequency, for example using a "voltage-frequency converter" (the variable voltage could be given by an "Arduino PWM" + "low-pass filter") or using an "astable multivibrator" ("astable oscillator") with a "digital potentiometer" to change the frequency. I've already tried the "voltage-frequency converter" method, but it didn't work due to the noises of the circuit.
I'd like you to help me to find out what's the better way to change the stepper motor's speed continuously during the program (and also to find the better way to make a variable frequency, as shown in the point 2).