Stepper motor stalling only at low frequencies.

Hi everyone. I am having an issue driving a stepper motor and I was looking for some help.

The motor I am using is here

This is the driver that I am using

I am trying to move the motor at various speeds with an analog signal, and I am using the AccelStepper library AccelStepper: AccelStepper library for Arduino . This is because in the future I want to use two motors at once. I can drive the motor quick with step speeds over a couple hundred steps per second. But when I slow down the motor just stalls and makes more of a clicking sound. Right now I do not have micro stepping engaged, so each signal of the drive should be a step to the motor.

Here is my code. This is make a custom syringe pump.

#include <AccelStepper.h>
AccelStepper stepper(1, 3, 2); // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
int microStepResolution = 1;
int numStepsPerMl = 1500 * microStepResolution; //8 revolutions for 1 ml in 10 ml syringe. 200 steps per rev
float flowRate = 8; // ml/min Don't go over 40 ml/min. We want
int stepSpeed = flowRate * (numStepsPerMl / 60);
const int trialPin = 12;
const int driverSleep = 11;
int stepPosition = 0;
int trialState = 0;
int analogInPin = A0;    // select the input pin for the potentiometer
int sensorValue = 0;  // variable to store the value coming from the sensor
int outputValue = 0;

void setup() {
  // put your setup code here, to run once:
  stepper.setMaxSpeed(800);
  stepper.setSpeed(stepSpeed);
  pinMode(trialPin, INPUT);
  pinMode(driverSleep, OUTPUT);
  pinMode(13, OUTPUT);
  stepper.setCurrentPosition(0);
}

void loop() {
  // put your main code here, to run repeatedly:
  trialState = digitalRead(trialPin);
  stepPosition = stepper.currentPosition();

  if (trialState == HIGH) {
    digitalWrite(13, HIGH);
    digitalWrite(driverSleep, HIGH);
    sensorValue = analogRead(analogInPin);
    outputValue = map(sensorValue, 0, 1023, 0, 2 * stepSpeed);
    stepper.setSpeed(outputValue);
    stepper.runSpeed();
  }

  else if (trialState == LOW && stepPosition != 0)
  {
    digitalWrite(13, LOW);
    digitalWrite(driverSleep, HIGH);
    stepper.moveTo(0);
    stepper.setSpeed(800);
    stepper.runSpeedToPosition();
  }
  else
  {
    digitalWrite(driverSleep, LOW);
  }
}

Thank you tremendously for any help. I can’t quite tell if this is an issue with the Accelstepper library, my coding, the driver, or the motor.

FB

How are you powering the motor?

Hi jremington,

Thanks for the reply. The motor is 5V and it's being powered by a 5V 3A wall wart. This goes to the stepper driver and then the driver should send it to the motor. Do you think it's underpowered?

FB

The driver is inadequate for that low resistance, high current motor, which would draw 6 amperes total at 5 V and overheat. Pololu recommends the DRV8825 driver.

For best performance use a 12-24 V power supply capable of around 2 amperes (for one motor). Be sure to follow the directions to set the current limit to somewhat less than 1.5 amperes/phase.

On the driver is a small potmeter, turn it until you the current is controlled. at high speeds the current is high, but at low speeds it must be limited. set the speed once (in a function) in the loop only the stepper.run (or stepper.runspeed) the driver should be connected only with pin 3, and 2 so the comment is not correct.

I wonder why you have chosen a low voltage stepper driver. Most stepper motors work best at high voltages - say 12v, 24v or 36v.

I guess the low voltage driver would make sense if you had no higher voltage power supply available. But the performance of the motor won't be as good as it could be.

...R Stepper Motor Basics

Hi everyone. Thank you again for the help with this project.

I bought a new driver Pololu - DRV8825 Stepper Motor Driver Carrier, High Current and wired everything up. I am now running this with a new power supply that is 24V and 14.6A. I set the current limit on the driver according to the directions on Pololu’s site. To do this, I wired it up with the minimum wiring diagram and simply left the motors disconnected. I set Sleep, Reset, Direction and Step all high. The equation from Pololu is Current Limit = VREF × 2. Since my motors draw 1.7A/Phase, I set VREF to 0.85V. This should allow the driver to send the motors the total amount of current they need correct?

Again, the general goal is to have the pump move at variable speeds depending on an analog input if a toggle switch is high. The magnitude of the analog signal determines the speed. When the toggle switch goes low, the pump just returns to it’s original position. I have it so close to working. The analog signal does set the speed of the pump nicely, and the pump returns to its original position if the toggle switch is set back to low (assuming the pump doesn’t stall)

A video can be seen here.

Things seem to work well now at very low step rates and at high step rates. But there are these awkward speeds were the pump motor seems to oscillate. I can’t tell what could be causing this. Here is a video of the issue. You’ll notice that for many speeds it works fine, but for some the pump just seems to vibrate back and forth. I’ve tried a few different pump chassis, motors, and drivers. So I’m thinking it’s my code or the motor, driver, power supply combo again.

Here is the code currently loaded on the Arduino. The analog input is essential a trim pot for 0-5V.

#include <AccelStepper.h>
AccelStepper stepper(1, 3, 2); // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
int microStepResolution = 1;
int numStepsPerMl = 1500 * microStepResolution; //8 revolutions for 1 ml in 10 ml syringe. 200 steps per rev
float flowRate = 8; 
int stepSpeed = flowRate * (numStepsPerMl / 60); // Do not exceed 1000 steps per second.
const int trialPin = 12;
const int driverSleep = 11;
int stepPosition = 0;
int trialState = 0;
int analogInPin = A0;    // select the input pin for the potentiometer
int sensorValue = 0;  // variable to store the value coming from the sensor
int outputValue = 0;

void setup() {
  // put your setup code here, to run once:
  stepper.setMaxSpeed(800);
  stepper.setSpeed(stepSpeed);
  pinMode(trialPin, INPUT);
  pinMode(driverSleep, OUTPUT);
  pinMode(13, OUTPUT);
  stepper.setCurrentPosition(0);
}

void loop() {
  // put your main code here, to run repeatedly:
  trialState = digitalRead(trialPin);
  stepPosition = stepper.currentPosition();

  if (trialState == HIGH) {
    digitalWrite(13, HIGH);
    digitalWrite(driverSleep, HIGH);
    sensorValue = analogRead(analogInPin);
    outputValue = map(sensorValue, 0, 1023, 0, 2 * stepSpeed);
    stepper.setSpeed(outputValue);
    stepper.runSpeed();
  }

  else if (trialState == LOW && stepPosition != 0)
  {
    digitalWrite(13, LOW);
    digitalWrite(driverSleep, HIGH);
    stepper.moveTo(0);
    stepper.setSpeed(800);
    stepper.runSpeedToPosition();
  }
  else
  {
    digitalWrite(driverSleep, LOW);
  }
}

Thank you all immensely,
FB

But there are these awkward speeds were the pump motor seems to oscillate. I can't tell what could be causing this.

This is common and caused by mechanical resonance in your hardware.

You could try microsteping the motor, or change something about the mechanics to change the self resonant frequency.