Go Down

Topic: Controlling a Stepper Motor with RAMPS V1.4 Controller (Read 6701 times) previous topic - next topic

Fuzzyzilla

Aug 27, 2016, 08:26 am Last Edit: Aug 27, 2016, 08:35 am by Fuzzyzilla
Hello, World!
First post -- Do correct me if I say anything stupid  :)

I am using a RAMPS V1.4 shield - Link
Hardware:
Arduino Mega 2650
RAMPS V1.4 Shield
Connected on the shield, in the area labeled "X," is a A4988 stepper driver. Connected above that, of course, is a 4-pin 200 step stepper motor.

As you can see by This image, pins A0(D54), A1(D55), D2, D3, and D38 are all associated with this stepper driver. This seems correct, as I have seen many people use these same pins for X-axis motors in their firmware. Two of them, X-MAX and X-MIN, might not even relate to the stepper. This leaves 3 pins, which still doesn't help much.

My question is -- In what order do these appear in firmware? After ~4 hours of research, I have come up empty handed. Many of the forums related to the Stepper.h library simply refers to the arguments needed in the constructor as pin 1, pin 2, pin 3, pin 4, <pin 5> -- and I don't know which ones it's referencing! I could try every combination of all of those pins, but that can easily cause damage.

So I have my pins - I have my hardware. Now I just need to know in which order the pins go.

So I have, at the moment, this very raw test code. Marked with ?? is where confusion is struck.
Code: [Select]

#include <Stepper.h>

Stepper xAxis(200, ??);

void setup(){
    xAxis.setSpeed(60);
}
void loop(){
    xAxis.step(10);
}

So, very simple code to rotate the stepper at 60 rpm.

So far, I have been able to make the stepper motors vibrate. This is what caused me to realize that trying all possible combinations was going to make something catch fire :)

Robin2

The standard stepper library is not suitable for A4988 stepper drivers. Either use the AccelStepper library (with the DRIVER option) or just write your own code. See the examples in this Simple Stepper Code

I suggest, for testing, that you use my Simple Stepper example for each motor in turn.

Please post a link to the datasheet for your motor.
And tell us what power supply you are using for the motors (volts and amps).

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

Fuzzyzilla

Thank you for your reply!

My stepper's datasheet  :  None found, but I'll tell you what I know!

  • NEMA 17
  • 1.8 degree
  • 6 pins
  • 5300g/cm
  • 3.4V
  • 1.5A
  • Link to the page where it was bought
  • You can plug it in backwards and reverse the direction (not sure if this is important!)


Powersupply:

  • Output: 12V DC, 3A
  • Input: 100-240V AC, 50-60Hz, 0.16-0.36A


The power supply makes the arduino board power on, and can move the steppers (As I learned from their shaking!). I won't be using more than 2, so that's a good amount of amperage.

Thank you very much for your reply, I would've never guessed that the stepper library didn't support these! That probably explains why no one I saw using a RAMPS board used it...

Robin2

If you still have problems after trying my suggestions let us know.

Be sure to set the current limit on the A4988 board to 1.5 amps or the 12v supply may fry the motor and the A4988. The Pololu A4988 page explains how to set the current limit.

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

Go Up