Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Increasing the speed of a stepper motor using the A4988 and


#1

Good night all. A4988 Adiquiri a drive with voltage regulator to develop my college project. The idea is to use the arduino to make some moves with a shaft on a table. I made the circuit of the assembly and the engine worked well and made the move I planned, but the problem and in relation to speed, because he’s too slow. Already tried everything i could not make it rotate faster. Already read the datasheet of the drive and tried combinations of connections but not worked. I am using an engine “Minebea 23km-C051-07V Step Motor Hybryd 1.8DEG 56 NEMA23 size of 9.9 kgf / cm” with a source “12V, 3A” and an Arduino Mega 2560. I really need help from you guys because my project is already too late. I am at the disposal for any clarification. Thank you.


#2

Hello.

What kind of speed are you getting and what kind of speed are you hoping to get (and what things have you tried so far to make it go faster)? Can you post a link to the datasheet for your stepper motor? What are you using for your power supply and what do you have the current limit set to on the driver? Can you post your code?

- Ben


#3

Hello Ben. Thanks for responding. The speed of rotation and to have around 120 RPM. I do not know how much until I increase, however would like more, something in 1000 or 2000 RPM. I know that when I lose the speed increase torque, but has no problem because the torque does not interest me. Already tried setting the MS1, MS2 and MS3 according to the table on page 6 of the A4988 datasheet, already made ​​several modifications in the arduino code shown below, already used a font adjustable to provide a higher voltage, but not getting success. I am currently using a source of 12V, 3A.
–Link to the stepper motorhttp://www.robocore.net/modules.php?name=GR_LojaVirtual&prod=362
–Code of arduino

void setup() 
{ 
  pinMode(9, OUTPUT);       // Motor Dir
  pinMode(10, OUTPUT);     // Motor Step
  }
void loop() 
{
  Pololu_A4988_Example();
}

void Pololu_A4988_Example()
{  
  delay(500);   // delay for Controller startup
  digitalWrite(9, HIGH);     // Turn left
  for(double i = 0; i < 5000; i++)  //5000 steps in one direction
  {   
    digitalWrite(10, HIGH);
    delay(1);
    digitalWrite(10, LOW);
    delay(1);
  } 
  delay(500);   // delay for Controller startup
  digitalWrite(9, LOW);     // Turn left
  for(double i = 0; i < 5000; i++)  //5000 steps in one direction
  {   
    digitalWrite(10, HIGH);
    delay(1);
    digitalWrite(10, LOW);
    delay(1);
  } 
  delay(1000);
} 

Driving a Stepper Motor with A4988
#4

Does the stepper motor turn when you run the code you posted? If so, can you post the faster-step code that did not work?

What do you have the A4988’s current limit set to? Also, I notice that your motor can be used as a unipolar or bipolar stepper; how do you have it connected to the A4988?

Generally speaking, you probably are not going to get more than a few hundred RPM from your stepper motor, but you should be able to do better than 120 RPM. There are a few main ways to increase your maximum step speed:

  1. Use a higher voltage. This lets the current ramp up faster every time you step and allows for a higher average current at high step rates.
  2. Set the current limit to the maximum allowed by your stepper motor. Unfortunately, you are using a stepper motor rated at 2 A per coil, but the driver you are using can only deliver around 1 A per coil without overheating. Adding a heat sink would let you get a little more current out of it, but I don’t expect you can get the full 2 A per coil out of it.
  3. Ramp the stepper speed up slowly. You can get the stepper motor to a much higher speed if you gradually increase your speed over time rather than trying to start at the maximum speed from rest.
  4. Decrease the external load on the stepper. The more torque your stepper motor needs to deliver, the lower it’s maximum step speed will be.

By the way, it looks like the datasheet for your motor has a lot of generally useful information on stepper motors on pages 29 and 30. Have you read that?

- Ben


DRV8825 STEP pulse width question
Problem with DRV8825
Question on test code for stepper
How to speed up step motor using mp6500?
Audible Frequency in Motor from MP6500
Issue about Distribution Enough Current For Motor
Choice of stepper motor drivers
#5

Hello Ben. Answering your question, the code works fine, but in low speed. I’m also posting another code I’ve used. This also worked but at low speed. I did so as follows: the line “myStepper.setSpeed ​​(120),” I increased to 240, I thought I would have 240 rpms and so on. But not. speed remained the same. Descupe not get it right but if you tell me in the item 1) that if I use a source with a higher power can I get a better result?
Will make the tests according to their explanation in items 2) and 3) and 4) and will post again.
I would like know also what is the best configuration pins MS1, MS2 and MS3 for a good performance of motor. The following code for your review.

[code]#define motorSteps 400 // change this depending on the number of steps
// per revolution of your motor
#define motorPin1 22
#define motorPin2 23
#define ledPin 13

// initialize of the Stepper library:
Stepper myStepper(motorSteps, motorPin1,motorPin2);

void setup() {
// set the motor speed at 60 RPMS:
myStepper.setSpeed(120);

// Initialize the Serial port:
Serial.begin(9600);

// set up the LED pin:
pinMode(ledPin, OUTPUT);
// blink the LED:
blink(3);
}

void loop() {
// Step forward 100 steps:
for (int i=0; i<4; i++) {

Serial.println(“Forward”);
myStepper.step(1600);
delay(250);
}
// Step backward 100 steps:
for (int i=0; i<2; i++){
Serial.println(“Backward”);
myStepper.step(-1600);
delay(250);
}
}

