# AccelStepper - how to disable acceleration

**URL:** <https://forum.arduino.cc/t/accelstepper-how-to-disable-acceleration/1227911>\
**Category:** Motors, Mechanics, Power and CNC\
**Created:** [February 24, 2024, 12:45pm UTC](https://forum.arduino.cc/t/accelstepper-how-to-disable-acceleration/1227911 "2024-02-24T12:45:53Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![tony359](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tony359/32/214996_2.png) [@tony359](https://forum.arduino.cc/u/tony359)\
**Post date:** [February 24, 2024, 12:45pm UTC](https://forum.arduino.cc/t/accelstepper-how-to-disable-acceleration/1227911/1 "2024-02-24T12:45:53Z")

</div>

Hi there,

I'm using AccelStepper for a simple stepper sketch. I don't need the acceleration feature, I would like the stepper to start and stop as fast as possible. I set acceleration to a very high value but ideally I'd like to disable it altogether.

Can someone point me to the right direction?

```arduino
void setup() {
	// set the maximum speed, acceleration factor,
	// initial speed and the target position
  myStepper.setMaxSpeed(3500);
	myStepper.setAcceleration(100000);
	myStepper.setSpeed(1500);
	myStepper.moveTo(355);
  myStepper.runToPosition();
  delay(100);
  myStepper.moveTo(0);
  myStepper.runToPosition();
  delay(1000);
  pinMode (XTIDE, INPUT);
  pinMode (enable, OUTPUT);
  Serial.begin(9600);

}

void loop() {

Activity = digitalRead(XTIDE);
if (Activity == 1) {
 // Activity = digitalRead(XTIDE);
  Seek = random(0, 355);
  digitalWrite(enable, 1);
  myStepper.moveTo(Seek);
	myStepper.runToPosition();
  digitalWrite(enable, 0);
  Bob = random(10, 500);
  delay(Bob);

}
  
}

```

Thanks!  
Tony

---

<div class="post-metadata">

**Author:** ![DrDiettrich](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/drdiettrich/32/219048_2.png) [@DrDiettrich](https://forum.arduino.cc/u/DrDiettrich)\
**Post date:** [February 24, 2024, 1:26pm UTC](https://forum.arduino.cc/t/accelstepper-how-to-disable-acceleration/1227911/2 "2024-02-24T13:26:20Z")

</div>

> [@tony359](#):
>
> the stepper to start and stop as fast as possible.

Then set the acceleration **as high as possible**. If you set it **higher than possible** then the motor will loose steps and will **not** start and stop as fast as possible.

---

<div class="post-metadata">

**Author:** ![zwieblum](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/zwieblum/32/427702_2.png) [@zwieblum](https://forum.arduino.cc/u/zwieblum)\
**Post date:** [February 24, 2024, 1:44pm UTC](https://forum.arduino.cc/t/accelstepper-how-to-disable-acceleration/1227911/3 "2024-02-24T13:44:12Z")

</div>

You realize that this results in very poor performance and unpredictable step losses?

---

<div class="post-metadata">

**Author:** ![tony359](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tony359/32/214996_2.png) [@tony359](https://forum.arduino.cc/u/tony359)\
**Post date:** [February 24, 2024, 1:50pm UTC](https://forum.arduino.cc/t/accelstepper-how-to-disable-acceleration/1227911/4 "2024-02-24T13:50:22Z")

</div>

Thanks both.

The stepper is used for a non-critical function so as long as it moves and makes some noise it's ok. I know it sounds silly...

Is there an alternative to this then? The basic stepper library doesn't seem to work with a controller which accepts STEP and DIRECTION pins?

---

<div class="post-metadata">

**Author:** ![MicroBahner](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/microbahner/32/238923_2.png) [@MicroBahner](https://forum.arduino.cc/u/MicroBahner)\
**Post date:** [February 24, 2024, 2:02pm UTC](https://forum.arduino.cc/t/accelstepper-how-to-disable-acceleration/1227911/5 "2024-02-24T14:02:02Z")

</div>

Use runSpeed instead of run

---

<div class="post-metadata">

**Author:** ![tony359](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tony359/32/214996_2.png) [@tony359](https://forum.arduino.cc/u/tony359)\
**Post date:** [February 24, 2024, 2:37pm UTC](https://forum.arduino.cc/t/accelstepper-how-to-disable-acceleration/1227911/6 "2024-02-24T14:37:17Z")

</div>

> [@MicroBahner](#):
>
> runSpeed

Thanks.  
I found this about runspeed

Poll the motor and step it if a step is due, implementing a constant speed as set by the most recent call to [setSpeed()]. You must call this as frequently as possible, but at least once per step interval,

## Returns true if the motor was stepped.

Right now my sketch does not call for the stepper function more than once. I use runToPosition and the stepper just does that.

runSpeed would need a change in the code, right?

Is there a command similar to runToPosition which does not account for acceleration?

---

<div class="post-metadata">

**Author:** ![cedarlakeinstruments](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/cedarlakeinstruments/32/1128931_2.png) [@cedarlakeinstruments](https://forum.arduino.cc/u/cedarlakeinstruments)\
**Post date:** [February 24, 2024, 3:59pm UTC](https://forum.arduino.cc/t/accelstepper-how-to-disable-acceleration/1227911/7 "2024-02-24T15:59:47Z")

</div>

> [@tony359](#):
>
> Is there an alternative to this then? The basic stepper library doesn't seem to work with a controller which accepts STEP and DIRECTION pins?

Yes, you answered your own question. Use one pin for direction and pulse another pin for step. As long as you don't pulse the pin too fast (probably keep it under 500 steps/second) that will work.

---

<div class="post-metadata">

**Author:** ![tony359](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tony359/32/214996_2.png) [@tony359](https://forum.arduino.cc/u/tony359)\
**Post date:** [February 24, 2024, 5:13pm UTC](https://forum.arduino.cc/t/accelstepper-how-to-disable-acceleration/1227911/8 "2024-02-24T17:13:11Z")

</div>

of course - but that means re-write the code. I was hoping to just be able to adjust some parameters and use the existing code.

---

<div class="post-metadata">

**Author:** ![MicroBahner](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/microbahner/32/238923_2.png) [@MicroBahner](https://forum.arduino.cc/u/MicroBahner)\
**Post date:** [February 24, 2024, 5:23pm UTC](https://forum.arduino.cc/t/accelstepper-how-to-disable-acceleration/1227911/9 "2024-02-24T17:23:40Z")

</div>

If I remembrt correctly, there ist also runSpeedToPosition

---

<div class="post-metadata">

**Author:** ![tony359](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tony359/32/214996_2.png) [@tony359](https://forum.arduino.cc/u/tony359)\
**Post date:** [February 24, 2024, 5:45pm UTC](https://forum.arduino.cc/t/accelstepper-how-to-disable-acceleration/1227911/10 "2024-02-24T17:45:51Z")

</div>

> Executes [runSpeed()] unless the targetPosition is reached. This function needs to be called often just like [runSpeed()] or [run()]. Will step the motor if a step is required at the currently selected speed unless the target position has been reached. Does not implement accelerations.

> Returns  
> true if it stepped

So I need to keep calling until it returns true?  
I'm not a developer, please forgive me if I am saying rubbish 🙂

---

<div class="post-metadata">

**Author:** ![cedarlakeinstruments](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/cedarlakeinstruments/32/1128931_2.png) [@cedarlakeinstruments](https://forum.arduino.cc/u/cedarlakeinstruments)\
**Post date:** [February 24, 2024, 6:10pm UTC](https://forum.arduino.cc/t/accelstepper-how-to-disable-acceleration/1227911/11 "2024-02-24T18:10:44Z")

</div>

> [@tony359](#):
>
> adjust some parameters and use the existing code.

Then the solution was already provided in post #2!!!  
Set a very high acceleration and it's done.

---

<div class="post-metadata">

**Author:** ![tony359](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tony359/32/214996_2.png) [@tony359](https://forum.arduino.cc/u/tony359)\
**Post date:** [February 24, 2024, 6:25pm UTC](https://forum.arduino.cc/t/accelstepper-how-to-disable-acceleration/1227911/12 "2024-02-24T18:25:36Z")

</div>

well, that's what I am doing so the solution would be in post #1!!!!!!!

I was hoping for a cleaner solution, a library - or a parameter within this library - which allowed to move the stepper without even considering the acceleration - which is my original question.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [August 22, 2024, 6:26pm UTC](https://forum.arduino.cc/t/accelstepper-how-to-disable-acceleration/1227911/13 "2024-08-22T18:26:33Z")

</div>

Closed on August 22, 2024, 6:26pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
