Nema 17 stepper motor control (motor will not run past a certain speed)

Hello,

I am trying to control a stepper motor using Arduino uno. The code is attached. The code we are using runs fine, but the motor will not run past a certain speed. I just wonder if the speeds are just too high for the motor to handle or if it is a problem with the code?

Thank you.

#include <Stepper.h>
 
int in1Pin = 12;
int in2Pin = 11;
int in3Pin = 10;
int in4Pin = 9;
 
#define STEPS 200
 
Stepper motor(STEPS, in1Pin, in2Pin, in3Pin, in4Pin); 
 
void setup()
{
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(in3Pin, OUTPUT);
  pinMode(in4Pin, OUTPUT);
 
    while (!Serial);
   
  Serial.begin(9600);
  motor.setSpeed(245);
}
 
void loop()
{
  if (Serial.available())
  {
    int steps = Serial.parseInt();
    motor.step(steps);
  }
}

Unless the stepper is tiny you must ramp motor speed up and down to get maximum performance - the
Stepper library cannot do this, try the AccelStepper library.

What motor, power supply and driver are you using - please always give full details of all hardware when
asking questions, that’s essential detail…

The stepper motor is called the Nema 17 and running off of a 12 volt power supply. L293D stepper motor driver. I will look into the AccelStepper library to ramp up the speed instead of setting it at a high speed initially.
Do you think current electronic configuration could work with a code that ramps up the speed?

McClaneK:
I am trying to control a stepper motor using Arduino uno. The code is attached. The code we are using runs fine, but the motor will not run past a certain speed. I just wonder if the speeds are just too high for the motor to handle or if it is a problem with the code?

It's unclear what speeds you mean. It's like saying a car runs just fine, but won't run past a certain speed. And naturally ..... there will be an expected top speed.

McClaneK:
The stepper motor is called the Nema 17

That just defines the size of the front face - 1.7 inches. It says nothing about the electrical characteristics. Please post a link to the datasheet for the motor.

...R

Attached file is the motor’s data sheets.

nema17-amt112s.pdf (858 KB)

nema17-amt112s.pdf (858 KB)

That datasheet covers 7 different motors. Which one do you have?

...R

I have the last one NEMA17-23-01DAMT112S

Thank you for trying to help me.

That stepper motor requires 2 amps and an L293 driver is totally unsuitable. I'm surprised that the L293 has survived this long.

Unfortunately the usual Arduino stepper drivers such as the A4988 and the DRV8825 cannot provide 2 amps either. You will need a more expensive stepper driver such as one that has a TB66xx chip. Look for a stepper driver than can provide 3 or 4 amps to give yourself some headroom.

...R
Stepper Motor Basics
Simple Stepper Code

What a shame, if you'd chosen the NEMA17-16-06PD-AMT112S model (1.4A) then a cheap DRV8825 module
would have been fine driving this.

You could try a DRV8825 set to 1.5A and hope that's enough with your 2A motor?