Bought a couple Nema 17 (17HS2408 and 42HD2037, 1.8deg step angel), DRV8825 driver boards, and extension board.
Tried two different codes. This library: GitHub - laurb9/StepperDriver: Arduino library for A4988, DRV8825, DRV8834, DRV8880 and generic two-pin (DIR/STEP) stepper motor drivers , and one with no libraries.
Same result with both motors and codes. They shake and buzz a bit, but don't turn, or turn just a degree or two forth and back.
Any idea what may cause this..?
#include <SPI.h>
#include <Wire.h>
#include <Arduino.h>
#include "DRV8825.h"
// using a 200-step motor (most common)
#define MOTOR_STEPS 200
// configure the pins connected
#define DIR 8
#define STEP 9
#define MS1 10
#define MS2 11
#define MS3 12
// 200 , 8 , 9 , 10 , 11 , 12
DRV8825 stepper(MOTOR_STEPS, DIR, STEP);
//DRV8825 stepper(MOTOR_STEPS, DIR, STEP, MS1, MS2, MS3);
void setup() {
// Set target motor RPM to 1RPM and microstepping to 1 (full step mode)
stepper.begin(60, 2); // (rpm, microsteps)
}
void loop() {
// Tell motor to rotate 360 degrees. That's it.
stepper.rotate(360);
delay(3000);
}
// 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 directionPin = 8;
byte stepPin = 9;
int numberOfSteps = 100;
byte ledPin = 13;
int pulseWidthMicros = 20; // microseconds
int millisbetweenSteps = 250; // 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);
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() {
}