improving smoothness of nema 17 steppers with cnc shield and a4988

I am setting up a nema 17 stepper motor (First time) and used a cnc shield with an a4988 controller. I want to improve the smoothness of the running of the stepper motor. I know that there are better motors like DC or steppers for smooth running and that steppers are inherently not smooth due to the way they turn by degrees. How might I improve this code or my setup for a smoother run of the steppers? I heard something about current limits and micro steps online. I have included my code below for reference to what ive got so far.

#include <AccelStepper.h>

// for the Arduino Uno + CNC shield V3 + A4988 + FL42STH47-1684A

#define MOTOR_X_ENABLE_PIN 8
#define MOTOR_X_STEP_PIN 2
#define MOTOR_X_DIR_PIN 5

AccelStepper motor_X(1, MOTOR_X_STEP_PIN, MOTOR_X_DIR_PIN);

void setup()
{
motor_X.setEnablePin(MOTOR_X_ENABLE_PIN);
motor_X.setPinsInverted(false, false, true);
motor_X.setAcceleration(10);
motor_X.move(3600);
motor_X.setMaxSpeed(5);
//motor_X.setSpeed(5);
motor_X.enableOutputs();
}

void loop()
{
motor_X.run();
}

You must set the coil current limit on the motor drivers or risk damage to the motors and/or drivers. There are instructions on the internet for making the adjustment. Here is one site. The Rsense resistors on many clone board are 0.1 Ohms, but you need to check what is actually installed on your boards. Setting the current will not make the motors run any smoother. The data sheets for your motors should specify the rated coil current.

Setting microstepping will make the motors run smoother. Microstepping will also help with preventing resonances from affecting the motors. Set with the jumpers underneath the drivers on the CNC shield. The table in the Pololu A4988 page shows the jumper settings.

There are also instructions for setting the coil current in the Pololu page. However they may not be using the right value for Rsense on your board. The formula and methodology is valid if used with your Rsense values.

Microstepping is pretty much essential for modern high performance steppers - otherwise you'll
have very noisy running and resonance issues (miss-steps, lockup). Try x8 or x16 in the first
instance is my recommendation.

With a lowly 8-bit microcontroller the high step rates needed for large microstepping factors can
overwhelm the processor, but even modest amounts of microstepping will smooth things out and
improve behaviour.

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