Stepper not moving, using grbl and cnc shield

I have been working on repairing an old cnc, have tried alot but nothing seems to help.
So today I setup an aduino, breadboard with drv8825 and a random stepper I got of a friend.
With the following code I got the stepper moving see video.

Code used:

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

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

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

  // 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);
}

On the breadboard I measured the drv8825:
EN, RST, SLP 5v and VMOT 18v

So when I put the cnc shield v3 on top of the arduino and plugin the power supply and try moving the stepper with universal g-code sender nothing happens. When I check the EN, RST, SLP pins they all seem fine but the VMOT is about 0.2v.

Does anyone have an idea what I am doing wrong?

The CNC shield disables the steppers by default. You must enable them before they will work.

The step and dir pins for the X axis motor are step = 2 and dir = 5. You have to use the pins as mapped.
Here is the pin mapping for the Uno to the CNC shield.
cnc shield Uno pins

Here is your code with the step and dir pins fixed and the enable pin included. Works on my Uno CNC shield setup. Try this code with the CNC shield installed. Did it work? If so and it still won't work with grbl installed using UGS, then it may be a grbl setup problem. Grbl can come up in an alarm state that disables the steppers and you need to make changes to the settings to get the motor to run.

// Define stepper motor connections and steps per revolution for the X axis motor:
#define dirPin 5
#define stepPin 2
#define enablePin 8  // ******** name the enable pin

#define stepsPerRevolution 200

void setup()
{
   // Declare pins as output:
   pinMode(stepPin, OUTPUT);
   pinMode(dirPin, OUTPUT);
   pinMode(enablePin, OUTPUT);  // ******** set the enable pinMode
   digitalWrite(enablePin, LOW); // ******** enable the motors
}

void loop()
{
   // 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);
}

Did you, carefully, set the coil current on the driver. It is important that you do so. The Pololu page on the drv8825 has instructions and a video on how to do it.

It can be difficult for us to help you without seeing exactly how you have connected up your CNC shield board - how you have powered it and the arduino. This seems to be a commonly asked question, so I have written an article showing how to get the Arduino / CNC shield working with a small CNC machine at Arduino / CNC Shield Machine Controller. I have also written up how to set up your stepper motor drivers at Configuring Stepper Motor Drivers.

The key bit of information you have provided for me which sounds like a problem is that Vmot is about 0.2V. This sounds very wrong, which is why I suggest looking at my articles and ensuring you have powered everything correctly and have set up the stepper motor drivers correctly.

For Grbl, I would suggest ensuring that hard limits are disabled ($21=0) and that the homing cycle is disabled ($22=0), as this is the cause of the alarm state that groundFungus mentions. You definitely need to establish why Vmot is only 0.2V first though!

You mentioned that the cnc shield disables the stepper by default but when running grbl I would not have to take this into consideration right?

I'll provide some pictures as soon as possible. Thanks for the quick reply.

You are correct - grbl will handle the stepper enable for you - as you will see in my article the CNC Shield will work without further configuration in this regard. I strongly believe that the Vmot at 0.2V indicates where your problem lies!

Sorry if the post was unclear I will try to get some pictures. The arduino is being powered by the laptop usb connection. The cnc shield was being powered by an ac/dc adaptor that outputs 24V/9.2A, I thought it was broken so all the testing I have done recently was with a car battery charger which was set to outputting 12V.

Also as you said the vmot is the main issue because the steppers are simply not getting enough power. So the vmot reading is correct when using a breadboard but not with the cnc shield, could the cnc shield be faulty? Or is that not the case because the enable pin reading is good?

So at the input I read correct value, but the vmot is low.

The points on your CNC Shield that you have indicated are directly connected via PCB tracks, so you can check that they are OK by disconnecting everything from the CNC shield and checking for continuity using a multimeter.

I think it's possible that your problem is with using a car battery charger as a power supply. Even a basic charger detects the state of the battery that is connected and reduces the current to low levels once the battery is charged, hence it is not a simple power supply!

Can you test your 24V power supply and if it is OK go back to using that?

