Stepper vibrates using cnc shield

Hello, I am trying to test a stepper motor but it seems to not work properly. Sometimes it vibrates for a bit, sometimes it beeps, sometimes it does nothing at all.

I am using an Arduino UNO R3 board, CNC shield v3, driver DRV8825. I bought all this here https://a.aliexpress.com/_Ex2XpSP. The stepper motor I am using is a Nema 17 17HS15-1504S-X1 manufactured by STEPPERONLINE, this is the datasheet: https://www.omc-stepperonline.com/download/17HS15-1504S-X1.pdf

I have wired a 12V 10A power supply to the cnc shield, on top of the arduino board; the driver is in the correct orientation and position; the stepper motor is wired to the cnc shield.
I have double checked each connection and checked with a multimeter and everything seems fine.

This is the code I have uploaded to the Arduino:


#include <AccelStepper.h>

AccelStepper stepper1(1, 2, 5);


void setup() {
  // initialize the serial port:
  Serial.begin(9600);

  pinMode(8, OUTPUT);  // enable pin x axis

  stepper1.setMaxSpeed(200);
  stepper1.setAcceleration(100);

  digitalWrite(8, LOW);

}

void loop() {

stepper1.setSpeed(200);
Serial.println("Starting motor...");
stepper1.runSpeed();

}

The stepper datasheet says it has 1.50A rate current per phase. Using the formula for the DRV8825 : Vref = Imax / 2 = 1.50 / 2 = 0.75, I have set it to 0.75V.
I am not sure this is totally correct since the 1.50A is the rated current per phase and maybe it isnt the right value for Imax in the formula.
I have asked chatgpt but it gives me this formula:
Itrip_max = 1.50A / 2.5 = 0.60A
Vref = 0.60A × 8.2 = 4.92V
This looks to me very dangerous since the driver, set to 0.75V, already gets very hot.

Please help me find where the problem is...

Why are you using pin 1? this is part of the Arduino's communication system and you should not be using this pin.

Also try swapping the two wires of one of the phases, that is often the cause of this sort of thing.

The first parameter is not a pin, but the mode Accelstepper uses. '1' stands for step/dir drivers and the step/dir pins must not be swapped.

1 Like

I tried your simple sketch with my CNC shield V3 and it worked fine. Your Serial.println in every loop cycle slows down the loop a lot, so the stepper will not spin with 200steps/sec, but it spins.
There must be a problem with your hardware. Can you show a photo of your setup and especially show how your motor is wired.
Be aware, that runSpeed does not do any acceleration. So if you set to a higher speed ( and delete the Serial.println :wink: ) it may not work and vibrate only.

Im Sorry the forum wont let me upload images. It says new users cant attach files... Is there anything I can do or im missing?

To post images etc. you need trust level 1, you can get there by:

  • Entering at least 5 topics
  • Reading at least 30 posts
  • Spend a total of 10 minutes reading posts

IMG-20240509-WA0026.pdf (271,8 KB)
Hello again, here are the photos of the wiring, I Hope you can see everything you need. Thanks in advance

most likely a dead driver.

Im Sorry but i dont think that Is the problem.

I now have switched both the driver and the stepper for new ones and It does the exact same thing: the sketch says the stepper should run smoothly at 200 steps/sec (12.5 steps/sec considering I have set 1/16 microstepping) but it just vibrates back and forth.

Should I try buying a new Arduino and CNC shield and Just replace everything?

That's the formula for a DRV8825 from Pololu, did you buy your driver from Pololu? If not, it may have different current sense resistors.

"stepper1.runSpeed();"

runSpeed does not do acceleration, you need stepper1.run, but you have to provide a position to run to.

https://hackaday.io/project/183279-accelstepper-the-missing-manual/details

I would use MicroBahner's MobaTools library from the IDE's library manager.

Try AccelStepper stepper1(1, 5, 2);

Unfortunately the connection to the stepper can't be seen. Did you check the coil connections with a meter?

That will not work. Step/dir pins are fixed to 2,5 on the cnc shield.

Hello again, I ended up buying a new Arduino+shield+drivers kit and I Will try again when the hardware gets shipped.
I was thinking tho, that the problem with my previous setup might have bene the fact that the Arduino was placed over the metal plate of the Power supply. Could this have caused some short circuits by accidentally connecting Arduino pins underneath the board??

That's a rhetorical question, isn't it?

1 Like

Yes but that could also not have bene it. I wanted to write about It anyway so if anyone in the future reads they will not make thie same mistake

This is a beginners mistake that I would nobody want to rob from the opportunity falling for it. If you realize you did it, just hit yourself really hard and try to remember next time.

All right, time to close this post as now everything works fine. The problem was Just the motors i bought... I ended up buying a new stepper from twotrees and It works perfectly.
I guess Just dont buy nema 17 from stepperonline.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.