28BYJ-48 & uln2003 - stepper as slow as possible

ey!

I am using a 28BYJ-48 stepper connected to a uln2003 stepper driver and an arduino uno.

I would like to have it turning pretty slow, if possible without seeing the steps, and I have seen in a video (28BYJ-48 stepper motor and ULN2003 Arduino (Quick tutorial for beginners) - YouTube) where it is said that it is possible to do microstepping with this stepper, reaching 2048 steps/rev, but I havent found information on how to do that. I have seen in Stepper Motor Basics that A4988 can make the motor move in 1/16th steps. Is that also possible with uln2003?

Somebody could guide me on this?

This is the code as it have it so far:

#define STEPPER_PIN_1 8
#define STEPPER_PIN_2 9
#define STEPPER_PIN_3 10
#define STEPPER_PIN_4 11

int stepdelay = 50;

void setup() {
pinMode(STEPPER_PIN_1, OUTPUT);
pinMode(STEPPER_PIN_2, OUTPUT);
pinMode(STEPPER_PIN_3, OUTPUT);
pinMode(STEPPER_PIN_4, OUTPUT);
}

void loop() { 
  digitalWrite(STEPPER_PIN_1, HIGH);
  digitalWrite(STEPPER_PIN_2, LOW);
  digitalWrite(STEPPER_PIN_3, LOW);
  digitalWrite(STEPPER_PIN_4, LOW);
  delay(stepdelay);
  digitalWrite(STEPPER_PIN_1, LOW);
  digitalWrite(STEPPER_PIN_2, HIGH);
  digitalWrite(STEPPER_PIN_3, LOW);
  digitalWrite(STEPPER_PIN_4, LOW);
  delay(stepdelay);
  digitalWrite(STEPPER_PIN_1, LOW);
  digitalWrite(STEPPER_PIN_2, LOW);
  digitalWrite(STEPPER_PIN_3, HIGH);
  digitalWrite(STEPPER_PIN_4, LOW);
  delay(stepdelay);
  digitalWrite(STEPPER_PIN_1, LOW);
  digitalWrite(STEPPER_PIN_2, LOW);
  digitalWrite(STEPPER_PIN_3, LOW);
  digitalWrite(STEPPER_PIN_4, HIGH);
  delay(stepdelay);
}

Just in case of doubt I am not expert on the 28BYJ stepper motors - or, perhaps more accurately, I know even less about them than about bipolar motors :slight_smile:

...R

Slow steps are not a problem, you only have to adjust stepdelay as desired.

ULN2003 is hardly usable as a stepper driver, and microsteps definitely require specialiced driver hardware. You should consult the motor data sheet and select a suitable power supply and stepper driver module.

Since you have DRV8825 drivers on the way for the other stepper, I Googled "28BYJ-48 stepper and drv8825" and found many pages on using the DRV8825 driver with the 28BYJ-48 stepper.

camilozk:
ey!

I am using a 28BYJ-48 stepper connected to a uln2003 stepper driver and an arduino uno.
. I have seen in Stepper Motor Basics that A4988 can make the motor move in 1/16th steps. Is that also possible with uln2003?

S

no. the ULN2003 is a pack of transistors.
there is no feedback to be able to automatically set them for micro-stepping.

camilozk:
ey!

I am using a 28BYJ-48 stepper connected to a uln2003 stepper driver and an arduino uno.

I would like to have it turning pretty slow, if possible without seeing the steps,

this motor is connected to a gearbox so that the motor movement is greatly reduced.
have you tried the motor with the ULN2003 ?
the output shaft has 4,096 steps when you use the ULN2003
I suspect that it would be very hard to see a step based on the amount of gearing.

Slow steps are not a problem, you only have to adjust stepdelay as desired.

slowsteps are not the question. The speed of the steps are not the question, but how big these steps are. That is why I would like to know how to do microsteps with this hardware

have you tried the motor with the ULN2003?

yes I have, as this is the topic of the thread. I have seen a video where it says that this stepper has 2048 steps when microstepping, that is why I would like to achieve microstepping. I haven´t found no information on its 4096 steps ability. And I can definitely see the steps.

So, for the information shared in this thread, I conclude that ULN2003 is not microstepping capable.

I will then try DRV8825, A3967 and A4988...

28BYJ-48s are a really cool motor - you can run it as a unipolar, or without modification, as a bipolar motor. So if you have a 2003 or whatever darlington array driver, it'll work, don't worry. Here's some old code I used back in the day - 2015 or so, that used 8 patterns per step, so 8x64 or 1024 steps per revolution:

// 28BYJ-48, using an NTE2019 darlington (similar to uln2003) driver
//   Blue   - 28BYJ48 pin 1 <-- 2019 <-- arduino pin 8
//   Pink   - 28BYJ48 pin 2 <-- 2019 <-- arduino pin 9
//   Yellow - 28BYJ48 pin 3 <-- 2019 <-- arduino pin 10
//   Orange - 28BYJ48 pin 4 <-- 2019 <-- arduino pin 11
//   Red    - 28BYJ48 pin 5 <-- vcc

long motorDelay = 1200L;  // fiddle with this to control the speed

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

void setup() {
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
}

void loop() {
  for (int i = 0; i < 8; i++) {
    digitalWrite(8, bitRead(patterns[i], 0));
    digitalWrite(9, bitRead(patterns[i], 1));
    digitalWrite(10, bitRead(patterns[i], 2));
    digitalWrite(11, bitRead(patterns[i], 3));
    delayMicroseconds(motorDelay);
  }
}

