5V 28BYJ-48 stepper + a4988 stepper driver

Hi!

I am trying to drive a 5V 28BYJ-48 stepper with a a4988 stepper driver.

I would like to first mention that I am succesfully driving a 42BYGH34-0400A (nema 17 type) with the a4988 with no problems.

I saw an article of someone who explains how to drive a 12V 28BYJ-48 with an a4988, so I though well, then I can connect my 5V 28BYJ-48, change the power supply from 12 volts to 5 volts and that is pretty much it. The 5V 28BYJ-48 has 5 cables instead of 4, and in this article they connect the 4 cables for the 2 coils, leaving the ground disconnected.

As I got the 28BYJ-48 with some uln2003 stepper driver, for the cable order I simply followed the order in which they ‚Äúshould‚ÄĚ be connected to the uln2003.

Well, it is not working. I can feel something going on inside of the stepper when I touch it, like a periodical step and the tipical chickimiki chickimiki sounds of the stepper, but it doesnt turn as it should. I am guessing, it is either the power supply, the cable order, or the fact that the ground is disconnected, but I am very new in steppers, so I really dont know. General wiring should be correct because, as I said, I run the nema 17 like motor flawless.

General wiring available at the driver¬īs website.

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 = 10UL;  // fiddle with this to control the speed

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); 
}

looking forward for new insights!

camilozk:
leaving the ground disconnected.

  1. things don't work without a ground to return path voltage and current.

It's not the ground, it's a center tap on the coils which are used for micro steps - it should be the red wire.

  1. Please provide a picture or schematic...

If you're trying to do something in a tutorial perhaps something isn't wired up correctly.

The specification for rhe A4988 states that the minimum motor supply voltage is 8 Volts. I know from experience that they will not work with 5V motors supply. Supply the driver with 12V (or > 8V) and make sure to set the coil current limit (Vref) to a value appropriate to the stepper motor. For steppers using that type of driver the voltage is not as relevant, it is the coil current that matters.

If you use a 5V 28BYJ-48 motor as a bipolar stepper motor (regardless of whether you cut the center tap connection as described here) it will be fine to run it on 12V.

After all, you have two 5V windings in series, and the bit extra won't hurt.

Thank you people for sharing your knowledge.

  1. things don't work without a ground to return path voltage and current.

It's not the ground, it's a center tap on the coils which are used for micro steps - it should be the red wire.

Of course... and yes indeed, it is the red wire. It is clear now.

The specification for rhe A4988 states that the minimum motor supply voltage is 8 Volts.

This information is very clear on the website of the driver, and I totally overlooked it. I also (should) know by now that current is what matters for steppers. Fixing knowledge right now.

Everything is working nice and smooth right now.

thanks also jremington for the link!

:slight_smile:

jremington:
If you use a 5V 28BYJ-48 motor as a bipolar stepper motor (regardless of whether you cut the center tap connection as described here) it will be fine to run it on 12V.

After all, you have two 5V windings in series, and the bit extra won't hurt.

There is something I do not fully understand about those instructions. Do I simply ignore the red cable, or I also need to scratch the copper track as it is mentioned there to convert the stepper into a bipolar motor?

Just ignore it

I am comparing the ‚Äúsmoothness‚ÄĚ of the 28BYJ-48 stepper driven by the uln2003 with a code written with patterns, and by the dvr8825 with a code working on 1/32 microstepping. I somehow expected to see it spinning much smoother with the dvr8825, but I actually dont perceive a great difference, and I fail to understand why.

I copy here both codes in case someone can check them out and understand why there are no big differences between them in regards of how smooth (resolution of the steps) they are.

uln2003

const int in1 = 2; 
const int in2 = 3; 
const int in3 = 4; 
const int in4 = 5; 

unsigned long motorDelay = 120UL;  // fiddle with this to control the speed

byte patterns[8] = {
  0b00001000,
  0b00001100,
  0b00000100,
  0b00000110,
  0b00000010,
  0b00000011,
  0b00000001,
  0b00001001,
};

void setup() {
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
}

void loop() {
  for (int i = 0; i < 8; i++) {
    digitalWrite(in1, bitRead(patterns[i], 0));
    digitalWrite(in2, bitRead(patterns[i], 1));
    digitalWrite(in3, bitRead(patterns[i], 2));
    digitalWrite(in4, bitRead(patterns[i], 3));
    delay(motorDelay);    
  }
}

dvr8825

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

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

unsigned long motorDelay = 4UL;  // fiddle with this to control the speed

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); 
}

Stepper motors are not designed to be smooth. They’re designed for torque at the steps to give holding power and to have steps where they can stop relatively accurately.

wolframore:
Stepper motors are not designed to be smooth. They’re designed for torque at the steps to give holding power and to have steps where they can stop relatively accurately.

good. anyway, I need to compare and choose one of the two systems for my application, and I need help to do so because the two systems work in different ways, which are beyond my grasp.

It also wouldnt be the first time we use something for an application for which it is not designed for. I am using stepper motors to turn (as smooth as possible, meaning with the higher steps resolution achievable) big acrylic discs, and I need the torque of steppers to do so.

You can use gear reduction for torque. Servos can get more expensive (especially sized up) but they are smoother.

Could you explain what you're doing?

I saw the planetary gear boxes for nema 17 like steppers, and of course they look like a great solution, but expensive (50‚ā¨ per piece at leats) + rather bulky in comparison.

I am spinning acrylic discs, some very small, some pretty large (4cm up to 100cm) vertically. The schaft is glued to the acrylic disc with Uhu Endfest 300. I need the rotation to be slow, almost imperceptible, and the steps to be also small, if possible, imperceptible as well.

As I posted in #7, these 2 codes spin the same motor with different drivers, and I was expecting more steps resolution with the dvr8825 than with the uln2003, but somehow I dont see a great difference, and I would like to understand why, or if I am doing something wrong and I actually should have a much better resolution with dvr8825 than what I currently see.

Gear reduction can be done with pullys and basically rubber bands for next to nothing... take apart old printers and tape (beta, cassette... otherwise) for things like that.

Stepper is the wrong motor for your application IMHO. you can reduce the speed and raise torque using tiny cheap dc motors.

Is there a reason why you need the arduino involved? Does it stop and do other things? patterns or such?

This is the beginning of a series of experiments in which I want to:

-know the exact position of the motor
-synchronise 2 or more motors
-control the speed and direction of the motor in different ways, such as potentiometers

That is why I would like to continue playing with steppers.

The results that I achieved so far in regards of speed and smoothness, are very close to what I need for my project. Now, my question in #7 remains.

You are using delay() for timing. That is not perfectly consistent. You are also trying to delay 4 milliseconds, so expect up to +/-1 error, or worse than 25%.

Switch to AccelStepper (which uses microseconds internally) and try again.

MorganS:
You are using delay() for timing. That is not perfectly consistent. You are also trying to delay 4 milliseconds, so expect up to +/-1 error, or worse than 25%.

Switch to AccelStepper (which uses microseconds internally) and try again.

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?

What happened when you tried it?

I didnt.

I didnt have time to figure out how to apply this library to my set up with dvr8825 driver. I am not quite sure how to do it and before jumping into this I would like to understand why are you suggesting this.

Because AccelStepper is able to time small increments in microseconds, not milliseconds.

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.

Because AccelStepper is able to use acceleration to smoothly bring your stepper up to a rotation speed that's unreachable with your current code.

There was this that showed up recently:
Smooth move from cheap motors