Using the Origin Variable
In servo control applications, the Command and Actual Positions for an Axis are generally used for position error calculations. On each sample, the controller reads the new Actual Positions from the feedback devices and calculates the new Command Positions.
To determine the relationship between Command and Actual Positions for an Axis and physical positions on the machine, you can use the Origin variable (which can be set by the host).
If it is important to set the Command or Actual Position to an exact value, you should use the mpiAxisOriginSet(...) function. Calling mpiAxisOriginSet(...) will modify both Command and Actual Positions by the same amount.
The Origin variable can be set in two different ways depending on the desired result. For example, assume the Command and Actual Positions are 10,000 and 10,024 counts respectively and that the axis is not moving.
Setting the Origin variable to 10,000 will result in Command Position = 0 and Actual Position = 24. Setting the Origin variable to 10,024 will result in Command Position = -24 and Actual Position = 0.
This second method is the most frequently used method for setting the new Origin after homing. Refer to the next table.
Position and Velocity criteria for generating motion completion events
If Command Position = |
If Actual Position |
And you set Origin Variable |
Then Command Position = |
And Actual Position = |
10,000 |
10,024 |
10,000 |
0 |
24 |
10,000 |
10,024 |
10,024 |
-24 |
0 |
Cautions about motion in general:
|
- During motion, you should never call mpiAxis[Actual|Command]PositionSet(...) functions.
- Setting a new Command Position using mpiAxisActualPositionSet(...) should be done with caution, because the controller will immediately try to servo to the new position. If the new and old command positions differ by a large amount the axis may fault (limit error) or jump to the new position at very high speed.
- The effect of mpiAxisOriginSet(...) and mpiAxis[Actual|Command]PositionSet(...) calls will not be seen by the host until the next controller sample following the call.
For example, if you call mpiAxisCommandPositionGet(...) immediately after calling mpiAxisOriginSet(...) or mpiAxisCommandPositionSet(...), mpiAxisCommandPositionGet(...) will probably return the old position values.
- Calling mpiAxisOriginSet() while an axis is in motion will change the final target position's value. This will not change the trajectory however. If the axis was to originally move 5000 counts, then the axis will still move a total of five thousand counts.
Start
Position |
Actual
Position |
End
Position |
Comment |
0 |
0 |
5000 |
The beginning of a 5000 count move, origin currently 0. |
0 |
2500 |
5000 |
Origin is about to be set to 2000. |
-2000 |
500 |
3000 |
Origin has been changed to 2000. |
-2000 |
3000 |
3000 |
Motion is complete. Distance traveled still 5000 counts. |
|
|