I have paired up L297 and L298 together to make a bipolar stepper driver.
My schematics are :
I have hooked up the step and direction pin number 4 and 5 respectively on Arduino.
I am using a 5V power supply from a DC adaptor
The code I'm using is:
#define stepPin 4
#define dirPin 5
void setup() {
Serial.begin(9600);
Serial.println("Starting stepper exerciser.");
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
digitalWrite(dirPin, HIGH);
digitalWrite(stepPin, LOW);
}
void loop() {
int i, j;
for (i=1000; i>=200; i-=100) {
Serial.print("Speed: ");
Serial.println(i);
for (j=0; j<2000; j++) {
digitalWrite(stepPin, HIGH);
delayMicroseconds(i);
digitalWrite(stepPin, LOW);
delayMicroseconds(i);
}
delay(500);
digitalWrite(dirPin, !digitalRead(dirPin));
for (j=0; j<2000; j++) {
digitalWrite(stepPin, HIGH);
delayMicroseconds(i);
digitalWrite(stepPin, LOW);
delayMicroseconds(i);
}
delay(1000);
Serial.println("Switching directions.");
digitalWrite(dirPin, !digitalRead(dirPin));
}
}
I am using NEMA17 bipolar 5V motors , the data sheet can be found here :
datasheet
Motor specs are here
I have also tried L297 with L293d , but the things aren't working the way they should.
Most probably the issues are with the oscillator or the clock pin (may be the pulse is not generating ), before posting the question , I had a quick google search which showed me I was not the only onne facing this issue.
Best Answer
Try this code, and change pin number to your like. if this code work, likely the problem is in the delayMicroseconds number, some Stepper motor only work on higher than 300 and some on more higher number. when delayMicroseconds number too low, it will stall and sometime only humming.
when powerup, motor will spin clockwise, and if you push button, it's will delay 1 second, and start spin counterclockwise.