Nema17 too much vibration with DRV8825

Hi,
I have setup as in below . It works, but lot of vibration. How can I make it smooth like a DC motor

Sketch is simple - Stepper Motor with DRV8825 and Arduino Tutorial (4 Examples)

I changed pins from 2 (dir), 3 (step) to 3 (dir)and 4(step) because of my previous setup. But does it make any difference?

Please advice on how can I reduce the noise I will be doing only quarter rotation

Project Idea- https://www.instructables.com/COVID-19-Rapid-Manufacture-Ventilator-BVM-Ambubag-/

/*Example sketch to control a stepper motor with A4988/DRV8825 stepper motor driver and Arduino without a library. More info: https://www.makerguides.com */

// Define stepper motor connections and steps per revolution:
#define dirPin 3 //2
#define stepPin 4 //3
#define stepsPerRevolution 40

void setup() {
  // Declare pins as output:
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
}

void loop() {
  // Set the spinning direction clockwise:
  digitalWrite(dirPin, HIGH);

  // Spin the stepper motor 1 revolution slowly:
  for (int i = 0; i < stepsPerRevolution; i++) {
    // These four lines result in 1 step:
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(2000);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(2000);
  }

  delay(1000);

  // Set the spinning direction counterclockwise:
  digitalWrite(dirPin, LOW);

  // Spin the stepper motor 1 revolution quickly:
  for (int i = 0; i < stepsPerRevolution; i++) {
    // These four lines result in 1 step:
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(1000);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(1000);
  }

  delay(1000);

  // Set the spinning direction clockwise:
  digitalWrite(dirPin, HIGH);

  // Spin the stepper motor 5 revolutions fast:
  for (int i = 0; i < 5 * stepsPerRevolution; i++) {
    // These four lines result in 1 step:
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(500);
  }

  delay(1000);

  // Set the spinning direction counterclockwise:
  digitalWrite(dirPin, LOW);

  //Spin the stepper motor 5 revolutions fast:
  for (int i = 0; i < 5 * stepsPerRevolution; i++) {
    // These four lines result in 1 step:
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(500);
  }

  delay(1000);
}

Take that breadboard away. It's not built for motor current.

I have a curtain project that uses PCB with header pins...even that shakes a lot. (vibration noise too)

Should I get rid of bread board?

If you take a step every other second you get vibration at that rate. Take a step every 10ms for less vibration.

DrDiettrich:
If you take a step every other second you get vibration at that rate. Take a step every 10ms for less vibration.

Code uses Microseconds, not milliseconds...

please advice any changes to sketch

I tried to understand the lady explaining amps...but failed to follow

any suggestion like which type of step to use - full step, 1/4step etc etc

Introduce micro stepping. That may help. Some steppers are noisy. Not much you can do about it.

Use delayMicroseconds(5000) or more.

Railroader:
Code uses Microseconds, not milliseconds...

You're right. Then it may happen that the motor cannot reach the speed immediately and only toggles between two states. AccelStepper library should help then.

Just what I thought, too much speed, especially for starting. My NEMA17 didn't accept less than 7 mS cycles.

krisferrari:
I have setup as in below . It works, but lot of vibration. How can I make it smooth like a DC motor

Even with microstepping stepper motors move in steps ("quelle surprise") so they will never be as smooth as a DC motor.

...R
Stepper Motor Basics
Simple Stepper Code

also look up the AccelStepper library