I'm building a positioner servo with a microcontroller and a stepper motor, I need to position the motor in one of 16 positions, the motor needs to turn clockwise only, no reverse.
Any ideas on an efficient way in to C to calculate the number of positions to move forwards, ie if the motor in on position 8 and the next position command is 4, then the motor needs to move 12 positions forwards.
Assuming I have understood the question being asked. Subtract current position from desired position. If the answer is positive move that number of steps. if the answer is negative then subtract the magnitude of the difference from 16. In the mid 1970s I had a similar problem with an antenna tracking system (For the antenna to track radio amateur satellites.) I wanted it to take the shorted direction to move the antenna. For example if the antenne was pointing 350 degrees and the next position was 20 degrees I wanted it to move 30 degrees to the new position. Not 330 degrees.