How to get more speed (rpm) in stepper motor 28byj-48 with arduino nano

Hello everyone, I almost know nothing about programming and I made this project for highschool:
It's kinda a rail with a lantern and I am using this stepper with arduino for making the light moves from A to B with a gears and a pulley.

This is the code I am using

#include <Stepper.h>
#define STEPS 2038 //
Stepper stepper(STEPS, 8, 10, 9, 11);
void setup() {
  // 
}
void loop() {
  stepper.setSpeed(16); // 
  stepper.step(32608); // 
  delay(500); //
  stepper.setSpeed(16); //
  stepper.step(-32608); //
}

¨

So the max rpm I get is setting stepper speed at 16, more it stuck and start vibrating.

I wanted to go faster like 25, 30 instead of 16, and I going crazy not knowing how to. Now I am kinda curious if it's possible with this kind of motor to go faster.

Thanks in advance

It's possible that it just won't go any faster with the load you have on it. However, what might be the issue is that it can't start moving at anything over 16, but needs to build up speed. Take a look at the Accelstepper library.

Well, I looked for it and I found this code. It kinda how with inertia and acceleration but still do not get more speed other than previous rpm I got.

The motor is 5v and im powering with a USB.

Any thoughts?

Thanks!

/* Example sketch to control a 28BYJ-48 stepper motor with ULN2003 driver board, AccelStepper and Arduino UNO: acceleration and deceleration. More info: https://www.makerguides.com */
// Include the AccelStepper library:
#include <AccelStepper.h>
// Motor pin definitions:
#define motorPin1  8      // IN1 on the ULN2003 driver
#define motorPin2  9      // IN2 on the ULN2003 driver
#define motorPin3  10     // IN3 on the ULN2003 driver
#define motorPin4  11     // IN4 on the ULN2003 driver
// Define the AccelStepper interface type; 4 wire motor in half step mode:
#define MotorInterfaceType 8
// Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper library with 28BYJ-48 stepper motor:
AccelStepper stepper = AccelStepper(MotorInterfaceType, motorPin1, motorPin3, motorPin2, motorPin4);
void setup() {
  // Set the maximum steps per second:
  stepper.setMaxSpeed(1500);
  // Set the maximum acceleration in steps per second^2:
  stepper.setAcceleration(500);
}
void loop() {
  // Set target position:
  stepper.moveTo(65536);
  // Run to position with set speed and acceleration:
  stepper.runToPosition();
  
  delay(1000);
  
  // Move back to original position:
  stepper.moveTo(0);
  // Run to position with set speed and acceleration:
  stepper.runToPosition();
  
  delay(1000);
}

ngermani99:
The motor is 5v and im powering with a USB.

That doesn't sound good, I doubt that the motor's getting enough current.

1 Like

wildbill:
That doesn't sound good, I doubt that the motor's getting enough current.

I wired the driver using a USB phone charger. It's 5v 1A.

Using my PC to power up the motor give me a top speed, using the charger gave me more, so still stucking from max speed. I suppose this kinda of motor do not get faster than certain steps?

I kind of had the same problem and found an easy solution.
How are the pins from your Arduino connected to the stepper driver? I guess you´re using a ULN2003 board?

ngermani99:
I wired the driver using a USB phone charger. It's 5v 1A.

Using my PC to power up the motor give me a top speed, using the charger gave me more, so still stucking from max speed. I suppose this kinda of motor do not get faster than certain steps?

Use the power supply in any case! You could easily destroy your PCs USB port. Happened to me twice...

dodoka:
I kind of had the same problem and found an easy solution.
How are the pins from your Arduino connected to the stepper driver? I guess you´re using a ULN2003 board?

Yes, they sold me a new one ULN2003a, blue one.

I wired 1,2,3&4 to arduino's 8,9,10,11

What did you do in order to gain more speed?

I'ts like setting speed al 1000 it's okey but using 1100 parameter stuck the motor.

ngermani99:
I wired 1,2,3&4 to arduino's 8,9,10,11

In this order?
If yes, then switch 2 and 3. That did the job for me :slight_smile:

So

1N1 to Pin 8
1N2 to Pin 10
1N3 to Pin 9
1N4 to Pin 11

And I used the normal Stepper.h library.

dodoka:
In this order?
If yes, then switch 2 and 3. That did the job for me :slight_smile:

So

1N1 to Pin 8
1N2 to Pin 10
1N3 to Pin 9
1N4 to Pin 11

And I used the normal Stepper.h library.

I tried this, it's not this issue. Using my code with the order I said it's working fine. It is true that with the stepper library changing the order of wires works okey. But still do not get me more speed than certain limit. I may have to change to nema 17 motor step

dodoka:
then switch 2 and 3.

OP did wire it in sequence 8, 9, 10, 11 :

// Motor pin definitions:
#define motorPin1  8      // IN1 on the ULN2003 driver
#define motorPin2  9      // IN2 on the ULN2003 driver
#define motorPin3  10     // IN3 on the ULN2003 driver
#define motorPin4  11     // IN4 on the ULN2003 driver

.... but the Accelstepper initialisation is 1,3,2 4 so actually 8, 10, 9, 11:

AccelStepper stepper = AccelStepper(MotorInterfaceType, motorPin1, motorPin3, motorPin2, motorPin4);

FEBaily:
OP did wire it in sequence 8, 9, 10, 11 :
.... but the Accelstepper initialisation is 1,3,2 4 so actually 8, 10, 9, 11:

Exactly

It's all in order, just want to gain speed. It's like the limits it's 1 revolution per 3 sec, I want to go faster with this motor like 2 sec instead of 3 sec.

Someone knows if it's possible?

FEBaily:
OP did wire it in sequence 8, 9, 10, 11

That´s not wiring, that´s a code :wink: Also that´s why I asked. For me I had to switch 9 and 10.

It worked fine the other way around too, but only to a certain speed. Then it just didn´t move.

I looked into my code and I also can´t make it go faster than 15.

I guess it´s not the right motor for high speeds...

ngermani99:
just want to gain speed.

Someone knows if it's possible?

Says here:

42 bots:
it offers decent torque for its size at speeds of about 15 rotations per minute (RPM). With some software “trickery” to accelerate gradually and a higher voltage power source (I tested them with 12 volts DC) I was able to get about 25+ RPM.

So if you're prepared to trust that blog, crank the voltitude up a bit.

FEBaily:
Says here:

So if you're prepared to trust that blog, crank the voltitude up a bit.

I think it works fine, still not getting the speed I imagine.

Thanks for it

Any other suggestions? Is it possible to code something to crack up this issue?