Stepper "jerky"

I have a project that I want to use a stepper for. I am currently trying to run it with a NMB-MAT D6NE stepper. Thats 48 steps per revolution.

I am using a pololu A4988 controller using 1/16th step. I have attached the schematic of design. (I have ordered 10 PCBs for use in other projects).

My project needs to have the motor rotate at two speeds selected by a pot, low speed is 6 rpm, high speed is 60 rpm. Here is the code I am currently using:

void setup() {
      // Sets the pins as Outputs
      pinMode(stepPin,OUTPUT);
      pinMode(dirPin,OUTPUT);
      pinMode(enablePin, OUTPUT);
      digitalWrite(enablePin,LOW); //Start with the motor stopped.  Use button to start/stop
      digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction

    }
void loop() {
          
        digitalWrite(stepPin,HIGH);
        delayMicroseconds(10);
        digitalWrite(stepPin,LOW);
        delay(10000);
}

This is just test code to check out the low speed characteristics of the motor. Eventually I will be doing motor reverse, and maybe even timing the rotations to rotate CW for a while, then CCW for a while.

Everything is fine at the higher speeds (smaller delays). But at the low end of the speed spectrum it begins to run "jerky". By that I mean step then stop then step again. Its due to the delay that I am using and the method I have programed. I am pretty sure I need a different way of controlling the delay at the lower speeds, but have not found anything on the net or in the forum that addresses this issue.

I need the slow speed because I am using this to turn fly rods that have had the threads on the guides coated with self leveling epoxy. The rod needs to turn for about 24 hours to let the epoxy dry, and the turning assures the epoxy is consistent on the rod. The jerkyness might create problems with the epoxy.

I need the high speed to actually do the application of the epoxy. Turning the rod at higher speeds will let me apply the epoxy faster so I don't have to worry too much about pot life.

If I can't get steppers to work, I may be forced into using DC gear motors. I have a project already working with a gear motor now that seems to be doing the trick, but steppers give me a lot more flexibility and I have several of them available.

Many thanks for any ideas.

dryerMotor.pdf (48 KB)

If you want 6 RPM or 1 rev every 10 seconds. And if there are 48 steps per rev that means about 208 millisecs between steps - or 5 steps per second. That would probably seem jerky. But with x16 microstepping the interval between steps should fall to about 13 millisecs which should seem fairly smooth.

I can't see how the code in your Original Post relates to the sort of speed you want - unless my maths is all wrong (which it might be).

...R
Stepper Motor Basics
Simple Stepper Code

Robin2:
If you want 6 RPM or 1 rev every 10 seconds. And if there are 48 steps per rev that means about 208 millisecs between steps - or 5 steps per second. That would probably seem jerky. But with x16 microstepping the interval between steps should fall to about 13 millisecs which should seem fairly smooth.

I can't see how the code in your Original Post relates to the sort of speed you want - unless my maths is all wrong (which it might be).

...R
Stepper Motor Basics
Simple Stepper Code

Well, if your math is wrong, then so is mine. When I tried to use the numbers you suggest (the same ones I tried by the way) the motor seems to run at a high speed, no where near 6 RPM. The delayMicroseconds(10) and delay(10000) are the only numbers that get me anywhere close to 6 RPM and then its jerky as I said. I have not had much luck getting much more information on this motor (I salvaged it from an older printer), so it may very well be that it cannot be driven at 1/16 step which would explain the math issues and jerkyness. Let me go back and reset the microsteps to 1 and see what happens.

Post a link to the datasheet for the stepper.

For microstepping, it is absolutely critical that you properly set the current limit on the motor driver. To what value did you set it?

Connecting LEDs to the motor lines, as you have, is a bad idea unless they have reverse voltage protection.

My bad, I had it set to run at 1 microstep not 1/16. Here is the new code:

void setup() {
      // Sets the two pins as Outputs
      pinMode(stepPin,OUTPUT);
      pinMode(dirPin,OUTPUT);
      pinMode(enablePin, OUTPUT);
      digitalWrite(enablePin,LOW);
      digitalWrite(stepPin,HIGH);
      digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
      digitalWrite(ms1Pin,HIGH);
      digitalWrite(ms2Pin,HIGH);
      digitalWrite(ms3Pin,HIGH);
    }
    void loop() {

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

    }

This gives me pretty close to 6 rpm, however I am still getting the jerkyness. I tried to take a video and upload it but the file is too big. It is not as jerky as it was with a microstep of 1, but still enough to create potential problems.

jremington:
Post a link to the datasheet for the stepper.

For microstepping, it is absolutely critical that you properly set the current limit on the motor driver. To what value did you set it?

Connecting LEDs to the motor lines, as you have, is a bad idea unless they have reverse voltage protection.

The datasheet is a big problem. I have not been able to find one for this motor. So may go with another that I have the datasheet for.

As for the current, without a datasheet its difficult to set the correct current as I know someone will remind me of.

Last problem, I did something and I believe the motor controller is fried. Will have to replace it and start over I guess. Oh well, live and learn.

But still have the same issue with the jerkyness.

By their very nature, stepper motors move in steps so they are inherently "jerky". The only way to refuce the jerkyiess is setting the microstepping to smaller fractions of a step. If you switch to using the DRV8825 stepper driver, you will be able to do 1/32 microstepping. The DRV8825 modules are pin compatible with the A4988 modules and about the same price.

The real problem is that you do not know anything useful about the motor you have. Measure the winding resistance of the motor; that is very informative.

As for setting the current limit, microstepping will not work unless the current is actually limited by the driver in full step mode.

