Arduino Uno R3 and Stepper Motor And A4988

Please help if you like. I bought the Arduino Uno R3, the Pololu A4988 and a stepper motor and I can't quite get the stepper motor to make one revolution in 200 steps as it rotates in one direction, stops, moves a few steps and reverses direction. I use the Arduino script for stepper motor. I am very new to all of this. Does Arduino have a pinout for the Uno R3? I find the pins and headers confusing. Does Arduino have a step by step explanation on how to get a stepper motor to function? Thanks.

The first thing you need to do is post your code here. Second we need to know which SPECIFIC stepper motor you are using.

/*
Stepper Motor Control - one revolution

This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.

The motor should revolve one revolution in one direction, then
one revolution in the other direction.

Created 11 Mar. 2007
Modified 30 Nov. 2009
by Tom Igoe

*/

#include <Stepper.h>

const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8,9,10,11);

void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
}

void loop() {
// step one revolution in one direction:
Serial.println(“clockwise”);
myStepper.step(stepsPerRevolution);
delay(500);

// step one revolution in the other direction:
Serial.println(“counterclockwise”);
myStepper.step(-stepsPerRevolution);
delay(500);
}

NEMA 11-size hybrid bipolar stepping motor has a 1.8° step angle (200 steps/revolution). Each phase draws 670 mA at 4.5 V, allowing for a holding torque of 950 g-cm (13 oz-in). 28mm x 45mm. Current rating: 670 mA per coil. Voltage rating: 4.5 V. Resistance: 6.8 ? per coil. Holding torque: 950 g-cm (13 oz-in). Inductance: 4.9 mH per coil.

I guess this about does it. Thanks.

What power supply are you using? I hope you are not trying to power the motor from the Arduino 5v pin.

If you have everything wired up as in the Pololu A4988 page (assuming your A4988 is compatible) this simple code should work - it doesn’t use any library.

// testing a stepper motor with a Pololu A4988 driver board or equivalent
// on an Uno the onboard led will flash with each step
// as posted on Arduino Forum at http://forum.arduino.cc/index.php?topic=208905.0

byte directionPin = 6;
byte stepPin = 5;
int numberOfSteps = 100;
byte ledPin = 13;
int pulseWidthMicros = 20;  // microseconds
int millisbetweenSteps = 25; // milliseconds


