Trimming a sketch regarding the use of delayMicros


With plenty of help from Forum, in the past, I now have a pretty well running sketch that will grow. Reading Forum topics I have learned things like "using millis() and a lot more.

My question is if anyone can see a benefitial way to eliminate the use of delayMicros in my sketch. Start looking at the function “stepmotor” that is the center, the lowest level, of logics. The layers above all need stepmotor to finish its job before the sketch can continue.
Is there a way to gain computing power for future functions?

The sketch exceeds the maximum 9000 characters even after slimming it.

Combined_20190408.ino (17.9 KB)

My question is if anyone can see a benefitial way to eliminate the use of delayMicros in my sketch.

Yes. Use a real stepper driver, with step and direction pins. Set the step pin HIGH, then immediately set it LOW, and the stepper will step.

    if (motor == motorX )
    if (motor == motorY)
    if (motor == motorZ)

If there isn't a snowball's chance in hell that no more than one of these if statements will evaluate to true, if/else if is more appropriate.

Thanks PaulS.
Actualy I do have one version where I can command any combination of the 3 steppers to run in stepmotor, using a mask like if(motornumber & motorId). The limit is that they must make the same number of steps.
I do use stepper drivers that need direction and step. (Enable also). One version of them is a Protooner board and the other version is a Micros Driver 6650(?), answering to the same signals.
Are there any more intelligent drivers that would accept Direction and number of steps? That would release my UNOs from waiting.

Pololu has some Tic Stepper Motor Controllers that might be worth looking at.

There's also the AccelStepper library which says it's non-blocking.

Disclaimer: Have not used either.

The Pololu drivers current maximum is a bit too low for my Mini Mill/CNC but enough for the Micro Mill/CNC.
I've heard about AccelStepper but only nosed at it. Maybe Worth looking closer at.