Go Down

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

sbright33

I couldn't fit cw and ccw() in the 10k code box limits of the forum.  It is included in the previous version, as well as the original version.  400us works if you ramp up the speed first.  Or just call degrpm(35rpm) it does that for you.  All the relevant speeds are listed in the comments.  I don't see the advantage of PORTB?  DigitalWrite is only microseconds apart which is not significant compared to 400 or 1200us.  Can you go faster than me?  My sketch is compatible with most Arduinos having the relevant ports which you specify at the top.
If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

celem

PORTB's advantage is probably moot, since we are throwing in delays anyway. The only advantage is to eliminate those microseconds of delay when setting two ports simultaneously. However, the difference is not trivial - is about 95 times faster, according to John Boxall's blog: http://tronixstuff.wordpress.com/tag/portb/

However, using PORTx commands introduce a lot of risk, reduces portability and readability and should be avoided unless truly needed.

I just wanted to see if I could get it working and I will NOT be using PORTx for a stepper application.

ajofscott

My point being that sequential turn off of motor windings is the same as a movement command, ergo there is a probability of either a backstep or a forward step as you release control.

sbright33

As you move from 1 step to the next you are only changing 1 winding at a time.  So if it begins to move before the 4th winding is not changed, all the better!  Then there is a delay of 1000x.  When you come to an immediate stop, there is no changes to worry about.  When you turn off the power in my code, the order could be important.  I have not handled this case yet.  You can choose which order to do this in.  If 1-4 then it could in theory move backward.  If 4-1 then maybe forward.  It could not move forward if there is some torque against it.  With the gear ratio of 64:1 nor will it move backwards.  Even if it did move a step 1/11th degree, you're coming to a stop anyway.  When you start up again it will be as if it didn't slip backwards.  It should not effect torque or top speed.  Agree?
If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

celem

#24
Jan 15, 2012, 08:04 pm Last Edit: Jan 15, 2012, 08:06 pm by celem Reason: 1
For those of you interested in greater technical detail on controlling a stepper motor, take a look at Atmel Corp's Application Note  titled "AVR446: Linear speed control of stepper motor". Lots of math there for you number crunchers.   it is an PDF located at:
http://www.atmel.com/dyn/resources/prod_documents/doc8017.pdf

Go Up