Stepper motion is pulsing

I have some simple code to get a constant RPM from a stepper. It does not run as smooth as I expected. It is hard to explain so I have a video. There is a pulse that is about 2/sec and therefore does not have a smooth continuous motion. I am using Arduino Uno with a DRV8825 stepper driver and a Nema 17 stepper from omc-stepperonline.com 17HS08-1004S. This is a 200 step/rev motor.
Arduino is powered by USB from the computer.
Stepper is powered by a separate 12v power supply with a 100 uf capacitor on the line.
here is the video where you can hear the pulsing and see the motion.
https://youtu.be/qwGIr5N_nHE

Any one know what can be causing that? it happens with different micro stepping too.
Here is a wiring diagram.

I tried simpler code and I get similar results.
and here is the code. I use pins 5, 6, and 7 to set the micro stepping on the driver. Pin 3 is the step pin.
I have a place to enter how many minutes per revolution I want, then I convert this to msec per step. In the loop section my delay is calculated to get the RPM or has I enter minutes per rev MPR. I am getting the appropriate RPM, but the pulsing is strange.
Any thoughts on how to trouble shoot.?
Thanks

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

// Microstepping control pins
#define M0_PIN 7
#define M1_PIN 6
#define M2_PIN 5

// Steps per revolution for the motor
int stepsPerRevolution = 200;
// Microstepping multiplier (1, 2, 4, 8, 16, or 32)
int microstepSetting = 16;
// Micro steps per revolution
const float MicroStepPerRev = stepsPerRevolution * microstepSetting;
// How many minutes per revolution do you want?
int MinPerRev = 2;  //2 min 

// convert to seconds per revolution
const float SecPerRev = MinPerRev * 60;
// convert to seconds per step
const float SecPerStep = SecPerRev / MicroStepPerRev;
// convert to mSec per step
const float mSecPerRev = SecPerStep * 1000;

void setup() {
// Declare pins as output:
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
 
// Set microstepping mode (adjust as needed: HIGH or LOW)
                              // 		  Full	Half	1/4		1/8		1/16	1/32
  digitalWrite(M0_PIN, LOW);  // 	M0	LOW		HIGH	LOW		HIGH	LOW		HIGH
  digitalWrite(M1_PIN, LOW);  // 	M1	LOW		LOW		HIGH	HIGH	LOW		HIGH
  digitalWrite(M2_PIN, HIGH); // 	M2	LOW		LOW		LOW		LOW		HIGH	HIGH

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

void loop() {
// Set the number of mircro steps per revolution
  float MicroStepPerRev = stepsPerRevolution * microstepSetting;

    // These four lines result in 1 step:
    digitalWrite(stepPin, HIGH);
    delay(mSecPerRev/2);
    digitalWrite(stepPin, LOW);
    delay(mSecPerRev/2);
}

You seem to be powering the driver and the stepper with the Arduino. Stop. Remove the power jumpers from the Arduino.

The driver must have external power source. The Arduino should only supply control signals to the stepper.

Here is a reference to the DRV8825...

I accidentally left out of the diagram what I put in words. The Arduino is powered by USB cable to the computer. A separate 12V power supply is used for the driver and therefore the stepper. I followed the same reference you linked.

No better time than now.

Stepper motors do not run smoothly, in your case it takes about 26.7 steps per second so it's pulsating at about 26.7 Hz.
The initial (about 1.5) second pause at startup is normal while the Arduino is booting and setting up.

Thanks for the replies.
Looks like that youtube video does not have the audio quality needed to highlight my situation. On my phone it sounded loud enough, but online no so much.

Here is another video with boosted audio. Also with a longer arm (aka pencil) you can see the oscillatory ... acceleration? Not sure how to describe it. When the phone is moved close you can hear this pulsing even better.

I changed the code using the AccelStepper library and I get the same result.
I changed the micro stepping and I get the same type result (regular pulse).
By they way I used other example codes for position control and that seems to work fine. However the RPM for those examples are pretty fast.

This makes me think there is a different problem. My motor did not come with a connector. Tell me if I wired motor pins in the correct order.
From the motor spec sheet.


Then the DRV8825 has this order of pins and here is how connected wires:
VMOT
GND
2B Blue
1B Red
1A Black
2A Green
FAULT
GND

I read somewhere that the A+ goes to 1A on the driver and the B+ does to 1B on the driver. Is this correct?

#include <AccelStepper.h>
 
// Define stepper pins
#define STEP_PIN 3      // Step pin
#define DIR_PIN 2       // Direction pin
 
// Microstepping control pins
#define M0_PIN 7
#define M1_PIN 6
#define M2_PIN 5
 
// Steps per revolution for the motor
const float stepsPerRevolution = 200;
// Microstepping multiplier (1, 2, 4, 8, 16, or 32)
int microstepSetting = 16;
 
// AccelStepper instance in driver mode
AccelStepper stepper(AccelStepper::DRIVER, STEP_PIN, DIR_PIN);
 
void setup() {
  // Set microstepping pins as outputs
  pinMode(M0_PIN, OUTPUT);
  pinMode(M1_PIN, OUTPUT);
  pinMode(M2_PIN, OUTPUT);
 
// Set microstepping mode (adjust as needed: HIGH or LOW)
                              // 		  Full	Half	1/4		1/8		1/16	1/32
  digitalWrite(M0_PIN, LOW);  // 	M0	LOW		HIGH	LOW		HIGH	LOW		HIGH
  digitalWrite(M1_PIN, LOW);  // 	M1	LOW		LOW		HIGH	HIGH	LOW		HIGH
  digitalWrite(M2_PIN, HIGH); // 	M2	LOW		LOW		LOW		LOW		HIGH	HIGH

  // Set the desired RPM and the max RPM
  float desiredRPM = 0.25; // Set the desired speed in rpm (revolutions per minute)
  float MaxRPM = 300; // Set max speed in rpm (revolutions per minute)
 
  // Calculate and set the desired and max speed in steps per second
  float speedStepsPerSec = (microstepSetting * stepsPerRevolution*desiredRPM) / 60.0;
  float Max_Speed_StepsPerSec = microstepSetting * stepsPerRevolution * MaxRPM / 60; // Specify max speed in steps/sec (converted from RPM)
  stepper.setMaxSpeed(Max_Speed_StepsPerSec);
  stepper.setSpeed(speedStepsPerSec);
}
 
void loop() {
  // Run the motor at constant speed
  
  stepper.runSpeed();
}

That doesn't sound right. I've seen that sort of thing with a high current and the driver hovers around thermal shutdown. The driver seems to keep resetting itself.

If you put your finger on the driver chip, does it burn your finger? If so, try reducing the current limit, and/or adding a heatsink to the driver chip.

Well this is quite curious. I am able to reproduce the "pulsing" on a test setup, using an A4988 driver. It seems to "skip" about every 20-30 steps. However, looking at the steps on a scope output, they seem to be totally solid, with no discernible jitter.

I notice you are running quite a low RPM, at least compared to most applications I have seen. I wonder if there is a feature of these type of drivers that they don't perform evenly at low RPM.

Interesting. So perhaps the code? Can you get your test setup to run smooth with different code?
I did check for heat. There is a heat sink and no detectable heat build up. It stays room temp. I adjusted the driver current limiting. motor spec is 1A so adjusted to 0.5V ( Current Limit = Vref × 2) Or in this case current limit of 1A / 2.

I am running a low RPM to ultimately power a large clock. I am just prototyping now so I did not bother with a pulley and drive belt that I will need to get the torque. The up side would be higher speed at the stepper. The problem is with long arms small jumps/pulses are very noticeable.

I played with different speeds (but still low RPM on the order of 1 rpm) and different micro steps and I still get these results.

Have you thought about one of the TMC "silent stepper" drives?
https://www.analog.com/en/products/TMC2209.html

Pololu's 8825's labels are different from yours.

The A4988 boards labeled them in number-letter order, with the numbers representing coils:


Getting the +/- backward only swaps the direction of rotation, so it isn't too important.

However, if you cross the coils, the stepper will act weird and turn only one direction. Does your stepper turn both ways?

Simulation:

stepper-motor--scope_crossed.ino - Wokwi ESP32, STM32, Arduino Simulator

Hi Dave. Yes the stepper runs in both directions. Not sure where you are seeing different labels other than the picture you included shows B2 instead of 2B. Letter/number vs. number/letter. They are still in the same order.

This is the one I ordered.
https://www.amazon.com/dp/B0B3884KGS?ref=ppx_yo2ov_dt_b_fed_asin_title

Hi, @stdubeck
Welcome to the forum.

Have you got the Arduino gnd and the stepper power supply gnd connected together?

Tom.... :smiley: :+1: :coffee: :australia:

Tried this with AccelStepper and a small (NEMA 8) motor with 1/32 stepping. Still see the "jerks"... ?


#include <AccelStepper.h>
#define dir 8
#define step 9

AccelStepper stepper(1,step,dir);

void setup()
{  
   stepper.setMaxSpeed(1000);
   stepper.setSpeed(53.33);
   //stepper.setCurrentPosition(0);    
}

void loop()
{  
  stepper.runSpeed();
  
}

I can feel pulsations at 100 per minute (1 2/3 Hz)......???

I did some more exploration. It seems instability of microstepping drivers at low speeds is a known problem. When I tried with full steps, the problem went away, but of course a full step gives a very jerky motion.

My take is that since steppers motors are inherently designed for full (or half) steps, to get microstepping is kind of a bodge, which works better at higher speeds but can introduce instability at low speeds.

There is also the issue of resonance in the motor, which can make certain speeds vibrate a lot more.

The way to avoid these effects seems to be use a geared stepper, and run the motor at higher speeds. There are also steppers with a 0.9 deg step. Also, consider using a DC motor, although the control is a bit more complex.

Thank you all for your inputs and experimentation. Based on the results of Bobcousins, JCA34F, and me, it appears this is a limitation of this type of stepper and driver at these speeds. This was confirmed with A4988 and DRV8825 drivers. JCA34F can you tell us what driver you used in your experiment?

If it goes both directions, I think you don't have the coils crossed and it is fine.

I was concerend bc you were asking about the connections with text names, and the devices are labeled different ways on different chips. That amazon link labels the 8825 coil pins three ways in its pictures:



The datasheet uses more of a winding-node naming:

DRV8825, I'm thinking that the unavoidable detent torque may have an effect at high microstep settings. The pulsations I feel at 1/32nd microstepping are exactly 200 per revolution.