Setting the current position using MC_SetPosition
MC_SetPosition is used to set the current position of the selected axis. This function block will set Origin Fix to On if using absolute position value change.
-
LS_Connect and MC_Power must be executed before this function block can be used.
-
The examples in this topic can be found in the XMC_SingleAxis_FBs.zip downloadable from Example Applications.

Element Name | Element Type | Description |
---|---|---|
Execute | Input | Edge detected request to execute the function block. |
Axis | Input/Output | Axis reference variable. This can not be a constant. |
Position | Input | Specify the current position of the axis. |
Relative | Input |
|
ExecutionMode | Input |
|
Done | Output | Indicates the inputted torque value and current operating torque value are equal. |
Busy | Output | Indicates the function block is currently being executed. |
CommandAborted | Output | Indicates the function block was aborted. |
Error | Output | Indicates whether an error occurs or not. |
ErrorID | Output | Error Identification number |

Before executing MC_SetPosition
After executing MC_SetPosition

//Set axis reference
Axis1 := 1;
IF (_AX01_RDY) AND (_AX01_SV_ON) THEN
//Example MC_SetPosition fb
INST_SETPOSITION(Execute:=Execute_SetPosition, Axis:=Axis1,
Position:=INST_SETPOSITION.Position,
Relative:=INST_SETPOSITION.Relative,
ExecutionMode:=INST_SETPOSITION.ExecutionMode,
ErrorID=>INST_SETPOSITION.ErrorID);
END_IF;
LM516