Problem with stepper_motor

Hello!

i have a bit of a problem (thats probably really simple but its my first time using a stepper motor)

So i have this simple code that basically tells the stepper to step x steps and it works perfectly if i set it to step 512 step but whenever i set a higher value something like 2000 or higher it steps almost one revolution but stops right before and then i have to reload the sketch for it to do the same again. It doesnt matter if i but 2000 or 10000 steps its the same. Is there something i am missing here?

So If i change the stepper.step value to 2000 or higher it always stops after almost one full rotation but not quite. i want it to spin maybe like 10-15 full rotation!

Thanks ahead!

#include <Stepper.h>

const int stepsPerRevolution = 512;  // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, D1, D3, D2, D4);



void setup() {
  // set the speed at 60 rpm:
  myStepper.setSpeed(60);
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
  // step one revolution  in one direction:
  Serial.println("clockwise");
  myStepper.step(512);

}

What is the exact maximum number of steps that is implemented correctly?

512 steps per revolution seems odd 200 is most common and you can also get motors with 400 steps. What stepper motor are you using? Post a link to its datasheet.

What stepper motor driver are you using?

How are you powering the stepper motor?

...R
Stepper Motor Basics
Simple Stepper Code

The maximum number of steps is from my understanding 2048.

I am using a stepper motor called 28BYJ-48 and the driver is a ULN2003. I am powering it via a 9v battery.

Link to datasheet: http://robocraft.ru/files/datasheet/28BYJ-48.pdf

Falkich:
The maximum number of steps is from my understanding 2048.

Please do some tests so that you can be certain.

Link to datasheet: http://robocraft.ru/files/datasheet/28BYJ-48.pdf

The datasheet clearly says that there are 64 steps per revolution.

...R

Yes it says it have 64 steps per revolution but it has gears which is 32 and 3264 = 2048. I've also tested using 64 and i just steps a tiny bit and if i step it 512 not in a loop it steps 1/4 of a revolution and 5124 is 2048 but here comes the problem when i set it to 2048 it doesnt not step one full revolution it stops right before one revolution and the loop stops working so i have to reload the sketch for it to do the same again.

and same happens if i but like 5000 steps it stops after almost one rotation its like there is a stop there.

From reading this web page it seems that the motor actually has 32 full steps per revolution.

With my 28BYJ motor this version of your code works. But it did not work when I increased the speed to 480 RPM.

#include <Stepper.h>

const int stepsPerRevolution = 32;  // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 3, 4, 5, 6);



void setup() {
  // set the speed :
  myStepper.setSpeed(360);
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
  // step one revolution  in one direction:
  Serial.println("clockwise");
  myStepper.step(512);

}

The Accelstepper library used in the linked page is much better than the standard Stepper library.

…R

Okey thank you i will try that and see if it works better for me!