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 CB 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}>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
>

 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_OUTshb7TakeThisOuTcornell.edu ICQ #: 3329174