Stepper Motor not Rotating enough using A4988 Stepper Motor Driver

Hi All,

I currently have an issue with a stepper motor I have connected to a A4988 and an Arduino Uno.

The Problem:

I am sending a command to rotate the stepper motor one full rotation but the motor is only rotating maybe a quarter of that distance. I am sending commands to the stepper motor driver to pulse the stepper motor 200 times. The stepper motor's step angel is 1.8 degrees so with 200 steps it should rotate 360 degrees or one full rotation. The motor turns approximately 1/4 rotation.

The Components:

Arduino Uno
Pololu A4988 Stepper Motor Driver
Stepper Motor

The Setup:

Arduino connected to stepper motor driver, stepper motor driver connected to stepper motor. Power supply powering stepper motor driver is 12v 1000mA. Capacitor on stepper motor power supply is 100uF, 35v. Arduino powered by 5V pc USB. Picture of connections is below:

The only difference being Step pin is connected to Pin 4 on the Arduino and Dir pin is connected to Pin 3 on the Arduino.

The stepper motor is set in full step mode.

The Code:

const int stepPin = 4;
const int dirPin = 3;
void setup() {
  // put your setup code here, to run once:
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
 test();
}

void test(){
 digitalWrite(dirPin, HIGH);
  // Makes 200 pulses for making one full cycle rotation
  for (int i = 0; i < 200; i++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(500);
    //Serial.println("we did it!.");
  }
}

I haven't been able to tell why the stepper motor is not turning a full rotation when as far as I can tell it should be. Any thoughts would be great.

Thanks!

First thing, you're trying to go from 0 to 1000 steps per second instantly, probably missing lots of steps, try:

    digitalWrite(stepPin, HIGH);
    delayMicroseconds(20);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(5000); // 5 thousand

Report back.

These links may help.
Stepper Motor Basics
Simple Stepper Code

And, as suggested in Reply #1 start testing with a very slow step rate - maybe just 2 to 5 steps per second.

Have you correctly adjusted the current limit for the A4988.

...R

Thank you JCA34F and Robin2 that worked perfectly! The motor is behaving as expected now.

Robin2 to answer your question about adjusting the current on the A4988...I have...kind of... I find the process to be quite tricky to actually do. I don't know if I am just not using the right tool but when I turn the potentiometer the current change I see when I am measuring it is almost negligible sometimes and other times swings drastically. I am using a small screwdriver but it never seems to interface with the potentiometer correctly. I sadly broke the top off an earlier one when trying to adjust it... I think from turning it too much because I was seeing no change. I was measuring the current change using this setup with my multimeter:

On the first A4988, I was at least able to get a sensible reading but not able to adjust the current much at all. On the second one, my multimeter only reads 1 as I am trying to read it when the multimeter is set at 200mA and the current is apparently above that. If I change to the next highest setting on my Multimeter of 10A I get a ~0 reading. My multimeter is a Sparkfun VC830L which you can see here. I have tried moving the red lead on the multimeter over to the 10A port rather than the mAVOhm port but I see the above behavior. This is making it really difficult for me to correctly set the current. I'd like to get this resolved as running the stepper as is, it gets very hot, and I am sure it isn't good for it. Any advice would be great!

Thanks,

Gorilla

Be VERY CAREFUL never to disconnect the wires between the motor and the stepper driver while the driver is powered up. The driver will be instantly destroyed.

I presume your motor was stationary when you were checking the current.

The Pololu A4988 web page has good info about setting the current by measuring a voltage. Just make sure you allow for the actual current sense resistors on your A4988 - they may not be the same as on the Pololu board.

...R

Thanks Robin2! I had read about that danger and I am being careful about it.

I have read and reviewed the current limiting information on the Pololu A9488 web page previously but I find the difficulty is in actually getting the current to change when I am trying to turn the potentiometer. I think it might be the screwdriver I am using. What do you use to adjust the potentiometer? How much do you typically have to turn it? Also, as I mentioned above I don't think my multimeter is sensitive enough to be able to sense the current at this level. I am most likely missing something there, any thoughts?

Assuming I want to set the current limit to 400mA I should be setting VREF to ~220mV?

Vref=80.400A0.068Ohms
Vref=~220mV

I am not exactly sure where to measure Vref? I know the Pololu web page says that "The VREF pin voltage is accessible on a via that is circled on the bottom silkscreen of the circuit board" and I do see two via's on the underside that seem to be circled... (See attached)

Is that what I am looking for? How would I measure that while it's in use on a breadboard?

This thread on current adjustment for the A4988 might help.
https://forum.arduino.cc/index.php?topic=415724.0