This is meant to be constructive, to help you. Not laying $hit on your good work.
Look at this fragment of code...
case 'D':
num=0.00;
lcd.setCursor(16,1);lcd.print(" ");
lcd.setCursor(16,1);
break;
}
Degrees = 360/num; // <----- Division by ZERO!! for case 'D'
key = kpd.getKey();
}
return Degrees; //num;
}'
Doing this sort of thing on micros, in my experience, NEVER needs floating point arithmetic on such a basic operation like working stepper motors.
For 200 step per rev and 90:1 for gear gives (200 * 90) / 360 gives 50 steps per degrees.
Want to move 13.5 degrees (internally counting from 0 to 3600) gives STEPS = (135 * 50) / 10 = 675;
Want to move 13.4 degrees (internally counting from 0 to 3600) gives STEPS = (134 * 50) / 10 = 670;
Want to move 0.1 degrees (internally counting from 0 to 3600) gives STEPS = (1 * 50) / 10 = 5;
Always do the MULTIPLY FIRST, usually for better results.
Dynamically changing time delays in loops, so that it accelerates and decelerates smoothly will allow much higher speeds.
Once above the critical speed of the motor you can't just stop or start it instantly.
A stepper is torsionally loaded against a permanent magnet, like a spring, and once you yank on the spring too quickly you can loose steps because inertia wins.
https://www.google.com/search?q=ste...ast5zcAhXFmJQKHaPHDX4QsAQIPg&biw=1375&bih=751
Look at the manufacturers data sheets for motors.
Study this.. It might explain a few things
https://en.wikipedia.org/wiki/Stepper_motor