Go Down

Topic: 28BYJ-48 5-Volt Stepper (Read 87 times) previous topic - next topic

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.

izanette


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:

Code: [Select]

/*
* 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.

sbright33

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.
If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

vm5ita


Here is the newest version for 28BYJ-48.

https://gist.github.com/sbright33/4178431

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.

For sure there's something that I didn't understood but, after using, with success, the first sketch on this post, I'm trying the last one without obtaining nothing of good. The four red leds on the PCB stay fixed without blinking.
In the setup there's no declaration of potentiometer to drive the motor. Is there something, due to my ignorance, that I miss? Thank You!

harriscreekcentral

I am having trouble.   I found one code that I actually got to work, giving me the 1 RPM.  I have to admit I did not save it and cannot find it again for love nor money.. For some of my previous postings you can refer to # 70 area.  I Have had several other projects that needed my attention thus the delay in getting back to Stepper Motors.

I am wanting to start out fresh, and see if starting with a clean slate gets me on the right track.

I have some (5 sets) new motors and the 2003 drivers that should be on my door step in the next few days.  I also have two of the A4983 driver boards.

My first objective is to load a fresh sketch with code that I know has been proven.  I see several within these pages but am confused as I know zero about reading the codes.  Your direction again to the correct code for the basic forward reverse operation would be greatly appreciated.

Once I get the new motors and boards, I will try to keep my nose to the grind stone until I get this mastered. Thanks so much for your help.


Harvey
in Kelowna, BC

Go Up