If timer=zero then copy value delay into timer and check speed to go with actual speed. Increase speed if result is positiv. Decrease speed if result is negativ. If timer <> zero then make a second loop to increase the stepping time.