Stepper motor with DRV8825 and Arduino

From the beginning I have to a apologize regarding my English and for stupid questions since I’m a novice.

I’m trying to make a Nema 17 stepper to move using Arduino and DRV8825.
Stepper is 1.5A rated curent and 3.75V rated voltage http://www.geeetech.com/nema17-stepper-motor-with-skidproof-shafts4lead18-degree-p-696.html.
I’ve tried different codes from Internet with no results.One of this is a A4988 guide from https://forum.pololu.com/t/a4983-and-a4988-getting-started-guide/2789/1 that I believe is good for DRV8825 also. I made some small adjustments in code and wiring reported to pdf files attached on topic (pin 2 and 3 interchange,power capacitor of 100 uF).

[code]#define stepPin 3
#define dirPin 2
#define enablePin 4
void setup()
{
// We set the enable pin to be an output
pinMode(enablePin, OUTPUT);
// then we set it HIGH so that the board is disabled until we
// get into a known state.
digitalWrite(enablePin, HIGH);

Serial.begin(9600);
Serial.println(“Starting stepper exerciser.”);
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
}
void loop()
{
int j;
// set the enablePin low so that we can now use our stepper driver.
digitalWrite(enablePin, LOW);
// wait a few microseconds for the enable to take effect
// (That isn’t in the spec sheet I just added it for sanity.)
delayMicroseconds(2);
// we set the direction pin in an arbitrary direction.
digitalWrite(dirPin, HIGH);
for(j=0; j<=10000; j++) {
digitalWrite(stepPin, LOW);
delayMicroseconds(2);
digitalWrite(stepPin, HIGH);
delayMicroseconds(1000);
}
}[/code]

Running the code, stepper shaft become stiff but not moving at all. A small intensity noise is coming from inside as similar as is rotating but only noise. DRV cooler is enough hot but still I can keep my finger on top for 3-4 seconds.
I’ve done current adjustment according instructions from above guide.I’m not sure if connection between two GND is necessary (Arduino and power GNDs; small green wire ). Powering done with 12V, 2A DC adapter.
Thank you if somebody can help me.


You probably have the current limit set too high. Carefully follow the instructions to set it to 1.5 amperes or preferably, less.

Pololu link from my first post contains three pdf files.Inside PololuPres_V3.pdf is explaining how to adjust the current to 0.7*rated current = 0.7 * 1.5 = 1.05A .I did like this and my test was with this setting. I don’t know an other method to adjust the current.

Hello.

Thanks for the information and for posting a clear picture of your connections. It looks like you currently have the driver in half-step mode. When you set the current limit using the method specified in that guide, did you have the stepper motor driver in full-step mode?

Instead of setting the current limit by measuring the current in the coils, we generally recommend setting it using the VREF voltage. Detailed instructions for setting the current limit using the VREF voltage method are given in this video.

By the way, in your code it looks like you are trying to step the motor a little fast. You might try slowing down the step rate to step every couple of milliseconds, and setting your delay using the normal delay() command, which is in milliseconds.

- Grant

[quote=“grant”]Hello.

this video.
[/quote]

Thank you Grant.
I managed to make stepper to move following that video by proper adjustment the of current and by reducing wiring to minimum.
Stepper is moving but is a very chaotic movement.Steps forward,backward or no step in the same loop.
For example using code below, stepper is doing sometimes one revolution CW sometimes not.Even if it is a full revolution the steps are alternating forward/backward.And not all the times is a full revolution. Sometime is more sometime less.
In the second part of the code, when the rotation suppose to be in opposite direction, stepper is nothing doing.

Using micro-stepping movement seems to improve but is far from a smooth one.

[code]int directionPin = 8;
int stepPin = 9;
int j;
void setup() {

Serial.begin(9600);
Serial.println(“Starting StepperTest”);

pinMode(directionPin, OUTPUT);
pinMode(stepPin, OUTPUT);
//digitalWrite(directionPin, LOW);
}

void loop()
{
Serial.println(“START”);
for(j=0; j<=199; j++) {
digitalWrite(directionPin, HIGH);
digitalWrite(stepPin, HIGH);
delay(20);
digitalWrite(stepPin, LOW);
delay(25);
}
Serial.println(“CHANGE DIRECTION”);
delay(5000);

for(j=0; j<=199; j++) {
digitalWrite(directionPin, LOW);

Serial.println(“STEP”);
digitalWrite(stepPin, HIGH);
delay(20);
digitalWrite(stepPin, LOW);
delay(25);
}
Serial.println(“END”);
}[/code]

So, please give some advice to improve the code for a smooth rotation of the stepper.

To what value did you set the winding current? It may be that the power supply cannot provide the necessary current for both windings.

Initially I’ve set current to 1.5 A (Vref = 0.75V) but after seeing how is moving I was playing with current limiting potentiometer on full range.
I’ll try to find a better/bigger power source than my 12V 2A adapter.
Regards,

LE.
I solved the problem. Doing so many attempts I forgot to connect the two GND each other(power and Arduino). Now stepper is working fine.
Thank you for your help Jim and Grant.

I am glad you got it working. Thanks for letting us know what the problem was.

- Grant