Stepper motor w/ A4988 driver makes noise when idle

Hi,

I'm working on a camera mount that tracks the stars so that I can take long exposures. I am using a NEMA17 stepper motor driven by an Arduino Nano and an A4988 driver. I'm using the driver in quarter step mode and it is driven by a 12v adapter capable of delivering 2 amps. The nominal current for the motor is 1.2 amps.

I've gotten the motor to work fairly quickly without any problems. But I have noticed that when I stop the motor movement either by breaking the loop or resetting the board, the current measured trough one of the four wires stays locked at values that differ after each rotation. This is accompanied by a whining noise that is different after every time I stop the rotation.

I've experimented with current limits in full step mode between 0.4 and 0.8 amps but the problem persists.

Some forum posts state that this driver "holds" the motor at a certain position when stationary. Could this be the cause of the noise/current?

My code:

//Set drive gear number of teeth
const int  driveTeeth = 38;

//Set intermediate gear number of teeth
const int intermediateTeeth = 18;

//Set motor gear number of teeth
const int motorTeeth = 17;

//Set stepper motor steps per revolution
const int motorStepsrev = 200;

//Required drive gear speed (RPM, default 1)
////----Change this value during calibration---------------------------------------////
////----Calculate using formula: Radius (in inches) = RPM / ((2Π/ 1436) * TPI)----////
float driveSpeed = 1;


//Calculation of required intermediate gear speed [RPM]
float intermediateSpeed = (38 / 18) * 1;

//Calculation of required motor gear speed [RPM]
float motorSpeedRPM = (intermediateTeeth / motorTeeth) * intermediateSpeed;

float motorSpeedStepsSec = 7.45098039;

//Required motSpeed in milliseconds/step
float motSpeed = ((1/motorSpeedStepsSec)/4)*1000; 

int currentPos = 0; 
 
//stepper motor outputs
#define dirPin 3
#define stepPin 2
#define motorInterfaceType 1

// button inputs
#define buttonRun 11
#define buttonReturn 5

// create debounce objects
Bounce runIn = Bounce(); //Run tracker toggle
Bounce returnIn= Bounce(); //Return to start toggle

void setup() {
  //Set pinModes
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  
  //Attach input pins/buttons to internal pullup and set debounce time
  runIn.attach(buttonRun, INPUT_PULLUP);
  runIn.interval(100);
  returnIn.attach(buttonReturn, INPUT_PULLUP);
  returnIn.interval(100);

  //Print results from speed calculations in serial
  Serial.begin(9600);
  Serial.println("Calculated intermediate speed [RPM] at:");
  Serial.println(intermediateSpeed);
  Serial.println("Calculated motor speed [RPM] at:");
  Serial.println(motorSpeedRPM);
  Serial.println("Calculated motor speed [Steps/s] at:");
  Serial.println(motorSpeedStepsSec);
  Serial.println("Calculated motor milliseconds/s");
  Serial.println(motSpeed, 7);

  digitalWrite(stepPin, LOW);
  digitalWrite(dirPin, LOW);

}

void loop() {
  //Update button debounce status
  runIn.update();
  returnIn.update();

  if(runIn.fell()){
  currentPos = 0;
  Serial.println("RUN PRESSED"); //Used for debugging
  
  while(currentPos < 3200)
  {
      currentPos = currentPos + 1;
      Serial.println(currentPos);
      
      // advance motor one step at calculated steptime
      digitalWrite(stepPin, HIGH);
      delay(motSpeed);
      digitalWrite(stepPin, LOW);
      delay(motSpeed);
    }
  }

  
}

The normal way stepper motors are used is for them to hold their position when stationary and that means that current is flowing through the motor coils. The noise is probably due to the driver chopping the current on and off at high frequency to ensure that it never exceeds the current limit that you have set. I wonder if the noise is greater if the motor happens to stop on one of the quarter step positions rather than at a full step position?

If the noise really is a problem there is a newer brand of drivers (called TMC if memory serves) which claim to be much quieter. I have no experience with them.

...R

Thanks for your quick reply!

Robin2:
I wonder if the noise is greater if the motor happens to stop on one of the quarter step positions rather than at a full step position?

If the noise really is a problem there is a newer brand of drivers (called TMC if memory serves) which claim to be much quieter. I have no experience with them.

...R

The noise does seem the loudest if it holds at around 0.7 amps which is roughly 90% of the current limit I set in full step mode. The noise itself isn't really a problem, just wondered if it was normal cause I want to minimize power consumption and heat so that I can use a 12v battery later on.

For now I set the driver enable pin high when I don't need the motor to spin or hold, seems to work fine!

The noise is normal, caused by the current limiting process, and movement in the motor windings.

Go to YouTube, and search for "stepper motor music".
Leo..

bramlaurens:
Thanks for your quick reply!

The noise does seem the loudest if it holds at around 0.7 amps which is roughly 90% of the current limit I set in full step mode. The noise itself isn't really a problem, just wondered if it was normal cause I want to minimize power consumption and heat so that I can use a 12v battery later on.

For now I set the driver enable pin high when I don't need the motor to spin or hold, seems to work fine!

That will allow the stepper to lose position though. Some stepper drivers have a convenient pin to switch
to 50% current mode, which reduces power consumption to about 25% when idle, without compromising
torque much (stationary torque is often more than needed if dynamic torque is OK).

Alas the A4988 and DRV8825 aren't like this and you'd need to modulate the reference voltage pin for
such effects (not brought out on common modules).

If battery life is an issue, choosing a stepper was perhaps a mistake.