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

Copy
// 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:

The diagram above illustrates the movement for each command:

Command Start Position Target Position Movement Distance (Direction) Modulo Mode Effect

A

360°

360 % 360 = 0

Since the axis is currently at 0°, no movement occurs.

B

720°

720 % 360 = 0

Since the axis is currently at 0°, no movement occurs.

C

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.