adding micro steps to code to improve smooth running of stepper

I am trying to set up a Nema 17 stepper motor with a cnc shield and a4988 driver. I am trying to increase the smoothness of the turning motor. I understand that steppers turn by degrees and so it cant get completely smooth, thats a better use for servos or DC motors. How can I add micro steps or current limits or something to this code to improve smoothness when running my stepper particularly at low speed. See code below

#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();
}

Microstepping is a setting on the A4988 driver. The Pololu A4988 web page explains all about it. You can connect the microstep pins to the Arduino so the program can change the setting but that is rarely necessary.

...R

This is basically a hardware-thing

The stepper-driver has three pins to adjust microstepping. So you have to change the LOW-HIGH-signals on the microstepping pins. If you don't want to change the microsteps while your device is working you can connect these IO-pins permantly to Ground / 5V according to the datasheet of the A4988.

If you want the steppermotor to run almost silent use a different stepperdriver from trinamic.
TMC2208 / TMC2209 The difference how quite a steppermotor runs with this drivers is enormous
Even in halfstep-mode.

If you do use microstepping you have more steppulses per rotation so you have to create the steppulese faster to create the same speed.

best regards Stefan

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