void setup() 
{ 

  Serial.begin(9600);
  Serial.println("Starting StepperTest");
  digitalWrite(ledPin, LOW);
  
  delay(2000);

  pinMode(directionPin, OUTPUT);
  pinMode(stepPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  
 
  digitalWrite(directionPin, HIGH);
  for(int n = 0; n < numberOfSteps; n++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(pulseWidthMicros);
    digitalWrite(stepPin, LOW);
    
    delay(millisbetweenSteps);
    
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
  
  delay(3000);
  

  digitalWrite(directionPin, LOW);
  for(int n = 0; n < numberOfSteps; n++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(pulseWidthMicros);
    digitalWrite(stepPin, LOW);
    
    delay(millisbetweenSteps);
    
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
  
}

void loop() 
{ 

}

…R

I started with the video posted on YouTube: https://www.youtube.com/watch?v=lvaBb-rPepY But according to Pololu the motor wiring to the A4988 as displayed during the aforementioned video was incorrect. I corrected it and it didn't make any difference. Plus I made the possible mistake of setting my variable 300mA voltage converter from Radio Shack to 7.5 volts when the stepper motor specs rate it as 4.5 volts dc. I have yet to assemble the components according to the Pololu diagram. I just got through looking up all the abbreviations in the Pololu diagram like VMOT etc. and I'm set to begin assembly. Thanks for the code.

nervousenorvus: Plus I made the possible mistake of setting my variable 300mA voltage converter from Radio Shack to 7.5 volts when the stepper motor specs rate it as 4.5 volts dc. I have yet to assemble the components according to the Pololu diagram. I just got through looking up all the abbreviations in the Pololu diagram like VMOT etc. and I'm set to begin assembly. Thanks for the code.

The high voltage is not a problem - the A4988 can take 35v (I think). But you said your motor needs 670mA per coil (1.34A total) and your power supply can only provide about 1/5th of that. Get a decent power supply that can provide 2 amps (or more) at 12v or 20v.

Just make sure to set the current limit on the A4988 to suit your motor.

The wiring diagram on the Pololu A4988 web page works.

Make sure there is no possibility of the connection between the driver and the motor disconnecting (e.g. loose connection) while powered up - it will ruin the A4988.

...R

Are you sure your step per revolution is the one that suits your motor ?

Arman5592: "Are you sure your step per revolution is the one that suits your motor ?" What do you mean, exactly? The specifications say 200 steps per revolution.

Robin2: "Just make sure to set the current limit on the A4988 to suit your motor." I don't know what you mean. How can I set the current limit to suit the motor? Please explain.

nervousenorvus: Robin2: "Just make sure to set the current limit on the A4988 to suit your motor." I don't know what you mean. How can I set the current limit to suit the motor? Please explain.

The Pololu A4988 web page explains it much better than I can, or is there something on that web page that you don't understand?

...R

I'll tell ya Robin, it's all greek to me. Links posted by people on this site and references given only lead me to more greek. The acronyms and concepts are all foreign. I have no background in electronics or electricity although I rewired my house from breaker box to every last switch, receptacle and light fixture. Anyone with money and time can do it. I saw the "dial" on the A4988 but have never touched it. Knowledge on projects using Uno and the various controllers is sporadic and spread across the internet. Most answers I get are vague. I argue that Pololu and Arduino would sell a lot more of their stuff if they made videos with precise instructions and named products to create projects. The A4988 diagram is vague. What is logic power supply and motor power supply? Supplied by what, exactly? Why the spread in voltage? The "reset - step - dir" detailed by the blue lines isn't explained. Amper values are not mentioned. It's like everyone wants to keep things a secret. Instead of answering my question or saying "I don't know" you tell me you can't explain it better than Pololu can and then you ask me if there is something on the web page that I don't understand. Why would you ask that when you say that you are unable to explain yourself regarding: Robin2: "Just make sure to set the current limit on the A4988 to suit your motor.". You say you aren't as knowledgeable as the Pololu text yet ask me what I don't understand in the Pololu text. You just said you couldn't explain as well as Pololu. If you ever forget your Windows7 password and have the installation disc I can tell you exactly how to open the command prompt and what code to enter to reset your password. I discovered the final lines of code myself. I'll help people from soup to nuts without wasting their time. I asked "Claire" from Pololu to expalin everything regarding the A4988 diagram. I'm curious if she will tell me or try to get me to buy something.

nervousenorvus: Instead of answering my question or saying "I don't know" you tell me you can't explain it better than Pololu can and then you ask me if there is something on the web page that I don't understand. Why would you ask that when you say that you are unable to explain yourself regarding:

Enough already ...

Why this long rant?

I assumed you had not read the Pololu page and that you would understand it when you did read it. I also left open the possibility that you might not understand it so that you would feel free to ask questions about the instructions.

It's very difficult to communicate with someone when you don't know their level of background knowedge.

This is the image from the Pololu page. I will try to answer your questions - but probably not all in this one post. Let me know if there is more that I need to explain.

Vdd can be connected to Arduino 5v pin GND to the Arduino GND Step and Dir are connected to 2 of the Arduino digital pins - say 5 for Step and 6 for direction The motor coils are connected to the 2A and 2B and 1A and 1B connections The motor power supply (8-35v and enough amps for your motor) is connected to VMot and GND beside it. You need to connect reset to sleep

The motor power supply is quite independent of the Arduino power supply because the motors work best with higher voltages and they also need more current than you could draw from the Arduino board.

It is very important NOT to disconnect the connection from the A4988 to the motor while the A4988 is powered up - even a brief disconnect will probably damage the A4988.

To set the max current you need a multimeter to measure the voltage between GND and the test point. The web page explains how to relate the measured voltage to the current.

If you need more advice I will try to help - but no more long rants please. (Or at least break them into paragraphs for easier reading)

...R

PS ... how many times did you read the Pololu page? I find it often takes me 10 or more readings to make sense of stuff.

I'm asking if you're sure your MOTOR is 200 steps per revolution as the sample code is ? Are you sure you have the right motor for the driver ? Are you sure you've connected it the right way ?

I'm asking if you're sure your MOTOR is 200 steps per revolution as the sample code is ? Are you sure you have the right motor for the driver ? Are you sure you've connected it the right way ?

I still can't figure out your logic. Specifications on the Pololu page say that my particular stepper motor is 200 steps per revolution. NEMA 11-size hybrid bipolar stepping motor has a 1.8° step angle (200 steps/revolution). The Pololu page recommended the A4988. I misconnected the wiring to the A4988 due to the instructions I followed on a YouTube video. BUT, after noticing the paragraph detailing the correct wiring sequence on the Pololu FAQ for this item I then reconnected the four wires. But it didn't make any difference in this situation. The stepper was as erratic as ever. Sometimes I think I got a faulty stepper motor. Everybody is high on connection. Pololu sells "premium jumper wires, stranded 26 American Wire Gauge, with female terminations on one end and male terminations on the other end." Yeah. Right. Try sticking the male "termination" into the padded through hole of the A4988. It's like using a 5/16th" nut on a 1/4" bolt. Do I take the time and solder it? No. I snipped off the "termination" and stripped 2" of insulation off the wire and twisted the wire until it could twist no more and I made a sharp bend in the wire and inserted it into the padded through hole and took the time to twist the wire tightly. I then used a magnifying glass to examine in great detail the wire contact and the placement of the wire in relation to the other wires so as to prevent contact and catastrophe. Ultimately I want to solder 6" lengths of wire to all the padded through holes on the A4988 and secure it to a piece of HDPE aka StarBoard or Seaboard in some fashion but keeping both sides accessible.

nervousenorvus: I misconnected the wiring to the A4988

...SNIP....

and twisted the wire until it could twist no more and I made a sharp bend in the wire and inserted it into the padded through hole and took the time to twist the wire tightly

Don't bother about the number of steps at this stage - it is irrelevant to getting the motor to move - you only need to worry about the number of steps when you want to position the motor accurately.

There is every possibility that the A4988 got damaged when it was misconnected - and at your level of experience it will be difficult to be certain without another good one to compare it with. It is FAR more likely that the A4988 is damaged than that the motor is faulty.

You MUST solder the wires to the A4988 or fit pins (also soldered in place) so you caan plug it into a suitable socket. Tying the wires on creates a real possibility of intermittent contact which can damage the board.

...R

PS - after taking the trouble to write a long response to your earlier Rant I thought you might have bothered to acknowledge my effort or even to apologize for your rant.

Hi, nervousenorvus, before we get any further, how much experience have you had with Arduino, electronic construction, electronic theory and programming.

Please read http://forum.arduino.cc/index.php/topic,148850.0.html

Tom… :slight_smile: