I've been trying to control a NEMA 17 stepper motor (from Stepperonline) with a L298N driver (Sparkfun) with an Arduino Mega following instructions from the Sparkfun manual and other forums, but it doesn't seem to work. Schematic with connections attached below.
Once I upload the code to the board, the motor starts vibrating and making short, incomplete rotations. I already verified to be using continuous coils on each side, inverted connections of digital PWM, tested for voltage/amperage, 4 different L298N drivers, and still the same problem. Code attached below if it's worth anything.
// Include the Arduino Stepper Library
#include <Stepper.h>
// Number of steps per output rotation
const int stepsPerRevolution = 200;
// Create Instance of Stepper library
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
void setup()
{
// set the speed at 60 rpm:
myStepper.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
}
void loop()
{
// step one revolution in one direction:
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
delay(1000);
// step one revolution in the other direction:
Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution);
delay(1000);
}
That looks like a serious mismatch combining that driver with that stepper.
Please post a link to the datasheet of the stepper. NEMA 17 is a mechanical specification telling absolutely nothing about the electrical needs.
The devil is reading the bible, his way, people say. You missed the data about amps. How would You control the amps with a driver having no current control?
You're not the first guy committing that mistake. Luck if nothing was destroyd.
A recent paranthesis from real life....
Normally yes, but..... Using eBay, or similar, TB6600 and 24 volt supply I got 30% extra steps! Using 12 volt worked perfectly.
If You want to use 2 Amp You need something extra. Some small matchbox sized drivers might manage but they need both heat sink and fan cooling, occupying space.
You have bought a motor that is meant to be used for high speed.
If you only have the room for a matchbox-sized driver, then you should have bought a different motor, with specs about 1Amp and about 3volt.
If you must use a small driver, then use the DRV8825, set to 1.5Amp. Expect lower performance.
Leo..