Go Down

Topic: Trimming a sketch regarding the use of delayMicros (Read 199 times) previous topic - next topic

Railroader

Hi!

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.
Use Your knowledge. If that's not enough, look for education.
Having knowledge, think outside the box to gain more of it. Only trains run like the train, on the rails. The rest run between the rails.

PaulS

Quote
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.

Code: [Select]
    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.
The art of getting good answers lies in asking good questions.

Railroader

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.
Use Your knowledge. If that's not enough, look for education.
Having knowledge, think outside the box to gain more of it. Only trains run like the train, on the rails. The rest run between the rails.

wildbill

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.

Railroader

Thanks!
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.
Use Your knowledge. If that's not enough, look for education.
Having knowledge, think outside the box to gain more of it. Only trains run like the train, on the rails. The rest run between the rails.

Go Up