I just realized something, while my steppers ARE moving, they're only turning in one direction. Isn't the code supposed to let the stepper turn one direction when directionpin is output high and then turn the other way when directionpin is output low?
dogla:
Isn't the code supposed to let the stepper turn one direction when directionpin is output high and then turn the other way when directionpin is output low?
It would be more accurate to say that the stepper driver should make the motor go in the direction set by the direction pin.
We need to see your program and your wiring diagram.
...R
Same code more or less as used before:
// testing a stepper motor with a Pololu A4988 driver board or equivalent
// on an Uno the onboard led will flash with each step
// this version uses delay() to manage timing
byte enablePin = 8;
byte directionPin = 5;
byte stepPin = 2;
int numberOfSteps = 6400;
byte ledPin = 13;
int pulseWidthMicros = 20; // microseconds
int millisbetweenSteps = 1; // milliseconds - or try 1000 for slower steps
void setup() {
Serial.begin(9600);
Serial.println("Starting StepperTest");
digitalWrite(ledPin, LOW);
delay(2000);
pinMode(directionPin, OUTPUT);
pinMode(stepPin, OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(enablePin, OUTPUT);
digitalWrite(enablePin, HIGH); //isn't really needed for my driver
digitalWrite(directionPin, HIGH);
for(int n = 0; n < numberOfSteps; n++) {
digitalWrite(stepPin, HIGH);
delayMicroseconds(pulseWidthMicros); // this line is probably unnecessary
digitalWrite(stepPin, LOW);
delay(millisbetweenSteps);
digitalWrite(ledPin, !digitalRead(ledPin));
}
delay(3000);
digitalWrite(directionPin, LOW);
for(int n = 0; n < numberOfSteps; n++) {
digitalWrite(stepPin, HIGH);
// delayMicroseconds(pulseWidthMicros); // probably not needed
digitalWrite(stepPin, LOW);
delay(millisbetweenSteps);
digitalWrite(ledPin, !digitalRead(ledPin));
}
}
void loop() {
}
I would expect that code and that wiring diagram to cause the motor to work in both directions.
Put some Serial.print() statements so you can see which part of the code is actually working.
...R
The response I get is 4 full rotations (I have my driver set at 1600), 3 sec pause and then again 4 full rotations.
I will put a Serial.print() before and after each block whenever I get back home.
dogla:
and then again 4 full rotations.
If the direction is not changing then check all your connections very carefully and measure the voltage at the direction pin of the driver to make sure it is changing. If the connections are all good and the voltage is changing then I would suspect a faulty driver.
...R
My apologies....all this time I had crappy quality Ebay pin header connectors between the arduino and stepper driver....
There was a batch which was really corroded inside and would loose connection. Measured all of my connectors and had to throw away half of the bunch I had. All is working now as it should.
Only problem I have now is I will most likely have to reinstall windows with a 32bit version since Mach3 doesn't see my parallel port (had to buy a parallel port card on Amazon) and I read on another forum that mach3 won't see it if the OS is 64bit.
Mach3 is far beyond my pay grade
...R