28BYJ-48 5-Volt Stepper

OK, got it. probably had to do with the pin definition

// accellsteppertest.ino
// Runs two steppers forwards and backwards, accelerating and decelerating
// at the limits. Derived from example code by Mike McCauley
// modified by Celem for single stepper
// Set for two 28BYJ-48 stepper motors

#include <AccelStepper.h>

#define FULLSTEP 4
#define HALFSTEP 8

//declare variables for the motor pins
int motorPin1 = 4;	// Blue   - 28BYJ48 pin 1
int motorPin2 = 5;	// Pink   - 28BYJ48 pin 2
int motorPin3 = 6;	// Yellow - 28BYJ48 pin 3
int motorPin4 = 7;	// Orange - 28BYJ48 pin 4
                        // Red    - 28BYJ48 pin 5 (VCC)
int motorPin5 = 8;	// Blue   - 28BYJ48 pin 1
int motorPin6 = 9;	// Pink   - 28BYJ48 pin 2
int motorPin7 = 10;	// Yellow - 28BYJ48 pin 3
int motorPin8 = 11;	// Orange - 28BYJ48 pin 4
                        // Red    - 28BYJ48 pin 5 (VCC)
// The sequence 1-3-2-4 required for proper sequencing of 28BYJ48
AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
AccelStepper stepper2(HALFSTEP, motorPin5, motorPin7, motorPin6, motorPin8);

void setup()
{ 
  stepper1.setMaxSpeed(1000.0);
  stepper1.setAcceleration(50.0);
  stepper1.setSpeed(200);
  stepper1.moveTo(2048);   
  
  stepper2.setMaxSpeed(1000.0);
  stepper2.setAcceleration(50.0);
  stepper2.setSpeed(200);
  stepper2.moveTo(2048);
}

void loop()
{
  //Change direction at the limits
  if (stepper1.distanceToGo() == 0) 
    stepper1.moveTo(-stepper1.currentPosition());
    if (stepper2.distanceToGo() == 0) 
    stepper2.moveTo(-stepper2.currentPosition());
  
  stepper1.run();
  stepper2.run();
}

Hi,

I'm a fresh beginner.
Could someone post pictures of the built circuit so I can learn how to read the diagram ?

Thanks!

sharonf
pls check the first page of this thread.

Doom, I mean a "real" picture of the arduino and the wires, not the circuit sketch

Sharonf, you can see a video of a "real" functioning 28BYJ-48 5-Volt Stepper circuit on YouTube - at Stepper driven by Arduino Mini Pro - YouTube

If you pause the video you'll be able to see the wiring. It is using an Arduino NANO

celem:
Sharonf, you can see a video of a "real" functioning 28BYJ-48 5-Volt Stepper circuit on YouTube - at Stepper driven by Arduino Mini Pro - YouTube

If you pause the video you'll be able to see the wiring. It is using an Arduino NANO

Thanks,
What is the additional board at the end of the prototype bread board?

A breadboard power supply. The stepper draws too much current to run from the USB port. The power supply was purchased over eBay and is similar to these:

Is there Anybody out there... there... there...

Yes, I am out here, and I am a newbie reading every little bit of information like a new born puppie having its first drink of milk from its mommies nipple. That is about the best way I have of describing my experience with Arduino.
I have the Arduino Uno, the 2003 driver board and the 28BYJ-48-5 motor. I have played with the Uno board and have suceeded in getting the "Blink" command to work. I have tried a previous set up to get the motor to do its thing but so far a "Fail"..
I have just received a second new motor and 2003 board, and I am about to go to my basement work area and start a new fresh approach to the problem.
My aim to have the Uno control a stepper motor to drive a dividing head for my Unimat lathe. I would like to direct you to a "YouTube" video by Chuck Fellows : Infra Red Remote Controlled Arduino Dividing Head - YouTube is what I am aiming to do.
I will be back. I just wanted you to know I was taking in all the good information.
Harvey,
in Kelowna, BC.

Maybe you could upload a picture of the wiring you did for the stepper + arduino, and the code you used?
I got it to work with some effort

I had Chuck look at the wiring. He thought I had one set of wires backwards. I have taken that set up apart and I am starting all over. I'll see how far I get tonight.

Note reference to: "Celem" December 31, 2011, 11:46:27 AM »

I have copied and pasted the code from your messgae. Thanks very much. Now, I am new, new, new,to Arduino and the "codes" ..I am using the 28BYJ-48-5VDC Gear Stepper Motor with ULN2003 Driver Board. So just to let you know why I put in three new's my first project was to download the "BLINK" code, and completed that succesfully. Now I have set up the Arduino Uno, with this little motor and driver, downloaded the code from your posting, and woopy it also works. So now Grampa has two attempts that have worked.

I sort of understand the concept of the clockwise and the C/clockwise, but I have no clue as to where to go into the code to edit it. My motor is turning at just under 1 rpm. Where do I go to adjust the speed, and direction. Thanks for your help.
Harvey
in Kelowna BC.