I would also test the glass fuse on the CNC Shield with a multimeter to see if you have blown it - it's just about where the blue dot on your photograph is.

Allright at first I thought the 24v one was malfuntioning becasue the multimeater reading was showing 80v meansuring on the blue connector. But after trying a different meter it was around 24v so the meter must have been faulty. I will try again with the 24v one.

Should I measure the amps on the fuse with any drivers connected?

Having the drivers plugged in won't make any difference, but disconnect all power supplies before taking the reading. You are not 'measuring the amps'. You should take a continuity or resistance reading across the glass fuse using your multimeter. You should measure close to zero ohms. As it is a glass fuse, you might be able to see if it has blown by just looking at it - is the wire inside burnt out at any point?

The picture kinda looks messy if anything is unclear let me know and I will get back to you.
So I checked the resitance on the fuse of the cnc shield and it is not zero or a low number, meaning the fuse on the shield is fried? This could explain why the vmot on the driver is so low when using the shield.

Also I tried the old power supply and was able to run a stepper properly using the code posted originally.

I will get a new cnc shield and try running a stepper using grbl again. Now I am wonding how I damaged the cnc shield. Could you maybe eleborate a bit on what could burn the fuse? What should I keep in mind when putting everything back together? I do not want to damage the cnc shield again.

Also two of the steppers in my setup do not have any stickers or info on them. How could I identify them, that is to adjust the vref on the drivers properly.

Thanks a lot, made some more progress today hopefully everythig will be up and running soon!

If the fuse resistance is not close to zero ohms, then it will be fried. You could actually either replace the fuse or even solder a piece of solid core wire across the PCB pads it connects to in order to 'repair' your CNC shield. The later versions of this board have the fuse removed anyway as it is unlikely to provide much protection to the motor drivers.

The only thing that burns out a fuse is too much current. How that happened is difficult to say but try to think it through yourself - did you accidentally short anything? Did you use the DRV8825 driver that was working successfully in your breadboard in the CNC shield to rule that out as being different? Did you use the same power source for both tests? Did you use exactly the same stepper motor?

As far as what to keep in mind, try to change as little as possible between your successful breadboard test and your first try at using the CNC shield - make it so that the CNC shield is the only change you make, so that you are eliminating any other variables. The CNC shield is actually such a simple circuit that it is unlikely to cause you any problems, it really is only a mounting PCB to join the Arduino to the DRV8825 drivers. Aside from that, just check your connections carefully before powering it up for the first time.

Now to the stepper motor in your photograph - I hope you haven't been connecting that to your DRV8825 / CNC Shield combination! The small 'random stepper from a friend' ( M35SP-11NK) is a very small motor that can easily be driven by the DRV8825. The stepper motor that you show in your photograph is a different beast entirely. It is difficult to guess its size from just a photograph, but it looks like at least a NEMA 23 or possibly a NEMA 34 to me and that is just way too much motor for the DRV8825 to handle. A NEMA 23 stepper will need at least 2.8A, possibly 4.0A or more. The DRV8825 can provide 2.5A maximum.

I'm afraid without an identifying sticker it will be nearly impossible to know the specification of your motor. You say you are rebuilding a CNC machine - could the manufacturer of the CNC machine help?

The CNC machine was bought of someone who build it himself, but sadly no way to contact them.

Ordered a new shield earlier today, but I'll just keep the old one if needed in the future just soldering a direct wire. Good to know.

I have used the machine in the past for a year or so the original setup was also using DRV8825's. What kind of problems can insufficient current cause while the steppers are in use?

I believe too much current causes them to just run quite hot, the M35SP-11NK was very hot when I ran it on the breadbord.

If the original set-up used DRV8825 drivers then I must be seeing the stepper motor in your photograph as larger than it really is, I'm guessing it is a NEMA 17 frame despite the way it looks! You can identify the frame size by comparing physical size measurements of your motor against the table shown here. If it is a NEMA 17, then the DRV8825 is probably OK.

