How can I measure the turn-around time of my engine?

Thanks for reading my question. I would like to know the time it takes to take a full turn. I have 1 nema 17 engine (stepper motor) but, I want to know how long it takes to complete 1 turn because from that I will make a relationship to be able to put on a keypad and reflect it on an LCD for how long you want it to be turning the motor steps. Try to do a sampling time and using volatile unsigned but it is not very close, so I ask for help. Below leave only the code, where the movement is made, I suppose it will be in the cycle for which the condition will be set. Thank you! sorry if I do not explain myself well, I do not speak English very well.THE COMPLETE CODE IS DOWN, THE DOWNLOADABLE FILE

for (int i = 0; i <a; i ++) {schedule2 ();
for (int i = 0; i <totalpasos2; i ++) {m2 ();} // Equivalent to the number of turns (200 steps are 360º degrees of servo)
// --------- Change of direction of rotation ---------------------------------- -------------------------------------------------- —
anti-clock2 (); // send direction to the servo
for (int i = 0; i <totalpasos2; i ++) {m22 ();}} // Equivalent to the number of turns (200 steps are 360 degrees of servo)
digitalWrite (reset1, LOW);
break;

case ‘F’:
for (int i = 0; i <a; i ++) {// Equivalent to the number of turns (200 steps are 360 degrees of servo)
schedule1 ();
schedule2 ();
for (int i = 0; i <totalpasos1; i ++) {// Equivalent to the number of turns (200 steps are 360º degrees of servo)
m1 ();
m2 ();}
// --------- Change of direction of rotation ---------------------------------- -------------------------------------------------- -
anti-clock1 ();
anti-clock2 ();
for (int i = 0; i <totalpasos1; i ++) {// Equivalent to the number of turns (200 steps are 360º degrees of servo)
m11 ();
m22 ();}}
digitalWrite (reset1, LOW);

codigo en ingles.txt (7.92 KB)

anti-clock2 ();.Do you see a problem there?

Please remember to use code tags when posting code, and don't post snippets.

The code is very long, do I publish it to such an extent?

0Avendano:
The code is very long, do I publish it to such an extent?

If it's too long to include in the post (9000 chars I think?), attach the .ino

But an even better way is to cut the code down to the minimum size where it still shows the problem. That way, sometimes you fix the problem in the process.

how to attach.GIF

I already uploaded it, thank you very much. I will wait for the answer while I keep thinking

There can’t be any uncertainty about the time for a stepper motor to make one revolution as your program will define the time interval between steps.

…R