I am doing absolute positioning using AC servo.I calculated how many steps of pulse are needed for a full rotation of the servo and converted it to degrees between 0-360.
For the current situation.
For example, if the motor is in the zero position, if I give a position in the CW direction. It goes to that degree in the CW direction. There is no problem here.
If the motor is in the 0 position, if I give a negative position, it moves in the CCW direction.
If the motor has moved in the CCW (negative position) direction, if I give a positive position, it will return to the position where it went in the negative direction and switch to the positive position.The method I want to create here is to go to the position given between 0 and 360 from the nearest path, regardless of the negative or positive direction of the motor.
It is completely similar to the logic of a compass, but it has to take the closest path to the given location.I'm trying a few ways, but I can't calculate the shortest path.
I tried to explain a little in the picture below.
Can anyone help with this?