# hello, good day, I have a nema 23 stepper motor that reaches up to 150 RPM, how can I achieve higher speeds?

#### whescker

Joined Jul 13, 2022
2
I am using a 24V 5A switching power supply.
Arduino UNO with potentiometer

and the code is:
Arduino Stepper Motor Code:
const byte DIR = 2;
const byte PUL = 3;
int pulsos_por_revolucion = 1000;
int PPR = pulsos_por_revolucion;
float senal = A0;
void girar_derecha();
void girar_izquierda();

void setup() {
pinMode(DIR, OUTPUT);
pinMode(PUL, OUTPUT);
Serial.begin(9600);}

void loop() {
float motorSpeed = map(sensorReading, 0.0, 1023.0, 500, 30000);
Serial.println(motorSpeed);
if (motorSpeed < 25000){
digitalWrite(DIR, LOW);
for (int i = 0; i < 2; i++){
digitalWrite(PUL, HIGH);
delayMicroseconds(motorSpeed);
digitalWrite(PUL, LOW);
delayMicroseconds(motorSpeed);}}}
Motor Driver HY-DIV268N-5A 5A 12-42V

<MODERATOR: Please use CODE tags when posing code. you can find the option in the ••• menu on the top of the edit box. I‘ve done it for you this time. Thanks!>

Last edited by a moderator:

#### DNA Robotics

Joined Jun 13, 2014
649
Try
float motorSpeed = map(sensorReading, 0.0, 1023.0, 200, 30000);

motorSpeed is a delay. The lower that number, the faster RPM until you get into mechanical or harmonic limits.

#### MisterBill2

Joined Jan 23, 2018
18,450
The torque wll drop a bit as the speed increases and at some point it will drop more rapidly, as the current in the coils will not have time to rise before the pulse ends. That can be compensated for with a higher supply voltage and a series resistor but that becomes very inefficient. Using a more complex scheme the voltage can rise with the speed, but that is a complex scheme to make work well.

#### Papabravo

Joined Feb 24, 2006
21,225
I am using a 24V 5A switching power supply.
Arduino UNO with potentiometer

and the code is:
Arduino Stepper Motor Code:
const byte DIR = 2;
const byte PUL = 3;
int pulsos_por_revolucion = 1000;
int PPR = pulsos_por_revolucion;
float senal = A0;
void girar_derecha();
void girar_izquierda();

void setup() {
pinMode(DIR, OUTPUT);
pinMode(PUL, OUTPUT);
Serial.begin(9600);}

void loop() {
float motorSpeed = map(sensorReading, 0.0, 1023.0, 500, 30000);
Serial.println(motorSpeed);
if (motorSpeed < 25000){
digitalWrite(DIR, LOW);
for (int i = 0; i < 2; i++){
digitalWrite(PUL, HIGH);
delayMicroseconds(motorSpeed);
digitalWrite(PUL, LOW);
delayMicroseconds(motorSpeed);}}}
Motor Driver HY-DIV268N-5A 5A 12-42V

<MODERATOR: Please use CODE tags when posing code. you can find the option in the ••• menu on the top of the edit box. I‘ve done it for you this time. Thanks!>

View attachment 274062
Am I correct that you are trying to start, stop and run the motor at a constant speed? If so, that is a suboptimal approach.
At 200 steps per revolution that is 500 steps per second. With careful hardware and firmware design you should be able to do several times that speed before the motor runs out of torque. However, you cannot get to those speeds from a dead stop.

#### Marley

Joined Apr 4, 2016
502
You will always have to accelerate up to a high speed. Torque will drop as speed increases.
As MisterBill says the problem is getting the current to rise and fall in the windings quick enough at high speeds.
To do this properly needs low inductance (low voltage) windings fed from a high voltage supply. Either via a resistor - very inefficient or using switching H-bridges (with current monitoring) - good but complex.
Servo motors with position feedback are better for high speeds and high power.

#### shortbus

Joined Sep 30, 2009
10,045
Either via a resistor - very inefficient or using switching H-bridges (with current monitoring) - good but complex.
All of that is in his stepper driver module. They are the only way to go for steppers and very low cost today. But the speed still needs to be ramped up from a stop, which his micro can be programmed to do.

#### MisterBill2

Joined Jan 23, 2018
18,450
So the next step is to write some cod to ramp up the frequency. I see a driver in the photo, but does the TS know how to program it An actual stepper driver system is much different from an arduino. I suggest reading the manual for the driver module.