I'm not sure that the AccelStepper library is designed for what you want. The normal way it works is to move through N steps using acceleration and deceleration from 0 to max speed and back to 0.
It would not be very difficult to write your own acceleration code. Have a look at this Simple Stepper Code and this Post in another Thread in which I illustrated a simple acceleration system.
The math gets a little hairy if you start at speed 0 since that is an infinite delay between steps. Let's start at 1 step per second and go up from there. 1 to 500 steps per second is 1,000,000 to 2,000 microseconds between steps. Dividing that range into the 3200 steps means you decrease the delay by 311.875 microseconds each step. Floating point math is slow but we can multiply everything by 8 so we can use the integer 2495 in place of 311.875.
static unsigned long lastStepTime = 0;
for (unsigned long stepDelay = 1000000UL*8UL; stepDelay > 2000UL*8UL; stepDelay -= 2495UL) {
// Wait until time for the next step
while ((micros()-lastStepTime)*8UL >= stepDelay) {}
// Take one step
stepper.step(1); // Use the built-in Stepper library instesd of AccelStepper.
// Prepare for the next step
lastStepTime += stepDelay;
}
Be warned that if you start at 1 revolution per second, the first 100 steps (1/2 turn?) will take about a minute and a half. I would not be surprised if the whole 3200 steps took half an hour.
Is there a way to use AccelStepper lib to move smoothly from one speed to another? I have found that I can use AccelStepper to accel from speed(0) to speed(500X) by changing setAcceleration to a large value when distanceToGo is about half way to the target position. But i'm having trouble doing what I describe in my step#2, ie accel from speed(500) to speed(750) over 6400 steps.
I realize AccelStepper is maybe not designed for my use, but AccelStepper does a great job of smoothly controlling the motor when speeds approach zero. I would like to use that capability in my steps# 1 & 3 and meld it with a routine (with or without using AccelStepper) that accomplishes my step#2.
Hydrobro:
I realize AccelStepper is maybe not designed for my use, but AccelStepper does a great job of smoothly controlling the motor when speeds approach zero. I would like to use that capability in my steps# 1 & 3 and meld it with a routine (with or without using AccelStepper) that accomplishes my step#2.
I have not studied the AccelStepper code but I doubt if it does anything very sophisticated. Why not just roll your own? Accelerating a stepper motor is just the process of reducing the interval between steps according to some formula.