Stepper motor

please help me

i need to rotate stepper motor nema 23 with 200, 100, 50 rpm. i have arduino board and Micro-Stepping Drive and arduino board.

i put programme into arduino is given below but it gives only 26 to 46 rpm. i need 50,100, 200 rpm kindly give me programming code for given rpm

int dirPin = 9;
int stepperPin = 8;
void setup() {
pinMode(dirPin, OUTPUT);
pinMode(stepperPin, OUTPUT);
}
void step(boolean dir,int steps){
digitalWrite(dirPin,dir);
delay(0);
for(int i=1;i<steps;i++){
digitalWrite(stepperPin, HIGH);
delayMicroseconds(0);
digitalWrite(stepperPin, LOW);
delayMicroseconds(0);
}
}
void loop(){
step(true,100);
delay(0);
step(false,100*6);
delay(0);
}

please help me

kindly give me programming code for given rpm

Can't. We don't know the steps per revolution of the motor. We don't know the microstep setting.

Please read the "how to use the forum" stickies to see how to format and post code. And for guidelines on how to ask a question.

This post may have information to help you.

Why are you not using the Stepper library?

These links may help
Stepper Motor Basics
Simple Stepper Code

While it makes sense to use delay() and delayMicroseconds() for testing the motor it is best not to use them in a real project as the Arduino can do nothing else during a delay(). The 2nd of the simple examples does not use delay.

Also, have a look at the AccelStepper library which is very comprehensive. The standard Stepper library is not intended for stepper motor drivers that take step and direction signals.

...R

Dear friends

please help me. i need stepper motor NEMA 23 speed from 100 to 1000 by using arduino. i am connected arduino to rheno microcontroller and microcontroller to stepper motor.
I try folloing arduino code for roatation but it is rotated only upto 40rpm not more than that please modified following code to obtain 100 to 1000 rpm stepper motor speed plz.

int dirPin = 9;
int stepperPin = 8;
void setup() {
pinMode(dirPin, OUTPUT);
pinMode(stepperPin, OUTPUT);
}
void step(boolean dir,int steps){
digitalWrite(dirPin,dir);
delay(0);
for(int i=0;i<steps ;i++){
digitalWrite(stepperPin, HIGH);
delayMicroseconds(0);
digitalWrite(stepperPin, LOW);
delayMicroseconds(0);
}
}
void loop(){
step(true,100);
delay(0);
step(false,100*6);
delay(0);
}

Assuming your motor has 200 steps per revolution then for 100 RPM = 1.667 RPS you need 334 steps per second. For 1000 rpm you would need 3334 steps per second. How many steps per second is your code generating? 1000RPM would be fast for a stepper motor.

Getting a high speed with a stepper motor will require a high voltage power supply - but you have told us nothing about that.

What stepper motor driver are you using? - post a link to its datasheet.
Also post a link to the datasheet fir your motor.

Also it will be necessary to accelerate the motor gradually up to the required speed. And AFAIK the Accelstepper library may not be able to produce the higher step rates that you require - but it would be worth trying it.

And from what others have said here I believe stepper motors (especially with no load on them) are prone to resonate at certain pulse frequencies which can affect the ability to achieve high speeds.

...R
Stepper Motor Basics
Simple Stepper Code

Thank you robin. but my field is mechanical. i dont have that much knowledge of coding if you possible please send me code of arduino to rotate stepper motor.
The following code shows only slower rotation. please send me coding programme. i used coding given below

int dirPin = 9;
int stepperPin = 8;
void setup() {
pinMode(dirPin, OUTPUT);
pinMode(stepperPin, OUTPUT);
}
void step(boolean dir,int steps){
digitalWrite(dirPin,dir);
delay(0);
for(int i=0;i<steps ;i++){
digitalWrite(stepperPin, HIGH);
delayMicroseconds(0);
digitalWrite(stepperPin, LOW);
delayMicroseconds(0);
}
}
void loop(){
step(true,100);
delay(0);
step(false,100*6);
delay(0);
}

Thank you robin. but my field is

. . . serial cross-posting.

DO NOT CROSS-POST, CROSS-POSTING WASTES TIME

pravin1900:
Thank you robin. but my field is mechanical. i dont have that much knowledge of coding if you possible please send me code of arduino to rotate stepper motor.

I already did - in Reply #5.

Did you not read it?

...R