Fast motor stepping using SpeedStepper

Hi,
I need to make a stepper run at highest speed as possible.
If I'm right, the SpeedStepper library (I think it's my best choice, as I'll add another stepper to my project) needs a call to function like stepper1.processMovement(); to update motor rotation.

As my sketch controls other devices, like remote control, LCD, and so on, I discovered that, to get higher speeds, I have to place "stepper1.processMovement();" many times in my sketch.

Placing "stepper1.processMovement();" only once inside my loop() is not enough.

My question: is there a system to have Arduino automatically call "stepper1.processMovement();", without having to put this instruction everywhere in my program?
I mean, a system (interrupt?) not controlled by the program but by something concerned with the CPU clock?

Thanks in advance
Raf

Please post a link to the documentation for the SpeedStepper library.

Also please post your program.

...R
Stepper Motor Basics
Simple Stepper Code

Thank Robin2
SpeedyStepper library is here: GitHub - Stan-Reifel/SpeedyStepper: Stepper motor control library for Arduino

About my sketch, this is an example that gets the motor to rotate 100k steps at 2500 steps per second, accelerating and decelerating at 500 step/s2.

the loop() continuously calls the .processMovement() function. Arduino Mega is able to handle this speed.
Example1:

#include <SpeedyStepper.h>
SpeedyStepper stepper1;

#define STEPPER1_EN 23
#define STEPPER1_DIR 25
#define STEPPER1_STEP 27
#define STEPPER1_M1 29
#define STEPPER1_M2 31
#define STEPPER1_M3 33

void setup() {
 pinMode(STEPPER1_EN, OUTPUT);   // Big Easy Driver Enable pin motor#1
 pinMode(STEPPER1_DIR, OUTPUT);  // Big Easy Driver Dir pin motor#1
 pinMode(STEPPER1_STEP, OUTPUT); // Big Easy Driver Step pin motor#1
 pinMode(STEPPER1_M1, OUTPUT);   // Big Easy Driver M1 pin motor#1
 pinMode(STEPPER1_M2, OUTPUT);   // Big Easy Driver M2 pin motor#1
 pinMode(STEPPER1_M3, OUTPUT);   // Big Easy Driver M3 pin motor#1
 digitalWrite(STEPPER1_M1, LOW); // Set M1,M2,M3 to LOW for FULL STEP
 digitalWrite(STEPPER1_M2, LOW);
 digitalWrite(STEPPER1_M3, LOW);
 digitalWrite(STEPPER1_EN, LOW); // LOW=Enable motor
 stepper1.connectToPins(STEPPER1_STEP, STEPPER1_DIR);
 stepper1.setSpeedInStepsPerSecond(2500);
 stepper1.setAccelerationInStepsPerSecondPerSecond(500);
 stepper1.setupMoveInSteps(100000); // Set a 100k steps rotation
}

void loop() {
 stepper1.processMovement();
}

Problems arrive when you write more functions in the loop(), because of time the MPU takes to run instructions SETS could be too long for the motor to have a smooth rotation, as every time the MPU calls stepper1.processMovement(); there could be some "missed" steps.
Obviously, this problem depends on motor speed/acceleration and time consumption of the different instructions.
In these cases I chop my instructions in short sets, and every time I call the same function stepper1.processMovement();

Example2:

#include <SpeedyStepper.h>
SpeedyStepper stepper1;

#define STEPPER1_EN 23
#define STEPPER1_DIR 25
#define STEPPER1_STEP 27
#define STEPPER1_M1 29
#define STEPPER1_M2 31
#define STEPPER1_M3 33

void setup() {
 pinMode(STEPPER1_EN, OUTPUT);   // Big Easy Driver Enable pin motor#1
 pinMode(STEPPER1_DIR, OUTPUT);  // Big Easy Driver Dir pin motor#1
 pinMode(STEPPER1_STEP, OUTPUT); // Big Easy Driver Step pin motor#1
 pinMode(STEPPER1_M1, OUTPUT);   // Big Easy Driver M1 pin motor#1
 pinMode(STEPPER1_M2, OUTPUT);   // Big Easy Driver M2 pin motor#1
 pinMode(STEPPER1_M3, OUTPUT);   // Big Easy Driver M3 pin motor#1
 digitalWrite(STEPPER1_M1, LOW); // Set M1,M2,M3 to LOW for FULL STEP
 digitalWrite(STEPPER1_M2, LOW);
 digitalWrite(STEPPER1_M3, LOW);
 digitalWrite(STEPPER1_EN, LOW); // LOW=Enable motor
 stepper1.connectToPins(STEPPER1_STEP, STEPPER1_DIR);
 stepper1.setSpeedInStepsPerSecond(2500);
 stepper1.setAccelerationInStepsPerSecondPerSecond(500);
 stepper1.setupMoveInSteps(100000); // Set a 100k steps rotation
}

void loop() {
 //
 //  .... ISTRUCTIONS SET 1
 //
 stepper1.processMovement();
 //
 //  .... ISTRUCTIONS SET 2
 //
 stepper1.processMovement();
 //
 //  .... ISTRUCTIONS SET 3
 //
 stepper1.processMovement();
 //
 //  .... ISTRUCTIONS SET 4
 //
 stepper1.processMovement();
}

This is not a solution as it cannot consider exactly how much time passes between .processMovement(); calls.

This is reason I'm looking for a timed automatic call of .processMovement();

What do you think about?

Thanks
Raf

To make it easy for people to help you please modify your post and use the code button </>
codeButton.png

so your code 
looks like this

and is easy to copy to a text editor. See How to use the Forum

Also please use the AutoFormat tool to indent your code consistently for easier reading.

I get the impression that the code in Reply #2 is not complete as there is nothing in loop() except the stepper library calls.

If you want help post a complete program that demonstrates the problem. The problem is usually in the part you have not posted.

...R

OK Robin2, code tagged, sorry.
Example1 is fully working. It's the fastest possible, as it updates motor's rotation at every loop. It does nothing more than this.
About Example2, it's only to show the fact that I call many times the same function in a loop, as I need to update motor so often. My complete list has different sheets and is not quite readable.
Thanks
Raf

I had not realised there were two separate programs.

I presume the problem arises with Example 2. And since you have not posted the complete program I have no idea what the problem might be - or the solution.

Neither have you said how many steps per second you need to achieve.

...R