Modulo Axis
Modulo axis positioning is a motion control method used for rotary axes where positions repeat after a full cycle. In a rotary axis with a modulo range of 0° to 360°, if the axis moves past 360°, the position resets to 0° instead of continuing to 361°. Similarly, moving backward past 0° would wrap around to 359° instead of going to -1°.
NOTE: Starting with KS 4.5.2, modulo axis is supported.
KINGSTAR Modulo Axis Example
// MoveAxisAbsolute, shortest path
KsCommandStatus moveCommand{};
KsCommandStatus setParaCmd{};
KsCommandStatus setPosOffsetCmd{};
setParaCmd = SetAxisParameter(TargetAxis, McAxisParameter::mcModuloAxisValue, 360, McExecutionMode::mcImmediately);
setParaCmd = WaitForCommand(10, true, setParaCmd);
setParaCmd = SetAxisParameter(TargetAxis, McAxisParameter::mcEnableModuloAxis, TRUE, McExecutionMode::mcImmediately);
setParaCmd = WaitForCommand(10, true, setParaCmd);
setPosOffsetCmd = SetAxisPositionOffset(TargetAxis, 0, FALSE, McExecutionMode::mcImmediately);
setPosOffsetCmd = WaitForCommand(10, true, setPosOffsetCmd)
moveCommand = MoveAxisAbsolute(TargetAxis, 360, 360, 3600, 3600, 360000, McDirection::mcShortestWay, McBufferMode::mcBuffered); // A
moveCommand = MoveAxisAbsolute(TargetAxis, 720, 360, 3600, 3600, 360000, McDirection::mcShortestWay, McBufferMode::mcBuffered); // B
moveCommand = MoveAxisAbsolute(TargetAxis, 60, 360, 3600, 3600, 360000, McDirection::mcShortestWay, McBufferMode::mcBuffered); // C
moveCommand = MoveAxisAbsolute(TargetAxis, 340, 360, 3600, 3600, 360000, McDirection::mcShortestWay, McBufferMode::mcBuffered); // D
moveCommand = MoveAxisAbsolute(TargetAxis, 90, 360, 3600, 3600, 360000, McDirection::mcShortestWay, McBufferMode::mcBuffered); // E
This code example configures and controls a modulo rotary axis in a motion control system by:
- Configuring the axis as a modulo axis by assigning a modulo axis value of 360 and enabling modulo axis.
- Commanding the axis to move to five absolute positions using MoveAxisAbsolute, ensuring the shortest path is taken.
The diagram above illustrates the movement for each command:
Command | Start Position | Target Position | Movement Distance (Direction) | Modulo Mode Effect |
---|---|---|---|---|
A |
0° |
360° |
0° |
360 % 360 = 0 Since the axis is currently at 0°, no movement occurs. |
B |
0° |
720° |
0° |
720 % 360 = 0 Since the axis is currently at 0°, no movement occurs. |
C |
0° |
60° |
60° (Positive) |
60 % 360 = 60 The axis is currently at 0°, and the shortest way to 60° is moving 60° in the positive direction. If it moves in the negative direction, it would travel 300°, which is much longer. |
D |
60° |
340° |
80° (Negative) |
340 % 360 = 340 The axis is currently at 60°, and the shortest way to 340° is moving 80° in the negative direction. If it moves in the positive direction, it would travel 280°, which is much longer. |
E |
340° |
90° |
110° (Positive) |
90 % 360 = 90 The axis is currently at 340°, and the shortest way to 90° is moving 110° in the positive direction. If it moves in the negative direction, it would travel 250°, which is much longer. |
KINGSTAR Modulo Axis
The content in this section includes information you should know about modulo axis in KINGSTAR.
- To configure KINGSTAR modulo axis, use the mcEnableModuloAxis and mcModuloAxisValue parameters.
- For RT/Win32, see McAxisParameter
- For .NET, see McAxisParameter
- When modulo axis is enabled, position input and output in the following APIs will be converted to modulo position:
- Position input:
- SetAxisPosition
- SetAxisPositionOffset, when absolute mode is used
- SetAxisParameter, mcSoftLimitPositive/mcSoftwareLimitPositive/mcSoftLimitNegative/mcSoftwareLimitNegative
- SetAxisTouchProbe
- SetAxisCamSwitch
- MoveAxisAbsolute
- SimulateAxisAbsolute
- MoveAxisContinuousAbsolute
- SetAxisGearInPos, MasterSyncPosition
- UpdateCommand
- Position output:
- Position input:
- When modulo axis is enabled, distance input in the following APIs will NOT be converted with the modulo settings:
- When modulo axis is enabled, position input in the following APIs will NOT be affected by the modulo settings:
- SetAxisCyclicSwitch
- SetAxisCam
- SetTrigger (users are responsible for converting the trigger value to a modulo value)
- The Group motion APIs can't be used with modulo axis.
- Properties of converted modulo value:
- The converted modulo value is always positive (0, modulo_value]. For example, assume the modulo value is set to 360. If a user commands a target position of -20, KINGSTAR will interpret it as 340.
- The default modulo value is UINT_MAX.
- No error is returned when a positive or distance command exceeds the modulo range.
- When the axis is at position 0 (modulo_value), the actual position may drift slightly away from 0. For example, assume the modulo value is set to 360. If a position is drifting by -0.001, the user will get a position of 359.999.
- Drive's modulo feature:
- It is not recommended to enable the drive's modulo feature, as drives should be recognized as linear axes.
- Take Sanyodenki's RS3 as an example, the drive's modulo feature relies on 0x607B (CiA), which is an optional object that is not guaranteed to be present.
- If users still want to use the drive's modulo feature, we recommend that users:
- Turn off the KINGSTAR modulo axis.
- Maintain the modulo position on their own.
- It is not recommended to enable the drive's modulo feature, as drives should be recognized as linear axes.