Short version: Controlling a NEMA 17 stepper motor with a DRV8825, stepper motor skips at a specific speed. Specific speed varies with amperage when changing the pot, and varies when changing to different drivers. How do I fix this?
Long version: My son and I built a CNC pen plotter machine and didn't have great results. We didn't know much about steppers, so it has been a learning experience for both of us. We're using GRBL and ChiliPeppr to control the machine. Didn't think about power requirements, and didn't know how to tune the driver motor, but we got it working anyway. Figured out the power supply was under-powered, upgraded to a 12V 15A unit. Found videos on how to tune the drivers and set them to 500mA with the direct measurement method (ammeter inline with stepper motor). The stepper motors are rated at 1.3A. We also tried 1A. The resulting drawing was okay, but it was clearly skipping. Through a lot of troubleshooting, we fixed a few things in the construction but the issue still exists (but not as much). At this point, when we move the X axis with G1X200F1200, the motor skips a lot. F1000 works fine, F1400 works fine, as well as lower speeds and higher speeds. When we move the Y axis, F2200 is the issue. If we change the amperage, the speed that causes the issue changes, but never goes away. As the motor speeds up and slows down through acceleration, it inevitably crosses the point that skips for a few split seconds here, few split seconds there. What are we doing wrong? How do we solve this?
Additional troubleshooting: I wired up a motor driver to a breadboard and wrote a small script to control the speed through a potentiometer and tested 5 different motors. 4 were of the same make (came off a RepRap 3D printer), 1 was a different motor (purchased separately for troubleshooting). The 4 of the same make have the same issue at the same speed, which happens to be around 120 in my code with this particular driver. The other doesn't have any issue at all, at any speed. As mentioned, if I change the amperage, the speed at which the issue occurs changes, but doesn't go away. Same if I change the driver, the speed at which the issue occurs just changes, doesn't go away.
Thanks for the help, hope the additional info wasn't too long.
As mentioned, we're using this with GRBL, but here's my troubleshooting code in case it's helpful:
#include <AccelStepper.h>
AccelStepper stepper(1 /*motorInterfaceType*/, 3 /*stepPin*/, 2 /*dirPin*/);
int maxSpeed = 2400;
int currentSpeed = 0;
int speedCounter = 0;
int displayCounter = 0;
void setup() {
Serial.begin(9600);
delay(2000);
Serial.println("Starting!");
stepper.setMaxSpeed(maxSpeed);
pinMode(A0, INPUT);
setRunSpeed();
}
void loop() {
if (speedCounter > 20000) {
setRunSpeed();
speedCounter = 0;
if (displayCounter > 10) {
Serial.print("Speed: ");
Serial.println(currentSpeed);
displayCounter = 0;
}
displayCounter++;
}
speedCounter++;
stepper.runSpeed();
}
int setRunSpeed() {
currentSpeed = map(analogRead(A0), 0, 1023, 0, maxSpeed);
stepper.setSpeed(currentSpeed);
}