#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.
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.
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.
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.
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.