5V 28BYJ-48 stepper + a4988 stepper driver

MorganS:
Because AccelStepper is just as easy to set up as your current example code: just load up one of the examples and change the pin numbers to the actual pins you connected the driver to.

Dear MorganS.

I fail to see it as straight forward as you see it. It is probably my unexperienced eye that doesnt allow me to modify the code as simply as you state it is.

In my code I am not using 4 pins for each of the 4 cables of the stepper, because the stepper is not connected to the arduino, but to the dvr8825, and the connections required by the dvr8825 are just 2 pins: direction and step, besides the 3 pins that I am using to set the microsteps in use. In my case, 1/32 steps.

I really do not know how to adapt my code to include the accelstepper library, and I would of course really appreciate a bit more guidance on the issue. My code follows:

const int M0 = 3; 
const int M1 = 4;
const int M2 = 5;

const int stepPin = 6; 
const int dirPin = 7; 

unsigned long motorDelay = 4UL;

void setup() {
  pinMode(stepPin,OUTPUT); 
  pinMode(dirPin,OUTPUT);
  
  pinMode(M0,OUTPUT);
  pinMode(M1,OUTPUT);
  pinMode(M2,OUTPUT);    

  digitalWrite(M0,HIGH); 
  digitalWrite(M1,HIGH); 
  digitalWrite(M2,HIGH); 
}

void loop() {
  digitalWrite(dirPin,HIGH);
  
  digitalWrite(stepPin,HIGH); 
  delay(motorDelay); 
  digitalWrite(stepPin,LOW); 
  delay(motorDelay); 
}

Today I managed to apply the accelstepper library to my code.

const int M0 = 3; 
const int M1 = 4;
const int M2 = 5;

const int stepPin = 6; 
const int dirPin = 7; 

#include <AccelStepper.h>

AccelStepper stepper(AccelStepper::DRIVER, stepPin, dirPin);

void setup() {
  pinMode(M0,OUTPUT);
  pinMode(M1,OUTPUT);
  pinMode(M2,OUTPUT);    

  digitalWrite(M0,HIGH); 
  digitalWrite(M1,HIGH); 
  digitalWrite(M2,HIGH);   
   
  stepper.setMaxSpeed(20);
  stepper.setSpeed(20);	
}

void loop() {  
  stepper.runSpeed();
}

I dont see any significant improvement in the way my steppers spin after applying accelstepper on this application.

The 5V 28BYJ-48 is still rather clumsy while rotating. I have been trying to adjust the potentiometer of the dvr8825 for it to spin as regular as possible, but I always see (and also hear) that there is a step out of 4 that is stronger than the others (clac clic clic clic clac clic clic clic), and it is not working out for me.

As a test, I went back to connect my Nema 17 stepper (42BYGH34-0400A) and I have to say that it runs much better than the previous one, for which I have to conclude that 28BYJ-48 are really rather bad in quality, at least if you need regular and equally strong steps.

Was trolling the internet to troubleshoot a similar problem... running a 12V 28BYJ-48 stepper with an a4988 stepstick driver. Saw that this post didn't necessarily have an adequate solution and was semi-recently posted, so figured I'd throw in my two cents for what it's worth.

Facts:

  • The 28BYJ-48 is not broken out on it's header connector correctly (ignoring the red wire entirely) to be connected one for one to an a4988 stepstick driver.
  • The specs state that an a4988 needs > 9V power supply for your motor, may not run at 5V.
  • You definitely do not need to disconnect the 28BYJ-48 red wire to run it in bipolar stepper mode.
  • You need to dial the potentiometer back on the a4988 to restrict it's current flow. I have mine set to 0.10V (I set this value by turning the potentiometer counterclockwise a little at a time, taking intermittent voltage readings-- stopping here because going much lower might under-power the stepper). Although, it didn't blow the a4988 or 12V stepper even when I had it at 0.50-0.60V, this could however prove dangerous if run for too long at this setting.

Speculations:

  • Steppers that chitter-chatter or are jittery, as you described, may be slightly mis-wired.
  • Your's are very likely mis-wired, mine were. It seems strange to think mis-wired, since the motor is afterall spinning. I especially suspect this error, because a regular nema motor ran fine for you.

Correct Wiring for a 28BYJ-48 stepper for a4988 bipolar mode:

  • Ignore the red wire. You do not need to disconnect it internally.
  • The pink and yellow wires need to be crossed over.
  • The correct order of 28BYJ-48 wires pinned for stepstick use is blue, yellow, pink, and then orange; or vice versa.

28BYJ-48 to a4988:
Red wire= not connected
Orange= 1B
Yellow= 2A
Pink= 1A
Blue= 2B

Basically, the pink and yellow wires need to be crossed over. I have done this by re-wiring with jumpers, by simply crossing the pink and yellow jumper positions with each other, because I needed the extra length in my application. Also, the 28BYJ-48's white connector could be rewired instead by popping out and switching the locations of the yellow and pink wires, permanently mapping it for compatibility with the a4988, at the expense of it no longer being direct pluggable for uln2003 unipolar stepper control.

1 Like

camilozk:
thanks for suggestion. are you proposing that this is the reason why I am not getting the results that I expect, or is this a side note?

It's nothing to do with the settings it's the 5th red wire is a common you need to take the back cover off and split the link on the board between the red wires terminal and the motors terminal. Basicly there are 2 coils in the motor the same as a nema 17 but the red common wire connects to the center of both coils so it can act as 4 single sided coils if you split the like where I said the motor will basicly have the same wiring as a normal nema 17 and will work perfectly once you have the 2 coils wired in the correct order