Inaccurate stepping when changing directions.

131 views
Skip to first unread message

Mahdi Ashktorab

unread,
May 14, 2013, 4:36:26 PM5/14/13
to accels...@googlegroups.com
Hello,

I'm using AccelStepper V1.31. I'm using this stepper motor: https://www.sparkfun.com/products/9238 with the big easy driver.

I noticed when I tell it to move 200 in once direction, then 200 in the other, it fell about 2 steps short.

So then I told it to move 1 step in both directions. No problem.

So then I told it to move 2 steps in both directions. This resulted in no movement. Very weird. Any ideas?

Brian Schmalz

unread,
May 14, 2013, 5:06:07 PM5/14/13
to accels...@googlegroups.com
Sounds to me like you have your current adjustment pot set wrong. If it's too low, the motor may not be able to actually move the full step every time. If it's too high (depending on your motor and your power supply and what you're driving with your motor) it make skip some of the microsteps.

So try this. Have it move 1 step forward, then 1 back. Then 2. Then 3. Then 4. All the way to 16 forward and 16 back. Note which ones actually cause movement of the shaft (sometimes just feeling the shaft with your fingers can be enough to tell). Then adjust the current set pot as you do this until you find a good spot where it works every time for each step number.

*Brian

From: accels...@googlegroups.com [accels...@googlegroups.com] on behalf of Mahdi Ashktorab [ashk...@gmail.com]
Sent: Tuesday, May 14, 2013 3:36 PM
To: accels...@googlegroups.com
Subject: [accelstepper] Inaccurate stepping when changing directions.

--
You received this message because you are subscribed to the Google Groups "accelstepper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Mahdi Ashktorab

unread,
May 14, 2013, 5:37:51 PM5/14/13
to accels...@googlegroups.com
I tried this with no result.

I don't think that is the issue. Because if I write my own code, this problem doesn't arise. It's only when I use AccelStepper. Maybe the direction change is happening too close to the Step pulse, which causes it to not move properly?

Regards,
Mahdi Ashktorab


--
You received this message because you are subscribed to a topic in the Google Groups "accelstepper" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/accelstepper/b1bUF-naqGg/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to accelstepper...@googlegroups.com.

Brian Schmalz

unread,
May 14, 2013, 5:50:35 PM5/14/13
to accels...@googlegroups.com
Ahh, OK. If your code works, and AccelStepper doesn't then it must be something with AccelStepper, not the Big Easy Driver.

*Brian

Sent: Tuesday, May 14, 2013 4:37 PM
To: accels...@googlegroups.com
Subject: Re: [accelstepper] Inaccurate stepping when changing directions.

Mike McCauley

unread,
May 14, 2013, 6:20:00 PM5/14/13
to accels...@googlegroups.com
Hello. In time honored fashion please post some code so we can reproduce this. Does it depend on the selected speed or the the number of steps?

Sent from my iPhone
--

Mahdi Ashktorab

unread,
May 14, 2013, 10:25:49 PM5/14/13
to accelstepper
My code not using AccelStepper: 

void setup() {                
  pinMode(2, OUTPUT);     
  pinMode(3, OUTPUT);
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
}
int i = 0;
void loop() {
  
  while (i < 2){
    digitalWrite(3, HIGH);
    delayMicroseconds(800) ;         
    digitalWrite(3, LOW); 
    delayMicroseconds(800)  ;
    i = i + 1;   
  }
if (i == 2){
  delay(1000);
   i = 0;
   digitalWrite(2, HIGH);
    while (i < 2){
    digitalWrite(3, HIGH);
    delayMicroseconds(800) ;         
    digitalWrite(3, LOW); 
    delayMicroseconds(800)  ;
    i = i + 1;   
  }
  delay(1000);
  digitalWrite(2, LOW);
  i = 0;
 
}
}

//////////////////////////////////////////////////////////////////////

Using AccelStepper:

//This is an example of how you would control 1 stepper

#include <AccelStepper.h>

int motorSpeed = 800;//10600; //maximum steps per second (about 3rps / at 16 microsteps)
//int motorAccel = 80000; //steps/second/second to accelerate

int motorDirPin = 2; //digital pin 2
int motorStepPin = 3; //digital pin 3

//set up the accelStepper intance
//the "1" tells it we are using a driver
AccelStepper stepper(AccelStepper::DRIVER, motorStepPin, motorDirPin); 



void setup(){
 stepper.setMaxSpeed(motorSpeed);
 stepper.setSpeed(800);
// stepper.setAcceleration(100000);
 
 //stepper.moveTo(100); //move 32000 steps (should be 10 rev)
}
int i = 1;
void loop(){
  
  if (stepper.distanceToGo() == 0)
    {
    delay(1000);
    stepper.move(2*i);
    stepper.setSpeed(600);
    i = -1 * i;
    }
    stepper.runSpeedToPosition(); 
}

Regards,
Mahdi Ashktorab


--
You received this message because you are subscribed to a topic in the Google Groups "accelstepper" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/accelstepper/b1bUF-naqGg/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to accelstepper...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages