DRV8825 & NEMA17 motor help

ok.. had a few minutes to play again..

So I am using this code:

#include <AccelStepper.h>
// Define a stepper and the pins it will use
//stepper(driver, 3(step), 2(dir))
//AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
AccelStepper stepper(1, 3, 2); //stepper(driver, step, dir)
//AccelStepper stepper(AccelStepper::DRIVER, 9, 8);

void setup(){ 
    stepper.setMaxSpeed(500.0);
    stepper.setAcceleration(400.0);
}
void loop(){   
    stepper.runToNewPosition(0);
    stepper.runToNewPosition(1500);
    delay(1000);
    stepper.runToNewPosition(100);
    stepper.runToNewPosition(1200);
}

and I noticed, that there is some sort of jerky/stall/glitch movement at the end of the range/target position.

If you watch the video, you will notice that right before the shaft changes direction, there is a brief, glitch/jerk in the shaft (like a brief stall)..

I took a video:
https://www.youtube.com/watch?v=q0wqjO5Pgu0&feature=youtu.be

I changed the code to this to get a bit more range, and test some values.

#include <AccelStepper.h>
// Define a stepper and the pins it will use
//stepper(driver, 3(step), 2(dir))
//AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
AccelStepper stepper(1, 3, 2); //stepper(driver, step, dir)
//AccelStepper stepper(AccelStepper::DRIVER, 9, 8);

void setup(){ 
    stepper.setMaxSpeed(1500.0);
    stepper.setAcceleration(1000.0);
}
void loop(){   
    stepper.runToNewPosition(0);
    stepper.runToNewPosition(2500);
    delay(1000);
    stepper.runToNewPosition(100);
    stepper.runToNewPosition(2200);
}

About the same results.. except more speed..etc..(loger run out..etc)

I then SLOWLY adjusted the pot..

it seems if I went one way.. that clunky/jerky movement at the end softened/disappeared... (but I could then easily stop the shaft with my fingers...so it must have been turning the current DOWN)..

I turned it up.. and the shaft became more difficult to stop with my fingers, but you could then see/hear the jerky movement behavior again (slightly.. but enough to know it was there)..

I settled for a position where it was strong enough and least 'jerk' when changing shaft directions..

Would micro stepping help eliminate this?

According to your code....

void loop(){
stepper.runToNewPosition(0);
stepper.runToNewPosition(1500);
delay(1000);
stepper.runToNewPosition(100);
stepper.runToNewPosition(1200);
}

You run to position '1200' or whatever it is, and then the loop immediately runs to position '0' with no delay. You have a pause of 1 second after it reaches position '1500'. I assume this is what you want.

Maybe you can take a look at the acceleration values.... and reduce those values for testing.

Basically, do tests at lower acceleration and lower stepping rate ..... to see if you can find out the limits of your system.

And...... instead of cycling back and forth for the moment, just make the system rotate in a single direction for a while, and then stop. You can always focus on this back-and-forth cycling thing later --- after the stepper is made to behave normally for simplest tests.

Southpark:
According to your code....

void loop(){
stepper.runToNewPosition(0);
stepper.runToNewPosition(1500);
delay(1000);
stepper.runToNewPosition(100);
stepper.runToNewPosition(1200);
}

You run to position '1200' or whatever it is, and then the loop immediately runs to position '0' with no delay. You have a pause of 1 second after it reaches position '1500'. I assume this is what you want.

Maybe you can take a look at the acceleration values.... and reduce those values for testing.

That is just some example code.. I actually threw in the delay() to see if that helped.

I'll throw a matching one in to see if it has any affect.

Southpark:
Basically, do tests at lower acceleration and lower stepping rate ..... to see if you can find out the limits of your system.

Will do. I'll make note of what (if any) vars/values help in the change of the behavior. However as mentioned above adjusting the pot had some bearing on how it behaved for sure.

Southpark:
And...... instead of cycling back and forth for the moment, just make the system rotate in a single direction for a while, and then stop. You can always focus on this back-and-forth cycling thing later --- after the stepper is made to behave normally for simplest tests.

This was just some example code I found for the acelstepper lib.

I was using the 'simple' and while it worked.. I couldnt get movement like this see if the stepper was behaving correctly. (being my first stepper project and no first hand exposure to how the feel/sound [shake]..etc)... I wasnt clear/confident things were working.

This sketch seems make a little more confident things are 'working' at a base level. (I thought?)

"after the stepper is made to behave normally for simplest tests."

What are the simple/basic tests I should be passing here to say things are behaving normally?

(as in when I ready to to move on to reading up on the lib and homing my stepper....etc.. knowing I have a working stepper and get to the coding side of things?) :slight_smile: