DRV8825 & NEMA17 motor help

hey gang-

So I am working with my first stepper motor project..

Stepper:

Driver: (DRV8825)

Library: (Accelstepper)
http://www.airspayce.com/mikem/arduino/AccelStepper/

example code from library:

#include <AccelStepper.h>
// Define a stepper and the pins it will use
//AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
AccelStepper stepper(1, 3, 2); 
//AccelStepper stepper(AccelStepper::DRIVER, 9, 8);

void setup()
{  
    stepper.setMaxSpeed(200.0);
    stepper.setAcceleration(100.0);
}
void loop()
{    
    stepper.runToNewPosition(0);
    stepper.runToNewPosition(500);
    stepper.runToNewPosition(100);
    stepper.runToNewPosition(120);
}

I have things wired like so: (right click, view image to see if full size I guess)

Arduino is powered via USB.... stepper is powered by PSU @ 12v

When I test the sketch,.. the motor doesnt do anything..

I sorta hear a 'whine' when its powered up...
and maybe a random click or clunk from the stepper as well..

I'm not sure what I have wrong here? (perhaps the coils are wired wrong?)

Did you do this?.....

AccelStepper stepper(1, 3, 2);

Isn't the syntax stepper(driver, step, dir)? Your diagram has pin 2 as the step pin.

Your ohmeter can confirm how the coils are wired.

These links may help

Stepper Motor Basics
Simple Stepper Code

...R

groundFungus:

AccelStepper stepper(1, 3, 2);

Isn't the syntax stepper(driver, step, dir)? Your diagram has pin 2 as the step pin.

Your ohmeter can confirm how the coils are wired.

Good pickup GF.

To the OP ...... if this really is the case, then it should not have been wired like that. You must keep checking wiring (visual inspections and physically tracing wires from 1 point to another) again and again ---- as many times as is needed (making sure that you have followed tutorial pin connections perfectly). Otherwise, if your physical connections are accurate, but you've drawn the wrong diagram, then ------- same thing.... make sure your diagram is correct when you draw it, and check over it.

The current update (that aligns with your code) is :

Otherwise, without the wiring update, your code could be switched to :

AccelStepper stepper(1, 2, 3);

Thanks guys!

I have corrected the STEP/DIR order issues..

And ensured that all GROUNDS are in fact tied together.

When I try things now..

I can hear the motor attempting to spin? or making noise like it is spinning? (wheening).. but the shaft is not actually (physically) moving/spinning.

According to this diagram, I believe I have the pins/wiring correct for the connections on the DRV8825 board to the coils on the stepper.

STEPPER:
RED: B / BLUE: B-

DRV8825:
B2 / B1


STEPPER:
GREEN: A / YELLOW: A-

DRV8825:
A2 / A1

I noticed I had the colors wrong on the wiring diagram posted (this has been updated now)..

I posted the connections above for clarification as well.

I can 'hear' what I would imagine is the actual movement happening... (the type of movement back and forth the code is dictating)... but its 'inside' the stepper.

There is also a 'whine'..or high pitched static constantly being emitted.

Thanks!

Have you tried (much) slower speed and acceleration settings? Did you confirm the coil wiring with an Ohmeter? Have you set the coil current as described in the Pololu page on the DRV8825?

Maybe give Robin2's simple stepper code a try.

@groundFungus

Thanks for the reply.

I tried (s)lower settings for the sketch posted.. and using Robin2's simple stepper code (which smaller values as well)..

I can HEAR the SOUND of it trying to move for the correct (estimated) times and stop.. then moving again.. but no physical movement of the shaft.

If I look at it.. it seems to move an EXTREMELY small amount.. fractions of an inch.. then back again (fractions of an inch)..

I confirms what coils were PAIRS using my meter... (continuity setting)..

This:
"Have you set the coil current as described in the Pololu page on the DRV8825?"

Was an interesting step.. and where I stopped now.. since I wasnt getting readings that I expected.

Their tutorials was a bit odd... (using the VREF..etc.. I never got the same results they showed!)..
..but I found another video that I'm going to try tonight.

I am powering it @ 12v from a bench top PSU..

I feel like I am overlooking something small here.. but just keep glazing over it?

I suggest you stick with my simple code until you get it working. And use a large value for millisBetweenSteps. The value of 250 will give 4 steps per second which ought to work.

...R

I'll stick with your example.. (which is what I was using last).. and I did change the value of millisBetweenSteps value...

When I got home.. I'll post the values that were specifically used.

I find it odd.. that teh stepper makes noise like it is turning (winding up and down).. but the shaft itself is not moving.

Try changing the polarity of one stepper coil connection to the drv. Imagine each coil as an electromagnet, if both are producing a North Field at the same time the stepper will not move. If one is producing a South while the other is posting in North then the stepper should move.

Sometimes stepper Motors are not wired the way we expect them to be. That is why you had to use your own meter to check it as others mentioned.

Mark

Using the 'simple stepper' code as given:

// 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 stepPin = 3;
byte directionPin = 2;

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() {
}

Same results.

I tried to swap the B1/B2 pins around.. as well the A1/A2 pins to see if it was fighting each other.

Same results.

Red/Blue are pairs
Green/Yellow are pairs

  • According to the multi-meter continuity tests..

The colors/order of the wires coming out of the stepper.. are not the same order they are in the connector at the end of the cord for the stepper..

Have you a spare stepper driver - maybe the one you are trying is faulty?

