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 CIm 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 mailto:shb7@cornell.edu ICQ #: 3329174