Only Clockwise Direction Overshoot/Slipping Problem

28 views
Skip to first unread message

Eren Palabiyik

unread,
Nov 15, 2025, 2:52:58 PM (11 days ago) Nov 15
to accelstepper
I have very weird problem with this library. 
My board is Arduino Due,
I am trying to move a step motor with tb6600 driver. Below is a bouncing code for this step motor.
Motor can stop  immediately with friction at below coded speed. So it shouldn't overshoot with momentum.
------------------------------------------------------------------------
#include <AccelStepper.h>

AccelStepper stepper(AccelStepper::DRIVER, 49, 48);

void setup() {
  // Change these to suit your stepper if you want
  pinMode(49, OUTPUT);
  pinMode(48, OUTPUT);
  stepper.setMaxSpeed(40);
  stepper.moveTo(40);
  stepper.setSpeed(40);
  stepper.setMinPulseWidth(6);
  delay(5000);
}

void loop() {
  // If at the end of travel go to the other end
  if (stepper.distanceToGo() == 0) {
    long mvTo = stepper.currentPosition() == 0 ? 40 : 0;

    stepper.moveTo(mvTo);
    stepper.setSpeed(40);
    delay(100);
  }
  while(stepper.runSpeedToPosition());
}
------------------------------------------------------------------------

My problem is that. With this code it actually overshoots. But only in the clockwise direction. This causes to be always wrong position while library thinks its at correct position. For every iteration, position 0 moves +2. So at iteration 10. Motor is at position +20 but library thinks its at position 0.

I tried to run motor manually by coding with same speed. It actually works normally.
I also tried stepper.run() with %10 percent max speed accelaration. It overshoot again.

Eren Palabiyik

unread,
Nov 15, 2025, 2:58:44 PM (11 days ago) Nov 15
to accelstepper
I forgot to mention driver switches.
Its 101 100. Which is microstep 2/A - 400 Pulse/Rev 

gjgsm...@gmail.com

unread,
Nov 15, 2025, 10:51:40 PM (11 days ago) Nov 15
to accelstepper
Hi Eren,
The overshoot is possibly just from the sudden stop at the end of the movement resulting in missed steps because you are using no acceleration. Have you tried running the Accelstepper library Bounce example which uses acceleration. Run that first to test your setup, adjust acceleration setting to eliminate missed steps (overshoot). One reason you might be overshooting in a clockwise direction only could be the 'load' is travelling downwards assisted by gravity, in the opposite direction gravity would have a braking effect which would inhibit missed steps. 

Eren Palabiyik

unread,
Nov 16, 2025, 6:36:04 AM (11 days ago) Nov 16
to accelstepper
Hi,
I have tried with accelaration, with %10 percent of max speed. It doesnt work.
Step motor rotates on Z axis( perpendicular to ground ).

John Tillson

unread,
Nov 16, 2025, 7:38:30 AM (11 days ago) Nov 16
to accels...@googlegroups.com
Hi Eren,
I raised a question some years back regarding the lack of setup time between the direction signal and the steps signal, a typical driver gives a minimum setup time of 5us but accelstepper only provides 0.5us
In my projects I have used a spare gpio and set the step signal in my code outside of accelstepper.
Works for me.
John

--
You received this message because you are subscribed to the Google Groups "accelstepper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/accelstepper/5b59f80b-7535-4101-b52e-4e0e5c4a2710n%40googlegroups.com.

Eren Palabiyik

unread,
Nov 16, 2025, 10:47:44 AM (10 days ago) Nov 16
to accelstepper
I have found out that its caused by lack of setup time between dir and step. I fixed by setting direction pin when actually direction changes.  and delaying 17us. ( even delaying 10us causes slips for me :( ).  I didnt touch setOutputPins function. Just removed setOutputPins function from step1, changing into 
---------------------
digitalWrite(_pin[0], ((_direction ? 0b11 : 0b01) & (1 << 0)) ? (HIGH ^ _pinInverted[0]) : (LOW ^ _pinInverted[0]));
delayMicroseconds(_minPulseWidth);
digitalWrite(_pin[0], ((_direction ? 0b10 : 0b00) & (1 << 0)) ? (HIGH ^ _pinInverted[0]) : (LOW ^ _pinInverted[0]));
--------------------

Below is setting of direction pin if _direction changed. Similar code is everywhere where _direction is assigned ( except constructor ). Below code is from runSpeedToPosition()
-------------------------
bool old_dir = _direction;
    if (_targetPos >_currentPos)
_direction = DIRECTION_CW;
    else
_direction = DIRECTION_CCW;
if( old_dir != _direction )
{
digitalWrite(_pin[1], ((_direction ? 0b10 : 0b00) & (1 << 1)) ? (HIGH ^ _pinInverted[1]) : (LOW ^ _pinInverted[1]));
delayMicroseconds(17);
    }
---------------------------
Also I have set DIR pin if setPinsInverted called. Before function ends.
Reply all
Reply to author
Forward
0 new messages