A turntable needs to be positioned depending on user input.
This system consists of
a steppermotor driven turntable
a 4x4 keypad for user commands
a rotary encoder for manual tunrtable positioning
a photocell for absolute positioning (calibration to a '0' position)
Below is a sheet with possible turntable scenarios (current position and target position) that must be solved using an algorithm that I have a hard time finding.
some additinal information is required:
scenarios 1 through 3 are "straight through", scenarios 4 & 5 are "reversing"
the user must select a target with prior indication whether it must be "straight through" or "reversing" by using the key '#' (straight) or '*' (reversing), before selecting a target destination. This means that a different algorithm can be used depending on this key choice.
the numbers on the drawings correspond to an actual amount of steppermotor steps (CCW) from a calibrated '0' position.
each position has an index number that corresponds to these number of steps, per position.
the '0' position is obtained by turning the table until a photosensor is reached (CCW).
The solution is far from a simply subtracting of positions: the algorithm must for each case calculate the number of steps, both CW and CCW, and select the shortest route.
EDIT: for algorithm input the only givens are 'target position', 'current position' and total number of steps for a full revolution.
And the algorithm will be different whether a "straight through" path or a "reversing path" is selected.
@DaveX no offence intended but you are kicking an open door. My question relates the contents of the "reversing" and "forward" in your sort-of flowchart.
Besides your proposal negates the contents of my stated prerequisites.
the choice for CW or CCW must be taken by the algorithm
"straight through" means that whatever moves forward (ie "head first", from the current position onto the turntable, is also moving forward "head first" onto the target path.
"reversing" means that whatever is moved from the current position onto the turntable first is turned around 180 degrees, and after turntable positioning, is moved "head last" onto the target position
You can see the little marks at one end of the turntable rotating plate.
In essence, the turntable rotating plate is polarised.
EDIT: "shortes route" is to minimise the time it takes to rotate the turntable from "current" to "target".
in the first scenario going CW = C + R/2 - T = 200 + 1000 - 900 = 300.
Going CCW the rotating table needs to make a full CCW turn (ie F / 2), and subsequentlye move from 200 to 900. Hence, CCW = C + F/2 + abs( T - C) = 200 + 1000 + (900-200) = 1700.
EDIT: remember that the rotating table polarity must be respected. In scenario 1 an item is moved head first onto the rotating tbable and upon exit it must also be head first into position 900.
sorry I've no idea what you mean by polarity or head first or what the item has to do with it.
Also if your algorithm input is only 'target position', 'current position' and total number of steps for a full revolution then I don't see how those matters anyway
" .. and I did not understand what reversed means and how it should be taken into account since you stated it's not an input to the algorithm.." Yes it is: the user either presses # for "straigth move" or * for a reversing move (see scenarios 4 & 5)
ah, I now see the little flag on your drawing and in scenario 5 it ends up flipped (flag was right of the pole at the top and is to the left at the bottom)
first a CCW rotation of 180 degrees: 1000 steps until the square notch on the turntable rotator sits at the opposite end of position "200".
next a further CCW rotation so that the "non-square noth" side of the turntable moves from its position obtained in "1" here above,; alligns with the 900 target position.
Total CCW moves:
1000 steps CCW until the table is turned 180 degrees
another 900 - 200 = 700 steps until the "non-square notch" part of the turntable alligns wioth target 900.
That little square notch is to indicate the polarity of the turntable.
At every intial move, a device moves "head first" onto the rotating table.
The the rotating table must move in such a way, for the "straight" move (not the "inverting or reversing move") that the device (that had been run onto the turntable head first) now also moves "head-first" into the target position.
" ...how can that happen ? is that an object sitting on the turn table ? how do you flip it ? it won't happen by just rotating the table underneath..."
The idea is that an object moves, from the target position, "head-first" onto the rotating table.
If a "non-reversing" button is pressed before a target position is selected, the this object also has to move "head-first" into the target position.
EDIT: the rotating table is exactly what you see as the single diagonal line in the circle. The square noth shows its actual "polarityu".