Stepper motor skips and jumps at low speeds (only when microstepping is enabled)

Hello friends,

I have recently run into an issue where my stepper motor starts skipping and sort of jumping between steps when at low speeds (presumably at higher speeds as well but it's not visible) with microstepping enabled. This just seems incredibly odd to me and I honestly can't explain it. Full, half, and 1/4 steps work just fine even at low speeds. But whenever I go to 1/8 steps microstepping or smaller it starts making weird noises and stopping at times to then proceed to make a jump. (I'll try to get a video showing this properly ASAP). This all occurs both with the stepper in the assembly (actually moving things) and when it is on it's own.

The components I am using are:

I measured and set the Vref of the driver at a bit under 0.75V since the maximum current of the motor is 1.5A.

Although I don't believe the code to be the issue here it is, I copied it off someone else on the forum. Looking at it myself I can't see this being the issue but I wouldn't know. This is the code I am using right now, I modified it to run at different speeds when pressing the end switches so I could test at what speed it happens:

byte directionPin = 6;
byte stepPin = 3;

unsigned long curMicros;
unsigned long prevStepMicros = 0;
unsigned long slowMicrosBetweenSteps = 312; // microseconds
unsigned long fastMicrosBetweenSteps = slowMicrosBetweenSteps;
unsigned long stepIntervalMicros;
unsigned long stepAdjustmentMicros;
int numAccelSteps = 100; // 100 is a half turn of a 200 step mmotor
long numSteps = 1000000000;
long stepsToGo;
byte direction = 1;

long speeds[] = {500000, 50000, 5000, 2500, 1250, 625, 312, 156, 78, 39};
int index = 0;

void setup() {

    Serial.begin(115200);

    pinMode(directionPin, OUTPUT);
    pinMode(stepPin, OUTPUT);

    pinMode(8, OUTPUT);
    digitalWrite(8, LOW);

    pinMode(9, INPUT_PULLUP);
    pinMode(10, INPUT_PULLUP);

    stepAdjustmentMicros = (slowMicrosBetweenSteps - fastMicrosBetweenSteps) / numAccelSteps;
    //stepIntervalMicros = slowMicrosBetweenSteps;
    stepIntervalMicros = speeds[index];
    stepsToGo = numSteps;
    digitalWrite(directionPin, direction);
}

void loop() {

    moveMotor();

}

void moveMotor() {
    stepIntervalMicros = speeds[index];
    
    if (stepsToGo > 0) {
        if (micros() - prevStepMicros >= stepIntervalMicros) {
            prevStepMicros += stepIntervalMicros;
            singleStep();
            stepsToGo --;
        }
    }
    else {
        direction = ! direction;
        digitalWrite(directionPin, direction);
            // next two lines just for the demo
        delay(2000);
        Serial.println("Changing direction");
        stepsToGo = numSteps;
        prevStepMicros = micros();
    }

    if(digitalRead(9)) {
      if(index < (sizeof(speeds)/sizeof(speeds[0]))) {
        index++;

        Serial.print("Now running at ");
        Serial.print(speeds[index]);
        Serial.println(" micros between steps");
      } else {
        digitalWrite(8, HIGH);
      }

      while(digitalRead(9)) delay(10);
    }

    if(digitalRead(10)) {
      digitalWrite(8, HIGH);
    }
}

void singleStep() {

    digitalWrite(stepPin, HIGH);
    digitalWrite(stepPin, LOW);

}

I would link to where I found this specific code but I can't seem to find it anymore.

I want to believe I somewhat understand how stepper motors work and I just can't explain what is happening here. I suspect it's me being stupid.

What I already checked:

  • Wiring (extensively and by other people)
  • Programming (I tried everything on the internet I could find that mentioned stepper motors and microstepping)
  • CNC shield, this shouldn't be the issue since I have had the issues since before I bought it. I bought it to fix this issue actually because I thought it was down to my bad soldering skills at first.

I suspect it to be an issue related to the power supply or the components just not being compatible for my purpose.

Let me know please if you need more information, I'll try to get a clear video of it as soon as I get home from work.

Thanks in advance, I really hope this is fixable with the hardware I have available.

EDIT: video of what happens at the moment when I enable microstepping above 1/8 steps:

I can't send the link due to the link limit, I posted it in the comments below.

Much text about Your thughts doesn't give help. It only burries the real info.
What is the current limit of the stepper and limit is set in the driver?

Stepper is rated for 1.5A per phase, Vref on the driver is 0.75V so that should be the same. (I'll edit this into the post as well.)

P.S. I was just trying to give a clear view of what I have and haven't tried, I guess it turned out a bit longer than needed.

Using the phone and its small screen it's hard overview large texts...
Did You check the driver manual to know that 1.5 amp reads as 0,75 volt? Lover it to some 0.60 - 0.65 volt to give the motor a longer life. Small steppers also get hot and running them for extended time will shorten their life. Note that steppers burn the same power at stand still, actually more, as when running. Disable the driver board (En inactive) whenever it's possible.
Also know that during micro stepping the torque in the motor drops quite a lot.

Looking through your code, the function for singleStep() appears to take the step pin high, then immediately low again - this might be the source of your problem as the step pulse length probably needs to be of the order of 10us to get a reliable step. Try putting a delayMicroseconds(10) line in between your two digitalWrite lines in the singleStep() function.

If that doesn't work could you try ensuring that there is no load on your stepper in order to see if whatever you are driving with it requires more torque than the motor can supply at the higher micro-stepping levels. Let us know if any of that yields any results.

Tried both already unfortunately, I delayed up to 100 microseconds between pulling it back to low, nothing seems to work. I have it disconnected from any moving parts now, I'm adding the video of what I am trying to explain in the post.

Yeah I double checked it just now, the Vref is set correctly. I have also looked into disabling the stepper when not in use but I haven't actually put it in a permanent fixture yet so I don't think it will be an issue.

How many volt does that driver handle? Stepping up from 12 to 24 volt or more might improve things.

Video link of what the issue is:

If I load your code to my Uno with a CNC shield I can make the motor (8x micro stepping) move only if I hold the button connected to pin 10 down and press and hold the button connected to pin 9. Then the motor runs smoothly. If I release and press the button on 9 and hold it the speed changes to the next indexed speed and runs smoothly until I get to a too high of speed then the motor stalls. Motor only runs when the button on pin 10 and the button on pin 9 are both pressed.

The thing is that I do not see the "skipping and sort of jumping between steps when at low speeds" that you describe. When the motor does run, it runs very smoothly.

I didn't think my code was the issue either, I just put it up in case I did something wrong. I posted a video of what exactly I mean by the skipping and jumping, I don't think it is very visible but if you turn the sound up you can hear the stepper attempt to move and make weird sounds then it sort of jumps and clicks before going back to making weird sounds.

I could give it a go, but speed is not the issue here. In fact it seems to get better as I increase the speed.

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