Problems driving a stepper motor

Hi guys

I am having a problem driving a stepper motor using the A4988 driver and an Arduino
I have set up the wiring using an example I found online (Diagram attached) How To Control a Stepper Motor with A4988 Driver and Arduino - YouTube. However the motor does not seem to turn.

The motor I am using is from an old Hitachi printer which I took apart a while back. Printed on it is 0.9A/ph. It has six wires however I am using it as a bipolar stepper by just leaving the center tap of each winding unconnected.

I have adjusted the VREF on the A4988 board to insure that the current is limited bellow the 0.9A. To do this I used the data sheet of the A4988. As I wanted to run the motor at full step mode, the A4988 data sheet specifies that the winding current could only reach 70 percent of the current limit.

consequently:
Current limit = 0.9 * 0.7 = 0.63A

Current limit = Vref * 2, Therefor Vref = 0.63/2 = 0.315V or 315mV

I have therefor set the current limit using the potentiometer on the A4988 to aprox 315mV

Once the wiring was set up, I applied power and measured the Vref to confirm it is still the same and it was.

Next I disconnected the Power to both the Arduino and the driver and connected in the stepper motor. I then connected the power and uploaded the following code:

// defines pins numbers
const int stepPin = 3;
const int dirPin = 4;

void setup() {
// Sets the two pins as Outputs
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
}
void loop() {
digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x < 200; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
delay(5000); // five second delay

digitalWrite(dirPin,LOW); //Changes the rotations direction
// Makes 400 pulses for making two full cycle rotation
for(int x = 0; x < 400; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
delay(5000);
}

Nothing happened... started off with 5 volts on the power supply and ramped it up to aprox 12vs however still nothing happened. I can feel the heat sink heating up on the A4988 which means power was reaching it. I measured the voltages from the Arduino to the A4988 and the power supply to the driver and the voltages matched the input. I started shaking about the power connections to and suddenly the motor made one step, but that was it. So i thought it was a problem with the breadboard. I checked the connections on the breadboard and all where connected. To be safe i decided to use another breadbord. Again nothing happened. I checked the Aarduino using the 28byj48 and UNL203 driver and stepper that came with it and they worked fine. I confirmed the wiring sequences and layout multiple times and they all matched the tutorial I followed.

My inital thinking was that the stepper motor was broken, so i disconnected it and tried running it using the power supple (5V) by connecting and disconnecting each coil in manually one by one, and it turned one step at a time, which meant that the stepper was working. Finally i decided to see if current was reaching the stepper, I therefore connected the Altimeter in series with one of the coils and it did not read any current, which meant that current was not reaching the coils.

Now i am unsure what to do, or what has gone wrong. The vref still reads aprox 310 - 320 mV, this makes me assume that driver is not fried. I do have another A4988 driver however I started working on that one and now the Vref does not go above 62mV so I'm guessing that it is burnt, however the second one reads fine.

I would really appreciate an opinion on this issue as I have no idea what to do

Many thanks for you time.

Adnan

A4988 wiring.png

Do you have the enable pin wired and LOW? Motor supply needs to be more than 8V, won't work on 5V.

A couple of things you might try. Increase the step delays to two milliseconds or more for both hi & lo. MS1, MS2, MS3 not connected means highest level of microstepping (x16). Ground out all three for full step. Also ground Enable, even though it is internally pulled down, the pulldown may not be working.

groundfungus:
Do you have the enable pin wired and LOW? Motor supply needs to be more than 8V, won't work on 5V.

I have tried using the enable button with the following code (2nd wiring Diagram attached) however it still didnt make in difference. As with regards to the power, I tried it with up to 12-13v, still didn't move. I did not want to push too much as the heat sink was getting really hot.

The following code is what i used for when I set the enabled to low (Note that the pin numbers have been changed)

int Index;

void setup()
{
pinMode(4, OUTPUT); //Enable
pinMode(2, OUTPUT); //Step
pinMode(3, OUTPUT); //Direction

digitalWrite(4,LOW);
}

void loop()
{
digitalWrite(3,HIGH);

for(Index = 0; Index < 2000; Index++)
{
digitalWrite(2,HIGH);
delayMicroseconds(500);
digitalWrite(2,LOW);
delayMicroseconds(500);
}
delay(1000);

digitalWrite(3,LOW);

for(Index = 0; Index < 2000; Index++)
{
digitalWrite(2,HIGH);
delayMicroseconds(500);
digitalWrite(2,LOW);
delayMicroseconds(500);
}
delay(1000);
}

Due_unto:
A couple of things you might try. Increase the step delays to two milliseconds or more for both hi & lo. MS1, MS2, MS3 not connected means highest level of microstepping (x16). Ground out all three for full step. Also ground Enable, even though it is internally pulled down, the pulldown may not be working.

So are you saying the delay time is too small, it is not able to step fast enough? I will definitely try this out.
As with regards to the MS1-3 and enable grounding, I assume that pulling a ground connection from the Arduino to the breadboard and connecting all 4 to the same pin should be sufficient enough?

Another question is why did the motors initially step (only one step upon each shake) when I shook the power supply leads? I am afraid to try that again as I think this is what damaged the first driver I was using. And why is there no current reaching the coils?

(Thank you for you time and replies btw)

A4988 wiring 2.png

Image from Reply #3 so we don't have to download it. See this Image Guide

A4988 wiring 2.png
.
...R

Is it possible that you disconnected a wire between the motor and the A4988 while the A4988 was powered - that is a very good way to destroy the A4988.

Your wiring looks OK. The Pololu A4988 web page has a good diagram,

And I think your code should work - though I would start with slower steps.

Make the motor voltage as high as you can subject to the limit of the A4988 - IIRC that is 30v, but don't rely on my memory.

What is the resistance of the motor coils?

On my A4988s it is not necessary to connect the Enable pin.

...R
Stepper Motor Basics
Simple Stepper Code

Robin2:
What is the resistance of the motor coils?

I measured it at 9.4ohms aprox. The overall resistance of the motor is printed on the case however i cant remember it and I don't have the motor at hand right now.

What is the best method to test and see if the driver is fried?
Since the Vref is showing at 315mV, is it safe to assume that it isn't? where as the other driver does not go above 62mV any more, does that mean the other driver is?

And what about the current at the coils? what would be the most likely reason for the current not to reach the coils?

k1228438:
What is the best method to test and see if the driver is fried?

The best way is probably to get a known good one. Bitter experience has taught me always to buy at least one spare.

I'm not sure what you would see if you put an oscilloscope on the connections between the A4988 and the motor - but I doubt if anything other than an oscilloscope would be useful. Even with an oscilloscope it may be necessary to have a good driver to get a reference from which to judge the doubtful one.

I suspect you could fry the output sections of the driver without damaging the rest of it.

...R

Might I add, when trying to measure output current on a stepper driver that has been configured for 1/16 microstepping at an extremely high rate would probably not yield much, if anything, because of all the high speed current reversals.
Possibly one way to check the outputs would be to replace the motor with two 50 or 100 ohm resistors, set the driver for full step and send step commands at a very, very low rate, maybe 5 - 10 seconds per step and use a voltmeter across the resistors. If any current is flowing the voltage drop across the resistor should show it.