Stepper Motor Accel/Decel Ramp for Fixed Frequency Input
Accelerating and decelerating stepper motors consistently can be a very challenging adventure.

Accelerate too fast and the motor can stall and just sit there screaming at you. If you are counting steps it can also lag back far enough to skip back a full cycle leaving you out of position. 

Accelerate too slowly with a light inertial load and the motor can actually turn around on you during the first few steps. This of course makes it that much harder for the motor to keep up with the ramping step rate.

All this can be further aggravated if the load itself is variable, either short term or long and let us not forget the variability of the motors and drivers.

Because of all that, finding the right acceleration and deceleration profiles that work consistently can be a frustrating effort.

In order to do so it is normal to back off the acceleration and deceleration torques to give the motor some lee-way to correct itself. That is, if you try to accelerate at what you have calculated to be the best torque of the motor, and the motor falls behind, there will be no torque left for the motor to go faster than the demand and catch up.

Ultimately, for best control of a stepper motor it is best to attach a shaft encoder to it that has the same, or a multiple, number of pulses as the motor has steps and closing the control loop. Basically turning your stepper motor into a high pole count BLDC. Properly controlled, such an arrangement lets you extract the most torque, and acceleration/deceleration, out of the motor even under highly variable loads.