# accelerate a stepper using arduino AccelStepper starting with a pre-defined speed

I've read the AccelStepper documentation on airspayce.com and it seems to be not possible to accelerate a stepper starting with a speed greater 0. Acceleration always starts from speed=0, I tried it with several variations of the code below...

#include <AccelStepper.h>
int onOffPin = 9;

AccelStepper stepper(AccelStepper::DRIVER, 2, 10);

void setup()
{
stepper.setMaxSpeed(1000);
stepper.setSpeed(200);
stepper.setAcceleration(100);
}

void loop()
{
//turn motor on
digitalWrite( onOffPin, HIGH );

// go forwards
digitalWrite( onOffPin, HIGH );
stepper.move(1300);
stepper.runToPosition(); // stepper shall start from speed 200, but it starts from speed 0;

// Now go backwards
stepper.move(-1300);
stepper.runToPosition();

//turn motor off
digitalWrite( onOffPin, LOW );
delay(2000);
}


I also tried to set the speed in the library's method void AccelStepper::computeNewSpeed() directly, but I'm not that good in c++ and don't get it to work.

Anybody any ideas?

## UPDATE

I tried to write some custom code in AccelStepper.cpp's method void AccelStepper::computeNewSpeed() My idea was to set the speed manually during acceleration/deceleration if the speed is below my intended value. At first I thought it couldn't be a big deal, but now I see that my cpp skills seems to be not good enough or I don't understand the library quite well.

I tried

void AccelStepper::computeNewSpeed()
{
long distanceTo = distanceToGo(); // +ve is clockwise from curent location
long stepsToStop = (long)((_speed * _speed) / (2.0 * _acceleration)); // Equation 16

//now here goes my modification
if (_speed < 200.0 && _speed >= 0 ){
setSpeed(200.0);
}
//I did no modification below this comment


This results in a very slow stepper movement..