If you are using the code in my December 31, 2011 post the variable "motorSpeed" controls the speed since it is used for the "delay" value between steps.
If your goal is to increase speed, remember that this stepper is geared down with a 1:64 ratio - so it will never spin very fast. That said, it can be improved with a different library - see my post of January 17, 2012, 10:14:20 AM - try the AccelStepper library mentioned there. The VIDEO at that post shows the AccelStepper in use - your stepper should turn at least this fast.

The AccelStepper Library has speed() and runSpeedToPosition() functions that may give you what you want. While the AccelStepper Library supports a maximum stepping speed to about 4kHz, the 28YJ-48 supports a maximum no-load step rate of 900pps (less that 1kHz).

The 28BYJ-48 has a step angle of 5.625°/64. Therefore, one full rotation requires 4,096 steps. At 900pps (with simultaneous port writes as mentioned in the post of Reply #19 on: January 14, 2012, 10:17:55 AM) the maximum rotation speed computes to 13rpm (unless my math was wrong) - (900/((360/5.625)*64))*60. However, look back in this thread and you'll see that sbright33 says that he can achieve 35rpm. I don't see how this is possible but that is what he says. Please note, however, that he is running the stepper with 12VDC and he has to de-power it when idle to avoid overheating, so he is driving the stepper very hard.

As to speed, remember that this stepper was designed to move the vents on air conditioners, that are popular in Asia, with a goal of high torque not high speed.

Good luck with your experiments.

What he said. Seriously. My code does support acceleration in many of the functions so you can achieve the results in AccelStepper library without any effort. Even using 5v. 12v is capable of going much faster with the only difficulty that celem mentioned.

sbright33 - re "What he said. Seriously." No offence intended - your library and the empirical research behind it are commendable and it is just that your RPMs exceed the factory specifications and my personal experience. I have never tried running that stepper on 12V nor the resistors and capacitors. Maybe I'll try it when the time is available (if I can dig up a suitable 12V PS). I do have copies of your step1a.pde and step1p1dps.pde. Is there another version that I should try instead?

Here is the newest version for 28BYJ-48.

12v is reliable, you just have to mind the heat. This means you cannot run at full speed for 20 minutes. You can go slow forever using the "cool" functions. Or go full speed then stop to let it cool down.

Reply #74 on: March 13, 2013, 06:13:49 AM

Thanks very much for the information. I have a very big learning process ahead of me. I have bookmarked serveral of your suggestions so I can come back to them as required.

Hello,

I've been doing some tests with this motor and I found that it misses some steps in two situations:

  1. If you use speeds higher than 14 RPM;
  2. If you change the direction frequently.

Case 1 seems normal. It must have a limit when the motor can't rotate fast enough to follow the signals.

Case 2 is something more strange. I created a small sketch where the motor turns an angle based in the value of a potentiometer. The noise in the readings of the potentiometer makes the motor go forward/backward often. When I turn the potentiometer to the limit, it doesn't come back to the initial position. I could get some good precision only if I reduce the speed down to 8 RPM.

Have you noticed this?

izanette - I have never tested for precision. However, I would prefer to see programmatic tests without using a potentiometer. For example, running a securely fastened stepper via test software to a set-point position, mechanically marking the position, then pseudo-randomly run the stepper back and forth and finally return to the set-point position and verify its position to the previous mark.

celem:
izanette - I have never tested for precision. However, I would prefer to see programmatic tests without using a potentiometer. For example, running a securely fastened stepper via test software to a set-point position, mechanically marking the position, then pseudo-randomly run the stepper back and forth and finally return to the set-point position and verify its position to the previous mark.

Hi celem,

Yes, I agree that it is better to have some random movements to make it easier for anyone to reproduce the experiment. So, I created this simple sketch:

/*
 * Brownian motion
 *
 * A stepper motor moves forward by randomically chosen steps.
 *
 */

#include <Stepper.h>

// change this to the number of steps on your motor
#define STEPS 2038

// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 8, 10, 9, 11);

// the position of the motor
int pos = 0;

// end of the brownian movement 
boolean finish = false;

void setup()
{
  // set the speed of the motor to 7 RPMs
  // values higher than this leads to lose of steps
  stepper.setSpeed(7);
}

void loop()
{
  if (!finish)
  {
    // choose a value from -5 to 10
    // statistically, it will move forward.
    int movement = random(-5, 10);
    
    stepper.step(movement);

    // saves the position of the motor
    pos += movement;
    
    // finishes when it completes 2 turns
    if (pos > 2 * STEPS)
    {
      finish = true;
      
      // returns to the initial position
      stepper.step(-pos);
    } 
  }
}

Using it, I found out that the speed limit is even lower: 7 RPM. I'm using 4 NiMh batteries to power the motor, they supply about 4.8V. Maybe with a higher voltage it is possible to achieve higher speeds without loosing steps.

That makes sense to me. You can only go 7RPM when you change directions without a delay. You can go 14RPM in one direction. The solution is simple. Go 14RPM, then stop for a short delay before changing directions. It's easy to calculate the delay using 7RPM. It's just twice the delay between steps at 14RPM.

Why not use 12V as in my code? You can change the duty cycle while moving so it never gets warm. Increase it back to 100% for 1 step before and after you change directions. This will give you 30RPM without any delay, even when changing directions. That's 4x faster.