MC_SetPosition
The function block sets the current axis position to a parameterizable value.
In absolute mode, the actual position is set to the parameterized absolute Position value. In relative mode, the actual position is offset by the parameterized Position value. In both cases, the set position of the axis is set so that any potential lag error is retained. The Options.ClearPositionLag
switch can be used to clear the lag error.
Relative mode can be used to change the axis position during the motion.
As of TwinCAT 3.1.4024.51 and Tc2_MC2 3.3.56, the position offset can be deleted and the position can be reset to the originally referenced coordinate system via the Options.ClearPositionOffset
switch. From this version onwards, the offset can also be read via ADS and displayed in the UserData variable of the AXIS_REF structure so that the value is available for the current cycle.
Inputs
VAR_INPUT
Execute : BOOL;
Position : LREAL;
Mode : BOOL; (* RELATIVE=True, ABSOLUTE=False (Default) *)
Options : ST_SetPositionOptions;
END_VAR
Name | Type | Description |
---|---|---|
Execute | BOOL | The command is executed with a rising edge. |
Position | LREAL | Position value that the axis position will be set to. In absolute mode, the actual position is set to this value, in relative mode it is shifted by this value. |
Mode | BOOL | The axis position is set to an absolute value set if Mode = FALSE. Otherwise the axis position is changed relative to the specified Position value. Relative mode can be used for changing the position of an axis during motion. |
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;
Error : BOOL;
ErrorID : UDINT;
END_VAR
Name | Type | Description |
---|---|---|
Done | BOOL | TRUE, if the reset was executed successfully. |
Busy | BOOL | TRUE, as long as the function block is called with Enable = TRUE. |
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
Reading the MC_SetPosition offset
As of TwinCAT 3.1.4024.51, the position offset set by MC_SetPosition can be read out via ADS:
Function | ADS Read | |
Port | 501 (dec) | |
Index Group | 0x4100 + axis ID | 0x5100 + axis ID |
Index Offset | 0x00n10017 | 0x0017 |
Data | REAL64 |
Merging the MC_SetPosition offset into the AXIS_REF
The AXIS_REF axis structure contains a UserData variable that can be configured so that the current value of the MC_SetPosition offset is displayed here from TwinCAT version 3.1.4024.51 onwards. The value is then available for the current cycle.
The UserData variable must be configured as follows via ADS:
Function | ADS Write |
Port | 501 (dec) |
Index Group | 0x4000 + axis ID |
Index Offset | 0x010D |
Data | 0x00000000: Deactivated (default) |
Requirements
Development environment | Target system type | PLC libraries to include |
---|---|---|
TwinCAT v3.0.0 | PC or CX (x86 or x64) | Tc2_MC2 |