MC_MoveModulo
The function block MC_MoveModulo is used to execute a positioning operation, which refers to the modulo position of an axis. A modulo rotation is based on the adjustable axis parameter modulo factor (e.g. 360°). A distinction is made between three possible start types, depending on the "Direction" input.
- Positioning in positive direction
- Positioning in negative direction
- Positioning along shortest path
Motion commands can be applied to coupled slave axes, if this option was explicitly activated in the axis parameters. A motion command such as MC_MoveModulo then automatically leads to decoupling of the axis, after which the command is executed. In this case the only available BufferMode is "Aborting".
Starting an axis from standstill
If an axis is started from standstill with MC_MoveModulo , it is possible to specify positions greater than or equal to 360°, in order to perform additional full turns. The same applies to a start with the BufferMode "MC_Buffered".
Starting an axis during motion
If an axis is already in motion, certain special considerations apply. The direction of movement cannot be reversed by MC_MoveModulo, i.e. the target can only be reached in the current direction. The user is not able to specify the number of additional turns. The system automatically calculates how the axis can be moved to the target position on the shortest possible path.
The error output must be analyzed, because under certain conditions an oriented stop is not possible. For example, a standard stop may have been triggered just before, or an oriented stop would cause an active software limit switch to be exceeded. For all fault conditions, the axis is stopped safely, but it may subsequently not be at the required oriented position.
Special cases
Particular attention should be paid to the behavior when requesting one or more complete modulo rotations. If the axis is located at an exact set position, such as 90 degrees, and if positioning to 90 degrees is required, no movement is carried out. If required to turn 450 degrees in a positive direction, it will perform just one rotation. The behavior can be different following an axis reset, because the reset will cause the current actual position to be adopted as the set position. The axis will then no longer be exactly at 90 degrees, but will be a little under or over. These cases will give rise either to a minimum positioning to 90 degrees, or on the other hand a complete rotation.
Depending on the particular case, it may be more effective for complete modulo rotations to calculate the desired target position on the basis of the current absolute position, and then to position using the function block MC_MoveAbsolute.
![]() | Modulo positioning and absolute positioning are available for all axes, irrespective of the modulo setting in the TwinCAT System Manager. For each axis, the current absolute position "SetPos" can be read from the cyclic axis interface data type NCTOPLC_AXIS_REF. |
See also: Notes on modulo positioning
Inputs
VAR_INPUT
Execute : BOOL;
Position : LREAL;
Velocity : LREAL;
Acceleration : LREAL;
Deceleration : LREAL;
Jerk : LREAL;
Direction : MC_Direction;
BufferMode : MC_BufferMode;
Options : ST_MoveOptions;
END_VAR
Name | Type | Description |
---|---|---|
Execute | BOOL | The command is executed with a rising edge. |
Position | LREAL | Modulo target position to be used for positioning. If the axis is started from standstill, positions greater than 360° result in additional turns. Negative positions are not permitted. |
Velocity | LREAL | Maximum travel velocity (>0). |
Acceleration | LREAL | Acceleration (≥0) |
Deceleration | LREAL | Deceleration (≥0) |
Jerk | LREAL | Jerk (≥0) |
Direction | Positive or negative direction of travel. If the axis is started during a motion, the direction may not be reversed. | |
BufferMode | Is evaluated if the axis is already executing another command. MC_MoveModulo becomes active after the current command or aborts it. Transition conditions from the current to the next command are also determined by the BufferMode. A second function block is always required to use the BufferMode. It is not possible to trigger a move function block with new parameters while it is active. | |
Options | Data structure containing additional, rarely used parameters. The input can normally remain open. |
See also: General rules for MC function blocks
Inputs/outputs
VAR_IN_OUT
Axis : AXIS_REF;
END_VAR
Name | Type | Description |
---|---|---|
Axis | Axis data structure that unambiguously addresses an axis in the system. Among other parameters it contains the current axis status, including position, velocity or error state. |
Outputs
VAR_OUTPUT
Done : BOOL;
Busy : BOOL;
Active : BOOL;
CommandAborted : BOOL;
Error : BOOL;
ErrorID : UDINT;
END_VAR
Name | Type | Description |
---|---|---|
Done | BOOL | TRUE when the target position has been reached. |
Busy | BOOL | TRUE as soon as the command is started with "Execute" and as long as the movement command is processed. If "Busy" is FALSE, the function block is ready for a new order. At the same time, one of the outputs "Done", "CommandAborted" or "Error" is set. |
Active | BOOL | Indicates that the command is executed. If the command was buffered, it becomes active once a running command is completed. |
CommandAborted | BOOL | TRUE if the command could not be executed completely. The axis was stopped or the current command was replaced by another Move command. |
Error | BOOL | TRUE, if an error occurs. |
ErrorID | UDINT | If the error output is set, this parameter supplies the error number. |
See also: General rules for MC function blocks
![]() |
|
Requirements
Development environment | Target system type | PLC libraries to include |
---|---|---|
TwinCAT v3.0.0 | PC or CX (x86 or x64) | Tc2_MC2 |