Ok, so the stepper motor controllers I have need code like this to run:
digitalWrite(STEP_PIN, HIGH);
delayMicroseconds(1000);
digitalWrite(STEP_PIN, LOW);
delayMicroseconds(DELAY);
the way to control the speed the motors run at is to control the DELAY value, thus controlling how long they are "off" for in between steps.
the issue arises when trying to run more than one motor. It essentially becomes a duty cycle problem, except the high state must be for 1000 microseconds, so the duty cycle is non-uniform in frequency between the two motors. To be clear, when I say duty cycle I'm not talking about PWM, that has much too fast of a pulse rate for these motors to run off of it.
If I do this:
digitalWrite(STEP_PIN1, HIGH);
digitalWrite(STEP_PIN2, HIGH);
delayMicroseconds(1000);
digitalWrite(STEP_PIN1, LOW);
delayMicroseconds(DELAY1);
digitalWrite(STEP_PIN1, HIGH);
delayMicroseconds(DELAY2 - DELAY1);
digitalWrite(STEP_PIN2, LOW);
delayMicroseconds(1000 + DELAY1 - DELAY2);
digitalWrite(STEP_PIN1, HIGH);
etc.
then it become massively out of sync within just a few repetitions, and if DELAY2 is > 1000 then it is out of sync on the first repetition.
How can this be done?