28BYJ-48 5-Volt Stepper

Thank you selem,

did you take the +5V from Nano or separate powersupply?

The nano's supply is inadequate for the stepper. I used a separate 5v supply and just tied the grounds.

@sbright33:
Hi! Do you have a new version of your code? Can you explain better your idea about the angle for motors x, y?

J

My newer library is on another thread here. Many improvements. More coming. PWM to make it smoother. Non-blocking to free up the processor for other tasks. Higher voltage to increase performance without getting hot...

I'd like to move 2 motors called x,y at the same time. Pointing a laser for example. While the laser is on when you go from 0,0 to 10,10 it should move at a 45 degree angle. That's simple just move 1x,1y,1x,1y... until you get to 10. Or move them simultaneously. Not so simple when you're going to 75,80 or an arbitrary x,y. There must be an easy algorithm? I don't know it. Anyone?

sbright33:
There must be an easy algorithm? I don't know it. Anyone?

Fairly simple for 2D stuff (there are tons of implementations out there - it is used for line drawing in 2D graphics); not sure what it would take to add a 3rd stepper (or more). You might also look into the few g-code interpreter implementations for the Arduino that are out there...

Found this; the links still work:

http://www.gamedev.net/topic/536735-bresenham-2d-3d-4d-6d/

BTW - that 6D one looks like it could be easily generalized to N-degrees...

Your first link looks really simple! I like simple.
Only 10 lines of code in the loop. Thanks!
2D is enough.

did that algorithm work for pointing at x,y?

Yes, in my simple experiments. Only 10 lines of code it is easy to follow. I've been sidetracked by a few other projects hope to get back to this. The whole point of Bresenham is to make a straight line while moving to arbitrary x,y.

sbright33:
My newer library is on another thread here. Many improvements. More coming. PWM to make it smoother. Non-blocking to free up the processor for other tasks. Higher voltage to increase performance without getting hot...

Hi sbright33, many thanks for your library. But I cannot find this newer version. Would you mind sharing the link?

I'm glad I found this, because with the standard library 28BYJ was getting very hot an not really behaving well!

I had trouble cobbling the code together from the various bits in this thread. Is there any particular reason to be pasting inline rather than just use a standard code-bin like pastebin or gist? If it helps anyone else, I put the latest version I could find on https://gist.github.com/4149982

The advantage of using something like Gist is that you can update the one file whenever you like and the forum link will always be up to date then.

Please don't take this as any criticism of your excellent library - it's just a newbie asking a newbie question!

Thanks for your compliments and posting my old code on Gist. I can update that site now? Will do it with a few different versions. It has branched off to a few since 2011. One for a bigger motor without gears. One for multiple steppers and servos together non-blocking with scripts. One using PWM. One to detect higher loads when the motor reaches travel limits. I could try to put them all together, or keep them separate. I also have a simple version for beginners which includes running cool and acceleration. This might be a great introduction for new users to understand first before it gets complicated.

sbright33:
Thanks for your compliments and posting my old code on Gist. I can update that site now? Will do it with a few different versions.

Would love to see your new versions! You can't edit my pasted code there, but creating a new account takes less than a minute and is free. You can either "fork" my copy of the code into your account, or just start again. If you want me to now remove my copy of the code I'm happy to delete it and replace it with a link to your new code.

Viewed 6900 times exactly!

sbright33:
Viewed 6900 times exactly!

Indeed. Which shows how popular your library is and how many people would appreciate the updates being made available!

If you have many versions, the other thing you could do would be to create a repository over at github. Then you have versioning and code commenting and people can suggest changes or improvements or bugfixes, they can follow the project and be notified of changes etc.

In fact, Arduino itself lives right there! GitHub - arduino/Arduino: Arduino IDE 1.x

It might look scary to start with, but you'll soon see how easy it is. Create a repo - GitHub Docs

If there's anything I can do to help, please let me know.

According to your link, Step 1 and 2 are on my local machine? But I don't have Linux. How do I do this with windows?
Should I just start with Gist? I get it!

sbright33:
According to your link, Step 1 and 2 are on my local machine? But I don't have Linux. How do I do this with windows?
Should I just start with Gist? I get it!

Yes, you could certainly do everything you wanted with Gist. There's some more setup info and Windows apps at https://github.com/ if you DID want to make a full repository of it, but a Gist (a sort of "github-lite"!) will do perfectly for this.

Edit: Looks like you've already got an account there! sbright33 · GitHub - if there's anything I can do to help get the new versions of the library up, please let me know.

Here it is at last! With new features. Will update Gist from now on.

Please...
Questions? Comments? Requests for new features? Improvements?
Thanks for looking at my code!
Steve

As a learning exercise or tutorial feel free to check out the older version, which is now obsolete.
https://gist.github.com/4149982

Hey, Steve! Great work! Going to bust out some breadboard and have a go later!

Might be an idea to let people know where to get the narcoleptic.h library from: Google Code Archive - Long-term storage for Google Code Project Hosting.

Incidentally, I've just added a note to the top of my old copy to point people to your version of the library.

Thanks again, keep up the good work!

Here's a demonstration of related code I've been working on. It allows the same script format to control both a stepper and servo simultaneously and independently. The script allows you to do motion easing and mechanical animation with Arduino and cheap servos/steppers. It's a work in progress.