If you can't figure this out, either buy a motor that has a data sheet and use it according to specifications, or live with the problem.

ov10fac:
Well, if your math is wrong, then so is mine. When I tried to use the numbers you suggest (the same ones I tried by the way) the motor seems to run at a high speed, no where near 6 RPM.

If you think my maths is wrong please point out the error.

If my maths is correct then, if it works with your numbers, there is something really weird going on.

Ignoring the maths is a complete waste of time because you won't be looking for the real problem.

...R

Robin2:
If you think my maths is wrong please point out the error.

If my maths is correct then, if it works with your numbers, there is something really weird going on.

Ignoring the maths is a complete waste of time because you won't be looking for the real problem.

...R

Sorry, you misunderstood. When I did the math I got the same numbers you did. I agree, being an Engineer by trade Math is critical to anything.

jremington:
The real problem is that you do not know anything useful about the motor you have. Measure the winding resistance of the motor; that is very informative.

As for setting the current limit, microstepping will not work unless the current is actually limited by the driver in full step mode.

If you can't figure this out, either buy a motor that has a data sheet and use it according to specifications, or live with the problem.

You are correct. So I changed the motor to a PM42L-048 that I could find a datasheet for. Max current per coil seems to be 600mA and I have it set to 500.

Its still "jerky" but I am thinking I may have to live with it.

motor.pdf (297 KB)

ov10fac:
You are correct. So I changed the motor to a PM42L-048 that I could find a datasheet for. Max current per coil seems to be 600mA and I have it set to 500.

Its still "jerky" but I am thinking I may have to live with it.

Can you make a short video and post it on YouTube so we can see what you mean by "jerky" ?

Also post the complete program that was used when making the video.

...R

The 8825 reset and sleep pins need to be connected to Vdd if not used.
0J4232.600.png

The data sheet for the motor posted in reply #10 gives two options: high impedance 60 Ohms and low impedance 7 Ohms.

Which do you have?

Microstepping won't work with the high impedance motor and a 12V power supply.

Dumb question, is the PM42L-048 wired as bipolar? Looks like a big difference between unipolar 60 Ω and bipolar 7Ω.

Wired as bipolar, there are only 4 wires. It measures out at between 6.4 and 7 ohms. I tested it at 1 and 16 microsteps and it definately is faster at one as I would expect keeping everything else constant of course.

The spece sheet on the A4988 also allows reset and sleep to be jumpered. That is the way I have always configured them and they seem to run just fine. I have attached the diagram from Pololu as reference.

a4988 diagram.png

I have swapped the motor with a 23 NEMA motor that uses 1.8 degree/step. I will check that out later today using a delay of about 3 milliseconds.

Thanks everyone for your ideas and suggestions. This is a true puzzle.

a4988 diagram.png

Please display your image(s) in your post so we can see it(them) without downloading it(them). See this Simple Image Guide

...R

Robin2:
Please display your image(s) in your post so we can see it(them) without downloading it(them). See this Simple Image Guide

...R

I was wondering how to do that. Other forums make it a little less complex. I inserted it. Thank you for the link.

Someone asked for a YouTube video: Here it is:

While making the clips I accidently disconnected one of the coils (clip one). I noticed the motor was stepping 24 steps per rev. That would indicate no microstepping. So connected the coil and it ran OK, still jerky but not as much and when I slowed the motion down I saw 48 steps per revolution. So I think what is happening is the motor is not accepting the microsteps. I will have to re-evaluate the code I am using and I need to change the current to more closely match the Spec Sheet. The last clip is a NEMA23 and it runs just fine with the 1/16 steps.

Here is the code I am using:

      /*     Simple Stepper Motor Control Example Code
     *
     *  by Dejan Nedelkovski, www.HowToMechatronics.com
     *  modified by John Wright
     *
     */
    // defines pins numbers
    const int stepPin = 6;
    const int dirPin = 5;
    const int enablePin = 12;
    const int ms1Pin = 11;
    const int ms2Pin = 10;
    const int ms3Pin = 9;

    void setup() {
      // Sets the 6 pins as Outputs
      pinMode(stepPin,OUTPUT);
      pinMode(dirPin,OUTPUT);
      pinMode(ms1Pin, OUTPUT);
      pinMode(ms2Pin, OUTPUT);
      pinMode(ms3Pin, OUTPUT);
      pinMode(enablePin, OUTPUT);

      //Initial motor configuration
      digitalWrite(enablePin,LOW);
      digitalWrite(stepPin,HIGH);
      digitalWrite(dirPin,HIGH);
      digitalWrite(ms1Pin,HIGH);
      digitalWrite(ms2Pin,HIGH);
      digitalWrite(ms3Pin,HIGH);
    }
    void loop() {

        digitalWrite(stepPin,HIGH);
        //delayMicroseconds(3000);  //1.8 degrees/step
        delayMicroseconds(26000); //7.5 degrees/step
        digitalWrite(stepPin,LOW);
     }

This comment (from the code in Reply #17) is irrelevant. As far as the Arduino is concerned the interval between steps is entirely unrelated to the step angle. The Arduino has no knowledge of the step angle.

delayMicroseconds(26000); //7.5 degrees/step

That interval is equivalent to about 38 steps per second if my maths is correct.

If you are using the same program with the Nema 23 motor and using microsteps I would expect it to be moving much more slowly.

The best way to check for steps per revolution is to get the motor to move that expected number of steps and see if the flag on the motor shaft gets to the same place each time.

...R

delayMicroseconds(26000); //7.5 degrees/step

Unless it has been recently changed, delayMicroseconds() will only do 16383 max.
26000 might be truncated to 9616.