Be VERY CAREFUL never to disconnect the wires between the motor and the stepper driver while the driver is powered up. The driver will be instantly destroyed,

...R

hmm... good idea.

I think I -do- have a another DRV8825 driver board..

I think I also have an "Easy Driver" board too... (although I chose the SRV8825 because of more current)

I'll swap it out... and see what happens.

Update:

I threw in the other DRV8825 board... and I'm getting 'some' sort of results here..

I power it up.. and the stepper it making very tiny 'movements'..

Maybe I'm just understanding how the movement is supposed to work.

How do you get a clean, smooth movement? And not this 'jerky' tiny 'movement' (step?)

I tired to change the millisBetweenSteps to something smaller.. and it didnt work.. first it did nothing..

then I hear a click on my PSU.. the it starts to move one direction... then just sits there?

Is the stepper itself supposed to be 'humming' when you hold it?

When I power up the PSU first.. the stepper is fine.. once I power is applied to the Arduino as well (via USB).. I start to hear this hum/wheeening sound from the stepper.

I'm also still confused about the coil wires?

I am understanding it as:

STEPPER:
RED: B / BLUE: B-

DRV8825:
B2 / B1


STEPPER:
GREEN: A / YELLOW: A-

DRV8825:
A2 / A1

So in this order on the right side of the DRV board: (going down the right side)

B2 - RED
B1 - BLUE
A1 - YELLOW
A2 - GREEN

I have to add wires to flip the YELLOW/GREEN wires.. as the pinout/connector they have has it GREEN/YELLOW order.. (A1/A2 flipped)

**I get different results/behavior depending on what I power up first?

If I plug in the USB first (for the Arduino).. and then the PSU (12v) for the DRV8825 driver.. then the voltage on the PSU screen reads roughly 6-7 volts.. and things are odd.

If I plug in the PSU first.. then the USB/Arduino.. the PSU reads the 12 volts.. and the stepper 'moves' in those really tiny/jerky movements.

Update 2:

I changed to this code:

#include <AccelStepper.h>
// Define a stepper and the pins it will use
//stepper(driver, 3(step), 2(dir))
//AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
AccelStepper stepper(1, 3, 2); //stepper(driver, step, dir)
//AccelStepper stepper(AccelStepper::DRIVER, 9, 8);

void setup(){ 
    stepper.setMaxSpeed(200.0);
    stepper.setAcceleration(100.0);
}
void loop(){   
    stepper.runToNewPosition(0);
    stepper.runToNewPosition(500);
    stepper.runToNewPosition(100);
    stepper.runToNewPosition(120);
}

and I get more fluid movement (like full turns)...etc..

However.. since this is my first stepper motor project.. let me ask..

is the motor suppose to be jittery/jerky? and make noise as it move/steps?

I am holding the stepper in my hand.. it shakes? (vibrates almost?) when its on.. and stepping?\

Is this normal? I guess I thought they would be fairly quiet?

I dont have any past experience/exposure to know if this is normal... or things are wrong somewhere?

Your posts are all double-spaced and that makes them very difficult to read. Please just use normal single spacing with an extra space between paragraphs.

Stepper motors move in steps so they vibrate and they make noise.

If you use microstepping the movement will be smoother. But don't waste time with that until you are confident that you have full control of the motor.

I presume your motor has 200 steps per revolution so it is easy to check if it is behaving properly. If necessary use a bit of sticky tape to make a flag on the motor shaft so you can be sure of the movement and the position.

If you are still unsure make a short YouTube video and post a link to it and also post the code used when making the video.

...R

Have you tried adjusting the current limit pot while the motor is trying to run? It almost sounds like the motor is not getting enough current and the current limit pot adjustment may be set too low.
M0, M1, and M2 should be at logic 0 level for full step, the datasheet says they have pull downs on them, might be worthwhile to check them with a meter to see if they really are at logic 0.
Anyway, try adjusting the current limit pot SLOWLY while the sketch is running and see if the motor improves.

As Robin2 suggested I wasnt planning on messing with the micro stepping pins quite yet.

but from he describes, this also seems like normal behavior for a stepper. (especially in full step mode)....

is adjusting the pot while running safe?

@xl97; is adjusting the pot while running safe?

Yes, as long as you do it slowly, don't run it end to end. The pot setting is used by the DRV8825 to limit the current to the motor. I had a BigEasyStepper where the pot was set according to the product sheet but the motor would stutter and miss steps. Slightly increasing the pot smoothed the motor right out. Going beyond that usually results in the motor heating up.
For a reasonably short period it won't hurt the motor if the pot is set too high while adjusting, just dial it back a bit.

The reason I mentioned the microstepping pins is that if, for whatever reason, they are not grounded then the unit is in microstep mode.

xl97:
is adjusting the pot while running safe?

Hard to say. If you don't know the value of Vref as you're twiddling the metal dial, then we can lose track of what the limit value is.

Probably better off using the multimeter to set a suitable/sensible known limit, and then just stick with it.

There are arduino threads about using DRV8825.... eg. UPDATE: Current adjustment for motor drivers (DRV8825 / A4988) - Motors, Mechanics, Power and CNC - Arduino Forum

I reckon the motor will not be too fussy about the exact current limit (as long as you don't exceed the max for the motor) when the motor is running without a load.

One thing to watch for is the value of the current-limiting resistor on the DRV8825. It may not be same value as on the Pololu DRV8825 boards - but IIRC the Pololu website explains the relationship between the resistor value, the current and Vref

...R