Using code expanded from this, and some Lego gears and rollers, I was able to spin it pretty slowly. In this movie, my 28byj48 turns a globe to exactly match the Earth's rotation using a cheap NTE2019 driver chip (which yes, is a pack of transistors.)

There is a difference between the motor number of steps per Revolution and the output shaft number of steps per Revolution if your stepper motor has a gear Drive then you may wind up having a much lower output rotation compared to motor rotation

Here's some old code I used back in the day...

Thank you so much for this @ChrisTenone. This is already much better than what I was currently testing! I still would love to go slower and smoother. The slower that I was able to go was:

long motorDelay = 16000;

Further than this, 17000 for example it doesnt turn at all but it sounds like operating, and with 18000 is turning very fast! why does this happen?

Today I am going to test A3967 and A4988

As I have no experience on this, every comment is appreciated!

Further than this, 17000 for example it doesnt turn at all but it sounds like operating, and with 18000 is turning very fast! why does this happen?

Look up the limitations of delayMicroseconds().

thanks!

Times should be unsigned long, e.g.

unsigned long motorDelay = 17000UL;

Times should be unsigned long

why?

camilozk:
The slower that I was able to go was:

long motorDelay = 16000L;

I have changed delayMicroseconds(motorDelay); for delay(motorDelay) to be able to go much slower.

camilozk:
why?

Because else constants and computations are limited to smaller values. The value 17000 cannot be represented as a signed 16 bit value.

camilozk:
slowsteps are not the question. The speed of the steps are not the question, but how big these steps are. That is why I would like to know how to do microsteps with this hardware

there are natural steps. these are the balance of magnetic forces and are a fundamental psychical world balance.
There are contrived steps, a balance of created magnetic forces. ie: microsteps.

When you remove power, the contrived steps vanish and the natural steps balance the rotor in the magnetic fields.
This will effectively eliminate any quantity of assumed contrived steps. This requires a re-zero after the loss of power.

The concept of micro-stepping is to make the lower speeds a smoother motion instead of the cogging you would get with a stepper.

As you slow the motor by creating long pauses between micro-steps, you may run the risk that the forces on the driven thing are stronger than the forces of the contrived steps. In most applications, there is momentum and part of the force is the flywheel effect of the device being driven (load) and rotor.

What you are essentially doing is removing the flywheel effect.

That said, whatever you are driving may be well under the forces needed to rotate, so, it might be a perfectly acceptable application of the motor.

Just wanted to point this bit out because as you slow things down, you are moving from a function that most are familiar with into a realm of the un-familiar. And as we all know, odd things just seem to happen for no reason. If you just loose any movement when you start to micro-step, you might look at the forces generated by micro-steps as compared to forces needed to drive your thing. It is a function of near magnetic fields (natural steps) where the forces are highest and near-by magnetic fields where the forces drop drastically.

if your movement seems to get smoother, then as you try to slow it down more, it just starts cogging and gets more jumpy, move back towards full steps. Full steps are the strongest power from the motor, then half, then quarter, you get the idea.

It is interesting to watch the thread and as it has developed, your actual goal has come to light.
paraphrasing, you are looking to rotate in a near-imperceptible motion, breaking down the rotation of the drive into as small a rotation as possible.

Please keep us informed as your testing progresses.

Thank you very much for your analisys @dave-in-nj

It is also very interesting to see things when other people share their knowledge and point of view.

I have another thread open (advice motors - Project Guidance - Arduino Forum) where I am testing different stepper drivers to achieve my goal, which is indeed rotate in a near-imperceptible motion. This will still take some weeks since some drivers on the post as we speak, but nevertheless I will update my results.

Also, and very importantly, so far I have been testing motors and drivers without a load. The load will be an acrylic disc, sometimes small, sometimes pretty big, and I am very curious how the whole system will react to different circumstances.

thanks again for all input!

the value 17000 cannot be represented as a signed 16 bit value.

It can indeed. The maximum positive value for signed 16 bit is 32767.

But that is not the problem with the OP's original sketch.

According to the official documentation, delayMicroseconds() is limited to the maximum value of 16383.

If you want to get to near insane steps per revolution, do what the telescope folks do.
use a worm gear and a large gear.
a 6 inch dia gear with a worm of 1/2"=20 thread (fine US thread) will have a circumference of about 18.8 inches. 20 threads per inch about 375 threads on the circumference.

200 steps per motor revolution times 375 rotations of the worm, you get 75,000 steps per revolution

If you use a proper stepper driver like the old L298 in full step mode, figure a high RPM for a stepper is 750 RPM.
Take over an hour and a half for one revolution.
if you half-step, double that. 150,000 steps per revolution....

if you get a micro-stepper, in 8 step mode, you are closer to 600,000 steps per revolution.

now, if you go that route, you have a whole different problem. Your problem now becomes getting a full rotation in an hour because the motor is not fast enough.

if you want to keep going, get a gear box on the stepper...
Amazon shows one that is a 51:1 ratio, so multiple 150,000 times 51 (full step mode) or a bit more for microstepping.

150,000 full steps, * 8 mciro steps * 51:1 gear box, 61 million.

these numbers seem so krazy high, you might want to check my math.

As a note, you only use microsteping for lower speeds. once you get into the higher speeds, you would be better off to go to full stepping.

====

375 teeth on the circumference of a 6 inch dia (18.8 inch circumference)
375 rotations of the worm gear, * 200 fullsteps per rotation
375 * 200 = 75,000 steps per final gear revolution.
x2 if you half step with a proper stepper driver like the L298
x8 if you 8th step with a micro-stepper driver