// Blink the reset LED:
void blink(int howManyTimes) {
int i;
for (i=0; i< howManyTimes; i++) {
digitalWrite(ledPin, HIGH);
delay(400);
digitalWrite(ledPin, LOW);
delay(400);
}
}
[/code]


#6

The stepper motor library you are using in your most recent program is not designed to work with the A4988 driver you are using and will not give you the behavior you want. You should do something similar to the first program you posted.

Also I cannot help you if you do not answer my questions.

[ul]
[li]For the third time, what do you have your A4988 current limit set to? [/li]
[li]How do you have your stepper motor connected to the driver?[/li]
[li]Can you post a version of your (first) program that you expect to work at higher speed but doesn’t?[/li][/ul]

- Ben


#7

Hello Ben. I’m sorry for my lack of attention, for not having answered your question and I coudn’t answer before.
I didn’t understand your first question. (what do you have your set to limit current A4988?) you can be more specicif please?
-For the second question, see the relation below:
GND =========> GND (arduino)
5V ===========> VDD
VDD =========> 5V
3.3V =========> N / C
GND =========> GND (arduino)
REF =========> N / C (not connected)
ENABLE =====> N / C
MS1 =========> N / C
MS2 =========> N / C
MS3 =========> N / C
RESET ======> N / C
SLEEP ======> N / C
STEP =======> PWM (arduino)
DIR =========> PWM (arduino)

VMOT ========> POWER-12V 3A
GND =========> POWER GND-12V 3A
1A ===========> RED WIRE
1B ===========> WIRE YELLOW
2A ===========> WIRE BLUE
2B ===========> WIRE ORANGE
VDD =========> N / C
GND =========> GND (arduino)

-For the third question. Here is the main and first code that I’m using to test my engine.

[code]void setup()
{
pinMode(9, OUTPUT); // Motor Dir
pinMode(10, OUTPUT); // Motor Step
}
void loop()
{
Pololu_A4988_Example();
}

void Pololu_A4988_Example()
{
delay(500); // delay for Controller startup
digitalWrite(9, HIGH); // Turn left
for(double i = 0; i < 5000; i++) //5000 steps in one direction
{
digitalWrite(10, HIGH);
delay(1);
digitalWrite(10, LOW);
delay(1);
}
delay(500); // delay for Controller startup
digitalWrite(9, LOW); // Turn left
for(double i = 0; i < 5000; i++) //5000 steps in one direction
{
digitalWrite(10, HIGH);
delay(1);
digitalWrite(10, LOW);
delay(1);
}
delay(1000);
}
[/code]
Escuse for my english not very good. Thanks for your patience.


#8

Your connections look fine, except you only need one common ground connection between your Arduino and the driver (you have three listed).

The stepper motor driver has a configurable current limit. It is not set to anything particular by default. Have you set it? Please see the “Current Limiting” section of the product page for instructions on how to set the current limit.

You said in your first post that you can get the stepper motor to turn slowly but not quickly. I want to see the code you used to try to make it turn quickly (the code that didn’t work). Can you confirm that the code you just posted does work? How quickly does your stepper motor turn when you run it?

- Ben


#9

Hello Ben. Sorry for being late. According to the information of the site and made ​​measurements and current limit of 1.275 A.
You ask if this code above works? yes it’s works. His speed is around 120 rpm.
The other code I tried was this one already posted earlier in post 3, which you said that the library used is not compatible with a4988. I’m disposition, thak you.


#10

First, Ben asked a great question that you did not answer:

[quote]the datasheet for your motor has a lot of generally useful information on stepper motors on pages 29 and 30. Have you read that?
[/quote]

Second, to run faster, try changing the “delay(1)” calls to “delayMicroseconds(500)” and see if it runs faster.

Also, as Ben already said, you might want to ramp the speed up a bit over the movement. Try something like this, perhaps:

void Pololu_A4988_Example() { delay(500); // delay for Controller startup digitalWrite(9, HIGH); // Turn left int delayUs = 1000; for(int i = 0; i < 5000; i++) //5000 steps in one direction { digitalWrite(10, HIGH); delayMicroseconds(delayUs); digitalWrite(10, LOW); delayMicroseconds(delayUs); if (delayUs > 300) { delayUs -= 5; } } delay(500); // delay for Controller startup digitalWrite(9, LOW); // Turn left delayUs = 1000; for(int i = 0; i < 5000; i++) //5000 steps in one direction { digitalWrite(10, HIGH); delayMicroseconds(delayUs); digitalWrite(10, LOW); delayMicroseconds(delayUs); if (delayUs > 300) { delayUs -= 5; } } }


#11

Hello jwatte. Thank you for ask my question. Sorry for be late. About page 29 and 30 of datasheet this true I forgot answer for Ben, but I already read it and I tried use all information. I’ll test your code and post result. I can’t show result yet, because I’m not at home, I am working in another city for three. Thank you!!


#12

Hello jwatte. Really the change that you made in the code, increased speed of motor, I think of to increase more. Although I will do some tests to see if the to increase. I also am going to change my source, maybe is not providing enough power to the motor. Thanks to everyone who answered my questions and I left descupas by responding. Once you have the test results back that’ll make the post here.


#13

I’m editing my original comment, because it was not correct. (This message is taking place of the original comment).