Go Down

### Topic: Stepper "jerky" (Read 1 time)previous topic - next topic

#### Robin2

#30
##### Jan 17, 2019, 09:14 pm
That's a lovely video - short and to the point.

What program produced that motion?

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

#### ov10fac

#31
##### Jan 18, 2019, 02:58 am
That's a lovely video - short and to the point.

What program produced that motion?

...R
Code: [Select]
`        /*     Simple Stepper Motor Control Example Code     *     *  by Dejan Nedelkovski, www.HowToMechatronics.com     *  modified by John Wright     *     */    // defines pins numbers and constants const unsigned long stepInterval = 50000UL;    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(stepInterval);  //1.8 degrees/step        delay(10);        digitalWrite(stepPin,LOW);        }        delay(1000);    }`

#### Robin2

#32
##### Jan 18, 2019, 09:08 am
My interpretation of your code and the video is that it is moving a few steps for every 48 pulses and the pause is the delay(1000) in your code.

Put some Serial.print statements in your code so you can relate the behaviour of the code to the action of the motor.

Try a very much slower step rate - maybe as low as 1 step per second to start with.

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

#### ov10fac

#33
##### Jan 18, 2019, 04:44 pm
My interpretation of your code and the video is that it is moving a few steps for every 48 pulses and the pause is the delay(1000) in your code.

Put some Serial.print statements in your code so you can relate the behaviour of the code to the action of the motor.

Try a very much slower step rate - maybe as low as 1 step per second to start with.

...R
Thats exactly what I think is happening.  I think it is stepping one step for every 16 pulses from the stepPin.  But I don't know why it is doing that.  I thought it might have been a voltage issue as from what I have read stepping is pretty dependent on voltage.  So I increased the voltage to 20 volts and still observed the same behavior.  So I thought maybe the motor is not right, so changed it out with another PM stepper I have and it did the same thing.  However as I mentioned earlier in this thread, the nema 23 motors I have run very smoothly with this configuration.  So I am begniing to wonder if the PM motors are capable of stepping in microsteps?  I even tried different stepping rates by changing the values of the ms pins.  Still got the same results except the speed changed as the stepping rate changes as I would expect.

I put a print statement to show each of the 48 steps and they are just fine.  Next I will be checking the value of the stepPin to see what it is doing.  I have used step rates down to 50 milliseconds and as the delay decreases the motion smothes out but the presence of step is still obvious.  I thought I might have a connection issue so did some reversing of wires and continued to get the same results.

#### Robin2

#34
##### Jan 18, 2019, 06:52 pm
I put a print statement to show each of the 48 steps and they are just fine.
Have you watched the motor to see what it does for each of the 48 steps?

Quote
I have used step rates down to 50 milliseconds
I reckon that is still very fast - try 1000 millisecs.

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

Go Up