Insufficient current to the stepper motor will cause it to lose torque and possibly miss steps. I was concerned that your motor was too large for the DRV8825, because if you draw more than 2.5A from the DRV8825, it will burn out. I was also heading towards the possibility that this also explained why your fuse has burned out, but if your photograph shows a NEMA 17 motor then this probably isn't the case. I say probably because NEMA 17 describes the physical size of the motor, not it's maximum current rating although a smaller motor tends to have a lower current rating.

You are correct in thinking that too much current causes stepper motors to run hot, which is why it is important to set the current limits correctly on your drivers. It is normal for stepper motors to get hot, many datasheets show that 80 degrees Celsius is a typical temperature for them to reach in normal operation, so obviously too hot to touch! Having said that too much current and heat will burn out the motor. As you don't have any data on your steppers motors, I would set the current limit to something quite low to start off with (maybe 0.8A), test your steppers motors in the CNC machine and then raise the current if necessary if you find you have insufficient torque or are missing steps etc. If your steppers are NEMA 17 frames, then you will probably find that the maximum phase current is in the range 0.8A to 1.3A, although of course there are exceptions to this! Try to keep the motor current as low as possible to give yourself reliable operation and sufficient torque as lower current equates to lower temperatures and long term reliability.

I took the driver out of the breadboard and plugged it into the old cnc shield with the fuse shorted, new one has not arrived yet. I was able to move the stepper using universal g-code sender.

Still need to figure out a good way to set the vref on the drivers the screw seems to be quite sensitive. I measured 1.4-1.6V and tested with that. It goes from 0.4 to 1.6V with just turning it slightly.

Do you have any recommendations on how to set it accurately?
I can simply seat all the drivers and plugin all the stepper, power Arduino, power 24V. Then measure the vref for each stepper right?

Did not have the chance to compare the measurements from the table yet. Will get back on that later.

I installed the new shield set the vref to ~1.4V for the z-ax and y-ax these stepper look similar like the picture posted before. Motor size from the link you provided points to them being NEMA 23's. The x-as are different steppers, but luckily they have stickers and are rated at 1.2 amp so I set the vref to ~0.6V.

Sending a file with universal g-code sender seems to work fine. Just one weird problem, the y-ax does not seem to move smoothly.

In the video you can see that it is moving correctly to the right but the movement towards the camera sounds like the stepper is skipping/slipping on the belt. The movement is very little and also inconsistent sometimes it does run.

Posted two short videos on imgur, one with a short movement that seems to work. Other one showing how it acts up.
https://imgur.com/a/P4ax72n

Any idea why it moves like this?

Edit:
Maybe it has to do with step size. I have put jumper on the first and last pins leaving the center one empty. I did this because it is how I remember the original setup, but I could be wrong. How is the step size supposed to be configured?

Everthing seems to work fine now. I dailed back the current on the nema 23 driver to ~1.0 A, because I believe the y-as driver was shutting down due to thermal issue.
Also reinstalled back the 20mm fans that point towards the drivers. I was able to succesfully phrase something.
Thanks a lot for all the help!

I'm really glad that you managed to get everything up and running!

You seem to have overcome the problem of setting the vref accurately, but just for information on the DRV8825 drivers I have I would have no difficulty in setting the vref to an accuracy of 0.05V and with a little extra care can set it to an accuracy of 0.01V using the screwdriver method that I outlined in the article linked in my first post. The small variable resistor only travels about 3/4 of a turn in total so I suppose it is a little fiddly until you get the hang of it.

If it is all now working fine as you say then well done, but if you have any future issues with the y axis then it could be worth reducing the micro-stepping level, as the on-off-on jumper setting you indicate sets the DRV8825 to 1/32 microsteps. Whilst this gives the highest resolution of movement, it will also reduce the torque output of the motors. You could try reducing this to 1/16, 1/8, 1/4 etc. to see if the increased torque improves reliability. The jumper settings you need are in Table 1, bottom of page 13 on the DRV8825 datasheet, linked from my article above.

Good luck and I'm glad I was able to help you out!

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