Go Down

Topic: Stepper "jerky" (Read 865 times) previous topic - next topic

ov10fac

#15
Jan 14, 2019, 03:23 pm Last Edit: Jan 14, 2019, 04:07 pm by ov10fac
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.



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.

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
Two or three hours spent thinking and reading documentation solves most programming problems.

ov10fac

#17
Jan 14, 2019, 04:08 pm Last Edit: Jan 14, 2019, 06:57 pm by ov10fac
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:

https://www.youtube.com/watch?v=4UWbLKpTpFs

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:

Code: [Select]

      /*     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);
     }

Robin2

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.
Code: [Select]
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
Two or three hours spent thinking and reading documentation solves most programming problems.

outsider

#19
Jan 14, 2019, 10:23 pm Last Edit: Jan 14, 2019, 10:25 pm by outsider
Code: [Select]
delayMicroseconds(26000); //7.5 degrees/step
Unless it has been recently changed, delayMicroseconds() will only do 16383 max.
26000 might be truncated to 9616.

ov10fac

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.
Code: [Select]
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.

...
Robin,

The comment was just for me.  You will notice that there are two delayMicroseconds statements.  I set them up initially to step the different motors.  Here's the math I used for the code you indicates.  1/(number of steps per rev X 6 revolutions per minute*16 steps per step./60 seconds per minute).  That results in a delayMicroseconds of 013020833 seconds or 13020.833 microseconds for the 7.5 degree motor.  I doubled it so I could actually count the steps as the motor moved.

Yes I used the same program for both motors.  That way I was able to see if the PM motor acted the same way as the NEMA.  I expected the PM motor to be about 4 times faster than the NEMA everything else being constant.  (200 steps/Rev vs 48 steps/Rev.  That was not what I observed.  The PM motor was much faster which indicated to me that there was a problem with the microsteps.  Hence I am now trying to figure out why the PM motor doesn't seem to be accepting the microstep that is being sent by the controller or is the controller not sending the proper signal.  All open for evaluiation right now.  The LEDs on the two coils have given me some indications of what is going on, but just an indication.

I will do more experimenting later today.

ov10fac

Code: [Select]
delayMicroseconds(26000); //7.5 degrees/step
Unless it has been recently changed, delayMicroseconds() will only do 16383 max.
26000 might be truncated to 9616.
I believe its an unsigned int which has a max value of 4,294,967,295 or ANSI standard ≥+65,535.  So 26000 should be fine.


ov10fac

One other thing I have observed is that the motor gets very hot.  Too hot to even touch.  The spec sheet says max operating temp is 50C or 122F.  I think it is getting a lot hotter than that.

ov10fac

#24
Jan 14, 2019, 11:06 pm Last Edit: Jan 14, 2019, 11:12 pm by ov10fac
Check the reference.  :)
https://www.arduino.cc/reference/en/language/functions/time/delaymicroseconds/
Yep unsigned int as I said.  I wonder why the limitation?  The UNO uses a 2 byte int so an unsigned int should have a max value of 65535.  But that would sure answer a few questions.


Robin2

Yep unsigned int as I said.  I wonder why the limitation?  The UNO uses a 2 byte int so an unsigned int should have a max value of 65535.  But that would sure answer a few questions.
Use millis() and micros() rather than delayMicroseconds() as illustrated in the second example in this Simple Stepper Code


...R
Two or three hours spent thinking and reading documentation solves most programming problems.

ov10fac

Use millis() and micros() rather than delayMicroseconds() as illustrated in the second example in this Simple Stepper Code


...R
I'll try that tomorrow.  Today I modified the code to actually step 48 steps and stop.  It took 16 iterations to complete a 360 rotation.  So that tells me the microstepping is working.  However, the motor is acting strangely.  I observed that the motor steps 16 microsteps then stops for a few .1 seconds, then steps and stops.  I checked and I am sending the correct number of steps, but my observations is it steps 3 times than makes the 1 second delay.  Here is my new code:

Code: [Select]

        /*     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);

      Serial.begin(9600);

      //Initial motor configuration
      digitalWrite(enablePin,LOW);
      digitalWrite(stepPin,HIGH);
      digitalWrite(dirPin,HIGH);
      digitalWrite(ms1Pin,HIGH);
      digitalWrite(ms2Pin,HIGH);
      digitalWrite(ms3Pin,HIGH);
    }
    void loop() {
     for(int i = 0;i < 48; i++){

        digitalWrite(stepPin,HIGH);
        delayMicroseconds(13000);  //1.8 degrees/step
        digitalWrite(stepPin,LOW);
     }
     delay(1000);
    }

outsider

Try this here   :)
Code: [Select]


/*     Simple Stepper Motor Control Example Code

   by Dejan Nedelkovski, www.HowToMechatronics.com
   modified by John Wright

*/
// defines pins numbers
unsigned long stepTimer,
         stepInterval = 13000UL, //time between steps
         pulseLength = 20;
int stepsToGo = 48;

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);

  Serial.begin(9600);

  //Initial motor configuration
  digitalWrite(enablePin, LOW);
  //digitalWrite(stepPin, HIGH);
  digitalWrite(dirPin, HIGH);
  digitalWrite(ms1Pin, HIGH);
  digitalWrite(ms2Pin, HIGH);
  digitalWrite(ms3Pin, HIGH);
}
void loop()
{
  for (int i = 0; i < 768; i++)
  {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(13000);  //1.8 degrees/step
    digitalWrite(stepPin, LOW);
  }
  delay(4000);
}

ov10fac

Not sure what just defining these variables will do?

unsigned long stepTimer,
         stepInterval = 13000UL, //time between steps
         pulseLength = 20;
int stepsToGo = 48;

Should I replace something?  Thanks

ov10fac

Ok,
So thought it might be a voltage issue.  Switched to a 20 volt source this morning and took a movie of what the rotation looks like.
See the video here:

https://youtu.be/e-rdJ8q6aLQ


As you can see, there is a definate 3 steps for every interval.  As I said the time to complete one revolution is sixteen intervals.  That is 48 total steps per revolution, so I am unclear what this motor is really doing.  My gut feeling is that the microstepping is not working on this motor althought I am not sure why.

Go Up