Searching \ for '[PICs] Stepper motor control' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=stepper
Search entire site for: 'Stepper motor control'.

Exact match. Not showing close matches.
PICList Thread
'[PICs] Stepper motor control'
1999\10\17@172507 by John De Villiers

flavicon
face
Im turning a large disk with a stepper and a pic.

The gearing that i use gives me several thousand possible stops (steps) in
one revelution of the disk. If the step number of the current point is
known, and the step number of the destination is known, how would i calulate
the shortest route ( clockwise or anti clockwise )??

Lets assume the step number is a 16bit variable.
Also assume that there will always be an equal number of stops.

John

1999\10\17@182225 by Sean H. Breheny

face picon face
A=Total number of steps
B=current step number
C=Destination step number

Let's assume that the step numbers increase clockwise

D = C - B
If ABS(D) < INT(A/2) then Result = D:done
If D > 0 then Result = D - A + 1:done
Result = D + A - 1
done

Where INT means take only the integer part and ABS is the absolute value
function.

Result is the number of steps that need to be taken. If it is positive, go
clockwise. IF negative, go counter clockwise. If zero, stay where you are.

The idea is this: If C>B then you should go clockwise if C-B is less than
half way around (hence the A/2). Otherwise, you should go the other way
around. Similar argument for C<B

Sorry, I don't have time right now to turn this into PIC code,but it should
be easy to do ;-)

Sean

At 11:25 PM 10/17/99 +0200, you wrote:
{Quote hidden}

| Sean Breheny
| Amateur Radio Callsign: KA3YXM
| Electrical Engineering Student
\--------------=----------------
Save lives, please look at http://www.all.org
Personal page: http://www.people.cornell.edu/pages/shb7
spam_OUTshb7TakeThisOuTspamcornell.edu ICQ #: 3329174

1999\10\18@152734 by Lawrence Lile

flavicon
face
Interesting problem, John.

Try this idea:

Say your present position is 1000.  You want to go to 1050.  and the
shortest route is clockwise.

Assume there are 65536 possible positions

1050 - 1000   is less than    65535 - 50.

Therefore,  subtract the present position from the desired postition, and
the desired position from the MAXIMUM number of positions.  the comparison
will give you the shortest route.



{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...