Pages: 1 2 [3] 4 5   Go Down
Author Topic: New 28BYJ-48 library  (Read 15720 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I bought one of these steppers with the controller board from ebay for like a dollar just to try to learn how stepper motors work.  Your sketches work very well, better by far than any of the other example sketches I could find.

You asked for suggestions for enhancements.  I'm pretty new to arduino, and electronics in general, so please excuse me if there are obvious answers to any of this.

The first suggestion is for stepper2.pde that you just uploaded, it calls for a library #include <Narcoleptic.h>.  Where can I find the Narcoleptic.h library?

Also in playing with the stepper.pde from your post on Jan 29, I'm having trouble with figuring out parameters for the variables.  For example, in:
void unramp1(boolean bcw, long deg100, int rpm100, int percslow)
What are each of those and what are the appropriate values for them?  I've figured out that bcw is either 0 or 1 and controls cw or ccw rotation.  deg100 is degrees x 100, But what are good values for rpm100, and what is percslow and and it's good values or a range of values?  It started acting funny when I put 2500 in for rpm100, and I didn't try messing with percslow.

The only other thing would be more description of what each subroutine does and how. Changing from unramp1 to unramp really killed the performance and I'm curious what the difference is.

What else can the sketch do?

Thanks!
Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A dollar or 2 is a good price!  Thank you for the compliments.  I tried to make it simple to use.  My coding is a little quirky, that's just me.  You have 2 choices for Narcoleptic.  Sorry about that.  You can search for that word in the code and delete it, I made it easier by putting it on a seperate line.  But then you'll lose the feature.

Or you can Google narcoleptic library and download it.  It's worth the trouble if the motor is moving slow and you want to save battery power.

Both times I uploaded it are about the same code.  I don't think I made any major changes or bug fixes yet.  At the top of this thread is a short one line description of each function and a few variables.  Exactly what you figured out so far is listed there.

rpm100 must be <3500 for my motor using 12v.  That is exactly 35RPM.  3150 is 31.5RPM.  You can experiment to see how slow it goes.  For slow speeds use a function with cool in it, especially with a 12v PS.

2000 is about the fastest you can go with 5v. 

percslow is the %, by distance, that it will go slow at the end of the move.  10 is good to start with.

Would you like to describe what each function does with 1-2 sentences as you learn them?  You can start by expanding the single lines I have already typed at the top of this thread.  I abbreviated the grammar.  This would be helpful for us both.  I will correct any errors you make.  It would be much better to have these comments from a new user.  I am too close to the code.

Changing from unramp1 to unramp killed the maximum speed.  That's exactly what it says at the top listing!  Do you see the differences in the code?  You can change the 100,400 speeds to suit your application.  Don't be afraid to experiment!

I listed many of the features I like at the top of this thread.  Which do you like best so far?

detecting excess torque
detecting loss of torque
non-blocking without interrupts
allows Uno to do other things while spinning
runs cooler with 12v and huge increase in performance
does not use any power between steps, can even sleep 328 chip
does not use any power when stopped
quick ramping in most functions behind the scenes
this allows a much faster speed with mass/load
less bouncing with a large DSLR
restarts after it stalls
choose rpm or rph
move to an absolute position 0-360 (4096)
you can choose the direction to get there or have it calculated for you
you can choose the temperature for your specific application and duty cycle
half stepping
keeps track of error between requested move 2.05 deg and actual move in steps, then does leap steps (like leap year) to keep it spot on
much more...

The next version will do servo easing to make the motion look more human and natural.  It works with servos and/or steppers at the same time.  Up to 6 have been tested without any additional hardware like a regulator, on my cloned board.  It uses data in an array so you can define the easing motion.

I appreciate your feedback.  Especially since you're a new user.

Thanks!
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I found Narcoleptic here: http://code.google.com/p/narcoleptic/downloads/list

I don't know how I missed the first post of the thread, that would have answered a few of my earlier questions.  Sorry about that.  The descriptions there are pretty good.

I didn't get the torque sensing to do anything, but I'm not sure I'm doing it right.  I put a jumper wire from A0 to mp4 (which is D11 on mine).  I called degrpmEZ(0, 72000, 600); in the loop, and held the motor shaft while it was turning and it didn't really seem to do anything.  I stalled the motor and when I let go, it continued on with the loop.

As far as additional features, is there any way to make it find the same start position each time, for example 12 o'clock?  I'm guessing there isn't because there is no reference in a stepper motor?  Unless it would use torque sensing and run one direction until it hits a stop, sense it, and use that as an initial point?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As far as additional features, is there any way to make it find the same start position each time, for example 12 o'clock? 

Just count the steps you are making in a variable, after "x" steps it will always return to the same position (where "x" is the number of steps per 360deg rotation of your stepper).
Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hook a jumper, or better a 4.7k resistor, between A0 and the actual motor winding on the driver board.  The white connector that goes to the motor.  It doesn't matter which of the 4 you choose.  This code is in ccw and ccwss() only not clockwise.  It doesn't immediately respond after reset, it needs time to calibrate while running.  It is forgiving of a few spikes, but not for long.  You can adjust all this in the code starting with line 352.  LED 13 blinks to show the status.

There is no way to know where the motor is when you start it, unless you left it that way the previous run.  Your idea is excellent.  You can detect a stop at the end of a rotation.  Keep in mind it will not give up immediately.  If it's a physically strong stop no harm will be done.  In my case it turns about 100 times as a pulley to pull a string with the DSLR on the end of a track.  I know when it gets to the end no matter how many turns it takes.  Since it's a string I can't make it go back to the other end unless I make a loop of string. 

@nitai most of my move functions already have a variable to count both absolute position, total steps taken, and phase in cycle 1-8. You are welcome to make another if these don't suit your needs, but usually they will.
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm planing to build a full panorama bot like the gigapan epic but only for a small canon 'point and shoot'.
Your code seems perfect for that and i guess you put quite a bit of work into it, so thanks for that!

The problem is that i need to control 2 motors but fortunately they will never run at the same time.
Can i just define mp1-mp4 as variables and switch to other pins during runtime?
Of course i have to define the additional outputs in setup.

Do you think the motors will have enough power to drive my setup(~700gr) directly on 5V or do i need some additional gears?
Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm using this for a large DSLR, Bescor MP-101.
http://www.amazon.com/Bescor-MP101-Video-Motorized-Head/dp/B0000AUR21

Yes, it's as easy as that!  Make them variables.  Make a function to change them.  The only problem you could potentially have, in theory, is when you move the step number on one motor, than switch back to the other.  It will not be where it's supposed to be and will step up to 4 steps to match up with the code.  Sometimes it will move in the wrong direction to do this.  This means it could be off by 8/11th of a degree.  It is also possible to run both at once, non-blocking.  Above I commented how to do this.  It would be better than your solution.  Someday I will make an object so this becomes trivial to accomplish.  You could make 2 variables for current step position, to hold the value when you change motors...

If it does not have enough power, use 12v.  There is no reason to avoid this.  There is no downside.  Unless you plan on running continuously for 15 minutes at the fastest speed possible.  In that case 5v is easier.  Still you can accomplish the same top speed without overheating using 12v.  Don't be afraid, go for it!  You can make 8v by using 6 AA NiMh batteries.  That will give you the fastest possible speed if heat is the limiting factor.  Try it!
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Found your post about the multi-motors (post #24)
That sounds easy enough, i havent really plucked your code yet so i'm looking forward to diving in and learning something 'bout stepper motors along the way

The pano-head you mentioned isn't really what i'm looking for:
1st it's only 180°x30°, i want to make 360x180 panos
2nd it's already built, i'm looking forward to MAKING it as much as using it!  smiley

I was thinking about switching to 12V so i searched for the cheapest eneloops out there but was not really happy about it because i just went to LiPo for my flashlights.
So how 'bout 3 LiPo in series? (3*3.7V = 11.1V)
But i don't dare to mess with LiPos since they can be quite unstable

Then i went on ebay and searched for 12V LiPo and found ebayitem.com/260948675541 or ebayitem.com/350523005066.
Now these look rather nice:
cheaper, more power (even if it has just half the advertised capacity), smaler and should be lighter too

Then i will salvage a car usb charger and can use it as a powerpack for all my devices on a long day out!

But now i am waaaay off topic so i will just wait for the steppers to arrive then play around a bit and decide afterwards how to move on with my project.  smiley-grin
Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's not that easy, sorry.  I'll be here to help you with post 24.  The Bescor is 360x30.  Had to modify it.  You can make many changes and control it with Uno.  It's very hackable.  11v is great!  You can choose any voltage between 8-24.  Just raise the duty cycle until it almost overheats the motor.  I'm using 6xAA for many applications.  12v wall transformer at home.  I hope you can help me improve my code...
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm looking for any feedback on this code I wrote back in January...
Is anybody using it?
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please let me know if you'd like any improvements.  Or if there are bugs or problems.  Any part of the code confusing?  Not sure of the purpose?  I'll explain.
[snip]
I've expanded it to include bigger steppers without a 64:1 gearbox.  You think I just multiplied everything by 64?  Nope.


According to http://arduino.cc/forum/index.php/topic,71964.0.html , the 28BYJ-48 doesn't have a 64:1 gearbox, but a 283712:4455 gearbox. Comments elsewhere appears to confirm this. See for example http://letsmakerobots.com/node/31381?page=1.

Not sure if this has any bearing on your lib or not. I have just started dabbling with arduinos and stuff.

Dag B

Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Occam's Razor.  I believe Stolfa in your link is mistaken.  I have tested my motor and code by rotating 4096 steps 1000 times.  Once even overnight slowly.  It always ends up exactly where it started.  I have measured this by attaching a long pointer like the hand of a clock and marking where it stops on paper.  I conclude that anyone with different results must be making a mistake and skipping steps either thru an error in software or a problem with their hardware.  Could it be a coincidence that my results just happen to come out to exactly 64:1 instead of 283712:4455??? 

Is there a variation of our motors with different gears?

Anyone else?
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I posted my new library on Gist.  Here is the related posting:
http://arduino.cc/forum/index.php/topic,85335.0.html
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your code looks great!
For a beginner, where could I see pictures of the circuit build connecting the motor to an external 12v battery and the arduino? I know its pretty basic but i'm new to this
Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

For those of you asking for help check out the beginning of this post.

Here's a schematic for you Sharon.
http://arduino.cc/en/Reference/StepperUnipolarCircuit
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Pages: 1 2 [3] 4 5   Go Up
Jump to: