28BYJ-48 stepper motor issues

i have an arduino uno with 2 stepper motors attached each have thier own ULN2003 motor drivers, powered by an external 5 volt power supply, below is the sketch I am running

#include <Stepper.h>

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

// initialize the stepper library on pins 8 through 11:
Stepper myStepper1(stepsPerRevolution, 9, 8, 10, 11); // 1, 2, 3, 4
Stepper myStepper2(stepsPerRevolution, 4, 5, 6, 7); // 1, 3, 2, 4

void setup() {
  // set the speed at 60 rpm:
  myStepper1.setSpeed(60);
   myStepper2.setSpeed(60);
 

}

void loop() {

  myStepper1.step(stepsPerRevolution);
delay(500);
 myStepper1.step(-stepsPerRevolution);
delay(500);


  myStepper2.step(stepsPerRevolution);
delay(500);
  myStepper2.step(-stepsPerRevolution);
delay(500);
}

when i run the sketch myStepper2 works fine, but myStepper1 moves in a very sporadic manner, and has very little torque, I have tried using different stepper motors and ULN2003 drivers (I have many spares) some of the other steppers dont move at all and others move very little.

I have also played around with the stepsPerRevolution value, i found 220 worked best but its still moving sporadically with very little torque, however the LED display on the ULN2003 is working correctly. I have noticed when i look at both of my stepper motors is that the pink and blue wire coming out of the actual stepper motor (myStepper1) are in the reverse of what they are on myStepper2, so i have cut the wires on myStepper1 and hooked them up in a way that i believe should make both steppers the same like in the image below.

I also tried switching the digital pins around, but none of this worked, any help would be met with my gratitude, and i thank you for reading this :slight_smile:

(mod edit)

The 28BYJ-48 motor has 2048 steps per revolution of the output shaft. The steps per revolution value is needed to work out the interval between steps that matches the speed you choose.

The line

  myStepper1.step(stepsPerRevolution);

does not have to use the stepsPerRevolution variable. It can be any number of steps. Normally, if you do use the stepsPerRevolution value the motor will cause the output shaft to make one full revolution.

When you have problems with a stepper motor it is always a good idea to try a much lower speed.

Apart from those comments I can't see any problem with your program.

...R

Robin2: The 28BYJ-48 motor has 2048 steps per revolution of the output shaft. The steps per revolution value is needed to work out the interval between steps that matches the speed you choose.

The line

  myStepper1.step(stepsPerRevolution);

does not have to use the stepsPerRevolution variable. It can be any number of steps. Normally, if you do use the stepsPerRevolution value the motor will cause the output shaft to make one full revolution.

When you have problems with a stepper motor it is always a good idea to try a much lower speed.

Apart from those comments I can't see any problem with your program.

...R

Thank you for your response :) when i posted this i had both steppers on .setSpeed(60); i have tried lowering them to 40, and then 30 and for those two myStepper1 didnt really move at all, it always buzzes and tries to turn but it only turns on speed 60, and even then its very sporadic will little torque.

did you see my picture of where i had to switch the two wires on the stepper motor? do you think all of that looks correct? i put it next to the other servo so people could see what i mean about the blue and pink wires being reversed.

Many of those cheap stepper may have what might be considered "wrong" wiring. The only way to be sure is to use a DMM to measure coil resistances.

Randomly swapping wires may just add confusion to an issue. If you dont have a DMM there are lost of cheap ones available that are almost all up to this task.

Also use heat shrink to cover those soldered wires before they become an accident that could fry something.

ballscrewbob: Many of those cheap stepper may have what might be considered "wrong" wiring. The only way to be sure is to use a DMM to measure coil resistances.

Can't do that with a 5-wire motor though, all the windings are the same.

Trial and error is needed, taking care to power down before moving any connections to avoid damage due to inductive spikes. Connections must be reliable for the same reason, croc-clips are a bid dodgy and it would be all too easy to fry the driver fiddling with them.

Normally these motors come with a driver all connected up, so you only need to swap the logic level wiring which doesn't have the inductive spike issue.

MarkT: Can't do that with a 5-wire motor though, all the windings are the same.

True but in the case of the cheapo 28BYJ-48 then less so.