Stepper motor with Arduino and DRV8825

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 current 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 http://forum.pololu.com/viewtopic.php?f=15&t=3428 ] 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).

#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); 
}
}

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.

With the pololu driver try the Accelstepepr library, you will need only to set pins of the motor, speed, acceleration and targhet position, no more. If you need Y can give you an example of code to show how it works.

Riccardo

Thank you.
I'll try examples coming with the library and if I have problems I'll post.

This simple stepper code should be good for testing.

You may also find something useful in stepper motor basics

...R

Radicator:
If you need Y can give you an example of code to show how it works.

Riccardo

Actually I need a small example but please mention complete wiring around DRV also.
AccelStepper library examples mention about four pins connection and I don't know aw to do this.

In between I tried arduino - Slow down stepper motor's speed using stepper driver DRV 8825 - Electrical Engineering Stack Exchange with the same result as before: a small noise from stepper.

ramadoss:
Actually I need a small example but please mention complete wiring around DRV also.

I can't make a smaller example than the one I mentioned in Reply #3

The Pololu DRV8825 web page has a very clear wiring diagram and lots of other useful data.

...R

Sorry Robin, at the moment when I wrote my previous post I didn't observe you suggested a "simple stepper code". I'll try tomorrow also this and I'll post the results.
However I think my problem is coming from wiring or from current settings.Here I have to find my mistake.

ramadoss:
However I think my problem is coming from wiring or from current settings.Here I have to find my mistake.

That is why I suggested the Pololu DRV8825 web page.

...R

I managed to make stepper to move following producer web page and

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.

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");
   }

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

ramadoss:
I managed to make stepper to move following producer web page and

Did you try my code. It has worked for me everytime I tried.

And because I am familiar with it I can help more easily if you use that.

What power supply are you using for the motor (volts and amps) ?

...R

Robin2:
Did you try my code.
What power supply are you using for the motor (volts and amps) ?

Yes Robin, I tried with the same inconsistent and chaotic movement result.
I'm using a 12V 2A AC/DC adapter. I didn't checked its performance (because I don't know how) but I'll try to find a better/bigger one this days.

Regards,

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

ramadoss:
Now your code is working fine.
Thank you for your help.

Good to know. Thank you for the feedback.

...R